75 unsigned len,
const char *key)
79 short current, total = 0;
85 snprintf(buf,
sizeof(buf),
"%d", current);
87 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
95 unsigned len,
const char *key)
109 unsigned len,
const char *key)
118 unsigned len,
const char *key)
134 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
135 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
136 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
137 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
138 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
139 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
140 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
141 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
142 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
143 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
144 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
145 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
146 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
147 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
148 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
149 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
153 char *dst,
int dstlen)
156 char *
end = dst+dstlen-1;
159 for (i = 0; i <
len; i++) {
161 if (c < 0x80 && p < end)
223 char language[4] = { 0 };
224 char buf[200], place[100];
225 uint16_t langcode = 0;
226 double longitude, latitude, altitude;
227 const char *key =
"location";
229 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
249 "loci too short (%u bytes left, need at least %d)\n", len, 12);
257 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f", latitude, longitude);
262 if (*language && strcmp(language,
"und")) {
264 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
291 char key2[32], language[4] = {0};
293 const char *key =
NULL;
294 uint16_t langcode = 0;
295 uint32_t data_type = 0, str_size, str_size_alloc;
301 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
302 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
303 case MKTAG(
'X',
'M',
'P',
'_'):
304 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
305 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
306 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
308 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
309 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
310 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
312 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
313 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
314 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
316 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
318 case MKTAG(
'F',
'I',
'R',
'M'): key =
"firmware"; raw = 1;
break;
319 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
321 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
323 case MKTAG(
'H',
'M',
'M',
'T'):
325 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
326 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
327 case MKTAG(
'l',
'o',
'c',
'i'):
329 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
331 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
333 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
334 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
336 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
337 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
338 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
339 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
340 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
341 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
342 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
344 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
346 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
347 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
349 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
350 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
351 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
353 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
354 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
355 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
356 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
357 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
358 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
359 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
360 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
361 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
362 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
363 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
364 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
365 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
366 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
367 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
368 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
369 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
370 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
371 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
372 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
373 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
374 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
375 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
376 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
377 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
378 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
379 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
380 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
381 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
382 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
383 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
384 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
385 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
386 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
387 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
393 if (tag ==
MKTAG(
'd',
'a',
't',
'a') && data_size <= atom.
size) {
396 str_size = data_size - 16;
399 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
407 if (index < c->meta_keys_count) {
411 "The index of 'data' is out of range: %d >= %d.\n",
418 if (str_size > atom.
size) {
428 str_size = atom.
size;
437 if (atom.
size < 0 || str_size >= INT_MAX/2)
442 num = (data_type >= 21 && data_type <= 23);
443 str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1;
449 parse(c, pb, str_size, key);
451 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
453 }
else if (data_type == 21) {
457 else if (str_size == 2)
459 else if (str_size == 3)
461 else if (str_size == 4)
463 if (
snprintf(str, str_size_alloc,
"%d", val) >= str_size_alloc) {
465 "Failed to store the number (%d) in string.\n", val);
469 }
else if (data_type == 22) {
470 unsigned int val = 0;
473 else if (str_size == 2)
475 else if (str_size == 3)
477 else if (str_size == 4)
479 if (
snprintf(str, str_size_alloc,
"%u", val) >= str_size_alloc) {
481 "Failed to store the number (%u) in string.\n", val);
485 }
else if (data_type == 23 && str_size >= 4) {
487 if (
snprintf(str, str_size_alloc,
"%f", val) >= str_size_alloc) {
489 "Failed to store the float32 number (%f) in string.\n", val);
503 if (*language && strcmp(language,
"und")) {
504 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
507 if (!strcmp(key,
"encoder")) {
508 int major, minor, micro;
509 if (sscanf(str,
"HandBrake %d.%d.%d", &major, &minor, µ) == 3) {
516 key, str, (
char*)&atom.
type, str_size_alloc, atom.
size);
525 int i, nb_chapters, str_len,
version;
532 if ((atom.
size -= 5) < 0)
541 for (i = 0; i < nb_chapters; i++) {
548 if ((atom.
size -= 9+str_len) < 0)
560 #define MIN_DATA_ENTRY_BOX_SIZE 12
576 entries >= UINT_MAX /
sizeof(*sc->
drefs))
586 for (i = 0; i < entries; i++) {
598 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
600 uint16_t volume_len,
len;
607 volume_len =
FFMIN(volume_len, 27);
611 dref->
volume[volume_len] = 0;
617 len =
FFMIN(len, 63);
634 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
653 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
655 memmove(dref->
path, dref->
path+volume_len, len);
659 for (j = len - 1; j >= 0; j--) {
660 if (dref->
path[j] == 0)
665 for (j = 0; j <
len; j++)
666 if (dref->
path[j] ==
':' || dref->
path[j] == 0)
669 }
else if (type == 0) {
681 for (j = 0; j <
len; j++)
682 if (dref->
dir[j] ==
':')
719 if (type ==
MKTAG(
'm',
'd',
't',
'a')) {
727 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
729 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
731 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
733 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
740 title_size = atom.
size - 24;
741 if (title_size > 0) {
751 title_str[title_size] = 0;
753 int off = (!c->
isom && title_str[0] == title_size - 1);
793 int ac3info, acmod, lfeon, bsmod;
805 bsmod = (ac3info >> 14) & 0x7;
806 acmod = (ac3info >> 11) & 0x7;
807 lfeon = (ac3info >> 10) & 0x1;
816 #if FF_API_LAVF_AVCTX
818 st->codec->audio_service_type = *ast;
829 int eac3info, acmod, lfeon, bsmod;
845 bsmod = (eac3info >> 12) & 0x1f;
846 acmod = (eac3info >> 9) & 0x7;
847 lfeon = (eac3info >> 8) & 0x1;
856 #if FF_API_LAVF_AVCTX
858 st->codec->audio_service_type = *ast;
867 const uint32_t ddts_size = 20;
870 uint32_t frame_duration_code = 0;
871 uint32_t channel_layout_code = 0;
878 if (
avio_read(pb, buf, ddts_size) < ddts_size) {
894 frame_duration_code =
get_bits(&gb, 2);
896 channel_layout_code =
get_bits(&gb, 16);
899 (frame_duration_code == 0) ? 512 :
900 (frame_duration_code == 1) ? 1024 :
901 (frame_duration_code == 2) ? 2048 :
902 (frame_duration_code == 3) ? 4096 : 0;
904 if (channel_layout_code > 0xff) {
967 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
970 }
else if (den != 0) {
986 #define DRM_BLOB_SIZE 56
995 uint8_t calculated_checksum[20];
1020 for (i = 0; i < 20; i++)
1025 if (!activation_bytes) {
1057 if (memcmp(calculated_checksum, file_checksum, 20)) {
1064 for (i = 0; i < 4; i++) {
1066 if (activation_bytes[i] != output[3 - i]) {
1072 memcpy(c->
file_key, output + 8, 16);
1073 memcpy(input, output + 26, 16);
1090 unsigned char iv[16];
1104 int comp_brand_size;
1105 char* comp_brands_str;
1111 if (strcmp(type,
"qt "))
1118 comp_brand_size = atom.
size - 8;
1119 if (comp_brand_size < 0)
1121 comp_brands_str =
av_malloc(comp_brand_size + 1);
1122 if (!comp_brands_str)
1130 comp_brands_str[comp_brand_size] = 0;
1166 "read the mfra (may be a live ismv)\n");
1170 "seekable, can not look for mfra\n");
1181 if(time >= 2082844800)
1192 char language[4] = {0};
1194 int64_t creation_time;
1234 int64_t creation_time;
1285 if (little_endian == 1) {
1309 char color_parameter_type[5] = { 0 };
1320 if (strncmp(color_parameter_type,
"nclx", 4) &&
1321 strncmp(color_parameter_type,
"nclc", 4)) {
1323 color_parameter_type);
1332 "%s: pri %d trc %d matrix %d",
1333 color_parameter_type, color_primaries, color_trc, color_matrix);
1335 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1360 unsigned mov_field_order;
1369 if ((mov_field_order & 0xFF00) == 0x0100)
1371 else if ((mov_field_order & 0xFF00) == 0x0200) {
1372 switch (mov_field_order & 0xFF) {
1395 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1409 int64_t result = atom.
size;
1418 }
else if (err < atom.
size) {
1432 uint64_t original_size;
1507 if (cid == 0xd4d || cid == 0xd4e)
1517 if (num <= 0 || den <= 0)
1521 if (den >= INT_MAX / 2)
1540 uint64_t original_size;
1545 if (atom.
size == 16) {
1550 if (length == atom.
size) {
1552 switch (range_value) {
1593 if ((uint64_t)atom.
size > (1<<30))
1604 }
else if (atom.
size > 8) {
1612 if ( (buffer & 0xFFFFFFFF) ==
MKBETAG(
'f',
'r',
'm',
'a')
1613 && buffer >> 32 <= atom.
size
1614 && buffer >> 32 >= 8) {
1618 #define ALAC_EXTRADATA_SIZE 36
1651 if ((uint64_t)atom.
size > (1<<30))
1654 if (atom.
size >= 10) {
1660 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1685 if (atom.
size >= (1<<28) || atom.
size < 7)
1689 if ((profile_level & 0xf0) != 0xc0)
1713 if (atom.
size <= 40)
1717 if ((uint64_t)atom.
size > (1<<30))
1733 unsigned int i, entries;
1757 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1760 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1793 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1794 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1801 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1857 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1864 !memcmp(codec_name,
"Sorenson H263", 13))
1880 int bits_per_sample,
flags;
1899 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1906 }
else if (version == 2) {
1921 if (version == 0 || (version == 1 && sc->
audio_cid != -2)) {
1980 if (bits_per_sample) {
2005 y = (ycbcr >> 16) & 0xFF;
2006 cr = (ycbcr >> 8) & 0xFF;
2009 b = av_clip_uint8((1164 * (y - 16) + 2018 * (cb - 128)) / 1000);
2010 g = av_clip_uint8((1164 * (y - 16) - 813 * (cr - 128) - 391 * (cb - 128)) / 1000);
2011 r = av_clip_uint8((1164 * (y - 16) + 1596 * (cr - 128) ) / 1000);
2013 return (r << 16) | (g << 8) | b;
2018 char buf[256] = {0};
2026 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
2030 for (i = 0; i < 16; i++) {
2031 uint32_t yuv =
AV_RB32(src + i * 4);
2034 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
2037 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
2058 if ((
int)size != size)
2071 #if FF_API_LAVF_AVCTX
2082 #if FF_API_LAVF_AVCTX
2092 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
2094 if (str_size > 0 && size >= (
int)str_size + 26) {
2095 char *reel_name =
av_malloc(str_size + 1);
2099 reel_name[str_size] = 0;
2101 if (*reel_name == 0) {
2126 #if CONFIG_DV_DEMUXER
2196 int codec_tag,
int format,
2202 (codec_tag != format &&
2206 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2215 if ( codec_tag ==
AV_RL32(
"hvc1") ||
2227 int pseudo_stream_id;
2234 for (pseudo_stream_id = 0;
2236 pseudo_stream_id++) {
2239 int ret, dref_id = 1;
2249 }
else if (size <= 7) {
2251 "invalid size %"PRId64
" in stsd\n", size);
2266 "size=%"PRId64
" 4CC= %c%c%c%c/0x%08x codec_type=%d\n", size,
2267 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
2291 }
else if (a.
size > 0)
2374 unsigned int i, entries;
2398 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2417 if (index < sc->stsc_count - 1)
2429 unsigned i, entries;
2447 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2464 unsigned int i, entries;
2487 if (entries >= UINT_MAX /
sizeof(
int))
2495 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2512 unsigned int i, entries, sample_size, field_size, num_bytes;
2525 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2544 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2551 if (entries >= (UINT_MAX - 4) / field_size)
2561 num_bytes = (entries*field_size+4)>>3;
2578 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2597 unsigned int i, entries;
2599 int64_t total_sample_count=0;
2621 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2622 int sample_duration;
2628 if (sample_count < 0) {
2636 sample_count, sample_duration);
2640 && sample_count == 1
2641 && total_sample_count > 100
2642 && sample_duration/10 > duration / total_sample_count)
2643 sample_duration = duration / total_sample_count;
2644 duration+=(int64_t)sample_duration*sample_count;
2645 total_sample_count+=sample_count;
2666 if (duration == INT_MIN) {
2678 unsigned int i, entries, ctts_count = 0;
2693 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2700 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2706 "ignoring CTTS entry with count=%d duration=%d\n",
2718 if (
FFNABS(duration) < -(1<<28) && i+2<entries) {
2743 unsigned int i, entries;
2745 uint32_t grouping_type;
2755 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2771 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2786 unsigned int edit_list_index,
2787 int64_t *edit_list_media_time,
2788 int64_t *edit_list_duration,
2789 int64_t global_timescale)
2794 *edit_list_media_time = msc->
elst_data[edit_list_index].
time;
2798 if (global_timescale == 0) {
2853 const size_t requested_size =
2870 ie= &entries[
index];
2885 int64_t* frame_duration_buffer,
2886 int frame_duration_buffer_size) {
2888 av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
2889 for (i = 0; i < frame_duration_buffer_size; i++) {
2890 end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i];
2903 const size_t min_size_needed = (*ctts_count + 1) *
sizeof(
MOVStts);
2904 const size_t requested_size =
2905 min_size_needed > *allocated_size ?
2906 FFMAX(min_size_needed, 2 * (*allocated_size)) :
2909 if((
unsigned)(*ctts_count) + 1 >= UINT_MAX /
sizeof(
MOVStts))
2912 ctts_buf_new =
av_fast_realloc(*ctts_data, allocated_size, requested_size);
2917 *ctts_data = ctts_buf_new;
2922 *ctts_count = (*ctts_count) + 1;
2940 int64_t ctts_index_old = 0;
2941 int64_t ctts_sample_old = 0;
2943 int64_t edit_list_media_time = 0;
2944 int64_t edit_list_duration = 0;
2945 int64_t frame_duration = 0;
2946 int64_t edit_list_dts_counter = 0;
2947 int64_t edit_list_dts_entry_end = 0;
2948 int64_t edit_list_start_ctts_sample = 0;
2950 int64_t edit_list_index = 0;
2952 int64_t index_ctts_count;
2954 unsigned int ctts_allocated_size = 0;
2955 int64_t start_dts = 0;
2956 int64_t edit_list_media_time_dts = 0;
2957 int64_t edit_list_start_encountered = 0;
2958 int64_t search_timestamp = 0;
2959 int64_t* frame_duration_buffer =
NULL;
2960 int num_discarded_begin = 0;
2961 int first_non_zero_audio_edit = -1;
2962 int packet_skip_samples = 0;
2981 edit_list_dts_entry_end -= msc->
dts_shift;
2984 if (ctts_data_old && ctts_count_old > 0) {
2985 edit_list_dts_entry_end -= ctts_data_old[0].
duration;
2989 start_dts = edit_list_dts_entry_end;
2993 av_log(mov->
fc,
AV_LOG_DEBUG,
"Processing st: %d, edit list %"PRId64
" - media time: %"PRId64
", duration: %"PRId64
"\n",
2994 st->
index, edit_list_index, edit_list_media_time, edit_list_duration);
2996 edit_list_dts_counter = edit_list_dts_entry_end;
2997 edit_list_dts_entry_end += edit_list_duration;
2998 num_discarded_begin = 0;
2999 if (edit_list_media_time == -1) {
3006 if (first_non_zero_audio_edit < 0) {
3007 first_non_zero_audio_edit = 1;
3009 first_non_zero_audio_edit = 0;
3012 if (first_non_zero_audio_edit > 0)
3017 edit_list_media_time_dts = edit_list_media_time;
3019 edit_list_media_time_dts -= msc->
dts_shift;
3026 search_timestamp = edit_list_media_time_dts;
3036 av_log(mov->
fc,
AV_LOG_ERROR,
"Missing key frame while reordering index according to edit list\n");
3039 current = e_old +
index;
3042 ctts_sample_old = 0;
3045 for (index_ctts_count = 0; index_ctts_count <
index; index_ctts_count++) {
3046 if (ctts_data_old && ctts_index_old < ctts_count_old) {
3048 if (ctts_data_old[ctts_index_old].
count == ctts_sample_old) {
3050 ctts_sample_old = 0;
3055 edit_list_start_ctts_sample = ctts_sample_old;
3058 edit_list_start_encountered = 0;
3059 for (; current < e_old_end; current++, index++) {
3061 frame_duration = (current + 1 < e_old_end) ?
3062 ((current + 1)->timestamp - current->
timestamp) : edit_list_duration;
3064 flags = current->
flags;
3069 if (ctts_data_old && ctts_index_old < ctts_count_old) {
3070 av_log(mov->
fc,
AV_LOG_DEBUG,
"shifted frame pts, curr_cts: %"PRId64
" @ %"PRId64
", ctts: %d, ctts_count: %"PRId64
"\n",
3071 curr_cts, ctts_index_old, ctts_data_old[ctts_index_old].
duration, ctts_count_old);
3072 curr_cts += ctts_data_old[ctts_index_old].
duration;
3074 if (ctts_sample_old == ctts_data_old[ctts_index_old].
count) {
3076 &ctts_allocated_size,
3077 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3078 ctts_data_old[ctts_index_old].
duration) == -1) {
3081 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3082 ctts_data_old[ctts_index_old].
duration);
3086 ctts_sample_old = 0;
3087 edit_list_start_ctts_sample = 0;
3091 if (curr_cts < edit_list_media_time || curr_cts >= (edit_list_duration + edit_list_media_time)) {
3093 curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time &&
3094 first_non_zero_audio_edit > 0) {
3095 packet_skip_samples = edit_list_media_time - curr_cts;
3099 edit_list_dts_counter -= packet_skip_samples;
3100 if (edit_list_start_encountered == 0) {
3101 edit_list_start_encountered = 1;
3104 if (frame_duration_buffer) {
3106 frame_duration_buffer, num_discarded_begin);
3111 av_log(mov->
fc,
AV_LOG_DEBUG,
"skip %d audio samples from curr_cts: %"PRId64
"\n", packet_skip_samples, curr_cts);
3114 av_log(mov->
fc,
AV_LOG_DEBUG,
"drop a frame at curr_cts: %"PRId64
" @ %"PRId64
"\n", curr_cts, index);
3117 num_discarded_begin++;
3118 frame_duration_buffer =
av_realloc(frame_duration_buffer,
3119 num_discarded_begin *
sizeof(int64_t));
3120 if (!frame_duration_buffer) {
3124 frame_duration_buffer[num_discarded_begin - 1] = frame_duration;
3133 }
else if (edit_list_start_encountered == 0) {
3134 edit_list_start_encountered = 1;
3139 frame_duration_buffer, num_discarded_begin);
3151 if (edit_list_start_encountered > 0) {
3152 edit_list_dts_counter = edit_list_dts_counter + frame_duration;
3156 if (((curr_cts + frame_duration) >= (edit_list_duration + edit_list_media_time)) &&
3159 if (ctts_data_old && ctts_sample_old != 0) {
3161 &ctts_allocated_size,
3162 ctts_sample_old - edit_list_start_ctts_sample,
3163 ctts_data_old[ctts_index_old].
duration) == -1) {
3165 ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample,
3166 ctts_data_old[ctts_index_old].
duration);
3175 st->
duration = edit_list_dts_entry_end - start_dts;
3185 int64_t current_offset;
3186 int64_t current_dts = 0;
3187 unsigned int stts_index = 0;
3188 unsigned int stsc_index = 0;
3189 unsigned int stss_index = 0;
3190 unsigned int stps_index = 0;
3192 uint64_t stream_size = 0;
3195 int i, edit_start_index = 0;
3196 int64_t empty_duration = 0;
3201 if (i == 0 && e->
time == -1) {
3205 edit_start_index = 1;
3206 }
else if (i == edit_start_index && e->
time >= 0) {
3207 start_time = e->
time;
3212 if ((empty_duration || start_time) && mov->
time_scale > 0) {
3222 unsigned int current_sample = 0;
3223 unsigned int stts_sample = 0;
3224 unsigned int sample_size;
3226 unsigned int rap_group_index = 0;
3227 unsigned int rap_group_sample = 0;
3228 int64_t last_dts = 0;
3229 int64_t dts_correction = 0;
3234 last_dts = current_dts;
3281 if (rap_group_present && rap_group_index < sc->rap_group_count) {
3284 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
3285 rap_group_sample = 0;
3291 && !rap_group_present
3300 if (sample_size > 0x3FFFFFFF) {
3305 e->
pos = current_offset;
3307 e->
size = sample_size;
3310 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
3311 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
3312 current_offset, current_dts, sample_size, distance, keyframe);
3317 current_offset += sample_size;
3318 stream_size += sample_size;
3324 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
3331 if (!dts_correction || current_dts + dts_correction > last_dts) {
3332 current_dts += dts_correction;
3336 dts_correction += current_dts - last_dts - 1;
3337 current_dts = last_dts + 1;
3339 last_dts = current_dts;
3352 unsigned chunk_samples, total = 0;
3356 unsigned count, chunk_count;
3369 count = (chunk_samples+samples-1) / samples;
3371 count = (chunk_samples+1023) / 1024;
3374 if (i < sc->stsc_count - 1)
3378 total += chunk_count *
count;
3400 while (chunk_samples > 0) {
3402 unsigned size, samples;
3406 "Zero bytes per frame, but %d samples per frame",
3420 samples =
FFMIN(1024, chunk_samples);
3429 if (size > 0x3FFFFFFF) {
3434 e->
pos = current_offset;
3440 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
3443 current_offset +=
size;
3444 current_dts += samples;
3445 chunk_samples -= samples;
3464 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0, src);
3465 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0, ref);
3467 if (strlen(src) == 0) {
3469 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
3470 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
3471 strlen(src_host) + 1 >=
sizeof(src_host) ||
3472 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
3474 }
else if (strcmp(src_proto, ref_proto) ||
3475 strcmp(src_auth, ref_auth) ||
3476 strcmp(src_host, ref_host) ||
3477 src_port != ref_port) {
3488 char filename[1025];
3489 const char *src_path;
3493 src_path = strrchr(src,
'/');
3500 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
3501 if (ref->
path[l] ==
'/') {
3509 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
3510 memcpy(filename, src, src_path - src);
3511 filename[src_path -
src] = 0;
3514 av_strlcat(filename,
"../",
sizeof(filename));
3522 "Reference with mismatching origin, %s not tried for security reasons, "
3523 "set demuxer option use_absolute_path to allow it anyway\n",
3528 if(strstr(ref->
path + l + 1,
"..") ||
3529 strstr(ref->
path + l + 1,
":") ||
3530 (ref->
nlvl_from > 1 && same_origin < 0) ||
3531 (filename[0] ==
'/' && src_path == src))
3535 if (strlen(filename) + 1 ==
sizeof(filename))
3542 "this is a possible security issue\n");
3547 "Absolute path %s not tried for security reasons, "
3548 "set demuxer option use_absolute_path to allow absolute paths\n",
3572 if (!st)
return AVERROR(ENOMEM);
3575 if (!sc)
return AVERROR(ENOMEM);
3606 "stream %d, error opening alias: path='%s', dir='%s', "
3607 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
3612 "Skipped opening external track: "
3613 "stream %d, alias: path='%s', dir='%s', "
3614 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d."
3615 "Set enable_drefs to allow this.\n",
3632 #if FF_API_R_FRAME_RATE
3648 #if CONFIG_H261_DECODER
3651 #if CONFIG_H263_DECODER
3654 #if CONFIG_MPEG4_DECODER
3700 if (count > UINT_MAX /
sizeof(*c->
meta_keys) - 1) {
3702 "The 'keys' atom with the invalid key count: %d\n", count);
3711 for (i = 1; i <=
count; ++i) {
3716 "The key# %d in meta has invalid size: %d\n", i, key_size);
3720 if (type !=
MKTAG(
'm',
'd',
't',
'a')) {
3746 for (i = 0; i < 3; i++) {
3757 if (len < 12 || len - 12 > end -
avio_tell(pb))
3761 if (tag ==
MKTAG(
'm',
'e',
'a',
'n'))
3763 else if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
3765 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
3783 if (mean && key && val) {
3784 if (strcmp(key,
"iTunSMPB") == 0) {
3785 int priming, remainder, samples;
3786 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
3787 if(priming>0 && priming<16384)
3791 if (strcmp(key,
"cdec") != 0) {
3798 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
3810 while (atom.
size > 8) {
3813 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
3827 int display_matrix[3][3];
3866 for (i = 0; i < 3; i++) {
3874 sc->
width = width >> 16;
3875 sc->
height = height >> 16;
3879 if (display_matrix[0][0] != (1 << 16) ||
3880 display_matrix[1][1] != (1 << 16) ||
3881 display_matrix[2][2] != (1 << 30) ||
3882 display_matrix[0][1] || display_matrix[0][2] ||
3883 display_matrix[1][0] || display_matrix[1][2] ||
3884 display_matrix[2][0] || display_matrix[2][1]) {
3893 for (i = 0; i < 3; i++)
3894 for (j = 0; j < 3; j++)
3898 if (!
isnan(rotate)) {
3899 char rotate_buf[64];
3903 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
3911 double disp_transform[2];
3913 for (i = 0; i < 2; i++)
3914 disp_transform[i] =
hypot(display_matrix[i][0], display_matrix[i][1]);
3916 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
3917 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
3918 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
3920 disp_transform[0] / disp_transform[1],
3931 int flags, track_id, i, found = 0;
3967 "found fragment index for track %u\n", frag->
track_id);
3969 for (j = index->
current_item; j < index->item_count; j++) {
3972 "for track %u and moof_offset %"PRId64
"\n",
3984 if (index && !found) {
3986 "it doesn't have an (in-order) entry for moof_offset "
3998 num = atom.
size / 4;
4076 int data_offset = 0;
4077 unsigned entries, first_sample_flags = frag->
flags;
4127 for (i = 0; i < entries && !pb->
eof_reached; i++) {
4128 unsigned sample_size = frag->
size;
4129 int sample_flags = i ? frag->
flags : first_sample_flags;
4130 unsigned sample_duration = frag->
duration;
4144 " sc->dts_shift %d ctts.duration %d"
4145 " sc->time_offset %"PRId64
" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
4149 if (flags & MOV_TRUN_SAMPLE_CTS) {
4158 ", using it for dts\n", dts);
4178 offset, dts, sample_size, distance, keyframe);
4180 dts += sample_duration;
4181 offset += sample_size;
4203 unsigned i, track_id;
4253 if (!index->
items) {
4261 if (size & 0x80000000) {
4309 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
4323 long cmov_len, moov_len;
4337 cmov_len = atom.
size - 6 * 4;
4349 goto free_and_return;
4351 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
4352 goto free_and_return;
4354 goto free_and_return;
4357 atom.
size = moov_len;
4394 for (i = 0; i < edit_count && !pb->
eof_reached; i++) {
4428 static const uint8_t uuid_isml_manifest[] = {
4429 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
4430 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
4432 static const uint8_t uuid_xmp[] = {
4433 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
4434 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
4437 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
4440 ret =
avio_read(pb, uuid,
sizeof(uuid));
4443 }
else if (ret !=
sizeof(uuid)) {
4446 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
4449 size_t len = atom.
size -
sizeof(uuid);
4465 }
else if (ret != len) {
4471 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
4472 ptr +=
sizeof(
"systemBitrate=\"") - 1;
4481 ret = strtol(ptr, &endptr, 10);
4482 if (ret < 0 || errno || *endptr !=
'"') {
4490 }
else if (!memcmp(uuid, uuid_xmp,
sizeof(uuid))) {
4492 size_t len = atom.
size -
sizeof(uuid);
4502 }
else if (ret != len) {
4529 && !memcmp(content,
"Anevia\x1A\x1A", 8)
4551 case MKTAG(
'e',
'n',
'c',
'v'):
4552 case MKTAG(
'e',
'n',
'c',
'a'):
4557 "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
4567 if (format != sc->
format) {
4569 "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
4570 (
char*)&format, (
char*)&sc->
format);
4582 size_t auxiliary_info_size;
4600 if (atom.
size < 8) {
4606 auxiliary_info_size = atom.
size - 8;
4636 int atom_header_size;
4650 atom_header_size = 9;
4655 if ((flags & 0x01) != 0) {
4656 atom_header_size += 8;
4665 if (atom.
size <= atom_header_size) {
4670 data_size = atom.
size - atom_header_size;
4689 uint32_t encrypted_bytes;
4690 uint16_t subsample_count;
4691 uint16_t clear_bytes;
4719 for (; subsample_count > 0; subsample_count--)
4732 if ((uint64_t)clear_bytes + encrypted_bytes > input_end - input) {
4738 input += clear_bytes;
4742 input += encrypted_bytes;
4745 if (input < input_end) {
4755 size_t auxiliary_info_seek_offset = 0;
4866 int64_t total_size = 0;
4877 atom.
size = INT64_MAX;
4882 if (atom.
size >= 8) {
4889 uint32_t *
type = (uint32_t *)buf + 1;
4893 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
4894 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
4899 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
4911 if (a.
size == 1 && total_size + 8 <= atom.
size) {
4916 av_log(c->
fc,
AV_LOG_TRACE,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
4919 a.
size = atom.
size - total_size + 8;
4926 for (i = 0; mov_default_parse_table[i].
type; i++)
4927 if (mov_default_parse_table[i].
type == a.
type) {
4950 int err =
parse(c, pb, a);
4966 else if (left < 0) {
4968 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
4969 (
char*)&a.
type, -left);
4974 total_size += a.
size;
4977 if (total_size < atom.
size && atom.
size < 0x7ffff)
4989 int moov_offset = -1;
4995 if ((offset + 8) > (
unsigned int)p->
buf_size)
5000 case MKTAG(
'm',
'o',
'o',
'v'):
5001 moov_offset = offset + 4;
5002 case MKTAG(
'm',
'd',
'a',
't'):
5003 case MKTAG(
'p',
'n',
'o',
't'):
5004 case MKTAG(
'u',
'd',
't',
'a'):
5005 case MKTAG(
'f',
't',
'y',
'p'):
5008 offset + 12 > (
unsigned int)p->
buf_size ||
5011 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
5015 score =
FFMAX(score, 5);
5022 case MKTAG(
'e',
'd',
'i',
'w'):
5023 case MKTAG(
'w',
'i',
'd',
'e'):
5024 case MKTAG(
'f',
'r',
'e',
'e'):
5025 case MKTAG(
'j',
'u',
'n',
'k'):
5026 case MKTAG(
'p',
'i',
'c',
't'):
5030 case MKTAG(0x82,0x82,0x7f,0x7d):
5031 case MKTAG(
's',
'k',
'i',
'p'):
5032 case MKTAG(
'u',
'u',
'i',
'd'):
5033 case MKTAG(
'p',
'r',
'f',
'l'):
5045 offset = moov_offset;
5047 while(offset < (p->
buf_size - 16)){
5081 if (s->
streams[i]->
id == chapter_track) {
5122 if (end < sample->timestamp) {
5134 if (len > sample->
size-2)
5136 title_len = 2*len + 1;
5149 else if (ch == 0xfffe)
5153 if (len == 1 || len == 2)
5188 int hh, mm,
ss, ff, drop;
5201 hh, mm, ss, drop ?
';' :
':', ff);
5346 int version, fieldlength, i, j;
5377 if (!index->
items) {
5392 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
5394 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
5396 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
5411 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
5416 if (mfra_size < 0 || mfra_size > stream_size) {
5420 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
5440 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
5443 "failed to seek back after looking for mfra\n");
5469 atom.
size = INT64_MAX;
5505 int tmcd_st_id = -1;
5511 if (tmcd_st_id < 0 || tmcd_st_id == i)
5618 int64_t best_dts = INT64_MAX;
5629 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
5632 sample = current_sample;
5652 int already_read = 0;
5654 if (
avio_seek(s->
pb, target, SEEK_SET) != target) {
5705 if (extradata_size > 0 && extradata) {
5711 memcpy(side, extradata, extradata_size);
5745 if (ret64 != sample->
pos) {
5773 #if CONFIG_DV_DEMUXER
5857 for (j = index->
item_count - 1; j >= 0; j--) {
5858 if (index->
items[j].
time <= timestamp) {
5883 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
5933 st = s->
streams[stream_index];
5948 if (stream_index == i)
5975 #define OFFSET(x) offsetof(MOVContext, x)
5976 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
5978 {
"use_absolute_path",
5979 "allow using absolute path when opening alias, this is a possible security issue",
5982 {
"seek_streams_individually",
5983 "Seek each stream individually to the to the closest point",
5991 "use mfra for fragment timestamps",
5996 FLAGS,
"use_mfra_for" },
5998 FLAGS,
"use_mfra_for" },
6000 FLAGS,
"use_mfra_for" },
6001 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
6003 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
6005 {
"activation_bytes",
"Secret bytes for Audible AAX files",
OFFSET(activation_bytes),
6007 {
"audible_fixed_key",
6008 "Fixed key used for handling Audible AAX files",
OFFSET(audible_fixed_key),
6013 {.i64 = 0}, 0, 1,
FLAGS },
6026 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
6030 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2",
static int mov_read_targa_y216(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int itunes_metadata
metadata are itunes style
int * bitrates
bitrates read before streams creation
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
const char const char void * val
enum AVFieldOrder field_order
Video only.
discard all frames except keyframes
static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVColorTransferCharacteristic color_trc
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define av_realloc_f(p, o, n)
uint32_t tmcd_flags
tmcd track flags
uint8_t * auxiliary_info_end
void av_sha_update(AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
unsigned int rap_group_count
void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id)
static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
#define MOV_TFHD_DEFAULT_DURATION
static AVIndexEntry * mov_find_next_sample(AVFormatContext *s, AVStream **st)
static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int samples_per_frame
static void mov_build_index(MOVContext *mov, AVStream *st)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint64_t base_data_offset
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
static void skip_bits_long(GetBitContext *s, int n)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle...
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
#define MOV_TRUN_SAMPLE_CTS
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
int event_flags
Flags for the user to detect events happening on the file.
static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int16_t audio_cid
stsd audio compression id
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#define PUT_UTF8(val, tmp, PUT_BYTE)
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
unsigned int avio_rb16(AVIOContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static int mov_get_stsc_samples(MOVStreamContext *sc, int index)
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
#define FF_INPUT_BUFFER_PADDING_SIZE
enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
Compute codec id for 'lpcm' tag.
unsigned fragment_index_count
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
This struct describes the properties of an encoded stream.
int found_moov
'moov' atom has been found
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void export_orphan_timecode(AVFormatContext *s)
enum AVColorSpace color_space
static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_TFHD_DEFAULT_BASE_IS_MOOF
Macro definitions for various function/variable attributes.
int frame_size
Audio only.
static int should_retry(AVIOContext *pb, int error_code)
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
static int mov_realloc_extradata(AVCodecParameters *par, MOVAtom atom)
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define MOV_TKHD_FLAG_ENABLED
int isom
1 if file is ISO Media (mp4/3gp)
int found_mdat
'mdat' atom has been found
static int mov_probe(AVProbeData *p)
static int mov_read_header(AVFormatContext *s)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
Process a buffer using a previously initialized context.
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
static double cb(void *priv, double x, double y)
int fragment_index_complete
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const AVOption mov_options[]
static int64_t start_time
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
#define FF_MOV_FLAG_MFRA_DTS
static int64_t add_ctts_entry(MOVStts **ctts_data, unsigned int *ctts_count, unsigned int *allocated_size, int count, int duration)
Append a new ctts entry to ctts_data.
Opaque data information usually continuous.
unsigned int sample_count
const AVCodecTag ff_codec_movvideo_tags[]
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
int dts_shift
dts shift when ctts is negative
static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
uint8_t * auxiliary_info_pos
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
AVInputFormat ff_mov_demuxer
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
int nb_side_data
The number of elements in the AVStream.side_data array.
static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add index entry with the given values, to the end of st->index_entries.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AV_CH_LOW_FREQUENCY
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
AVStream ** streams
A list of all streams in the file.
static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb, int codec_tag, int format, int64_t size)
int activation_bytes_size
MOVFragmentIndex ** fragment_index_data
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define ALAC_EXTRADATA_SIZE
int flags
Flags modifying the (de)muxer behaviour.
#define MOV_TRUN_SAMPLE_SIZE
#define AVERROR_EOF
End of file.
bitstream reader API header.
static av_cold int read_close(AVFormatContext *ctx)
#define AV_LOG_VERBOSE
Detailed information.
struct AVAESCTR * aes_ctr
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
static int test_same_origin(const char *src, const char *ref)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
enum AVCodecID video_codec_id
Forced video codec_id.
uint64_t channel_layout
Audio only.
#define MOV_TFHD_DEFAULT_SIZE
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t time_offset
time offset of the edit list entries
static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int keyframe_count
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
const uint16_t avpriv_ac3_channel_layout_tab[8]
Map audio coding mode (acmod) to channel layout mask.
static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_rewrite_dvd_sub_extradata(AVStream *st)
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int avio_rl32(AVIOContext *s)
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVColorPrimaries color_primaries
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
enum AVMediaType codec_type
General type of the encoded data.
static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref)
simple assert() macros that are a bit more flexible than ISO C assert().
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVPacketSideDataType type
#define FFNABS(a)
Negative Absolute value.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet. ...
static const uint8_t offset[127][2]
static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVRational avg_frame_rate
Average framerate.
const AVCodecTag ff_codec_wav_tags[]
static void * av_mallocz_array(size_t nmemb, size_t size)
#define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time)
const AVCodecTag ff_codec_movsubtitle_tags[]
static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MIN_DATA_ENTRY_BOX_SIZE
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
int avio_r8(AVIOContext *s)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
static float distance(float x, float y, int band)
static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int buf_size
Size of buf except extra allocated bytes.
static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int aax_filter(uint8_t *input, int size, MOVContext *c)
static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
common internal API header
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
int block_align
Audio only.
static av_const double hypot(double x, double y)
struct AVAES * aes_decrypt
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const uint16_t fc[]
uint8_t auxiliary_info_default_size
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
audio channel layout utility functions
unsigned int avio_rb24(AVIOContext *s)
char filename[1024]
input or output filename
static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
const AVCodecTag ff_codec_bmp_tags[]
static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
GLsizei GLboolean const GLfloat * value
static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
int audible_fixed_key_size
static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_fix_index(MOVContext *mov, AVStream *st)
Fix st->index_entries, so that it contains only the entries (and the entries which are needed to deco...
static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
MOVFragmentIndexItem * items
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
#define MOV_TRUN_SAMPLE_DURATION
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
#define AV_CH_FRONT_CENTER
enum AVColorRange color_range
Video only.
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
static int mov_read_close(AVFormatContext *s)
static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
This function reads atom content and puts data in extradata without tag nor size unlike mov_read_extr...
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size)
Read 'chan' tag from the input stream.
offset must point to a pointer immediately followed by an int for the length
#define FF_MOV_FLAG_MFRA_PTS
the normal 2^n-1 "JPEG" YUV ranges
static int read_header(FFV1Context *f)
size_t auxiliary_info_sizes_count
int64_t duration
duration of the longest track
int ff_mov_lang_to_iso639(unsigned code, char to[4])
static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
static int mov_metadata_hmmt(MOVContext *c, AVIOContext *pb, unsigned len)
DVDemuxContext * dv_demux
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL AV_RB8
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static const uint32_t mac_to_unicode[128]
#define AV_LOG_INFO
Standard information.
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette)
Retrieve the palette (or "color table" in QuickTime terms), either from the video sample description...
#define MP4DecConfigDescrTag
const AVCodecTag ff_codec_movaudio_tags[]
static void mov_read_chapters(AVFormatContext *s)
AVIOContext * pb
I/O context.
static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
unsigned int stsz_sample_size
always contains sample size from stsz atom
static int read_tfra(MOVContext *mov, AVIOContext *f)
static AVRational av_make_q(int num, int den)
Create an AVRational.
Public header for SHA-1 & SHA-256 hash function implementations.
static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_TRUN_FIRST_SAMPLE_FLAGS
static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
timecode wraps after 24 hours
struct AVSHA * av_sha_alloc(void)
Allocate an AVSHA context.
static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static const char * format
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
Rational number (pair of numerator and denominator).
unsigned int aax_mode
'aax' file has been detected
static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
MOVFragment fragment
current fragment in moof atom
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
int64_t track_end
used for dts generation in fragmented movie files
static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, char *dst, int dstlen)
#define MOV_TFHD_DEFAULT_FLAGS
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
#define FF_MOV_FLAG_MFRA_AUTO
#define MOV_TRUN_SAMPLE_FLAGS
This structure contains the data a format has to probe a file.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVFormatContext * dv_fctx
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
static int64_t pts
Global timestamp for the audio frames.
static void mov_update_dts_shift(MOVStreamContext *sc, int duration)
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the iv.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
unsigned * stps_data
partial sync sample for mpeg-2 open gop
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
uint8_t * auxiliary_info_sizes
the normal 219*2^(n-8) "MPEG" YUV ranges
int(* parse)(MOVContext *ctx, AVIOContext *pb, MOVAtom atom)
static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int64_t duration
Decoding: duration of the stream, in stream time base.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int sample_rate
Audio only.
static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int start_pad
amount of samples to skip due to enc-dec delay
int trak_index
Index of the current 'trak'.
negative time values are allowed
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
static void fix_index_entry_timestamps(AVStream *st, int end_index, int64_t end_ts, int64_t *frame_duration_buffer, int frame_duration_buffer_size)
Rewrite timestamps of index entries in the range [end_index - frame_duration_buffer_size, end_index) by subtracting end_ts successively by the amounts given in frame_duration_buffer.
static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
An strf atom is a BITMAPINFOHEADER struct.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
unsigned int bytes_per_frame
#define FF_DISABLE_DEPRECATION_WARNINGS
static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)
#define MOV_TFHD_BASE_DATA_OFFSET
static int ref[MAX_W *MAX_W]
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
static const MOVParseTableEntry mov_default_parse_table[]
static int get_edit_list_entry(MOVContext *mov, const MOVStreamContext *msc, unsigned int edit_list_index, int64_t *edit_list_media_time, int64_t *edit_list_duration, int64_t global_timescale)
Get ith edit list entry (media time, duration).
static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st, uint32_t value, int flags)
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int disposition
AV_DISPOSITION_* bit field.
static int mov_codec_id(AVStream *st, uint32_t format)
int64_t nb_frames
number of frames in this stream if known or 0
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
double av_display_rotation_get(const int32_t matrix[9])
The display transformation matrix specifies an affine transformation that should be applied to video ...
static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
#define MKBETAG(a, b, c, d)
static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp)
unsigned int index_entries_allocated_size
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
int eof_reached
true if eof reached
static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FF_ENABLE_DEPRECATION_WARNINGS
as in Berlin toast format
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, enum AVCodecID codec_id)
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
unsigned int sample_size
may contain value calculated from stsd or value from stsz atom
void * priv_data
Format private data.
static int mov_read_mfra(MOVContext *c, AVIOContext *f)
static const AVClass mov_class
static int64_t find_prev_closest_keyframe_index(AVStream *st, AVIndexEntry *e_old, int nb_old, int64_t timestamp, int flag)
Find the closest previous keyframe to the timestamp, in e_old index entries.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
#define MOV_TRUN_DATA_OFFSET
int64_t next_root_atom
offset of the next root atom
unsigned int nb_chapter_tracks
static int cenc_filter(MOVContext *c, MOVStreamContext *sc, uint8_t *input, int size)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int pseudo_stream_id
-1 means demux all ids
#define AV_CH_FRONT_RIGHT
static int64_t mov_read_atom_into_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, AVCodecParameters *par, uint8_t *buf)
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int ffindex
AVStream index.
uint8_t ** extradata
extradata array (and size) for multiple stsd
static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
AVCodecParameters * codecpar
#define av_malloc_array(a, b)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static int mov_read_alac(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_seek_auxiliary_info(AVFormatContext *s, MOVStreamContext *sc)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static double cr(void *priv, double x, double y)
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static void fix_timescale(MOVContext *c, MOVStreamContext *sc)
AVRational r_frame_rate
Real base framerate of the stream.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
static int mov_switch_root(AVFormatContext *s, int64_t target)
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
struct MOVStreamContext::@206 cenc
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int found_hdlr_mdta
'hdlr' atom with type 'mdta' has been found
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static uint32_t yuv_to_rgba(uint32_t ycbcr)
#define AV_TIMECODE_STR_SIZE
#define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.