43 uint32_t stream_bitrates[128];
45 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;
381 (10000000 / 1000) - start_time;
385 test_for_ext_stream_audio = 0;
396 test_for_ext_stream_audio = 1;
411 if (test_for_ext_stream_audio) {
430 if (is_dvr_ms_audio) {
442 if (size >= (pos2 + 8 - pos1 + 24)) {
456 size - (
avio_tell(pb) - pos1 + 24) >= 51) {
493 if (tag1 ==
MKTAG(
'D',
'V',
'R',
' ')) {
507 avio_skip(pb, size - (pos2 - pos1 + 24));
517 int ext_len, payload_ext_ct, stream_ct, i;
518 uint32_t leak_rate, stream_num;
519 unsigned int stream_languageid_index;
534 if (stream_num < 128)
541 if (stream_num < 128) {
546 for (i = 0; i < stream_ct; i++) {
552 for (i = 0; i < payload_ext_ct; i++) {
573 int len1, len2, len3, len4, len5;
580 get_tag(s,
"title", 0, len1, 32);
581 get_tag(s,
"author", 0, len2, 32);
582 get_tag(s,
"copyright", 0, len3, 32);
583 get_tag(s,
"comment", 0, len4, 32);
593 int desc_count, i,
ret;
596 for (i = 0; i < desc_count; i++) {
597 int name_len, value_type, value_len;
607 if (!value_type && value_len % 2)
612 if (!strcmp(name,
"AspectRatioX"))
614 else if (!strcmp(name,
"AspectRatioY"))
617 get_tag(s, name, value_type, value_len, 32);
629 for (j = 0; j < stream_count; j++) {
631 unsigned int lang_len =
avio_r8(pb);
633 sizeof(lang))) < lang_len)
647 int n, stream_num, name_len, value_len;
651 for (i = 0; i <
n; i++) {
663 av_dlog(s,
"%d stream %d name_len %2d type %d len %4d <%s>\n",
664 i, stream_num, name_len, value_type, value_len, name);
666 if (!strcmp(name,
"AspectRatioX")){
669 asf->
dar[stream_num].
num = aspect_x;
670 }
else if(!strcmp(name,
"AspectRatioY")){
673 asf->
dar[stream_num].
den = aspect_y;
675 get_tag(s, name, value_type, value_len, 16);
693 for (i = 0; i < name_len; i++)
696 for (i = 0; i <
count; i++) {
707 sizeof(name))) < name_len)
741 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100)
785 "DRM protected stream detected, decoding will likely fail!\n");
790 get_tag(s,
"ASF_Protection_Type", -1, len, 32);
792 get_tag(s,
"ASF_Key_ID", -1, len, 32);
794 get_tag(s,
"ASF_License_URL", -1, len, 32);
797 "Ext DRM protected stream detected, decoding will likely fail!\n");
806 "gpos mismatch our pos=%"PRIu64
", end=%"PRId64
"\n",
819 for (i = 0; i < 128; i++) {
821 if (stream_num >= 0) {
829 }
else if ((asf->
dar[0].
num > 0) && (asf->
dar[0].
den > 0) &&
836 av_dlog(s,
"i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
843 if (rfc1766 && strlen(rfc1766) > 1) {
844 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
859 #define DO_2BITS(bits, var, defval) \
860 switch (bits & 3) { \
862 var = avio_rl32(pb); \
866 var = avio_rl16(pb); \
887 uint32_t packet_length, padsize;
903 if (c == 0x82 && !d && !e)
916 "ff asf bad header %x at:%"PRId64
"\n", c,
avio_tell(pb));
918 if ((c & 0x8f) == 0x82) {
939 if (!packet_length || packet_length >= (1
U << 29)) {
941 "invalid packet_length %d at:%"PRId64
"\n",
945 if (padsize >= packet_length) {
947 "invalid padsize %d at:%"PRId64
"\n", padsize,
avio_tell(pb));
963 if (rsize > packet_length - padsize) {
966 "invalid packet header length %d for pktlen %d-%d at %"PRId64
"\n",
967 rsize, packet_length, padsize,
avio_tell(pb));
971 if (packet_length < asf->hdr.min_pktsize)
974 av_dlog(s,
"packet: size=%d padsize=%d left=%d\n",
995 asfst = &asf->
streams[num & 0x7f];
1000 av_dlog(asf,
"key:%d stream:%d seq:%d offset:%d replic_size:%d\n",
1185 "freeing incomplete packet size %d, new %d\n",
1208 av_dlog(asf,
"new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1220 av_dlog(asf,
"READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n",
1230 "packet fragment position invalid %u,%u not in %u\n",
1239 if (ret < 0 || asf->packet_frag_offset + ret == 0)
1278 "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1288 memset(newdata + asf_st->
pkt.
size, 0,
1290 while (offset < asf_st->pkt.
size) {
1292 int row = off / asf_st->
ds_span;
1293 int col = off % asf_st->
ds_span;
1297 memcpy(newdata + offset,
1310 #if FF_API_DESTRUCT_PACKET
1311 asf_st->
pkt.destruct = NULL;
1388 int64_t *ppos, int64_t pos_limit)
1393 int64_t pos = *ppos;
1467 int64_t itime, last_pos = -1;
1476 "itime:0x%"PRIx64
", pct:%d, ict:%d\n", itime, pct, ict);
1478 for (i = 0; i < ict; i++) {
1484 if (pos != last_pos) {
1486 pktnum, pktct, index_pts);
1498 int64_t pts,
int flags)
1550 .priv_class = &asf_class,