69 unsigned len,
const char *key)
73 short current, total = 0;
79 snprintf(buf,
sizeof(buf),
"%d", current);
81 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
89 unsigned len,
const char *key)
103 unsigned len,
const char *key)
112 unsigned len,
const char *key)
128 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
129 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
130 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
131 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
132 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
133 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
134 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
135 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
136 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
137 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
138 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
139 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
140 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
141 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
142 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
143 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
147 char *dst,
int dstlen)
150 char *
end = dst+dstlen-1;
153 for (i = 0; i <
len; i++) {
155 if (c < 0x80 && p < end)
208 char language[4] = { 0 };
210 uint16_t langcode = 0;
211 double longitude, latitude;
212 const char *key =
"location";
214 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
240 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f/", latitude, longitude);
241 if (*language && strcmp(language,
"und")) {
243 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
253 char key2[32], language[4] = {0};
255 const char *key =
NULL;
256 uint16_t langcode = 0;
257 uint32_t data_type = 0, str_size, str_size_alloc;
262 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
263 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
264 case MKTAG(
'X',
'M',
'P',
'_'):
265 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
266 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
267 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
269 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
270 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
271 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
273 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
274 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
275 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
277 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
279 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
281 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
283 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
284 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
285 case MKTAG(
'l',
'o',
'c',
'i'):
287 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
289 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
291 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
292 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
294 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
295 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
296 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
297 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
298 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
299 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
300 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
302 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
304 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
305 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
307 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
308 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
309 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
311 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
312 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
313 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
314 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
315 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
316 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
317 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
318 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
319 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
320 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
321 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
322 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
323 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
324 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
325 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
326 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
327 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
328 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
329 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
330 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
331 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
332 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
333 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
334 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
335 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
336 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
337 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
338 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
339 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
340 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
341 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
342 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
343 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
344 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
345 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
351 if (tag ==
MKTAG(
'd',
'a',
't',
'a')) {
354 str_size = data_size - 16;
357 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
367 if (str_size > atom.
size) {
377 str_size = atom.
size;
386 if (atom.
size < 0 || str_size >= INT_MAX/2)
390 str_size_alloc = (raw ? str_size : str_size * 2) + 1;
396 parse(c, pb, str_size, key);
398 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
402 if (ret != str_size) {
410 if (*language && strcmp(language,
"und")) {
411 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
415 av_dlog(c->
fc,
"lang \"%3s\" ", language);
416 av_dlog(c->
fc,
"tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64
"\n",
417 key, str, (
char*)&atom.
type, str_size_alloc, atom.
size);
426 int i, nb_chapters, str_len,
version;
429 if ((atom.
size -= 5) < 0)
438 for (i = 0; i < nb_chapters; i++) {
445 if ((atom.
size -= 9+str_len) < 0)
455 #define MIN_DATA_ENTRY_BOX_SIZE 12
470 entries >= UINT_MAX /
sizeof(*sc->
drefs))
489 av_dlog(c->
fc,
"type %.4s size %d\n", (
char*)&dref->
type, size);
491 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
493 uint16_t volume_len,
len;
499 volume_len =
FFMIN(volume_len, 27);
501 dref->
volume[volume_len] = 0;
507 len =
FFMIN(len, 63);
522 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
536 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
538 memmove(dref->
path, dref->
path+volume_len, len);
541 for (j = 0; j <
len; j++)
542 if (dref->
path[j] ==
':')
545 }
else if (type == 0) {
553 for (j = 0; j <
len; j++)
554 if (dref->
dir[j] ==
':')
586 av_dlog(c->
fc,
"ctype= %.4s (0x%08x)\n", (
char*)&ctype, ctype);
587 av_dlog(c->
fc,
"stype= %.4s\n", (
char*)&type);
589 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
591 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
593 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
595 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
602 title_size = atom.
size - 24;
603 if (title_size > 0) {
608 title_str[title_size] = 0;
610 int off = (!c->
isom && title_str[0] == title_size - 1);
650 int ac3info, acmod, lfeon, bsmod;
662 bsmod = (ac3info >> 14) & 0x7;
663 acmod = (ac3info >> 11) & 0x7;
664 lfeon = (ac3info >> 10) & 0x1;
665 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
682 int eac3info, acmod, lfeon, bsmod;
698 bsmod = (eac3info >> 12) & 0x1f;
699 acmod = (eac3info >> 9) & 0x7;
700 lfeon = (eac3info >> 8) & 0x1;
761 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
764 }
else if (den != 0) {
785 char* comp_brands_str;
789 if (strcmp(type,
"qt "))
796 comp_brand_size = atom.
size - 8;
797 if (comp_brand_size < 0)
799 comp_brands_str =
av_malloc(comp_brand_size + 1);
800 if (!comp_brands_str)
802 avio_read(pb, comp_brands_str, comp_brand_size);
803 comp_brands_str[comp_brand_size] = 0;
839 "read the mfra (may be a live ismv)\n");
843 "seekable, can not look for mfra\n");
855 struct tm *ptm, tmbuf;
857 if(time >= 2082844800)
862 if (strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm))
872 char language[4] = {0};
874 int64_t creation_time;
914 int64_t creation_time;
963 av_dlog(c->
fc,
"enda %d\n", little_endian);
964 if (little_endian == 1) {
988 char color_parameter_type[5] = { 0 };
996 if (strncmp(color_parameter_type,
"nclx", 4) &&
997 strncmp(color_parameter_type,
"nclc", 4)) {
999 color_parameter_type);
1007 av_dlog(c->
fc,
"%s: pri %d trc %d matrix %d",
1008 color_parameter_type, color_primaries, color_trc, color_matrix);
1012 av_dlog(c->
fc,
" full %"PRIu8
"", color_range);
1032 switch (color_primaries) {
1038 switch (color_trc) {
1043 switch (color_matrix) {
1057 unsigned mov_field_order;
1066 if ((mov_field_order & 0xFF00) == 0x0100)
1068 else if ((mov_field_order & 0xFF00) == 0x0200) {
1069 switch (mov_field_order & 0xFF) {
1092 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1106 int64_t result = atom.
size;
1115 }
else if (err < atom.
size) {
1129 uint64_t original_size;
1203 codec->
width = 1440;
1215 uint64_t original_size;
1220 if (atom.
size == 16) {
1225 if (length == atom.
size) {
1227 switch (range_value) {
1267 if ((uint64_t)atom.
size > (1<<30))
1277 }
else if (atom.
size > 8) {
1298 if ((uint64_t)atom.
size > (1<<30))
1301 if (atom.
size >= 10) {
1307 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1331 if (atom.
size >= (1<<28) || atom.
size < 7)
1335 if ((profile_level & 0xf0) != 0xc0)
1357 if (atom.
size <= 40)
1361 if ((uint64_t)atom.
size > (1<<30))
1375 unsigned int i, entries;
1399 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1402 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1435 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1436 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1443 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1467 unsigned int color_depth,
len, j;
1468 int color_greyscale;
1496 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1503 !memcmp(codec_name,
"Sorenson H263", 13))
1508 av_dlog(c->
fc,
"depth %d, ctab id %d\n",
1518 if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
1520 unsigned int color_start, color_count, color_end;
1521 unsigned char a,
r,
g,
b;
1523 if (color_greyscale) {
1524 int color_index, color_dec;
1527 color_count = 1 << color_depth;
1529 color_dec = 256 / (color_count - 1);
1530 for (j = 0; j < color_count; j++) {
1531 r = g = b = color_index;
1532 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1533 color_index -= color_dec;
1534 if (color_index < 0)
1537 }
else if (color_table_id) {
1540 color_count = 1 << color_depth;
1541 if (color_depth == 2)
1543 else if (color_depth == 4)
1548 for (j = 0; j < color_count; j++) {
1549 r = color_table[j * 3 + 0];
1550 g = color_table[j * 3 + 1];
1551 b = color_table[j * 3 + 2];
1552 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1559 if ((color_start <= 255) && (color_end <= 255)) {
1560 for (j = color_start; j <= color_end; j++) {
1571 sc->
palette[j] = (a << 24 ) | (r << 16) | (g << 8) | (b);
1582 int bits_per_sample,
flags;
1599 av_dlog(c->
fc,
"version =%d, isom =%d\n", version, c->
isom);
1601 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1608 }
else if (version == 2) {
1666 if (bits_per_sample) {
1691 y = (ycbcr >> 16) & 0xFF;
1692 cr = (ycbcr >> 8) & 0xFF;
1695 b = av_clip_uint8(1.164 * (y - 16) + 2.018 * (cb - 128));
1696 g = av_clip_uint8(1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128));
1697 r = av_clip_uint8(1.164 * (y - 16) + 1.596 * (cr - 128));
1699 return (r << 16) | (g << 8) | b;
1704 char buf[256] = {0};
1712 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
1716 for (i = 0; i < 16; i++) {
1717 uint32_t yuv =
AV_RB32(src + i * 4);
1720 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
1723 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
1763 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
1765 if (str_size > 0 && size >= (
int)str_size + 26) {
1766 char *reel_name =
av_malloc(str_size + 1);
1770 reel_name[str_size] = 0;
1772 if (*reel_name == 0) {
1797 #if CONFIG_DV_DEMUXER
1863 int codec_tag,
int format,
1869 (codec_tag != format &&
1871 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
1880 if ( codec_tag ==
AV_RL32(
"avc1") ||
1881 codec_tag ==
AV_RL32(
"hvc1") ||
1893 int pseudo_stream_id;
1900 for (pseudo_stream_id = 0;
1902 pseudo_stream_id++) {
1905 int ret, dref_id = 1;
1915 }
else if (size <= 7){
1929 av_dlog(c->
fc,
"size=%"PRId64
" 4CC= %c%c%c%c codec_type=%d\n", size,
1930 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
1954 }
else if (a.
size > 0)
1979 unsigned int i, entries;
2003 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2021 unsigned i, entries;
2039 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2056 unsigned int i, entries;
2068 av_dlog(c->
fc,
"keyframe_count = %d\n", entries);
2079 if (entries >= UINT_MAX /
sizeof(
int))
2087 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2104 unsigned int i, entries, sample_size, field_size, num_bytes;
2116 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2135 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2142 if (entries >= (UINT_MAX - 4) / field_size)
2152 num_bytes = (entries*field_size+4)>>3;
2160 if (
avio_read(pb, buf, num_bytes) < num_bytes) {
2168 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2186 unsigned int i, entries;
2188 int64_t total_sample_count=0;
2199 av_dlog(c->
fc,
"track[%i].stts.entries = %i\n",
2210 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2211 int sample_duration;
2218 if (sample_duration < 0) {
2221 sample_duration = 1;
2223 if (sample_count < 0) {
2230 av_dlog(c->
fc,
"sample_count=%d, sample_duration=%d\n",
2231 sample_count, sample_duration);
2235 && sample_count == 1
2236 && total_sample_count > 100
2237 && sample_duration/10 > duration / total_sample_count)
2238 sample_duration = duration / total_sample_count;
2239 duration+=(int64_t)sample_duration*sample_count;
2240 total_sample_count+=sample_count;
2269 unsigned int i, entries;
2284 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2290 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2297 av_dlog(c->
fc,
"count=%d, duration=%d\n",
2300 if (
FFNABS(duration) < -(1<<28) && i+2<entries) {
2325 unsigned int i, entries;
2327 uint32_t grouping_type;
2337 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2353 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2366 int64_t current_offset;
2367 int64_t current_dts = 0;
2368 unsigned int stts_index = 0;
2369 unsigned int stsc_index = 0;
2370 unsigned int stss_index = 0;
2371 unsigned int stps_index = 0;
2373 uint64_t stream_size = 0;
2377 int64_t empty_duration = 0;
2382 if (i == 0 && e->
time == -1) {
2386 edit_start_index = 1;
2387 }
else if (i == edit_start_index && e->
time >= 0) {
2388 start_time = e->
time;
2394 "a/v desync might occur, patch welcome\n");
2397 if ((empty_duration || start_time) && mov->
time_scale > 0) {
2415 unsigned int current_sample = 0;
2416 unsigned int stts_sample = 0;
2417 unsigned int sample_size;
2419 unsigned int rap_group_index = 0;
2420 unsigned int rap_group_sample = 0;
2471 if (rap_group_present && rap_group_index < sc->rap_group_count) {
2474 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
2475 rap_group_sample = 0;
2481 && !rap_group_present
2490 e->
pos = current_offset;
2492 e->
size = sample_size;
2495 av_dlog(mov->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2496 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
2497 current_offset, current_dts, sample_size, distance, keyframe);
2502 current_offset += sample_size;
2503 stream_size += sample_size;
2517 unsigned chunk_samples, total = 0;
2521 unsigned count, chunk_count;
2534 count = (chunk_samples+samples-1) / samples;
2536 count = (chunk_samples+1023) / 1024;
2539 if (i < sc->stsc_count - 1)
2543 total += chunk_count *
count;
2546 av_dlog(mov->
fc,
"chunk count %d\n", total);
2565 while (chunk_samples > 0) {
2567 unsigned size, samples;
2578 samples =
FFMIN(1024, chunk_samples);
2588 e->
pos = current_offset;
2593 av_dlog(mov->
fc,
"AVIndex stream %d, chunk %d, offset %"PRIx64
", dts %"PRId64
", "
2594 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
2597 current_offset +=
size;
2598 current_dts += samples;
2599 chunk_samples -= samples;
2611 char filename[1025];
2612 const char *src_path;
2616 src_path = strrchr(src,
'/');
2623 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
2624 if (ref->
path[l] ==
'/') {
2632 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
2633 memcpy(filename, src, src_path - src);
2634 filename[src_path -
src] = 0;
2637 av_strlcat(filename,
"../",
sizeof(filename));
2640 if (!use_absolute_path)
2644 if (strlen(filename) + 1 ==
sizeof(filename))
2649 }
else if (use_absolute_path) {
2651 "this is a possible security issue\n");
2676 if (!st)
return AVERROR(ENOMEM);
2679 if (!sc)
return AVERROR(ENOMEM);
2708 "stream %d, error opening alias: path='%s', dir='%s', "
2709 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
2714 "Skipped opening external track: "
2715 "stream %d, alias: path='%s', dir='%s', "
2716 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d."
2717 "Set enable_drefs to allow this.\n",
2734 #if FF_API_R_FRAME_RATE
2750 #if CONFIG_H261_DECODER
2753 #if CONFIG_H263_DECODER
2756 #if CONFIG_MPEG4_DECODER
2799 for (i = 0; i < 2; i++) {
2810 if (len < 12 || len - 12 > end -
avio_tell(pb))
2814 if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
2816 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
2831 if (strcmp(key,
"iTunSMPB") == 0) {
2832 int priming, remainder, samples;
2833 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
2834 if(priming>0 && priming<16384)
2838 if (strcmp(key,
"cdec") != 0) {
2862 if (len > atom.
size)
2865 if (tag ==
MKTAG(
'm',
'e',
'a',
'n') && len > 12) {
2872 domain_len =
avio_get_str(pb, len, domain,
sizeof(domain));
2879 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
2885 while (atom.
size > 8) {
2888 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
2902 int display_matrix[3][3];
2941 for (i = 0; i < 3; i++) {
2949 sc->
width = width >> 16;
2950 sc->
height = height >> 16;
2954 if (display_matrix[0][0] != (1 << 16) ||
2955 display_matrix[1][1] != (1 << 16) ||
2956 display_matrix[2][2] != (1 << 30) ||
2957 display_matrix[0][1] || display_matrix[0][2] ||
2958 display_matrix[1][0] || display_matrix[1][2] ||
2959 display_matrix[2][0] || display_matrix[2][1]) {
2968 for (i = 0; i < 3; i++)
2969 for (j = 0; j < 3; j++)
2973 if (!
isnan(rotate)) {
2974 char rotate_buf[64];
2978 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
2986 double disp_transform[2];
2988 #define SQR(a) ((a)*(double)(a))
2989 for (i = 0; i < 2; i++)
2990 disp_transform[i] = sqrt(
SQR(display_matrix[i][0]) +
SQR(display_matrix[i][1]));
2992 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
2993 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
2994 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
2996 disp_transform[0] / disp_transform[1],
3007 int flags, track_id, i;
3029 "found fragment index for track %u\n", frag->
track_id);
3049 for (i = index->
current_item; i < index->item_count; i++) {
3052 "for track %u and moof_offset %"PRId64
"\n",
3061 "but it doesn't have an (in-order) entry for moof_offset "
3139 int data_offset = 0;
3140 unsigned entries, first_sample_flags = frag->
flags;
3159 av_dlog(c->
fc,
"flags 0x%x entries %d\n", flags, entries);
3189 av_dlog(c->
fc,
"first sample flags 0x%x\n", first_sample_flags);
3190 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3191 unsigned sample_size = frag->
size;
3192 int sample_flags = i ? frag->
flags : first_sample_flags;
3193 unsigned sample_duration = frag->
duration;
3207 " sc->dts_shift %d ctts.duration %d"
3208 " sc->time_offset %"PRId64
" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
3212 if (flags & MOV_TRUN_SAMPLE_CTS) {
3221 ", using it for dts\n", dts);
3228 else if (!found_keyframe)
3229 keyframe = found_keyframe =
3239 av_dlog(c->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
3241 offset, dts, sample_size, distance, keyframe);
3243 dts += sample_duration;
3244 offset += sample_size;
3273 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
3287 long cmov_len, moov_len;
3301 cmov_len = atom.
size - 6 * 4;
3312 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
3313 goto free_and_return;
3315 goto free_and_return;
3318 atom.
size = moov_len;
3355 for (i = 0; i < edit_count && !pb->
eof_reached; i++) {
3366 av_dlog(c->
fc,
"duration=%"PRId64
" time=%"PRId64
" rate=%f\n",
3389 static const uint8_t uuid_isml_manifest[] = {
3390 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
3391 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
3394 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
3397 ret =
avio_read(pb, uuid,
sizeof(uuid));
3400 }
else if (ret !=
sizeof(uuid)) {
3403 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
3406 size_t len = atom.
size -
sizeof(uuid);
3422 }
else if (ret != len) {
3428 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
3429 ptr +=
sizeof(
"systemBitrate=\"") - 1;
3438 ret = strtol(ptr, &endptr, 10);
3439 if (ret < 0 || errno || *endptr !=
'"') {
3465 && !memcmp(content,
"Anevia\x1A\x1A", 8)
3549 int64_t total_size = 0;
3560 atom.
size = INT64_MAX;
3565 if (atom.
size >= 8) {
3572 uint32_t *
type = (uint32_t *)buf + 1;
3575 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
3576 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
3581 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
3593 if (a.
size == 1 && total_size + 8 <= atom.
size) {
3598 av_dlog(c->
fc,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
3601 a.
size = atom.
size - total_size + 8;
3608 for (i = 0; mov_default_parse_table[i].
type; i++)
3609 if (mov_default_parse_table[i].
type == a.
type) {
3624 int err =
parse(c, pb, a);
3640 else if (left < 0) {
3642 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
3643 (
char*)&a.
type, -left);
3648 total_size += a.
size;
3651 if (total_size < atom.
size && atom.
size < 0x7ffff)
3663 int moov_offset = -1;
3669 if ((offset + 8) > (
unsigned int)p->
buf_size)
3674 case MKTAG(
'm',
'o',
'o',
'v'):
3675 moov_offset = offset + 4;
3676 case MKTAG(
'm',
'd',
'a',
't'):
3677 case MKTAG(
'p',
'n',
'o',
't'):
3678 case MKTAG(
'u',
'd',
't',
'a'):
3679 case MKTAG(
'f',
't',
'y',
'p'):
3682 offset + 12 > (
unsigned int)p->
buf_size ||
3685 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
3687 score =
FFMAX(score, 5);
3694 case MKTAG(
'e',
'd',
'i',
'w'):
3695 case MKTAG(
'w',
'i',
'd',
'e'):
3696 case MKTAG(
'f',
'r',
'e',
'e'):
3697 case MKTAG(
'j',
'u',
'n',
'k'):
3698 case MKTAG(
'p',
'i',
'c',
't'):
3702 case MKTAG(0x82,0x82,0x7f,0x7d):
3703 case MKTAG(
's',
'k',
'i',
'p'):
3704 case MKTAG(
'u',
'u',
'i',
'd'):
3705 case MKTAG(
'p',
'r',
'f',
'l'):
3717 offset = moov_offset;
3719 while(offset < (p->
buf_size - 16)){
3769 if (end < sample->timestamp) {
3781 if (len > sample->
size-2)
3783 title_len = 2*len + 1;
3796 else if (ch == 0xfffe)
3800 if (len == 1 || len == 2)
3948 int version, fieldlength, i, j;
3979 if (!index->
items) {
3994 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
3996 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
3998 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
4013 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
4018 if (mfra_size < 0 || mfra_size > stream_size) {
4022 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
4042 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
4045 "failed to seek back after looking for mfra\n");
4064 atom.
size = INT64_MAX;
4097 int tmcd_st_id = -1;
4103 if (tmcd_st_id < 0 || tmcd_st_id == i)
4202 int64_t best_dts = INT64_MAX;
4213 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
4216 sample = current_sample;
4276 #if CONFIG_DV_DEMUXER
4311 av_dlog(s,
"stream %d, pts %"PRId64
", dts %"PRId64
", pos 0x%"PRIx64
", duration %d\n",
4323 av_dlog(s,
"stream %d, timestamp %"PRId64
", sample %d\n", st->
index, timestamp, sample);
4324 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
4349 int64_t seek_timestamp, timestamp;
4356 st = s->
streams[stream_index];
4369 if (stream_index == i)
4378 #define OFFSET(x) offsetof(MOVContext, x)
4379 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
4381 {
"use_absolute_path",
4382 "allow using absolute path when opening alias, this is a possible security issue",
4388 "use mfra for fragment timestamps",
4393 FLAGS,
"use_mfra_for" },
4395 FLAGS,
"use_mfra_for" },
4397 FLAGS,
"use_mfra_for" },
4398 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
4400 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
4403 {.i64 = 0}, 0, 1,
FLAGS },
4415 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
4419 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2",