46 uint32_t stream_bitrates[128];
48 char stream_languages[128][6];
100 #define ASF_MAX_STREAMS 127
101 #define FRAME_HEADER_SIZE 16
106 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
109 #define PRINT_IF_GUID(g, cmp) \
110 if (!ff_guidcmp(g, &cmp)) \
111 av_dlog(NULL, "(GUID: %s) ", # cmp)
139 else PRINT_IF_GUID(g, stream_bitrate_guid);
142 av_dlog(NULL,
"(GUID: unknown) ");
143 for (i = 0; i < 16; i++)
144 av_dlog(NULL,
" 0x%02x,", (*g)[i]);
149 #define print_guid(g)
189 int ret,
type, picsize, desc_len;
192 if (len < 1 + 4 + 2 + 2) {
212 if (!strncmp(mime->
str, mimetype,
sizeof(mimetype))) {
224 if (picsize >= len) {
231 desc_len = (len - picsize) * 2 + 1;
273 if (id3v2_extra_meta)
284 if ((
unsigned)len >= (UINT_MAX -
LEN) / 2)
293 }
else if (type == -1) {
296 }
else if (type == 1) {
297 if (!strcmp(key,
"WM/Picture")) {
299 }
else if (!strcmp(key,
"ID3")) {
305 }
else if (type > 1 && type <= 5) {
308 }
else if (type == 6) {
313 "Unsupported value type %d in tag %s.\n", type, key);
356 int type_specific_size, sizeX;
359 int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
379 (10000000 / 1000) - start_time;
383 test_for_ext_stream_audio = 0;
394 test_for_ext_stream_audio = 1;
410 if (test_for_ext_stream_audio) {
429 if (is_dvr_ms_audio) {
441 if (size >= (pos2 + 8 - pos1 + 24)) {
455 size - (
avio_tell(pb) - pos1 + 24) >= 51) {
494 if (tag1 ==
MKTAG(
'D',
'V',
'R',
' ')) {
510 avio_skip(pb, size - (pos2 - pos1 + 24));
520 int ext_len, payload_ext_ct, stream_ct, i;
521 uint32_t leak_rate, stream_num;
522 unsigned int stream_languageid_index;
537 if (stream_num < 128)
544 if (stream_num < 128) {
549 for (i = 0; i < stream_ct; i++) {
555 for (i = 0; i < payload_ext_ct; i++) {
576 int len1, len2, len3, len4, len5;
583 get_tag(s,
"title", 0, len1, 32);
584 get_tag(s,
"author", 0, len2, 32);
585 get_tag(s,
"copyright", 0, len3, 32);
586 get_tag(s,
"comment", 0, len4, 32);
596 int desc_count, i,
ret;
599 for (i = 0; i < desc_count; i++) {
600 int name_len, value_type, value_len;
610 if (!value_type && value_len % 2)
615 if (!strcmp(name,
"AspectRatioX"))
617 else if (!strcmp(name,
"AspectRatioY"))
620 get_tag(s, name, value_type, value_len, 32);
632 for (j = 0; j < stream_count; j++) {
634 unsigned int lang_len =
avio_r8(pb);
636 sizeof(lang))) < lang_len)
650 int n, stream_num, name_len, value_len;
654 for (i = 0; i <
n; i++) {
666 av_dlog(s,
"%d stream %d name_len %2d type %d len %4d <%s>\n",
667 i, stream_num, name_len, value_type, value_len, name);
669 if (!strcmp(name,
"AspectRatioX")){
672 asf->
dar[stream_num].
num = aspect_x;
673 }
else if(!strcmp(name,
"AspectRatioY")){
676 asf->
dar[stream_num].
den = aspect_y;
678 get_tag(s, name, value_type, value_len, 16);
697 for (i = 0; i < name_len; i++)
700 for (i = 0; i <
count; i++) {
712 sizeof(name))) < name_len)
738 for (i = 0; i<128; i++)
750 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100)
796 "DRM protected stream detected, decoding will likely fail!\n");
801 get_tag(s,
"ASF_Protection_Type", -1, len, 32);
803 get_tag(s,
"ASF_Key_ID", -1, len, 32);
805 get_tag(s,
"ASF_License_URL", -1, len, 32);
808 "Ext DRM protected stream detected, decoding will likely fail!\n");
817 "gpos mismatch our pos=%"PRIu64
", end=%"PRId64
"\n",
830 for (i = 0; i < 128; i++) {
832 if (stream_num >= 0) {
840 }
else if ((asf->
dar[0].
num > 0) && (asf->
dar[0].
den > 0) &&
847 av_dlog(s,
"i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
854 if (rfc1766 && strlen(rfc1766) > 1) {
855 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
870 #define DO_2BITS(bits, var, defval) \
871 switch (bits & 3) { \
873 var = avio_rl32(pb); \
877 var = avio_rl16(pb); \
898 uint32_t packet_length, padsize;
914 if (c == 0x82 && !d && !e)
927 "ff asf bad header %x at:%"PRId64
"\n", c,
avio_tell(pb));
929 if ((c & 0x8f) == 0x82) {
950 if (!packet_length || packet_length >= (1
U << 29)) {
952 "invalid packet_length %"PRIu32
" at:%"PRId64
"\n",
956 if (padsize >= packet_length) {
958 "invalid padsize %"PRIu32
" at:%"PRId64
"\n", padsize,
avio_tell(pb));
974 if (rsize > packet_length - padsize) {
977 "invalid packet header length %d for pktlen %"PRIu32
"-%"PRIu32
" at %"PRId64
"\n",
978 rsize, packet_length, padsize,
avio_tell(pb));
982 if (packet_length < asf->hdr.min_pktsize)
985 av_dlog(s,
"packet: size=%d padsize=%d left=%d\n",
1006 asfst = &asf->
streams[num & 0x7f];
1011 av_dlog(asf,
"key:%d stream:%d seq:%d offset:%d replic_size:%d\n",
1170 av_dlog(s,
"skipping asf data pkt with fragment offset for "
1171 "stream:%d, expected:%d but got %d from pkt)\n",
1202 "freeing incomplete packet size %d, new %d\n",
1230 av_dlog(asf,
"new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1242 av_dlog(asf,
"READ PACKET s:%d os:%d o:%d,%d l:%d DATA:%p\n",
1252 "packet fragment position invalid %u,%u not in %u\n",
1266 if (ret < 0 || asf->packet_frag_offset + ret == 0)
1305 "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1315 memset(newdata + asf_st->
pkt.
size, 0,
1317 while (offset < asf_st->pkt.
size) {
1319 int row = off / asf_st->
ds_span;
1320 int col = off % asf_st->
ds_span;
1324 memcpy(newdata + offset,
1337 #if FF_API_DESTRUCT_PACKET
1396 for (i = 0; i < 128; i++) {
1411 for (i = 0; i < 128; i++) {
1429 int64_t *ppos, int64_t pos_limit)
1435 int64_t pos = *ppos;
1509 int64_t itime, last_pos = -1;
1519 "itime:0x%"PRIx64
", pct:%d, ict:%d\n", itime, pct, ict);
1521 for (i = 0; i < ict; i++) {
1527 if (pos != last_pos) {
1529 pktnum, pktct, index_pts);
1546 int64_t pts,
int flags)
1611 .priv_class = &asf_class,