72 unsigned len,
const char *key)
76 short current, total = 0;
82 snprintf(buf,
sizeof(buf),
"%d", current);
84 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
92 unsigned len,
const char *key)
106 unsigned len,
const char *key)
115 unsigned len,
const char *key)
131 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
132 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
133 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
134 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
135 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
136 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
137 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
138 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
139 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
140 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
141 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
142 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
143 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
144 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
145 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
146 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
150 char *dst,
int dstlen)
153 char *
end = dst+dstlen-1;
156 for (i = 0; i <
len; i++) {
158 if (c < 0x80 && p < end)
211 char language[4] = { 0 };
212 char buf[200], place[100];
213 uint16_t langcode = 0;
214 double longitude, latitude, altitude;
215 const char *key =
"location";
217 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
244 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f", latitude, longitude);
249 if (*language && strcmp(language,
"und")) {
251 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
261 char key2[32], language[4] = {0};
263 const char *key =
NULL;
264 uint16_t langcode = 0;
265 uint32_t data_type = 0, str_size, str_size_alloc;
270 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
271 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
272 case MKTAG(
'X',
'M',
'P',
'_'):
273 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
274 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
275 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
277 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
278 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
279 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
281 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
282 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
283 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
285 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
287 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
289 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
291 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
292 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
293 case MKTAG(
'l',
'o',
'c',
'i'):
295 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
297 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
299 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
300 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
302 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
303 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
304 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
305 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
306 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
307 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
308 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
310 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
312 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
313 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
315 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
316 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
317 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
319 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
320 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
321 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
322 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
323 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
324 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
325 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
326 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
327 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
328 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
329 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
330 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
331 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
332 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
333 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
334 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
335 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
336 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
337 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
338 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
339 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
340 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
341 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
342 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
343 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
344 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
345 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
346 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
347 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
348 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
349 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
350 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
351 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
352 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
353 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
359 if (tag ==
MKTAG(
'd',
'a',
't',
'a') && data_size <= atom.
size) {
362 str_size = data_size - 16;
365 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
375 if (str_size > atom.
size) {
385 str_size = atom.
size;
394 if (atom.
size < 0 || str_size >= INT_MAX/2)
398 str_size_alloc = (raw ? str_size : str_size * 2) + 1;
404 parse(c, pb, str_size, key);
406 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
418 if (*language && strcmp(language,
"und")) {
419 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
425 key, str, (
char*)&atom.
type, str_size_alloc, atom.
size);
434 int i, nb_chapters, str_len,
version;
438 if ((atom.
size -= 5) < 0)
447 for (i = 0; i < nb_chapters; i++) {
454 if ((atom.
size -= 9+str_len) < 0)
466 #define MIN_DATA_ENTRY_BOX_SIZE 12
481 entries >= UINT_MAX /
sizeof(*sc->
drefs))
502 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
504 uint16_t volume_len,
len;
511 volume_len =
FFMIN(volume_len, 27);
515 dref->
volume[volume_len] = 0;
521 len =
FFMIN(len, 63);
538 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
546 if (type == 2 || type == 18) {
559 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
561 memmove(dref->
path, dref->
path+volume_len, len);
564 for (j = 0; j <
len; j++)
565 if (dref->
path[j] ==
':')
568 }
else if (type == 0) {
580 for (j = 0; j <
len; j++)
581 if (dref->
dir[j] ==
':')
617 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
619 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
621 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
623 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
630 title_size = atom.
size - 24;
631 if (title_size > 0) {
641 title_str[title_size] = 0;
643 int off = (!c->
isom && title_str[0] == title_size - 1);
683 int ac3info, acmod, lfeon, bsmod;
695 bsmod = (ac3info >> 14) & 0x7;
696 acmod = (ac3info >> 11) & 0x7;
697 lfeon = (ac3info >> 10) & 0x1;
698 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
715 int eac3info, acmod, lfeon, bsmod;
731 bsmod = (eac3info >> 12) & 0x1f;
732 acmod = (eac3info >> 9) & 0x7;
733 lfeon = (eac3info >> 8) & 0x1;
794 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
797 }
else if (den != 0) {
813 #define DRM_BLOB_SIZE 56
822 uint8_t calculated_checksum[20];
847 for (i = 0; i < 20; i++)
852 if (!activation_bytes) {
884 if (memcmp(calculated_checksum, file_checksum, 20)) {
891 for (i = 0; i < 4; i++) {
893 if (activation_bytes[i] != output[3 - i]) {
899 memcpy(c->
file_key, output + 8, 16);
900 memcpy(input, output + 26, 16);
917 unsigned char iv[16];
932 char* comp_brands_str;
938 if (strcmp(type,
"qt "))
945 comp_brand_size = atom.
size - 8;
946 if (comp_brand_size < 0)
948 comp_brands_str =
av_malloc(comp_brand_size + 1);
949 if (!comp_brands_str)
957 comp_brands_str[comp_brand_size] = 0;
993 "read the mfra (may be a live ismv)\n");
997 "seekable, can not look for mfra\n");
1009 struct tm *ptm, tmbuf;
1011 if(time >= 2082844800)
1016 if (strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm))
1017 av_dict_set(metadata,
"creation_time", buffer, 0);
1026 char language[4] = {0};
1028 int64_t creation_time;
1068 int64_t creation_time;
1119 if (little_endian == 1) {
1143 char color_parameter_type[5] = { 0 };
1154 if (strncmp(color_parameter_type,
"nclx", 4) &&
1155 strncmp(color_parameter_type,
"nclc", 4)) {
1157 color_parameter_type);
1166 "%s: pri %d trc %d matrix %d",
1167 color_parameter_type, color_primaries, color_trc, color_matrix);
1169 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1189 }
else if (!strncmp(color_parameter_type,
"nclc", 4)) {
1191 switch (color_primaries) {
1197 switch (color_trc) {
1202 switch (color_matrix) {
1216 unsigned mov_field_order;
1225 if ((mov_field_order & 0xFF00) == 0x0100)
1227 else if ((mov_field_order & 0xFF00) == 0x0200) {
1228 switch (mov_field_order & 0xFF) {
1251 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1265 int64_t result = atom.
size;
1274 }
else if (err < atom.
size) {
1288 uint64_t original_size;
1362 codec->
width = 1440;
1374 uint64_t original_size;
1379 if (atom.
size == 16) {
1384 if (length == atom.
size) {
1386 switch (range_value) {
1427 if ((uint64_t)atom.
size > (1<<30))
1438 }
else if (atom.
size > 8) {
1446 if ( (buffer & 0xFFFFFFFF) ==
MKBETAG(
'f',
'r',
'm',
'a')
1447 && buffer >> 32 <= atom.
size
1448 && buffer >> 32 >= 8) {
1452 #define ALAC_EXTRADATA_SIZE 36
1485 if ((uint64_t)atom.
size > (1<<30))
1488 if (atom.
size >= 10) {
1494 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1519 if (atom.
size >= (1<<28) || atom.
size < 7)
1523 if ((profile_level & 0xf0) != 0xc0)
1547 if (atom.
size <= 40)
1551 if ((uint64_t)atom.
size > (1<<30))
1567 unsigned int i, entries;
1591 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1594 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1627 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1628 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1635 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1659 unsigned int color_depth,
len, j;
1660 int color_greyscale;
1688 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1695 !memcmp(codec_name,
"Sorenson H263", 13))
1710 if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
1712 unsigned int color_start, color_count, color_end;
1713 unsigned int a,
r,
g,
b;
1715 if (color_greyscale) {
1716 int color_index, color_dec;
1719 color_count = 1 << color_depth;
1721 color_dec = 256 / (color_count - 1);
1722 for (j = 0; j < color_count; j++) {
1723 r = g = b = color_index;
1724 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1725 color_index -= color_dec;
1726 if (color_index < 0)
1729 }
else if (color_table_id) {
1732 color_count = 1 << color_depth;
1733 if (color_depth == 2)
1735 else if (color_depth == 4)
1740 for (j = 0; j < color_count; j++) {
1741 r = color_table[j * 3 + 0];
1742 g = color_table[j * 3 + 1];
1743 b = color_table[j * 3 + 2];
1744 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1751 if ((color_start <= 255) && (color_end <= 255)) {
1752 for (j = color_start; j <= color_end; j++) {
1763 sc->
palette[j] = (a << 24 ) | (r << 16) | (g << 8) | (b);
1774 int bits_per_sample,
flags;
1793 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1800 }
else if (version == 2) {
1815 if (version == 0 || (version == 1 && sc->
audio_cid != -2)) {
1867 if (bits_per_sample) {
1892 y = (ycbcr >> 16) & 0xFF;
1893 cr = (ycbcr >> 8) & 0xFF;
1896 b = av_clip_uint8((1164 * (y - 16) + 2018 * (cb - 128)) / 1000);
1897 g = av_clip_uint8((1164 * (y - 16) - 813 * (cr - 128) - 391 * (cb - 128)) / 1000);
1898 r = av_clip_uint8((1164 * (y - 16) + 1596 * (cr - 128) ) / 1000);
1900 return (r << 16) | (g << 8) | b;
1905 char buf[256] = {0};
1913 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
1917 for (i = 0; i < 16; i++) {
1918 uint32_t yuv =
AV_RB32(src + i * 4);
1921 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
1924 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
1945 if ((
int)size != size)
1970 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
1972 if (str_size > 0 && size >= (
int)str_size + 26) {
1973 char *reel_name =
av_malloc(str_size + 1);
1977 reel_name[str_size] = 0;
1979 if (*reel_name == 0) {
2004 #if CONFIG_DV_DEMUXER
2073 int codec_tag,
int format,
2079 (codec_tag != format &&
2081 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2090 if ( codec_tag ==
AV_RL32(
"avc1") ||
2091 codec_tag ==
AV_RL32(
"hvc1") ||
2103 int pseudo_stream_id;
2110 for (pseudo_stream_id = 0;
2112 pseudo_stream_id++) {
2115 int ret, dref_id = 1;
2125 }
else if (size <= 7){
2140 "size=%"PRId64
" 4CC= %c%c%c%c/0x%08x codec_type=%d\n", size,
2141 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
2165 }
else if (a.
size > 0)
2190 unsigned int i, entries;
2214 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2232 unsigned i, entries;
2250 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2267 unsigned int i, entries;
2290 if (entries >= UINT_MAX /
sizeof(
int))
2298 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2315 unsigned int i, entries, sample_size, field_size, num_bytes;
2328 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2347 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2354 if (entries >= (UINT_MAX - 4) / field_size)
2364 num_bytes = (entries*field_size+4)>>3;
2381 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2400 unsigned int i, entries;
2402 int64_t total_sample_count=0;
2424 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2425 int sample_duration;
2431 if (sample_count < 0) {
2439 sample_count, sample_duration);
2443 && sample_count == 1
2444 && total_sample_count > 100
2445 && sample_duration/10 > duration / total_sample_count)
2446 sample_duration = duration / total_sample_count;
2447 duration+=(int64_t)sample_duration*sample_count;
2448 total_sample_count+=sample_count;
2477 unsigned int i, entries;
2492 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2499 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2509 if (
FFNABS(duration) < -(1<<28) && i+2<entries) {
2534 unsigned int i, entries;
2536 uint32_t grouping_type;
2546 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2562 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2575 int64_t current_offset;
2576 int64_t current_dts = 0;
2577 unsigned int stts_index = 0;
2578 unsigned int stsc_index = 0;
2579 unsigned int stss_index = 0;
2580 unsigned int stps_index = 0;
2582 uint64_t stream_size = 0;
2586 int64_t empty_duration = 0;
2591 if (i == 0 && e->
time == -1) {
2595 edit_start_index = 1;
2596 }
else if (i == edit_start_index && e->
time >= 0) {
2597 start_time = e->
time;
2603 "a/v desync might occur, patch welcome\n");
2606 if ((empty_duration || start_time) && mov->
time_scale > 0) {
2624 unsigned int current_sample = 0;
2625 unsigned int stts_sample = 0;
2626 unsigned int sample_size;
2628 unsigned int rap_group_index = 0;
2629 unsigned int rap_group_sample = 0;
2630 int64_t last_dts = 0;
2631 int64_t dts_correction = 0;
2636 last_dts = current_dts;
2683 if (rap_group_present && rap_group_index < sc->rap_group_count) {
2686 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
2687 rap_group_sample = 0;
2693 && !rap_group_present
2702 e->
pos = current_offset;
2704 e->
size = sample_size;
2707 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2708 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
2709 current_offset, current_dts, sample_size, distance, keyframe);
2714 current_offset += sample_size;
2715 stream_size += sample_size;
2721 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
2728 if (!dts_correction || current_dts + dts_correction > last_dts) {
2729 current_dts += dts_correction;
2733 dts_correction += current_dts - last_dts - 1;
2734 current_dts = last_dts + 1;
2736 last_dts = current_dts;
2749 unsigned chunk_samples, total = 0;
2753 unsigned count, chunk_count;
2766 count = (chunk_samples+samples-1) / samples;
2768 count = (chunk_samples+1023) / 1024;
2771 if (i < sc->stsc_count - 1)
2775 total += chunk_count *
count;
2797 while (chunk_samples > 0) {
2799 unsigned size, samples;
2803 "Zero bytes per frame, but %d samples per frame",
2817 samples =
FFMIN(1024, chunk_samples);
2827 e->
pos = current_offset;
2833 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
2836 current_offset +=
size;
2837 current_dts += samples;
2838 chunk_samples -= samples;
2854 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0, src);
2855 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0, ref);
2857 if (strlen(src) == 0) {
2859 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
2860 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
2861 strlen(src_host) + 1 >=
sizeof(src_host) ||
2862 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
2864 }
else if (strcmp(src_proto, ref_proto) ||
2865 strcmp(src_auth, ref_auth) ||
2866 strcmp(src_host, ref_host) ||
2867 src_port != ref_port) {
2884 char filename[1025];
2885 const char *src_path;
2889 src_path = strrchr(src,
'/');
2896 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
2897 if (ref->
path[l] ==
'/') {
2905 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
2906 memcpy(filename, src, src_path - src);
2907 filename[src_path -
src] = 0;
2910 av_strlcat(filename,
"../",
sizeof(filename));
2918 "Reference with mismatching origin, %s not tried for security reasons, "
2919 "set demuxer option use_absolute_path to allow it anyway\n",
2924 if(strstr(ref->
path + l + 1,
"..") ||
2925 strstr(ref->
path + l + 1,
":") ||
2926 (ref->
nlvl_from > 1 && same_origin < 0) ||
2927 (filename[0] ==
'/' && src_path == src))
2931 if (strlen(filename) + 1 ==
sizeof(filename))
2938 "this is a possible security issue\n");
2946 "Absolute path %s not tried for security reasons, "
2947 "set demuxer option use_absolute_path to allow absolute paths\n",
2971 if (!st)
return AVERROR(ENOMEM);
2974 if (!sc)
return AVERROR(ENOMEM);
3002 "stream %d, error opening alias: path='%s', dir='%s', "
3003 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
3019 #if FF_API_R_FRAME_RATE
3035 #if CONFIG_H261_DECODER
3038 #if CONFIG_H263_DECODER
3041 #if CONFIG_MPEG4_DECODER
3084 for (i = 0; i < 2; i++) {
3096 if (len < 12 || len - 12 > end -
avio_tell(pb))
3100 if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
3102 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
3121 if (strcmp(key,
"iTunSMPB") == 0) {
3122 int priming, remainder, samples;
3123 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
3124 if(priming>0 && priming<16384)
3128 if (strcmp(key,
"cdec") != 0) {
3152 if (len > atom.
size)
3155 if (tag ==
MKTAG(
'm',
'e',
'a',
'n') && len > 12) {
3162 domain_len =
avio_get_str(pb, len, domain,
sizeof(domain));
3169 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
3175 while (atom.
size > 8) {
3178 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
3192 int display_matrix[3][3];
3231 for (i = 0; i < 3; i++) {
3239 sc->
width = width >> 16;
3240 sc->
height = height >> 16;
3244 if (display_matrix[0][0] != (1 << 16) ||
3245 display_matrix[1][1] != (1 << 16) ||
3246 display_matrix[2][2] != (1 << 30) ||
3247 display_matrix[0][1] || display_matrix[0][2] ||
3248 display_matrix[1][0] || display_matrix[1][2] ||
3249 display_matrix[2][0] || display_matrix[2][1]) {
3258 for (i = 0; i < 3; i++)
3259 for (j = 0; j < 3; j++)
3263 if (!
isnan(rotate)) {
3264 char rotate_buf[64];
3268 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
3276 double disp_transform[2];
3278 #define SQR(a) ((a)*(double)(a))
3279 for (i = 0; i < 2; i++)
3280 disp_transform[i] = sqrt(
SQR(display_matrix[i][0]) +
SQR(display_matrix[i][1]));
3282 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
3283 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
3284 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
3286 disp_transform[0] / disp_transform[1],
3297 int flags, track_id, i;
3319 "found fragment index for track %u\n", frag->
track_id);
3339 for (i = index->
current_item; i < index->item_count; i++) {
3342 "for track %u and moof_offset %"PRId64
"\n",
3351 "but it doesn't have an (in-order) entry for moof_offset "
3429 int data_offset = 0;
3430 unsigned entries, first_sample_flags = frag->
flags;
3480 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3481 unsigned sample_size = frag->
size;
3482 int sample_flags = i ? frag->
flags : first_sample_flags;
3483 unsigned sample_duration = frag->
duration;
3497 " sc->dts_shift %d ctts.duration %d"
3498 " sc->time_offset %"PRId64
" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
3502 if (flags & MOV_TRUN_SAMPLE_CTS) {
3511 ", using it for dts\n", dts);
3518 else if (!found_keyframe)
3519 keyframe = found_keyframe =
3531 offset, dts, sample_size, distance, keyframe);
3533 dts += sample_duration;
3534 offset += sample_size;
3563 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
3577 long cmov_len, moov_len;
3591 cmov_len = atom.
size - 6 * 4;
3603 goto free_and_return;
3605 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
3606 goto free_and_return;
3608 goto free_and_return;
3611 atom.
size = moov_len;
3648 for (i = 0; i < edit_count && !pb->
eof_reached; i++) {
3682 static const uint8_t uuid_isml_manifest[] = {
3683 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
3684 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
3687 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
3690 ret =
avio_read(pb, uuid,
sizeof(uuid));
3693 }
else if (ret !=
sizeof(uuid)) {
3696 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
3699 size_t len = atom.
size -
sizeof(uuid);
3715 }
else if (ret != len) {
3721 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
3722 ptr +=
sizeof(
"systemBitrate=\"") - 1;
3731 ret = strtol(ptr, &endptr, 10);
3732 if (ret < 0 || errno || *endptr !=
'"') {
3758 && !memcmp(content,
"Anevia\x1A\x1A", 8)
3843 int64_t total_size = 0;
3854 atom.
size = INT64_MAX;
3859 if (atom.
size >= 8) {
3866 uint32_t *
type = (uint32_t *)buf + 1;
3870 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
3871 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
3876 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
3888 if (a.
size == 1 && total_size + 8 <= atom.
size) {
3893 av_log(c->
fc,
AV_LOG_TRACE,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
3896 a.
size = atom.
size - total_size + 8;
3903 for (i = 0; mov_default_parse_table[i].
type; i++)
3904 if (mov_default_parse_table[i].
type == a.
type) {
3919 int err =
parse(c, pb, a);
3935 else if (left < 0) {
3937 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
3938 (
char*)&a.
type, -left);
3943 total_size += a.
size;
3946 if (total_size < atom.
size && atom.
size < 0x7ffff)
3958 int moov_offset = -1;
3964 if ((offset + 8) > (
unsigned int)p->
buf_size)
3969 case MKTAG(
'm',
'o',
'o',
'v'):
3970 moov_offset = offset + 4;
3971 case MKTAG(
'm',
'd',
'a',
't'):
3972 case MKTAG(
'p',
'n',
'o',
't'):
3973 case MKTAG(
'u',
'd',
't',
'a'):
3974 case MKTAG(
'f',
't',
'y',
'p'):
3977 offset + 12 > (
unsigned int)p->
buf_size ||
3980 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
3984 score =
FFMAX(score, 5);
3991 case MKTAG(
'e',
'd',
'i',
'w'):
3992 case MKTAG(
'w',
'i',
'd',
'e'):
3993 case MKTAG(
'f',
'r',
'e',
'e'):
3994 case MKTAG(
'j',
'u',
'n',
'k'):
3995 case MKTAG(
'p',
'i',
'c',
't'):
3999 case MKTAG(0x82,0x82,0x7f,0x7d):
4000 case MKTAG(
's',
'k',
'i',
'p'):
4001 case MKTAG(
'u',
'u',
'i',
'd'):
4002 case MKTAG(
'p',
'r',
'f',
'l'):
4014 offset = moov_offset;
4016 while(offset < (p->
buf_size - 16)){
4066 if (end < sample->timestamp) {
4078 if (len > sample->
size-2)
4080 title_len = 2*len + 1;
4093 else if (ch == 0xfffe)
4097 if (len == 1 || len == 2)
4247 int version, fieldlength, i, j;
4278 if (!index->
items) {
4293 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
4295 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
4297 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
4312 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
4317 if (mfra_size < 0 || mfra_size > stream_size) {
4321 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
4341 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
4344 "failed to seek back after looking for mfra\n");
4363 atom.
size = INT64_MAX;
4396 int tmcd_st_id = -1;
4402 if (tmcd_st_id < 0 || tmcd_st_id == i)
4502 int64_t best_dts = INT64_MAX;
4513 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
4516 sample = current_sample;