FFmpeg
asfdec_f.c
Go to the documentation of this file.
1 /*
2  * ASF compatible demuxer
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <inttypes.h>
23 
24 #include "libavutil/attributes.h"
25 #include "libavutil/avassert.h"
26 #include "libavutil/avstring.h"
27 #include "libavutil/bswap.h"
28 #include "libavutil/common.h"
29 #include "libavutil/dict.h"
30 #include "libavutil/internal.h"
31 #include "libavutil/mathematics.h"
32 #include "libavutil/opt.h"
33 #include "avformat.h"
34 #include "avio_internal.h"
35 #include "avlanguage.h"
36 #include "internal.h"
37 #include "riff.h"
38 #include "asf.h"
39 #include "asfcrypt.h"
40 
41 typedef struct ASFPayload {
42  uint8_t type;
43  uint16_t size;
44 } ASFPayload;
45 
46 typedef struct ASFStream {
47  int num;
48  unsigned char seq;
49  /* use for reading */
53  int timestamp;
54  int64_t duration;
56  int pkt_clean;
57 
58  int ds_span; /* descrambling */
61 
62  int64_t packet_pos;
63 
65 
67  uint32_t palette[256];
68 
71 } ASFStream;
72 
73 typedef struct ASFContext {
74  const AVClass *class;
75  int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID
76  ASFStream streams[128]; ///< it's max number and it's not that big
77  uint32_t stream_bitrates[128]; ///< max number of streams, bitrate for each (for streaming)
79  char stream_languages[128][6]; ///< max number of streams, language for each (RFC1766, e.g. en-US)
80  /* non streamed additonnal info */
81  /* packet filling */
83  /* only for reading */
84  uint64_t data_offset; ///< beginning of the first data packet
85  uint64_t data_object_offset; ///< data object offset (excl. GUID & size)
86  uint64_t data_object_size; ///< size of the data object
88 
90 
100  unsigned int packet_frag_offset;
101  unsigned int packet_frag_size;
107  int64_t packet_pos;
108 
110 
111  ASFStream *asf_st; ///< currently decoded stream
112 
115 
117 } ASFContext;
118 
119 static const AVOption options[] = {
120  { "no_resync_search", "Don't try to resynchronize by looking for a certain optional start code", offsetof(ASFContext, no_resync_search), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
121  { "export_xmp", "Export full XMP metadata", offsetof(ASFContext, export_xmp), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
122  { NULL },
123 };
124 
125 static const AVClass asf_class = {
126  .class_name = "asf demuxer",
127  .item_name = av_default_item_name,
128  .option = options,
129  .version = LIBAVUTIL_VERSION_INT,
130 };
131 
132 #undef NDEBUG
133 #include <assert.h>
134 
135 #define ASF_MAX_STREAMS 127
136 #define FRAME_HEADER_SIZE 6
137 // Fix Me! FRAME_HEADER_SIZE may be different.
138 // (7 is known to be too large for GipsyGuitar.wmv)
139 
140 #ifdef DEBUG
141 static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */
142  0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
143 };
144 
145 static const ff_asf_guid asf_audio_conceal_none = {
146  // 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
147  // New value lifted from avifile
148  0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
149 };
150 
151 #define PRINT_IF_GUID(g, cmp) \
152  if (!ff_guidcmp(g, &(cmp))) \
153  av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp)
154 
155 static void print_guid(ff_asf_guid *g)
156 {
157  int i;
158  PRINT_IF_GUID(g, ff_asf_header);
159  else PRINT_IF_GUID(g, ff_asf_file_header);
160  else PRINT_IF_GUID(g, ff_asf_stream_header);
161  else PRINT_IF_GUID(g, ff_asf_audio_stream);
162  else PRINT_IF_GUID(g, asf_audio_conceal_none);
163  else PRINT_IF_GUID(g, ff_asf_video_stream);
164  else PRINT_IF_GUID(g, ff_asf_video_conceal_none);
165  else PRINT_IF_GUID(g, ff_asf_command_stream);
166  else PRINT_IF_GUID(g, ff_asf_comment_header);
167  else PRINT_IF_GUID(g, ff_asf_codec_comment_header);
168  else PRINT_IF_GUID(g, ff_asf_codec_comment1_header);
169  else PRINT_IF_GUID(g, ff_asf_data_header);
170  else PRINT_IF_GUID(g, ff_asf_simple_index_header);
171  else PRINT_IF_GUID(g, ff_asf_head1_guid);
172  else PRINT_IF_GUID(g, ff_asf_head2_guid);
173  else PRINT_IF_GUID(g, ff_asf_my_guid);
174  else PRINT_IF_GUID(g, ff_asf_ext_stream_header);
175  else PRINT_IF_GUID(g, ff_asf_extended_content_header);
176  else PRINT_IF_GUID(g, ff_asf_ext_stream_embed_stream_header);
177  else PRINT_IF_GUID(g, ff_asf_ext_stream_audio_stream);
178  else PRINT_IF_GUID(g, ff_asf_metadata_header);
179  else PRINT_IF_GUID(g, ff_asf_metadata_library_header);
180  else PRINT_IF_GUID(g, ff_asf_marker_header);
181  else PRINT_IF_GUID(g, stream_bitrate_guid);
182  else PRINT_IF_GUID(g, ff_asf_language_guid);
183  else
184  av_log(NULL, AV_LOG_TRACE, "(GUID: unknown) ");
185  for (i = 0; i < 16; i++)
186  av_log(NULL, AV_LOG_TRACE, " 0x%02x,", (*g)[i]);
187  av_log(NULL, AV_LOG_TRACE, "}\n");
188 }
189 #undef PRINT_IF_GUID
190 #else
191 #define print_guid(g) while(0)
192 #endif
193 
194 static int asf_probe(const AVProbeData *pd)
195 {
196  /* check file header */
197  if (!ff_guidcmp(pd->buf, &ff_asf_header))
198  return AVPROBE_SCORE_MAX;
199  else
200  return 0;
201 }
202 
203 /* size of type 2 (BOOL) is 32bit for "Extended Content Description Object"
204  * but 16 bit for "Metadata Object" and "Metadata Library Object" */
205 static int get_value(AVIOContext *pb, int type, int type2_size)
206 {
207  switch (type) {
208  case ASF_BOOL:
209  return (type2_size == 32) ? avio_rl32(pb) : avio_rl16(pb);
210  case ASF_DWORD:
211  return avio_rl32(pb);
212  case ASF_QWORD:
213  return avio_rl64(pb);
214  case ASF_WORD:
215  return avio_rl16(pb);
216  default:
217  return INT_MIN;
218  }
219 }
220 
221 static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)
222 {
223  ASFContext *asf = s->priv_data;
224  char *value = NULL;
225  int64_t off = avio_tell(s->pb);
226 #define LEN 22
227 
228  av_assert0((unsigned)len < (INT_MAX - LEN) / 2);
229 
230  if (!asf->export_xmp && !strncmp(key, "xmp", 3))
231  goto finish;
232 
233  value = av_malloc(2 * len + LEN);
234  if (!value)
235  goto finish;
236 
237  switch (type) {
238  case ASF_UNICODE:
239  avio_get_str16le(s->pb, len, value, 2 * len + 1);
240  break;
241  case -1: // ASCI
242  avio_read(s->pb, value, len);
243  value[len]=0;
244  break;
245  case ASF_BYTE_ARRAY:
246  if (ff_asf_handle_byte_array(s, key, len) > 0)
247  av_log(s, AV_LOG_VERBOSE, "Unsupported byte array in tag %s.\n", key);
248  goto finish;
249  case ASF_BOOL:
250  case ASF_DWORD:
251  case ASF_QWORD:
252  case ASF_WORD: {
253  uint64_t num = get_value(s->pb, type, type2_size);
254  snprintf(value, LEN, "%"PRIu64, num);
255  break;
256  }
257  case ASF_GUID:
258  av_log(s, AV_LOG_DEBUG, "Unsupported GUID value in tag %s.\n", key);
259  goto finish;
260  default:
262  "Unsupported value type %d in tag %s.\n", type, key);
263  goto finish;
264  }
265  if (*value)
266  av_dict_set(&s->metadata, key, value, 0);
267 
268 finish:
269  av_freep(&value);
270  avio_seek(s->pb, off + len, SEEK_SET);
271 }
272 
274 {
275  ASFContext *asf = s->priv_data;
276  AVIOContext *pb = s->pb;
277 
278  ff_get_guid(pb, &asf->hdr.guid);
279  asf->hdr.file_size = avio_rl64(pb);
280  asf->hdr.create_time = avio_rl64(pb);
281  avio_rl64(pb); /* number of packets */
282  asf->hdr.play_time = avio_rl64(pb);
283  asf->hdr.send_time = avio_rl64(pb);
284  asf->hdr.preroll = avio_rl32(pb);
285  asf->hdr.ignore = avio_rl32(pb);
286  asf->hdr.flags = avio_rl32(pb);
287  asf->hdr.min_pktsize = avio_rl32(pb);
288  asf->hdr.max_pktsize = avio_rl32(pb);
289  if (asf->hdr.min_pktsize >= (1U << 29))
290  return AVERROR_INVALIDDATA;
291  asf->hdr.max_bitrate = avio_rl32(pb);
292  s->packet_size = asf->hdr.max_pktsize;
293 
294  return 0;
295 }
296 
298 {
299  ASFContext *asf = s->priv_data;
300  AVIOContext *pb = s->pb;
301  AVStream *st;
302  FFStream *sti;
303  ASFStream *asf_st;
304  ff_asf_guid g;
305  enum AVMediaType type;
306  int type_specific_size, sizeX;
307  unsigned int tag1;
308  int64_t pos1, pos2, start_time;
309  int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
310 
311  if (s->nb_streams == ASF_MAX_STREAMS) {
312  av_log(s, AV_LOG_ERROR, "too many streams\n");
313  return AVERROR(EINVAL);
314  }
315 
316  pos1 = avio_tell(pb);
317 
318  st = avformat_new_stream(s, NULL);
319  if (!st)
320  return AVERROR(ENOMEM);
321  sti = ffstream(st);
322  avpriv_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */
323  start_time = asf->hdr.preroll;
324 
325  if (!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
326  int64_t fsize = avio_size(pb);
327  if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 ||
328  FFABS(fsize - (int64_t)asf->hdr.file_size) < FFMIN(fsize, asf->hdr.file_size)/20)
329  st->duration = asf->hdr.play_time /
330  (10000000 / 1000) - start_time;
331  }
332  ff_get_guid(pb, &g);
333 
334  test_for_ext_stream_audio = 0;
335  if (!ff_guidcmp(&g, &ff_asf_audio_stream)) {
337  } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) {
339  } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) {
342  } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) {
345  test_for_ext_stream_audio = 1;
347  } else {
348  return -1;
349  }
350  ff_get_guid(pb, &g);
351  avio_skip(pb, 8); /* total_size */
352  type_specific_size = avio_rl32(pb);
353  avio_rl32(pb);
354  st->id = avio_rl16(pb) & 0x7f; /* stream id */
355  // mapping of asf ID to AV stream ID;
356  asf->asfid2avid[st->id] = s->nb_streams - 1;
357  asf_st = &asf->streams[st->id];
358 
359  avio_rl32(pb);
360 
361  if (test_for_ext_stream_audio) {
362  ff_get_guid(pb, &g);
365  is_dvr_ms_audio = 1;
366  ff_get_guid(pb, &g);
367  avio_rl32(pb);
368  avio_rl32(pb);
369  avio_rl32(pb);
370  ff_get_guid(pb, &g);
371  avio_rl32(pb);
372  }
373  }
374 
375  st->codecpar->codec_type = type;
376  if (type == AVMEDIA_TYPE_AUDIO) {
377  int ret = ff_get_wav_header(s, pb, st->codecpar, type_specific_size, 0);
378  if (ret < 0)
379  return ret;
380  if (is_dvr_ms_audio) {
381  // codec_id and codec_tag are unreliable in dvr_ms
382  // files. Set them later by probing stream.
383  sti->request_probe = 1;
384  st->codecpar->codec_tag = 0;
385  }
386  if (st->codecpar->codec_id == AV_CODEC_ID_AAC)
388  else
390  /* We have to init the frame size at some point .... */
391  pos2 = avio_tell(pb);
392  if (size >= (pos2 + 8 - pos1 + 24)) {
393  asf_st->ds_span = avio_r8(pb);
394  asf_st->ds_packet_size = avio_rl16(pb);
395  asf_st->ds_chunk_size = avio_rl16(pb);
396  avio_rl16(pb); // ds_data_size
397  avio_r8(pb); // ds_silence_data
398  }
399  if (asf_st->ds_span > 1) {
400  if (!asf_st->ds_chunk_size ||
401  (asf_st->ds_packet_size / asf_st->ds_chunk_size <= 1) ||
402  asf_st->ds_packet_size % asf_st->ds_chunk_size)
403  asf_st->ds_span = 0; // disable descrambling
404  }
405  } else if (type == AVMEDIA_TYPE_VIDEO &&
406  size - (avio_tell(pb) - pos1 + 24) >= 51) {
407  avio_rl32(pb);
408  avio_rl32(pb);
409  avio_r8(pb);
410  avio_rl16(pb); /* size */
411  sizeX = avio_rl32(pb); /* size */
412  st->codecpar->width = avio_rl32(pb);
413  st->codecpar->height = avio_rl32(pb);
414  /* not available for asf */
415  avio_rl16(pb); /* panes */
416  st->codecpar->bits_per_coded_sample = avio_rl16(pb); /* depth */
417  tag1 = avio_rl32(pb);
418  avio_skip(pb, 20);
419  if (sizeX > 40) {
420  if (size < sizeX - 40 || sizeX - 40 > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
421  return AVERROR_INVALIDDATA;
422  st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
425  if (!st->codecpar->extradata)
426  return AVERROR(ENOMEM);
428  }
429 
430  /* Extract palette from extradata if bpp <= 8 */
431  /* This code assumes that extradata contains only palette */
432  /* This is true for all paletted codecs implemented in libavcodec */
433  if (st->codecpar->extradata_size && (st->codecpar->bits_per_coded_sample <= 8)) {
434 #if HAVE_BIGENDIAN
435  int i;
436  for (i = 0; i < FFMIN(st->codecpar->extradata_size, AVPALETTE_SIZE) / 4; i++)
437  asf_st->palette[i] = av_bswap32(((uint32_t *)st->codecpar->extradata)[i]);
438 #else
439  memcpy(asf_st->palette, st->codecpar->extradata,
441 #endif
442  asf_st->palette_changed = 1;
443  }
444 
445  st->codecpar->codec_tag = tag1;
447  if (tag1 == MKTAG('D', 'V', 'R', ' ')) {
449  /* issue658 contains wrong w/h and MS even puts a fake seq header
450  * with wrong w/h in extradata while a correct one is in the stream.
451  * maximum lameness */
452  st->codecpar->width =
453  st->codecpar->height = 0;
454  av_freep(&st->codecpar->extradata);
455  st->codecpar->extradata_size = 0;
456  }
457  if (st->codecpar->codec_id == AV_CODEC_ID_H264)
459  if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
461  }
462  pos2 = avio_tell(pb);
463  avio_skip(pb, size - (pos2 - pos1 + 24));
464 
465  return 0;
466 }
467 
469 {
470  ASFContext *asf = s->priv_data;
471  AVIOContext *pb = s->pb;
472  ff_asf_guid g;
473  int ext_len, payload_ext_ct, stream_ct, i;
474  uint32_t leak_rate, stream_num;
475  unsigned int stream_languageid_index;
476 
477  avio_rl64(pb); // starttime
478  avio_rl64(pb); // endtime
479  leak_rate = avio_rl32(pb); // leak-datarate
480  avio_rl32(pb); // bucket-datasize
481  avio_rl32(pb); // init-bucket-fullness
482  avio_rl32(pb); // alt-leak-datarate
483  avio_rl32(pb); // alt-bucket-datasize
484  avio_rl32(pb); // alt-init-bucket-fullness
485  avio_rl32(pb); // max-object-size
486  avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
487  stream_num = avio_rl16(pb); // stream-num
488 
489  stream_languageid_index = avio_rl16(pb); // stream-language-id-index
490  if (stream_num < 128)
491  asf->streams[stream_num].stream_language_index = stream_languageid_index;
492 
493  avio_rl64(pb); // avg frametime in 100ns units
494  stream_ct = avio_rl16(pb); // stream-name-count
495  payload_ext_ct = avio_rl16(pb); // payload-extension-system-count
496 
497  if (stream_num < 128) {
498  asf->stream_bitrates[stream_num] = leak_rate;
499  asf->streams[stream_num].payload_ext_ct = 0;
500  }
501 
502  for (i = 0; i < stream_ct; i++) {
503  avio_rl16(pb);
504  ext_len = avio_rl16(pb);
505  avio_skip(pb, ext_len);
506  }
507 
508  for (i = 0; i < payload_ext_ct; i++) {
509  int size;
510  ff_get_guid(pb, &g);
511  size = avio_rl16(pb);
512  ext_len = avio_rl32(pb);
513  if (ext_len < 0)
514  return AVERROR_INVALIDDATA;
515  avio_skip(pb, ext_len);
516  if (stream_num < 128 && i < FF_ARRAY_ELEMS(asf->streams[stream_num].payload)) {
517  ASFPayload *p = &asf->streams[stream_num].payload[i];
518  p->type = g[0];
519  p->size = size;
520  av_log(s, AV_LOG_DEBUG, "Payload extension %x %d\n", g[0], p->size );
521  asf->streams[stream_num].payload_ext_ct ++;
522  }
523  }
524 
525  return 0;
526 }
527 
529 {
530  AVIOContext *pb = s->pb;
531  int len1, len2, len3, len4, len5;
532 
533  len1 = avio_rl16(pb);
534  len2 = avio_rl16(pb);
535  len3 = avio_rl16(pb);
536  len4 = avio_rl16(pb);
537  len5 = avio_rl16(pb);
538  get_tag(s, "title", 0, len1, 32);
539  get_tag(s, "author", 0, len2, 32);
540  get_tag(s, "copyright", 0, len3, 32);
541  get_tag(s, "comment", 0, len4, 32);
542  avio_skip(pb, len5);
543 
544  return 0;
545 }
546 
548 {
549  AVIOContext *pb = s->pb;
550  ASFContext *asf = s->priv_data;
551  int desc_count, i, ret;
552 
553  desc_count = avio_rl16(pb);
554  for (i = 0; i < desc_count; i++) {
555  int name_len, value_type, value_len;
556  char name[1024];
557 
558  name_len = avio_rl16(pb);
559  if (name_len % 2) // must be even, broken lavf versions wrote len-1
560  name_len += 1;
561  if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
562  avio_skip(pb, name_len - ret);
563  value_type = avio_rl16(pb);
564  value_len = avio_rl16(pb);
565  if (!value_type && value_len % 2)
566  value_len += 1;
567  /* My sample has that stream set to 0 maybe that mean the container.
568  * ASF stream count starts at 1. I am using 0 to the container value
569  * since it's unused. */
570  if (!strcmp(name, "AspectRatioX"))
571  asf->dar[0].num = get_value(s->pb, value_type, 32);
572  else if (!strcmp(name, "AspectRatioY"))
573  asf->dar[0].den = get_value(s->pb, value_type, 32);
574  else
575  get_tag(s, name, value_type, value_len, 32);
576  }
577 
578  return 0;
579 }
580 
582 {
583  AVIOContext *pb = s->pb;
584  ASFContext *asf = s->priv_data;
585  int j, ret;
586  int stream_count = avio_rl16(pb);
587  for (j = 0; j < stream_count; j++) {
588  char lang[6];
589  unsigned int lang_len = avio_r8(pb);
590  if ((ret = avio_get_str16le(pb, lang_len, lang,
591  sizeof(lang))) < lang_len)
592  avio_skip(pb, lang_len - ret);
593  if (j < 128)
594  av_strlcpy(asf->stream_languages[j], lang,
595  sizeof(*asf->stream_languages));
596  }
597 
598  return 0;
599 }
600 
602 {
603  AVIOContext *pb = s->pb;
604  ASFContext *asf = s->priv_data;
605  int n, stream_num, name_len_utf16, name_len_utf8, value_len;
606  int ret, i;
607  n = avio_rl16(pb);
608 
609  for (i = 0; i < n; i++) {
610  uint8_t *name;
611  int value_type;
612 
613  avio_rl16(pb); // lang_list_index
614  stream_num = avio_rl16(pb);
615  name_len_utf16 = avio_rl16(pb);
616  value_type = avio_rl16(pb); /* value_type */
617  value_len = avio_rl32(pb);
618 
619  if (value_len < 0 || value_len > UINT16_MAX)
620  return AVERROR_INVALIDDATA;
621 
622  name_len_utf8 = 2*name_len_utf16 + 1;
623  name = av_malloc(name_len_utf8);
624  if (!name)
625  return AVERROR(ENOMEM);
626 
627  if ((ret = avio_get_str16le(pb, name_len_utf16, name, name_len_utf8)) < name_len_utf16)
628  avio_skip(pb, name_len_utf16 - ret);
629  av_log(s, AV_LOG_TRACE, "%d stream %d name_len %2d type %d len %4d <%s>\n",
630  i, stream_num, name_len_utf16, value_type, value_len, name);
631 
632  if (!strcmp(name, "AspectRatioX")){
633  int aspect_x = get_value(s->pb, value_type, 16);
634  if(stream_num < 128)
635  asf->dar[stream_num].num = aspect_x;
636  } else if(!strcmp(name, "AspectRatioY")){
637  int aspect_y = get_value(s->pb, value_type, 16);
638  if(stream_num < 128)
639  asf->dar[stream_num].den = aspect_y;
640  } else {
641  get_tag(s, name, value_type, value_len, 16);
642  }
643  av_freep(&name);
644  }
645 
646  return 0;
647 }
648 
649 static int asf_read_marker(AVFormatContext *s, int64_t size)
650 {
651  AVIOContext *pb = s->pb;
652  ASFContext *asf = s->priv_data;
653  int i, count, name_len, ret;
654  char name[1024];
655 
656  avio_rl64(pb); // reserved 16 bytes
657  avio_rl64(pb); // ...
658  count = avio_rl32(pb); // markers count
659  avio_rl16(pb); // reserved 2 bytes
660  name_len = avio_rl16(pb); // name length
661  avio_skip(pb, name_len);
662 
663  for (i = 0; i < count; i++) {
664  int64_t pres_time;
665  int name_len;
666 
667  if (avio_feof(pb))
668  return AVERROR_INVALIDDATA;
669 
670  avio_rl64(pb); // offset, 8 bytes
671  pres_time = avio_rl64(pb); // presentation time
672  pres_time -= asf->hdr.preroll * 10000;
673  avio_rl16(pb); // entry length
674  avio_rl32(pb); // send time
675  avio_rl32(pb); // flags
676  name_len = avio_rl32(pb); // name length
677  if ((unsigned)name_len > INT_MAX / 2)
678  return AVERROR_INVALIDDATA;
679  if ((ret = avio_get_str16le(pb, name_len * 2, name,
680  sizeof(name))) < name_len)
681  avio_skip(pb, name_len - ret);
682  avpriv_new_chapter(s, i, (AVRational) { 1, 10000000 }, pres_time,
684  }
685 
686  return 0;
687 }
688 
690 {
691  ASFContext *asf = s->priv_data;
692  ff_asf_guid g;
693  AVIOContext *pb = s->pb;
694  int i;
695  int64_t gsize;
696 
697  ff_get_guid(pb, &g);
698  if (ff_guidcmp(&g, &ff_asf_header))
699  return AVERROR_INVALIDDATA;
700  avio_rl64(pb);
701  avio_rl32(pb);
702  avio_r8(pb);
703  avio_r8(pb);
704  memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
705 
706  for (i = 0; i<128; i++)
707  asf->streams[i].stream_language_index = 128; // invalid stream index means no language info
708 
709  for (;;) {
710  uint64_t gpos = avio_tell(pb);
711  int ret = 0;
712  ff_get_guid(pb, &g);
713  gsize = avio_rl64(pb);
714  print_guid(&g);
715  if (!ff_guidcmp(&g, &ff_asf_data_header)) {
716  asf->data_object_offset = avio_tell(pb);
717  /* If not streaming, gsize is not unlimited (how?),
718  * and there is enough space in the file.. */
719  if (!(asf->hdr.flags & 0x01) && gsize >= 100)
720  asf->data_object_size = gsize - 24;
721  else
722  asf->data_object_size = (uint64_t)-1;
723  break;
724  }
725  if (gsize < 24)
726  return AVERROR_INVALIDDATA;
727  if (!ff_guidcmp(&g, &ff_asf_file_header)) {
728  ret = asf_read_file_properties(s, gsize);
729  } else if (!ff_guidcmp(&g, &ff_asf_stream_header)) {
730  ret = asf_read_stream_properties(s, gsize);
731  } else if (!ff_guidcmp(&g, &ff_asf_comment_header)) {
732  asf_read_content_desc(s, gsize);
733  } else if (!ff_guidcmp(&g, &ff_asf_language_guid)) {
734  asf_read_language_list(s, gsize);
735  } else if (!ff_guidcmp(&g, &ff_asf_extended_content_header)) {
737  } else if (!ff_guidcmp(&g, &ff_asf_metadata_header)) {
738  asf_read_metadata(s, gsize);
739  } else if (!ff_guidcmp(&g, &ff_asf_metadata_library_header)) {
740  asf_read_metadata(s, gsize);
741  } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_header)) {
743 
744  // there could be an optional stream properties object to follow
745  // if so the next iteration will pick it up
746  continue;
747  } else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) {
748  ff_get_guid(pb, &g);
749  avio_skip(pb, 6);
750  continue;
751  } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
752  asf_read_marker(s, gsize);
753  } else if (avio_feof(pb)) {
754  return AVERROR_EOF;
755  } else {
756  if (!s->keylen) {
759  unsigned int len;
761  "DRM protected stream detected, decoding will likely fail!\n");
762  len= avio_rl32(pb);
763  av_log(s, AV_LOG_DEBUG, "Secret data:\n");
764 
765  if ((ret = av_get_packet(pb, pkt, len)) < 0)
766  return ret;
769 
770  len= avio_rl32(pb);
771  if (len > UINT16_MAX)
772  return AVERROR_INVALIDDATA;
773  get_tag(s, "ASF_Protection_Type", -1, len, 32);
774 
775  len= avio_rl32(pb);
776  if (len > UINT16_MAX)
777  return AVERROR_INVALIDDATA;
778  get_tag(s, "ASF_Key_ID", -1, len, 32);
779 
780  len= avio_rl32(pb);
781  if (len > UINT16_MAX)
782  return AVERROR_INVALIDDATA;
783  get_tag(s, "ASF_License_URL", -1, len, 32);
784  } else if (!ff_guidcmp(&g, &ff_asf_ext_content_encryption)) {
786  "Ext DRM protected stream detected, decoding will likely fail!\n");
787  av_dict_set(&s->metadata, "encryption", "ASF Extended Content Encryption", 0);
788  } else if (!ff_guidcmp(&g, &ff_asf_digital_signature)) {
789  av_log(s, AV_LOG_INFO, "Digital signature detected!\n");
790  }
791  }
792  }
793  if (ret < 0)
794  return ret;
795 
796  if (avio_tell(pb) != gpos + gsize)
798  "gpos mismatch our pos=%"PRIu64", end=%"PRId64"\n",
799  avio_tell(pb) - gpos, gsize);
800  avio_seek(pb, gpos + gsize, SEEK_SET);
801  }
802  ff_get_guid(pb, &g);
803  avio_rl64(pb);
804  avio_r8(pb);
805  avio_r8(pb);
806  if (avio_feof(pb))
807  return AVERROR_EOF;
808  asf->data_offset = avio_tell(pb);
809  asf->packet_size_left = 0;
810 
811  for (i = 0; i < 128; i++) {
812  int stream_num = asf->asfid2avid[i];
813  if (stream_num >= 0) {
814  AVStream *st = s->streams[stream_num];
815  if (!st->codecpar->bit_rate)
816  st->codecpar->bit_rate = asf->stream_bitrates[i];
817  if (asf->dar[i].num > 0 && asf->dar[i].den > 0) {
820  asf->dar[i].num, asf->dar[i].den, INT_MAX);
821  } else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) &&
822  // Use ASF container value if the stream doesn't set AR.
826  asf->dar[0].num, asf->dar[0].den, INT_MAX);
827 
828  av_log(s, AV_LOG_TRACE, "i=%d, st->codecpar->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
829  i, st->codecpar->codec_type, asf->dar[i].num, asf->dar[i].den,
831 
832  // copy and convert language codes to the frontend
833  if (asf->streams[i].stream_language_index < 128) {
834  const char *rfc1766 = asf->stream_languages[asf->streams[i].stream_language_index];
835  if (rfc1766 && strlen(rfc1766) > 1) {
836  const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any
837  const char *iso6392 = ff_convert_lang_to(primary_tag,
839  if (iso6392)
840  av_dict_set(&st->metadata, "language", iso6392, 0);
841  }
842  }
843  }
844  }
845 
847 
848  return 0;
849 }
850 
851 #define DO_2BITS(bits, var, defval) \
852  switch (bits & 3) { \
853  case 3: \
854  var = avio_rl32(pb); \
855  rsize += 4; \
856  break; \
857  case 2: \
858  var = avio_rl16(pb); \
859  rsize += 2; \
860  break; \
861  case 1: \
862  var = avio_r8(pb); \
863  rsize++; \
864  break; \
865  default: \
866  var = defval; \
867  break; \
868  }
869 
870 /**
871  * Load a single ASF packet into the demuxer.
872  * @param s demux context
873  * @param pb context to read data from
874  * @return 0 on success, <0 on error
875  */
877 {
878  ASFContext *asf = s->priv_data;
879  uint32_t packet_length, padsize;
880  int rsize = 8;
881  int c, d, e, off;
882 
883  if (asf->uses_std_ecc > 0) {
884  // if we do not know packet size, allow skipping up to 32 kB
885  off = 32768;
886  if (asf->no_resync_search)
887  off = 3;
888 // else if (s->packet_size > 0 && !asf->uses_std_ecc)
889 // off = (avio_tell(pb) - ffformatcontext(s)->data_offset) % s->packet_size + 3;
890 
891  c = d = e = -1;
892  while (off-- > 0) {
893  c = d;
894  d = e;
895  e = avio_r8(pb);
896  if (c == 0x82 && !d && !e)
897  break;
898  }
899 
900  if (c != 0x82) {
901  /* This code allows handling of -EAGAIN at packet boundaries (i.e.
902  * if the packet sync code above triggers -EAGAIN). This does not
903  * imply complete -EAGAIN handling support at random positions in
904  * the stream. */
905  if (pb->error == AVERROR(EAGAIN))
906  return AVERROR(EAGAIN);
907  if (!avio_feof(pb))
909  "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
910  }
911  if ((c & 0x8f) == 0x82) {
912  if (d || e) {
913  if (!avio_feof(pb))
914  av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
915  return AVERROR_INVALIDDATA;
916  }
917  c = avio_r8(pb);
918  d = avio_r8(pb);
919  rsize += 3;
920  } else if(!avio_feof(pb)) {
921  avio_seek(pb, -1, SEEK_CUR); // FIXME
922  }
923  } else {
924  c = avio_r8(pb);
925  if (c & 0x80) {
926  rsize ++;
927  if (!(c & 0x60)) {
928  d = avio_r8(pb);
929  e = avio_r8(pb);
930  avio_seek(pb, (c & 0xF) - 2, SEEK_CUR);
931  rsize += c & 0xF;
932  }
933 
934  if (c != 0x82)
935  avpriv_request_sample(s, "Invalid ECC byte");
936 
937  if (!asf->uses_std_ecc)
938  asf->uses_std_ecc = (c == 0x82 && !d && !e) ? 1 : -1;
939 
940  c = avio_r8(pb);
941  } else
942  asf->uses_std_ecc = -1;
943  d = avio_r8(pb);
944  }
945 
946  asf->packet_flags = c;
947  asf->packet_property = d;
948 
949  DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size);
950  DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored
951  DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length
952 
953  // the following checks prevent overflows and infinite loops
954  if (!packet_length || packet_length >= (1U << 29)) {
956  "invalid packet_length %"PRIu32" at:%"PRId64"\n",
957  packet_length, avio_tell(pb));
958  return AVERROR_INVALIDDATA;
959  }
960  if (padsize >= packet_length) {
962  "invalid padsize %"PRIu32" at:%"PRId64"\n", padsize, avio_tell(pb));
963  return AVERROR_INVALIDDATA;
964  }
965 
966  asf->packet_timestamp = avio_rl32(pb);
967  avio_rl16(pb); /* duration */
968  // rsize has at least 11 bytes which have to be present
969 
970  if (asf->packet_flags & 0x01) {
971  asf->packet_segsizetype = avio_r8(pb);
972  rsize++;
973  asf->packet_segments = asf->packet_segsizetype & 0x3f;
974  } else {
975  asf->packet_segments = 1;
976  asf->packet_segsizetype = 0x80;
977  }
978  if (rsize > packet_length - padsize) {
979  asf->packet_size_left = 0;
981  "invalid packet header length %d for pktlen %"PRIu32"-%"PRIu32" at %"PRId64"\n",
982  rsize, packet_length, padsize, avio_tell(pb));
983  return AVERROR_INVALIDDATA;
984  }
985  asf->packet_size_left = packet_length - padsize - rsize;
986  if (packet_length < asf->hdr.min_pktsize)
987  padsize += asf->hdr.min_pktsize - packet_length;
988  asf->packet_padsize = padsize;
989  av_log(s, AV_LOG_TRACE, "packet: size=%d padsize=%d left=%d\n",
990  s->packet_size, asf->packet_padsize, asf->packet_size_left);
991  return 0;
992 }
993 
994 /**
995  *
996  * @return <0 if error
997  */
999 {
1000  ASFContext *asf = s->priv_data;
1001  ASFStream *asfst;
1002  int rsize = 1;
1003  int num = avio_r8(pb);
1004  int i;
1005  int64_t ts0, ts1 av_unused;
1006 
1007  asf->packet_segments--;
1008  asf->packet_key_frame = num >> 7;
1009  asf->stream_index = asf->asfid2avid[num & 0x7f];
1010  asfst = &asf->streams[num & 0x7f];
1011  // sequence should be ignored!
1012  DO_2BITS(asf->packet_property >> 4, asf->packet_seq, 0);
1013  DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0);
1015  av_log(asf, AV_LOG_TRACE, "key:%d stream:%d seq:%d offset:%d replic_size:%d num:%X packet_property %X\n",
1016  asf->packet_key_frame, asf->stream_index, asf->packet_seq,
1017  asf->packet_frag_offset, asf->packet_replic_size, num, asf->packet_property);
1018  if (rsize+(int64_t)asf->packet_replic_size > asf->packet_size_left) {
1019  av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size);
1020  return AVERROR_INVALIDDATA;
1021  }
1022  if (asf->packet_replic_size >= 8) {
1023  int64_t end = avio_tell(pb) + asf->packet_replic_size;
1024  AVRational aspect;
1025  asfst->packet_obj_size = avio_rl32(pb);
1026  if (asfst->packet_obj_size >= (1 << 24) || asfst->packet_obj_size < 0) {
1027  av_log(s, AV_LOG_ERROR, "packet_obj_size %d invalid\n", asfst->packet_obj_size);
1028  asfst->packet_obj_size = 0;
1029  return AVERROR_INVALIDDATA;
1030  }
1031  asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
1032 
1033  for (i = 0; i < asfst->payload_ext_ct; i++) {
1034  ASFPayload *p = &asfst->payload[i];
1035  int size = p->size;
1036  int64_t payend;
1037  if (size == 0xFFFF)
1038  size = avio_rl16(pb);
1039  payend = avio_tell(pb) + size;
1040  if (payend > end) {
1041  av_log(s, AV_LOG_ERROR, "too long payload\n");
1042  break;
1043  }
1044  switch (p->type) {
1045  case 0x50:
1046 // duration = avio_rl16(pb);
1047  break;
1048  case 0x54:
1049  aspect.num = avio_r8(pb);
1050  aspect.den = avio_r8(pb);
1051  if (aspect.num > 0 && aspect.den > 0 && asf->stream_index >= 0) {
1052  s->streams[asf->stream_index]->sample_aspect_ratio = aspect;
1053  }
1054  break;
1055  case 0x2A:
1056  avio_skip(pb, 8);
1057  ts0 = avio_rl64(pb);
1058  ts1 = avio_rl64(pb);
1059  if (ts0!= -1) asf->packet_frag_timestamp = ts0/10000;
1061  asf->ts_is_pts = 1;
1062  break;
1063  case 0x5B:
1064  case 0xB7:
1065  case 0xCC:
1066  case 0xC0:
1067  case 0xA0:
1068  //unknown
1069  break;
1070  }
1071  avio_seek(pb, payend, SEEK_SET);
1072  }
1073 
1074  avio_seek(pb, end, SEEK_SET);
1075  rsize += asf->packet_replic_size; // FIXME - check validity
1076  } else if (asf->packet_replic_size == 1) {
1077  // multipacket - frag_offset is beginning timestamp
1079  asf->packet_frag_offset = 0;
1081 
1082  asf->packet_time_delta = avio_r8(pb);
1083  rsize++;
1084  } else if (asf->packet_replic_size != 0) {
1085  av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n",
1086  asf->packet_replic_size);
1087  return AVERROR_INVALIDDATA;
1088  }
1089  if (asf->packet_flags & 0x01) {
1090  DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal
1091  if (rsize > asf->packet_size_left) {
1092  av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n");
1093  return AVERROR_INVALIDDATA;
1094  } else if (asf->packet_frag_size > asf->packet_size_left - rsize) {
1095  if (asf->packet_frag_size > asf->packet_size_left - rsize + asf->packet_padsize) {
1096  av_log(s, AV_LOG_ERROR, "packet_frag_size is invalid (%d>%d-%d+%d)\n",
1097  asf->packet_frag_size, asf->packet_size_left, rsize, asf->packet_padsize);
1098  return AVERROR_INVALIDDATA;
1099  } else {
1100  int diff = asf->packet_frag_size - (asf->packet_size_left - rsize);
1101  asf->packet_size_left += diff;
1102  asf->packet_padsize -= diff;
1103  }
1104  }
1105  } else {
1106  asf->packet_frag_size = asf->packet_size_left - rsize;
1107  }
1108  if (asf->packet_replic_size == 1) {
1109  asf->packet_multi_size = asf->packet_frag_size;
1110  if (asf->packet_multi_size > asf->packet_size_left)
1111  return AVERROR_INVALIDDATA;
1112  }
1113  asf->packet_size_left -= rsize;
1114 
1115  return 0;
1116 }
1117 
1118 /**
1119  * Parse data from individual ASF packets (which were previously loaded
1120  * with asf_get_packet()).
1121  * @param s demux context
1122  * @param pb context to read data from
1123  * @param pkt pointer to store packet data into
1124  * @return 0 if data was stored in pkt, <0 on error or 1 if more ASF
1125  * packets need to be loaded (through asf_get_packet())
1126  */
1128 {
1129  ASFContext *asf = s->priv_data;
1130  ASFStream *asf_st = 0;
1131  for (;;) {
1132  int ret;
1133  if (avio_feof(pb))
1134  return AVERROR_EOF;
1135  if (asf->packet_size_left < FRAME_HEADER_SIZE ||
1136  asf->packet_segments < 1 && asf->packet_time_start == 0) {
1137  int ret = asf->packet_size_left + asf->packet_padsize;
1138 
1140  av_log(s, AV_LOG_WARNING, "Skip due to FRAME_HEADER_SIZE\n");
1141 
1142  assert(ret >= 0);
1143  /* fail safe */
1144  avio_skip(pb, ret);
1145 
1146  asf->packet_pos = avio_tell(pb);
1147  if (asf->data_object_size != (uint64_t)-1 &&
1148  (asf->packet_pos - asf->data_object_offset >= asf->data_object_size))
1149  return AVERROR_EOF; /* Do not exceed the size of the data object */
1150  return 1;
1151  }
1152  if (asf->packet_time_start == 0) {
1153  if (asf_read_frame_header(s, pb) < 0) {
1154  asf->packet_time_start = asf->packet_segments = 0;
1155  continue;
1156  }
1157  if (asf->stream_index < 0 ||
1158  s->streams[asf->stream_index]->discard >= AVDISCARD_ALL ||
1159  (!asf->packet_key_frame &&
1160  (s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY || asf->streams[s->streams[asf->stream_index]->id].skip_to_key))) {
1161  asf->packet_time_start = 0;
1162  /* unhandled packet (should not happen) */
1163  avio_skip(pb, asf->packet_frag_size);
1164  asf->packet_size_left -= asf->packet_frag_size;
1165  if (asf->stream_index < 0)
1166  av_log(s, AV_LOG_ERROR, "ff asf skip %d (unknown stream)\n",
1167  asf->packet_frag_size);
1168  continue;
1169  }
1170  asf->asf_st = &asf->streams[s->streams[asf->stream_index]->id];
1171  if (!asf->packet_frag_offset)
1172  asf->asf_st->skip_to_key = 0;
1173  }
1174  asf_st = asf->asf_st;
1175  av_assert0(asf_st);
1176 
1177  if (!asf_st->frag_offset && asf->packet_frag_offset) {
1178  av_log(s, AV_LOG_TRACE, "skipping asf data pkt with fragment offset for "
1179  "stream:%d, expected:%d but got %d from pkt)\n",
1180  asf->stream_index, asf_st->frag_offset,
1181  asf->packet_frag_offset);
1182  avio_skip(pb, asf->packet_frag_size);
1183  asf->packet_size_left -= asf->packet_frag_size;
1184  continue;
1185  }
1186 
1187  if (asf->packet_replic_size == 1) {
1188  // frag_offset is here used as the beginning timestamp
1190  asf->packet_time_start += asf->packet_time_delta;
1191  asf_st->packet_obj_size = asf->packet_frag_size = avio_r8(pb);
1192  asf->packet_size_left--;
1193  asf->packet_multi_size--;
1194  if (asf->packet_multi_size < asf_st->packet_obj_size) {
1195  asf->packet_time_start = 0;
1196  avio_skip(pb, asf->packet_multi_size);
1197  asf->packet_size_left -= asf->packet_multi_size;
1198  continue;
1199  }
1200  asf->packet_multi_size -= asf_st->packet_obj_size;
1201  }
1202 
1203  if (asf_st->pkt.size != asf_st->packet_obj_size ||
1204  // FIXME is this condition sufficient?
1205  asf_st->frag_offset + asf->packet_frag_size > asf_st->pkt.size) {
1206  int ret;
1207 
1208  if (asf_st->pkt.data) {
1209  av_log(s, AV_LOG_INFO,
1210  "freeing incomplete packet size %d, new %d\n",
1211  asf_st->pkt.size, asf_st->packet_obj_size);
1212  asf_st->frag_offset = 0;
1213  av_packet_unref(&asf_st->pkt);
1214  }
1215  /* new packet */
1216  if ((ret = av_new_packet(&asf_st->pkt, asf_st->packet_obj_size)) < 0)
1217  return ret;
1218  asf_st->seq = asf->packet_seq;
1219  if (asf->ts_is_pts) {
1220  asf_st->pkt.pts = asf->packet_frag_timestamp - asf->hdr.preroll;
1221  } else
1222  asf_st->pkt.dts = asf->packet_frag_timestamp - asf->hdr.preroll;
1223  asf_st->pkt.stream_index = asf->stream_index;
1224  asf_st->pkt.pos = asf_st->packet_pos = asf->packet_pos;
1225  asf_st->pkt_clean = 0;
1226 
1227  if (asf_st->pkt.data && asf_st->palette_changed) {
1228  uint8_t *pal;
1230  AVPALETTE_SIZE);
1231  if (!pal) {
1232  av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n");
1233  } else {
1234  memcpy(pal, asf_st->palette, AVPALETTE_SIZE);
1235  asf_st->palette_changed = 0;
1236  }
1237  }
1238  av_log(asf, AV_LOG_TRACE, "new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1239  asf->stream_index, asf->packet_key_frame,
1240  asf_st->pkt.flags & AV_PKT_FLAG_KEY,
1241  s->streams[asf->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO,
1242  asf_st->packet_obj_size);
1243  if (s->streams[asf->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
1244  asf->packet_key_frame = 1;
1245  if (asf->packet_key_frame)
1246  asf_st->pkt.flags |= AV_PKT_FLAG_KEY;
1247  }
1248 
1249  /* read data */
1250  av_log(asf, AV_LOG_TRACE, "READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n",
1251  s->packet_size, asf_st->pkt.size, asf->packet_frag_offset,
1252  asf_st->frag_offset, asf->packet_frag_size, asf_st->pkt.data);
1253  asf->packet_size_left -= asf->packet_frag_size;
1254  if (asf->packet_size_left < 0)
1255  continue;
1256 
1257  if (asf->packet_frag_offset >= asf_st->pkt.size ||
1258  asf->packet_frag_size > asf_st->pkt.size - asf->packet_frag_offset) {
1260  "packet fragment position invalid %u,%u not in %u\n",
1262  asf_st->pkt.size);
1263  continue;
1264  }
1265 
1266  if (asf->packet_frag_offset != asf_st->frag_offset && !asf_st->pkt_clean) {
1267  memset(asf_st->pkt.data + asf_st->frag_offset, 0, asf_st->pkt.size - asf_st->frag_offset);
1268  asf_st->pkt_clean = 1;
1269  }
1270 
1271  ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset,
1272  asf->packet_frag_size);
1273  if (ret != asf->packet_frag_size) {
1274  if (ret < 0 || asf->packet_frag_offset + ret == 0)
1275  return ret < 0 ? ret : AVERROR_EOF;
1276 
1277  if (asf_st->ds_span > 1) {
1278  // scrambling, we can either drop it completely or fill the remainder
1279  // TODO: should we fill the whole packet instead of just the current
1280  // fragment?
1281  memset(asf_st->pkt.data + asf->packet_frag_offset + ret, 0,
1282  asf->packet_frag_size - ret);
1283  ret = asf->packet_frag_size;
1284  } else {
1285  // no scrambling, so we can return partial packets
1286  av_shrink_packet(&asf_st->pkt, asf->packet_frag_offset + ret);
1287  }
1288  }
1289  if (s->key && s->keylen == 20)
1290  ff_asfcrypt_dec(s->key, asf_st->pkt.data + asf->packet_frag_offset,
1291  ret);
1292  asf_st->frag_offset += ret;
1293  /* test if whole packet is read */
1294  if (asf_st->frag_offset == asf_st->pkt.size) {
1295  // workaround for macroshit radio DVR-MS files
1296  if (s->streams[asf->stream_index]->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
1297  asf_st->pkt.size > 100) {
1298  int i;
1299  for (i = 0; i < asf_st->pkt.size && !asf_st->pkt.data[i]; i++)
1300  ;
1301  if (i == asf_st->pkt.size) {
1302  av_log(s, AV_LOG_DEBUG, "discarding ms fart\n");
1303  asf_st->frag_offset = 0;
1304  av_packet_unref(&asf_st->pkt);
1305  continue;
1306  }
1307  }
1308 
1309  /* return packet */
1310  if (asf_st->ds_span > 1) {
1311  if (asf_st->pkt.size != asf_st->ds_packet_size * asf_st->ds_span) {
1313  "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1314  asf_st->pkt.size, asf_st->ds_packet_size,
1315  asf_st->ds_span);
1316  } else {
1317  /* packet descrambling */
1318  AVBufferRef *buf = av_buffer_alloc(asf_st->pkt.size +
1320  if (buf) {
1321  uint8_t *newdata = buf->data;
1322  int offset = 0;
1323  memset(newdata + asf_st->pkt.size, 0,
1325  while (offset < asf_st->pkt.size) {
1326  int off = offset / asf_st->ds_chunk_size;
1327  int row = off / asf_st->ds_span;
1328  int col = off % asf_st->ds_span;
1329  int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size;
1330  assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size);
1331  assert(idx + 1 <= asf_st->pkt.size / asf_st->ds_chunk_size);
1332  memcpy(newdata + offset,
1333  asf_st->pkt.data + idx * asf_st->ds_chunk_size,
1334  asf_st->ds_chunk_size);
1335  offset += asf_st->ds_chunk_size;
1336  }
1337  av_buffer_unref(&asf_st->pkt.buf);
1338  asf_st->pkt.buf = buf;
1339  asf_st->pkt.data = buf->data;
1340  }
1341  }
1342  }
1343  asf_st->frag_offset = 0;
1344  *pkt = asf_st->pkt;
1345  asf_st->pkt.buf = 0;
1346  asf_st->pkt.size = 0;
1347  asf_st->pkt.data = 0;
1348  asf_st->pkt.side_data_elems = 0;
1349  asf_st->pkt.side_data = NULL;
1350  break; // packet completed
1351  }
1352  }
1353  return 0;
1354 }
1355 
1357 {
1358  ASFContext *asf = s->priv_data;
1359 
1360  for (;;) {
1361  int ret;
1362 
1363  /* parse cached packets, if any */
1364  if ((ret = asf_parse_packet(s, s->pb, pkt)) <= 0)
1365  return ret;
1366  if ((ret = asf_get_packet(s, s->pb)) < 0)
1367  assert(asf->packet_size_left < FRAME_HEADER_SIZE ||
1368  asf->packet_segments < 1);
1369  asf->packet_time_start = 0;
1370  }
1371 }
1372 
1373 // Added to support seeking after packets have been read
1374 // If information is not reset, read_packet fails due to
1375 // leftover information from previous reads
1377 {
1378  ASFContext *asf = s->priv_data;
1379  ASFStream *asf_st;
1380  int i;
1381 
1382  asf->packet_size_left = 0;
1383  asf->packet_flags = 0;
1384  asf->packet_property = 0;
1385  asf->packet_timestamp = 0;
1386  asf->packet_segsizetype = 0;
1387  asf->packet_segments = 0;
1388  asf->packet_seq = 0;
1389  asf->packet_replic_size = 0;
1390  asf->packet_key_frame = 0;
1391  asf->packet_padsize = 0;
1392  asf->packet_frag_offset = 0;
1393  asf->packet_frag_size = 0;
1394  asf->packet_frag_timestamp = 0;
1395  asf->packet_multi_size = 0;
1396  asf->packet_time_delta = 0;
1397  asf->packet_time_start = 0;
1398 
1399  for (i = 0; i < 128; i++) {
1400  asf_st = &asf->streams[i];
1401  av_packet_unref(&asf_st->pkt);
1402  asf_st->packet_obj_size = 0;
1403  asf_st->frag_offset = 0;
1404  asf_st->seq = 0;
1405  }
1406  asf->asf_st = NULL;
1407 }
1408 
1410 {
1411  ASFContext *asf = s->priv_data;
1412  int i;
1413 
1414  for (i = 0; i < 128; i++) {
1415  int j = asf->asfid2avid[i];
1416  ASFStream *asf_st = &asf->streams[i];
1417  if (j < 0 || s->streams[j]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
1418  continue;
1419 
1420  asf_st->skip_to_key = 1;
1421  }
1422 }
1423 
1425 {
1427 
1428  return 0;
1429 }
1430 
1431 static int64_t asf_read_pts(AVFormatContext *s, int stream_index,
1432  int64_t *ppos, int64_t pos_limit)
1433 {
1434  FFFormatContext *const si = ffformatcontext(s);
1435  ASFContext *asf = s->priv_data;
1436  AVPacket pkt1, *pkt = &pkt1;
1437  ASFStream *asf_st;
1438  int64_t pts;
1439  int64_t pos = *ppos;
1440  int i;
1441  int64_t start_pos[ASF_MAX_STREAMS];
1442 
1443  for (i = 0; i < s->nb_streams; i++)
1444  start_pos[i] = pos;
1445 
1446  if (s->packet_size > 0)
1447  pos = (pos + s->packet_size - 1 - si->data_offset) /
1448  s->packet_size * s->packet_size +
1449  si->data_offset;
1450  *ppos = pos;
1451  if (avio_seek(s->pb, pos, SEEK_SET) < 0)
1452  return AV_NOPTS_VALUE;
1453 
1456  for (;;) {
1457  if (av_read_frame(s, pkt) < 0) {
1458  av_log(s, AV_LOG_INFO, "asf_read_pts failed\n");
1459  return AV_NOPTS_VALUE;
1460  }
1461 
1462  pts = pkt->dts;
1463 
1464  if (pkt->flags & AV_PKT_FLAG_KEY) {
1465  i = pkt->stream_index;
1466 
1467  asf_st = &asf->streams[s->streams[i]->id];
1468 
1469 // assert((asf_st->packet_pos - s->data_offset) % s->packet_size == 0);
1470  pos = asf_st->packet_pos;
1471  av_assert1(pkt->pos == asf_st->packet_pos);
1472 
1473  av_add_index_entry(s->streams[i], pos, pts, pkt->size,
1474  pos - start_pos[i] + 1, AVINDEX_KEYFRAME);
1475  start_pos[i] = asf_st->packet_pos + 1;
1476 
1477  if (pkt->stream_index == stream_index) {
1479  break;
1480  }
1481  }
1483  }
1484 
1485  *ppos = pos;
1486  return pts;
1487 }
1488 
1489 static int asf_build_simple_index(AVFormatContext *s, int stream_index)
1490 {
1491  ff_asf_guid g;
1492  ASFContext *asf = s->priv_data;
1493  int64_t current_pos = avio_tell(s->pb);
1494  int64_t ret;
1495 
1496  if((ret = avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET)) < 0) {
1497  return ret;
1498  }
1499 
1500  if ((ret = ff_get_guid(s->pb, &g)) < 0)
1501  goto end;
1502 
1503  /* the data object can be followed by other top-level objects,
1504  * skip them until the simple index object is reached */
1506  int64_t gsize = avio_rl64(s->pb);
1507  if (gsize < 24 || avio_feof(s->pb)) {
1508  goto end;
1509  }
1510  avio_skip(s->pb, gsize - 24);
1511  if ((ret = ff_get_guid(s->pb, &g)) < 0)
1512  goto end;
1513  }
1514 
1515  {
1516  int64_t itime, last_pos = -1;
1517  int pct, ict;
1518  int i;
1519  int64_t av_unused gsize = avio_rl64(s->pb);
1520  if ((ret = ff_get_guid(s->pb, &g)) < 0)
1521  goto end;
1522  itime = avio_rl64(s->pb);
1523  pct = avio_rl32(s->pb);
1524  ict = avio_rl32(s->pb);
1526  "itime:0x%"PRIx64", pct:%d, ict:%d\n", itime, pct, ict);
1527 
1528  for (i = 0; i < ict; i++) {
1529  int pktnum = avio_rl32(s->pb);
1530  int pktct = avio_rl16(s->pb);
1531  int64_t pos = ffformatcontext(s)->data_offset + s->packet_size * (int64_t)pktnum;
1532  int64_t index_pts = FFMAX(av_rescale(itime, i, 10000) - asf->hdr.preroll, 0);
1533 
1534  if (avio_feof(s->pb)) {
1536  goto end;
1537  }
1538 
1539  if (pos != last_pos) {
1540  av_log(s, AV_LOG_DEBUG, "pktnum:%d, pktct:%d pts: %"PRId64"\n",
1541  pktnum, pktct, index_pts);
1542  av_add_index_entry(s->streams[stream_index], pos, index_pts,
1543  s->packet_size, 0, AVINDEX_KEYFRAME);
1544  last_pos = pos;
1545  }
1546  }
1547  asf->index_read = ict > 1;
1548  }
1549 end:
1550 // if (avio_feof(s->pb)) {
1551 // ret = 0;
1552 // }
1553  avio_seek(s->pb, current_pos, SEEK_SET);
1554  return ret;
1555 }
1556 
1557 static int asf_read_seek(AVFormatContext *s, int stream_index,
1558  int64_t pts, int flags)
1559 {
1560  ASFContext *asf = s->priv_data;
1561  AVStream *st = s->streams[stream_index];
1562  FFStream *const sti = ffstream(st);
1563  int ret = 0;
1564 
1565  if (s->packet_size <= 0)
1566  return -1;
1567 
1568  /* Try using the protocol's read_seek if available */
1569  if (s->pb) {
1570  int64_t ret = avio_seek_time(s->pb, stream_index, pts, flags);
1571  if (ret >= 0)
1573  if (ret != AVERROR(ENOSYS))
1574  return ret;
1575  }
1576 
1577  /* explicitly handle the case of seeking to 0 */
1578  if (!pts) {
1580  avio_seek(s->pb, ffformatcontext(s)->data_offset, SEEK_SET);
1581  return 0;
1582  }
1583 
1584  if (!asf->index_read) {
1585  ret = asf_build_simple_index(s, stream_index);
1586  if (ret < 0)
1587  asf->index_read = -1;
1588  }
1589 
1590  if (asf->index_read > 0 && sti->index_entries) {
1592  if (index >= 0) {
1593  /* find the position */
1594  uint64_t pos = sti->index_entries[index].pos;
1595 
1596  /* do the seek */
1597  av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos);
1598  if(avio_seek(s->pb, pos, SEEK_SET) < 0)
1599  return -1;
1601  skip_to_key(s);
1602  return 0;
1603  }
1604  }
1605  /* no index or seeking by index failed */
1606  if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0)
1607  return -1;
1609  skip_to_key(s);
1610  return 0;
1611 }
1612 
1614  .name = "asf",
1615  .long_name = NULL_IF_CONFIG_SMALL("ASF (Advanced / Active Streaming Format)"),
1616  .priv_data_size = sizeof(ASFContext),
1617  .read_probe = asf_probe,
1624  .priv_class = &asf_class,
1625 };
ff_asf_ext_stream_embed_stream_header
const ff_asf_guid ff_asf_ext_stream_embed_stream_header
Definition: asf.c:96
asf_class
static const AVClass asf_class
Definition: asfdec_f.c:125
ff_asf_jfif_media
const ff_asf_guid ff_asf_jfif_media
Definition: asf.c:53
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:424
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
ASF_MAX_STREAMS
#define ASF_MAX_STREAMS
Definition: asfdec_f.c:135
name
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 default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
ff_asf_demuxer
const AVInputFormat ff_asf_demuxer
Definition: asfdec_f.c:1613
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
ff_get_guid
int ff_get_guid(AVIOContext *s, ff_asf_guid *g)
Definition: riffdec.c:31
opt.h
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:768
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
ASF_WORD
@ ASF_WORD
Definition: asf.h:35
ffformatcontext
static av_always_inline FFFormatContext * ffformatcontext(AVFormatContext *s)
Definition: internal.h:189
ASFMainHeader::send_time
uint64_t send_time
time to send file, in 100-nanosecond units invalid if broadcasting (could be ignored)
Definition: asf.h:47
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
avlanguage.h
ASFContext::packet_segsizetype
int packet_segsizetype
Definition: asfdec_f.c:94
asf_read_content_desc
static int asf_read_content_desc(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:528
skip_to_key
static void skip_to_key(AVFormatContext *s)
Definition: asfdec_f.c:1409
asf_parse_packet
static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
Parse data from individual ASF packets (which were previously loaded with asf_get_packet()).
Definition: asfdec_f.c:1127
ASFStream::palette_changed
int palette_changed
Definition: asfdec_f.c:66
av_unused
#define av_unused
Definition: attributes.h:131
AV_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:62
index
fg index
Definition: ffmpeg_filter.c:167
ASFMainHeader::preroll
uint32_t preroll
timestamp of the first packet, in milliseconds if nonzero - subtract from time
Definition: asf.h:49
AVPacket::data
uint8_t * data
Definition: packet.h:373
AVOption
AVOption.
Definition: opt.h:247
AV_PKT_DATA_PALETTE
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition: packet.h:46
asf_build_simple_index
static int asf_build_simple_index(AVFormatContext *s, int stream_index)
Definition: asfdec_f.c:1489
ASFStream::skip_to_key
int skip_to_key
Definition: asfdec_f.c:55
LEN
#define LEN
ASF_BOOL
@ ASF_BOOL
Definition: asf.h:32
AVIOContext::error
int error
contains the error code or 0 if no error happened
Definition: avio.h:240
asfcrypt.h
ff_asf_video_stream
const ff_asf_guid ff_asf_video_stream
Definition: asf.c:49
ff_asf_simple_index_header
const ff_asf_guid ff_asf_simple_index_header
Definition: asf.c:92
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
mathematics.h
ASF_UNICODE
@ ASF_UNICODE
Definition: asf.h:30
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_read_frame
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: demux.c:1412
ff_asf_stream_header
const ff_asf_guid ff_asf_stream_header
Definition: asf.c:33
ASFContext::packet_padsize
int packet_padsize
Definition: asfdec_f.c:99
AVFMT_NOBINSEARCH
#define AVFMT_NOBINSEARCH
Format does not allow to fall back on binary search via read_timestamp.
Definition: avformat.h:481
ff_asf_codec_comment_header
const ff_asf_guid ff_asf_codec_comment_header
Definition: asf.c:69
ASFContext::data_offset
uint64_t data_offset
beginning of the first data packet
Definition: asfdec_f.c:84
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:352
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:428
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
ff_seek_frame_binary
int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
Perform a binary search using av_index_search_timestamp() and AVInputFormat.read_timestamp().
Definition: seek.c:282
AVINDEX_KEYFRAME
#define AVINDEX_KEYFRAME
Definition: avformat.h:809
asf_get_packet
static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
Load a single ASF packet into the demuxer.
Definition: asfdec_f.c:876
ff_guidcmp
static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
Definition: riff.h:121
ASFContext::packet_frag_size
unsigned int packet_frag_size
Definition: asfdec_f.c:101
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:459
ASFContext::stream_index
int stream_index
Definition: asfdec_f.c:109
finish
static void finish(void)
Definition: movenc.c:342
ASFContext::hdr
ASFMainHeader hdr
Definition: asfdec_f.c:89
ASFMainHeader::flags
uint32_t flags
0x01 - broadcast 0x02 - seekable rest is reserved should be 0
Definition: asf.h:52
ffstream
static av_always_inline FFStream * ffstream(AVStream *st)
Definition: internal.h:432
ASFContext::stream_bitrates
uint32_t stream_bitrates[128]
max number of streams, bitrate for each (for streaming)
Definition: asfdec_f.c:77
U
#define U(x)
Definition: vp56_arith.h:37
ASFContext::streams
ASFStream streams[128]
it's max number and it's not that big
Definition: asfdec_f.c:76
ASFContext::uses_std_ecc
int uses_std_ecc
Definition: asfdec_f.c:116
avio_seek_time
int64_t avio_seek_time(AVIOContext *h, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
Definition: aviobuf.c:1324
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:149
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:114
av_add_index_entry
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
Definition: seek.c:117
AVSTREAM_PARSE_FULL_ONCE
@ AVSTREAM_PARSE_FULL_ONCE
full parsing and repack of the first frame only, only implemented for H.264 currently
Definition: avformat.h:795
ASFContext::data_object_size
uint64_t data_object_size
size of the data object
Definition: asfdec_f.c:86
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:141
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:504
ASFContext::ts_is_pts
int ts_is_pts
Definition: asfdec_f.c:103
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
ASF_GUID
@ ASF_GUID
Definition: asf.h:36
asf_read_ext_content_desc
static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:547
AVStream::duration
int64_t duration
Decoding: duration of the stream, in stream time base.
Definition: avformat.h:985
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:743
AVRational::num
int num
Numerator.
Definition: rational.h:59
ASFMainHeader::create_time
uint64_t create_time
time of creation, in 100-nanosecond units since 1.1.1601 invalid if broadcasting
Definition: asf.h:43
av_bswap32
#define av_bswap32
Definition: bswap.h:33
asf_read_stream_properties
static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:297
avassert.h
ASFStream::pkt_clean
int pkt_clean
Definition: asfdec_f.c:56
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
get_value
static int get_value(AVIOContext *pb, int type, int type2_size)
Definition: asfdec_f.c:205
AVInputFormat
Definition: avformat.h:650
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
asf_read_close
static int asf_read_close(AVFormatContext *s)
Definition: asfdec_f.c:1424
ASFContext::asf_st
ASFStream * asf_st
currently decoded stream
Definition: asfdec_f.c:111
avio_get_str16le
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
ASFContext::packet_frag_timestamp
int64_t packet_frag_timestamp
Definition: asfdec_f.c:102
ASFStream::duration
int64_t duration
Definition: asfdec_f.c:54
asf_read_seek
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
Definition: asfdec_f.c:1557
s
#define s(width, name)
Definition: cbs_vp9.c:257
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:99
ff_asf_data_header
const ff_asf_guid ff_asf_data_header
Definition: asf.c:76
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:655
g
const char * g
Definition: vf_curves.c:117
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:449
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
ASFContext::packet_pos
int64_t packet_pos
Definition: asfdec_f.c:107
DO_2BITS
#define DO_2BITS(bits, var, defval)
Definition: asfdec_f.c:851
asf_read_marker
static int asf_read_marker(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:649
ASFContext::dar
AVRational dar[128]
Definition: asfdec_f.c:78
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
asf_probe
static int asf_probe(const AVProbeData *pd)
Definition: asfdec_f.c:194
ASFContext::packet_property
int packet_property
Definition: asfdec_f.c:92
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ASFContext::packet_frag_offset
unsigned int packet_frag_offset
Definition: asfdec_f.c:100
FFFormatContext::data_offset
int64_t data_offset
offset of the first packet
Definition: internal.h:99
asf_read_packet
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: asfdec_f.c:1356
ASF_BYTE_ARRAY
@ ASF_BYTE_ARRAY
Definition: asf.h:31
key
const char * key
Definition: hwcontext_opencl.c:168
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
fsize
static int64_t fsize(FILE *f)
Definition: audiomatch.c:29
ASFStream::timestamp
int timestamp
Definition: asfdec_f.c:53
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:77
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:65
if
if(ret)
Definition: filter_design.txt:179
ASFMainHeader
Definition: asf.h:39
FFFormatContext
Definition: internal.h:73
FFStream::need_parsing
enum AVStreamParseType need_parsing
Definition: internal.h:405
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:54
AVFormatContext
Format I/O context.
Definition: avformat.h:1200
ASF_QWORD
@ ASF_QWORD
Definition: asf.h:34
internal.h
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: packet.h:356
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1095
AV_LANG_ISO639_2_BIBL
@ AV_LANG_ISO639_2_BIBL
Definition: avlanguage.h:28
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
ASFStream::ds_packet_size
int ds_packet_size
Definition: asfdec_f.c:59
ASFMainHeader::guid
ff_asf_guid guid
generated by client computer
Definition: asf.h:40
NULL
#define NULL
Definition: coverity.c:32
ff_asf_guid
uint8_t ff_asf_guid[16]
Definition: riff.h:95
ASFPayload::size
uint16_t size
Definition: asfdec_f.c:43
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
ff_asf_header
const ff_asf_guid ff_asf_header
Definition: asf.c:25
ASFStream::seq
unsigned char seq
Definition: asfdec_f.c:48
ff_asf_metadata_conv
const AVMetadataConv ff_asf_metadata_conv[]
Definition: asf.c:155
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
AVSTREAM_PARSE_NONE
@ AVSTREAM_PARSE_NONE
Definition: avformat.h:791
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
ASFMainHeader::ignore
uint32_t ignore
preroll is 64 bits - but let's just ignore it
Definition: asf.h:51
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:447
ASFContext::stream_languages
char stream_languages[128][6]
max number of streams, language for each (RFC1766, e.g. en-US)
Definition: asfdec_f.c:79
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:1006
ASFContext::index_read
int index_read
Definition: asfdec_f.c:87
ASFMainHeader::play_time
uint64_t play_time
play time, in 100-nanosecond units invalid if broadcasting
Definition: asf.h:45
ASFContext::packet_size_left
int packet_size_left
Definition: asfdec_f.c:82
ff_asf_head1_guid
const ff_asf_guid ff_asf_head1_guid
Definition: asf.c:80
ff_asf_digital_signature
const ff_asf_guid ff_asf_digital_signature
Definition: asf.c:138
ff_asf_handle_byte_array
int ff_asf_handle_byte_array(AVFormatContext *s, const char *name, int val_len)
Handles both attached pictures as well as id3 tags.
Definition: asf.c:269
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ASFContext::packet_seq
int packet_seq
Definition: asfdec_f.c:96
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
ASFStream::packet_pos
int64_t packet_pos
Definition: asfdec_f.c:62
ASFStream::ds_chunk_size
int ds_chunk_size
Definition: asfdec_f.c:60
AV_CODEC_ID_AAC
@ AV_CODEC_ID_AAC
Definition: codec_id.h:425
options
static const AVOption options[]
Definition: asfdec_f.c:119
ASFContext::packet_time_start
int packet_time_start
Definition: asfdec_f.c:106
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:759
AVDISCARD_NONKEY
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition: defs.h:53
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
AVMediaType
AVMediaType
Definition: avutil.h:199
AVPacket::size
int size
Definition: packet.h:374
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
FFFormatContext::parse_pkt
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
Definition: internal.h:125
ff_codec_get_id
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
Definition: utils.c:357
FFStream
Definition: internal.h:194
ASFContext::packet_time_delta
int packet_time_delta
Definition: asfdec_f.c:105
ff_convert_lang_to
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
Definition: avlanguage.c:736
start_time
static int64_t start_time
Definition: ffplay.c:330
size
int size
Definition: twinvq_data.h:10344
asf_read_metadata
static int asf_read_metadata(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:601
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
ASFPayload::type
uint8_t type
Definition: asfdec_f.c:42
ASFMainHeader::min_pktsize
uint32_t min_pktsize
size of a data packet invalid if broadcasting
Definition: asf.h:55
ASFStream::ds_span
int ds_span
Definition: asfdec_f.c:58
ASFMainHeader::max_pktsize
uint32_t max_pktsize
shall be the same as for min_pktsize invalid if broadcasting
Definition: asf.h:57
FRAME_HEADER_SIZE
#define FRAME_HEADER_SIZE
Definition: asfdec_f.c:136
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
ASF_DWORD
@ ASF_DWORD
Definition: asf.h:33
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:1004
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:372
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:632
offset
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 offset
Definition: writing_filters.txt:86
attributes.h
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
ASFContext::data_object_offset
uint64_t data_object_offset
data object offset (excl. GUID & size)
Definition: asfdec_f.c:85
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
ASFStream::payload
ASFPayload payload[8]
Definition: asfdec_f.c:70
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
ASFStream::pkt
AVPacket pkt
Definition: asfdec_f.c:50
ff_asf_command_stream
const ff_asf_guid ff_asf_command_stream
Definition: asf.c:61
ffio_limit
int ffio_limit(AVIOContext *s, int size)
Definition: aviobuf.c:1090
AV_CODEC_ID_MJPEG
@ AV_CODEC_ID_MJPEG
Definition: codec_id.h:57
ASFContext::packet_flags
int packet_flags
Definition: asfdec_f.c:91
print_guid
#define print_guid(g)
Definition: asfdec_f.c:191
ff_asf_content_encryption
const ff_asf_guid ff_asf_content_encryption
Definition: asf.c:130
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
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
internal.h
AVCodecParameters::height
int height
Definition: codec_par.h:127
ASFStream::stream_language_index
uint16_t stream_language_index
Definition: asfdec_f.c:64
ASFContext::packet_key_frame
int packet_key_frame
Definition: asfdec_f.c:98
ASFStream::frag_offset
int frag_offset
Definition: asfdec_f.c:51
ff_metadata_conv
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition: metadata.c:26
common.h
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
ff_asf_ext_stream_header
const ff_asf_guid ff_asf_ext_stream_header
Definition: asf.c:37
value
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 default value
Definition: writing_filters.txt:86
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:278
asf_read_pts
static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
Definition: asfdec_f.c:1431
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
asf_read_frame_header
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
Definition: asfdec_f.c:998
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
len
int len
Definition: vorbis_enc_data.h:426
ff_get_wav_header
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
Definition: riffdec.c:90
avpriv_new_chapter
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
Definition: utils.c:883
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
ff_asf_extended_content_header
const ff_asf_guid ff_asf_extended_content_header
Definition: asf.c:88
ASFStream::palette
uint32_t palette[256]
Definition: asfdec_f.c:67
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:197
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:949
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:935
bswap.h
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:260
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
av_hex_dump_log
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
Definition: dump.c:82
ff_asf_audio_stream
const ff_asf_guid ff_asf_audio_stream
Definition: asf.c:41
ff_asf_metadata_library_header
const ff_asf_guid ff_asf_metadata_library_header
Definition: asf.c:108
ASFStream::packet_obj_size
int packet_obj_size
Definition: asfdec_f.c:52
ASFMainHeader::file_size
uint64_t file_size
in bytes invalid if broadcasting
Definition: asf.h:41
pos
unsigned int pos
Definition: spdifenc.c:412
asf_read_file_properties
static int asf_read_file_properties(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:273
avformat.h
dict.h
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:384
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
asf.h
ASFContext::asfid2avid
int asfid2avid[128]
conversion table from asf ID 2 AVStream ID
Definition: asfdec_f.c:75
ff_codec_bmp_tags
const AVCodecTag ff_codec_bmp_tags[]
Definition: riff.c:34
ff_asf_comment_header
const ff_asf_guid ff_asf_comment_header
Definition: asf.c:65
ASFContext::packet_timestamp
int packet_timestamp
Definition: asfdec_f.c:93
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
Definition: avpacket.c:232
asf_read_language_list
static int asf_read_language_list(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:581
AVRational::den
int den
Denominator.
Definition: rational.h:60
AVFMT_NOGENSEARCH
#define AVFMT_NOGENSEARCH
Format does not allow to fall back on generic search.
Definition: avformat.h:482
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:641
ASFStream::num
int num
Definition: asfdec_f.c:47
AVIndexEntry::pos
int64_t pos
Definition: avformat.h:802
ff_asf_language_guid
const ff_asf_guid ff_asf_language_guid
Definition: asf.c:126
ff_asf_ext_content_encryption
const ff_asf_guid ff_asf_ext_content_encryption
Definition: asf.c:134
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:1196
asf_reset_header
static void asf_reset_header(AVFormatContext *s)
Definition: asfdec_f.c:1376
AVPacket::stream_index
int stream_index
Definition: packet.h:375
ASFContext::packet_multi_size
int packet_multi_size
Definition: asfdec_f.c:104
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:347
ff_asf_file_header
const ff_asf_guid ff_asf_file_header
Definition: asf.c:29
FFStream::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:277
ff_asf_metadata_header
const ff_asf_guid ff_asf_metadata_header
Definition: asf.c:104
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVCodecParameters::bits_per_coded_sample
int bits_per_coded_sample
The number of bits per sample in the codedwords.
Definition: codec_par.h:102
ASFContext
Definition: asfdec_f.c:73
ff_asf_head2_guid
const ff_asf_guid ff_asf_head2_guid
Definition: asf.c:84
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ASFMainHeader::max_bitrate
uint32_t max_bitrate
bandwidth of stream in bps should be the sum of bitrates of the individual media streams
Definition: asf.h:59
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
get_tag
static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)
Definition: asfdec_f.c:221
FFStream::request_probe
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
Definition: internal.h:291
diff
static av_always_inline int diff(const uint32_t a, const uint32_t b)
Definition: vf_palettegen.c:139
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
ff_read_frame_flush
void ff_read_frame_flush(AVFormatContext *s)
Flush the frame reader.
Definition: seek.c:714
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:70
riff.h
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:393
avio_rl64
uint64_t avio_rl64(AVIOContext *s)
Definition: aviobuf.c:767
ff_asf_my_guid
const ff_asf_guid ff_asf_my_guid
Definition: asf.c:122
d
d
Definition: ffmpeg_filter.c:153
ASFStream
Definition: asfdec_f.c:46
ASFContext::no_resync_search
int no_resync_search
Definition: asfdec_f.c:113
AVSTREAM_PARSE_FULL
@ AVSTREAM_PARSE_FULL
full parsing and repack
Definition: avformat.h:792
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ff_asf_marker_header
const ff_asf_guid ff_asf_marker_header
Definition: asf.c:112
av_strlcpy
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
Definition: avstring.c:83
AVCodecParameters::bit_rate
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
Definition: codec_par.h:89
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
read_timestamp
static int64_t read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, int64_t(*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t))
Definition: seek.c:273
asf_read_ext_stream_properties
static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size)
Definition: asfdec_f.c:468
avstring.h
ff_asf_video_conceal_none
const ff_asf_guid ff_asf_video_conceal_none
Definition: asf.c:57
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:52
snprintf
#define snprintf
Definition: snprintf.h:34
ASFPayload
Definition: asfdec_f.c:41
ASFContext::packet_replic_size
int packet_replic_size
Definition: asfdec_f.c:97
ff_asfcrypt_dec
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
Definition: asfcrypt.c:147
ASFContext::packet_segments
int packet_segments
Definition: asfdec_f.c:95
ff_asf_codec_comment1_header
const ff_asf_guid ff_asf_codec_comment1_header
Definition: asf.c:72
asf_read_header
static int asf_read_header(AVFormatContext *s)
Definition: asfdec_f.c:689
ff_asf_ext_stream_audio_stream
const ff_asf_guid ff_asf_ext_stream_audio_stream
Definition: asf.c:100
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:385
ASFStream::payload_ext_ct
int payload_ext_ct
Definition: asfdec_f.c:69
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
ASFContext::export_xmp
int export_xmp
Definition: asfdec_f.c:114
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:375