72 unsigned len,
const char *key)
76 short current, total = 0;
82 snprintf(buf,
sizeof(buf),
"%d", current);
84 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
92 unsigned len,
const char *key)
106 unsigned len,
const char *key)
115 unsigned len,
const char *key)
131 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
132 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
133 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
134 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
135 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
136 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
137 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
138 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
139 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
140 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
141 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
142 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
143 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
144 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
145 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
146 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
150 char *dst,
int dstlen)
153 char *
end = dst+dstlen-1;
156 for (i = 0; i <
len; i++) {
158 if (c < 0x80 && p < end)
211 char language[4] = { 0 };
212 char buf[200], place[100];
213 uint16_t langcode = 0;
214 double longitude, latitude, altitude;
215 const char *key =
"location";
217 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
244 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f", latitude, longitude);
249 if (*language && strcmp(language,
"und")) {
251 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
261 char key2[32], language[4] = {0};
263 const char *key =
NULL;
264 uint16_t langcode = 0;
265 uint32_t data_type = 0, str_size, str_size_alloc;
270 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
271 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
272 case MKTAG(
'X',
'M',
'P',
'_'):
273 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
274 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
275 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
277 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
278 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
279 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
281 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
282 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
283 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
285 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
287 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
289 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
291 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
292 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
293 case MKTAG(
'l',
'o',
'c',
'i'):
295 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
297 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
299 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
300 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
302 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
303 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
304 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
305 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
306 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
307 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
308 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
310 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
312 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
313 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
315 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
316 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
317 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
319 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
320 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
321 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
322 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
323 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
324 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
325 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
326 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
327 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
328 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
329 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
330 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
331 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
332 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
333 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
334 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
335 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
336 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
337 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
338 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
339 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
340 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
341 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
342 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
343 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
344 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
345 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
346 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
347 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
348 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
349 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
350 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
351 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
352 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
353 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
359 if (tag ==
MKTAG(
'd',
'a',
't',
'a') && data_size <= atom.
size) {
362 str_size = data_size - 16;
365 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
375 if (str_size > atom.
size) {
385 str_size = atom.
size;
394 if (atom.
size < 0 || str_size >= INT_MAX/2)
398 str_size_alloc = (raw ? str_size : str_size * 2) + 1;
404 parse(c, pb, str_size, key);
406 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
418 if (*language && strcmp(language,
"und")) {
419 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
425 key, str, (
char*)&atom.
type, str_size_alloc, atom.
size);
434 int i, nb_chapters, str_len,
version;
438 if ((atom.
size -= 5) < 0)
447 for (i = 0; i < nb_chapters; i++) {
454 if ((atom.
size -= 9+str_len) < 0)
466 #define MIN_DATA_ENTRY_BOX_SIZE 12
481 entries >= UINT_MAX /
sizeof(*sc->
drefs))
502 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
504 uint16_t volume_len,
len;
511 volume_len =
FFMIN(volume_len, 27);
515 dref->
volume[volume_len] = 0;
521 len =
FFMIN(len, 63);
538 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
546 if (type == 2 || type == 18) {
559 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
561 memmove(dref->
path, dref->
path+volume_len, len);
564 for (j = 0; j <
len; j++)
565 if (dref->
path[j] ==
':')
568 }
else if (type == 0) {
580 for (j = 0; j <
len; j++)
581 if (dref->
dir[j] ==
':')
617 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
619 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
621 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
623 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
630 title_size = atom.
size - 24;
631 if (title_size > 0) {
641 title_str[title_size] = 0;
643 int off = (!c->
isom && title_str[0] == title_size - 1);
683 int ac3info, acmod, lfeon, bsmod;
695 bsmod = (ac3info >> 14) & 0x7;
696 acmod = (ac3info >> 11) & 0x7;
697 lfeon = (ac3info >> 10) & 0x1;
698 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
715 int eac3info, acmod, lfeon, bsmod;
731 bsmod = (eac3info >> 12) & 0x1f;
732 acmod = (eac3info >> 9) & 0x7;
733 lfeon = (eac3info >> 8) & 0x1;
794 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
797 }
else if (den != 0) {
813 #define DRM_BLOB_SIZE 56
822 uint8_t calculated_checksum[20];
847 for (i = 0; i < 20; i++)
852 if (!activation_bytes) {
884 if (memcmp(calculated_checksum, file_checksum, 20)) {
891 for (i = 0; i < 4; i++) {
893 if (activation_bytes[i] != output[3 - i]) {
899 memcpy(c->
file_key, output + 8, 16);
900 memcpy(input, output + 26, 16);
917 unsigned char iv[16];
932 char* comp_brands_str;
938 if (strcmp(type,
"qt "))
945 comp_brand_size = atom.
size - 8;
946 if (comp_brand_size < 0)
948 comp_brands_str =
av_malloc(comp_brand_size + 1);
949 if (!comp_brands_str)
957 comp_brands_str[comp_brand_size] = 0;
993 "read the mfra (may be a live ismv)\n");
997 "seekable, can not look for mfra\n");
1009 struct tm *ptm, tmbuf;
1011 if(time >= 2082844800)
1016 if (strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm))
1017 av_dict_set(metadata,
"creation_time", buffer, 0);
1026 char language[4] = {0};
1028 int64_t creation_time;
1068 int64_t creation_time;
1119 if (little_endian == 1) {
1143 char color_parameter_type[5] = { 0 };
1154 if (strncmp(color_parameter_type,
"nclx", 4) &&
1155 strncmp(color_parameter_type,
"nclc", 4)) {
1157 color_parameter_type);
1166 "%s: pri %d trc %d matrix %d",
1167 color_parameter_type, color_primaries, color_trc, color_matrix);
1169 if (!strncmp(color_parameter_type,
"nclx", 4)) {
1189 }
else if (!strncmp(color_parameter_type,
"nclc", 4)) {
1191 switch (color_primaries) {
1197 switch (color_trc) {
1202 switch (color_matrix) {
1216 unsigned mov_field_order;
1225 if ((mov_field_order & 0xFF00) == 0x0100)
1227 else if ((mov_field_order & 0xFF00) == 0x0200) {
1228 switch (mov_field_order & 0xFF) {
1251 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1265 int64_t result = atom.
size;
1274 }
else if (err < atom.
size) {
1288 uint64_t original_size;
1362 codec->
width = 1440;
1374 uint64_t original_size;
1379 if (atom.
size == 16) {
1384 if (length == atom.
size) {
1386 switch (range_value) {
1427 if ((uint64_t)atom.
size > (1<<30))
1438 }
else if (atom.
size > 8) {
1446 if ( (buffer & 0xFFFFFFFF) ==
MKBETAG(
'f',
'r',
'm',
'a')
1447 && buffer >> 32 <= atom.
size
1448 && buffer >> 32 >= 8) {
1452 #define ALAC_EXTRADATA_SIZE 36
1485 if ((uint64_t)atom.
size > (1<<30))
1488 if (atom.
size >= 10) {
1494 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1519 if (atom.
size >= (1<<28) || atom.
size < 7)
1523 if ((profile_level & 0xf0) != 0xc0)
1547 if (atom.
size <= 40)
1551 if ((uint64_t)atom.
size > (1<<30))
1567 unsigned int i, entries;
1591 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1594 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1627 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1628 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1635 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1659 unsigned int color_depth,
len, j;
1660 int color_greyscale;
1688 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1695 !memcmp(codec_name,
"Sorenson H263", 13))
1710 if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
1712 unsigned int color_start, color_count, color_end;
1713 unsigned int a,
r,
g,
b;
1715 if (color_greyscale) {
1716 int color_index, color_dec;
1719 color_count = 1 << color_depth;
1721 color_dec = 256 / (color_count - 1);
1722 for (j = 0; j < color_count; j++) {
1723 r = g = b = color_index;
1724 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1725 color_index -= color_dec;
1726 if (color_index < 0)
1729 }
else if (color_table_id) {
1732 color_count = 1 << color_depth;
1733 if (color_depth == 2)
1735 else if (color_depth == 4)
1740 for (j = 0; j < color_count; j++) {
1741 r = color_table[j * 3 + 0];
1742 g = color_table[j * 3 + 1];
1743 b = color_table[j * 3 + 2];
1744 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1751 if ((color_start <= 255) && (color_end <= 255)) {
1752 for (j = color_start; j <= color_end; j++) {
1763 sc->
palette[j] = (a << 24 ) | (r << 16) | (g << 8) | (b);
1774 int bits_per_sample,
flags;
1793 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1800 }
else if (version == 2) {
1815 if (version == 0 || (version == 1 && sc->
audio_cid != -2)) {
1867 if (bits_per_sample) {
1892 y = (ycbcr >> 16) & 0xFF;
1893 cr = (ycbcr >> 8) & 0xFF;
1896 b = av_clip_uint8((1164 * (y - 16) + 2018 * (cb - 128)) / 1000);
1897 g = av_clip_uint8((1164 * (y - 16) - 813 * (cr - 128) - 391 * (cb - 128)) / 1000);
1898 r = av_clip_uint8((1164 * (y - 16) + 1596 * (cr - 128) ) / 1000);
1900 return (r << 16) | (g << 8) | b;
1905 char buf[256] = {0};
1913 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
1917 for (i = 0; i < 16; i++) {
1918 uint32_t yuv =
AV_RB32(src + i * 4);
1921 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
1924 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
1945 if ((
int)size != size)
1970 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
1972 if (str_size > 0 && size >= (
int)str_size + 26) {
1973 char *reel_name =
av_malloc(str_size + 1);
1977 reel_name[str_size] = 0;
1979 if (*reel_name == 0) {
2004 #if CONFIG_DV_DEMUXER
2073 int codec_tag,
int format,
2079 (codec_tag != format &&
2081 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
2090 if ( codec_tag ==
AV_RL32(
"avc1") ||
2091 codec_tag ==
AV_RL32(
"hvc1") ||
2103 int pseudo_stream_id;
2110 for (pseudo_stream_id = 0;
2112 pseudo_stream_id++) {
2115 int ret, dref_id = 1;
2125 }
else if (size <= 7){
2140 "size=%"PRId64
" 4CC= %c%c%c%c/0x%08x codec_type=%d\n", size,
2141 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
2165 }
else if (a.
size > 0)
2190 unsigned int i, entries;
2214 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2232 unsigned i, entries;
2250 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2267 unsigned int i, entries;
2290 if (entries >= UINT_MAX /
sizeof(
int))
2298 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2315 unsigned int i, entries, sample_size, field_size, num_bytes;
2328 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2347 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2354 if (entries >= (UINT_MAX - 4) / field_size)
2364 num_bytes = (entries*field_size+4)>>3;
2381 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2400 unsigned int i, entries;
2402 int64_t total_sample_count=0;
2424 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2425 int sample_duration;
2431 if (sample_count < 0) {
2439 sample_count, sample_duration);
2443 && sample_count == 1
2444 && total_sample_count > 100
2445 && sample_duration/10 > duration / total_sample_count)
2446 sample_duration = duration / total_sample_count;
2447 duration+=(int64_t)sample_duration*sample_count;
2448 total_sample_count+=sample_count;
2477 unsigned int i, entries;
2492 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2499 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2509 if (
FFNABS(duration) < -(1<<28) && i+2<entries) {
2534 unsigned int i, entries;
2536 uint32_t grouping_type;
2546 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2562 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2575 int64_t current_offset;
2576 int64_t current_dts = 0;
2577 unsigned int stts_index = 0;
2578 unsigned int stsc_index = 0;
2579 unsigned int stss_index = 0;
2580 unsigned int stps_index = 0;
2582 uint64_t stream_size = 0;
2586 int64_t empty_duration = 0;
2591 if (i == 0 && e->
time == -1) {
2595 edit_start_index = 1;
2596 }
else if (i == edit_start_index && e->
time >= 0) {
2597 start_time = e->
time;
2603 "a/v desync might occur, patch welcome\n");
2606 if ((empty_duration || start_time) && mov->
time_scale > 0) {
2624 unsigned int current_sample = 0;
2625 unsigned int stts_sample = 0;
2626 unsigned int sample_size;
2628 unsigned int rap_group_index = 0;
2629 unsigned int rap_group_sample = 0;
2630 int64_t last_dts = 0;
2631 int64_t dts_correction = 0;
2636 last_dts = current_dts;
2683 if (rap_group_present && rap_group_index < sc->rap_group_count) {
2686 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
2687 rap_group_sample = 0;
2693 && !rap_group_present
2702 e->
pos = current_offset;
2704 e->
size = sample_size;
2707 av_log(mov->
fc,
AV_LOG_TRACE,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2708 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
2709 current_offset, current_dts, sample_size, distance, keyframe);
2714 current_offset += sample_size;
2715 stream_size += sample_size;
2721 "Invalid SampleDelta %d in STTS, at %d st:%d\n",
2728 if (!dts_correction || current_dts + dts_correction > last_dts) {
2729 current_dts += dts_correction;
2733 dts_correction += current_dts - last_dts - 1;
2734 current_dts = last_dts + 1;
2736 last_dts = current_dts;
2749 unsigned chunk_samples, total = 0;
2753 unsigned count, chunk_count;
2766 count = (chunk_samples+samples-1) / samples;
2768 count = (chunk_samples+1023) / 1024;
2771 if (i < sc->stsc_count - 1)
2775 total += chunk_count *
count;
2797 while (chunk_samples > 0) {
2799 unsigned size, samples;
2803 "Zero bytes per frame, but %d samples per frame",
2817 samples =
FFMIN(1024, chunk_samples);
2827 e->
pos = current_offset;
2833 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
2836 current_offset +=
size;
2837 current_dts += samples;
2838 chunk_samples -= samples;
2854 av_url_split(src_proto,
sizeof(src_proto), src_auth,
sizeof(src_auth), src_host,
sizeof(src_host), &src_port,
NULL, 0, src);
2855 av_url_split(ref_proto,
sizeof(ref_proto), ref_auth,
sizeof(ref_auth), ref_host,
sizeof(ref_host), &ref_port,
NULL, 0, ref);
2857 if (strlen(src) == 0) {
2859 }
else if (strlen(src_auth) + 1 >=
sizeof(src_auth) ||
2860 strlen(ref_auth) + 1 >=
sizeof(ref_auth) ||
2861 strlen(src_host) + 1 >=
sizeof(src_host) ||
2862 strlen(ref_host) + 1 >=
sizeof(ref_host)) {
2864 }
else if (strcmp(src_proto, ref_proto) ||
2865 strcmp(src_auth, ref_auth) ||
2866 strcmp(src_host, ref_host) ||
2867 src_port != ref_port) {
2884 char filename[1025];
2885 const char *src_path;
2889 src_path = strrchr(src,
'/');
2896 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
2897 if (ref->
path[l] ==
'/') {
2905 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
2906 memcpy(filename, src, src_path - src);
2907 filename[src_path -
src] = 0;
2910 av_strlcat(filename,
"../",
sizeof(filename));
2918 "Reference with mismatching origin, %s not tried for security reasons, "
2919 "set demuxer option use_absolute_path to allow it anyway\n",
2924 if(strstr(ref->
path + l + 1,
"..") ||
2925 strstr(ref->
path + l + 1,
":") ||
2926 (ref->
nlvl_from > 1 && same_origin < 0) ||
2927 (filename[0] ==
'/' && src_path == src))
2931 if (strlen(filename) + 1 ==
sizeof(filename))
2938 "this is a possible security issue\n");
2946 "Absolute path %s not tried for security reasons, "
2947 "set demuxer option use_absolute_path to allow absolute paths\n",
2971 if (!st)
return AVERROR(ENOMEM);
2974 if (!sc)
return AVERROR(ENOMEM);
3002 "stream %d, error opening alias: path='%s', dir='%s', "
3003 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
3019 #if FF_API_R_FRAME_RATE
3035 #if CONFIG_H261_DECODER
3038 #if CONFIG_H263_DECODER
3041 #if CONFIG_MPEG4_DECODER
3084 for (i = 0; i < 2; i++) {
3096 if (len < 12 || len - 12 > end -
avio_tell(pb))
3100 if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
3102 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
3121 if (strcmp(key,
"iTunSMPB") == 0) {
3122 int priming, remainder, samples;
3123 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
3124 if(priming>0 && priming<16384)
3128 if (strcmp(key,
"cdec") != 0) {
3152 if (len > atom.
size)
3155 if (tag ==
MKTAG(
'm',
'e',
'a',
'n') && len > 12) {
3162 domain_len =
avio_get_str(pb, len, domain,
sizeof(domain));
3169 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
3175 while (atom.
size > 8) {
3178 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
3192 int display_matrix[3][3];
3231 for (i = 0; i < 3; i++) {
3239 sc->
width = width >> 16;
3240 sc->
height = height >> 16;
3244 if (display_matrix[0][0] != (1 << 16) ||
3245 display_matrix[1][1] != (1 << 16) ||
3246 display_matrix[2][2] != (1 << 30) ||
3247 display_matrix[0][1] || display_matrix[0][2] ||
3248 display_matrix[1][0] || display_matrix[1][2] ||
3249 display_matrix[2][0] || display_matrix[2][1]) {
3258 for (i = 0; i < 3; i++)
3259 for (j = 0; j < 3; j++)
3263 if (!
isnan(rotate)) {
3264 char rotate_buf[64];
3268 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
3276 double disp_transform[2];
3278 #define SQR(a) ((a)*(double)(a))
3279 for (i = 0; i < 2; i++)
3280 disp_transform[i] = sqrt(
SQR(display_matrix[i][0]) +
SQR(display_matrix[i][1]));
3282 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
3283 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
3284 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
3286 disp_transform[0] / disp_transform[1],
3297 int flags, track_id, i;
3319 "found fragment index for track %u\n", frag->
track_id);
3339 for (i = index->
current_item; i < index->item_count; i++) {
3342 "for track %u and moof_offset %"PRId64
"\n",
3351 "but it doesn't have an (in-order) entry for moof_offset "
3429 int data_offset = 0;
3430 unsigned entries, first_sample_flags = frag->
flags;
3480 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3481 unsigned sample_size = frag->
size;
3482 int sample_flags = i ? frag->
flags : first_sample_flags;
3483 unsigned sample_duration = frag->
duration;
3497 " sc->dts_shift %d ctts.duration %d"
3498 " sc->time_offset %"PRId64
" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
3502 if (flags & MOV_TRUN_SAMPLE_CTS) {
3511 ", using it for dts\n", dts);
3518 else if (!found_keyframe)
3519 keyframe = found_keyframe =
3531 offset, dts, sample_size, distance, keyframe);
3533 dts += sample_duration;
3534 offset += sample_size;
3563 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
3577 long cmov_len, moov_len;
3591 cmov_len = atom.
size - 6 * 4;
3603 goto free_and_return;
3605 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
3606 goto free_and_return;
3608 goto free_and_return;
3611 atom.
size = moov_len;
3648 for (i = 0; i < edit_count && !pb->
eof_reached; i++) {
3682 static const uint8_t uuid_isml_manifest[] = {
3683 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
3684 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
3687 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
3690 ret =
avio_read(pb, uuid,
sizeof(uuid));
3693 }
else if (ret !=
sizeof(uuid)) {
3696 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
3699 size_t len = atom.
size -
sizeof(uuid);
3715 }
else if (ret != len) {
3721 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
3722 ptr +=
sizeof(
"systemBitrate=\"") - 1;
3731 ret = strtol(ptr, &endptr, 10);
3732 if (ret < 0 || errno || *endptr !=
'"') {
3758 && !memcmp(content,
"Anevia\x1A\x1A", 8)
3843 int64_t total_size = 0;
3854 atom.
size = INT64_MAX;
3859 if (atom.
size >= 8) {
3866 uint32_t *
type = (uint32_t *)buf + 1;
3870 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
3871 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
3876 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
3888 if (a.
size == 1 && total_size + 8 <= atom.
size) {
3893 av_log(c->
fc,
AV_LOG_TRACE,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
3896 a.
size = atom.
size - total_size + 8;
3903 for (i = 0; mov_default_parse_table[i].
type; i++)
3904 if (mov_default_parse_table[i].
type == a.
type) {
3919 int err =
parse(c, pb, a);
3935 else if (left < 0) {
3937 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
3938 (
char*)&a.
type, -left);
3943 total_size += a.
size;
3946 if (total_size < atom.
size && atom.
size < 0x7ffff)
3958 int moov_offset = -1;
3964 if ((offset + 8) > (
unsigned int)p->
buf_size)
3969 case MKTAG(
'm',
'o',
'o',
'v'):
3970 moov_offset = offset + 4;
3971 case MKTAG(
'm',
'd',
'a',
't'):
3972 case MKTAG(
'p',
'n',
'o',
't'):
3973 case MKTAG(
'u',
'd',
't',
'a'):
3974 case MKTAG(
'f',
't',
'y',
'p'):
3977 offset + 12 > (
unsigned int)p->
buf_size ||
3980 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
3984 score =
FFMAX(score, 5);
3991 case MKTAG(
'e',
'd',
'i',
'w'):
3992 case MKTAG(
'w',
'i',
'd',
'e'):
3993 case MKTAG(
'f',
'r',
'e',
'e'):
3994 case MKTAG(
'j',
'u',
'n',
'k'):
3995 case MKTAG(
'p',
'i',
'c',
't'):
3999 case MKTAG(0x82,0x82,0x7f,0x7d):
4000 case MKTAG(
's',
'k',
'i',
'p'):
4001 case MKTAG(
'u',
'u',
'i',
'd'):
4002 case MKTAG(
'p',
'r',
'f',
'l'):
4014 offset = moov_offset;
4016 while(offset < (p->
buf_size - 16)){
4066 if (end < sample->timestamp) {
4078 if (len > sample->
size-2)
4080 title_len = 2*len + 1;
4093 else if (ch == 0xfffe)
4097 if (len == 1 || len == 2)
4247 int version, fieldlength, i, j;
4278 if (!index->
items) {
4293 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
4295 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
4297 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
4312 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
4317 if (mfra_size < 0 || mfra_size > stream_size) {
4321 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
4341 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
4344 "failed to seek back after looking for mfra\n");
4363 atom.
size = INT64_MAX;
4396 int tmcd_st_id = -1;
4402 if (tmcd_st_id < 0 || tmcd_st_id == i)
4502 int64_t best_dts = INT64_MAX;
4513 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
4516 sample = current_sample;
4568 if (ret64 != sample->
pos) {
4590 #if CONFIG_DV_DEMUXER
4640 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
4672 st = s->
streams[stream_index];
4687 if (stream_index == i)
4714 #define OFFSET(x) offsetof(MOVContext, x)
4715 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
4717 {
"use_absolute_path",
4718 "allow using absolute path when opening alias, this is a possible security issue",
4721 {
"seek_streams_individually",
4722 "Seek each stream individually to the to the closest point",
4728 "use mfra for fragment timestamps",
4733 FLAGS,
"use_mfra_for" },
4735 FLAGS,
"use_mfra_for" },
4737 FLAGS,
"use_mfra_for" },
4738 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
4740 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
4742 {
"activation_bytes",
"Secret bytes for Audible AAX files",
OFFSET(activation_bytes),
4744 {
"audible_fixed_key",
4745 "Fixed key used for handling Audible AAX files",
OFFSET(audible_fixed_key),
4759 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
4763 .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
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)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
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)
unsigned int samples_per_frame
static void mov_build_index(MOVContext *mov, AVStream *st)
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint64_t base_data_offset
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
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...
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.
static const uint8_t ff_qt_default_palette_256[256 *3]
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 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...
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(* open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Called to open further IO contexts when needed for demuxing.
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...
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)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
enum AVColorTransferCharacteristic color_trc
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.
static av_always_inline av_const int isnan(float x)
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 av_cold int end(AVCodecContext *avctx)
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
AVInputFormat ff_mov_demuxer
enum AVColorRange color_range
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.
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#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.
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)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
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.
#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
static const uint8_t ff_qt_default_palette_4[4 *3]
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)
Callback for checking whether to abort blocking functions.
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.
const AVIOInterruptCB int_cb
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
enum AVColorPrimaries color_primaries
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
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]
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.
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)
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.
int bit_rate
the average bitrate
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
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
int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
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
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...
static int mov_open_dref(MOVContext *c, AVIOContext **pb, const char *src, MOVDref *ref, AVIOInterruptCB *int_cb)
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 const ColorEntry color_table[]
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.
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)
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)
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.
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 const uint8_t ff_qt_default_palette_16[16 *3]
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)
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
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...
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...
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)
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
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
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.
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.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
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...
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.