FFmpeg
dhav.c
Go to the documentation of this file.
1 /*
2  * DHAV demuxer
3  *
4  * Copyright (c) 2018 Paul B Mahol
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavutil/parseutils.h"
24 #include "avio_internal.h"
25 #include "avformat.h"
26 #include "internal.h"
27 
28 typedef struct DHAVContext {
29  unsigned type;
30  unsigned subtype;
31  unsigned channel;
32  unsigned frame_subnumber;
33  unsigned frame_number;
34  unsigned date;
35  unsigned timestamp;
36  int width, height;
42  int64_t last_good_pos;
43  int64_t duration;
44 
47 } DHAVContext;
48 
49 typedef struct DHAVStream {
50  int64_t last_timestamp;
51  int64_t last_time;
52  int64_t pts;
53 } DHAVStream;
54 
55 static int dhav_probe(const AVProbeData *p)
56 {
57  if (!memcmp(p->buf, "DAHUA", 5))
58  return AVPROBE_SCORE_MAX;
59 
60  if (memcmp(p->buf, "DHAV", 4))
61  return 0;
62 
63  if (p->buf[4] == 0xf0 ||
64  p->buf[4] == 0xf1 ||
65  p->buf[4] == 0xfc ||
66  p->buf[4] == 0xfd)
67  return AVPROBE_SCORE_MAX;
68  return 0;
69 }
70 
71 static const uint32_t sample_rates[] = {
72  8000, 4000, 8000, 11025, 16000,
73  20000, 22050, 32000, 44100, 48000,
74  96000, 192000, 64000,
75 };
76 
77 static int parse_ext(AVFormatContext *s, int length)
78 {
79  DHAVContext *dhav = s->priv_data;
80  int index, ret = 0;
81 
82  while (length > 0) {
83  int type = avio_r8(s->pb);
84 
85  switch (type) {
86  case 0x80:
87  ret = avio_skip(s->pb, 1);
88  dhav->width = 8 * avio_r8(s->pb);
89  dhav->height = 8 * avio_r8(s->pb);
90  length -= 4;
91  break;
92  case 0x81:
93  ret = avio_skip(s->pb, 1);
94  dhav->video_codec = avio_r8(s->pb);
95  dhav->frame_rate = avio_r8(s->pb);
96  length -= 4;
97  break;
98  case 0x82:
99  ret = avio_skip(s->pb, 3);
100  dhav->width = avio_rl16(s->pb);
101  dhav->height = avio_rl16(s->pb);
102  length -= 8;
103  break;
104  case 0x83:
105  dhav->audio_channels = avio_r8(s->pb);
106  dhav->audio_codec = avio_r8(s->pb);
107  index = avio_r8(s->pb);
108  if (index < FF_ARRAY_ELEMS(sample_rates)) {
109  dhav->sample_rate = sample_rates[index];
110  } else {
111  dhav->sample_rate = 8000;
112  }
113  length -= 4;
114  break;
115  case 0x88:
116  ret = avio_skip(s->pb, 7);
117  length -= 8;
118  break;
119  case 0x8c:
120  ret = avio_skip(s->pb, 1);
121  dhav->audio_channels = avio_r8(s->pb);
122  dhav->audio_codec = avio_r8(s->pb);
123  index = avio_r8(s->pb);
124  if (index < FF_ARRAY_ELEMS(sample_rates)) {
125  dhav->sample_rate = sample_rates[index];
126  } else {
127  dhav->sample_rate = 8000;
128  }
129  ret = avio_skip(s->pb, 3);
130  length -= 8;
131  break;
132  case 0x91:
133  case 0x92:
134  case 0x93:
135  case 0x95:
136  case 0x9a:
137  case 0x9b: // sample aspect ratio
138  case 0xb3:
139  ret = avio_skip(s->pb, 7);
140  length -= 8;
141  break;
142  case 0x84:
143  case 0x85:
144  case 0x8b:
145  case 0x94:
146  case 0x96:
147  case 0xa0:
148  case 0xb2:
149  case 0xb4:
150  ret = avio_skip(s->pb, 3);
151  length -= 4;
152  break;
153  default:
154  av_log(s, AV_LOG_INFO, "Unknown type: %X, skipping rest of header.\n", type);
155  ret = avio_skip(s->pb, length - 1);
156  length = 0;
157  }
158 
159  if (ret < 0)
160  return ret;
161  }
162 
163  return 0;
164 }
165 
167 {
168  DHAVContext *dhav = s->priv_data;
169  int frame_length, ext_length;
170  int64_t start, end;
171  int ret;
172 
173  if (avio_feof(s->pb))
174  return AVERROR_EOF;
175 
176  while (avio_r8(s->pb) != 'D' || avio_r8(s->pb) != 'H' || avio_r8(s->pb) != 'A' || avio_r8(s->pb) != 'V') {
177  if (avio_feof(s->pb))
178  return AVERROR_EOF;
179  }
180 
181  start = avio_tell(s->pb) - 4;
182  dhav->last_good_pos = start;
183  dhav->type = avio_r8(s->pb);
184  dhav->subtype = avio_r8(s->pb);
185  dhav->channel = avio_r8(s->pb);
186  dhav->frame_subnumber = avio_r8(s->pb);
187  dhav->frame_number = avio_rl32(s->pb);
188  frame_length = avio_rl32(s->pb);
189  dhav->date = avio_rl32(s->pb);
190 
191  if (frame_length < 24)
192  return AVERROR_INVALIDDATA;
193  if (dhav->type == 0xf1) {
194  ret = avio_skip(s->pb, frame_length - 20);
195  return ret < 0 ? ret : 0;
196  }
197 
198  dhav->timestamp = avio_rl16(s->pb);
199  ext_length = avio_r8(s->pb);
200  avio_skip(s->pb, 1); // checksum
201 
202  ret = parse_ext(s, ext_length);
203  if (ret < 0)
204  return ret;
205 
206  end = avio_tell(s->pb);
207 
208  return frame_length - 8 - (end - start);
209 }
210 
211 static void get_timeinfo(unsigned date, struct tm *timeinfo)
212 {
213  int year, month, day, hour, min, sec;
214 
215  sec = date & 0x3F;
216  min = (date >> 6) & 0x3F;
217  hour = (date >> 12) & 0x1F;
218  day = (date >> 17) & 0x1F;
219  month = (date >> 22) & 0x0F;
220  year = ((date >> 26) & 0x3F) + 2000;
221 
222  timeinfo->tm_year = year - 1900;
223  timeinfo->tm_mon = month - 1;
224  timeinfo->tm_mday = day;
225  timeinfo->tm_hour = hour;
226  timeinfo->tm_min = min;
227  timeinfo->tm_sec = sec;
228 }
229 
231 {
232  DHAVContext *dhav = s->priv_data;
233  int64_t start_pos = avio_tell(s->pb);
234  int64_t start = 0, end = 0;
235  struct tm timeinfo;
236 
237  if (!s->pb->seekable)
238  return 0;
239 
240  avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET);
241  if (avio_rl32(s->pb) == MKTAG('d','h','a','v')) {
242  int seek_back = avio_rl32(s->pb);
243 
244  avio_seek(s->pb, -seek_back, SEEK_CUR);
245  read_chunk(s);
246  get_timeinfo(dhav->date, &timeinfo);
247  end = av_timegm(&timeinfo) * 1000LL;
248  } else {
249  avio_seek(s->pb, start_pos, SEEK_SET);
250  return 0;
251  }
252 
253  avio_seek(s->pb, start_pos, SEEK_SET);
254 
255  read_chunk(s);
256  get_timeinfo(dhav->date, &timeinfo);
257  start = av_timegm(&timeinfo) * 1000LL;
258 
259  avio_seek(s->pb, start_pos, SEEK_SET);
260 
261  return end - start;
262 }
263 
265 {
266  DHAVContext *dhav = s->priv_data;
267  uint8_t signature[5];
268 
269  ffio_ensure_seekback(s->pb, 5);
270  avio_read(s->pb, signature, sizeof(signature));
271  if (!memcmp(signature, "DAHUA", 5)) {
272  avio_skip(s->pb, 0x400 - 5);
273  dhav->last_good_pos = avio_tell(s->pb);
274  } else {
275  if (!memcmp(signature, "DHAV", 4)) {
276  avio_seek(s->pb, -5, SEEK_CUR);
277  dhav->last_good_pos = avio_tell(s->pb);
278  } else if (s->pb->seekable) {
279  avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET);
280  while (avio_rl32(s->pb) == MKTAG('d','h','a','v')) {
281  int seek_back;
282 
283  seek_back = avio_rl32(s->pb) + 8;
284  if (seek_back < 9)
285  break;
286  dhav->last_good_pos = avio_tell(s->pb);
287  avio_seek(s->pb, -seek_back, SEEK_CUR);
288  }
289  avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
290  }
291  }
292 
293  dhav->duration = get_duration(s);
294  dhav->last_good_pos = avio_tell(s->pb);
296  dhav->video_stream_index = -1;
297  dhav->audio_stream_index = -1;
298 
299  return 0;
300 }
301 
302 static int64_t get_pts(AVFormatContext *s, int stream_index)
303 {
304  DHAVStream *dst = s->streams[stream_index]->priv_data;
305  DHAVContext *dhav = s->priv_data;
306  struct tm timeinfo;
307  time_t t;
308 
309  get_timeinfo(dhav->date, &timeinfo);
310 
311  t = av_timegm(&timeinfo);
312  if (dst->last_time == t) {
313  int64_t diff = dhav->timestamp - dst->last_timestamp;
314 
315  if (diff < 0)
316  diff += 65535;
317  dst->pts += diff;
318  } else {
319  dst->pts = t * 1000LL;
320  }
321 
322  dst->last_time = t;
323  dst->last_timestamp = dhav->timestamp;
324 
325  return dst->pts;
326 }
327 
329 {
330  DHAVContext *dhav = s->priv_data;
331  int size, ret, stream_index;
332 
333 retry:
334  while ((ret = read_chunk(s)) == 0)
335  ;
336 
337  if (ret < 0)
338  return ret;
339 
340  if (dhav->type == 0xfd && dhav->video_stream_index == -1) {
342  DHAVStream *dst;
343 
344  if (!st)
345  return AVERROR(ENOMEM);
346 
348  switch (dhav->video_codec) {
349  case 0x1: st->codecpar->codec_id = AV_CODEC_ID_MPEG4; break;
350  case 0x3: st->codecpar->codec_id = AV_CODEC_ID_MJPEG; break;
351  case 0x2:
352  case 0x4:
353  case 0x8: st->codecpar->codec_id = AV_CODEC_ID_H264; break;
354  case 0xc: st->codecpar->codec_id = AV_CODEC_ID_HEVC; break;
355  default: avpriv_request_sample(s, "Unknown video codec %X", dhav->video_codec);
356  }
357  st->duration = dhav->duration;
358  st->codecpar->width = dhav->width;
359  st->codecpar->height = dhav->height;
360  st->avg_frame_rate.num = dhav->frame_rate;
361  st->avg_frame_rate.den = 1;
362  st->priv_data = dst = av_mallocz(sizeof(DHAVStream));
363  if (!st->priv_data)
364  return AVERROR(ENOMEM);
365  dst->last_time = AV_NOPTS_VALUE;
366  dhav->video_stream_index = st->index;
367 
368  avpriv_set_pts_info(st, 64, 1, 1000);
369  } else if (dhav->type == 0xf0 && dhav->audio_stream_index == -1) {
371  DHAVStream *dst;
372 
373  if (!st)
374  return AVERROR(ENOMEM);
375 
377  switch (dhav->audio_codec) {
378  case 0x07: st->codecpar->codec_id = AV_CODEC_ID_PCM_S8; break;
379  case 0x0c: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; break;
380  case 0x10: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; break;
381  case 0x0a: st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW; break;
382  case 0x16: st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW; break;
383  case 0x0e: st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW; break;
384  case 0x1a: st->codecpar->codec_id = AV_CODEC_ID_AAC; break;
385  case 0x1f: st->codecpar->codec_id = AV_CODEC_ID_MP2; break;
386  case 0x21: st->codecpar->codec_id = AV_CODEC_ID_MP3; break;
387  case 0x0d: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_MS; break;
388  default: avpriv_request_sample(s, "Unknown audio codec %X", dhav->audio_codec);
389  }
390  st->duration = dhav->duration;
391  st->codecpar->channels = dhav->audio_channels;
392  st->codecpar->sample_rate = dhav->sample_rate;
393  st->priv_data = dst = av_mallocz(sizeof(DHAVStream));
394  if (!st->priv_data)
395  return AVERROR(ENOMEM);
396  dst->last_time = AV_NOPTS_VALUE;
397  dhav->audio_stream_index = st->index;
398 
399  avpriv_set_pts_info(st, 64, 1, 1000);
400  }
401 
402  stream_index = dhav->type == 0xf0 ? dhav->audio_stream_index : dhav->video_stream_index;
403  if (stream_index < 0) {
404  avio_skip(s->pb, ret);
405  if (avio_rl32(s->pb) == MKTAG('d','h','a','v'))
406  avio_skip(s->pb, 4);
407  goto retry;
408  }
409 
410  size = ret;
411  ret = av_get_packet(s->pb, pkt, size);
412  if (ret < 0)
413  return ret;
414  pkt->stream_index = stream_index;
415  if (dhav->type != 0xfc)
416  pkt->flags |= AV_PKT_FLAG_KEY;
417  pkt->duration = 1;
418  if (pkt->stream_index >= 0)
419  pkt->pts = get_pts(s, pkt->stream_index);
420  pkt->pos = dhav->last_good_pos;
421  if (avio_rl32(s->pb) == MKTAG('d','h','a','v'))
422  avio_skip(s->pb, 4);
423 
424  return ret;
425 }
426 
427 static int dhav_read_seek(AVFormatContext *s, int stream_index,
428  int64_t timestamp, int flags)
429 {
430  DHAVContext *dhav = s->priv_data;
431  AVStream *st = s->streams[stream_index];
432  int index = av_index_search_timestamp(st, timestamp, flags);
433  int64_t pts;
434 
435  if (index < 0)
436  return -1;
437  if (avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET) < 0)
438  return -1;
439 
441 
442  for (int n = 0; n < s->nb_streams; n++) {
443  AVStream *st = s->streams[n];
444  DHAVStream *dst = st->priv_data;
445 
446  dst->pts = pts;
447  dst->last_time = AV_NOPTS_VALUE;
448  }
449  dhav->last_good_pos = avio_tell(s->pb);
450 
451  return 0;
452 }
453 
455  .name = "dhav",
456  .long_name = NULL_IF_CONFIG_SMALL("Video DAV"),
457  .priv_data_size = sizeof(DHAVContext),
462  .extensions = "dav",
464 };
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
Definition: parseutils.c:568
#define NULL
Definition: coverity.c:32
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:346
int64_t last_time
Definition: dhav.c:51
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:383
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4899
int64_t pos
Definition: avformat.h:809
#define avpriv_request_sample(...)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:153
static int read_chunk(AVFormatContext *s)
Definition: dhav.c:166
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
int num
Numerator.
Definition: rational.h:59
int index
stream index in AVFormatContext
Definition: avformat.h:881
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:253
GLint GLenum type
Definition: opengl_enc.c:104
void * priv_data
Definition: avformat.h:895
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:341
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:237
static AVPacket pkt
static const uint32_t sample_rates[]
Definition: dhav.c:71
int ctx_flags
Flags signalling stream properties.
Definition: avformat.h:1288
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:472
Format I/O context.
Definition: avformat.h:1239
unsigned channel
Definition: dhav.c:31
static const char signature[]
Definition: ipmovie.c:615
uint8_t
int width
Video only.
Definition: codec_par.h:126
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition: avformat.h:1183
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:92
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:381
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4480
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1307
unsigned date
Definition: dhav.c:34
#define AVERROR_EOF
End of file.
Definition: error.h:55
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition: utils.c:310
ptrdiff_t size
Definition: opengl_enc.c:100
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
static void seek_back(AVFormatContext *s, AVIOContext *pb, int64_t pos)
Definition: mpegts.c:3053
#define av_log(a,...)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:637
static int dhav_read_header(AVFormatContext *s)
Definition: dhav.c:264
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:401
unsigned subtype
Definition: dhav.c:30
int64_t last_timestamp
Definition: dhav.c:50
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:2106
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition: avformat.h:464
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:754
unsigned type
Definition: dhav.c:29
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
Definition: avformat.h:810
int64_t pts
Definition: dhav.c:52
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:115
int audio_channels
Definition: dhav.c:39
static int dhav_probe(const AVProbeData *p)
Definition: dhav.c:55
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:422
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
GLsizei GLsizei * length
Definition: opengl_enc.c:114
int video_codec
Definition: dhav.c:37
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:953
AVInputFormat ff_dhav_demuxer
Definition: dhav.c:454
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:369
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:628
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:443
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:228
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1295
unsigned timestamp
Definition: dhav.c:35
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:260
static void get_timeinfo(unsigned date, struct tm *timeinfo)
Definition: dhav.c:211
static int dhav_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: dhav.c:328
int64_t duration
Definition: dhav.c:43
#define s(width, name)
Definition: cbs_vp9.c:257
int video_stream_index
Definition: dhav.c:45
int width
Definition: dhav.c:36
#define FF_ARRAY_ELEMS(a)
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
Stream structure.
Definition: avformat.h:880
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
#define AV_LOG_INFO
Standard information.
Definition: log.h:205
AVStreamInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1119
AVIOContext * pb
I/O context.
Definition: avformat.h:1281
static int dhav_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: dhav.c:427
unsigned frame_number
Definition: dhav.c:33
int64_t last_good_pos
Definition: dhav.c:42
int sample_rate
Definition: dhav.c:41
int index
Definition: gxfenc.c:89
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:463
This structure contains the data a format has to probe a file.
Definition: avformat.h:441
misc parsing utilities
static int64_t pts
#define flags(name, subs,...)
Definition: cbs_av1.c:561
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
static int64_t get_pts(AVFormatContext *s, int stream_index)
Definition: dhav.c:302
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition: aviobuf.c:1002
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:929
int sample_rate
Audio only.
Definition: codec_par.h:170
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:453
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:738
Main libavformat public API header.
int den
Denominator.
Definition: rational.h:60
int audio_stream_index
Definition: dhav.c:46
unsigned frame_subnumber
Definition: dhav.c:32
static av_always_inline int diff(const uint32_t a, const uint32_t b)
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition: avformat.h:470
void * priv_data
Format private data.
Definition: avformat.h:1267
int audio_codec
Definition: dhav.c:40
int height
Definition: dhav.c:36
int channels
Audio only.
Definition: codec_par.h:166
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:652
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1045
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:368
int stream_index
Definition: packet.h:365
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#define MKTAG(a, b, c, d)
Definition: common.h:405
int frame_rate
Definition: dhav.c:38
float min
This structure stores compressed data.
Definition: packet.h:340
static int parse_ext(AVFormatContext *s, int length)
Definition: dhav.c:77
static int64_t get_duration(AVFormatContext *s)
Definition: dhav.c:230
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:356
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248