45 uint32_t stream_bitrates[128];
47 char stream_languages[128][6];
99 #define ASF_MAX_STREAMS 127
100 #define FRAME_HEADER_SIZE 16
105 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
108 #define PRINT_IF_GUID(g, cmp) \
109 if (!ff_guidcmp(g, &cmp)) \
110 av_dlog(NULL, "(GUID: %s) ", # cmp)
138 else PRINT_IF_GUID(g, stream_bitrate_guid);
142 for (i = 0; i < 16; i++)
148 #define print_guid(g)
188 int ret, type, picsize, desc_len;
191 if (len < 1 + 4 + 2 + 2) {
211 if (!strncmp(mime->
str, mimetype,
sizeof(mimetype))) {
223 if (picsize >= len) {
230 desc_len = (len - picsize) * 2 + 1;
272 if (id3v2_extra_meta)
283 if ((
unsigned)len >= (UINT_MAX -
LEN) / 2)
292 }
else if (type == -1) {
295 }
else if (type == 1) {
296 if (!strcmp(key,
"WM/Picture")) {
298 }
else if (!strcmp(key,
"ID3")) {
304 }
else if (type > 1 && type <= 5) {
307 }
else if (type == 6) {
312 "Unsupported value type %d in tag %s.\n", type, key);
355 int type_specific_size, sizeX;
358 int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
383 (10000000 / 1000) - start_time;
387 test_for_ext_stream_audio = 0;
398 test_for_ext_stream_audio = 1;
413 if (test_for_ext_stream_audio) {
432 if (is_dvr_ms_audio) {
444 if (size >= (pos2 + 8 - pos1 + 24)) {
458 size - (
avio_tell(pb) - pos1 + 24) >= 51) {
495 if (tag1 ==
MKTAG(
'D',
'V',
'R',
' ')) {
509 avio_skip(pb, size - (pos2 - pos1 + 24));
519 int ext_len, payload_ext_ct, stream_ct, i;
520 uint32_t leak_rate, stream_num;
521 unsigned int stream_languageid_index;
536 if (stream_num < 128)
543 if (stream_num < 128) {
548 for (i = 0; i < stream_ct; i++) {
554 for (i = 0; i < payload_ext_ct; i++) {
575 int len1, len2, len3, len4, len5;
582 get_tag(s,
"title", 0, len1, 32);
583 get_tag(s,
"author", 0, len2, 32);
584 get_tag(s,
"copyright", 0, len3, 32);
585 get_tag(s,
"comment", 0, len4, 32);
595 int desc_count, i, ret;
598 for (i = 0; i < desc_count; i++) {
599 int name_len, value_type, value_len;
609 if (!value_type && value_len % 2)
614 if (!strcmp(name,
"AspectRatioX"))
616 else if (!strcmp(name,
"AspectRatioY"))
619 get_tag(s, name, value_type, value_len, 32);
631 for (j = 0; j < stream_count; j++) {
633 unsigned int lang_len =
avio_r8(pb);
635 sizeof(lang))) < lang_len)
649 int n, stream_num, name_len, value_len;
653 for (i = 0; i < n; i++) {
665 av_dlog(s,
"%d stream %d name_len %2d type %d len %4d <%s>\n",
666 i, stream_num, name_len, value_type, value_len, name);
668 if (!strcmp(name,
"AspectRatioX")){
671 asf->
dar[stream_num].
num = aspect_x;
672 }
else if(!strcmp(name,
"AspectRatioY")){
675 asf->
dar[stream_num].
den = aspect_y;
677 get_tag(s, name, value_type, value_len, 16);
687 int i, count, name_len, ret;
695 for (i = 0; i < name_len; i++)
698 for (i = 0; i < count; i++) {
709 sizeof(name))) < name_len)
743 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100)
787 "DRM protected stream detected, decoding will likely fail!\n");
792 get_tag(s,
"ASF_Protection_Type", -1, len, 32);
794 get_tag(s,
"ASF_Key_ID", -1, len, 32);
796 get_tag(s,
"ASF_License_URL", -1, len, 32);
799 "Ext DRM protected stream detected, decoding will likely fail!\n");
808 "gpos mismatch our pos=%"PRIu64
", end=%"PRId64
"\n",
821 for (i = 0; i < 128; i++) {
823 if (stream_num >= 0) {
831 }
else if ((asf->
dar[0].
num > 0) && (asf->
dar[0].
den > 0) &&
838 av_dlog(s,
"i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
845 if (rfc1766 && strlen(rfc1766) > 1) {
846 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
861 #define DO_2BITS(bits, var, defval) \
862 switch (bits & 3) { \
864 var = avio_rl32(pb); \
868 var = avio_rl16(pb); \
889 uint32_t packet_length, padsize;
905 if (c == 0x82 && !d && !e)
918 "ff asf bad header %x at:%"PRId64
"\n", c,
avio_tell(pb));
920 if ((c & 0x8f) == 0x82) {
941 if (!packet_length || packet_length >= (1
U << 29)) {
943 "invalid packet_length %d at:%"PRId64
"\n",
947 if (padsize >= packet_length) {
949 "invalid padsize %d at:%"PRId64
"\n", padsize,
avio_tell(pb));
965 if (rsize > packet_length - padsize) {
968 "invalid packet header length %d for pktlen %d-%d at %"PRId64
"\n",
969 rsize, packet_length, padsize,
avio_tell(pb));
973 if (packet_length < asf->hdr.min_pktsize)
976 av_dlog(s,
"packet: size=%d padsize=%d left=%d\n",
997 asfst = &asf->
streams[num & 0x7f];
1002 av_dlog(asf,
"key:%d stream:%d seq:%d offset:%d replic_size:%d\n",
1187 "freeing incomplete packet size %d, new %d\n",
1210 av_dlog(asf,
"new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1222 av_dlog(asf,
"READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n",
1232 "packet fragment position invalid %u,%u not in %u\n",
1241 if (ret < 0 || asf->packet_frag_offset + ret == 0)
1280 "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1289 memset(newdata + asf_st->
pkt.
size, 0,
1291 while (offset < asf_st->pkt.
size) {
1293 int row = off / asf_st->
ds_span;
1294 int col = off % asf_st->
ds_span;
1298 memcpy(newdata + offset,
1384 int64_t *ppos, int64_t pos_limit)
1389 int64_t pos = *ppos;
1463 int64_t itime, last_pos = -1;
1472 "itime:0x%"PRIx64
", pct:%d, ict:%d\n", itime, pct, ict);
1474 for (i = 0; i < ict; i++) {
1480 if (pos != last_pos) {
1482 pktnum, pktct, index_pts);
1494 int64_t pts,
int flags)
1546 .priv_class = &asf_class,