73 unsigned len,
const char *key)
77 short current, total = 0;
83 snprintf(buf,
sizeof(buf),
"%d", current);
85 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
93 unsigned len,
const char *key)
107 unsigned len,
const char *key)
116 unsigned len,
const char *key)
132 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
133 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
134 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
135 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
136 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
137 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
138 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
139 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
140 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
141 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
142 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
143 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
144 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
145 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
146 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
147 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
151 char *dst,
int dstlen)
154 char *
end = dst+dstlen-1;
157 for (i = 0; i <
len; i++) {
159 if (c < 0x80 && p < end)
220 char language[4] = { 0 };
221 char buf[200], place[100];
222 uint16_t langcode = 0;
223 double longitude, latitude, altitude;
224 const char *key =
"location";
226 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
253 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f", latitude, longitude);
258 if (*language && strcmp(language,
"und")) {
260 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
270 char key2[32], language[4] = {0};
272 const char *key =
NULL;
273 uint16_t langcode = 0;
274 uint32_t data_type = 0, str_size, str_size_alloc;
280 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
281 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
282 case MKTAG(
'X',
'M',
'P',
'_'):
283 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
284 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
285 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
287 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
288 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
289 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
291 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
292 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
293 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
295 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
297 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
299 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
301 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
302 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
303 case MKTAG(
'l',
'o',
'c',
'i'):
305 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
307 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
309 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
310 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
312 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
313 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
314 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
315 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
316 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
317 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
318 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
320 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
322 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
323 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
325 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
326 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
327 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
329 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
330 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
331 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
332 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
333 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
334 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
335 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
336 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
337 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
338 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
339 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
340 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
341 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
342 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
343 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
344 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
345 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
346 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
347 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
348 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
349 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
350 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
351 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
352 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
353 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
354 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
355 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
356 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
357 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
358 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
359 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
360 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
361 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
362 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
363 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
369 if (tag ==
MKTAG(
'd',
'a',
't',
'a') && data_size <= atom.
size) {
372 str_size = data_size - 16;
375 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
383 if (index < c->meta_keys_count) {
387 "The index of 'data' is out of range: %d >= %d.\n",
394 if (str_size > atom.
size) {
404 str_size = atom.
size;
413 if (atom.
size < 0 || str_size >= INT_MAX/2)
418 num = (data_type == 23);
419 str_size_alloc = (num ? 512 : (raw ? str_size : str_size * 2)) + 1;
425 parse(c, pb, str_size, key);
427 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
429 }
else if (data_type == 23 && str_size >= 4) {
431 if (
snprintf(str, str_size_alloc,
"%f", val) >= str_size_alloc) {
433 "Failed to store the float32 number (%f) in string.\n", val);
447 if (*language && strcmp(language,
"und")) {
448 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
451 if (!strcmp(key,
"encoder")) {
452 int major, minor, micro;
453 if (sscanf(str,
"HandBrake %d.%d.%d", &major, &minor, µ) == 3) {
460 key, str, (
char*)&atom.
type, str_size_alloc, atom.
size);
469 int i, nb_chapters, str_len,
version;
476 if ((atom.
size -= 5) < 0)
485 for (i = 0; i < nb_chapters; i++) {
492 if ((atom.
size -= 9+str_len) < 0)
504 #define MIN_DATA_ENTRY_BOX_SIZE 12
519 entries >= UINT_MAX /
sizeof(*sc->
drefs))
528 for (i = 0; i < entries; i++) {
540 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
542 uint16_t volume_len,
len;
549 volume_len =
FFMIN(volume_len, 27);
553 dref->
volume[volume_len] = 0;
559 len =
FFMIN(len, 63);
576 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
595 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
597 memmove(dref->
path, dref->
path+volume_len, len);
600 for (j = 0; j <
len; j++)
601 if (dref->
path[j] ==
':' || dref->
path[j] == 0)
604 }
else if (type == 0) {
616 for (j = 0; j <
len; j++)
617 if (dref->
dir[j] ==
':')
654 if (type ==
MKTAG(
'm',
'd',
't',
'a')) {
662 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
664 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
666 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
668 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
675 title_size = atom.
size - 24;
676 if (title_size > 0) {
686 title_str[title_size] = 0;
688 int off = (!c->
isom && title_str[0] == title_size - 1);
728 int ac3info, acmod, lfeon, bsmod;
740 bsmod = (ac3info >> 14) & 0x7;
741 acmod = (ac3info >> 11) & 0x7;
742 lfeon = (ac3info >> 10) & 0x1;
743 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
760 int eac3info, acmod, lfeon, bsmod;
776 bsmod = (eac3info >> 12) & 0x1f;
777 acmod = (eac3info >> 9) & 0x7;
778 lfeon = (eac3info >> 8) & 0x1;
794 const uint32_t ddts_size = 20;
797 uint32_t frame_duration_code = 0;
798 uint32_t channel_layout_code = 0;
805 if (
avio_read(pb, buf, ddts_size) < ddts_size) {
821 frame_duration_code =
get_bits(&gb, 2);
823 channel_layout_code =
get_bits(&gb, 16);
826 (frame_duration_code == 0) ? 512 :
827 (frame_duration_code == 1) ? 1024 :
828 (frame_duration_code == 2) ? 2048 :
829 (frame_duration_code == 3) ? 4096 : 0;
831 if (channel_layout_code > 0xff) {
894 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
897 }
else if (den != 0) {
913 #define DRM_BLOB_SIZE 56
922 uint8_t calculated_checksum[20];
947 for (i = 0; i < 20; i++)
952 if (!activation_bytes) {
984 if (memcmp(calculated_checksum, file_checksum, 20)) {
991 for (i = 0; i < 4; i++) {
993 if (activation_bytes[i] != output[3 - i]) {
999 memcpy(c->
file_key, output + 8, 16);
1000 memcpy(input, output + 26, 16);
1017 unsigned char iv[16];
1031 int comp_brand_size;
1032 char* comp_brands_str;
1038 if (strcmp(type,
"qt "))
1045 comp_brand_size = atom.
size - 8;
1046 if (comp_brand_size < 0)
1048 comp_brands_str =
av_malloc(comp_brand_size + 1);
1049 if (!comp_brands_str)
1057 comp_brands_str[comp_brand_size] = 0;
1093 "read the mfra (may be a live ismv)\n");
1097 "seekable, can not look for mfra\n");
1109 struct tm *ptm, tmbuf;
1111 if(time >= 2082844800)
1116 if (strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm))
1117 av_dict_set(metadata,
"creation_time", buffer, 0);
1126 char language[4] = {0};
1128 int64_t creation_time;
1168 int64_t creation_time;
1219 if (little_endian == 1) {
1243 char color_parameter_type[5] = { 0 };
1244 uint16_t color_primaries, color_trc, color_matrix;
1254 if (strncmp(color_parameter_type,
"nclx", 4) &&
1255 strncmp(color_parameter_type,
"nclc", 4)) {
1257 color_parameter_type);
1266 "%s: pri %d trc %d matrix %d",
1267 color_parameter_type, color_primaries, color_trc, color_matrix);
1269 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1289 }
else if (!strncmp(color_parameter_type,
"nclc", 4)) {
1291 switch (color_primaries) {
1297 switch (color_trc) {
1302 switch (color_matrix) {
1316 unsigned mov_field_order;
1325 if ((mov_field_order & 0xFF00) == 0x0100)
1327 else if ((mov_field_order & 0xFF00) == 0x0200) {
1328 switch (mov_field_order & 0xFF) {
1351 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1365 int64_t result = atom.
size;
1374 }
else if (err < atom.
size) {
1388 uint64_t original_size;
1462 codec->
width = 1440;
1474 uint64_t original_size;
1479 if (atom.
size == 16) {
1484 if (length == atom.
size) {
1486 switch (range_value) {
1527 if ((uint64_t)atom.
size > (1<<30))
1538 }
else if (atom.
size > 8) {
1546 if ( (buffer & 0xFFFFFFFF) ==
MKBETAG(
'f',
'r',
'm',
'a')
1547 && buffer >> 32 <= atom.
size
1548 && buffer >> 32 >= 8) {
1552 #define ALAC_EXTRADATA_SIZE 36
1585 if ((uint64_t)atom.
size > (1<<30))
1588 if (atom.
size >= 10) {
1594 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1619 if (atom.
size >= (1<<28) || atom.
size < 7)
1623 if ((profile_level & 0xf0) != 0xc0)
1647 if (atom.
size <= 40)
1651 if ((uint64_t)atom.
size > (1<<30))
1667 unsigned int i, entries;
1691 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1694 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1727 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1728 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1735 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1791 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1798 !memcmp(codec_name,
"Sorenson H263", 13))
1814 int bits_per_sample,
flags;
1833 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1840 }
else if (version == 2) {
1855 if (version == 0 || (version == 1 && sc->
audio_cid != -2)) {
1914 if (bits_per_sample) {
1939 y = (ycbcr >> 16) & 0xFF;
1940 cr = (ycbcr >> 8) & 0xFF;
1943 b = av_clip_uint8((1164 * (y - 16) + 2018 * (cb - 128)) / 1000);
1944 g = av_clip_uint8((1164 * (y - 16) - 813 * (cr - 128) - 391 * (cb - 128)) / 1000);
1945 r = av_clip_uint8((1164 * (y - 16) + 1596 * (cr - 128) ) / 1000);
1947 return (r << 16) | (g << 8) | b;
1952 char buf[256] = {0};
1960 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
1964 for (i = 0; i < 16; i++) {
1965 uint32_t yuv =
AV_RB32(src + i * 4);
1968 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
1971 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
1992 if ((
int)size != size)
2017 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
2019 if (str_size > 0 && size >= (
int)str_size + 26) {
2020 char *reel_name =
av_malloc(str_size + 1);
2024 reel_name[str_size] = 0;
2026 if (*reel_name == 0) {
2051 #if CONFIG_DV_DEMUXER
2120 int codec_tag,
int format,
2126 (codec_tag != format &&
2128 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2137 if ( codec_tag ==
AV_RL32(
"avc1") ||
2138 codec_tag ==
AV_RL32(
"hvc1") ||
2150 int pseudo_stream_id;
2157 for (pseudo_stream_id = 0;
2159 pseudo_stream_id++) {
2162 int ret, dref_id = 1;
2172 }
else if (size <= 7){
2188 "size=%"PRId64
" 4CC= %c%c%c%c/0x%08x codec_type=%d\n", size,
2189 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
2213 }
else if (a.
size > 0)
2238 unsigned int i, entries;
2262 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2280 unsigned i, entries;
2298 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2315 unsigned int i, entries;
2338 if (entries >= UINT_MAX /
sizeof(
int))
2346 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2363 unsigned int i, entries, sample_size, field_size, num_bytes;
2376 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2395 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2402 if (entries >= (UINT_MAX - 4) / field_size)
2412 num_bytes = (entries*field_size+4)>>3;
2429 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2448 unsigned int i, entries;
2450 int64_t total_sample_count=0;
2472 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2473 int sample_duration;
2479 if (sample_count < 0) {
2487 sample_count, sample_duration);
2491 && sample_count == 1
2492 && total_sample_count > 100
2493 && sample_duration/10 > duration / total_sample_count)
2494 sample_duration = duration / total_sample_count;
2495 duration+=(int64_t)sample_duration*sample_count;
2496 total_sample_count+=sample_count;
2517 if (duration == INT_MIN) {
2529 unsigned int i, entries;
2544 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2551 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2561 if (
FFNABS(duration) < -(1<<28) && i+2<entries) {
2586 unsigned int i, entries;
2588 uint32_t grouping_type;
2598 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2614 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2627 int64_t current_offset;
2628 int64_t current_dts = 0;
2629 unsigned int stts_index = 0;
2630 unsigned int stsc_index = 0;
2631 unsigned int stss_index = 0;
2632 unsigned int stps_index = 0;
2634 uint64_t stream_size = 0;
2638 int64_t empty_duration = 0;
2643 if (i == 0 && e->
time == -1) {
2647 edit_start_index = 1;
2648 }
else if (i == edit_start_index && e->
time >= 0) {
2649 start_time = e->
time;
2655 "a/v desync might occur, patch welcome\n");
2658 if ((empty_duration || start_time) && mov->
time_scale > 0) {
2676 unsigned int current_sample = 0;
2677 unsigned int stts_sample = 0;
2678 unsigned int sample_size;
2680 unsigned int rap_group_index = 0;
2681 unsigned int rap_group_sample = 0;
2682 int64_t last_dts = 0;
2683 int64_t dts_correction = 0;
2688 last_dts = current_dts;
2735 if (rap_group_present && rap_group_index < sc->rap_group_count) {
2738 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
2739 rap_group_sample = 0;
2745 && !rap_group_present
2754 e->
pos = current_offset;
2756 e->
size = sample_size;
2759 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2760 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
2761 current_offset, current_dts, sample_size, distance, keyframe);
2766 current_offset += sample_size;
2767 stream_size += sample_size;
2773 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
2780 if (!dts_correction || current_dts + dts_correction > last_dts) {
2781 current_dts += dts_correction;
2785 dts_correction += current_dts - last_dts - 1;
2786 current_dts = last_dts + 1;
2788 last_dts = current_dts;
2801 unsigned chunk_samples, total = 0;
2805 unsigned count, chunk_count;
2818 count = (chunk_samples+samples-1) / samples;
2820 count = (chunk_samples+1023) / 1024;
2823 if (i < sc->stsc_count - 1)
2827 total += chunk_count *
count;
2849 while (chunk_samples > 0) {
2851 unsigned size, samples;
2855 "Zero bytes per frame, but %d samples per frame",
2869 samples =
FFMIN(1024, chunk_samples);
2879 e->
pos = current_offset;
2885 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
2888 current_offset +=
size;
2889 current_dts += samples;
2890 chunk_samples -= samples;
2906 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0, src);
2907 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0, ref);
2909 if (strlen(src) == 0) {
2911 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
2912 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
2913 strlen(src_host) + 1 >=
sizeof(src_host) ||
2914 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
2916 }
else if (strcmp(src_proto, ref_proto) ||
2917 strcmp(src_auth, ref_auth) ||
2918 strcmp(src_host, ref_host) ||
2919 src_port != ref_port) {
2930 char filename[1025];
2931 const char *src_path;
2935 src_path = strrchr(src,
'/');
2942 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
2943 if (ref->
path[l] ==
'/') {
2951 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
2952 memcpy(filename, src, src_path - src);
2953 filename[src_path -
src] = 0;
2956 av_strlcat(filename,
"../",
sizeof(filename));
2964 "Reference with mismatching origin, %s not tried for security reasons, "
2965 "set demuxer option use_absolute_path to allow it anyway\n",
2970 if(strstr(ref->
path + l + 1,
"..") ||
2971 strstr(ref->
path + l + 1,
":") ||
2972 (ref->
nlvl_from > 1 && same_origin < 0) ||
2973 (filename[0] ==
'/' && src_path == src))
2977 if (strlen(filename) + 1 ==
sizeof(filename))
2984 "this is a possible security issue\n");
2989 "Absolute path %s not tried for security reasons, "
2990 "set demuxer option use_absolute_path to allow absolute paths\n",
3014 if (!st)
return AVERROR(ENOMEM);
3017 if (!sc)
return AVERROR(ENOMEM);
3048 "stream %d, error opening alias: path='%s', dir='%s', "
3049 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
3054 "Skipped opening external track: "
3055 "stream %d, alias: path='%s', dir='%s', "
3056 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d."
3057 "Set enable_drefs to allow this.\n",
3074 #if FF_API_R_FRAME_RATE
3090 #if CONFIG_H261_DECODER
3093 #if CONFIG_H263_DECODER
3096 #if CONFIG_MPEG4_DECODER
3143 if (count > UINT_MAX /
sizeof(*c->
meta_keys)) {
3145 "The 'keys' atom with the invalid key count: %d\n", count);
3154 for (i = 1; i <=
count; ++i) {
3159 "The key# %d in meta has invalid size: %d\n", i, key_size);
3163 if (type !=
MKTAG(
'm',
'd',
't',
'a')) {
3188 for (i = 0; i < 2; i++) {
3200 if (len < 12 || len - 12 > end -
avio_tell(pb))
3204 if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
3206 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
3225 if (strcmp(key,
"iTunSMPB") == 0) {
3226 int priming, remainder, samples;
3227 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
3228 if(priming>0 && priming<16384)
3232 if (strcmp(key,
"cdec") != 0) {
3256 if (len > atom.
size)
3259 if (tag ==
MKTAG(
'm',
'e',
'a',
'n') && len > 12) {
3266 domain_len =
avio_get_str(pb, len, domain,
sizeof(domain));
3273 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
3279 while (atom.
size > 8) {
3282 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
3296 int display_matrix[3][3];
3335 for (i = 0; i < 3; i++) {
3343 sc->
width = width >> 16;
3344 sc->
height = height >> 16;
3348 if (display_matrix[0][0] != (1 << 16) ||
3349 display_matrix[1][1] != (1 << 16) ||
3350 display_matrix[2][2] != (1 << 30) ||
3351 display_matrix[0][1] || display_matrix[0][2] ||
3352 display_matrix[1][0] || display_matrix[1][2] ||
3353 display_matrix[2][0] || display_matrix[2][1]) {
3362 for (i = 0; i < 3; i++)
3363 for (j = 0; j < 3; j++)
3367 if (!
isnan(rotate)) {
3368 char rotate_buf[64];
3372 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
3380 double disp_transform[2];
3382 for (i = 0; i < 2; i++)
3383 disp_transform[i] =
hypot(display_matrix[i][0], display_matrix[i][1]);
3385 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
3386 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
3387 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
3389 disp_transform[0] / disp_transform[1],
3400 int flags, track_id, i, found = 0;
3436 "found fragment index for track %u\n", frag->
track_id);
3438 for (j = index->
current_item; j < index->item_count; j++) {
3441 "for track %u and moof_offset %"PRId64
"\n",
3453 if (index && !found) {
3455 "it doesn't have an (in-order) entry for moof_offset "
3532 int data_offset = 0;
3533 unsigned entries, first_sample_flags = frag->
flags;
3583 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3584 unsigned sample_size = frag->
size;
3585 int sample_flags = i ? frag->
flags : first_sample_flags;
3586 unsigned sample_duration = frag->
duration;
3600 " sc->dts_shift %d ctts.duration %d"
3601 " sc->time_offset %"PRId64
" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
3605 if (flags & MOV_TRUN_SAMPLE_CTS) {
3614 ", using it for dts\n", dts);
3634 offset, dts, sample_size, distance, keyframe);
3636 dts += sample_duration;
3637 offset += sample_size;
3659 unsigned i, track_id;
3709 if (!index->
items) {
3717 if (size & 0x80000000) {
3765 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
3779 long cmov_len, moov_len;
3793 cmov_len = atom.
size - 6 * 4;
3805 goto free_and_return;
3807 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
3808 goto free_and_return;
3810 goto free_and_return;
3813 atom.
size = moov_len;
3850 for (i = 0; i < edit_count && !pb->
eof_reached; i++) {
3884 static const uint8_t uuid_isml_manifest[] = {
3885 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
3886 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
3888 static const uint8_t uuid_xmp[] = {
3889 0xbe, 0x7a, 0xcf, 0xcb, 0x97, 0xa9, 0x42, 0xe8,
3890 0x9c, 0x71, 0x99, 0x94, 0x91, 0xe3, 0xaf, 0xac
3893 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
3896 ret =
avio_read(pb, uuid,
sizeof(uuid));
3899 }
else if (ret !=
sizeof(uuid)) {
3902 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
3905 size_t len = atom.
size -
sizeof(uuid);
3921 }
else if (ret != len) {
3927 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
3928 ptr +=
sizeof(
"systemBitrate=\"") - 1;
3937 ret = strtol(ptr, &endptr, 10);
3938 if (ret < 0 || errno || *endptr !=
'"') {
3946 }
else if (!memcmp(uuid, uuid_xmp,
sizeof(uuid))) {
3948 size_t len = atom.
size -
sizeof(uuid);
3958 }
else if (ret != len) {
3985 && !memcmp(content,
"Anevia\x1A\x1A", 8)
4007 case MKTAG(
'e',
'n',
'c',
'v'):
4008 case MKTAG(
'e',
'n',
'c',
'a'):
4013 "ignoring 'frma' atom of '%.4s', stream has codec id %d\n",
4023 if (format != sc->
format) {
4025 "ignoring 'frma' atom of '%.4s', stream format is '%.4s'\n",
4026 (
char*)&format, (
char*)&sc->
format);
4038 size_t auxiliary_info_size;
4056 if (atom.
size < 8) {
4062 auxiliary_info_size = atom.
size - 8;
4089 uint32_t encrypted_bytes;
4090 uint16_t subsample_count;
4091 uint16_t clear_bytes;
4119 for (; subsample_count > 0; subsample_count--)
4132 if ((uint64_t)clear_bytes + encrypted_bytes > input_end - input) {
4138 input += clear_bytes;
4142 input += encrypted_bytes;
4145 if (input < input_end) {
4235 int64_t total_size = 0;
4246 atom.
size = INT64_MAX;
4251 if (atom.
size >= 8) {
4258 uint32_t *
type = (uint32_t *)buf + 1;
4262 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
4263 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
4268 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
4280 if (a.
size == 1 && total_size + 8 <= atom.
size) {
4285 av_log(c->
fc,
AV_LOG_TRACE,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
4288 a.
size = atom.
size - total_size + 8;
4295 for (i = 0; mov_default_parse_table[i].
type; i++)
4296 if (mov_default_parse_table[i].
type == a.
type) {
4319 int err =
parse(c, pb, a);
4335 else if (left < 0) {
4337 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
4338 (
char*)&a.
type, -left);
4343 total_size += a.
size;
4346 if (total_size < atom.
size && atom.
size < 0x7ffff)
4358 int moov_offset = -1;
4364 if ((offset + 8) > (
unsigned int)p->
buf_size)
4369 case MKTAG(
'm',
'o',
'o',
'v'):
4370 moov_offset = offset + 4;
4371 case MKTAG(
'm',
'd',
'a',
't'):
4372 case MKTAG(
'p',
'n',
'o',
't'):
4373 case MKTAG(
'u',
'd',
't',
'a'):
4374 case MKTAG(
'f',
't',
'y',
'p'):
4377 offset + 12 > (
unsigned int)p->
buf_size ||
4380 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
4384 score =
FFMAX(score, 5);
4391 case MKTAG(
'e',
'd',
'i',
'w'):
4392 case MKTAG(
'w',
'i',
'd',
'e'):
4393 case MKTAG(
'f',
'r',
'e',
'e'):
4394 case MKTAG(
'j',
'u',
'n',
'k'):
4395 case MKTAG(
'p',
'i',
'c',
't'):
4399 case MKTAG(0x82,0x82,0x7f,0x7d):
4400 case MKTAG(
's',
'k',
'i',
'p'):
4401 case MKTAG(
'u',
'u',
'i',
'd'):
4402 case MKTAG(
'p',
'r',
'f',
'l'):
4414 offset = moov_offset;
4416 while(offset < (p->
buf_size - 16)){
4466 if (end < sample->timestamp) {
4478 if (len > sample->
size-2)
4480 title_len = 2*len + 1;
4493 else if (ch == 0xfffe)
4497 if (len == 1 || len == 2)
4657 int version, fieldlength, i, j;
4688 if (!index->
items) {
4703 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
4705 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
4707 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
4722 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
4727 if (mfra_size < 0 || mfra_size > stream_size) {
4731 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
4751 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
4754 "failed to seek back after looking for mfra\n");
4780 atom.
size = INT64_MAX;
4813 int tmcd_st_id = -1;
4819 if (tmcd_st_id < 0 || tmcd_st_id == i)
4926 int64_t best_dts = INT64_MAX;
4937 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
4940 sample = current_sample;
4960 int already_read = 0;
4962 if (
avio_seek(s->
pb, target, SEEK_SET) != target) {
5030 if (ret64 != sample->
pos) {
5052 #if CONFIG_DV_DEMUXER
5112 for (j = index->
item_count - 1; j >= 0; j--) {
5113 if (index->
items[j].
time <= timestamp) {
5138 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
5170 st = s->
streams[stream_index];
5185 if (stream_index == i)
5212 #define OFFSET(x) offsetof(MOVContext, x)
5213 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
5215 {
"use_absolute_path",
5216 "allow using absolute path when opening alias, this is a possible security issue",
5219 {
"seek_streams_individually",
5220 "Seek each stream individually to the to the closest point",
5228 "use mfra for fragment timestamps",
5233 FLAGS,
"use_mfra_for" },
5235 FLAGS,
"use_mfra_for" },
5237 FLAGS,
"use_mfra_for" },
5238 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
5240 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
5242 {
"activation_bytes",
"Secret bytes for Audible AAX files",
OFFSET(activation_bytes),
5244 {
"audible_fixed_key",
5245 "Fixed key used for handling Audible AAX files",
OFFSET(audible_fixed_key),
5250 {.i64 = 0}, 0, 1,
FLAGS },
5263 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
5267 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2",
static int mov_read_targa_y216(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int itunes_metadata
metadata are itunes style
int * bitrates
bitrates read before streams creation
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
const char const char void * val
static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define av_realloc_f(p, o, n)
uint32_t tmcd_flags
tmcd track flags
uint8_t * auxiliary_info_end
void av_sha_update(AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
unsigned int rap_group_count
void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id)
static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
"Linear transfer characteristics"
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
#define MOV_TFHD_DEFAULT_DURATION
static AVIndexEntry * mov_find_next_sample(AVFormatContext *s, AVStream **st)
static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_keys(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int samples_per_frame
static void mov_build_index(MOVContext *mov, AVStream *st)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint64_t base_data_offset
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
static void skip_bits_long(GetBitContext *s, int n)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle...
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
#define MOV_TRUN_SAMPLE_CTS
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
void av_aes_crypt(AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt)
Encrypt or decrypt a buffer using a previously initialized context.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
static int tmcd_is_referenced(AVFormatContext *s, int tmcd_id)
int event_flags
Flags for the user to detect events happening on the file.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int mov_read_custom_2plus(MOVContext *c, AVIOContext *pb, int size)
int16_t audio_cid
stsd audio compression id
#define PUT_UTF8(val, tmp, PUT_BYTE)
Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
unsigned int avio_rb16(AVIOContext *s)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
static AVRational av_make_q(int num, int den)
Create a rational.
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
#define FF_INPUT_BUFFER_PADDING_SIZE
enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
Compute codec id for 'lpcm' tag.
unsigned fragment_index_count
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int found_moov
'moov' atom has been found
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static void export_orphan_timecode(AVFormatContext *s)
static int mov_read_aclr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_TFHD_DEFAULT_BASE_IS_MOOF
Macro definitions for various function/variable attributes.
static int should_retry(AVIOContext *pb, int error_code)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define MOV_TKHD_FLAG_ENABLED
int isom
1 if file is ISO Media (mp4/3gp)
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
int found_mdat
'mdat' atom has been found
static int mov_probe(AVProbeData *p)
static int mov_read_header(AVFormatContext *s)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int count)
Process a buffer using a previously initialized context.
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
static double cb(void *priv, double x, double y)
int fragment_index_complete
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const AVOption mov_options[]
static int64_t start_time
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
#define FF_MOV_FLAG_MFRA_DTS
Opaque data information usually continuous.
unsigned int sample_count
const AVCodecTag ff_codec_movvideo_tags[]
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
int dts_shift
dts shift when ctts is negative
static int mov_read_ddts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
uint8_t * auxiliary_info_pos
struct MOVStreamContext::@172 cenc
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
AVInputFormat ff_mov_demuxer
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb)
int nb_side_data
The number of elements in the AVStream.side_data array.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AV_CH_LOW_FREQUENCY
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
AVStream ** streams
A list of all streams in the file.
static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
static int mov_skip_multiple_stsd(MOVContext *c, AVIOContext *pb, int codec_tag, int format, int64_t size)
int activation_bytes_size
MOVFragmentIndex ** fragment_index_data
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define ALAC_EXTRADATA_SIZE
int flags
Flags modifying the (de)muxer behaviour.
#define MOV_TRUN_SAMPLE_SIZE
#define AVERROR_EOF
End of file.
bitstream reader API header.
static av_cold int read_close(AVFormatContext *ctx)
#define AV_LOG_VERBOSE
Detailed information.
struct AVAESCTR * aes_ctr
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
static int test_same_origin(const char *src, const char *ref)
void av_aes_ctr_free(struct AVAESCTR *a)
Release an AVAESCTR context.
enum AVCodecID video_codec_id
Forced video codec_id.
#define MOV_TFHD_DEFAULT_SIZE
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int mov_read_frma(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int64_t time_offset
time offset of the edit list entries
static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int keyframe_count
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
const uint16_t avpriv_ac3_channel_layout_tab[8]
Map audio coding mode (acmod) to channel layout mask.
static int mov_read_fiel(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_rewrite_dvd_sub_extradata(AVStream *st)
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc, int64_t size)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int avio_rl32(AVIOContext *s)
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int64_t mov_read_atom_into_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, AVCodecContext *codec, uint8_t *buf)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref)
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVPacketSideDataType type
#define FFNABS(a)
Negative Absolute value.
struct AVAES * av_aes_alloc(void)
Allocate an AVAES context.
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet. ...
static const uint8_t offset[127][2]
static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVRational avg_frame_rate
Average framerate.
const AVCodecTag ff_codec_wav_tags[]
#define MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time)
const AVCodecTag ff_codec_movsubtitle_tags[]
static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MIN_DATA_ENTRY_BOX_SIZE
static struct tm * gmtime_r(const time_t *clock, struct tm *result)
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
struct AVAESCTR * av_aes_ctr_alloc(void)
Allocate an AVAESCTR context.
static float distance(float x, float y, int band)
static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int buf_size
Size of buf except extra allocated bytes.
static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int aax_filter(uint8_t *input, int size, MOVContext *c)
static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
common internal API header
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static av_const double hypot(double x, double y)
struct AVAES * aes_decrypt
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const uint16_t fc[]
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
audio channel layout utility functions
static int mov_realloc_extradata(AVCodecContext *codec, MOVAtom atom)
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
unsigned int avio_rb24(AVIOContext *s)
char filename[1024]
input or output filename
static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
const AVCodecTag ff_codec_bmp_tags[]
static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int mov_read_tmcd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
colour filters using Illuminant C
int width
picture width / height.
GLsizei GLboolean const GLfloat * value
static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
ITU-R BT2020 non-constant luminance system.
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
int audible_fixed_key_size
static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
MOVFragmentIndexItem * items
#define MOV_TRUN_SAMPLE_DURATION
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
#define AV_CH_FRONT_CENTER
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
static int mov_read_close(AVFormatContext *s)
static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
This function reads atom content and puts data in extradata without tag nor size unlike mov_read_extr...
int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st, int64_t size)
Read 'chan' tag from the input stream.
offset must point to a pointer immediately followed by an int for the length
#define FF_MOV_FLAG_MFRA_PTS
the normal 2^n-1 "JPEG" YUV ranges
static int read_header(FFV1Context *f)
int64_t duration
duration of the longest track
int ff_mov_lang_to_iso639(unsigned code, char to[4])
static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_aes_init(AVAES *a, const uint8_t *key, int key_bits, int decrypt)
Initialize an AVAES context.
int frame_size
Number of samples per channel in an audio frame.
DVDemuxContext * dv_demux
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL AV_RB8
#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE
timecode is in drop frame format.
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static const uint32_t mac_to_unicode[128]
#define AV_LOG_INFO
Standard information.
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int 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...
enum AVMediaType codec_type
#define MP4DecConfigDescrTag
const AVCodecTag ff_codec_movaudio_tags[]
functionally identical to above
static void mov_read_chapters(AVFormatContext *s)
int sample_rate
samples per second
AVIOContext * pb
I/O context.
static void mov_parse_stsd_video(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
unsigned int stsz_sample_size
always contains sample size from stsz atom
static int read_tfra(MOVContext *mov, AVIOContext *f)
main external API structure.
static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define MOV_TRUN_FIRST_SAMPLE_FLAGS
static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static const char * format
timecode wraps after 24 hours
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
struct AVSHA * av_sha_alloc(void)
Allocate an AVSHA context.
static int mov_read_free(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
BYTE int const BYTE int int int height
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
enum AVColorSpace colorspace
YUV colorspace type.
rational number numerator/denominator
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
unsigned int aax_mode
'aax' file has been detected
static int mov_read_dpxe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
"Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
MOVFragment fragment
current fragment in moof atom
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int64_t track_end
used for dts generation in fragmented movie files
static void mov_parse_stsd_audio(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, char *dst, int dstlen)
#define MOV_TFHD_DEFAULT_FLAGS
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
#define FF_MOV_FLAG_MFRA_AUTO
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext *codec, int size, int big_endian)
#define MOV_TRUN_SAMPLE_FLAGS
This structure contains the data a format has to probe a file.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVFormatContext * dv_fctx
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
static int64_t pts
Global timestamp for the audio frames.
static void mov_update_dts_shift(MOVStreamContext *sc, int duration)
static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t *iv)
Forcefully change the iv.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
unsigned * stps_data
partial sync sample for mpeg-2 open gop
the normal 219*2^(n-8) "MPEG" YUV ranges
int(* parse)(MOVContext *ctx, AVIOContext *pb, MOVAtom atom)
static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int64_t duration
Decoding: duration of the stream, in stream time base.
static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int start_pad
amount of samples to skip due to enc-dec delay
int trak_index
Index of the current 'trak'.
negative time values are allowed
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
An strf atom is a BITMAPINFOHEADER struct.
unsigned int bytes_per_frame
int wrong_dts
dts are wrong due to huge ctts offset (iMovie files)
#define MOV_TFHD_BASE_DATA_OFFSET
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))
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
static const MOVParseTableEntry mov_default_parse_table[]
static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st, uint32_t value, int flags)
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it...
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int disposition
AV_DISPOSITION_* bit field.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static int mov_codec_id(AVStream *st, uint32_t format)
int64_t nb_frames
number of frames in this stream if known or 0
double av_display_rotation_get(const int32_t matrix[9])
The display transformation matrix specifies an affine transformation that should be applied to video ...
static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
#define MKBETAG(a, b, c, d)
static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp)
unsigned int index_entries_allocated_size
static int mov_finalize_stsd_codec(MOVContext *c, AVIOContext *pb, AVStream *st, MOVStreamContext *sc)
int eof_reached
true if eof reached
static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
as in Berlin toast format
int channels
number of audio channels
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom, enum AVCodecID codec_id)
int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key)
Initialize an AVAESCTR context.
unsigned int sample_size
may contain value calculated from stsd or value from stsz atom
void * priv_data
Format private data.
static int mov_read_mfra(MOVContext *c, AVIOContext *f)
static const AVClass mov_class
int flags2
AV_CODEC_FLAG2_*.
#define MOV_TRUN_DATA_OFFSET
int64_t next_root_atom
offset of the next root atom
static int cenc_filter(MOVContext *c, MOVStreamContext *sc, uint8_t *input, int size)
ITU-R BT2020 for 10 bit system.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
static void * av_mallocz_array(size_t nmemb, size_t size)
int pseudo_stream_id
-1 means demux all ids
#define AV_CH_FRONT_RIGHT
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int ffindex
AVStream index.
enum AVFieldOrder field_order
Field order.
static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define av_malloc_array(a, b)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
static int mov_read_alac(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static int unsupported(AVCodecContext *avctx)
static double cr(void *priv, double x, double y)
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static void fix_timescale(MOVContext *c, MOVStreamContext *sc)
AVRational r_frame_rate
Real base framerate of the stream.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
static int mov_switch_root(AVFormatContext *s, int64_t target)
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
static int mov_read_sbgp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int found_hdlr_mdta
'hdlr' atom with type 'mdta' has been found
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static uint32_t yuv_to_rgba(uint32_t ycbcr)
#define AV_TIMECODE_STR_SIZE
#define MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC
This side data should be associated with an audio stream and corresponds to enum AVAudioServiceType.