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 {
51  int64_t last_timestamp;
52  int64_t last_time;
53  int64_t pts;
54 } DHAVStream;
55 
56 static int dhav_probe(const AVProbeData *p)
57 {
58  if (!memcmp(p->buf, "DAHUA", 5))
59  return AVPROBE_SCORE_MAX;
60 
61  if (memcmp(p->buf, "DHAV", 4))
62  return 0;
63 
64  if (p->buf[4] == 0xf0 ||
65  p->buf[4] == 0xf1 ||
66  p->buf[4] == 0xfc ||
67  p->buf[4] == 0xfd)
68  return AVPROBE_SCORE_MAX;
69  return 0;
70 }
71 
72 static const uint32_t sample_rates[] = {
73  8000, 4000, 8000, 11025, 16000,
74  20000, 22050, 32000, 44100, 48000,
75  96000, 192000, 64000,
76 };
77 
78 static int parse_ext(AVFormatContext *s, int length)
79 {
80  DHAVContext *dhav = s->priv_data;
81  int index, ret = 0;
82 
83  while (length > 0) {
84  int type = avio_r8(s->pb);
85 
86  switch (type) {
87  case 0x80:
88  ret = avio_skip(s->pb, 1);
89  dhav->width = 8 * avio_r8(s->pb);
90  dhav->height = 8 * avio_r8(s->pb);
91  length -= 4;
92  break;
93  case 0x81:
94  ret = avio_skip(s->pb, 1);
95  dhav->video_codec = avio_r8(s->pb);
96  dhav->frame_rate = avio_r8(s->pb);
97  length -= 4;
98  break;
99  case 0x82:
100  ret = avio_skip(s->pb, 3);
101  dhav->width = avio_rl16(s->pb);
102  dhav->height = avio_rl16(s->pb);
103  length -= 8;
104  break;
105  case 0x83:
106  dhav->audio_channels = avio_r8(s->pb);
107  dhav->audio_codec = avio_r8(s->pb);
108  index = avio_r8(s->pb);
110  dhav->sample_rate = sample_rates[index];
111  } else {
112  dhav->sample_rate = 8000;
113  }
114  length -= 4;
115  break;
116  case 0x88:
117  ret = avio_skip(s->pb, 7);
118  length -= 8;
119  break;
120  case 0x8c:
121  ret = avio_skip(s->pb, 1);
122  dhav->audio_channels = avio_r8(s->pb);
123  dhav->audio_codec = avio_r8(s->pb);
124  index = avio_r8(s->pb);
126  dhav->sample_rate = sample_rates[index];
127  } else {
128  dhav->sample_rate = 8000;
129  }
130  ret = avio_skip(s->pb, 3);
131  length -= 8;
132  break;
133  case 0x91:
134  case 0x92:
135  case 0x93:
136  case 0x95:
137  case 0x9a:
138  case 0x9b: // sample aspect ratio
139  case 0xb3:
140  ret = avio_skip(s->pb, 7);
141  length -= 8;
142  break;
143  case 0x84:
144  case 0x85:
145  case 0x8b:
146  case 0x94:
147  case 0x96:
148  case 0xa0:
149  case 0xb2:
150  case 0xb4:
151  ret = avio_skip(s->pb, 3);
152  length -= 4;
153  break;
154  default:
155  av_log(s, AV_LOG_INFO, "Unknown type: %X, skipping rest of header.\n", type);
156  ret = avio_skip(s->pb, length - 1);
157  length = 0;
158  }
159 
160  if (ret < 0)
161  return ret;
162  }
163 
164  return 0;
165 }
166 
168 {
169  DHAVContext *dhav = s->priv_data;
170  int frame_length, ext_length;
171  int64_t start, end;
172  int ret;
173 
174  if (avio_feof(s->pb))
175  return AVERROR_EOF;
176 
177  while (avio_r8(s->pb) != 'D' || avio_r8(s->pb) != 'H' || avio_r8(s->pb) != 'A' || avio_r8(s->pb) != 'V') {
178  if (avio_feof(s->pb))
179  return AVERROR_EOF;
180  }
181 
182  start = avio_tell(s->pb) - 4;
183  dhav->last_good_pos = start;
184  dhav->type = avio_r8(s->pb);
185  dhav->subtype = avio_r8(s->pb);
186  dhav->channel = avio_r8(s->pb);
187  dhav->frame_subnumber = avio_r8(s->pb);
188  dhav->frame_number = avio_rl32(s->pb);
189  frame_length = avio_rl32(s->pb);
190  dhav->date = avio_rl32(s->pb);
191 
192  if (frame_length < 24)
193  return AVERROR_INVALIDDATA;
194  if (dhav->type == 0xf1) {
195  ret = avio_skip(s->pb, frame_length - 20);
196  return ret < 0 ? ret : 0;
197  }
198 
199  dhav->timestamp = avio_rl16(s->pb);
200  ext_length = avio_r8(s->pb);
201  avio_skip(s->pb, 1); // checksum
202 
203  ret = parse_ext(s, ext_length);
204  if (ret < 0)
205  return ret;
206 
207  end = avio_tell(s->pb);
208 
209  return frame_length - 8 - (end - start);
210 }
211 
212 static void get_timeinfo(unsigned date, struct tm *timeinfo)
213 {
214  int year, month, day, hour, min, sec;
215 
216  sec = date & 0x3F;
217  min = (date >> 6) & 0x3F;
218  hour = (date >> 12) & 0x1F;
219  day = (date >> 17) & 0x1F;
220  month = (date >> 22) & 0x0F;
221  year = ((date >> 26) & 0x3F) + 2000;
222 
223  timeinfo->tm_year = year - 1900;
224  timeinfo->tm_mon = month - 1;
225  timeinfo->tm_mday = day;
226  timeinfo->tm_hour = hour;
227  timeinfo->tm_min = min;
228  timeinfo->tm_sec = sec;
229 }
230 
232 {
233  DHAVContext *dhav = s->priv_data;
234  int64_t start_pos = avio_tell(s->pb);
235  int64_t start = 0, end = 0;
236  struct tm timeinfo;
237 
238  if (!s->pb->seekable)
239  return 0;
240 
241  avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET);
242  if (avio_rl32(s->pb) == MKTAG('d','h','a','v')) {
243  int seek_back = avio_rl32(s->pb);
244 
245  avio_seek(s->pb, -seek_back, SEEK_CUR);
246  read_chunk(s);
247  get_timeinfo(dhav->date, &timeinfo);
248  end = av_timegm(&timeinfo) * 1000LL;
249  } else {
250  avio_seek(s->pb, start_pos, SEEK_SET);
251  return 0;
252  }
253 
254  avio_seek(s->pb, start_pos, SEEK_SET);
255 
256  read_chunk(s);
257  get_timeinfo(dhav->date, &timeinfo);
258  start = av_timegm(&timeinfo) * 1000LL;
259 
260  avio_seek(s->pb, start_pos, SEEK_SET);
261 
262  return end - start;
263 }
264 
266 {
267  DHAVContext *dhav = s->priv_data;
268  uint8_t signature[5];
269 
270  ffio_ensure_seekback(s->pb, 5);
271  avio_read(s->pb, signature, sizeof(signature));
272  if (!memcmp(signature, "DAHUA", 5)) {
273  avio_skip(s->pb, 0x400 - 5);
274  dhav->last_good_pos = avio_tell(s->pb);
275  } else {
276  if (!memcmp(signature, "DHAV", 4)) {
277  avio_seek(s->pb, -5, SEEK_CUR);
278  dhav->last_good_pos = avio_tell(s->pb);
279  } else if (s->pb->seekable) {
280  avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET);
281  while (avio_rl32(s->pb) == MKTAG('d','h','a','v')) {
282  int seek_back;
283 
284  seek_back = avio_rl32(s->pb) + 8;
285  if (seek_back < 9)
286  break;
287  dhav->last_good_pos = avio_tell(s->pb);
288  avio_seek(s->pb, -seek_back, SEEK_CUR);
289  }
290  avio_seek(s->pb, dhav->last_good_pos, SEEK_SET);
291  }
292  }
293 
294  dhav->duration = get_duration(s);
295  dhav->last_good_pos = avio_tell(s->pb);
296  s->ctx_flags |= AVFMTCTX_NOHEADER;
297  dhav->video_stream_index = -1;
298  dhav->audio_stream_index = -1;
299 
300  return 0;
301 }
302 
303 static int64_t get_pts(AVFormatContext *s, int stream_index)
304 {
305  DHAVStream *dst = s->streams[stream_index]->priv_data;
306  DHAVContext *dhav = s->priv_data;
307  struct tm timeinfo;
308  time_t t;
309 
310  get_timeinfo(dhav->date, &timeinfo);
311 
312  t = av_timegm(&timeinfo);
313  if (dst->last_time == t) {
314  int64_t diff = dhav->timestamp - dst->last_timestamp;
315 
316  if (diff < 0)
317  diff += 65535;
318  if (diff == 0 && dhav->frame_rate)
319  diff = av_rescale(dhav->frame_number - dst->last_frame_number, 1000, dhav->frame_rate);
320  dst->pts += diff;
321  } else {
322  dst->pts = t * 1000LL;
323  }
324 
325  dst->last_time = t;
326  dst->last_timestamp = dhav->timestamp;
327  dst->last_frame_number = dhav->frame_number;
328 
329  return dst->pts;
330 }
331 
333 {
334  DHAVContext *dhav = s->priv_data;
335  int size, ret, stream_index;
336 
337 retry:
338  while ((ret = read_chunk(s)) == 0)
339  ;
340 
341  if (ret < 0)
342  return ret;
343 
344  if (dhav->type == 0xfd && dhav->video_stream_index == -1) {
346  DHAVStream *dst;
347 
348  if (!st)
349  return AVERROR(ENOMEM);
350 
352  switch (dhav->video_codec) {
353  case 0x1: st->codecpar->codec_id = AV_CODEC_ID_MPEG4; break;
354  case 0x3: st->codecpar->codec_id = AV_CODEC_ID_MJPEG; break;
355  case 0x2:
356  case 0x4:
357  case 0x8: st->codecpar->codec_id = AV_CODEC_ID_H264; break;
358  case 0xc: st->codecpar->codec_id = AV_CODEC_ID_HEVC; break;
359  default: avpriv_request_sample(s, "Unknown video codec %X", dhav->video_codec);
360  }
361  st->duration = dhav->duration;
362  st->codecpar->width = dhav->width;
363  st->codecpar->height = dhav->height;
364  st->avg_frame_rate.num = dhav->frame_rate;
365  st->avg_frame_rate.den = 1;
366  st->priv_data = dst = av_mallocz(sizeof(DHAVStream));
367  if (!st->priv_data)
368  return AVERROR(ENOMEM);
369  dst->last_time = AV_NOPTS_VALUE;
370  dhav->video_stream_index = st->index;
371 
372  avpriv_set_pts_info(st, 64, 1, 1000);
373  } else if (dhav->type == 0xf0 && dhav->audio_stream_index == -1) {
375  DHAVStream *dst;
376 
377  if (!st)
378  return AVERROR(ENOMEM);
379 
381  switch (dhav->audio_codec) {
382  case 0x07: st->codecpar->codec_id = AV_CODEC_ID_PCM_S8; break;
383  case 0x0c: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; break;
384  case 0x10: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; break;
385  case 0x0a: st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW; break;
386  case 0x16: st->codecpar->codec_id = AV_CODEC_ID_PCM_MULAW; break;
387  case 0x0e: st->codecpar->codec_id = AV_CODEC_ID_PCM_ALAW; break;
388  case 0x1a: st->codecpar->codec_id = AV_CODEC_ID_AAC; break;
389  case 0x1f: st->codecpar->codec_id = AV_CODEC_ID_MP2; break;
390  case 0x21: st->codecpar->codec_id = AV_CODEC_ID_MP3; break;
391  case 0x0d: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_MS; break;
392  default: avpriv_request_sample(s, "Unknown audio codec %X", dhav->audio_codec);
393  }
394  st->duration = dhav->duration;
395  st->codecpar->channels = dhav->audio_channels;
396  st->codecpar->sample_rate = dhav->sample_rate;
397  st->priv_data = dst = av_mallocz(sizeof(DHAVStream));
398  if (!st->priv_data)
399  return AVERROR(ENOMEM);
400  dst->last_time = AV_NOPTS_VALUE;
401  dhav->audio_stream_index = st->index;
402 
403  avpriv_set_pts_info(st, 64, 1, 1000);
404  }
405 
406  stream_index = dhav->type == 0xf0 ? dhav->audio_stream_index : dhav->video_stream_index;
407  if (stream_index < 0) {
408  avio_skip(s->pb, ret);
409  if (avio_rl32(s->pb) == MKTAG('d','h','a','v'))
410  avio_skip(s->pb, 4);
411  goto retry;
412  }
413 
414  size = ret;
415  ret = av_get_packet(s->pb, pkt, size);
416  if (ret < 0)
417  return ret;
418  pkt->stream_index = stream_index;
419  if (dhav->type != 0xfc)
421  pkt->duration = 1;
422  if (pkt->stream_index >= 0)
424  pkt->pos = dhav->last_good_pos;
425  if (avio_rl32(s->pb) == MKTAG('d','h','a','v'))
426  avio_skip(s->pb, 4);
427 
428  return ret;
429 }
430 
431 static int dhav_read_seek(AVFormatContext *s, int stream_index,
432  int64_t timestamp, int flags)
433 {
434  DHAVContext *dhav = s->priv_data;
435  AVStream *st = s->streams[stream_index];
436  FFStream *const sti = ffstream(st);
437  int index = av_index_search_timestamp(st, timestamp, flags);
438  int64_t pts;
439 
440  if (index < 0)
441  return -1;
442  if (avio_seek(s->pb, sti->index_entries[index].pos, SEEK_SET) < 0)
443  return -1;
444 
446 
447  for (int n = 0; n < s->nb_streams; n++) {
448  AVStream *st = s->streams[n];
449  DHAVStream *dst = st->priv_data;
450 
451  dst->pts = pts;
452  dst->last_time = AV_NOPTS_VALUE;
453  }
454  dhav->last_good_pos = avio_tell(s->pb);
455 
456  return 0;
457 }
458 
460  .name = "dhav",
461  .long_name = NULL_IF_CONFIG_SMALL("Video DAV"),
462  .priv_data_size = sizeof(DHAVContext),
467  .extensions = "dav",
469 };
AV_CODEC_ID_PCM_S16LE
@ AV_CODEC_ID_PCM_S16LE
Definition: codec_id.h:313
AV_CODEC_ID_ADPCM_MS
@ AV_CODEC_ID_ADPCM_MS
Definition: codec_id.h:358
AVFMT_NO_BYTE_SEEK
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition: avformat.h:475
AVERROR
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
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:724
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
DHAVContext::frame_number
unsigned frame_number
Definition: dhav.c:33
get_pts
static int64_t get_pts(AVFormatContext *s, int stream_index)
Definition: dhav.c:303
AVStream::priv_data
void * priv_data
Definition: avformat.h:854
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
dhav_read_header
static int dhav_read_header(AVFormatContext *s)
Definition: dhav.c:265
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:62
index
fg index
Definition: ffmpeg_filter.c:168
dhav_probe
static int dhav_probe(const AVProbeData *p)
Definition: dhav.c:56
DHAVContext::timestamp
unsigned timestamp
Definition: dhav.c:35
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:912
DHAVStream::last_time
int64_t last_time
Definition: dhav.c:52
get_timeinfo
static void get_timeinfo(unsigned date, struct tm *timeinfo)
Definition: dhav.c:212
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:391
DHAVContext::audio_codec
int audio_codec
Definition: dhav.c:40
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:338
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:425
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:458
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
DHAVStream::pts
int64_t pts
Definition: dhav.c:53
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:426
DHAVContext::sample_rate
int sample_rate
Definition: dhav.c:41
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:149
DHAVContext::frame_rate
int frame_rate
Definition: dhav.c:38
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:486
AVFMT_GENERIC_INDEX
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:468
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
pts
static int64_t pts
Definition: transcode_aac.c:653
av_timegm
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
Definition: parseutils.c:568
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:423
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:888
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:726
AVRational::num
int num
Numerator.
Definition: rational.h:59
DHAVContext::date
unsigned date
Definition: dhav.c:34
signature
static const char signature[]
Definition: ipmovie.c:592
DHAVContext::type
unsigned type
Definition: dhav.c:29
AV_CODEC_ID_PCM_S8
@ AV_CODEC_ID_PCM_S8
Definition: codec_id.h:317
pkt
AVPacket * pkt
Definition: movenc.c:59
AVInputFormat
Definition: avformat.h:626
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
s
#define s(width, name)
Definition: cbs_vp9.c:257
DHAVContext
Definition: dhav.c:28
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:631
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:448
read_chunk
static int read_chunk(AVFormatContext *s)
Definition: dhav.c:167
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
AV_CODEC_ID_MP2
@ AV_CODEC_ID_MP2
Definition: codec_id.h:422
AVIndexEntry::timestamp
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
Definition: avformat.h:779
dhav_read_seek
static int dhav_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: dhav.c:431
DHAVContext::channel
unsigned channel
Definition: dhav.c:31
AV_CODEC_ID_PCM_MULAW
@ AV_CODEC_ID_PCM_MULAW
Definition: codec_id.h:319
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:77
AVFormatContext
Format I/O context.
Definition: avformat.h:1097
AV_CODEC_ID_PCM_ALAW
@ AV_CODEC_ID_PCM_ALAW
Definition: codec_id.h:320
internal.h
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:992
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
NULL
#define NULL
Definition: coverity.c:32
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
AVFMTCTX_NOHEADER
#define AVFMTCTX_NOHEADER
signal that no header is present (streams are added dynamically)
Definition: avformat.h:1048
parse_ext
static int parse_ext(AVFormatContext *s, int length)
Definition: dhav.c:78
DHAVContext::audio_stream_index
int audio_stream_index
Definition: dhav.c:46
parseutils.h
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:446
DHAVContext::duration
int64_t duration
Definition: dhav.c:43
seek_back
static void seek_back(AVFormatContext *s, AVIOContext *pb, int64_t pos)
Definition: mpegts.c:3067
DHAVStream::last_timestamp
int64_t last_timestamp
Definition: dhav.c:51
DHAVContext::height
int height
Definition: dhav.c:36
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
DHAVContext::video_codec
int video_codec
Definition: dhav.c:37
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:424
sample_rates
static const uint32_t sample_rates[]
Definition: dhav.c:72
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:742
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
FFStream
Definition: internal.h:188
get_duration
static int64_t get_duration(AVFormatContext *s)
Definition: dhav.c:231
size
int size
Definition: twinvq_data.h:10344
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
DHAVStream::last_frame_number
int64_t last_frame_number
Definition: dhav.c:50
DHAVStream
Definition: dhav.c:49
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:616
ffio_ensure_seekback
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
Definition: aviobuf.c:990
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
DHAVContext::subtype
unsigned subtype
Definition: dhav.c:30
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:57
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
avio_internal.h
AVCodecParameters::height
int height
Definition: codec_par.h:127
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:224
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:263
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:128
av_get_packet
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:196
AVFMT_TS_NONSTRICT
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:477
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVStream
Stream structure.
Definition: avformat.h:845
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
ff_dhav_demuxer
const AVInputFormat ff_dhav_demuxer
Definition: dhav.c:459
avformat.h
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:846
AVRational::den
int den
Denominator.
Definition: rational.h:60
dhav_read_packet
static int dhav_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: dhav.c:332
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:625
AVIndexEntry::pos
int64_t pos
Definition: avformat.h:778
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *st, 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:1146
AVPacket::stream_index
int stream_index
Definition: packet.h:375
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:333
FFStream::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:271
DHAVContext::audio_channels
int audio_channels
Definition: dhav.c:39
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVFMT_TS_DISCONT
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition: avformat.h:469
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:136
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
AVPacket
This structure stores compressed data.
Definition: packet.h:350
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:393
DHAVContext::video_stream_index
int video_stream_index
Definition: dhav.c:45
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
DHAVContext::last_good_pos
int64_t last_good_pos
Definition: dhav.c:42
DHAVContext::width
int width
Definition: dhav.c:36
DHAVContext::frame_subnumber
unsigned frame_subnumber
Definition: dhav.c:32
av_index_search_timestamp
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: seek.c:237
min
float min
Definition: vorbis_enc_data.h:429
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:360