Go to the documentation of this file.
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++) {
236 char buf[200], place[100];
237 uint16_t langcode = 0;
238 double longitude, latitude, altitude;
239 const char *
key =
"location";
241 if (
len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
261 "loci too short (%u bytes left, need at least %d)\n",
len, 12);
269 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f", latitude, longitude);
289 if (
c->ignore_chapters)
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) {
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) {
455 if (atom.
size < 0 || str_size >= INT_MAX/2)
460 num = (data_type >= 21 && data_type <= 23);
461 str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1;
469 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
471 }
else if (data_type == 21) {
475 else if (str_size == 2)
477 else if (str_size == 3)
479 else if (str_size == 4)
483 "Failed to store the number (%d) in string.\n",
val);
487 }
else if (data_type == 22) {
488 unsigned int val = 0;
491 else if (str_size == 2)
493 else if (str_size == 3)
495 else if (str_size == 4)
499 "Failed to store the number (%u) in string.\n",
val);
503 }
else if (data_type == 23 && str_size >= 4) {
507 "Failed to store the float32 number (%f) in string.\n",
val);
525 if (!strcmp(
key,
"encoder")) {
527 if (sscanf(
str,
"HandBrake %d.%d.%d", &
major, &
minor, µ) == 3) {
528 c->handbrake_version = 1000000*
major + 1000*
minor + micro;
540 int i, nb_chapters, str_len,
version;
544 if (
c->ignore_chapters)
547 if ((atom.
size -= 5) < 0)
556 for (
i = 0;
i < nb_chapters;
i++) {
563 if ((atom.
size -= 9+str_len) < 0)
575 #define MIN_DATA_ENTRY_BOX_SIZE 12
582 if (
c->fc->nb_streams < 1)
584 st =
c->fc->streams[
c->fc->nb_streams-1];
591 entries >= UINT_MAX /
sizeof(*sc->
drefs))
601 for (
i = 0;
i < entries;
i++) {
614 uint16_t volume_len,
len;
621 volume_len =
FFMIN(volume_len, 27);
625 dref->
volume[volume_len] = 0;
667 if (
len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
673 for (j =
len - 1; j >= 0; j--) {
674 if (dref->
path[j] == 0)
679 for (j = 0; j <
len; j++)
680 if (dref->
path[j] ==
':' || dref->
path[j] == 0)
683 }
else if (
type == 0) {
695 for (j = 0; j <
len; j++)
696 if (dref->
dir[j] ==
':')
732 if (
c->trak_index < 0) {
734 c->found_hdlr_mdta = 1;
739 st =
c->fc->streams[
c->fc->nb_streams-1];
754 title_size = atom.
size - 24;
755 if (title_size > 0) {
756 if (title_size >
FFMIN(INT_MAX, SIZE_MAX-1))
767 title_str[title_size] = 0;
769 int off = (!
c->isom && title_str[0] == title_size - 1);
788 int ac3info, acmod, lfeon, bsmod;
790 if (
c->fc->nb_streams < 1)
792 st =
c->fc->streams[
c->fc->nb_streams-1];
800 bsmod = (ac3info >> 14) & 0x7;
801 acmod = (ac3info >> 11) & 0x7;
802 lfeon = (ac3info >> 10) & 0x1;
811 #if FF_API_LAVF_AVCTX
813 st->codec->audio_service_type = *ast;
824 int eac3info, acmod, lfeon, bsmod;
826 if (
c->fc->nb_streams < 1)
828 st =
c->fc->streams[
c->fc->nb_streams-1];
840 bsmod = (eac3info >> 12) & 0x1f;
841 acmod = (eac3info >> 9) & 0x7;
842 lfeon = (eac3info >> 8) & 0x1;
851 #if FF_API_LAVF_AVCTX
853 st->codec->audio_service_type = *ast;
862 const uint32_t ddts_size = 20;
865 uint32_t frame_duration_code = 0;
866 uint32_t channel_layout_code = 0;
873 if (
avio_read(pb, buf, ddts_size) < ddts_size) {
880 if (
c->fc->nb_streams < 1) {
884 st =
c->fc->streams[
c->fc->nb_streams-1];
895 frame_duration_code =
get_bits(&gb, 2);
897 channel_layout_code =
get_bits(&gb, 16);
900 (frame_duration_code == 0) ? 512 :
901 (frame_duration_code == 1) ? 1024 :
902 (frame_duration_code == 2) ? 2048 :
903 (frame_duration_code == 3) ? 4096 : 0;
905 if (channel_layout_code > 0xff) {
926 if (
c->fc->nb_streams < 1)
928 st =
c->fc->streams[
c->fc->nb_streams-1];
946 if (
c->fc->nb_streams < 1)
948 st =
c->fc->streams[
c->fc->nb_streams-1];
962 if (
c->fc->nb_streams < 1)
964 st =
c->fc->streams[
c->fc->nb_streams-1];
969 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
972 }
else if (den != 0) {
988 #define DRM_BLOB_SIZE 56
997 uint8_t calculated_checksum[20];
1001 uint8_t *activation_bytes =
c->activation_bytes;
1002 uint8_t *fixed_key =
c->audible_fixed_key;
1011 if (!
c->aes_decrypt) {
1023 for (
i = 0;
i < 20;
i++)
1028 if (!activation_bytes) {
1033 if (
c->activation_bytes_size != 4) {
1040 if (
c->audible_fixed_key_size != 16) {
1060 if (memcmp(calculated_checksum, file_checksum, 20)) {
1067 for (
i = 0;
i < 4;
i++) {
1069 if (activation_bytes[
i] !=
output[3 -
i]) {
1075 memcpy(
c->file_key,
output + 8, 16);
1093 unsigned char iv[16];
1095 memcpy(iv,
c->file_iv, 16);
1107 int comp_brand_size;
1108 char* comp_brands_str;
1114 if (strcmp(
type,
"qt "))
1121 comp_brand_size = atom.
size - 8;
1122 if (comp_brand_size < 0)
1124 comp_brands_str =
av_malloc(comp_brand_size + 1);
1125 if (!comp_brands_str)
1133 comp_brands_str[comp_brand_size] = 0;
1145 if (
c->found_moov) {
1167 if (index < 0 || index >= frag_index->
nb_items)
1183 if (frag_index->
current < 0 ||
1202 if (frag_index->
current < 0 ||
1217 int64_t moof_offset;
1230 if (moof_offset >=
offset)
1232 if (moof_offset <=
offset)
1249 int index,
int track_id)
1255 if (track_id >= 0) {
1288 m0 = m = (
a +
b) >> 1;
1294 if (m <
b && frag_time <= timestamp)
1311 if (index < c->frag_index.nb_items &&
1318 &
c->frag_index.allocated_size,
1319 (
c->frag_index.nb_items + 1) *
1320 sizeof(*
c->frag_index.item));
1323 c->frag_index.item = item;
1327 if (!frag_stream_info)
1330 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
1332 if (
c->fc->streams[
i]->id < 0) {
1337 frag_stream_info[
i].
id =
c->fc->streams[
i]->id;
1346 if (index < c->frag_index.nb_items)
1347 memmove(
c->frag_index.item +
index + 1,
c->frag_index.item +
index,
1348 (
c->frag_index.nb_items -
index) *
sizeof(*
c->frag_index.item));
1350 item = &
c->frag_index.item[
index];
1356 c->frag_index.nb_items++;
1362 int id,
int entries)
1371 if (frag_stream_info && frag_stream_info->
index_entry >= 0)
1379 c->fragment.found_tfhd = 0;
1381 if (!
c->has_looked_for_mfra &&
c->use_mfra_for > 0) {
1382 c->has_looked_for_mfra = 1;
1389 "read the mfra (may be a live ismv)\n");
1393 "seekable, can not look for mfra\n");
1396 c->fragment.moof_offset =
c->fragment.implicit_offset =
avio_tell(pb) - 8;
1405 if(time >= 2082844800)
1408 if ((int64_t)(time * 1000000ULL) / 1000000 != time) {
1424 int64_t creation_time;
1426 if (
c->fc->nb_streams < 1)
1428 st =
c->fc->streams[
c->fc->nb_streams-1];
1469 int64_t creation_time;
1482 if (
c->time_scale <= 0) {
1491 if (
c->time_scale > 0 && !
c->trex_data)
1500 for (
i = 0;
i < 3;
i++) {
1522 if (
c->fc->nb_streams < 1)
1524 st =
c->fc->streams[
c->fc->nb_streams-1];
1528 if (little_endian == 1) {
1553 char color_parameter_type[5] = { 0 };
1557 if (
c->fc->nb_streams < 1)
1559 st =
c->fc->streams[
c->fc->nb_streams - 1];
1564 if (strncmp(color_parameter_type,
"nclx", 4) &&
1565 strncmp(color_parameter_type,
"nclc", 4) &&
1566 strncmp(color_parameter_type,
"prof", 4)) {
1568 color_parameter_type);
1572 if (!strncmp(color_parameter_type,
"prof", 4)) {
1586 "%s: pri %d trc %d matrix %d",
1589 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1616 unsigned mov_field_order;
1619 if (
c->fc->nb_streams < 1)
1621 st =
c->fc->streams[
c->fc->nb_streams-1];
1625 if ((mov_field_order & 0xFF00) == 0x0100)
1627 else if ((mov_field_order & 0xFF00) == 0x0200) {
1628 switch (mov_field_order & 0xFF) {
1651 if (
size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1674 }
else if (err < atom.
size) {
1688 uint64_t original_size;
1691 if (
c->fc->nb_streams < 1)
1693 st =
c->fc->streams[
c->fc->nb_streams-1];
1742 if (!
ret &&
c->fc->nb_streams >= 1) {
1754 if (
c->fc->nb_streams >= 1) {
1763 if (
cid == 0xd4d ||
cid == 0xd4e)
1774 if (num <= 0 || den <= 0)
1778 if (den >= INT_MAX / 2)
1782 c->fc->streams[
c->fc->nb_streams-1]->display_aspect_ratio.num = num;
1783 c->fc->streams[
c->fc->nb_streams-1]->display_aspect_ratio.den = den;
1797 uint64_t original_size;
1798 if (
c->fc->nb_streams >= 1) {
1802 if (atom.
size == 16) {
1807 if (length == atom.
size) {
1809 switch (range_value) {
1846 if (
c->fc->nb_streams < 1)
1848 st =
c->fc->streams[
c->fc->nb_streams-1];
1850 if ((uint64_t)atom.
size > (1<<30))
1860 }
else if (atom.
size > 8) {
1874 #define ALAC_EXTRADATA_SIZE 36
1903 if (
c->fc->nb_streams < 1)
1905 st =
c->fc->streams[
c->fc->nb_streams-1];
1907 if ((uint64_t)atom.
size > (1<<30))
1910 if (atom.
size >= 10) {
1943 if (
c->fc->nb_streams < 1)
1945 st =
c->fc->streams[
c->fc->nb_streams-1];
1947 if (atom.
size >= (1<<28) || atom.
size < 7)
1951 if ((profile_level & 0xf0) != 0xc0)
1972 if (
c->fc->nb_streams < 1)
1974 if (atom.
size <= 40)
1976 st =
c->fc->streams[
c->fc->nb_streams-1];
1978 if ((uint64_t)atom.
size > (1<<30))
1993 unsigned int i, entries;
1995 if (
c->trak_index < 0) {
1999 if (
c->fc->nb_streams < 1)
2001 st =
c->fc->streams[
c->fc->nb_streams-1];
2021 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
2024 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
2045 ((
format & 0xFFFF) ==
'm' + (
's' << 8) ||
2046 (
format & 0xFFFF) ==
'T' + (
'S' << 8)))
2078 uint8_t codec_name[32] = { 0 };
2111 if (!strncmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
2118 !strncmp(codec_name,
"Sorenson H263", 13))
2134 int bits_per_sample,
flags;
2153 (compatible_brands && strstr(compatible_brands->
value,
"qt ")) ||
2234 if (bits_per_sample) {
2259 y = (ycbcr >> 16) & 0xFF;
2260 cr = (ycbcr >> 8) & 0xFF;
2263 b = av_clip_uint8((1164 * (y - 16) + 2018 * (
cb - 128)) / 1000);
2264 g = av_clip_uint8((1164 * (y - 16) - 813 * (
cr - 128) - 391 * (
cb - 128)) / 1000);
2265 r = av_clip_uint8((1164 * (y - 16) + 1596 * (
cr - 128) ) / 1000);
2267 return (
r << 16) | (
g << 8) |
b;
2272 char buf[256] = {0};
2280 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
2284 for (
i = 0;
i < 16;
i++) {
2288 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba,
i != 15 ?
", " :
"");
2291 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
2322 #if FF_API_LAVF_AVCTX
2333 #if FF_API_LAVF_AVCTX
2345 if (str_size > 0 &&
size >= (
int)str_size + 30) {
2346 char *reel_name =
av_malloc(str_size + 1);
2350 reel_name[str_size] = 0;
2352 if (*reel_name == 0) {
2377 #if CONFIG_DV_DEMUXER
2448 int codec_tag,
int format,
2461 (
c->fc->video_codec_id ? video_codec_id !=
c->fc->video_codec_id
2462 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2479 int pseudo_stream_id;
2482 st =
c->fc->streams[
c->fc->nb_streams-1];
2485 for (pseudo_stream_id = 0;
2487 pseudo_stream_id++) {
2490 int ret, dref_id = 1;
2500 }
else if (
size <= 7) {
2502 "invalid size %"PRId64
" in stsd\n",
size);
2519 "size=%"PRId64
" 4CC=%s codec_type=%d\n",
size,
2545 }
else if (
a.size > 0)
2577 if (
c->fc->nb_streams < 1)
2579 st =
c->fc->streams[
c->fc->nb_streams - 1];
2587 if (entries <= 0 || entries > atom.
size / 8) {
2594 "Duplicate stsd found in this track.\n");
2640 unsigned int i, entries;
2642 if (
c->fc->nb_streams < 1)
2644 st =
c->fc->streams[
c->fc->nb_streams-1];
2651 if ((uint64_t)entries * 12 + 4 > atom.
size)
2674 int64_t first_min =
i + 1;
2734 unsigned i, entries;
2736 if (
c->fc->nb_streams < 1)
2738 st =
c->fc->streams[
c->fc->nb_streams-1];
2770 unsigned int i, entries;
2772 if (
c->fc->nb_streams < 1)
2774 st =
c->fc->streams[
c->fc->nb_streams-1];
2793 if (entries >= UINT_MAX /
sizeof(
int))
2819 unsigned int i, entries, sample_size, field_size, num_bytes;
2824 if (
c->fc->nb_streams < 1)
2826 st =
c->fc->streams[
c->fc->nb_streams-1];
2832 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2851 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2858 if (entries >= (UINT_MAX - 4) / field_size)
2868 num_bytes = (entries*field_size+4)>>3;
2912 unsigned int i, entries, alloc_size = 0;
2914 int64_t total_sample_count=0;
2916 if (
c->fc->nb_streams < 1)
2918 st =
c->fc->streams[
c->fc->nb_streams-1];
2926 c->fc->nb_streams-1, entries);
2932 if (entries >= INT_MAX /
sizeof(*sc->
stts_data))
2936 int sample_duration;
2937 unsigned int sample_count;
2938 unsigned int min_entries =
FFMIN(
FFMAX(
i + 1, 1024 * 1024), entries);
2956 sample_count, sample_duration);
2958 duration+=(int64_t)sample_duration*(uint64_t)sample_count;
2959 total_sample_count+=sample_count;
2965 duration <= INT64_MAX - sc->duration_for_fps &&
2966 total_sample_count <= INT_MAX - sc->nb_frames_for_fps
2990 if (
c->fc->nb_streams < 1)
2992 st =
c->fc->streams[
c->fc->nb_streams - 1];
2997 entries = atom.
size - 4;
3000 c->fc->nb_streams - 1, entries);
3033 unsigned int i, entries, ctts_count = 0;
3035 if (
c->fc->nb_streams < 1)
3037 st =
c->fc->streams[
c->fc->nb_streams-1];
3048 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
3061 "ignoring CTTS entry with count=%d duration=%d\n",
3099 unsigned int i, entries;
3101 uint32_t grouping_type;
3103 if (
c->fc->nb_streams < 1)
3105 st =
c->fc->streams[
c->fc->nb_streams-1];
3111 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
3147 unsigned int edit_list_index,
3148 int64_t *edit_list_media_time,
3149 int64_t *edit_list_duration,
3150 int64_t global_timescale)
3155 *edit_list_media_time = msc->
elst_data[edit_list_index].
time;
3159 if (global_timescale == 0) {
3192 int64_t timestamp_pts,
3195 int64_t* ctts_index,
3196 int64_t* ctts_sample)
3202 int64_t index_ctts_count;
3230 if (ctts_data && *
index >= 0) {
3236 for (index_ctts_count = 0; index_ctts_count < *
index; index_ctts_count++) {
3237 if (*ctts_index < ctts_count) {
3239 if (ctts_data[*ctts_index].
count == *ctts_sample) {
3246 while (*
index >= 0 && (*ctts_index) >= 0 && (*ctts_index) < ctts_count) {
3250 if ((e_old[*
index].timestamp + ctts_data[*ctts_index].
duration) <= timestamp_pts &&
3256 if (*ctts_sample == 0) {
3258 if (*ctts_index >= 0)
3259 *ctts_sample = ctts_data[*ctts_index].
count - 1;
3269 return *
index >= 0 ? 0 : -1;
3292 const size_t requested_size =
3309 ie= &entries[
index];
3324 int64_t* frame_duration_buffer,
3325 int frame_duration_buffer_size) {
3327 av_assert0(end_index >= 0 && end_index <= st->nb_index_entries);
3328 for (
i = 0;
i < frame_duration_buffer_size;
i++) {
3329 end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 -
i];
3342 const size_t min_size_needed = (*ctts_count + 1) *
sizeof(
MOVStts);
3343 const size_t requested_size =
3344 min_size_needed > *allocated_size ?
3345 FFMAX(min_size_needed, 2 * (*allocated_size)) :
3348 if((
unsigned)(*ctts_count) >= UINT_MAX /
sizeof(
MOVStts) - 1)
3351 ctts_buf_new =
av_fast_realloc(*ctts_data, allocated_size, requested_size);
3356 *ctts_data = ctts_buf_new;
3361 *ctts_count = (*ctts_count) + 1;
3365 #define MAX_REORDER_DELAY 16
3370 int ctts_sample = 0;
3373 int j,
r, num_swaps;
3376 pts_buf[j] = INT64_MIN;
3384 buf_start = (buf_start + 1);
3397 while (j != buf_start) {
3400 if (pts_buf[j] < pts_buf[
r]) {
3401 FFSWAP(int64_t, pts_buf[j], pts_buf[
r]);
3459 if (range_size > current_sample) {
3463 current_sample -= range_size;
3481 int64_t ctts_index_old = 0;
3482 int64_t ctts_sample_old = 0;
3484 int64_t edit_list_media_time = 0;
3485 int64_t edit_list_duration = 0;
3486 int64_t frame_duration = 0;
3487 int64_t edit_list_dts_counter = 0;
3488 int64_t edit_list_dts_entry_end = 0;
3489 int64_t edit_list_start_ctts_sample = 0;
3491 int64_t curr_ctts = 0;
3492 int64_t empty_edits_sum_duration = 0;
3493 int64_t edit_list_index = 0;
3496 int64_t start_dts = 0;
3497 int64_t edit_list_start_encountered = 0;
3498 int64_t search_timestamp = 0;
3499 int64_t* frame_duration_buffer =
NULL;
3500 int num_discarded_begin = 0;
3501 int first_non_zero_audio_edit = -1;
3502 int packet_skip_samples = 0;
3505 int found_keyframe_after_edit = 0;
3506 int found_non_empty_edit = 0;
3539 edit_list_dts_entry_end -= msc->
dts_shift;
3543 start_dts = edit_list_dts_entry_end;
3547 av_log(mov->
fc,
AV_LOG_DEBUG,
"Processing st: %d, edit list %"PRId64
" - media time: %"PRId64
", duration: %"PRId64
"\n",
3548 st->
index, edit_list_index, edit_list_media_time, edit_list_duration);
3550 edit_list_dts_counter = edit_list_dts_entry_end;
3551 edit_list_dts_entry_end += edit_list_duration;
3552 num_discarded_begin = 0;
3553 if (!found_non_empty_edit && edit_list_media_time == -1) {
3554 empty_edits_sum_duration += edit_list_duration;
3557 found_non_empty_edit = 1;
3562 if (first_non_zero_audio_edit < 0) {
3563 first_non_zero_audio_edit = 1;
3565 first_non_zero_audio_edit = 0;
3568 if (first_non_zero_audio_edit > 0)
3576 search_timestamp = edit_list_media_time;
3585 &
index, &ctts_index_old, &ctts_sample_old) < 0) {
3587 "st: %d edit list: %"PRId64
" Missing key frame while searching for timestamp: %"PRId64
"\n",
3588 st->
index, edit_list_index, search_timestamp);
3590 &
index, &ctts_index_old, &ctts_sample_old) < 0) {
3592 "st: %d edit list %"PRId64
" Cannot find an index entry before timestamp: %"PRId64
".\n",
3593 st->
index, edit_list_index, search_timestamp);
3596 ctts_sample_old = 0;
3599 current = e_old +
index;
3600 edit_list_start_ctts_sample = ctts_sample_old;
3603 edit_list_start_encountered = 0;
3604 found_keyframe_after_edit = 0;
3605 for (; current < e_old_end; current++,
index++) {
3607 frame_duration = (current + 1 < e_old_end) ?
3608 ((current + 1)->timestamp - current->
timestamp) : edit_list_duration;
3616 if (ctts_data_old && ctts_index_old < ctts_count_old) {
3617 curr_ctts = ctts_data_old[ctts_index_old].
duration;
3618 av_log(mov->
fc,
AV_LOG_DEBUG,
"stts: %"PRId64
" ctts: %"PRId64
", ctts_index: %"PRId64
", ctts_count: %"PRId64
"\n",
3619 curr_cts, curr_ctts, ctts_index_old, ctts_count_old);
3620 curr_cts += curr_ctts;
3622 if (ctts_sample_old == ctts_data_old[ctts_index_old].
count) {
3625 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3626 ctts_data_old[ctts_index_old].
duration) == -1) {
3629 ctts_data_old[ctts_index_old].
count - edit_list_start_ctts_sample,
3630 ctts_data_old[ctts_index_old].
duration);
3634 ctts_sample_old = 0;
3635 edit_list_start_ctts_sample = 0;
3639 if (curr_cts < edit_list_media_time || curr_cts >= (edit_list_duration + edit_list_media_time)) {
3641 curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time &&
3642 first_non_zero_audio_edit > 0) {
3643 packet_skip_samples = edit_list_media_time - curr_cts;
3647 edit_list_dts_counter -= packet_skip_samples;
3648 if (edit_list_start_encountered == 0) {
3649 edit_list_start_encountered = 1;
3652 if (frame_duration_buffer) {
3654 frame_duration_buffer, num_discarded_begin);
3659 av_log(mov->
fc,
AV_LOG_DEBUG,
"skip %d audio samples from curr_cts: %"PRId64
"\n", packet_skip_samples, curr_cts);
3664 if (edit_list_start_encountered == 0) {
3665 num_discarded_begin++;
3666 frame_duration_buffer =
av_realloc(frame_duration_buffer,
3667 num_discarded_begin *
sizeof(int64_t));
3668 if (!frame_duration_buffer) {
3672 frame_duration_buffer[num_discarded_begin - 1] = frame_duration;
3687 if (edit_list_start_encountered == 0) {
3688 edit_list_start_encountered = 1;
3691 if (frame_duration_buffer) {
3693 frame_duration_buffer, num_discarded_begin);
3706 if (current_index_range < msc->index_ranges ||
index != current_index_range->
end) {
3707 current_index_range++;
3710 current_index_range->
end =
index + 1;
3713 if (edit_list_start_encountered > 0) {
3714 edit_list_dts_counter = edit_list_dts_counter + frame_duration;
3718 if ((curr_cts + frame_duration >= (edit_list_duration + edit_list_media_time)) &&
3720 if (ctts_data_old) {
3725 found_keyframe_after_edit = 1;
3728 if (ctts_sample_old != 0) {
3731 ctts_sample_old - edit_list_start_ctts_sample,
3732 ctts_data_old[ctts_index_old].
duration) == -1) {
3734 ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample,
3735 ctts_data_old[ctts_index_old].
duration);
3771 current_index_range++;
3772 current_index_range->
start = 0;
3773 current_index_range->
end = 0;
3780 int64_t current_offset;
3781 int64_t current_dts = 0;
3782 unsigned int stts_index = 0;
3783 unsigned int stsc_index = 0;
3784 unsigned int stss_index = 0;
3785 unsigned int stps_index = 0;
3787 uint64_t stream_size = 0;
3789 unsigned int ctts_count_old = sc->
ctts_count;
3792 int i, edit_start_index = 0, multiple_edits = 0;
3793 int64_t empty_duration = 0;
3798 if (
i == 0 && e->
time == -1) {
3802 edit_start_index = 1;
3803 }
else if (
i == edit_start_index && e->
time >= 0) {
3812 "Use -advanced_editlist to correctly decode otherwise "
3813 "a/v desync might occur\n");
3833 unsigned int current_sample = 0;
3834 unsigned int stts_sample = 0;
3835 unsigned int sample_size;
3837 unsigned int rap_group_index = 0;
3838 unsigned int rap_group_sample = 0;
3839 int64_t last_dts = 0;
3840 int64_t dts_correction = 0;
3845 last_dts = current_dts;
3859 if (ctts_data_old) {
3874 for (
i = 0;
i < ctts_count_old &&
3876 for (j = 0; j < ctts_data_old[
i].
count &&
3917 if (rap_group_present && rap_group_index < sc->rap_group_count) {
3920 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
3921 rap_group_sample = 0;
3927 && !rap_group_present
3936 if (sample_size > 0x3FFFFFFF) {
3941 e->
pos = current_offset;
3943 e->
size = sample_size;
3946 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %u, offset %"PRIx64
", dts %"PRId64
", "
3947 "size %u, distance %u, keyframe %d\n", st->
index, current_sample,
3948 current_offset, current_dts, sample_size,
distance, keyframe);
3953 current_offset += sample_size;
3954 stream_size += sample_size;
3960 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
3967 if (!dts_correction || current_dts + dts_correction > last_dts) {
3968 current_dts += dts_correction;
3972 dts_correction += current_dts - last_dts - 1;
3973 current_dts = last_dts + 1;
3975 last_dts = current_dts;
3988 unsigned chunk_samples, total = 0;
3995 unsigned count, chunk_count;
4010 count = (chunk_samples+1023) / 1024;
4017 total += chunk_count *
count;
4039 while (chunk_samples > 0) {
4045 "Zero bytes per frame, but %d samples per frame",
4068 if (
size > 0x3FFFFFFF) {
4073 e->
pos = current_offset;
4079 "size %u, duration %u\n", st->
index,
i, current_offset, current_dts,
4082 current_offset +=
size;
4115 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0,
src);
4116 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0,
ref);
4118 if (strlen(
src) == 0) {
4120 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
4121 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
4122 strlen(src_host) + 1 >=
sizeof(src_host) ||
4123 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
4125 }
else if (strcmp(src_proto, ref_proto) ||
4126 strcmp(src_auth, ref_auth) ||
4127 strcmp(src_host, ref_host) ||
4128 src_port != ref_port) {
4138 if (
ref->nlvl_to > 0 &&
ref->nlvl_from > 0) {
4139 char filename[1025];
4140 const char *src_path;
4144 src_path = strrchr(
src,
'/');
4151 for (
i = 0, l = strlen(
ref->path) - 1; l >= 0; l--)
4152 if (
ref->path[l] ==
'/') {
4153 if (
i ==
ref->nlvl_to - 1)
4160 if (
i ==
ref->nlvl_to - 1 && src_path -
src <
sizeof(filename)) {
4161 memcpy(filename,
src, src_path -
src);
4162 filename[src_path -
src] = 0;
4164 for (
i = 1;
i <
ref->nlvl_from;
i++)
4165 av_strlcat(filename,
"../",
sizeof(filename));
4168 if (!
c->use_absolute_path) {
4173 "Reference with mismatching origin, %s not tried for security reasons, "
4174 "set demuxer option use_absolute_path to allow it anyway\n",
4179 if(strstr(
ref->path + l + 1,
"..") ||
4180 strstr(
ref->path + l + 1,
":") ||
4181 (
ref->nlvl_from > 1 && same_origin < 0) ||
4182 (filename[0] ==
'/' && src_path ==
src))
4186 if (strlen(filename) + 1 ==
sizeof(filename))
4191 }
else if (
c->use_absolute_path) {
4193 "this is a possible security issue\n");
4198 "Absolute path %s not tried for security reasons, "
4199 "set demuxer option use_absolute_path to allow absolute paths\n",
4223 if (!st)
return AVERROR(ENOMEM);
4226 if (!sc)
return AVERROR(ENOMEM);
4231 c->trak_index = st->
index;
4267 if (
c->enable_drefs) {
4270 "stream %d, error opening alias: path='%s', dir='%s', "
4271 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
4276 "Skipped opening external track: "
4277 "stream %d, alias: path='%s', dir='%s', "
4278 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d."
4279 "Set enable_drefs to allow this.\n",
4296 #if FF_API_R_FRAME_RATE
4312 #if CONFIG_H261_DECODER
4315 #if CONFIG_H263_DECODER
4318 #if CONFIG_MPEG4_DECODER
4348 c->itunes_metadata = 1;
4350 c->itunes_metadata = 0;
4364 if (
count > UINT_MAX /
sizeof(*
c->meta_keys) - 1) {
4366 "The 'keys' atom with the invalid key count: %"PRIu32
"\n",
count);
4370 c->meta_keys_count =
count + 1;
4371 c->meta_keys =
av_mallocz(
c->meta_keys_count *
sizeof(*
c->meta_keys));
4380 "The key# %"PRIu32
" in meta has invalid size:"
4381 "%"PRIu32
"\n",
i, key_size);
4389 if (!
c->meta_keys[
i])
4406 if (
c->fc->nb_streams < 1)
4408 st =
c->fc->streams[
c->fc->nb_streams-1];
4411 for (
i = 0;
i < 3;
i++) {
4426 if (
tag ==
MKTAG(
'm',
'e',
'a',
'n'))
4428 else if (
tag ==
MKTAG(
'n',
'a',
'm',
'e'))
4430 else if (
tag ==
MKTAG(
'd',
'a',
't',
'a') &&
len > 4) {
4453 if (mean &&
key &&
val) {
4454 if (strcmp(
key,
"iTunSMPB") == 0) {
4455 int priming, remainder,
samples;
4456 if(sscanf(
val,
"%*X %X %X %X", &priming, &remainder, &
samples) == 3){
4457 if(priming>0 && priming<16384)
4461 if (strcmp(
key,
"cdec") != 0) {
4468 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
4480 while (atom.
size > 8) {
4486 if (
tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
4496 #define IS_MATRIX_IDENT(matrix) \
4497 ( (matrix)[0][0] == (1 << 16) && \
4498 (matrix)[1][1] == (1 << 16) && \
4499 (matrix)[2][2] == (1 << 30) && \
4500 !(matrix)[0][1] && !(matrix)[0][2] && \
4501 !(matrix)[1][0] && !(matrix)[1][2] && \
4502 !(matrix)[2][0] && !(matrix)[2][1])
4509 int display_matrix[3][3];
4510 int res_display_matrix[3][3] = { { 0 } };
4516 if (
c->fc->nb_streams < 1)
4518 st =
c->fc->streams[
c->fc->nb_streams-1];
4554 for (
i = 0;
i < 3;
i++) {
4566 for (
i = 0;
i < 3;
i++) {
4567 const int sh[3] = { 16, 16, 30 };
4568 for (j = 0; j < 3; j++) {
4569 for (e = 0; e < 3; e++) {
4570 res_display_matrix[
i][j] +=
4571 ((int64_t) display_matrix[
i][e] *
4572 c->movie_display_matrix[e][j]) >> sh[e];
4586 for (
i = 0;
i < 3;
i++)
4587 for (j = 0; j < 3; j++)
4593 char rotate_buf[64];
4606 double disp_transform[2];
4608 for (
i = 0;
i < 2;
i++)
4612 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
4613 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
4614 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
4616 disp_transform[0] / disp_transform[1],
4635 for (
i = 0;
i <
c->trex_count;
i++)
4636 if (
c->trex_data[
i].track_id == track_id) {
4637 trex = &
c->trex_data[
i];
4644 c->fragment.found_tfhd = 1;
4662 if (frag_stream_info)
4673 num = atom.
size / 4;
4678 c->chapter_tracks = new_tracks;
4679 c->nb_chapter_tracks = num;
4692 if ((uint64_t)
c->trex_count+1 >= UINT_MAX /
sizeof(*
c->trex_data))
4695 sizeof(*
c->trex_data))) < 0) {
4702 trex = &
c->trex_data[
c->trex_count++];
4720 int64_t base_media_decode_time;
4722 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
4723 if (
c->fc->streams[
i]->id == frag->
track_id) {
4724 st =
c->fc->streams[
i];
4744 if (frag_stream_info)
4745 frag_stream_info->
tfdt_dts = base_media_decode_time;
4759 int data_offset = 0;
4760 unsigned entries, first_sample_flags = frag->
flags;
4763 int next_frag_index = -1, index_entry_pos;
4764 size_t requested_size;
4765 size_t old_ctts_allocated_size;
4774 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
4775 if (
c->fc->streams[
i]->id == frag->
track_id) {
4776 st =
c->fc->streams[
i];
4795 for (
i =
c->frag_index.current + 1; i < c->frag_index.nb_items;
i++) {
4797 if (frag_stream_info && frag_stream_info->
index_entry >= 0) {
4798 next_frag_index =
i;
4803 av_assert0(index_entry_pos <= st->nb_index_entries);
4816 if (frag_stream_info)
4824 ", using it for pts\n",
pts);
4829 ", using it for dts\n",
pts);
4835 ", using it for pts\n",
pts);
4839 ", using it for dts\n", dts);
4843 ", using it for dts\n", dts);
4848 ", using it for dts\n", dts);
4884 if (index_entry_pos < st->nb_index_entries) {
4890 memmove(sc->
ctts_data + index_entry_pos + entries,
4893 if (index_entry_pos < sc->current_sample) {
4902 if (frag_stream_info)
4905 if (index_entry_pos > 0)
4909 unsigned sample_size = frag->
size;
4910 int sample_flags =
i ? frag->
flags : first_sample_flags;
4911 unsigned sample_duration = frag->
duration;
4912 unsigned ctts_duration = 0;
4914 int index_entry_flags = 0;
4925 dts -= ctts_duration;
4930 "pts %"PRId64
" calculated dts %"PRId64
4931 " sc->dts_shift %d ctts.duration %d"
4932 " sc->time_offset %"PRId64
4933 " flags & MOV_TRUN_SAMPLE_CTS %d\n",
4952 if (prev_dts >= dts)
4965 av_log(
c->fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
4966 "size %u, distance %d, keyframe %d\n", st->
index,
4969 dts += sample_duration;
4973 if (sample_duration <= INT64_MAX - sc->duration_for_fps &&
4980 if (frag_stream_info)
4985 int gap = entries -
i;
4990 memmove(sc->
ctts_data + index_entry_pos,
4997 if (index_entry_pos < sc->current_sample) {
5007 if (index_entry_pos > 0)
5010 if (prev_dts < st->index_entries[
i].timestamp)
5039 unsigned i, j, track_id, item_count;
5054 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
5055 if (
c->fc->streams[
i]->id == track_id) {
5056 st =
c->fc->streams[
i];
5069 if (timescale.
den <= 0) {
5086 for (
i = 0;
i < item_count;
i++) {
5091 if (
size & 0x80000000) {
5100 if (frag_stream_info)
5101 frag_stream_info->
sidx_pts = timestamp;
5114 for (
i = 0;
i <
c->frag_index.nb_items;
i++) {
5120 ref_st =
c->fc->streams[j];
5126 if (ref_st)
for (
i = 0;
i <
c->fc->nb_streams;
i++) {
5127 st =
c->fc->streams[
i];
5134 c->frag_index.complete = 1;
5155 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
5169 long cmov_len, moov_len;
5183 cmov_len = atom.
size - 6 * 4;
5195 goto free_and_return;
5198 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
5199 goto free_and_return;
5201 goto free_and_return;
5204 atom.
size = moov_len;
5221 int64_t elst_entry_size;
5223 if (
c->fc->nb_streams < 1 ||
c->ignore_editlist)
5225 sc =
c->fc->streams[
c->fc->nb_streams-1]->priv_data;
5232 elst_entry_size =
version == 1 ? 20 : 12;
5233 if (atom.
size != edit_count * elst_entry_size) {
5235 av_log(
c->fc,
AV_LOG_ERROR,
"Invalid edit list entry_count: %d for elst atom of size: %"PRId64
" bytes.\n",
5236 edit_count, atom.
size + 8);
5239 edit_count = atom.
size / elst_entry_size;
5240 if (edit_count * elst_entry_size != atom.
size) {
5274 if (e->
time < 0 && e->
time != -1 &&
5276 av_log(
c->fc,
AV_LOG_ERROR,
"Track %d, edit %d: Invalid edit list media time=%"PRId64
"\n",
5277 c->fc->nb_streams-1,
i, e->
time);
5290 if (
c->fc->nb_streams < 1)
5292 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5302 if (
c->fc->nb_streams < 1)
5304 st =
c->fc->streams[
c->fc->nb_streams - 1];
5306 if (atom.
size < 4) {
5330 if (
c->fc->nb_streams < 1)
5332 st =
c->fc->streams[
c->fc->nb_streams - 1];
5334 if (atom.
size < 5) {
5374 if (
c->fc->nb_streams < 1)
5377 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5379 if (atom.
size < 5) {
5395 for (
i = 0;
i < 3;
i++) {
5414 const int mapping[3] = {1, 2, 0};
5415 const int chroma_den = 50000;
5416 const int luma_den = 10000;
5419 if (
c->fc->nb_streams < 1)
5422 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5424 if (atom.
size < 24) {
5433 for (
i = 0;
i < 3;
i++) {
5434 const int j = mapping[
i];
5455 if (
c->fc->nb_streams < 1)
5458 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5460 if (atom.
size < 5) {
5486 if (
c->fc->nb_streams < 1)
5489 sc =
c->fc->streams[
c->fc->nb_streams - 1]->priv_data;
5491 if (atom.
size < 4) {
5513 if (
c->fc->nb_streams < 1)
5516 st =
c->fc->streams[
c->fc->nb_streams - 1];
5519 if (atom.
size < 5) {
5555 uint32_t l = 0, t = 0,
r = 0,
b = 0;
5556 uint32_t
tag, padding = 0;
5559 if (
c->fc->nb_streams < 1)
5562 st =
c->fc->streams[
c->fc->nb_streams - 1];
5565 if (atom.
size < 8) {
5571 if (size <= 12 || size > atom.
size)
5575 if (
tag !=
MKTAG(
's',
'v',
'h',
'd')) {
5593 if (
tag !=
MKTAG(
'p',
'r',
'o',
'j')) {
5603 if (
tag !=
MKTAG(
'p',
'r',
'h',
'd')) {
5633 case MKTAG(
'c',
'b',
'm',
'p'):
5637 "Unsupported cubemap layout %d\n",
layout);
5643 case MKTAG(
'e',
'q',
'u',
'i'):
5649 if (
b >= UINT_MAX - t ||
r >= UINT_MAX - l) {
5651 "Invalid bounding rectangle coordinates "
5652 "%"PRIu32
",%"PRIu32
",%"PRIu32
",%"PRIu32
"\n", l, t,
r,
b);
5656 if (l || t ||
r ||
b)
5755 static const uint8_t uuid_isml_manifest[] = {
5756 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
5757 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
5759 static const uint8_t uuid_xmp[] = {
5760 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
5761 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
5763 static const uint8_t uuid_spherical[] = {
5764 0xff, 0xcc, 0x82, 0x63, 0xf8, 0x55, 0x4a, 0x93,
5765 0x88, 0x14, 0x58, 0x7a, 0x02, 0x52, 0x1f, 0xdd,
5768 if (atom.
size <
sizeof(uuid) || atom.
size >=
FFMIN(INT_MAX, SIZE_MAX))
5771 if (
c->fc->nb_streams < 1)
5773 st =
c->fc->streams[
c->fc->nb_streams - 1];
5779 }
else if (
ret !=
sizeof(uuid)) {
5782 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
5785 size_t len = atom.
size -
sizeof(uuid);
5807 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
5808 ptr +=
sizeof(
"systemBitrate=\"") - 1;
5809 c->bitrates_count++;
5810 c->bitrates =
av_realloc_f(
c->bitrates,
c->bitrates_count,
sizeof(*
c->bitrates));
5812 c->bitrates_count = 0;
5817 ret = strtol(ptr, &endptr, 10);
5818 if (
ret < 0 || errno || *endptr !=
'"') {
5819 c->bitrates[
c->bitrates_count - 1] = 0;
5821 c->bitrates[
c->bitrates_count - 1] =
ret;
5826 }
else if (!memcmp(uuid, uuid_xmp,
sizeof(uuid))) {
5828 size_t len = atom.
size -
sizeof(uuid);
5829 if (
c->export_xmp) {
5851 }
else if (!memcmp(uuid, uuid_spherical,
sizeof(uuid))) {
5852 size_t len = atom.
size -
sizeof(uuid);
5877 && !memcmp(content,
"Anevia\x1A\x1A", 8)
5892 if (
c->fc->nb_streams < 1)
5894 st =
c->fc->streams[
c->fc->nb_streams - 1];
5899 case MKTAG(
'e',
'n',
'c',
'v'):
5900 case MKTAG(
'e',
'n',
'c',
'a'):
5905 "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
5917 "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
5939 if (frag_stream_info) {
5940 for (
i = 0;
i <
c->fc->nb_streams;
i++) {
5941 if (
c->fc->streams[
i]->id == frag_stream_info->
id) {
5942 st =
c->fc->streams[
i];
5946 if (
i ==
c->fc->nb_streams)
5952 if (!(*sc)->cenc.default_encrypted_sample)
5963 if (
c->fc->nb_streams < 1)
5965 st =
c->fc->streams[
c->fc->nb_streams - 1];
5968 if (!(*sc)->cenc.encryption_index) {
5970 if (!(*sc)->cenc.default_encrypted_sample)
5973 if (!(*sc)->cenc.encryption_index)
5977 *encryption_index = (*sc)->cenc.encryption_index;
5985 unsigned int subsample_count;
6006 if (use_subsamples) {
6008 av_free((*sample)->subsamples);
6009 (*sample)->subsamples =
av_mallocz_array(subsample_count,
sizeof(*subsamples));
6010 if (!(*sample)->subsamples) {
6017 (*sample)->subsamples[
i].bytes_of_clear_data =
avio_rb16(pb);
6018 (*sample)->subsamples[
i].bytes_of_protected_data =
avio_rb32(pb);
6027 (*sample)->subsample_count = subsample_count;
6038 int use_subsamples,
ret;
6039 unsigned int sample_count,
i, alloc_size = 0;
6055 if (sample_count >= INT_MAX /
sizeof(*encrypted_samples))
6058 for (
i = 0;
i < sample_count;
i++) {
6059 unsigned int min_samples =
FFMIN(
FFMAX(
i + 1, 1024 * 1024), sample_count);
6061 min_samples *
sizeof(*encrypted_samples));
6062 if (encrypted_samples) {
6091 size_t sample_count, sample_info_size,
i;
6093 unsigned int alloc_size = 0;
6102 if (sample_count >= INT_MAX /
sizeof(*encrypted_samples))
6108 av_log(
c->fc,
AV_LOG_INFO,
"Failed to seek for auxiliary info, will only parse senc atoms for encryption info\n");
6113 unsigned int min_samples =
FFMIN(
FFMAX(
i + 1, 1024 * 1024), sample_count);
6115 min_samples *
sizeof(*encrypted_samples));
6116 if (!encrypted_samples) {
6141 for (;
i > 0;
i--) {
6156 const unsigned int block_size = 1024 * 1024;
6158 unsigned int alloc_size = 0,
offset = 0;
6160 unsigned int new_size =
6161 alloc_size >= INT_MAX - block_size ? INT_MAX : alloc_size + block_size;
6186 unsigned int sample_count, aux_info_type, aux_info_param;
6212 if (aux_info_param != 0) {
6218 if ((aux_info_type ==
MKBETAG(
'c',
'e',
'n',
'c') ||
6219 aux_info_type ==
MKBETAG(
'c',
'e',
'n',
's') ||
6220 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
'1') ||
6221 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
's')) &&
6222 aux_info_param == 0) {
6255 uint64_t *auxiliary_offsets;
6259 unsigned int version, entry_count, aux_info_type, aux_info_param;
6260 unsigned int alloc_size = 0;
6286 if (aux_info_param != 0) {
6292 if ((aux_info_type ==
MKBETAG(
'c',
'e',
'n',
'c') ||
6293 aux_info_type ==
MKBETAG(
'c',
'e',
'n',
's') ||
6294 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
'1') ||
6295 aux_info_type ==
MKBETAG(
'c',
'b',
'c',
's')) &&
6296 aux_info_param == 0) {
6309 if (entry_count >= INT_MAX /
sizeof(*auxiliary_offsets))
6313 unsigned int min_offsets =
FFMIN(
FFMAX(
i + 1, 1024), entry_count);
6316 min_offsets *
sizeof(*auxiliary_offsets));
6317 if (!auxiliary_offsets) {
6328 if (
c->frag_index.current >= 0) {
6353 uint8_t *side_data, *extra_data, *old_side_data;
6354 size_t side_data_size;
6355 int ret = 0, old_side_data_size;
6356 unsigned int version, kid_count, extra_data_size, alloc_size = 0;
6358 if (
c->fc->nb_streams < 1)
6360 st =
c->fc->streams[
c->fc->nb_streams-1];
6378 if (kid_count >= INT_MAX /
sizeof(*key_ids)) {
6383 for (
unsigned int i = 0;
i < kid_count && !pb->
eof_reached;
i++) {
6384 unsigned int min_kid_count =
FFMIN(
FFMAX(
i + 1, 1024), kid_count);
6386 min_kid_count *
sizeof(*key_ids));
6391 info->key_ids = key_ids;
6394 if (!
info->key_ids[
i]) {
6398 info->num_key_ids =
i + 1;
6420 info->data = extra_data;
6421 info->data_size = extra_data_size;
6425 if (old_side_data) {
6427 if (old_init_info) {
6435 info = old_init_info;
6449 side_data, side_data_size);
6463 if (
c->fc->nb_streams < 1)
6465 st =
c->fc->streams[
c->fc->nb_streams-1];
6469 av_log(
c->fc,
AV_LOG_ERROR,
"schm boxes are only supported in first sample descriptor\n");
6493 unsigned int version, pattern, is_protected, iv_size;
6495 if (
c->fc->nb_streams < 1)
6497 st =
c->fc->streams[
c->fc->nb_streams-1];
6546 if (iv_size != 8 && iv_size != 16) {
6566 if (
c->fc->nb_streams < 1)
6568 st =
c->fc->streams[
c->fc->nb_streams-1];
6570 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 42)
6621 if (!
sample->subsample_count)
6628 for (
i = 0;
i <
sample->subsample_count;
i++)
6630 if (
sample->subsamples[
i].bytes_of_clear_data +
sample->subsamples[
i].bytes_of_protected_data >
size) {
6637 size -=
sample->subsamples[
i].bytes_of_clear_data;
6641 input +=
sample->subsamples[
i].bytes_of_protected_data;
6642 size -=
sample->subsamples[
i].bytes_of_protected_data;
6658 int encrypted_index,
ret;
6661 encrypted_index = current_index;
6662 encryption_index =
NULL;
6663 if (frag_stream_info) {
6667 encrypted_index = current_index - frag_stream_info->
index_entry;
6677 if (encryption_index) {
6692 }
else if (encrypted_index >= 0 && encrypted_index < encryption_index->nb_encrypted_samples) {
6725 if (
c->fc->nb_streams < 1)
6727 st =
c->fc->streams[
c->fc->nb_streams-1];
6729 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 11)
6769 unsigned format_info;
6770 int channel_assignment, channel_assignment1, channel_assignment2;
6773 if (
c->fc->nb_streams < 1)
6775 st =
c->fc->streams[
c->fc->nb_streams-1];
6782 ratebits = (format_info >> 28) & 0xF;
6783 channel_assignment1 = (format_info >> 15) & 0x1F;
6784 channel_assignment2 = format_info & 0x1FFF;
6785 if (channel_assignment2)
6786 channel_assignment = channel_assignment2;
6788 channel_assignment = channel_assignment1;
6806 if (
c->fc->nb_streams < 1)
6808 st =
c->fc->streams[
c->fc->nb_streams-1];
6810 if ((uint64_t)atom.
size > (1<<30) || atom.
size < 4)
6822 dovi->
dv_level = (buf >> 3) & 0x3f;
6826 if (atom.
size >= 24) {
6843 "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
6844 dovi->dv_version_major, dovi->dv_version_minor,
6845 dovi->dv_profile, dovi->dv_level,
6846 dovi->rpu_present_flag,
6847 dovi->el_present_flag,
6848 dovi->bl_present_flag,
6849 dovi->dv_bl_signal_compatibility_id
6957 int64_t total_size = 0;
6961 if (
c->atom_depth > 10) {
6968 atom.
size = INT64_MAX;
6973 if (atom.
size >= 8) {
6976 if (((
a.type ==
MKTAG(
'f',
'r',
'e',
'e') &&
c->moov_retry) ||
6977 a.type ==
MKTAG(
'h',
'o',
'o',
'v')) &&
6981 uint32_t *
type = (uint32_t *)buf + 1;
6988 a.type =
MKTAG(
'm',
'o',
'o',
'v');
6991 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
6994 if (
a.type ==
MKTAG(
't',
'r',
'a',
'k') ||
a.type ==
MKTAG(
'm',
'd',
'a',
't'))
7003 if (
a.size == 1 && total_size + 8 <= atom.
size) {
7011 a.size = atom.
size - total_size + 8;
7031 if (!
parse &&
c->found_hdlr_mdta &&
7033 a.type ==
MKTAG(
'k',
'e',
'y',
's') &&
7034 c->meta_keys_count == 0) {
7048 if (
c->found_moov &&
c->found_mdat &&
7052 c->next_root_atom = start_pos +
a.size;
7059 else if (
left < 0) {
7061 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
7062 (
char*)&
a.type, -
left);
7067 total_size +=
a.size;
7070 if (total_size < atom.
size && atom.
size < 0x7ffff)
7082 int moov_offset = -1;
7093 case MKTAG(
'm',
'o',
'o',
'v'):
7094 moov_offset =
offset + 4;
7095 case MKTAG(
'm',
'd',
'a',
't'):
7096 case MKTAG(
'p',
'n',
'o',
't'):
7097 case MKTAG(
'u',
'd',
't',
'a'):
7098 case MKTAG(
'f',
't',
'y',
'p'):
7104 }
else if (
tag ==
MKTAG(
'f',
't',
'y',
'p') &&
7108 score =
FFMAX(score, 5);
7115 case MKTAG(
'e',
'd',
'i',
'w'):
7116 case MKTAG(
'w',
'i',
'd',
'e'):
7117 case MKTAG(
'f',
'r',
'e',
'e'):
7118 case MKTAG(
'j',
'u',
'n',
'k'):
7119 case MKTAG(
'p',
'i',
'c',
't'):
7123 case MKTAG(0x82,0x82,0x7f,0x7d):
7124 case MKTAG(
's',
'k',
'i',
'p'):
7125 case MKTAG(
'u',
'u',
'i',
'd'):
7126 case MKTAG(
'p',
'r',
'f',
'l'):
7173 for (
i = 0;
i <
s->nb_streams;
i++)
7174 if (
s->streams[
i]->id == chapter_track) {
7215 if (end < sample->timestamp) {
7229 title_len = 2*
len + 1;
7242 else if (
ch == 0xfffe)
7246 if (
len == 1 ||
len == 2)
7281 int hh, mm,
ss, ff, drop;
7294 hh, mm,
ss, drop ?
';' :
':', ff);
7332 for (
i = 0;
i < (*index)->nb_encrypted_samples;
i++) {
7335 av_freep(&(*index)->encrypted_samples);
7336 av_freep(&(*index)->auxiliary_info_sizes);
7337 av_freep(&(*index)->auxiliary_offsets);
7346 for (
i = 0;
i <
s->nb_streams;
i++) {
7428 for (
i = 0;
i <
s->nb_streams;
i++) {
7444 for (
i = 0;
i <
s->nb_streams;
i++) {
7463 unsigned track_id, item_count;
7475 for (
i = 0;
i < item_count;
i++) {
7497 if (frag_stream_info &&
7501 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
7503 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
7505 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
7520 if ((seek_ret =
avio_seek(
f, stream_size - 4, SEEK_SET)) < 0) {
7525 if (mfra_size < 0 || mfra_size > stream_size) {
7529 if ((seek_ret =
avio_seek(
f, -mfra_size, SEEK_CUR)) < 0) {
7549 seek_ret =
avio_seek(
f, original_pos, SEEK_SET);
7552 "failed to seek back after looking for mfra\n");
7578 atom.
size = INT64_MAX;
7599 for (
i = 0;
i <
s->nb_streams;
i++)
7600 if (
s->streams[
i]->codecpar->codec_tag ==
AV_RL32(
"tmcd")) {
7602 }
else if (
s->streams[
i]->codecpar->codec_tag ==
AV_RL32(
"rtmd")) {
7608 for (
i = 0;
i <
s->nb_streams;
i++) {
7613 int tmcd_st_id = -1;
7615 for (j = 0; j <
s->nb_streams; j++)
7619 if (tmcd_st_id < 0 || tmcd_st_id ==
i)
7628 for (
i = 0;
i <
s->nb_streams;
i++) {
7658 for (
i = 0;
i <
s->nb_streams;
i++) {
7674 for (
i = 0;
i <
s->nb_streams;
i++) {
7692 s->streams[
i]->codecpar->bit_rate = mov->
bitrates[
i];
7698 for (
i = 0;
i <
s->nb_streams;
i++) {
7772 int64_t best_dts = INT64_MAX;
7774 for (
i = 0;
i <
s->nb_streams;
i++) {
7807 if (
index >= 0 && index < mov->frag_index.nb_items)
7809 if (
avio_seek(
s->pb, target, SEEK_SET) != target) {
7817 if (index < mov->frag_index.nb_items &&
7849 if (extradata_size > 0 && extradata) {
7855 memcpy(side, extradata, extradata_size);
7867 int64_t current_index;
7891 if (ret64 !=
sample->pos) {
7923 #if CONFIG_DV_DEMUXER
7965 uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3;
8036 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
8081 if (stream_index >=
s->nb_streams)
8084 st =
s->streams[stream_index];
8089 if (
mc->seek_individually) {
8093 for (
i = 0;
i <
s->nb_streams;
i++) {
8099 if (stream_index ==
i)
8106 for (
i = 0;
i <
s->nb_streams;
i++) {
8126 #define OFFSET(x) offsetof(MOVContext, x)
8127 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
8129 {
"use_absolute_path",
8130 "allow using absolute path when opening alias, this is a possible security issue",
8133 {
"seek_streams_individually",
8134 "Seek each stream individually to the closest point",
8139 {
"advanced_editlist",
8140 "Modify the AVIndex according to the editlists. Use this option to decode in the order specified by the edits.",
8146 "use mfra for fragment timestamps",
8151 FLAGS,
"use_mfra_for" },
8153 FLAGS,
"use_mfra_for" },
8155 FLAGS,
"use_mfra_for" },
8156 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
8158 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
8160 {
"activation_bytes",
"Secret bytes for Audible AAX files",
OFFSET(activation_bytes),
8162 {
"audible_fixed_key",
8163 "Fixed key used for handling Audible AAX files",
OFFSET(audible_fixed_key),
8168 {.i64 = 0}, 0, 1,
FLAGS },
8181 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
8185 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v",
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
struct MOVStreamContext::@257 cenc
unsigned int ctts_allocated_size
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_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FF_ENABLE_DEPRECATION_WARNINGS
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define MOV_TFHD_DEFAULT_FLAGS
#define PUT_UTF8(val, tmp, PUT_BYTE)
#define AV_TIMECODE_STR_SIZE
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
int16_t audio_cid
stsd audio compression id
AVSphericalProjection
Projection of the video surface(s) on a sphere.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@ AV_CODEC_ID_ADPCM_IMA_QT
#define MOV_TRUN_SAMPLE_FLAGS
unsigned int nb_chapter_tracks
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define MOV_TKHD_FLAG_ENABLED
enum AVMediaType codec_type
General type of the encoded data.
enum AVSphericalProjection projection
Projection type.
uint8_t ** extradata
extradata array (and size) for multiple stsd
static const AVClass mov_class
uint32_t bound_bottom
Distance from the bottom edge.
static int mov_read_targa_y216(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FFSWAP(type, a, b)
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static double cb(void *priv, double x, double y)
This struct describes the properties of an encoded stream.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
enum AVColorSpace color_space
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
#define AVERROR_EOF
End of file.
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static const AVOption mov_options[]
static int mov_codec_id(AVStream *st, uint32_t format)
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
static int mov_read_alac(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int test_same_origin(const char *src, const char *ref)
uint64_t base_data_offset
#define IS_MATRIX_IDENT(matrix)
static void mov_update_dts_shift(MOVStreamContext *sc, int duration, void *logctx)
AVSphericalMapping * spherical
unsigned MaxCLL
Max content light level (cd/m^2).
static av_cold int end(AVCodecContext *avctx)
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
void av_encryption_init_info_free(AVEncryptionInitInfo *info)
Frees the given encryption init info object.
static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@ AV_PKT_DATA_ENCRYPTION_INFO
This side data contains encryption info for how to decrypt the packet.
int found_moov
'moov' atom has been found
static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, enum AVCodecID codec_id)
@ AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
unsigned int rap_group_count
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int found_mdat
'mdat' atom has been found
uint32_t crypt_byte_block
Only used for pattern encryption.
static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time, void *logctx)
static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int seek_preroll
Audio only.
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int * bitrates
bitrates read before streams creation
static int truehd_channels(int chanmap)
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVRational avg_frame_rate
Average framerate.
static int mov_read_colr(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 uint32_t yuv_to_rgba(uint32_t ycbcr)
@ AV_PKT_DATA_ENCRYPTION_INIT_INFO
This side data is encryption initialization data.
static int mov_parse_auxiliary_info(MOVContext *c, MOVStreamContext *sc, AVIOContext *pb, MOVEncryptionIndex *encryption_index)
static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
static int mov_read_saio(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index)
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
#define AV_LOG_VERBOSE
Detailed information.
const AVCodecTag ff_codec_wav_tags[]
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).
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new samples
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
@ AV_SPHERICAL_EQUIRECTANGULAR_TILE
Video represents a portion of a sphere mapped on a flat surface using equirectangular projection.
static void mov_current_sample_set(MOVStreamContext *sc, int current_sample)
#define AV_PKT_FLAG_DISPOSABLE
Flag is used to indicate packets that contain frames that can be discarded by the decoder.
int buf_size
Size of buf except extra allocated bytes.
@ FLAC_METADATA_TYPE_STREAMINFO
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FFNABS(a)
Negative Absolute value.
@ AV_PKT_DATA_SPHERICAL
This side data should be associated with a video stream and corresponds to the AVSphericalMapping str...
static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int sample_count
@ AV_SPHERICAL_EQUIRECTANGULAR
Video represents a sphere mapped on a flat surface using equirectangular projection.
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.
int64_t avio_size(AVIOContext *s)
Get the filesize.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
struct AVAESCTR * aes_ctr
static int cenc_filter(MOVContext *mov, AVStream *st, MOVStreamContext *sc, AVPacket *pkt, int current_index)
static int mov_read_sdtp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define OPUS_SEEK_PREROLL_MS
static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ff_mov_lang_to_iso639(unsigned code, char to[4])
AVInputFormat ff_mov_demuxer
static void skip_bits(GetBitContext *s, int n)
enum AVColorPrimaries color_primaries
uint32_t scheme
The fourcc encryption scheme, in big-endian byte order.
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
uint32_t skip_byte_block
Only used for pattern encryption.
static int aax_filter(uint8_t *input, int size, MOVContext *c)
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
const char * av_color_space_name(enum AVColorSpace space)
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.
AVMasteringDisplayMetadata * mastering
static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static MOVFragmentStreamInfo * get_current_frag_stream_info(MOVFragmentIndex *frag_index)
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
static av_cold int read_close(AVFormatContext *ctx)
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define MOV_TRUN_SAMPLE_DURATION
static double val(void *priv, double ch)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
uint8_t * iv
The initialization vector.
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t duration
Decoding: duration of the stream, in stream time base.
#define ss(width, name, subs,...)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static int update_frag_index(MOVContext *c, int64_t offset)
size_t auxiliary_info_sample_count
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
static int mov_read_saiz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
#define MOV_TRUN_DATA_OFFSET
AVEncryptionInfo * av_encryption_info_clone(const AVEncryptionInfo *info)
Allocates an AVEncryptionInfo structure with a copy of the given data.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVColorTransferCharacteristic color_trc
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void mov_free_encryption_index(MOVEncryptionIndex **index)
#define AV_CH_LOW_FREQUENCY
uint64_t * auxiliary_offsets
Absolute seek position.
int dts_shift
dts shift when ctts is negative
@ AV_PKT_DATA_AUDIO_SERVICE_TYPE
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
int frame_size
Audio only.
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.
static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static void rotate(const float rot_mat[3][3], float *vec)
Rotate vector with given rotation matrix.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
#define FF_MOV_FLAG_MFRA_PTS
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
static int mov_read_coll(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVEncryptionIndex * encryption_index
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_TFHD_DEFAULT_BASE_IS_MOOF
@ AV_PKT_DATA_STEREO3D
This side data should be associated with a video stream and contains Stereoscopic 3D information in f...
#define MOV_TFHD_DEFAULT_DURATION
#define ALAC_EXTRADATA_SIZE
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
@ AV_PKT_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata (based on SMPTE-2086:2014).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
struct AVAES * aes_decrypt
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
uint32_t bound_top
Distance from the top edge.
#define MOV_TRUN_FIRST_SAMPLE_FLAGS
static void mov_estimate_video_delay(MOVContext *c, AVStream *st)
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
Process a buffer using a previously initialized context.
int64_t min_corrected_pts
minimum Composition time shown by the edits excluding empty edits.
@ AV_PKT_DATA_ICC_PROFILE
ICC profile data consisting of an opaque octet buffer following the format described by ISO 15076-1.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVStreamParseType need_parsing
static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static AVIndexEntry * mov_find_next_sample(AVFormatContext *s, AVStream **st)
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int(* parse)(MOVContext *ctx, AVIOContext *pb, MOVAtom atom)
static int mov_try_read_block(AVIOContext *pb, size_t size, uint8_t **data)
Tries to read the given number of bytes from the stream and puts it in a newly allocated buffer.
static int search_frag_timestamp(MOVFragmentIndex *frag_index, AVStream *st, int64_t timestamp)
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
#define MAX_REORDER_DELAY
AVEncryptionInfo ** encrypted_samples
static int mov_read_close(AVFormatContext *s)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
Compute codec id for 'lpcm' tag.
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_sample_encryption_info(MOVContext *c, AVIOContext *pb, MOVStreamContext *sc, AVEncryptionInfo **sample, int use_subsamples)
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&HAVE_MMX) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
unsigned int keyframe_count
@ AVDISCARD_ALL
discard all
#define av_realloc_f(p, o, n)
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVIndexRange * index_ranges
static void set_frag_stream(MOVFragmentIndex *frag_index, int id)
static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_realloc_extradata(AVCodecParameters *par, MOVAtom atom)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static uint64_t truehd_layout(int chanmap)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
uint8_t dv_bl_signal_compatibility_id
This describes info used to initialize an encryption key system.
static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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.
Rational number (pair of numerator and denominator).
static int mov_probe(const AVProbeData *p)
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.
@ AV_CODEC_ID_DVD_SUBTITLE
int64_t time_offset
time offset of the edit list entries
static int mov_read_smdm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
const char * av_default_item_name(void *ptr)
Return the context name.
uint64_t avio_rb64(AVIOContext *s)
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.
MOVIndexRange * current_index_range
static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref)
This structure contains the data a format has to probe a file.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
static int mov_read_schm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FLAC_STREAMINFO_SIZE
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
#define FF_MOV_FLAG_MFRA_DTS
#define MOV_SAMPLE_DEPENDENCY_NO
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_CH_FRONT_CENTER
static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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.
#define MOV_TFHD_BASE_DATA_OFFSET
const AVCodecTag ff_codec_movdata_tags[]
static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb, int codec_tag, int format, int64_t size)
@ AV_CODEC_ID_GSM
as in Berlin toast format
int64_t nb_frames
number of frames in this stream if known or 0
AVCodecID
Identify the syntax and semantics of the bitstream.
static int should_retry(AVIOContext *pb, int error_code)
int extradata_size
Size of the extradata content in bytes.
@ AV_AUDIO_SERVICE_TYPE_KARAOKE
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
DVDemuxContext * dv_demux
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t auxiliary_info_default_size
static int mov_read_header(AVFormatContext *s)
const AVCodecTag ff_codec_movvideo_tags[]
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
unsigned int avio_rl32(AVIOContext *s)
@ AVDISCARD_NONKEY
discard all frames except keyframes
static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
@ AV_SPHERICAL_CUBEMAP
Video frame is split into 6 faces of a cube, and arranged on a 3x2 layout.
unsigned int avio_rb24(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex **encryption_index, MOVStreamContext **sc)
Gets the current encryption info and associated current stream context.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_current_sample_dec(MOVStreamContext *sc)
uint8_t * av_stream_get_side_data(const AVStream *stream, enum AVPacketSideDataType type, int *size)
Get side information from stream.
uint32_t bound_right
Distance from the right edge.
unsigned int stsz_sample_size
always contains sample size from stsz atom
#define FF_MOV_FLAG_MFRA_AUTO
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
static int64_t start_time
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
static av_const double hypot(double x, double y)
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static AVRational av_make_q(int num, int den)
Create an AVRational.
static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int ff_get_qtpalette(int codec_id, AVIOContext *pb, uint32_t *palette)
Retrieve the palette (or "color table" in QuickTime terms), either from the video sample description,...
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define MKBETAG(a, b, c, d)
AVContentLightMetadata * coll
static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add index entry with the given values, to the end of st->index_entries.
static void mov_current_sample_inc(MOVStreamContext *sc)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static int64_t get_frag_time(MOVFragmentIndex *frag_index, int index, int track_id)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
static void fix_timescale(MOVContext *c, MOVStreamContext *sc)
int avio_r8(AVIOContext *s)
uint32_t padding
Number of pixels to pad from the edge of each cube face.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@ AV_TIMECODE_FLAG_24HOURSMAX
timecode wraps after 24 hours
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
@ AV_PKT_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
size_t auxiliary_offsets_count
int flags
A combination of AV_PKT_FLAG values.
void av_encryption_info_free(AVEncryptionInfo *info)
Frees the given encryption info object.
This file is part of FFmpeg.
MOVFragmentStreamInfo * stream_info
struct AVEncryptionInitInfo * next
An optional pointer to the next initialization info in the list.
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some input
static int mov_read_clli(MOVContext *c, AVIOContext *pb, MOVAtom atom)
MOVFragmentIndexItem * item
#define AV_LOG_INFO
Standard information.
AVEncryptionInitInfo * av_encryption_init_info_alloc(uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size)
Allocates an AVEncryptionInitInfo structure and sub-pointers to hold the given sizes.
static int mov_read_dfla(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint64_t count
number of bytes in buffer
static const MOVParseTableEntry mov_default_parse_table[]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st, uint32_t value, int flags)
static int mov_metadata_hmmt(MOVContext *c, AVIOContext *pb, unsigned len)
struct AVSHA * av_sha_alloc(void)
Allocate an AVSHA context.
static int mov_read_tenc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_stsc_index_valid(unsigned int index, unsigned int count)
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static const uint32_t mac_to_unicode[128]
unsigned int bytes_per_frame
int32_t roll
Rotation around the forward vector [-180, 180].
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void mov_fix_index(MOVContext *mov, AVStream *st)
Fix st->index_entries, so that it contains only the entries (and the entries which are needed to deco...
static int mov_read_pssh(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_rewrite_dvd_sub_extradata(AVStream *st)
#define AV_TIME_BASE
Internal time base represented as integer.
int block_align
Audio only.
#define av_malloc_array(a, b)
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
const uint16_t avpriv_ac3_channel_layout_tab[8]
Map audio coding mode (acmod) to channel layout mask.
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
MOVFragmentIndex frag_index
static int mov_read_vpcc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
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.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static void fix_frag_index_entries(MOVFragmentIndex *frag_index, int index, int id, int entries)
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
static int mov_read_mdcv(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@ AV_TIMECODE_FLAG_ALLOWNEGATIVE
negative time values are allowed
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVColorRange color_range
Video only.
#define MOV_TFHD_DEFAULT_SIZE
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static void mov_build_index(MOVContext *mov, AVStream *st)
static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
@ AVCOL_RANGE_MPEG
the normal 219*2^(n-8) "MPEG" YUV ranges
enum AVFieldOrder field_order
Video only.
static int64_t get_stream_info_time(MOVFragmentStreamInfo *frag_stream_info)
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,...
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet.
@ AV_TIMECODE_FLAG_DROPFRAME
timecode is drop frame
Undefined Behavior In the C language
static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int disposition
AV_DISPOSITION_* bit field.
int id
Format-specific stream ID.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
unsigned int nb_encrypted_samples
AVStereo3D * av_stereo3d_alloc(void)
Allocate an AVStereo3D structure and set its fields to default values.
static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
uint8_t * key_id
The ID of the key used to encrypt the packet.
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,...
int32_t pitch
Rotation around the right vector [-90, 90].
unsigned int avio_rb16(AVIOContext *s)
enum AVStereo3DType type
How views are packed within the video.
static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the "full" 16-byte iv, including the counter.
#define AV_INPUT_BUFFER_PADDING_SIZE
int pseudo_stream_id
-1 means demux all ids
static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
static int search_frag_moof_offset(MOVFragmentIndex *frag_index, int64_t offset)
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
static int mov_switch_root(AVFormatContext *s, int64_t target, int index)
This describes encryption info for a packet.
MOVEncryptionIndex * encryption_index
#define MIN_DATA_ENTRY_BOX_SIZE
int index
stream index in AVFormatContext
static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp)
static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
const AVCodecTag ff_codec_bmp_tags[]
static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int sample_size
may contain value calculated from stsd or value from stsz atom
static int mlp_samplerate(int in)
static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
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 mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt)
@ 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...
static int mov_parse_uuid_spherical(MOVStreamContext *sc, AVIOContext *pb, size_t len)
AVFormatContext * dv_fctx
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
unsigned int aax_mode
'aax' file has been detected
static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int mov_read_av1c(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int ref[MAX_W *MAX_W]
AVRational r_frame_rate
Real base framerate of the stream.
int64_t track_end
used for dts generation in fragmented movie files
MOVFragment fragment
current fragment in moof atom
int eof_reached
true if was unable to read due to error or eof
static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
unsigned int per_sample_iv_size
const AVCodecTag ff_codec_movsubtitle_tags[]
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static void export_orphan_timecode(AVFormatContext *s)
#define AV_CH_FRONT_RIGHT
static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
#define FF_DISABLE_DEPRECATION_WARNINGS
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it.
static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AVIO_FLAG_READ
read-only
AVSphericalMapping * av_spherical_alloc(size_t *size)
Allocate a AVSphericalVideo structure and initialize its fields to default values.
static int mov_read_rtmd_track(AVFormatContext *s, AVStream *st)
int bits_per_coded_sample
The number of bits per sample in the codedwords.
static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
int trak_index
Index of the current 'trak'.
static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
uint32_t bound_left
Distance from the left edge.
static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, char *dst, int dstlen)
uint8_t * auxiliary_info_sizes
int video_delay
Video only.
#define avpriv_request_sample(...)
static int read_tfra(MOVContext *mov, AVIOContext *f)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
unsigned MaxFALL
Max average light level per frame (cd/m^2).
This structure stores compressed data.
static double cr(void *priv, double x, double y)
unsigned * stps_data
partial sync sample for mpeg-2 open gop
@ AV_CODEC_ID_ADPCM_IMA_WAV
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
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.
int64_t pos
byte position in stream, -1 if unknown
uint64_t channel_layout
Audio only.
static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
#define MOV_TRUN_SAMPLE_SIZE
uint32_t tmcd_flags
tmcd track flags
static float distance(float x, float y, int band)
#define flags(name, subs,...)
int start_pad
amount of samples to skip due to enc-dec delay
AVStereo3DType
List of possible 3D Types.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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.
const AVCodecTag ff_codec_movaudio_tags[]
static int cenc_decrypt(MOVContext *c, MOVStreamContext *sc, AVEncryptionInfo *sample, uint8_t *input, int size)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
unsigned int samples_per_frame
static int mov_read_mfra(MOVContext *c, AVIOContext *f)
static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static MOVFragmentStreamInfo * get_frag_stream_info(MOVFragmentIndex *frag_index, int index, int id)
#define MOV_TRUN_SAMPLE_CTS
int initial_padding
Audio only.
static const struct ColorPrimaries color_primaries[AVCOL_PRI_NB]
static int mov_read_st3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
static int64_t mov_read_atom_into_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, AVCodecParameters *par, uint8_t *buf)
int32_t yaw
Rotation around the up vector [-180, 180].
static void mov_read_chapters(AVFormatContext *s)
AVEncryptionInfo * default_encrypted_sample
unsigned int index_entries_allocated_size
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
int64_t next_root_atom
offset of the next root atom
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
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.
#define av_fourcc2str(fourcc)
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size)
Read 'chan' tag from the input stream.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int ffindex
AVStream index.
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)