77 static int64_t
add_ctts_entry(
MOVStts** ctts_data,
unsigned int* ctts_count,
unsigned int* allocated_size,
81 unsigned len,
const char *
key)
85 short current, total = 0;
91 snprintf(buf,
sizeof(buf),
"%d", current);
93 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
101 unsigned len,
const char *
key)
115 unsigned len,
const char *
key)
124 unsigned len,
const char *
key)
140 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
141 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
142 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
143 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
144 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
145 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
146 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
147 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
148 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
149 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
150 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
151 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
152 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
153 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
154 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
155 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
159 char *dst,
int dstlen)
162 char *
end = dst+dstlen-1;
165 for (i = 0; i <
len; i++) {
233 char language[4] = { 0 };
234 char buf[200], place[100];
235 uint16_t langcode = 0;
236 double longitude, latitude, altitude;
237 const char *
key =
"location";
239 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
259 "loci too short (%u bytes left, need at least %d)\n", len, 12);
267 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f", latitude, longitude);
272 if (*language && strcmp(language,
"und")) {
274 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
291 if (n_hmmt > len / 4)
305 char key2[32], language[4] = {0};
308 uint16_t langcode = 0;
309 uint32_t data_type = 0, str_size, str_size_alloc;
315 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
316 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
317 case MKTAG(
'X',
'M',
'P',
'_'):
318 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
319 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
320 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
322 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
323 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
324 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
326 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
327 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
328 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
330 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
332 case MKTAG(
'F',
'I',
'R',
'M'): key =
"firmware"; raw = 1;
break;
333 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
335 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
337 case MKTAG(
'H',
'M',
'M',
'T'):
339 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
340 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
341 case MKTAG(
'l',
'o',
'c',
'i'):
343 case MKTAG(
'm',
'a',
'n',
'u'): key =
"make";
break;
344 case MKTAG(
'm',
'o',
'd',
'l'): key =
"model";
break;
345 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
347 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
349 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
350 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
352 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
353 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
354 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
355 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
356 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
357 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
358 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
360 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
362 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
363 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
365 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
366 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
367 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
369 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
370 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
371 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
372 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
373 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
374 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
375 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
376 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
377 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
378 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
379 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
380 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
381 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
382 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
383 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
384 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
385 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
386 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
387 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
388 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
389 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
390 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
391 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
392 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
393 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
394 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
395 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
396 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
397 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
398 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
399 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
400 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
401 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
402 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
403 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
409 if (tag ==
MKTAG(
'd',
'a',
't',
'a') && data_size <= atom.size && data_size >= 16) {
412 str_size = data_size - 16;
415 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
421 atom.
size -= str_size;
427 if (index < c->meta_keys_count && index > 0) {
431 "The index of 'data' is out of range: %"PRId32
" < 1 or >= %d.\n",
438 if (str_size > atom.
size) {
448 str_size = atom.
size;
457 if (atom.
size < 0 || str_size >= INT_MAX/2)
462 num = (data_type >= 21 && data_type <= 23);
463 str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1;
469 parse(c, pb, str_size, key);
471 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
473 }
else if (data_type == 21) {
477 else if (str_size == 2)
479 else if (str_size == 3)
481 else if (str_size == 4)
483 if (
snprintf(str, str_size_alloc,
"%d", val) >= str_size_alloc) {
485 "Failed to store the number (%d) in string.\n", val);
489 }
else if (data_type == 22) {
490 unsigned int val = 0;
493 else if (str_size == 2)
495 else if (str_size == 3)
497 else if (str_size == 4)
499 if (
snprintf(str, str_size_alloc,
"%u", val) >= str_size_alloc) {
501 "Failed to store the number (%u) in string.\n", val);
505 }
else if (data_type == 23 && str_size >= 4) {
507 if (
snprintf(str, str_size_alloc,
"%f", val) >= str_size_alloc) {
509 "Failed to store the float32 number (%f) in string.\n", val);
523 if (*language && strcmp(language,
"und")) {
524 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
527 if (!strcmp(key,
"encoder")) {
528 int major, minor, micro;
529 if (sscanf(str,
"HandBrake %d.%d.%d", &major, &minor, µ) == 3) {
542 int i, nb_chapters, str_len,
version;
549 if ((atom.
size -= 5) < 0)
558 for (i = 0; i < nb_chapters; i++) {
565 if ((atom.
size -= 9+str_len) < 0)
577 #define MIN_DATA_ENTRY_BOX_SIZE 12 593 entries >= UINT_MAX /
sizeof(*sc->
drefs))
603 for (i = 0; i < entries; i++) {
608 if (size < 12 || next < 0 || next > INT64_MAX - size)
616 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
618 uint16_t volume_len,
len;
625 volume_len =
FFMIN(volume_len, 27);
629 dref->
volume[volume_len] = 0;
635 len =
FFMIN(len, 63);
652 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
671 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
673 memmove(dref->
path, dref->
path+volume_len, len);
677 for (j = len - 1; j >= 0; j--) {
678 if (dref->
path[j] == 0)
683 for (j = 0; j <
len; j++)
684 if (dref->
path[j] ==
':' || dref->
path[j] == 0)
687 }
else if (type == 0) {
699 for (j = 0; j <
len; j++)
700 if (dref->
dir[j] ==
':')
737 if (type ==
MKTAG(
'm',
'd',
't',
'a')) {
745 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
747 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
749 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
751 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
758 title_size = atom.
size - 24;
759 if (title_size > 0) {
760 if (title_size >
FFMIN(INT_MAX, SIZE_MAX-1))
771 title_str[title_size] = 0;
773 int off = (!c->
isom && title_str[0] == title_size - 1);
792 int ac3info, acmod, lfeon, bsmod;
804 bsmod = (ac3info >> 14) & 0x7;
805 acmod = (ac3info >> 11) & 0x7;
806 lfeon = (ac3info >> 10) & 0x1;
815 #if FF_API_LAVF_AVCTX 817 st->codec->audio_service_type = *ast;
828 int eac3info, acmod, lfeon, bsmod;
844 bsmod = (eac3info >> 12) & 0x1f;
845 acmod = (eac3info >> 9) & 0x7;
846 lfeon = (eac3info >> 8) & 0x1;
855 #if FF_API_LAVF_AVCTX 857 st->codec->audio_service_type = *ast;
866 const uint32_t ddts_size = 20;
869 uint32_t frame_duration_code = 0;
870 uint32_t channel_layout_code = 0;
877 if (
avio_read(pb, buf, ddts_size) < ddts_size) {
899 frame_duration_code =
get_bits(&gb, 2);
901 channel_layout_code =
get_bits(&gb, 16);
904 (frame_duration_code == 0) ? 512 :
905 (frame_duration_code == 1) ? 1024 :
906 (frame_duration_code == 2) ? 2048 :
907 (frame_duration_code == 3) ? 4096 : 0;
909 if (channel_layout_code > 0xff) {
973 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
976 }
else if (den != 0) {
992 #define DRM_BLOB_SIZE 56 1001 uint8_t calculated_checksum[20];
1027 for (i = 0; i < 20; i++)
1032 if (!activation_bytes) {
1064 if (memcmp(calculated_checksum, file_checksum, 20)) {
1071 for (i = 0; i < 4; i++) {
1073 if (activation_bytes[i] != output[3 - i]) {
1079 memcpy(c->
file_key, output + 8, 16);
1080 memcpy(input, output + 26, 16);
1097 unsigned char iv[16];
1111 int comp_brand_size;
1112 char* comp_brands_str;
1118 if (strcmp(type,
"qt "))
1125 comp_brand_size = atom.
size - 8;
1126 if (comp_brand_size < 0 || comp_brand_size == INT_MAX)
1128 comp_brands_str =
av_malloc(comp_brand_size + 1);
1129 if (!comp_brands_str)
1137 comp_brands_str[comp_brand_size] = 0;
1171 if (index < 0 || index >= frag_index->
nb_items)
1187 if (frag_index->
current < 0 ||
1206 if (frag_index->
current < 0 ||
1221 int64_t moof_offset;
1234 if (moof_offset >= offset)
1236 if (moof_offset <= offset)
1245 if (frag_stream_info) {
1257 int index,
int track_id)
1263 if (track_id >= 0) {
1296 m0 = m = (a +
b) >> 1;
1302 if (m < b && frag_time <= timestamp)
1319 if (index < c->frag_index.nb_items &&
1335 if (!frag_stream_info)
1353 if (index < c->frag_index.nb_items)
1369 int id,
int entries)
1376 for (i = index; i < frag_index->
nb_items; i++) {
1378 if (frag_stream_info && frag_stream_info->
index_entry >= 0)
1396 "read the mfra (may be a live ismv)\n");
1400 "seekable, can not look for mfra\n");
1412 if(time >= 2082844800)
1415 if ((int64_t)(time * 1000000ULL) / 1000000 != time) {
1429 char language[4] = {0};
1431 int64_t creation_time;
1476 int64_t creation_time;
1507 for (i = 0; i < 3; i++) {
1535 if (little_endian == 1) {
1559 char color_parameter_type[5] = { 0 };
1570 if (strncmp(color_parameter_type,
"nclx", 4) &&
1571 strncmp(color_parameter_type,
"nclc", 4)) {
1573 color_parameter_type);
1582 "%s: pri %d trc %d matrix %d",
1583 color_parameter_type, color_primaries, color_trc, color_matrix);
1585 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1612 unsigned mov_field_order;
1621 if ((mov_field_order & 0xFF00) == 0x0100)
1623 else if ((mov_field_order & 0xFF00) == 0x0200) {
1624 switch (mov_field_order & 0xFF) {
1647 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1661 int64_t result = atom.
size;
1670 }
else if (err < atom.
size) {
1684 uint64_t original_size;
1759 if (cid == 0xd4d || cid == 0xd4e)
1770 if (num <= 0 || den <= 0)
1774 if (den >= INT_MAX / 2)
1793 uint64_t original_size;
1798 if (atom.
size == 16) {
1803 if (length == atom.
size) {
1805 switch (range_value) {
1846 if ((uint64_t)atom.
size > (1<<30))
1857 }
else if (atom.
size > 8) {
1865 if ( (buffer & 0xFFFFFFFF) ==
MKBETAG(
'f',
'r',
'm',
'a')
1866 && buffer >> 32 <= atom.
size 1867 && buffer >> 32 >= 8) {
1871 #define ALAC_EXTRADATA_SIZE 36 1904 if ((uint64_t)atom.
size > (1<<30))
1907 if (atom.
size >= 10) {
1915 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1942 if (atom.
size >= (1<<28) || atom.
size < 7)
1946 if ((profile_level & 0xf0) != 0xc0)
1970 if (atom.
size <= 40)
1974 if ((uint64_t)atom.
size > (1<<30))
1990 unsigned int i, entries;
2020 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
2023 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
2044 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
2045 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
2052 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
2077 uint8_t codec_name[32] = { 0 };
2110 if (!strncmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
2117 !strncmp(codec_name,
"Sorenson H263", 13))
2133 int bits_per_sample,
flags;
2152 (compatible_brands && strstr(compatible_brands->
value,
"qt ")) ||
2159 }
else if (version == 2) {
2174 if (version == 0 || (version == 1 && sc->
audio_cid != -2)) {
2233 if (bits_per_sample && (bits_per_sample >> 3) * (uint64_t)st->
codecpar->
channels <= INT_MAX) {
2258 y = (ycbcr >> 16) & 0xFF;
2259 cr = (ycbcr >> 8) & 0xFF;
2262 b = av_clip_uint8((1164 * (y - 16) + 2018 * (cb - 128)) / 1000);
2263 g = av_clip_uint8((1164 * (y - 16) - 813 * (cr - 128) - 391 * (cb - 128)) / 1000);
2264 r = av_clip_uint8((1164 * (y - 16) + 1596 * (cr - 128) ) / 1000);
2266 return (r << 16) | (g << 8) | b;
2271 char buf[256] = {0};
2279 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
2283 for (i = 0; i < 16; i++) {
2284 uint32_t yuv =
AV_RB32(src + i * 4);
2287 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
2290 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
2311 if ((
int)size != size)
2324 #if FF_API_LAVF_AVCTX 2334 #if FF_API_LAVF_AVCTX 2343 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
2345 if (str_size > 0 && size >= (
int)str_size + 30) {
2346 char *reel_name =
av_malloc(str_size + 1);
2350 reel_name[str_size] = 0;
2352 if (*reel_name == 0) {
2377 #if CONFIG_DV_DEMUXER 2448 int codec_tag,
int format,
2454 (codec_tag != format &&
2462 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2479 int pseudo_stream_id;
2485 for (pseudo_stream_id = 0;
2487 pseudo_stream_id++) {
2490 int ret, dref_id = 1;
2500 }
else if (size <= 7) {
2502 "invalid size %"PRId64
" in stsd\n", size);
2519 "size=%"PRId64
" 4CC=%s codec_type=%d\n", size,
2549 }
else if (a.
size > 0)
2591 if (entries <= 0 || entries > atom.
size / 8) {
2598 "Duplicate stsd found in this track.\n");
2644 unsigned int i, entries;
2655 if ((uint64_t)entries * 12 + 4 > atom.
size)
2672 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2679 for (i = sc->
stsc_count - 1; i < UINT_MAX; i--) {
2680 int64_t first_min = i + 1;
2713 return index < count - 1;
2736 unsigned i, entries;
2754 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2772 unsigned int i, entries;
2795 if (entries >= UINT_MAX /
sizeof(
int))
2803 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2821 unsigned int i, entries, sample_size, field_size, num_bytes;
2834 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2853 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2860 if (entries >= (UINT_MAX - 4) / field_size)
2870 num_bytes = (entries*field_size+4)>>3;
2888 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2913 unsigned int i, entries, alloc_size = 0;
2915 int64_t total_sample_count=0;
2933 if (entries >= INT_MAX /
sizeof(*sc->
stts_data))
2936 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2937 int sample_duration;
2938 unsigned int sample_count;
2939 unsigned int min_entries =
FFMIN(
FFMAX(i + 1, 1024 * 1024), entries);
2957 sample_count, sample_duration);
2961 && sample_count == 1
2962 && total_sample_count > 100
2963 && sample_duration/10 > duration / total_sample_count)
2964 sample_duration = duration / total_sample_count;
2965 duration+=(int64_t)sample_duration*(uint64_t)sample_count;
2966 total_sample_count+=sample_count;
2972 duration <= INT64_MAX - sc->duration_for_fps &&
2973 total_sample_count <= INT64_MAX - sc->nb_frames_for_fps
2994 if (duration == INT_MIN) {
3006 unsigned int i, entries, ctts_count = 0;
3021 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
3028 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3034 "ignoring CTTS entry with count=%d duration=%d\n",
3045 if (
FFNABS(duration) < -(1<<28) && i+2<entries) {
3072 unsigned int i, entries;
3074 uint32_t grouping_type;
3084 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
3100 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3120 unsigned int edit_list_index,
3121 int64_t *edit_list_media_time,
3122 int64_t *edit_list_duration,
3123 int64_t global_timescale)
3128 *edit_list_media_time = msc->
elst_data[edit_list_index].
time;
3132 if (global_timescale == 0) {
3165 int64_t timestamp_pts,
3168 int64_t* ctts_index,
3169 int64_t* ctts_sample)
3175 int64_t index_ctts_count;
3203 if (ctts_data && *index >= 0) {
3209 for (index_ctts_count = 0; index_ctts_count < *
index; index_ctts_count++) {
3210 if (*ctts_index < ctts_count) {
3212 if (ctts_data[*ctts_index].
count == *ctts_sample) {
3219 while (*index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < ctts_count) {
3223 if ((e_old[*index].timestamp + ctts_data[*ctts_index].
duration) <= timestamp_pts &&
3229 if (*ctts_sample == 0) {
3231 if (*ctts_index >= 0)
3232 *ctts_sample = ctts_data[*ctts_index].
count - 1;
3242 return *index >= 0 ? 0 : -1;
3265 const size_t requested_size =
3282 ie= &entries[
index];
3297 int64_t* frame_duration_buffer,
3298 int frame_duration_buffer_size) {
3300 av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
3301 for (i = 0; i < frame_duration_buffer_size; i++) {
3302 end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 -
i];
3315 const size_t min_size_needed = (*ctts_count + 1) *
sizeof(
MOVStts);
3316 const size_t requested_size =
3317 min_size_needed > *allocated_size ?
3318 FFMAX(min_size_needed, 2 * (*allocated_size)) :
3321 if((
unsigned)(*ctts_count) >= UINT_MAX /
sizeof(
MOVStts) - 1)
3324 ctts_buf_new =
av_fast_realloc(*ctts_data, allocated_size, requested_size);
3329 *ctts_data = ctts_buf_new;
3334 *ctts_count = (*ctts_count) + 1;
3338 #define MAX_REORDER_DELAY 16 3343 int ctts_sample = 0;
3346 int j,
r, num_swaps;
3349 pts_buf[j] = INT64_MIN;
3357 buf_start = (buf_start + 1);
3358 if (buf_start == MAX_REORDER_DELAY + 1)
3370 while (j != buf_start) {
3373 if (pts_buf[j] < pts_buf[r]) {
3374 FFSWAP(int64_t, pts_buf[j], pts_buf[r]);
3432 if (range_size > current_sample) {
3436 current_sample -= range_size;
3454 int64_t ctts_index_old = 0;
3455 int64_t ctts_sample_old = 0;
3457 int64_t edit_list_media_time = 0;
3458 int64_t edit_list_duration = 0;
3459 int64_t frame_duration = 0;
3460 int64_t edit_list_dts_counter = 0;
3461 int64_t edit_list_dts_entry_end = 0;
3462 int64_t edit_list_start_ctts_sample = 0;
3464 int64_t curr_ctts = 0;
3465 int64_t empty_edits_sum_duration = 0;
3466 int64_t edit_list_index = 0;
3469 int64_t start_dts = 0;
3470 int64_t edit_list_start_encountered = 0;
3471 int64_t search_timestamp = 0;
3472 int64_t* frame_duration_buffer =
NULL;
3473 int num_discarded_begin = 0;
3474 int first_non_zero_audio_edit = -1;
3475 int packet_skip_samples = 0;
3478 int found_keyframe_after_edit = 0;
3511 edit_list_dts_entry_end -= msc->
dts_shift;
3515 start_dts = edit_list_dts_entry_end;
3519 av_log(mov->
fc,
AV_LOG_DEBUG,
"Processing st: %d, edit list %"PRId64
" - media time: %"PRId64
", duration: %"PRId64
"\n",
3520 st->
index, edit_list_index, edit_list_media_time, edit_list_duration);
3522 edit_list_dts_counter = edit_list_dts_entry_end;
3523 edit_list_dts_entry_end += edit_list_duration;
3524 num_discarded_begin = 0;
3525 if (edit_list_media_time == -1) {
3526 empty_edits_sum_duration += edit_list_duration;
3533 if (first_non_zero_audio_edit < 0) {
3534 first_non_zero_audio_edit = 1;
3536 first_non_zero_audio_edit = 0;
3539 if (first_non_zero_audio_edit > 0)
3547 search_timestamp = edit_list_media_time;
3556 &index, &ctts_index_old, &ctts_sample_old) < 0) {
3558 "st: %d edit list: %"PRId64
" Missing key frame while searching for timestamp: %"PRId64
"\n",
3559 st->
index, edit_list_index, search_timestamp);
3561 &index, &ctts_index_old, &ctts_sample_old) < 0) {
3563 "st: %d edit list %"PRId64
" Cannot find an index entry before timestamp: %"PRId64
".\n",
3564 st->
index, edit_list_index, search_timestamp);
3567 ctts_sample_old = 0;
3570 current = e_old +
index;
3571 edit_list_start_ctts_sample = ctts_sample_old;
3574 edit_list_start_encountered = 0;
3575 found_keyframe_after_edit = 0;
3576 for (; current < e_old_end; current++, index++) {
3578 frame_duration = (current + 1 < e_old_end) ?
3579 ((current + 1)->timestamp - current->
timestamp) : edit_list_duration;
3581 flags = current->
flags;
3587 if (ctts_data_old && ctts_index_old < ctts_count_old) {
3588 curr_ctts = ctts_data_old[ctts_index_old].
duration;
3589 av_log(mov->
fc,
AV_LOG_DEBUG,
"stts: %"PRId64
" ctts: %"PRId64
", ctts_index: %"PRId64
", ctts_count: %"PRId64
"\n",
3590 curr_cts, curr_ctts, ctts_index_old, ctts_count_old);
3591 curr_cts += curr_ctts;
3593 if (ctts_sample_old == ctts_data_old[ctts_index_old].
count) {
3596 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3597 ctts_data_old[ctts_index_old].
duration) == -1) {
3600 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3601 ctts_data_old[ctts_index_old].
duration);
3605 ctts_sample_old = 0;
3606 edit_list_start_ctts_sample = 0;
3610 if (curr_cts < edit_list_media_time || curr_cts >= (edit_list_duration + edit_list_media_time)) {
3612 curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time &&
3613 first_non_zero_audio_edit > 0) {
3614 packet_skip_samples = edit_list_media_time - curr_cts;
3618 edit_list_dts_counter -= packet_skip_samples;
3619 if (edit_list_start_encountered == 0) {
3620 edit_list_start_encountered = 1;
3623 if (frame_duration_buffer) {
3625 frame_duration_buffer, num_discarded_begin);
3630 av_log(mov->
fc,
AV_LOG_DEBUG,
"skip %d audio samples from curr_cts: %"PRId64
"\n", packet_skip_samples, curr_cts);
3633 av_log(mov->
fc,
AV_LOG_DEBUG,
"drop a frame at curr_cts: %"PRId64
" @ %"PRId64
"\n", curr_cts, index);
3635 if (edit_list_start_encountered == 0) {
3636 num_discarded_begin++;
3637 frame_duration_buffer =
av_realloc(frame_duration_buffer,
3638 num_discarded_begin *
sizeof(int64_t));
3639 if (!frame_duration_buffer) {
3643 frame_duration_buffer[num_discarded_begin - 1] = frame_duration;
3658 if (edit_list_start_encountered == 0) {
3659 edit_list_start_encountered = 1;
3662 if (frame_duration_buffer) {
3664 frame_duration_buffer, num_discarded_begin);
3677 if (current_index_range < msc->index_ranges || index != current_index_range->
end) {
3678 current_index_range++;
3681 current_index_range->
end = index + 1;
3684 if (edit_list_start_encountered > 0) {
3685 edit_list_dts_counter = edit_list_dts_counter + frame_duration;
3689 if ((curr_cts + frame_duration >= (edit_list_duration + edit_list_media_time)) &&
3691 if (ctts_data_old) {
3696 found_keyframe_after_edit = 1;
3699 if (ctts_sample_old != 0) {
3702 ctts_sample_old - edit_list_start_ctts_sample,
3703 ctts_data_old[ctts_index_old].
duration) == -1) {
3705 ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample,
3706 ctts_data_old[ctts_index_old].
duration);
3742 current_index_range++;
3743 current_index_range->
start = 0;
3744 current_index_range->
end = 0;
3751 int64_t current_offset;
3752 int64_t current_dts = 0;
3753 unsigned int stts_index = 0;
3754 unsigned int stsc_index = 0;
3755 unsigned int stss_index = 0;
3756 unsigned int stps_index = 0;
3758 uint64_t stream_size = 0;
3760 unsigned int ctts_count_old = sc->
ctts_count;
3763 int i, edit_start_index = 0, multiple_edits = 0;
3764 int64_t empty_duration = 0;
3769 if (i == 0 && e->
time == -1) {
3773 edit_start_index = 1;
3774 }
else if (i == edit_start_index && e->
time >= 0) {
3775 start_time = e->
time;
3783 "Use -advanced_editlist to correctly decode otherwise " 3784 "a/v desync might occur\n");
3787 if ((empty_duration || start_time) && mov->
time_scale > 0) {
3804 unsigned int current_sample = 0;
3805 unsigned int stts_sample = 0;
3806 unsigned int sample_size;
3808 unsigned int rap_group_index = 0;
3809 unsigned int rap_group_sample = 0;
3810 int64_t last_dts = 0;
3811 int64_t dts_correction = 0;
3816 last_dts = current_dts;
3830 if (ctts_data_old) {
3845 for (i = 0; i < ctts_count_old &&
3847 for (j = 0; j < ctts_data_old[
i].
count &&
3888 if (rap_group_present && rap_group_index < sc->rap_group_count) {
3891 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
3892 rap_group_sample = 0;
3898 && !rap_group_present
3904 if (current_offset > INT64_MAX - sample_size) {
3914 if (sample_size > 0x3FFFFFFF) {
3919 e->
pos = current_offset;
3921 e->
size = sample_size;
3924 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %u, offset %"PRIx64
", dts %"PRId64
", " 3925 "size %u, distance %u, keyframe %d\n", st->
index, current_sample,
3926 current_offset, current_dts, sample_size, distance, keyframe);
3931 current_offset += sample_size;
3932 stream_size += sample_size;
3938 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
3945 if (!dts_correction || current_dts + dts_correction > last_dts) {
3946 current_dts += dts_correction;
3950 dts_correction += current_dts - last_dts - 1;
3951 current_dts = last_dts + 1;
3953 last_dts = current_dts;
3966 unsigned chunk_samples, total = 0;
3973 unsigned count, chunk_count;
3986 count = (chunk_samples+samples-1) / samples;
3988 count = (chunk_samples+1023) / 1024;
3995 total += chunk_count *
count;
4017 while (chunk_samples > 0) {
4019 unsigned size, samples;
4023 "Zero bytes per frame, but %d samples per frame",
4037 samples =
FFMIN(1024, chunk_samples);
4046 if (size > 0x3FFFFFFF) {
4051 e->
pos = current_offset;
4057 "size %u, duration %u\n", st->
index, i, current_offset, current_dts,
4060 current_offset +=
size;
4061 current_dts += samples;
4062 chunk_samples -= samples;
4093 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0, src);
4094 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0, ref);
4096 if (strlen(src) == 0) {
4098 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
4099 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
4100 strlen(src_host) + 1 >=
sizeof(src_host) ||
4101 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
4103 }
else if (strcmp(src_proto, ref_proto) ||
4104 strcmp(src_auth, ref_auth) ||
4105 strcmp(src_host, ref_host) ||
4106 src_port != ref_port) {
4117 char filename[1025];
4118 const char *src_path;
4122 src_path = strrchr(src,
'/');
4129 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
4130 if (ref->
path[l] ==
'/') {
4138 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
4139 memcpy(filename, src, src_path - src);
4140 filename[src_path -
src] = 0;
4143 av_strlcat(filename,
"../",
sizeof(filename));
4151 "Reference with mismatching origin, %s not tried for security reasons, " 4152 "set demuxer option use_absolute_path to allow it anyway\n",
4157 if(strstr(ref->
path + l + 1,
"..") ||
4158 strstr(ref->
path + l + 1,
":") ||
4159 (ref->
nlvl_from > 1 && same_origin < 0) ||
4160 (filename[0] ==
'/' && src_path == src))
4164 if (strlen(filename) + 1 ==
sizeof(filename))
4171 "this is a possible security issue\n");
4176 "Absolute path %s not tried for security reasons, " 4177 "set demuxer option use_absolute_path to allow absolute paths\n",
4201 if (!st)
return AVERROR(ENOMEM);
4204 if (!sc)
return AVERROR(ENOMEM);
4248 "stream %d, error opening alias: path='%s', dir='%s', " 4249 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
4254 "Skipped opening external track: " 4255 "stream %d, alias: path='%s', dir='%s', " 4256 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d." 4257 "Set enable_drefs to allow this.\n",
4274 #if FF_API_R_FRAME_RATE 4290 #if CONFIG_H261_DECODER 4293 #if CONFIG_H263_DECODER 4296 #if CONFIG_MPEG4_DECODER 4342 if (count > UINT_MAX /
sizeof(*c->
meta_keys) - 1) {
4344 "The 'keys' atom with the invalid key count: %"PRIu32
"\n", count);
4353 for (i = 1; i <=
count; ++
i) {
4358 "The key# %"PRIu32
" in meta has invalid size:" 4359 "%"PRIu32
"\n", i, key_size);
4363 if (type !=
MKTAG(
'm',
'd',
't',
'a')) {
4389 for (i = 0; i < 3; i++) {
4400 if (len < 12 || len - 12 > end -
avio_tell(pb))
4404 if (tag ==
MKTAG(
'm',
'e',
'a',
'n'))
4406 else if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
4408 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
4431 if (mean && key && val) {
4432 if (strcmp(key,
"iTunSMPB") == 0) {
4433 int priming, remainder, samples;
4434 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
4435 if(priming>0 && priming<16384)
4439 if (strcmp(key,
"cdec") != 0) {
4446 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
4458 while (atom.
size > 8) {
4464 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
4474 #define IS_MATRIX_IDENT(matrix) \ 4475 ( (matrix)[0][0] == (1 << 16) && \ 4476 (matrix)[1][1] == (1 << 16) && \ 4477 (matrix)[2][2] == (1 << 30) && \ 4478 !(matrix)[0][1] && !(matrix)[0][2] && \ 4479 !(matrix)[1][0] && !(matrix)[1][2] && \ 4480 !(matrix)[2][0] && !(matrix)[2][1]) 4487 int display_matrix[3][3];
4488 int res_display_matrix[3][3] = { { 0 } };
4532 for (i = 0; i < 3; i++) {
4540 sc->
width = width >> 16;
4541 sc->
height = height >> 16;
4544 for (i = 0; i < 3; i++) {
4545 const int sh[3] = { 16, 16, 30 };
4546 for (j = 0; j < 3; j++) {
4547 for (e = 0; e < 3; e++) {
4548 res_display_matrix[
i][j] +=
4549 ((int64_t) display_matrix[i][e] *
4564 for (i = 0; i < 3; i++)
4565 for (j = 0; j < 3; j++)
4570 if (!
isnan(rotate)) {
4571 char rotate_buf[64];
4575 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
4584 double disp_transform[2];
4586 for (i = 0; i < 2; i++)
4590 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
4591 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
4592 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
4594 disp_transform[0] / disp_transform[1],
4646 num = atom.
size / 4;
4695 int64_t base_media_decode_time;
4719 if (frag_stream_info)
4720 frag_stream_info->
tfdt_dts = base_media_decode_time;
4734 int data_offset = 0;
4735 unsigned entries, first_sample_flags = frag->
flags;
4738 int next_frag_index = -1, index_entry_pos;
4739 size_t requested_size;
4740 size_t old_ctts_allocated_size;
4772 if (frag_stream_info && frag_stream_info->
index_entry >= 0) {
4773 next_frag_index =
i;
4778 av_assert0(index_entry_pos <= st->nb_index_entries);
4791 if (frag_stream_info)
4797 ", using it for pts\n", pts);
4803 ", using it for pts\n", pts);
4807 ", using it for dts\n", dts);
4811 ", using it for dts\n", dts);
4816 ", using it for dts\n", dts);
4852 if (index_entry_pos < st->nb_index_entries) {
4858 memmove(sc->
ctts_data + index_entry_pos + entries,
4861 if (index_entry_pos < sc->current_sample) {
4870 if (frag_stream_info)
4873 if (index_entry_pos > 0)
4876 for (i = 0; i < entries && !pb->
eof_reached; i++) {
4877 unsigned sample_size = frag->
size;
4878 int sample_flags = i ? frag->
flags : first_sample_flags;
4879 unsigned sample_duration = frag->
duration;
4880 unsigned ctts_duration = 0;
4882 int index_entry_flags = 0;
4892 if (flags & MOV_TRUN_SAMPLE_CTS) {
4893 dts -= ctts_duration;
4898 "pts %"PRId64
" calculated dts %"PRId64
4899 " sc->dts_shift %d ctts.duration %d" 4900 " sc->time_offset %"PRId64
4901 " flags & MOV_TRUN_SAMPLE_CTS %d\n",
4920 if (prev_dts >= dts)
4934 "size %u, distance %d, keyframe %d\n", st->
index,
4935 index_entry_pos, offset, dts, sample_size, distance, keyframe);
4937 dts += sample_duration;
4938 offset += sample_size;
4941 if (sample_duration <= INT64_MAX - sc->duration_for_fps &&
4951 int gap = entries -
i;
4956 memmove(sc->
ctts_data + index_entry_pos,
4963 if (index_entry_pos < sc->current_sample) {
4973 if (index_entry_pos > 0)
4976 if (prev_dts < st->index_entries[i].timestamp)
5005 unsigned i, j, track_id, item_count;
5035 if (timescale.
den <= 0) {
5051 if (item_count == 0)
5054 for (i = 0; i < item_count; i++) {
5059 if (size & 0x80000000) {
5068 if (frag_stream_info)
5069 frag_stream_info->
sidx_pts = timestamp;
5123 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
5137 long cmov_len, moov_len;
5151 cmov_len = atom.
size - 6 * 4;
5163 goto free_and_return;
5166 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
5167 goto free_and_return;
5169 goto free_and_return;
5172 atom.
size = moov_len;
5189 int64_t elst_entry_size;
5200 elst_entry_size = version == 1 ? 20 : 12;
5201 if (atom.
size != edit_count * elst_entry_size) {
5203 av_log(c->
fc,
AV_LOG_ERROR,
"Invalid edit list entry_count: %d for elst atom of size: %"PRId64
" bytes.\n",
5204 edit_count, atom.
size + 8);
5207 edit_count = atom.
size / elst_entry_size;
5208 if (edit_count * elst_entry_size != atom.
size) {
5225 for (i = 0; i < edit_count && atom.
size > 0 && !pb->
eof_reached; i++) {
5242 if (e->
time < 0 && e->
time != -1 &&
5274 if (atom.
size < 4) {
5302 if (atom.
size < 5) {
5316 color_primaries =
avio_r8(pb);
5340 const int chroma_den = 50000;
5341 const int luma_den = 10000;
5349 if (atom.
size < 5) {
5368 for (i = 0; i < 3; i++)
5369 for (j = 0; j < 2; j++)
5372 for (i = 0; i < 2; i++)
5389 const int mapping[3] = {1, 2, 0};
5390 const int chroma_den = 50000;
5391 const int luma_den = 10000;
5408 for (i = 0; i < 3; i++) {
5409 const int j = mapping[
i];
5435 if (atom.
size < 5) {
5471 if (atom.
size < 4) {
5504 if (atom.
size < 5) {
5544 uint32_t l = 0, t = 0,
r = 0,
b = 0;
5545 uint32_t
tag, padding = 0;
5554 if (atom.
size < 8) {
5560 if (size <= 12 || size > atom.
size)
5564 if (tag !=
MKTAG(
's',
'v',
'h',
'd')) {
5578 if (size > atom.
size)
5582 if (tag !=
MKTAG(
'p',
'r',
'o',
'j')) {
5588 if (size > atom.
size)
5592 if (tag !=
MKTAG(
'p',
'r',
'h',
'd')) {
5610 if (size > atom.
size)
5622 case MKTAG(
'c',
'b',
'm',
'p'):
5626 "Unsupported cubemap layout %d\n", layout);
5632 case MKTAG(
'e',
'q',
'u',
'i'):
5638 if (
b >= UINT_MAX - t ||
r >= UINT_MAX - l) {
5640 "Invalid bounding rectangle coordinates " 5641 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n", l, t,
r,
b);
5645 if (l || t ||
r ||
b)
5691 av_stristr(buffer,
"<GSpherical:StitchingSoftware>") &&
5692 (val =
av_stristr(buffer,
"<GSpherical:Spherical>")) &&
5694 (val =
av_stristr(buffer,
"<GSpherical:Stitched>")) &&
5696 (val =
av_stristr(buffer,
"<GSpherical:ProjectionType>")) &&
5722 val =
av_stristr(buffer,
"<GSpherical:InitialViewHeadingDegrees>");
5725 val =
av_stristr(buffer,
"<GSpherical:InitialViewPitchDegrees>");
5728 val =
av_stristr(buffer,
"<GSpherical:InitialViewRollDegrees>");
5744 static const uint8_t uuid_isml_manifest[] = {
5745 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
5746 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
5748 static const uint8_t uuid_xmp[] = {
5749 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
5750 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
5752 static const uint8_t uuid_spherical[] = {
5753 0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
5754 0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
5757 if (atom.
size <
sizeof(uuid) || atom.
size >=
FFMIN(INT_MAX, SIZE_MAX))
5765 ret =
avio_read(pb, uuid,
sizeof(uuid));
5768 }
else if (ret !=
sizeof(uuid)) {
5771 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
5774 size_t len = atom.
size -
sizeof(uuid);
5790 }
else if (ret != len) {
5796 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
5797 ptr +=
sizeof(
"systemBitrate=\"") - 1;
5806 ret = strtol(ptr, &endptr, 10);
5807 if (ret < 0 || errno || *endptr !=
'"') {
5815 }
else if (!memcmp(uuid, uuid_xmp,
sizeof(uuid))) {
5817 size_t len = atom.
size -
sizeof(uuid);
5827 }
else if (ret != len) {
5840 }
else if (!memcmp(uuid, uuid_spherical,
sizeof(uuid))) {
5841 size_t len = atom.
size -
sizeof(uuid);
5866 && !memcmp(content,
"Anevia\x1A\x1A", 8)
5888 case MKTAG(
'e',
'n',
'c',
'v'):
5889 case MKTAG(
'e',
'n',
'c',
'a'):
5894 "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
5904 if (format != sc->
format) {
5906 "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
5907 (
char*)&format, (
char*)&sc->
format);
5928 if (frag_stream_info) {
5941 if (!(*sc)->cenc.default_encrypted_sample)
5957 if (!(*sc)->cenc.encryption_index) {
5959 if (!(*sc)->cenc.default_encrypted_sample)
5962 if (!(*sc)->cenc.encryption_index)
5966 *encryption_index = (*sc)->cenc.encryption_index;
5974 unsigned int subsample_count;
5995 if (use_subsamples) {
5997 av_free((*sample)->subsamples);
5998 (*sample)->subsamples =
av_mallocz_array(subsample_count,
sizeof(*subsamples));
5999 if (!(*sample)->subsamples) {
6005 for (i = 0; i < subsample_count && !pb->
eof_reached; i++) {
6006 (*sample)->subsamples[
i].bytes_of_clear_data =
avio_rb16(pb);
6007 (*sample)->subsamples[
i].bytes_of_protected_data =
avio_rb32(pb);
6016 (*sample)->subsample_count = subsample_count;
6027 int use_subsamples, ret;
6028 unsigned int sample_count,
i, alloc_size = 0;
6044 if (sample_count >= INT_MAX /
sizeof(*encrypted_samples))
6047 for (i = 0; i < sample_count; i++) {
6048 unsigned int min_samples =
FFMIN(
FFMAX(i + 1, 1024 * 1024), sample_count);
6050 min_samples *
sizeof(*encrypted_samples));
6051 if (encrypted_samples) {
6082 size_t sample_count, sample_info_size,
i;
6084 unsigned int alloc_size = 0;
6093 if (sample_count >= INT_MAX /
sizeof(*encrypted_samples))
6099 av_log(c->
fc,
AV_LOG_INFO,
"Failed to seek for auxiliary info, will only parse senc atoms for encryption info\n");
6103 for (i = 0; i < sample_count && !pb->
eof_reached; i++) {
6104 unsigned int min_samples =
FFMIN(
FFMAX(i + 1, 1024 * 1024), sample_count);
6106 min_samples *
sizeof(*encrypted_samples));
6107 if (!encrypted_samples) {
6132 for (; i > 0; i--) {
6147 const unsigned int block_size = 1024 * 1024;
6149 unsigned int alloc_size = 0,
offset = 0;
6151 unsigned int new_size =
6152 alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + block_size;
6154 unsigned int to_read =
FFMIN(size, alloc_size) -
offset;
6159 buffer = new_buffer;
6177 unsigned int sample_count, aux_info_type, aux_info_param;
6203 if (aux_info_param != 0) {
6209 if ((aux_info_type ==
MKBETAG(
'c',
'e',
'n',
'c') ||
6210 aux_info_type ==
MKBETAG(
'c',
'e',
'n',
's') ||
6211 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
'1') ||
6212 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
's')) &&
6213 aux_info_param == 0) {
6246 uint64_t *auxiliary_offsets;
6250 unsigned int version, entry_count, aux_info_type, aux_info_param;
6251 unsigned int alloc_size = 0;
6277 if (aux_info_param != 0) {
6283 if ((aux_info_type ==
MKBETAG(
'c',
'e',
'n',
'c') ||
6284 aux_info_type ==
MKBETAG(
'c',
'e',
'n',
's') ||
6285 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
'1') ||
6286 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
's')) &&
6287 aux_info_param == 0) {
6300 if (entry_count >= INT_MAX /
sizeof(*auxiliary_offsets))
6303 for (i = 0; i < entry_count && !pb->
eof_reached; i++) {
6304 unsigned int min_offsets =
FFMIN(
FFMAX(i + 1, 1024), entry_count);
6307 min_offsets *
sizeof(*auxiliary_offsets));
6308 if (!auxiliary_offsets) {
6344 uint8_t *side_data, *extra_data, *old_side_data;
6345 size_t side_data_size;
6346 int ret = 0, old_side_data_size;
6347 unsigned int version, kid_count, extra_data_size, alloc_size = 0;
6369 if (kid_count >= INT_MAX /
sizeof(*key_ids)) {
6374 for (
unsigned int i = 0;
i < kid_count && !pb->
eof_reached;
i++) {
6375 unsigned int min_kid_count =
FFMIN(
FFMAX(
i + 1, 1024), kid_count);
6377 min_kid_count *
sizeof(*key_ids));
6411 info->
data = extra_data;
6416 if (old_side_data) {
6418 if (old_init_info) {
6426 info = old_init_info;
6440 side_data, side_data_size);
6484 unsigned int version, pattern, is_protected, iv_size;
6537 if (iv_size != 8 && iv_size != 16) {
6561 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 42)
6649 int encrypted_index, ret;
6652 encrypted_index = current_index;
6653 encryption_index =
NULL;
6654 if (frag_stream_info) {
6658 encrypted_index = current_index - frag_stream_info->
index_entry;
6668 if (encryption_index) {
6683 }
else if (encrypted_index >= 0 && encrypted_index < encryption_index->nb_encrypted_samples) {
6719 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 11)
6729 size = atom.
size + 8;
6854 int64_t total_size = 0;
6865 atom.
size = INT64_MAX;
6870 if (atom.
size >= 8) {
6883 if (type ==
MKTAG(
'm',
'v',
'h',
'd') ||
6884 type ==
MKTAG(
'c',
'm',
'o',
'v')) {
6889 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
6901 if (a.
size == 1 && total_size + 8 <= atom.
size) {
6909 a.
size = atom.
size - total_size + 8;
6918 for (i = 0; mov_default_parse_table[
i].
type; i++)
6919 if (mov_default_parse_table[i].
type == a.
type) {
6942 int err =
parse(c, pb, a);
6958 else if (left < 0) {
6960 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
6961 (
char*)&a.
type, -left);
6966 total_size += a.
size;
6969 if (total_size < atom.
size && atom.
size < 0x7ffff)
6981 int moov_offset = -1;
6987 if ((offset + 8) > (
unsigned int)p->
buf_size)
6992 case MKTAG(
'm',
'o',
'o',
'v'):
6993 moov_offset = offset + 4;
6994 case MKTAG(
'm',
'd',
'a',
't'):
6995 case MKTAG(
'p',
'n',
'o',
't'):
6996 case MKTAG(
'u',
'd',
't',
'a'):
6997 case MKTAG(
'f',
't',
'y',
'p'):
7000 offset + 12 > (
unsigned int)p->
buf_size ||
7003 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
7007 score =
FFMAX(score, 5);
7014 case MKTAG(
'e',
'd',
'i',
'w'):
7015 case MKTAG(
'w',
'i',
'd',
'e'):
7016 case MKTAG(
'f',
'r',
'e',
'e'):
7017 case MKTAG(
'j',
'u',
'n',
'k'):
7018 case MKTAG(
'p',
'i',
'c',
't'):
7022 case MKTAG(0x82,0x82,0x7f,0x7d):
7023 case MKTAG(
's',
'k',
'i',
'p'):
7024 case MKTAG(
'u',
'u',
'i',
'd'):
7025 case MKTAG(
'p',
'r',
'f',
'l'):
7037 offset = moov_offset;
7039 while(offset < (p->
buf_size - 16)){
7073 if (s->
streams[i]->
id == chapter_track) {
7114 if (end < sample->timestamp) {
7126 if (len > sample->
size-2)
7128 title_len = 2*len + 1;
7141 else if (ch == 0xfffe)
7145 if (len == 1 || len == 2)
7180 int hh, mm,
ss, ff, drop;
7193 hh, mm, ss, drop ?
';' :
':', ff);
7230 if (!index || !*index)
return;
7231 for (i = 0; i < (*index)->nb_encrypted_samples; i++) {
7234 av_freep(&(*index)->encrypted_samples);
7235 av_freep(&(*index)->auxiliary_info_sizes);
7236 av_freep(&(*index)->auxiliary_offsets);
7360 unsigned track_id, item_count;
7372 for (i = 0; i < item_count; i++) {
7394 if (frag_stream_info &&
7398 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
7400 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
7402 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
7417 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
7422 if (mfra_size < 0 || mfra_size > stream_size) {
7426 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
7446 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
7449 "failed to seek back after looking for mfra\n");
7475 atom.
size = INT64_MAX;
7510 int tmcd_st_id = -1;
7516 if (tmcd_st_id < 0 || tmcd_st_id == i)
7669 int64_t best_dts = INT64_MAX;
7683 sample = current_sample;
7704 if (index >= 0 && index < mov->frag_index.nb_items)
7706 if (
avio_seek(s->
pb, target, SEEK_SET) != target) {
7714 if (index < mov->frag_index.nb_items) {
7745 if (extradata_size > 0 && extradata) {
7751 memcpy(side, extradata, extradata_size);
7763 int64_t current_index;
7787 if (ret64 != sample->
pos) {
7808 #if CONFIG_DV_DEMUXER 7856 if (next_dts >= pkt->
dts)
7887 ret =
cenc_filter(mov, st, sc, pkt, current_index);
7918 int sample, time_sample, ret;
7931 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
7979 st = s->
streams[stream_index];
7994 if (stream_index == i)
8021 #define OFFSET(x) offsetof(MOVContext, x) 8022 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM 8024 {
"use_absolute_path",
8025 "allow using absolute path when opening alias, this is a possible security issue",
8028 {
"seek_streams_individually",
8029 "Seek each stream individually to the to the closest point",
8034 {
"advanced_editlist",
8035 "Modify the AVIndex according to the editlists. Use this option to decode in the order specified by the edits.",
8041 "use mfra for fragment timestamps",
8046 FLAGS,
"use_mfra_for" },
8048 FLAGS,
"use_mfra_for" },
8050 FLAGS,
"use_mfra_for" },
8051 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
8053 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
8055 {
"activation_bytes",
"Secret bytes for Audible AAX files",
OFFSET(activation_bytes),
8057 {
"audible_fixed_key",
8058 "Fixed key used for handling Audible AAX files",
OFFSET(audible_fixed_key),
8063 {.i64 = 0}, 0, 1,
FLAGS },
8076 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
8080 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2",
int32_t pitch
Rotation around the right vector [-90, 90].
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.
AVSphericalMapping * av_spherical_alloc(size_t *size)
Allocate a AVSphericalVideo structure and initialize its fields to default values.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
size_t auxiliary_offsets_count
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.
static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
int64_t avio_size(AVIOContext *s)
Get the filesize.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
static const char * format[]
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
#define OPUS_SEEK_PREROLL_MS
unsigned int rap_group_count
unsigned MaxCLL
Max content light level (cd/m^2).
void av_encryption_info_free(AVEncryptionInfo *info)
Frees the given encryption info object.
static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt)
#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
AVEncryptionInitInfo * av_encryption_init_info_alloc(uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size)
Allocates an AVEncryptionInitInfo structure and sub-pointers to hold the given sizes.
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
unsigned int ctts_allocated_size
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
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 void mov_free_encryption_index(MOVEncryptionIndex **index)
void av_encryption_init_info_free(AVEncryptionInitInfo *info)
Frees the given encryption init info object.
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)
uint32_t crypt_byte_block
Only used for pattern encryption.
#define avpriv_request_sample(...)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
static void set_frag_stream(MOVFragmentIndex *frag_index, int id)
static MOVFragmentStreamInfo * get_current_frag_stream_info(MOVFragmentIndex *frag_index)
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection...
AVEncryptionInfo * default_encrypted_sample
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)
AVMasteringDisplayMetadata * mastering
int index
stream index in AVFormatContext
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_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), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;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)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) 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);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=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) { int planes=out->planar ? out->ch_count :1;unsigned m=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){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
#define MOV_TRUN_SAMPLE_CTS
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
#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.
This describes encryption info for a packet.
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
int event_flags
Flags for the user to detect events happening on the file.
AVEncryptionInfo ** encrypted_samples
struct MOVStreamContext::@253 cenc
static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
Video represents a sphere mapped on a flat surface using equirectangular projection.
uint64_t * auxiliary_offsets
Absolute seek position.
uint8_t * av_encryption_init_info_add_side_data(const AVEncryptionInitInfo *info, size_t *side_data_size)
Allocates and initializes side data that holds a copy of the given encryption init info...
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int16_t audio_cid
stsd audio compression id
#define PUT_UTF8(val, tmp, PUT_BYTE)
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
Views are next to each other.
static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_t len)
#define IS_MATRIX_IDENT(matrix)
unsigned int avio_rb16(AVIOContext *s)
int(* parse)(MOVContext *ctx, AVIOContext *pb, MOVAtom atom)
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint32_t skip_byte_block
Only used for pattern encryption.
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.
AVStereo3D * av_stereo3d_alloc(void)
Allocate an AVStereo3D structure and set its fields to default values.
int strict_std_compliance
Allow non-standard and experimental extension.
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVSphericalMapping * spherical
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)
static MOVFragmentStreamInfo * get_frag_stream_info(MOVFragmentIndex *frag_index, int index, int id)
#define MOV_TFHD_DEFAULT_BASE_IS_MOOF
const char * av_color_space_name(enum AVColorSpace space)
Macro definitions for various function/variable attributes.
int frame_size
Audio only.
Mastering display metadata (based on SMPTE-2086:2014).
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_read_st3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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 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)
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const AVOption mov_options[]
static void mov_current_sample_dec(MOVStreamContext *sc)
static int64_t start_time
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
uint8_t ** key_ids
An array of key IDs this initialization data is for.
AVEncryptionInfo * av_encryption_info_clone(const AVEncryptionInfo *info)
Allocates an AVEncryptionInfo structure with a copy of the given data.
#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)
unsigned int bytes_of_clear_data
The number of bytes that are clear.
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
AVInputFormat ff_mov_demuxer
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVStreamContext *sc, AVEncryptionInfo **sample, int use_subsamples)
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.
static void mov_current_sample_inc(MOVStreamContext *sc)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
uint8_t * av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
uint32_t scheme
The fourcc encryption scheme, in big-endian byte order.
This file is part of FFmpeg.
This describes info used to initialize an encryption key system.
#define AV_CH_LOW_FREQUENCY
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
int initial_padding
Audio only.
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.
This side data is encryption initialization data.
#define MOV_TRUN_SAMPLE_SIZE
uint8_t * iv
The initialization vector.
#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
Video is not stereoscopic (and metadata has to be there).
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 get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encryption_index, MOVStreamContext **sc)
Gets the current encryption info and associated current stream context.
static int test_same_origin(const char *src, const char *ref)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
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
int32_t movie_display_matrix[3][3]
display matrix from mvhd
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)
AVEncryptionInitInfo * av_encryption_init_info_get_side_data(const uint8_t *side_data, size_t side_data_size)
Creates a copy of the AVEncryptionInitInfo that is contained in the given side data.
static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_try_read_block(AVIOContext *pb, size_t size, uint8_t **data)
Tries to read the given number of bytes from the stream and puts it in a newly allocated buffer...
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
MOVIndexRange * index_ranges
AVSubsampleEncryptionInfo * subsamples
An array of subsample encryption info specifying how parts of the sample are encrypted.
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)
uint8_t * auxiliary_info_sizes
static int mov_rewrite_dvd_sub_extradata(AVStream *st)
const AVCodecTag ff_codec_movdata_tags[]
#define i(width, name, range_min, range_max)
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.
static int mov_read_vpcc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette...
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_mdcv(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryptionIndex *encryption_index)
FLAC (Free Lossless Audio Codec) decoder/demuxer common functions.
unsigned int avio_rl32(AVIOContext *s)
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint32_t num_key_ids
The number of key IDs.
static int mov_read_coll(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...
MOVIndexRange * current_index_range
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVColorPrimaries color_primaries
char * url
input or output URL.
int video_delay
Video only.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define av_fourcc2str(fourcc)
enum AVMediaType codec_type
General type of the encoded data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
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)
#define FFNABS(a)
Negative Absolute value.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
uint8_t * av_encryption_info_add_side_data(const AVEncryptionInfo *info, size_t *size)
Allocates and initializes side data that holds a copy of the given encryption info.
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[]
#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[]
int64_t min_corrected_pts
minimum Composition time shown by the edits excluding empty edits.
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.
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
static int search_frag_timestamp(MOVFragmentIndex *frag_index, AVStream *st, int64_t timestamp)
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)
Allocate, reallocate, or free an array through a pointer to a pointer.
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)
#define MAX_REORDER_DELAY
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVContentLightMetadata * coll
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)
uint32_t bound_bottom
Distance from the bottom edge.
static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
static int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index)
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)
#define ss(width, name, subs,...)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static int mov_read_clli(MOVContext *c, AVIOContext *pb, MOVAtom atom)
struct AVEncryptionInitInfo * next
An optional pointer to the next initialization info in the list.
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
audio channel layout utility functions
unsigned int avio_rb24(AVIOContext *s)
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.
MOVFragmentStreamInfo * stream_info
const AVCodecTag ff_codec_bmp_tags[]
int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as stream side data.
AVStereo3DType
List of possible 3D Types.
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)
static int mov_stsc_index_valid(unsigned int index, unsigned int count)
static int update_frag_index(MOVContext *c, int64_t offset)
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t auxiliary_info_default_size
static int cenc_filter(MOVContext *mov, AVStream *st, MOVStreamContext *sc, AVPacket *pkt, int current_index)
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint32_t bound_right
Distance from the right edge.
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 FLAC_STREAMINFO_SIZE
static int search_frag_moof_offset(MOVFragmentIndex *frag_index, int64_t offset)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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.
int32_t yaw
Rotation around the up vector [-180, 180].
#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.
MOVFragmentIndexItem * item
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...
MOVFragmentIndex frag_index
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
static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *input, int size)
the normal 2^n-1 "JPEG" YUV ranges
static int mov_read_av1c(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
static int read_header(FFV1Context *f)
uint32_t padding
Number of pixels to pad from the edge of each cube face.
int64_t duration
duration of the longest track
int ff_mov_lang_to_iso639(unsigned code, char to[4])
static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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)
AVSphericalProjection
Projection of the video surface(s) on a sphere.
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)
Content light level (based on CTA-861.3).
DVDemuxContext * dv_demux
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
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]
enum AVStereo3DType type
How views are packed within the video.
#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...
Views are on top of each other.
const AVCodecTag ff_codec_movaudio_tags[]
static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
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 int64_t get_frag_time(MOVFragmentIndex *frag_index, int index, int track_id)
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.
MOVEncryptionIndex * encryption_index
Describe the class of an AVClass context structure.
static int find_prev_closest_index(AVStream *st, AVIndexEntry *e_old, int nb_old, MOVStts *ctts_data, int64_t ctts_count, int64_t timestamp_pts, int flag, int64_t *index, int64_t *ctts_index, int64_t *ctts_sample)
Find the closest previous frame to the timestamp_pts, in e_old index entries.
static void skip_bits(GetBitContext *s, int n)
unsigned int bytes_of_protected_data
The number of bytes that are protected.
int32_t roll
Rotation around the forward vector [-180, 180].
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.
static void mov_estimate_video_delay(MOVContext *c, AVStream *st)
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
int64_t track_end
used for dts generation in fragmented movie files
static enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
Compute codec id for 'lpcm' tag.
static av_always_inline void flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size)
Parse the metadata block parameters from the header.
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
static int mov_read_schm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
This side data contains encryption info for how to decrypt the packet.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
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...
int seek_preroll
Audio only.
#define flags(name, subs,...)
static void mov_update_dts_shift(MOVStreamContext *sc, int duration)
unsigned int per_sample_iv_size
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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.
uint32_t bound_top
Distance from the top edge.
the normal 219*2^(n-8) "MPEG" YUV ranges
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)
A reference to a data buffer.
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
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
uint8_t * key_id
The ID of the key used to encrypt the packet.
static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)
#define MOV_TFHD_BASE_DATA_OFFSET
static int ref[MAX_W *MAX_W]
enum AVSphericalProjection projection
Projection type.
static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
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.
uint8_t * data
Key-system specific initialization data.
static int mov_codec_id(AVStream *st, uint32_t format)
int64_t nb_frames
number of frames in this stream if known or 0
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
MOVEncryptionIndex * encryption_index
static void fix_frag_index_entries(MOVFragmentIndex *frag_index, int index, int id, int entries)
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
static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void * priv_data
Format private data.
static int mov_read_mfra(MOVContext *c, AVIOContext *f)
static const AVClass mov_class
uint32_t bound_left
Distance from the left edge.
static int64_t get_stream_info_time(MOVFragmentStreamInfo *frag_stream_info)
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_encrypted_samples
unsigned int nb_chapter_tracks
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)
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
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)
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
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
AVEncryptionInfo * av_encryption_info_alloc(uint32_t subsample_count, uint32_t key_id_size, uint32_t iv_size)
Allocates an AVEncryptionInfo structure and sub-pointers to hold the given number of subsamples...
static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_current_sample_set(MOVStreamContext *sc, int current_sample)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#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.
void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the "full" 16-byte iv, including the counter.
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)
#define FFSWAP(type, a, b)
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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.
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
unsigned MaxFALL
Max average light level per frame (cd/m^2).
This structure stores compressed data.
static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
size_t auxiliary_info_sample_count
mode
Use these values in ebur128_init (or'ed).
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...
uint8_t * system_id
A unique identifier for the key system this is for, can be NULL if it is not known.
#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
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom)