79 static int64_t
add_ctts_entry(
MOVStts** ctts_data,
unsigned int* ctts_count,
unsigned int* allocated_size,
83 unsigned len,
const char *
key)
87 short current, total = 0;
93 snprintf(buf,
sizeof(buf),
"%d", current);
95 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
103 unsigned len,
const char *
key)
117 unsigned len,
const char *
key)
126 unsigned len,
const char *
key)
142 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
143 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
144 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
145 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
146 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
147 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
148 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
149 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
150 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
151 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
152 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
153 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
154 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
155 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
156 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
157 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
161 char *dst,
int dstlen)
164 char *end = dst+dstlen-1;
167 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);
287 if (
c->ignore_chapters)
291 if (n_hmmt >
len / 4)
303 char key2[32], language[4] = {0};
306 uint16_t langcode = 0;
307 uint32_t data_type = 0, str_size, str_size_alloc;
313 case MKTAG(
'@',
'P',
'R',
'M'):
key =
"premiere_version"; raw = 1;
break;
314 case MKTAG(
'@',
'P',
'R',
'Q'):
key =
"quicktime_version"; raw = 1;
break;
315 case MKTAG(
'X',
'M',
'P',
'_'):
316 if (
c->export_xmp) {
key =
"xmp"; raw = 1; }
break;
317 case MKTAG(
'a',
'A',
'R',
'T'):
key =
"album_artist";
break;
318 case MKTAG(
'a',
'k',
'I',
'D'):
key =
"account_type";
320 case MKTAG(
'a',
'p',
'I',
'D'):
key =
"account_id";
break;
321 case MKTAG(
'c',
'a',
't',
'g'):
key =
"category";
break;
322 case MKTAG(
'c',
'p',
'i',
'l'):
key =
"compilation";
324 case MKTAG(
'c',
'p',
'r',
't'):
key =
"copyright";
break;
325 case MKTAG(
'd',
'e',
's',
'c'):
key =
"description";
break;
326 case MKTAG(
'd',
'i',
's',
'k'):
key =
"disc";
328 case MKTAG(
'e',
'g',
'i',
'd'):
key =
"episode_uid";
330 case MKTAG(
'F',
'I',
'R',
'M'):
key =
"firmware"; raw = 1;
break;
331 case MKTAG(
'g',
'n',
'r',
'e'):
key =
"genre";
333 case MKTAG(
'h',
'd',
'v',
'd'):
key =
"hd_video";
335 case MKTAG(
'H',
'M',
'M',
'T'):
337 case MKTAG(
'k',
'e',
'y',
'w'):
key =
"keywords";
break;
338 case MKTAG(
'l',
'd',
'e',
's'):
key =
"synopsis";
break;
339 case MKTAG(
'l',
'o',
'c',
'i'):
341 case MKTAG(
'm',
'a',
'n',
'u'):
key =
"make";
break;
342 case MKTAG(
'm',
'o',
'd',
'l'):
key =
"model";
break;
343 case MKTAG(
'p',
'c',
's',
't'):
key =
"podcast";
345 case MKTAG(
'p',
'g',
'a',
'p'):
key =
"gapless_playback";
347 case MKTAG(
'p',
'u',
'r',
'd'):
key =
"purchase_date";
break;
348 case MKTAG(
'r',
't',
'n',
'g'):
key =
"rating";
350 case MKTAG(
's',
'o',
'a',
'a'):
key =
"sort_album_artist";
break;
351 case MKTAG(
's',
'o',
'a',
'l'):
key =
"sort_album";
break;
352 case MKTAG(
's',
'o',
'a',
'r'):
key =
"sort_artist";
break;
353 case MKTAG(
's',
'o',
'c',
'o'):
key =
"sort_composer";
break;
354 case MKTAG(
's',
'o',
'n',
'm'):
key =
"sort_name";
break;
355 case MKTAG(
's',
'o',
's',
'n'):
key =
"sort_show";
break;
356 case MKTAG(
's',
't',
'i',
'k'):
key =
"media_type";
358 case MKTAG(
't',
'r',
'k',
'n'):
key =
"track";
360 case MKTAG(
't',
'v',
'e',
'n'):
key =
"episode_id";
break;
361 case MKTAG(
't',
'v',
'e',
's'):
key =
"episode_sort";
363 case MKTAG(
't',
'v',
'n',
'n'):
key =
"network";
break;
364 case MKTAG(
't',
'v',
's',
'h'):
key =
"show";
break;
365 case MKTAG(
't',
'v',
's',
'n'):
key =
"season_number";
367 case MKTAG(0xa9,
'A',
'R',
'T'):
key =
"artist";
break;
368 case MKTAG(0xa9,
'P',
'R',
'D'):
key =
"producer";
break;
369 case MKTAG(0xa9,
'a',
'l',
'b'):
key =
"album";
break;
370 case MKTAG(0xa9,
'a',
'u',
't'):
key =
"artist";
break;
371 case MKTAG(0xa9,
'c',
'h',
'p'):
key =
"chapter";
break;
372 case MKTAG(0xa9,
'c',
'm',
't'):
key =
"comment";
break;
373 case MKTAG(0xa9,
'c',
'o',
'm'):
key =
"composer";
break;
374 case MKTAG(0xa9,
'c',
'p',
'y'):
key =
"copyright";
break;
375 case MKTAG(0xa9,
'd',
'a',
'y'):
key =
"date";
break;
376 case MKTAG(0xa9,
'd',
'i',
'r'):
key =
"director";
break;
377 case MKTAG(0xa9,
'd',
'i',
's'):
key =
"disclaimer";
break;
378 case MKTAG(0xa9,
'e',
'd',
'1'):
key =
"edit_date";
break;
379 case MKTAG(0xa9,
'e',
'n',
'c'):
key =
"encoder";
break;
380 case MKTAG(0xa9,
'f',
'm',
't'):
key =
"original_format";
break;
381 case MKTAG(0xa9,
'g',
'e',
'n'):
key =
"genre";
break;
382 case MKTAG(0xa9,
'g',
'r',
'p'):
key =
"grouping";
break;
383 case MKTAG(0xa9,
'h',
's',
't'):
key =
"host_computer";
break;
384 case MKTAG(0xa9,
'i',
'n',
'f'):
key =
"comment";
break;
385 case MKTAG(0xa9,
'l',
'y',
'r'):
key =
"lyrics";
break;
386 case MKTAG(0xa9,
'm',
'a',
'k'):
key =
"make";
break;
387 case MKTAG(0xa9,
'm',
'o',
'd'):
key =
"model";
break;
388 case MKTAG(0xa9,
'n',
'a',
'm'):
key =
"title";
break;
389 case MKTAG(0xa9,
'o',
'p',
'e'):
key =
"original_artist";
break;
390 case MKTAG(0xa9,
'p',
'r',
'd'):
key =
"producer";
break;
391 case MKTAG(0xa9,
'p',
'r',
'f'):
key =
"performers";
break;
392 case MKTAG(0xa9,
'r',
'e',
'q'):
key =
"playback_requirements";
break;
393 case MKTAG(0xa9,
's',
'r',
'c'):
key =
"original_source";
break;
394 case MKTAG(0xa9,
's',
't',
'3'):
key =
"subtitle";
break;
395 case MKTAG(0xa9,
's',
'w',
'r'):
key =
"encoder";
break;
396 case MKTAG(0xa9,
't',
'o',
'o'):
key =
"encoder";
break;
397 case MKTAG(0xa9,
't',
'r',
'k'):
key =
"track";
break;
398 case MKTAG(0xa9,
'u',
'r',
'l'):
key =
"URL";
break;
399 case MKTAG(0xa9,
'w',
'r',
'n'):
key =
"warning";
break;
400 case MKTAG(0xa9,
'w',
'r',
't'):
key =
"composer";
break;
401 case MKTAG(0xa9,
'x',
'y',
'z'):
key =
"location";
break;
404 if (
c->itunes_metadata && atom.
size > 8) {
407 if (
tag ==
MKTAG(
'd',
'a',
't',
'a') && data_size <= atom.size && data_size >= 16) {
410 str_size = data_size - 16;
413 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
419 atom.
size -= str_size;
423 }
else if (!
key &&
c->found_hdlr_mdta &&
c->meta_keys) {
425 if (index < c->meta_keys_count &&
index > 0) {
429 "The index of 'data' is out of range: %"PRId32
" < 1 or >= %d.\n",
430 index,
c->meta_keys_count);
434 }
else if (atom.
size > 4 &&
key && !
c->itunes_metadata && !raw) {
436 if (str_size > atom.
size) {
446 str_size = atom.
size;
448 if (
c->export_all && !
key) {
454 if (atom.
size < 0 || str_size >= INT_MAX/2)
459 num = (data_type >= 21 && data_type <= 23);
460 str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1;
468 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
470 }
else if (data_type == 21) {
474 else if (str_size == 2)
476 else if (str_size == 3)
478 else if (str_size == 4)
482 "Failed to store the number (%d) in string.\n",
val);
486 }
else if (data_type == 22) {
487 unsigned int val = 0;
490 else if (str_size == 2)
492 else if (str_size == 3)
494 else if (str_size == 4)
498 "Failed to store the number (%u) in string.\n",
val);
502 }
else if (data_type == 23 && str_size >= 4) {
506 "Failed to store the float32 number (%f) in string.\n",
val);
520 if (*language && strcmp(language,
"und")) {
521 snprintf(key2,
sizeof(key2),
"%s-%s",
key, language);
524 if (!strcmp(
key,
"encoder")) {
526 if (sscanf(
str,
"HandBrake %d.%d.%d", &
major, &
minor, µ) == 3) {
527 c->handbrake_version = 1000000*
major + 1000*
minor + micro;
539 int i, nb_chapters, str_len,
version;
543 if (
c->ignore_chapters)
546 if ((atom.
size -= 5) < 0)
555 for (
i = 0;
i < nb_chapters;
i++) {
562 if ((atom.
size -= 9+str_len) < 0)
574 #define MIN_DATA_ENTRY_BOX_SIZE 12
581 if (
c->fc->nb_streams < 1)
583 st =
c->fc->streams[
c->fc->nb_streams-1];
590 entries >= UINT_MAX /
sizeof(*sc->
drefs))
605 for (
i = 0;
i < entries;
i++) {
618 uint16_t volume_len,
len;
625 volume_len =
FFMIN(volume_len, 27);
629 dref->
volume[volume_len] = 0;
671 if (
len > volume_len && !strncmp(dref->
path, dref->
volume, volume_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] ==
':')
736 if (
c->trak_index < 0) {
738 c->found_hdlr_mdta = 1;
743 st =
c->fc->streams[
c->fc->nb_streams-1];
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;
794 if (
c->fc->nb_streams < 1)
796 st =
c->fc->streams[
c->fc->nb_streams-1];
804 bsmod = (ac3info >> 14) & 0x7;
805 acmod = (ac3info >> 11) & 0x7;
806 lfeon = (ac3info >> 10) & 0x1;
815 #if FF_API_LAVF_AVCTX
828 int eac3info, acmod, lfeon, bsmod;
830 if (
c->fc->nb_streams < 1)
832 st =
c->fc->streams[
c->fc->nb_streams-1];
844 bsmod = (eac3info >> 12) & 0x1f;
845 acmod = (eac3info >> 9) & 0x7;
846 lfeon = (eac3info >> 8) & 0x1;
855 #if FF_API_LAVF_AVCTX
869 uint32_t frame_duration_code = 0;
870 uint32_t channel_layout_code = 0;
879 if (
c->fc->nb_streams < 1) {
882 st =
c->fc->streams[
c->fc->nb_streams-1];
892 frame_duration_code =
get_bits(&gb, 2);
894 channel_layout_code =
get_bits(&gb, 16);
897 (frame_duration_code == 0) ? 512 :
898 (frame_duration_code == 1) ? 1024 :
899 (frame_duration_code == 2) ? 2048 :
900 (frame_duration_code == 3) ? 4096 : 0;
902 if (channel_layout_code > 0xff) {
922 if (
c->fc->nb_streams < 1)
924 st =
c->fc->streams[
c->fc->nb_streams-1];
942 if (
c->fc->nb_streams < 1)
944 st =
c->fc->streams[
c->fc->nb_streams-1];
958 if (
c->fc->nb_streams < 1)
960 st =
c->fc->streams[
c->fc->nb_streams-1];
965 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
968 }
else if (den != 0) {
984 #define DRM_BLOB_SIZE 56
993 uint8_t calculated_checksum[20];
997 uint8_t *activation_bytes =
c->activation_bytes;
998 uint8_t *fixed_key =
c->audible_fixed_key;
1007 if (!
c->aes_decrypt) {
1019 for (
i = 0;
i < 20;
i++)
1024 if (!activation_bytes) {
1029 if (
c->activation_bytes_size != 4) {
1036 if (
c->audible_fixed_key_size != 16) {
1056 if (memcmp(calculated_checksum, file_checksum, 20)) {
1063 for (
i = 0;
i < 4;
i++) {
1065 if (activation_bytes[
i] != output[3 -
i]) {
1071 memcpy(
c->file_key, output + 8, 16);
1072 memcpy(input, output + 26, 16);
1087 if (
c->audible_key_size != 16) {
1092 if (
c->audible_iv_size != 16) {
1098 if (!
c->aes_decrypt) {
1102 memcpy(
c->file_key,
c->audible_key, 16);
1103 memcpy(
c->file_iv,
c->audible_iv, 16);
1113 unsigned char iv[16];
1115 memcpy(iv,
c->file_iv, 16);
1127 int comp_brand_size;
1128 char* comp_brands_str;
1134 if (strcmp(
type,
"qt "))
1141 comp_brand_size = atom.
size - 8;
1142 if (comp_brand_size < 0 || comp_brand_size == INT_MAX)
1144 comp_brands_str =
av_malloc(comp_brand_size + 1);
1145 if (!comp_brands_str)
1153 comp_brands_str[comp_brand_size] = 0;
1158 if (!strcmp(
type,
"aaxc")) {
1170 if (
c->found_moov) {
1192 if (index < 0 || index >= frag_index->
nb_items)
1208 if (frag_index->
current < 0 ||
1227 if (frag_index->
current < 0 ||
1242 int64_t moof_offset;
1255 if (moof_offset >=
offset)
1257 if (moof_offset <=
offset)
1274 int index,
int track_id)
1280 if (track_id >= 0) {
1317 m0 = m = (
a +
b) >> 1;
1323 if (m <
b && frag_time <= timestamp)
1340 if (index < c->frag_index.nb_items &&
1347 &
c->frag_index.allocated_size,
1348 (
c->frag_index.nb_items + 1) *
1349 sizeof(*
c->frag_index.item));
1352 c->frag_index.item = item;
1356 if (!frag_stream_info)
1359 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
1361 if (
c->fc->streams[
i]->id < 0) {
1366 frag_stream_info[
i].
id =
c->fc->streams[
i]->id;
1375 if (index < c->frag_index.nb_items)
1376 memmove(
c->frag_index.item +
index + 1,
c->frag_index.item +
index,
1377 (
c->frag_index.nb_items -
index) *
sizeof(*
c->frag_index.item));
1379 item = &
c->frag_index.item[
index];
1385 c->frag_index.nb_items++;
1391 int id,
int entries)
1400 if (frag_stream_info && frag_stream_info->
index_entry >= 0)
1408 c->fragment.found_tfhd = 0;
1410 if (!
c->has_looked_for_mfra &&
c->use_mfra_for > 0) {
1411 c->has_looked_for_mfra = 1;
1418 "read the mfra (may be a live ismv)\n");
1422 "seekable, can not look for mfra\n");
1425 c->fragment.moof_offset =
c->fragment.implicit_offset =
avio_tell(pb) - 8;
1434 if (time >= 2082844800)
1437 if ((int64_t)(time * 1000000ULL) / 1000000 != time) {
1451 char language[4] = {0};
1453 int64_t creation_time;
1455 if (
c->fc->nb_streams < 1)
1457 st =
c->fc->streams[
c->fc->nb_streams-1];
1498 int64_t creation_time;
1511 if (
c->time_scale <= 0) {
1529 for (
i = 0;
i < 3;
i++) {
1551 if (
c->fc->nb_streams < 1)
1553 st =
c->fc->streams[
c->fc->nb_streams-1];
1557 if (little_endian == 1) {
1582 char color_parameter_type[5] = { 0 };
1586 if (
c->fc->nb_streams < 1)
1588 st =
c->fc->streams[
c->fc->nb_streams - 1];
1593 if (strncmp(color_parameter_type,
"nclx", 4) &&
1594 strncmp(color_parameter_type,
"nclc", 4) &&
1595 strncmp(color_parameter_type,
"prof", 4)) {
1597 color_parameter_type);
1601 if (!strncmp(color_parameter_type,
"prof", 4)) {
1614 "%s: pri %d trc %d matrix %d",
1617 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1644 unsigned mov_field_order;
1647 if (
c->fc->nb_streams < 1)
1649 st =
c->fc->streams[
c->fc->nb_streams-1];
1653 if ((mov_field_order & 0xFF00) == 0x0100)
1655 else if ((mov_field_order & 0xFF00) == 0x0200) {
1656 switch (mov_field_order & 0xFF) {
1679 if (
size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1693 int64_t result = atom.
size;
1702 }
else if (err < atom.
size) {
1716 uint64_t original_size;
1719 if (
c->fc->nb_streams < 1)
1721 st =
c->fc->streams[
c->fc->nb_streams-1];
1770 if (!ret &&
c->fc->nb_streams >= 1) {
1782 if (
c->fc->nb_streams >= 1) {
1791 if (
cid == 0xd4d ||
cid == 0xd4e)
1802 if (num <= 0 || den <= 0)
1806 if (den >= INT_MAX / 2)
1810 c->fc->streams[
c->fc->nb_streams-1]->internal->display_aspect_ratio.num = num;
1811 c->fc->streams[
c->fc->nb_streams-1]->internal->display_aspect_ratio.den = den;
1825 uint64_t original_size;
1826 if (
c->fc->nb_streams >= 1) {
1830 if (atom.
size == 16) {
1835 if (length == atom.
size) {
1837 switch (range_value) {
1874 if (
c->fc->nb_streams < 1)
1876 st =
c->fc->streams[
c->fc->nb_streams-1];
1878 if ((uint64_t)atom.
size > (1<<30))
1888 }
else if (atom.
size > 8) {
1902 #define ALAC_EXTRADATA_SIZE 36
1931 if (
c->fc->nb_streams < 1)
1933 st =
c->fc->streams[
c->fc->nb_streams-1];
1935 if ((uint64_t)atom.
size > (1<<30))
1938 if (atom.
size >= 10) {
1971 if (
c->fc->nb_streams < 1)
1973 st =
c->fc->streams[
c->fc->nb_streams-1];
1975 if (atom.
size >= (1<<28) || atom.
size < 7)
1979 if ((profile_level & 0xf0) != 0xc0)
2000 if (
c->fc->nb_streams < 1)
2002 if (atom.
size <= 40)
2004 st =
c->fc->streams[
c->fc->nb_streams-1];
2006 if ((uint64_t)atom.
size > (1<<30))
2021 unsigned int i, entries;
2023 if (
c->trak_index < 0) {
2027 if (
c->fc->nb_streams < 1)
2029 st =
c->fc->streams[
c->fc->nb_streams-1];
2051 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
2054 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
2075 ((
format & 0xFFFF) ==
'm' + (
's' << 8) ||
2076 (
format & 0xFFFF) ==
'T' + (
'S' << 8)))
2108 uint8_t codec_name[32] = { 0 };
2143 if (!strncmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
2150 !strncmp(codec_name,
"Sorenson H263", 13))
2166 int bits_per_sample,
flags;
2187 (compatible_brands && strstr(compatible_brands->
value,
"qt ")) ||
2268 if (bits_per_sample && (bits_per_sample >> 3) * (uint64_t)st->
codecpar->
channels <= INT_MAX) {
2293 y = (ycbcr >> 16) & 0xFF;
2294 cr = (ycbcr >> 8) & 0xFF;
2301 return (
r << 16) | (
g << 8) |
b;
2306 char buf[256] = {0};
2314 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
2318 for (
i = 0;
i < 16;
i++) {
2322 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba,
i != 15 ?
", " :
"");
2325 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
2356 #if FF_API_LAVF_AVCTX
2366 if (str_size > 0 &&
size >= (
int)str_size + 30 &&
2368 char *reel_name =
av_malloc(str_size + 1);
2372 reel_name[str_size] = 0;
2395 #if CONFIG_DV_DEMUXER
2469 int codec_tag,
int format,
2482 (
c->fc->video_codec_id ? video_codec_id !=
c->fc->video_codec_id
2483 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2500 int pseudo_stream_id;
2503 st =
c->fc->streams[
c->fc->nb_streams-1];
2506 for (pseudo_stream_id = 0;
2508 pseudo_stream_id++) {
2511 int ret, dref_id = 1;
2521 }
else if (
size <= 7) {
2523 "invalid size %"PRId64
" in stsd\n",
size);
2540 "size=%"PRId64
" 4CC=%s codec_type=%d\n",
size,
2566 }
else if (
a.size > 0)
2595 if (
c->fc->nb_streams < 1)
2597 st =
c->fc->streams[
c->fc->nb_streams - 1];
2605 if (entries <= 0 || entries > atom.
size / 8 || entries > 1024) {
2612 "Duplicate stsd found in this track.\n");
2658 unsigned int i, entries;
2660 if (
c->fc->nb_streams < 1)
2662 st =
c->fc->streams[
c->fc->nb_streams-1];
2669 if ((uint64_t)entries * 12 + 4 > atom.
size)
2694 int64_t first_min =
i + 1;
2754 unsigned i, entries;
2756 if (
c->fc->nb_streams < 1)
2758 st =
c->fc->streams[
c->fc->nb_streams-1];
2790 unsigned int i, entries;
2792 if (
c->fc->nb_streams < 1)
2794 st =
c->fc->streams[
c->fc->nb_streams-1];
2812 if (entries >= UINT_MAX /
sizeof(
int))
2838 unsigned int i, entries, sample_size, field_size, num_bytes;
2843 if (
c->fc->nb_streams < 1)
2845 st =
c->fc->streams[
c->fc->nb_streams-1];
2851 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2870 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2877 if (entries >= (UINT_MAX - 4) / field_size)
2887 num_bytes = (entries*field_size+4)>>3;
2931 unsigned int i, entries, alloc_size = 0;
2933 int64_t total_sample_count = 0;
2935 if (
c->fc->nb_streams < 1)
2937 st =
c->fc->streams[
c->fc->nb_streams-1];
2945 c->fc->nb_streams-1, entries);
2951 if (entries >= INT_MAX /
sizeof(*sc->
stts_data))
2955 int sample_duration;
2956 unsigned int sample_count;
2957 unsigned int min_entries =
FFMIN(
FFMAX(
i + 1, 1024 * 1024), entries);
2975 sample_count, sample_duration);
2977 duration+=(int64_t)sample_duration*(uint64_t)sample_count;
2978 total_sample_count+=sample_count;
2984 duration <= INT64_MAX - sc->duration_for_fps &&
2985 total_sample_count <= INT_MAX - sc->nb_frames_for_fps) {
3008 if (
c->fc->nb_streams < 1)
3010 st =
c->fc->streams[
c->fc->nb_streams - 1];
3015 entries = atom.
size - 4;
3018 c->fc->nb_streams - 1, entries);
3051 unsigned int i, entries, ctts_count = 0;
3053 if (
c->fc->nb_streams < 1)
3055 st =
c->fc->streams[
c->fc->nb_streams-1];
3066 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
3079 "ignoring CTTS entry with count=%d duration=%d\n",
3117 unsigned int i, entries;
3119 uint32_t grouping_type;
3121 if (
c->fc->nb_streams < 1)
3123 st =
c->fc->streams[
c->fc->nb_streams-1];
3129 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
3165 unsigned int edit_list_index,
3166 int64_t *edit_list_media_time,
3167 int64_t *edit_list_duration,
3168 int64_t global_timescale)
3173 *edit_list_media_time = msc->
elst_data[edit_list_index].
time;
3177 if (global_timescale == 0) {
3210 int64_t timestamp_pts,
3213 int64_t* ctts_index,
3214 int64_t* ctts_sample)
3220 int64_t index_ctts_count;
3248 if (ctts_data && *
index >= 0) {
3254 for (index_ctts_count = 0; index_ctts_count < *
index; index_ctts_count++) {
3255 if (*ctts_index < ctts_count) {
3257 if (ctts_data[*ctts_index].
count == *ctts_sample) {
3264 while (*
index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < ctts_count) {
3268 if ((e_old[*
index].timestamp + ctts_data[*ctts_index].
duration) <= timestamp_pts &&
3274 if (*ctts_sample == 0) {
3276 if (*ctts_index >= 0)
3277 *ctts_sample = ctts_data[*ctts_index].
count - 1;
3287 return *
index >= 0 ? 0 : -1;
3310 const size_t requested_size =
3327 ie= &entries[
index];
3342 int64_t* frame_duration_buffer,
3343 int frame_duration_buffer_size) {
3345 av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
3346 for (
i = 0;
i < frame_duration_buffer_size;
i++) {
3347 end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 -
i];
3360 const size_t min_size_needed = (*ctts_count + 1) *
sizeof(
MOVStts);
3361 const size_t requested_size =
3362 min_size_needed > *allocated_size ?
3363 FFMAX(min_size_needed, 2 * (*allocated_size)) :
3366 if ((
unsigned)(*ctts_count) >= UINT_MAX /
sizeof(
MOVStts) - 1)
3369 ctts_buf_new =
av_fast_realloc(*ctts_data, allocated_size, requested_size);
3374 *ctts_data = ctts_buf_new;
3379 *ctts_count = (*ctts_count) + 1;
3383 #define MAX_REORDER_DELAY 16
3389 int ctts_sample = 0;
3392 int j,
r, num_swaps;
3395 pts_buf[j] = INT64_MIN;
3403 buf_start = (buf_start + 1);
3416 while (j != buf_start) {
3419 if (pts_buf[j] < pts_buf[
r]) {
3420 FFSWAP(int64_t, pts_buf[j], pts_buf[
r]);
3478 if (range_size > current_sample) {
3482 current_sample -= range_size;
3500 int64_t ctts_index_old = 0;
3501 int64_t ctts_sample_old = 0;
3503 int64_t edit_list_media_time = 0;
3504 int64_t edit_list_duration = 0;
3505 int64_t frame_duration = 0;
3506 int64_t edit_list_dts_counter = 0;
3507 int64_t edit_list_dts_entry_end = 0;
3508 int64_t edit_list_start_ctts_sample = 0;
3510 int64_t curr_ctts = 0;
3511 int64_t empty_edits_sum_duration = 0;
3512 int64_t edit_list_index = 0;
3515 int64_t start_dts = 0;
3516 int64_t edit_list_start_encountered = 0;
3517 int64_t search_timestamp = 0;
3518 int64_t* frame_duration_buffer =
NULL;
3519 int num_discarded_begin = 0;
3520 int first_non_zero_audio_edit = -1;
3521 int packet_skip_samples = 0;
3524 int found_keyframe_after_edit = 0;
3525 int found_non_empty_edit = 0;
3558 edit_list_dts_entry_end -= msc->
dts_shift;
3562 start_dts = edit_list_dts_entry_end;
3566 av_log(mov->
fc,
AV_LOG_DEBUG,
"Processing st: %d, edit list %"PRId64
" - media time: %"PRId64
", duration: %"PRId64
"\n",
3567 st->
index, edit_list_index, edit_list_media_time, edit_list_duration);
3569 edit_list_dts_counter = edit_list_dts_entry_end;
3570 edit_list_dts_entry_end += edit_list_duration;
3571 num_discarded_begin = 0;
3572 if (!found_non_empty_edit && edit_list_media_time == -1) {
3573 empty_edits_sum_duration += edit_list_duration;
3576 found_non_empty_edit = 1;
3581 if (first_non_zero_audio_edit < 0) {
3582 first_non_zero_audio_edit = 1;
3584 first_non_zero_audio_edit = 0;
3587 if (first_non_zero_audio_edit > 0)
3595 search_timestamp = edit_list_media_time;
3604 &
index, &ctts_index_old, &ctts_sample_old) < 0) {
3606 "st: %d edit list: %"PRId64
" Missing key frame while searching for timestamp: %"PRId64
"\n",
3607 st->
index, edit_list_index, search_timestamp);
3609 &
index, &ctts_index_old, &ctts_sample_old) < 0) {
3611 "st: %d edit list %"PRId64
" Cannot find an index entry before timestamp: %"PRId64
".\n",
3612 st->
index, edit_list_index, search_timestamp);
3615 ctts_sample_old = 0;
3618 current = e_old +
index;
3619 edit_list_start_ctts_sample = ctts_sample_old;
3622 edit_list_start_encountered = 0;
3623 found_keyframe_after_edit = 0;
3624 for (; current < e_old_end; current++,
index++) {
3626 frame_duration = (current + 1 < e_old_end) ?
3627 ((current + 1)->timestamp - current->
timestamp) : edit_list_duration;
3635 if (ctts_data_old && ctts_index_old < ctts_count_old) {
3636 curr_ctts = ctts_data_old[ctts_index_old].
duration;
3637 av_log(mov->
fc,
AV_LOG_DEBUG,
"stts: %"PRId64
" ctts: %"PRId64
", ctts_index: %"PRId64
", ctts_count: %"PRId64
"\n",
3638 curr_cts, curr_ctts, ctts_index_old, ctts_count_old);
3639 curr_cts += curr_ctts;
3641 if (ctts_sample_old == ctts_data_old[ctts_index_old].
count) {
3644 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3645 ctts_data_old[ctts_index_old].
duration) == -1) {
3648 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3649 ctts_data_old[ctts_index_old].
duration);
3653 ctts_sample_old = 0;
3654 edit_list_start_ctts_sample = 0;
3658 if (curr_cts < edit_list_media_time || curr_cts >= (edit_list_duration + edit_list_media_time)) {
3660 curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time &&
3661 first_non_zero_audio_edit > 0) {
3662 packet_skip_samples = edit_list_media_time - curr_cts;
3666 edit_list_dts_counter -= packet_skip_samples;
3667 if (edit_list_start_encountered == 0) {
3668 edit_list_start_encountered = 1;
3671 if (frame_duration_buffer) {
3673 frame_duration_buffer, num_discarded_begin);
3678 av_log(mov->
fc,
AV_LOG_DEBUG,
"skip %d audio samples from curr_cts: %"PRId64
"\n", packet_skip_samples, curr_cts);
3683 if (edit_list_start_encountered == 0) {
3684 num_discarded_begin++;
3685 frame_duration_buffer =
av_realloc(frame_duration_buffer,
3686 num_discarded_begin *
sizeof(int64_t));
3687 if (!frame_duration_buffer) {
3691 frame_duration_buffer[num_discarded_begin - 1] = frame_duration;
3706 if (edit_list_start_encountered == 0) {
3707 edit_list_start_encountered = 1;
3710 if (frame_duration_buffer) {
3712 frame_duration_buffer, num_discarded_begin);
3725 if (current_index_range < msc->index_ranges ||
index != current_index_range->
end) {
3726 current_index_range++;
3729 current_index_range->
end =
index + 1;
3732 if (edit_list_start_encountered > 0) {
3733 edit_list_dts_counter = edit_list_dts_counter + frame_duration;
3737 if ((curr_cts + frame_duration >= (edit_list_duration + edit_list_media_time)) &&
3739 if (ctts_data_old) {
3744 found_keyframe_after_edit = 1;
3747 if (ctts_sample_old != 0) {
3750 ctts_sample_old - edit_list_start_ctts_sample,
3751 ctts_data_old[ctts_index_old].
duration) == -1) {
3753 ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample,
3754 ctts_data_old[ctts_index_old].
duration);
3790 current_index_range++;
3791 current_index_range->
start = 0;
3792 current_index_range->
end = 0;
3799 int64_t current_offset;
3800 int64_t current_dts = 0;
3801 unsigned int stts_index = 0;
3802 unsigned int stsc_index = 0;
3803 unsigned int stss_index = 0;
3804 unsigned int stps_index = 0;
3806 uint64_t stream_size = 0;
3808 unsigned int ctts_count_old = sc->
ctts_count;
3811 int i, edit_start_index = 0, multiple_edits = 0;
3812 int64_t empty_duration = 0;
3817 if (
i == 0 && e->
time == -1) {
3821 edit_start_index = 1;
3822 }
else if (
i == edit_start_index && e->
time >= 0) {
3831 "Use -advanced_editlist to correctly decode otherwise "
3832 "a/v desync might occur\n");
3852 unsigned int current_sample = 0;
3853 unsigned int stts_sample = 0;
3854 unsigned int sample_size;
3856 unsigned int rap_group_index = 0;
3857 unsigned int rap_group_sample = 0;
3858 int64_t last_dts = 0;
3859 int64_t dts_correction = 0;
3864 last_dts = current_dts;
3878 if (ctts_data_old) {
3893 for (
i = 0;
i < ctts_count_old &&
3895 for (j = 0; j < ctts_data_old[
i].
count &&
3936 if (rap_group_present && rap_group_index < sc->rap_group_count) {
3939 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
3940 rap_group_sample = 0;
3946 && !rap_group_present
3955 if (sample_size > 0x3FFFFFFF) {
3960 e->
pos = current_offset;
3962 e->
size = sample_size;
3965 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %u, offset %"PRIx64
", dts %"PRId64
", "
3966 "size %u, distance %u, keyframe %d\n", st->
index, current_sample,
3967 current_offset, current_dts, sample_size,
distance, keyframe);
3972 current_offset += sample_size;
3973 stream_size += sample_size;
3979 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
3986 if (!dts_correction || current_dts + dts_correction > last_dts) {
3987 current_dts += dts_correction;
3991 dts_correction += current_dts - last_dts - 1;
3992 current_dts = last_dts + 1;
3994 last_dts = current_dts;
4007 unsigned chunk_samples, total = 0;
4014 unsigned count, chunk_count;
4027 count = (chunk_samples+samples-1) / samples;
4029 count = (chunk_samples+1023) / 1024;
4036 total += chunk_count *
count;
4058 while (chunk_samples > 0) {
4060 unsigned size, samples;
4064 "Zero bytes per frame, but %d samples per frame",
4078 samples =
FFMIN(1024, chunk_samples);
4087 if (
size > 0x3FFFFFFF) {
4092 e->
pos = current_offset;
4098 "size %u, duration %u\n", st->
index,
i, current_offset, current_dts,
4101 current_offset +=
size;
4102 current_dts += samples;
4103 chunk_samples -= samples;
4134 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0,
src);
4135 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0,
ref);
4137 if (strlen(
src) == 0) {
4139 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
4140 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
4141 strlen(src_host) + 1 >=
sizeof(src_host) ||
4142 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
4144 }
else if (strcmp(src_proto, ref_proto) ||
4145 strcmp(src_auth, ref_auth) ||
4146 strcmp(src_host, ref_host) ||
4147 src_port != ref_port) {
4157 if (
ref->nlvl_to > 0 &&
ref->nlvl_from > 0) {
4158 char filename[1025];
4159 const char *src_path;
4163 src_path = strrchr(
src,
'/');
4170 for (
i = 0, l = strlen(
ref->path) - 1; l >= 0; l--)
4171 if (
ref->path[l] ==
'/') {
4172 if (
i ==
ref->nlvl_to - 1)
4179 if (
i ==
ref->nlvl_to - 1 && src_path -
src <
sizeof(filename)) {
4180 memcpy(filename,
src, src_path -
src);
4181 filename[src_path -
src] = 0;
4183 for (
i = 1;
i <
ref->nlvl_from;
i++)
4184 av_strlcat(filename,
"../",
sizeof(filename));
4187 if (!
c->use_absolute_path) {
4192 "Reference with mismatching origin, %s not tried for security reasons, "
4193 "set demuxer option use_absolute_path to allow it anyway\n",
4198 if (strstr(
ref->path + l + 1,
"..") ||
4199 strstr(
ref->path + l + 1,
":") ||
4200 (
ref->nlvl_from > 1 && same_origin < 0) ||
4201 (filename[0] ==
'/' && src_path ==
src))
4205 if (strlen(filename) + 1 ==
sizeof(filename))
4210 }
else if (
c->use_absolute_path) {
4212 "this is a possible security issue\n");
4217 "Absolute path %s not tried for security reasons, "
4218 "set demuxer option use_absolute_path to allow absolute paths\n",
4242 if (!st)
return AVERROR(ENOMEM);
4245 if (!sc)
return AVERROR(ENOMEM);
4250 c->trak_index = st->
index;
4286 if (
c->enable_drefs) {
4289 "stream %d, error opening alias: path='%s', dir='%s', "
4290 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
4295 "Skipped opening external track: "
4296 "stream %d, alias: path='%s', dir='%s', "
4297 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d."
4298 "Set enable_drefs to allow this.\n",
4315 #if FF_API_R_FRAME_RATE
4331 #if CONFIG_H261_DECODER
4334 #if CONFIG_H263_DECODER
4337 #if CONFIG_MPEG4_DECODER
4367 c->itunes_metadata = 1;
4369 c->itunes_metadata = 0;
4383 if (
count > UINT_MAX /
sizeof(*
c->meta_keys) - 1) {
4385 "The 'keys' atom with the invalid key count: %"PRIu32
"\n",
count);
4389 c->meta_keys_count =
count + 1;
4390 c->meta_keys =
av_mallocz(
c->meta_keys_count *
sizeof(*
c->meta_keys));
4399 "The key# %"PRIu32
" in meta has invalid size:"
4400 "%"PRIu32
"\n",
i, key_size);
4408 if (!
c->meta_keys[
i])
4425 if (
c->fc->nb_streams < 1)
4427 st =
c->fc->streams[
c->fc->nb_streams-1];
4430 for (
i = 0;
i < 3;
i++) {
4441 if (len < 12 || len - 12 > end -
avio_tell(pb))
4445 if (
tag ==
MKTAG(
'm',
'e',
'a',
'n'))
4447 else if (
tag ==
MKTAG(
'n',
'a',
'm',
'e'))
4449 else if (
tag ==
MKTAG(
'd',
'a',
't',
'a') &&
len > 4) {
4473 if (strcmp(
key,
"iTunSMPB") == 0) {
4474 int priming, remainder, samples;
4475 if(sscanf(
val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
4476 if(priming>0 && priming<16384)
4480 if (strcmp(
key,
"cdec") != 0) {
4487 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
4499 while (atom.
size > 8) {
4505 if (
tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
4515 #define IS_MATRIX_IDENT(matrix) \
4516 ( (matrix)[0][0] == (1 << 16) && \
4517 (matrix)[1][1] == (1 << 16) && \
4518 (matrix)[2][2] == (1 << 30) && \
4519 !(matrix)[0][1] && !(matrix)[0][2] && \
4520 !(matrix)[1][0] && !(matrix)[1][2] && \
4521 !(matrix)[2][0] && !(matrix)[2][1])
4528 int display_matrix[3][3];
4529 int res_display_matrix[3][3] = { { 0 } };
4535 if (
c->fc->nb_streams < 1)
4537 st =
c->fc->streams[
c->fc->nb_streams-1];
4573 for (
i = 0;
i < 3;
i++) {
4585 for (
i = 0;
i < 3;
i++) {
4586 const int sh[3] = { 16, 16, 30 };
4587 for (j = 0; j < 3; j++) {
4588 for (e = 0; e < 3; e++) {
4589 res_display_matrix[
i][j] +=
4590 ((int64_t) display_matrix[
i][e] *
4591 c->movie_display_matrix[e][j]) >> sh[e];
4605 for (
i = 0;
i < 3;
i++)
4606 for (j = 0; j < 3; j++)
4612 char rotate_buf[64];
4625 double disp_transform[2];
4627 for (
i = 0;
i < 2;
i++)
4631 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
4632 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
4633 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
4635 disp_transform[0] / disp_transform[1],
4654 for (
i = 0;
i <
c->trex_count;
i++)
4655 if (
c->trex_data[
i].track_id == track_id) {
4656 trex = &
c->trex_data[
i];
4663 c->fragment.found_tfhd = 1;
4681 if (frag_stream_info)
4692 num = atom.
size / 4;
4697 c->chapter_tracks = new_tracks;
4698 c->nb_chapter_tracks = num;
4711 if ((uint64_t)
c->trex_count+1 >= UINT_MAX /
sizeof(*
c->trex_data))
4714 sizeof(*
c->trex_data))) < 0) {
4721 trex = &
c->trex_data[
c->trex_count++];
4739 int64_t base_media_decode_time;
4741 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
4742 if (
c->fc->streams[
i]->id == frag->
track_id) {
4743 st =
c->fc->streams[
i];
4763 if (frag_stream_info)
4764 frag_stream_info->
tfdt_dts = base_media_decode_time;
4778 int data_offset = 0;
4779 unsigned entries, first_sample_flags = frag->
flags;
4782 int next_frag_index = -1, index_entry_pos;
4783 size_t requested_size;
4784 size_t old_ctts_allocated_size;
4793 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
4794 if (
c->fc->streams[
i]->id == frag->
track_id) {
4795 st =
c->fc->streams[
i];
4814 for (
i =
c->frag_index.current + 1; i < c->frag_index.nb_items;
i++) {
4816 if (frag_stream_info && frag_stream_info->
index_entry >= 0) {
4817 next_frag_index =
i;
4822 av_assert0(index_entry_pos <= st->nb_index_entries);
4835 if (frag_stream_info) {
4842 ", using it for pts\n",
pts);
4847 ", using it for dts\n",
pts);
4853 ", using it for pts\n",
pts);
4857 ", using it for dts\n", dts);
4861 ", using it for dts\n", dts);
4866 ", using it for dts\n", dts);
4902 if (index_entry_pos < st->nb_index_entries) {
4908 memmove(sc->
ctts_data + index_entry_pos + entries,
4911 if (index_entry_pos < sc->current_sample) {
4920 if (frag_stream_info)
4923 if (index_entry_pos > 0)
4927 unsigned sample_size = frag->
size;
4928 int sample_flags =
i ? frag->
flags : first_sample_flags;
4929 unsigned sample_duration = frag->
duration;
4930 unsigned ctts_duration = 0;
4932 int index_entry_flags = 0;
4943 dts -= ctts_duration;
4948 "pts %"PRId64
" calculated dts %"PRId64
4949 " sc->dts_shift %d ctts.duration %d"
4950 " sc->time_offset %"PRId64
4951 " flags & MOV_TRUN_SAMPLE_CTS %d\n",
4970 if (prev_dts >= dts)
4983 av_log(
c->fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
4984 "size %u, distance %d, keyframe %d\n", st->
index,
4987 dts += sample_duration;
4991 if (sample_duration <= INT64_MAX - sc->duration_for_fps &&
4998 if (frag_stream_info)
5003 int gap = entries -
i;
5008 memmove(sc->
ctts_data + index_entry_pos,
5015 if (index_entry_pos < sc->current_sample) {
5025 if (index_entry_pos > 0)
5028 if (prev_dts < st->index_entries[
i].timestamp)
5059 unsigned i, j, track_id, item_count;
5074 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
5075 if (
c->fc->streams[
i]->id == track_id) {
5076 st =
c->fc->streams[
i];
5089 if (timescale.
den <= 0) {
5104 offset += (uint64_t)offadd;
5110 for (
i = 0;
i < item_count;
i++) {
5115 if (
size & 0x80000000) {
5124 if (frag_stream_info)
5125 frag_stream_info->
sidx_pts = timestamp;
5138 is_complete =
offset == stream_size;
5142 if (!
c->have_read_mfra_size) {
5143 if ((ret =
avio_seek(pb, stream_size - 4, SEEK_SET)) < 0)
5146 c->have_read_mfra_size = 1;
5147 if ((ret =
avio_seek(pb, original_pos, SEEK_SET)) < 0)
5150 if (
offset +
c->mfra_size == stream_size)
5157 for (
i = 0;
i <
c->frag_index.nb_items;
i++) {
5163 ref_st =
c->fc->streams[j];
5169 if (ref_st)
for (
i = 0;
i <
c->fc->nb_streams;
i++) {
5170 st =
c->fc->streams[
i];
5177 c->frag_index.complete = 1;
5198 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
5212 long cmov_len, moov_len;
5226 cmov_len = atom.
size - 6 * 4;
5238 goto free_and_return;
5241 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
5242 goto free_and_return;
5244 goto free_and_return;
5247 atom.
size = moov_len;
5264 int64_t elst_entry_size;
5266 if (
c->fc->nb_streams < 1 ||
c->ignore_editlist)
5268 sc =
c->fc->streams[
c->fc->nb_streams-1]->priv_data;
5275 elst_entry_size =
version == 1 ? 20 : 12;
5276 if (atom.
size != edit_count * elst_entry_size) {
5278 av_log(
c->fc,
AV_LOG_ERROR,
"Invalid edit list entry_count: %d for elst atom of size: %"PRId64
" bytes.\n",
5279 edit_count, atom.
size + 8);
5282 edit_count = atom.
size / elst_entry_size;
5283 if (edit_count * elst_entry_size != atom.
size) {
5317 if (e->
time < 0 && e->
time != -1 &&
5319 av_log(
c->fc,
AV_LOG_ERROR,
"Track %d, edit %d: Invalid edit list media time=%"PRId64
"\n",
5320 c->fc->nb_streams-1,
i, e->
time);
5333 if (
c->fc->nb_streams < 1)
5335 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5345 if (
c->fc->nb_streams < 1)
5347 st =
c->fc->streams[
c->fc->nb_streams - 1];
5349 if (atom.
size < 4) {
5373 if (
c->fc->nb_streams < 1)
5375 st =
c->fc->streams[
c->fc->nb_streams - 1];
5377 if (atom.
size < 5) {
5417 if (
c->fc->nb_streams < 1)
5420 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5422 if (atom.
size < 5) {
5438 for (
i = 0;
i < 3;
i++) {
5457 const int mapping[3] = {1, 2, 0};
5458 const int chroma_den = 50000;
5459 const int luma_den = 10000;
5462 if (
c->fc->nb_streams < 1)
5465 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5467 if (atom.
size < 24) {
5476 for (
i = 0;
i < 3;
i++) {
5477 const int j = mapping[
i];
5498 if (
c->fc->nb_streams < 1)
5501 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5503 if (atom.
size < 5) {
5529 if (
c->fc->nb_streams < 1)
5532 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5534 if (atom.
size < 4) {
5556 if (
c->fc->nb_streams < 1)
5559 st =
c->fc->streams[
c->fc->nb_streams - 1];
5562 if (atom.
size < 5) {
5602 uint32_t l = 0, t = 0,
r = 0,
b = 0;
5603 uint32_t
tag, padding = 0;
5606 if (
c->fc->nb_streams < 1)
5609 st =
c->fc->streams[
c->fc->nb_streams - 1];
5612 if (atom.
size < 8) {
5618 if (size <= 12 || size > atom.
size)
5622 if (
tag !=
MKTAG(
's',
'v',
'h',
'd')) {
5640 if (
tag !=
MKTAG(
'p',
'r',
'o',
'j')) {
5650 if (
tag !=
MKTAG(
'p',
'r',
'h',
'd')) {
5680 case MKTAG(
'c',
'b',
'm',
'p'):
5684 "Unsupported cubemap layout %d\n",
layout);
5690 case MKTAG(
'e',
'q',
'u',
'i'):
5696 if (
b >= UINT_MAX - t ||
r >= UINT_MAX - l) {
5698 "Invalid bounding rectangle coordinates "
5699 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n", l, t,
r,
b);
5703 if (l || t ||
r ||
b)
5802 static const uint8_t uuid_isml_manifest[] = {
5803 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
5804 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
5806 static const uint8_t uuid_xmp[] = {
5807 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
5808 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
5810 static const uint8_t uuid_spherical[] = {
5811 0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
5812 0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
5815 if (atom.
size <
sizeof(uuid) || atom.
size >=
FFMIN(INT_MAX, SIZE_MAX))
5818 if (
c->fc->nb_streams < 1)
5820 st =
c->fc->streams[
c->fc->nb_streams - 1];
5826 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
5829 size_t len = atom.
size -
sizeof(uuid);
5848 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
5849 ptr +=
sizeof(
"systemBitrate=\"") - 1;
5850 c->bitrates_count++;
5851 c->bitrates =
av_realloc_f(
c->bitrates,
c->bitrates_count,
sizeof(*
c->bitrates));
5853 c->bitrates_count = 0;
5858 ret = strtol(ptr, &endptr, 10);
5859 if (ret < 0 || errno || *endptr !=
'"') {
5860 c->bitrates[
c->bitrates_count - 1] = 0;
5862 c->bitrates[
c->bitrates_count - 1] = ret;
5867 }
else if (!memcmp(uuid, uuid_xmp,
sizeof(uuid))) {
5869 size_t len = atom.
size -
sizeof(uuid);
5870 if (
c->export_xmp) {
5889 }
else if (!memcmp(uuid, uuid_spherical,
sizeof(uuid))) {
5890 size_t len = atom.
size -
sizeof(uuid);
5915 && !memcmp(content,
"Anevia\x1A\x1A", 8)
5930 if (
c->fc->nb_streams < 1)
5932 st =
c->fc->streams[
c->fc->nb_streams - 1];
5937 case MKTAG(
'e',
'n',
'c',
'v'):
5938 case MKTAG(
'e',
'n',
'c',
'a'):
5943 "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
5955 "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
5977 if (frag_stream_info) {
5978 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
5979 if (
c->fc->streams[
i]->id == frag_stream_info->
id) {
5980 st =
c->fc->streams[
i];
5984 if (
i ==
c->fc->nb_streams)
5990 if (!(*sc)->cenc.default_encrypted_sample)
6001 if (
c->fc->nb_streams < 1)
6003 st =
c->fc->streams[
c->fc->nb_streams - 1];
6006 if (!(*sc)->cenc.encryption_index) {
6008 if (!(*sc)->cenc.default_encrypted_sample)
6011 if (!(*sc)->cenc.encryption_index)
6015 *encryption_index = (*sc)->cenc.encryption_index;
6023 unsigned int subsample_count;
6044 if (use_subsamples) {
6046 av_free((*sample)->subsamples);
6047 (*sample)->subsamples =
av_mallocz_array(subsample_count,
sizeof(*subsamples));
6048 if (!(*sample)->subsamples) {
6055 (*sample)->subsamples[
i].bytes_of_clear_data =
avio_rb16(pb);
6056 (*sample)->subsamples[
i].bytes_of_protected_data =
avio_rb32(pb);
6065 (*sample)->subsample_count = subsample_count;
6076 int use_subsamples, ret;
6077 unsigned int sample_count,
i, alloc_size = 0;
6093 if (sample_count >= INT_MAX /
sizeof(*encrypted_samples))
6096 for (
i = 0;
i < sample_count;
i++) {
6097 unsigned int min_samples =
FFMIN(
FFMAX(
i + 1, 1024 * 1024), sample_count);
6099 min_samples *
sizeof(*encrypted_samples));
6100 if (encrypted_samples) {
6129 size_t sample_count, sample_info_size,
i;
6131 unsigned int alloc_size = 0;
6140 if (sample_count >= INT_MAX /
sizeof(*encrypted_samples))
6146 av_log(
c->fc,
AV_LOG_INFO,
"Failed to seek for auxiliary info, will only parse senc atoms for encryption info\n");
6151 unsigned int min_samples =
FFMIN(
FFMAX(
i + 1, 1024 * 1024), sample_count);
6153 min_samples *
sizeof(*encrypted_samples));
6154 if (!encrypted_samples) {
6179 for (;
i > 0;
i--) {
6194 const unsigned int block_size = 1024 * 1024;
6196 unsigned int alloc_size = 0,
offset = 0;
6198 unsigned int new_size =
6199 alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + block_size;
6224 unsigned int sample_count, aux_info_type, aux_info_param;
6250 if (aux_info_param != 0) {
6256 if ((aux_info_type ==
MKBETAG(
'c',
'e',
'n',
'c') ||
6257 aux_info_type ==
MKBETAG(
'c',
'e',
'n',
's') ||
6258 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
'1') ||
6259 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
's')) &&
6260 aux_info_param == 0) {
6293 uint64_t *auxiliary_offsets;
6297 unsigned int version, entry_count, aux_info_type, aux_info_param;
6298 unsigned int alloc_size = 0;
6324 if (aux_info_param != 0) {
6330 if ((aux_info_type ==
MKBETAG(
'c',
'e',
'n',
'c') ||
6331 aux_info_type ==
MKBETAG(
'c',
'e',
'n',
's') ||
6332 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
'1') ||
6333 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
's')) &&
6334 aux_info_param == 0) {
6347 if (entry_count >= INT_MAX /
sizeof(*auxiliary_offsets))
6351 unsigned int min_offsets =
FFMIN(
FFMAX(
i + 1, 1024), entry_count);
6354 min_offsets *
sizeof(*auxiliary_offsets));
6355 if (!auxiliary_offsets) {
6366 if (
c->frag_index.current >= 0) {
6391 uint8_t *side_data, *extra_data, *old_side_data;
6392 size_t side_data_size;
6395 unsigned int version, kid_count, extra_data_size, alloc_size = 0;
6397 if (
c->fc->nb_streams < 1)
6399 st =
c->fc->streams[
c->fc->nb_streams-1];
6416 if (kid_count >= INT_MAX /
sizeof(*key_ids)) {
6421 for (
unsigned int i = 0;
i < kid_count && !pb->
eof_reached;
i++) {
6422 unsigned int min_kid_count =
FFMIN(
FFMAX(
i + 1, 1024), kid_count);
6424 min_kid_count *
sizeof(*key_ids));
6457 info->
data = extra_data;
6462 if (old_side_data) {
6464 if (old_init_info) {
6472 info = old_init_info;
6486 side_data, side_data_size);
6500 if (
c->fc->nb_streams < 1)
6502 st =
c->fc->streams[
c->fc->nb_streams-1];
6506 av_log(
c->fc,
AV_LOG_ERROR,
"schm boxes are only supported in first sample descriptor\n");
6530 unsigned int version, pattern, is_protected, iv_size;
6532 if (
c->fc->nb_streams < 1)
6534 st =
c->fc->streams[
c->fc->nb_streams-1];
6583 if (iv_size != 8 && iv_size != 16) {
6603 if (
c->fc->nb_streams < 1)
6605 st =
c->fc->streams[
c->fc->nb_streams-1];
6607 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 42)
6658 if (!
sample->subsample_count) {
6664 for (
i = 0;
i <
sample->subsample_count;
i++) {
6665 if (
sample->subsamples[
i].bytes_of_clear_data +
sample->subsamples[
i].bytes_of_protected_data >
size) {
6671 input +=
sample->subsamples[
i].bytes_of_clear_data;
6672 size -=
sample->subsamples[
i].bytes_of_clear_data;
6676 input +=
sample->subsamples[
i].bytes_of_protected_data;
6677 size -=
sample->subsamples[
i].bytes_of_protected_data;
6693 int encrypted_index, ret;
6696 encrypted_index = current_index;
6697 encryption_index =
NULL;
6698 if (frag_stream_info) {
6702 encrypted_index = current_index - frag_stream_info->
index_entry;
6712 if (encryption_index) {
6727 }
else if (encrypted_index >= 0 && encrypted_index < encryption_index->nb_encrypted_samples) {
6760 if (
c->fc->nb_streams < 1)
6762 st =
c->fc->streams[
c->fc->nb_streams-1];
6764 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 11)
6804 unsigned format_info;
6805 int channel_assignment, channel_assignment1, channel_assignment2;
6808 if (
c->fc->nb_streams < 1)
6810 st =
c->fc->streams[
c->fc->nb_streams-1];
6817 ratebits = (format_info >> 28) & 0xF;
6818 channel_assignment1 = (format_info >> 15) & 0x1F;
6819 channel_assignment2 = format_info & 0x1FFF;
6820 if (channel_assignment2)
6821 channel_assignment = channel_assignment2;
6823 channel_assignment = channel_assignment1;
6841 if (
c->fc->nb_streams < 1)
6843 st =
c->fc->streams[
c->fc->nb_streams-1];
6845 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 4)
6857 dovi->
dv_level = (buf >> 3) & 0x3f;
6861 if (atom.
size >= 24) {
6878 "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
6992 int64_t total_size = 0;
6996 if (
c->atom_depth > 10) {
7003 atom.
size = INT64_MAX;
7008 if (atom.
size >= 8) {
7011 if (((
a.type ==
MKTAG(
'f',
'r',
'e',
'e') &&
c->moov_retry) ||
7012 a.type ==
MKTAG(
'h',
'o',
'o',
'v')) &&
7024 a.type =
MKTAG(
'm',
'o',
'o',
'v');
7027 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
7029 if (
a.type ==
MKTAG(
't',
'r',
'a',
'k') ||
7030 a.type ==
MKTAG(
'm',
'd',
'a',
't')) {
7038 if (
a.size == 1 && total_size + 8 <= atom.
size) {
7046 a.size = atom.
size - total_size + 8;
7066 if (!
parse &&
c->found_hdlr_mdta &&
7068 a.type ==
MKTAG(
'k',
'e',
'y',
's') &&
7069 c->meta_keys_count == 0) {
7083 if (
c->found_moov &&
c->found_mdat &&
a.size <= INT64_MAX - start_pos &&
7087 c->next_root_atom = start_pos +
a.size;
7094 else if (left < 0) {
7096 "overread end of atom '%s' by %"PRId64
" bytes\n",
7102 total_size +=
a.size;
7105 if (total_size < atom.
size && atom.
size < 0x7ffff)
7117 int moov_offset = -1;
7131 }
else if (
size == 0) {
7134 if (
size < minsize) {
7141 case MKTAG(
'm',
'o',
'o',
'v'):
7142 moov_offset =
offset + 4;
7143 case MKTAG(
'm',
'd',
'a',
't'):
7144 case MKTAG(
'p',
'n',
'o',
't'):
7145 case MKTAG(
'u',
'd',
't',
'a'):
7146 case MKTAG(
'f',
't',
'y',
'p'):
7147 if (
tag ==
MKTAG(
'f',
't',
'y',
'p') &&
7151 score =
FFMAX(score, 5);
7157 case MKTAG(
'e',
'd',
'i',
'w'):
7158 case MKTAG(
'w',
'i',
'd',
'e'):
7159 case MKTAG(
'f',
'r',
'e',
'e'):
7160 case MKTAG(
'j',
'u',
'n',
'k'):
7161 case MKTAG(
'p',
'i',
'c',
't'):
7164 case MKTAG(0x82,0x82,0x7f,0x7d):
7165 case MKTAG(
's',
'k',
'i',
'p'):
7166 case MKTAG(
'u',
'u',
'i',
'd'):
7167 case MKTAG(
'p',
'r',
'f',
'l'):
7215 for (
i = 0;
i <
s->nb_streams;
i++)
7216 if (
s->streams[
i]->id == chapter_track) {
7255 if (end < sample->timestamp) {
7269 title_len = 2*
len + 1;
7282 else if (ch == 0xfffe)
7286 if (
len == 1 ||
len == 2)
7321 int hh, mm,
ss, ff, drop;
7334 hh, mm,
ss, drop ?
';' :
':', ff);
7372 for (
i = 0;
i < (*index)->nb_encrypted_samples;
i++) {
7375 av_freep(&(*index)->encrypted_samples);
7376 av_freep(&(*index)->auxiliary_info_sizes);
7377 av_freep(&(*index)->auxiliary_offsets);
7386 for (
i = 0;
i <
s->nb_streams;
i++) {
7467 for (
i = 0;
i <
s->nb_streams;
i++) {
7483 for (
i = 0;
i <
s->nb_streams;
i++) {
7502 unsigned track_id, item_count;
7514 for (
i = 0;
i < item_count;
i++) {
7536 if (frag_stream_info &&
7540 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
7542 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
7544 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
7558 if ((seek_ret =
avio_seek(
f, stream_size - 4, SEEK_SET)) < 0) {
7563 c->have_read_mfra_size = 1;
7564 if (!
c->mfra_size ||
c->mfra_size > stream_size) {
7568 if ((seek_ret =
avio_seek(
f, -((int64_t)
c->mfra_size), SEEK_CUR)) < 0) {
7587 c->frag_index.complete = 1;
7589 seek_ret =
avio_seek(
f, original_pos, SEEK_SET);
7592 "failed to seek back after looking for mfra\n");
7618 atom.
size = INT64_MAX;
7639 for (
i = 0;
i <
s->nb_streams;
i++)
7640 if (
s->streams[
i]->codecpar->codec_tag ==
AV_RL32(
"tmcd")) {
7642 }
else if (
s->streams[
i]->codecpar->codec_tag ==
AV_RL32(
"rtmd")) {
7648 for (
i = 0;
i <
s->nb_streams;
i++) {
7653 int tmcd_st_id = -1;
7655 for (j = 0; j <
s->nb_streams; j++)
7659 if (tmcd_st_id < 0 || tmcd_st_id ==
i)
7668 for (
i = 0;
i <
s->nb_streams;
i++) {
7698 for (
i = 0;
i <
s->nb_streams;
i++) {
7714 for (
i = 0;
i <
s->nb_streams;
i++) {
7732 s->streams[
i]->codecpar->bit_rate = mov->
bitrates[
i];
7738 for (
i = 0;
i <
s->nb_streams;
i++) {
7811 int64_t best_dts = INT64_MAX;
7813 for (
i = 0;
i <
s->nb_streams;
i++) {
7846 if (
index >= 0 && index < mov->frag_index.nb_items)
7848 if (
avio_seek(
s->pb, target, SEEK_SET) != target) {
7856 if (index < mov->frag_index.nb_items &&
7888 if (extradata_size > 0 && extradata) {
7894 memcpy(side, extradata, extradata_size);
7906 new_size = ((
size - 8) / 2) * 3;
7912 for (
int j = 0; j < new_size; j += 3) {
7927 int64_t current_index;
7951 if (ret64 !=
sample->pos) {
7975 #if CONFIG_DV_DEMUXER
8031 uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3;
8089 int sample, time_sample, ret;
8102 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
8163 if (stream_index >=
s->nb_streams)
8166 st =
s->streams[stream_index];
8171 if (
mc->seek_individually) {
8176 for (
i = 0;
i <
s->nb_streams;
i++) {
8180 if (stream_index ==
i)
8189 for (
i = 0;
i <
s->nb_streams;
i++) {
8209 #define OFFSET(x) offsetof(MOVContext, x)
8210 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
8212 {
"use_absolute_path",
8213 "allow using absolute path when opening alias, this is a possible security issue",
8216 {
"seek_streams_individually",
8217 "Seek each stream individually to the closest point",
8222 {
"advanced_editlist",
8223 "Modify the AVIndex according to the editlists. Use this option to decode in the order specified by the edits.",
8229 "use mfra for fragment timestamps",
8234 FLAGS,
"use_mfra_for" },
8236 FLAGS,
"use_mfra_for" },
8238 FLAGS,
"use_mfra_for" },
8239 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
8241 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
8243 {
"activation_bytes",
"Secret bytes for Audible AAX files",
OFFSET(activation_bytes),
8245 {
"audible_key",
"AES-128 Key for Audible AAXC files",
OFFSET(audible_key),
8247 {
"audible_iv",
"AES-128 IV for Audible AAXC files",
OFFSET(audible_iv),
8249 {
"audible_fixed_key",
8250 "Fixed key used for handling Audible AAX files",
OFFSET(audible_fixed_key),
8255 {.i64 = 0}, 0, 1,
FLAGS },
8268 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
8272 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v",
const uint16_t avpriv_ac3_channel_layout_tab[8]
Map audio coding mode (acmod) to channel layout mask.
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the "full" 16-byte iv, including the counter.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
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 double val(void *priv, double ch)
static const char *const format[]
Macro definitions for various function/variable attributes.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint64_t avio_rb64(AVIOContext *s)
#define AVIO_FLAG_READ
read-only
int64_t avio_size(AVIOContext *s)
Get the filesize.
unsigned int avio_rb16(AVIOContext *s)
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.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rl32(AVIOContext *s)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
unsigned int avio_rb24(AVIOContext *s)
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
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))
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, buffer_size_t size)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
#define flags(name, subs,...)
#define ss(width, name, subs,...)
audio channel layout utility functions
#define FFSWAP(type, a, b)
#define MKTAG(a, b, c, d)
#define MKBETAG(a, b, c, d)
#define FFNABS(a)
Negative Absolute value.
#define PUT_UTF8(val, tmp, PUT_BYTE)
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static __device__ float fabs(float a)
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
mode
Use these values in ebur128_init (or'ed).
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.
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.
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.
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.
AVEncryptionInfo * av_encryption_info_clone(const AVEncryptionInfo *info)
Allocates an AVEncryptionInfo structure with a copy of the given data.
void av_encryption_init_info_free(AVEncryptionInitInfo *info)
Frees the given encryption init info object.
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.
void av_encryption_info_free(AVEncryptionInfo *info)
Frees the given encryption info object.
static int64_t start_time
static int read_header(FFV1Context *f)
FLAC (Free Lossless Audio Codec) decoder/demuxer common functions.
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.
@ FLAC_METADATA_TYPE_STREAMINFO
#define FLAC_STREAMINFO_SIZE
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define AV_CH_FRONT_RIGHT
#define AV_CH_FRONT_CENTER
#define AV_CH_LOW_FREQUENCY
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_GSM
as in Berlin toast format
@ AV_CODEC_ID_DVD_SUBTITLE
@ AV_CODEC_ID_ADPCM_IMA_QT
@ AV_CODEC_ID_ADPCM_IMA_WAV
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
@ AV_AUDIO_SERVICE_TYPE_KARAOKE
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_PKT_FLAG_DISPOSABLE
Flag is used to indicate packets that contain frames that can be discarded by the decoder.
FF_ENABLE_DEPRECATION_WARNINGS 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.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
@ AV_PKT_DATA_ENCRYPTION_INFO
This side data contains encryption info for how to decrypt the packet.
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
@ AV_PKT_DATA_ENCRYPTION_INIT_INFO
This side data is encryption initialization data.
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, size_t size)
Allocate new information from stream.
uint8_t * av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, size_t *size)
Get side information from stream.
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.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
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.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
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.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
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.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static AVRational av_make_q(int num, int den)
Create an AVRational.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
#define av_fourcc2str(fourcc)
#define AV_FOURCC_MAX_STRING_SIZE
char * av_fourcc_make_string(char *buf, uint32_t fourcc)
Fill the provided buffer with a string containing a FourCC (four-character code) representation.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
struct AVSHA * av_sha_alloc(void)
Allocate an AVSHA context.
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
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,...
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
#define LIBAVUTIL_VERSION_INT
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
AVSphericalProjection
Projection of the video surface(s) on a sphere.
AVSphericalMapping * av_spherical_alloc(size_t *size)
Allocate a AVSphericalVideo structure and initialize its fields to default values.
@ AV_SPHERICAL_EQUIRECTANGULAR
Video represents a sphere mapped on a flat surface using equirectangular projection.
@ AV_SPHERICAL_EQUIRECTANGULAR_TILE
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection.
@ AV_SPHERICAL_CUBEMAP
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
AVStereo3DType
List of possible 3D Types.
AVStereo3D * av_stereo3d_alloc(void)
Allocate an AVStereo3D structure and set its fields to default values.
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
int ff_mov_lang_to_iso639(unsigned code, char to[4])
const AVCodecTag ff_codec_movdata_tags[]
const AVCodecTag ff_codec_movsubtitle_tags[]
#define MOV_TRUN_SAMPLE_DURATION
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
#define FF_MOV_FLAG_MFRA_PTS
#define MOV_TRUN_SAMPLE_CTS
#define MOV_TKHD_FLAG_ENABLED
#define MOV_TFHD_DEFAULT_BASE_IS_MOOF
#define FF_MOV_FLAG_MFRA_DTS
const AVCodecTag ff_codec_movaudio_tags[]
#define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
const AVCodecTag ff_codec_movvideo_tags[]
#define MOV_TFHD_DEFAULT_SIZE
#define MOV_TRUN_FIRST_SAMPLE_FLAGS
#define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
#define MOV_TRUN_SAMPLE_FLAGS
#define MOV_TFHD_DEFAULT_FLAGS
#define MOV_TRUN_DATA_OFFSET
#define MOV_TFHD_BASE_DATA_OFFSET
static enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
Compute codec id for 'lpcm' tag.
#define MOV_TRUN_SAMPLE_SIZE
#define MOV_SAMPLE_DEPENDENCY_NO
#define FF_MOV_FLAG_MFRA_AUTO
#define MOV_TFHD_DEFAULT_DURATION
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static av_const double hypot(double x, double y)
static int truehd_channels(int chanmap)
static int mlp_samplerate(int in)
static uint64_t truehd_layout(int chanmap)
static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int64_t mov_get_skip_samples(AVStream *st, int sample)
static int search_frag_moof_offset(MOVFragmentIndex *frag_index, int64_t offset)
static int update_frag_index(MOVContext *c, int64_t offset)
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MAX_REORDER_DELAY
static int aax_filter(uint8_t *input, int size, MOVContext *c)
static void mov_current_sample_dec(MOVStreamContext *sc)
static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVInputFormat ff_mov_demuxer
static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int64_t get_stream_info_time(MOVFragmentStreamInfo *frag_stream_info)
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.
static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb, int codec_tag, int format, int64_t size)
static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time, void *logctx)
static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static uint32_t yuv_to_rgba(uint32_t ycbcr)
static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_metadata_hmmt(MOVContext *c, AVIOContext *pb, unsigned len)
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int64_t get_frag_time(MOVFragmentIndex *frag_index, int index, int track_id)
static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_header(AVFormatContext *s)
static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_st3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int test_same_origin(const char *src, const char *ref)
static int mov_read_av1c(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_current_sample_set(MOVStreamContext *sc, int current_sample)
static int mov_aaxc_crypto(MOVContext *c)
static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int cenc_filter(MOVContext *mov, AVStream *st, MOVStreamContext *sc, AVPacket *pkt, int current_index)
static const AVClass mov_class
static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVStreamContext *sc, AVEncryptionInfo **sample, int use_subsamples)
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const uint32_t mac_to_unicode[128]
static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
An strf atom is a BITMAPINFOHEADER struct.
static void fix_frag_index_entries(MOVFragmentIndex *frag_index, int index, int id, int entries)
static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)
static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_schm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
static int read_tfra(MOVContext *mov, AVIOContext *f)
static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp)
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, enum AVCodecID codec_id)
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_stsc_index_valid(unsigned int index, unsigned int count)
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int should_retry(AVIOContext *pb, int error_code)
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_clli(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_update_dts_shift(MOVStreamContext *sc, int duration, void *logctx)
static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static MOVFragmentStreamInfo * get_frag_stream_info(MOVFragmentIndex *frag_index, int index, int id)
static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_rewrite_dvd_sub_extradata(AVStream *st)
static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_alac(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_mfra(MOVContext *c, AVIOContext *f)
#define MIN_DATA_ENTRY_BOX_SIZE
static int mov_read_mdcv(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st, uint32_t value, int flags)
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 const MOVParseTableEntry mov_default_parse_table[]
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
static MOVFragmentStreamInfo * get_current_frag_stream_info(MOVFragmentIndex *frag_index)
static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static AVIndexEntry * mov_find_next_sample(AVFormatContext *s, AVStream **st)
static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void fix_timescale(MOVContext *c, MOVStreamContext *sc)
static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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 mov_read_close(AVFormatContext *s)
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref)
static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_build_index(MOVContext *mov, AVStream *st)
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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...
static int get_eia608_packet(AVIOContext *pb, AVPacket *pkt, int size)
static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define IS_MATRIX_IDENT(matrix)
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.
static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryptionIndex *encryption_index)
static int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index)
static int mov_read_vpcc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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_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 cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *input, int size)
static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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,...
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int64_t mov_read_atom_into_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, AVCodecParameters *par, uint8_t *buf)
static void mov_free_encryption_index(MOVEncryptionIndex **index)
static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, char *dst, int dstlen)
static int search_frag_timestamp(MOVFragmentIndex *frag_index, AVStream *st, int64_t timestamp)
static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_realloc_extradata(AVCodecParameters *par, MOVAtom atom)
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_coll(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_codec_id(AVStream *st, uint32_t format)
static void export_orphan_timecode(AVFormatContext *s)
static void mov_estimate_video_delay(MOVContext *c, AVStream *st)
static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_probe(const AVProbeData *p)
static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_t len)
static void mov_current_sample_inc(MOVStreamContext *sc)
static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_targa_y216(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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 void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt)
static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define ALAC_EXTRADATA_SIZE
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
static void mov_read_chapters(AVFormatContext *s)
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void set_frag_stream(MOVFragmentIndex *frag_index, int id)
static const AVOption mov_options[]
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size)
Read 'chan' tag from the input stream.
static float distance(float x, float y, int band)
#define OPUS_SEEK_PREROLL_MS
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const char * av_color_space_name(enum AVColorSpace space)
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
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,...
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
const AVCodecTag ff_codec_bmp_tags[]
const AVCodecTag ff_codec_wav_tags[]
internal header for RIFF based (de)muxers do NOT include this in end user applications
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
Public header for SHA-1 & SHA-256 hash function implementations.
A reference to a data buffer.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
This struct describes the properties of an encoded stream.
enum AVColorSpace color_space
int extradata_size
Size of the extradata content in bytes.
int frame_size
Audio only.
enum AVFieldOrder field_order
Video only.
uint64_t channel_layout
Audio only.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int seek_preroll
Audio only.
enum AVMediaType codec_type
General type of the encoded data.
int block_align
Audio only.
int video_delay
Video only.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
enum AVColorPrimaries color_primaries
int sample_rate
Audio only.
enum AVColorTransferCharacteristic color_trc
int initial_padding
Audio only.
enum AVColorRange color_range
Video only.
unsigned MaxFALL
Max average light level per frame (cd/m^2).
unsigned MaxCLL
Max content light level (cd/m^2).
uint8_t dv_bl_signal_compatibility_id
This describes encryption info for a packet.
uint32_t skip_byte_block
Only used for pattern encryption.
uint8_t * iv
The initialization vector.
uint32_t crypt_byte_block
Only used for pattern encryption.
uint8_t * key_id
The ID of the key used to encrypt the packet.
uint32_t scheme
The fourcc encryption scheme, in big-endian byte order.
This describes info used to initialize an encryption key system.
uint8_t * data
Key-system specific initialization data.
struct AVEncryptionInitInfo * next
An optional pointer to the next initialization info in the list.
uint8_t ** key_ids
An array of key IDs this initialization data is for.
uint8_t * system_id
A unique identifier for the key system this is for, can be NULL if it is not known.
uint32_t num_key_ids
The number of key IDs.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int eof_reached
true if was unable to read due to error or eof
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int flags
A combination of AV_PKT_FLAG values.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int64_t pos
byte position in stream, -1 if unknown
This structure contains the data a format has to probe a file.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Rational number (pair of numerator and denominator).
uint64_t count
number of bytes in buffer
uint32_t bound_left
Distance from the left edge.
enum AVSphericalProjection projection
Projection type.
uint32_t bound_top
Distance from the top edge.
uint32_t bound_bottom
Distance from the bottom edge.
uint32_t bound_right
Distance from the right edge.
int32_t pitch
Rotation around the right vector [-90, 90].
int32_t roll
Rotation around the forward vector [-180, 180].
int32_t yaw
Rotation around the up vector [-180, 180].
uint32_t padding
Number of pixels to pad from the edge of each cube face.
enum AVStereo3DType type
How views are packed within the video.
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet.
unsigned int index_entries_allocated_size
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t nb_frames
number of frames in this stream if known or 0
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
int64_t duration
Decoding: duration of the stream, in stream time base.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
attribute_deprecated AVCodecContext * codec
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVStreamParseType need_parsing
AVRational r_frame_rate
Real base framerate of the stream.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
int disposition
AV_DISPOSITION_* bit field.
This file is part of FFmpeg.
int * bitrates
bitrates read before streams creation
unsigned int aax_mode
'aax' file has been detected
int found_mdat
'mdat' atom has been found
int64_t next_root_atom
offset of the next root atom
DVDemuxContext * dv_demux
unsigned int nb_chapter_tracks
MOVFragmentIndex frag_index
struct AVAES * aes_decrypt
MOVFragment fragment
current fragment in moof atom
AVFormatContext * dv_fctx
int found_moov
'moov' atom has been found
int trak_index
Index of the current 'trak'.
uint64_t * auxiliary_offsets
Absolute seek position.
unsigned int nb_encrypted_samples
size_t auxiliary_offsets_count
size_t auxiliary_info_sample_count
uint8_t auxiliary_info_default_size
uint8_t * auxiliary_info_sizes
AVEncryptionInfo ** encrypted_samples
MOVFragmentStreamInfo * stream_info
MOVFragmentIndexItem * item
MOVEncryptionIndex * encryption_index
uint64_t base_data_offset
int(* parse)(MOVContext *ctx, AVIOContext *pb, MOVAtom atom)
int64_t time_offset
time offset of the edit list entries
uint8_t ** extradata
extradata array (and size) for multiple stsd
MOVEncryptionIndex * encryption_index
int64_t track_end
used for dts generation in fragmented movie files
int pseudo_stream_id
-1 means demux all ids
unsigned int rap_group_count
unsigned int ctts_allocated_size
unsigned int per_sample_iv_size
struct MOVStreamContext::@261 cenc
AVContentLightMetadata * coll
unsigned int samples_per_frame
int start_pad
amount of samples to skip due to enc-dec delay
unsigned int sample_size
may contain value calculated from stsd or value from stsz atom
AVEncryptionInfo * default_encrypted_sample
int16_t audio_cid
stsd audio compression id
struct AVAESCTR * aes_ctr
MOVIndexRange * current_index_range
AVMasteringDisplayMetadata * mastering
unsigned int sample_count
int dts_shift
dts shift when ctts is negative
int64_t min_corrected_pts
minimum Composition time shown by the edits excluding empty edits.
int ffindex
AVStream index.
AVSphericalMapping * spherical
unsigned int keyframe_count
unsigned int bytes_per_frame
uint32_t tmcd_flags
tmcd track flags
unsigned * stps_data
partial sync sample for mpeg-2 open gop
MOVIndexRange * index_ranges
unsigned int stsz_sample_size
always contains sample size from stsz atom
#define av_malloc_array(a, b)
#define av_realloc_f(p, o, n)
#define avpriv_request_sample(...)
static int ref[MAX_W *MAX_W]
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
#define AV_TIMECODE_STR_SIZE
@ AV_TIMECODE_FLAG_ALLOWNEGATIVE
negative time values are allowed
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
@ AV_TIMECODE_FLAG_24HOURSMAX
timecode wraps after 24 hours
static double cr(void *priv, double x, double y)
static double cb(void *priv, double x, double y)
static float mean(const float *input, int size)
static const uint8_t offset[127][2]
static void rotate(const float rot_quaternion[2][4], float *vec)
Rotate vector with given rotation quaternion.
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)