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