44 uint32_t stream_bitrates[128];
46 char stream_languages[128][6];
97 #define ASF_MAX_STREAMS 127
98 #define FRAME_HEADER_SIZE 16
103 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
106 #define PRINT_IF_GUID(g, cmp) \
107 if (!ff_guidcmp(g, &cmp)) \
108 av_dlog(NULL, "(GUID: %s) ", # cmp)
136 else PRINT_IF_GUID(g, stream_bitrate_guid);
139 av_dlog(NULL,
"(GUID: unknown) ");
140 for (i = 0; i < 16; i++)
141 av_dlog(NULL,
" 0x%02x,", (*g)[i]);
146 #define print_guid(g)
186 int ret,
type, picsize, desc_len;
189 if (len < 1 + 4 + 2 + 2) {
209 if (!strncmp(mime->
str, mimetype,
sizeof(mimetype))) {
221 if (picsize >= len) {
228 desc_len = (len - picsize) * 2 + 1;
270 if (id3v2_extra_meta)
281 if ((
unsigned)len >= (UINT_MAX -
LEN) / 2)
290 }
else if (type == -1) {
293 }
else if (type == 1) {
294 if (!strcmp(key,
"WM/Picture")) {
296 }
else if (!strcmp(key,
"ID3")) {
302 }
else if (type > 1 && type <= 5) {
305 }
else if (type == 6) {
310 "Unsupported value type %d in tag %s.\n", type, key);
353 int type_specific_size, sizeX;
356 int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
375 (10000000 / 1000) - start_time;
379 test_for_ext_stream_audio = 0;
390 test_for_ext_stream_audio = 1;
406 if (test_for_ext_stream_audio) {
425 if (is_dvr_ms_audio) {
437 if (size >= (pos2 + 8 - pos1 + 24)) {
451 size - (
avio_tell(pb) - pos1 + 24) >= 51) {
490 if (tag1 ==
MKTAG(
'D',
'V',
'R',
' ')) {
504 avio_skip(pb, size - (pos2 - pos1 + 24));
514 int ext_len, payload_ext_ct, stream_ct, i;
515 uint32_t leak_rate, stream_num;
516 unsigned int stream_languageid_index;
531 if (stream_num < 128)
538 if (stream_num < 128) {
543 for (i = 0; i < stream_ct; i++) {
549 for (i = 0; i < payload_ext_ct; i++) {
570 int len1, len2, len3, len4, len5;
577 get_tag(s,
"title", 0, len1, 32);
578 get_tag(s,
"author", 0, len2, 32);
579 get_tag(s,
"copyright", 0, len3, 32);
580 get_tag(s,
"comment", 0, len4, 32);
590 int desc_count, i,
ret;
593 for (i = 0; i < desc_count; i++) {
594 int name_len, value_type, value_len;
604 if (!value_type && value_len % 2)
609 if (!strcmp(name,
"AspectRatioX"))
611 else if (!strcmp(name,
"AspectRatioY"))
614 get_tag(s, name, value_type, value_len, 32);
626 for (j = 0; j < stream_count; j++) {
628 unsigned int lang_len =
avio_r8(pb);
630 sizeof(lang))) < lang_len)
644 int n, stream_num, name_len, value_len;
648 for (i = 0; i <
n; i++) {
660 av_dlog(s,
"%d stream %d name_len %2d type %d len %4d <%s>\n",
661 i, stream_num, name_len, value_type, value_len, name);
663 if (!strcmp(name,
"AspectRatioX")){
666 asf->
dar[stream_num].
num = aspect_x;
667 }
else if(!strcmp(name,
"AspectRatioY")){
670 asf->
dar[stream_num].
den = aspect_y;
672 get_tag(s, name, value_type, value_len, 16);
691 for (i = 0; i < name_len; i++)
694 for (i = 0; i <
count; i++) {
706 sizeof(name))) < name_len)
732 for (i = 0; i<128; i++)
744 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100)
790 "DRM protected stream detected, decoding will likely fail!\n");
795 get_tag(s,
"ASF_Protection_Type", -1, len, 32);
797 get_tag(s,
"ASF_Key_ID", -1, len, 32);
799 get_tag(s,
"ASF_License_URL", -1, len, 32);
802 "Ext DRM protected stream detected, decoding will likely fail!\n");
811 "gpos mismatch our pos=%"PRIu64
", end=%"PRId64
"\n",
824 for (i = 0; i < 128; i++) {
826 if (stream_num >= 0) {
834 }
else if ((asf->
dar[0].
num > 0) && (asf->
dar[0].
den > 0) &&
841 av_dlog(s,
"i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
848 if (rfc1766 && strlen(rfc1766) > 1) {
849 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
864 #define DO_2BITS(bits, var, defval) \
865 switch (bits & 3) { \
867 var = avio_rl32(pb); \
871 var = avio_rl16(pb); \
892 uint32_t packet_length, padsize;
908 if (c == 0x82 && !d && !e)
921 "ff asf bad header %x at:%"PRId64
"\n", c,
avio_tell(pb));
923 if ((c & 0x8f) == 0x82) {
944 if (!packet_length || packet_length >= (1
U << 29)) {
946 "invalid packet_length %d at:%"PRId64
"\n",
950 if (padsize >= packet_length) {
952 "invalid padsize %d at:%"PRId64
"\n", padsize,
avio_tell(pb));
968 if (rsize > packet_length - padsize) {
971 "invalid packet header length %d for pktlen %d-%d at %"PRId64
"\n",
972 rsize, packet_length, padsize,
avio_tell(pb));
976 if (packet_length < asf->hdr.min_pktsize)
979 av_dlog(s,
"packet: size=%d padsize=%d left=%d\n",
1000 asfst = &asf->
streams[num & 0x7f];
1005 av_dlog(asf,
"key:%d stream:%d seq:%d offset:%d replic_size:%d\n",
1184 "freeing incomplete packet size %d, new %d\n",
1207 av_dlog(asf,
"new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1219 av_dlog(asf,
"READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n",
1229 "packet fragment position invalid %u,%u not in %u\n",
1238 if (ret < 0 || asf->packet_frag_offset + ret == 0)
1277 "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1287 memset(newdata + asf_st->
pkt.
size, 0,
1289 while (offset < asf_st->pkt.
size) {
1291 int row = off / asf_st->
ds_span;
1292 int col = off % asf_st->
ds_span;
1296 memcpy(newdata + offset,
1309 #if FF_API_DESTRUCT_PACKET
1311 asf_st->
pkt.destruct = NULL;
1369 for (i = 0; i < 128; i++) {
1384 for (i = 0; i < 128; i++) {
1402 int64_t *ppos, int64_t pos_limit)
1408 int64_t pos = *ppos;
1482 int64_t itime, last_pos = -1;
1491 "itime:0x%"PRIx64
", pct:%d, ict:%d\n", itime, pct, ict);
1493 for (i = 0; i < ict; i++) {
1499 if (pos != last_pos) {
1501 pktnum, pktct, index_pts);
1513 int64_t pts,
int flags)
1567 .priv_class = &asf_class,