69 unsigned len,
const char *key)
73 short current, total = 0;
79 snprintf(buf,
sizeof(buf),
"%d", current);
81 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
89 unsigned len,
const char *key)
103 unsigned len,
const char *key)
112 unsigned len,
const char *key)
128 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1,
129 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8,
130 0x00EA,0x00EB,0x00ED,0x00EC,0x00EE,0x00EF,0x00F1,0x00F3,
131 0x00F2,0x00F4,0x00F6,0x00F5,0x00FA,0x00F9,0x00FB,0x00FC,
132 0x2020,0x00B0,0x00A2,0x00A3,0x00A7,0x2022,0x00B6,0x00DF,
133 0x00AE,0x00A9,0x2122,0x00B4,0x00A8,0x2260,0x00C6,0x00D8,
134 0x221E,0x00B1,0x2264,0x2265,0x00A5,0x00B5,0x2202,0x2211,
135 0x220F,0x03C0,0x222B,0x00AA,0x00BA,0x03A9,0x00E6,0x00F8,
136 0x00BF,0x00A1,0x00AC,0x221A,0x0192,0x2248,0x2206,0x00AB,
137 0x00BB,0x2026,0x00A0,0x00C0,0x00C3,0x00D5,0x0152,0x0153,
138 0x2013,0x2014,0x201C,0x201D,0x2018,0x2019,0x00F7,0x25CA,
139 0x00FF,0x0178,0x2044,0x20AC,0x2039,0x203A,0xFB01,0xFB02,
140 0x2021,0x00B7,0x201A,0x201E,0x2030,0x00C2,0x00CA,0x00C1,
141 0x00CB,0x00C8,0x00CD,0x00CE,0x00CF,0x00CC,0x00D3,0x00D4,
142 0xF8FF,0x00D2,0x00DA,0x00DB,0x00D9,0x0131,0x02C6,0x02DC,
143 0x00AF,0x02D8,0x02D9,0x02DA,0x00B8,0x02DD,0x02DB,0x02C7,
147 char *dst,
int dstlen)
150 char *
end = dst+dstlen-1;
153 for (i = 0; i <
len; i++) {
155 if (c < 0x80 && p < end)
208 char language[4] = { 0 };
210 uint16_t langcode = 0;
211 double longitude, latitude;
212 const char *key =
"location";
214 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4)
234 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f/", latitude, longitude);
235 if (*language && strcmp(language,
"und")) {
237 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
247 char key2[32], language[4] = {0};
249 const char *key =
NULL;
250 uint16_t langcode = 0;
251 uint32_t data_type = 0, str_size, str_size_alloc;
256 case MKTAG(
'@',
'P',
'R',
'M'): key =
"premiere_version"; raw = 1;
break;
257 case MKTAG(
'@',
'P',
'R',
'Q'): key =
"quicktime_version"; raw = 1;
break;
258 case MKTAG(
'X',
'M',
'P',
'_'):
259 if (c->
export_xmp) { key =
"xmp"; raw = 1; }
break;
260 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
261 case MKTAG(
'a',
'k',
'I',
'D'): key =
"account_type";
263 case MKTAG(
'a',
'p',
'I',
'D'): key =
"account_id";
break;
264 case MKTAG(
'c',
'a',
't',
'g'): key =
"category";
break;
265 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
267 case MKTAG(
'c',
'p',
'r',
't'): key =
"copyright";
break;
268 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
269 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
271 case MKTAG(
'e',
'g',
'i',
'd'): key =
"episode_uid";
273 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
275 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
277 case MKTAG(
'k',
'e',
'y',
'w'): key =
"keywords";
break;
278 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
279 case MKTAG(
'l',
'o',
'c',
'i'):
281 case MKTAG(
'p',
'c',
's',
't'): key =
"podcast";
283 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
285 case MKTAG(
'p',
'u',
'r',
'd'): key =
"purchase_date";
break;
286 case MKTAG(
'r',
't',
'n',
'g'): key =
"rating";
288 case MKTAG(
's',
'o',
'a',
'a'): key =
"sort_album_artist";
break;
289 case MKTAG(
's',
'o',
'a',
'l'): key =
"sort_album";
break;
290 case MKTAG(
's',
'o',
'a',
'r'): key =
"sort_artist";
break;
291 case MKTAG(
's',
'o',
'c',
'o'): key =
"sort_composer";
break;
292 case MKTAG(
's',
'o',
'n',
'm'): key =
"sort_name";
break;
293 case MKTAG(
's',
'o',
's',
'n'): key =
"sort_show";
break;
294 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
296 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
298 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
299 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
301 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
302 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
303 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
305 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
306 case MKTAG(0xa9,
'P',
'R',
'D'): key =
"producer";
break;
307 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
308 case MKTAG(0xa9,
'a',
'u',
't'): key =
"artist";
break;
309 case MKTAG(0xa9,
'c',
'h',
'p'): key =
"chapter";
break;
310 case MKTAG(0xa9,
'c',
'm',
't'): key =
"comment";
break;
311 case MKTAG(0xa9,
'c',
'o',
'm'): key =
"composer";
break;
312 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
313 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
314 case MKTAG(0xa9,
'd',
'i',
'r'): key =
"director";
break;
315 case MKTAG(0xa9,
'd',
'i',
's'): key =
"disclaimer";
break;
316 case MKTAG(0xa9,
'e',
'd',
'1'): key =
"edit_date";
break;
317 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
318 case MKTAG(0xa9,
'f',
'm',
't'): key =
"original_format";
break;
319 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
320 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
321 case MKTAG(0xa9,
'h',
's',
't'): key =
"host_computer";
break;
322 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
323 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
324 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
325 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
326 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
327 case MKTAG(0xa9,
'o',
'p',
'e'): key =
"original_artist";
break;
328 case MKTAG(0xa9,
'p',
'r',
'd'): key =
"producer";
break;
329 case MKTAG(0xa9,
'p',
'r',
'f'): key =
"performers";
break;
330 case MKTAG(0xa9,
'r',
'e',
'q'): key =
"playback_requirements";
break;
331 case MKTAG(0xa9,
's',
'r',
'c'): key =
"original_source";
break;
332 case MKTAG(0xa9,
's',
't',
'3'): key =
"subtitle";
break;
333 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
334 case MKTAG(0xa9,
't',
'o',
'o'): key =
"encoder";
break;
335 case MKTAG(0xa9,
't',
'r',
'k'): key =
"track";
break;
336 case MKTAG(0xa9,
'u',
'r',
'l'): key =
"URL";
break;
337 case MKTAG(0xa9,
'w',
'r',
'n'): key =
"warning";
break;
338 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
339 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
345 if (tag ==
MKTAG(
'd',
'a',
't',
'a')) {
348 str_size = data_size - 16;
351 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
361 if (str_size > atom.
size) {
371 str_size = atom.
size;
380 if (atom.
size < 0 || str_size >= INT_MAX/2)
384 str_size_alloc = (raw ? str_size : str_size * 2) + 1;
390 parse(c, pb, str_size, key);
392 if (!raw && (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff)))) {
396 if (ret != str_size) {
404 if (*language && strcmp(language,
"und")) {
405 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
409 av_dlog(c->
fc,
"lang \"%3s\" ", language);
410 av_dlog(c->
fc,
"tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64
"\n",
411 key, str, (
char*)&atom.
type, str_size_alloc, atom.
size);
420 int i, nb_chapters, str_len,
version;
423 if ((atom.
size -= 5) < 0)
432 for (i = 0; i < nb_chapters; i++) {
439 if ((atom.
size -= 9+str_len) < 0)
449 #define MIN_DATA_ENTRY_BOX_SIZE 12
464 entries >= UINT_MAX /
sizeof(*sc->
drefs))
483 av_dlog(c->
fc,
"type %.4s size %d\n", (
char*)&dref->
type, size);
485 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
487 uint16_t volume_len,
len;
493 volume_len =
FFMIN(volume_len, 27);
495 dref->
volume[volume_len] = 0;
501 len =
FFMIN(len, 63);
516 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
530 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
532 memmove(dref->
path, dref->
path+volume_len, len);
535 for (j = 0; j <
len; j++)
536 if (dref->
path[j] ==
':')
539 }
else if (type == 0) {
547 for (j = 0; j <
len; j++)
548 if (dref->
dir[j] ==
':')
580 av_dlog(c->
fc,
"ctype= %.4s (0x%08x)\n", (
char*)&ctype, ctype);
581 av_dlog(c->
fc,
"stype= %.4s\n", (
char*)&type);
583 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
585 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
587 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
589 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
596 title_size = atom.
size - 24;
597 if (title_size > 0) {
602 title_str[title_size] = 0;
604 int off = (!c->
isom && title_str[0] == title_size - 1);
644 int ac3info, acmod, lfeon, bsmod;
656 bsmod = (ac3info >> 14) & 0x7;
657 acmod = (ac3info >> 11) & 0x7;
658 lfeon = (ac3info >> 10) & 0x1;
659 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
676 int eac3info, acmod, lfeon, bsmod;
692 bsmod = (eac3info >> 12) & 0x1f;
693 acmod = (eac3info >> 9) & 0x7;
694 lfeon = (eac3info >> 8) & 0x1;
755 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
758 }
else if (den != 0) {
779 char* comp_brands_str;
783 if (strcmp(type,
"qt "))
790 comp_brand_size = atom.
size - 8;
791 if (comp_brand_size < 0)
793 comp_brands_str =
av_malloc(comp_brand_size + 1);
794 if (!comp_brands_str)
796 avio_read(pb, comp_brands_str, comp_brand_size);
797 comp_brands_str[comp_brand_size] = 0;
833 "read the mfra (may be a live ismv)\n");
837 "seekable, can not look for mfra\n");
849 struct tm *ptm, tmbuf;
851 if(time >= 2082844800)
856 if (strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm))
866 char language[4] = {0};
868 int64_t creation_time;
908 int64_t creation_time;
957 av_dlog(c->
fc,
"enda %d\n", little_endian);
958 if (little_endian == 1) {
982 char color_parameter_type[5] = { 0 };
990 if (strncmp(color_parameter_type,
"nclx", 4) &&
991 strncmp(color_parameter_type,
"nclc", 4)) {
993 color_parameter_type);
1001 av_dlog(c->
fc,
"%s: pri %d trc %d matrix %d",
1002 color_parameter_type, color_primaries, color_trc, color_matrix);
1006 av_dlog(c->
fc,
" full %"PRIu8
"", color_range);
1026 switch (color_primaries) {
1032 switch (color_trc) {
1037 switch (color_matrix) {
1051 unsigned mov_field_order;
1060 if ((mov_field_order & 0xFF00) == 0x0100)
1062 else if ((mov_field_order & 0xFF00) == 0x0200) {
1063 switch (mov_field_order & 0xFF) {
1086 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
1100 int64_t result = atom.
size;
1109 }
else if (err < atom.
size) {
1123 uint64_t original_size;
1197 codec->
width = 1440;
1209 uint64_t original_size;
1212 if (atom.
size == 16) {
1217 if (length == atom.
size) {
1219 switch (range_value) {
1259 if ((uint64_t)atom.
size > (1<<30))
1269 }
else if (atom.
size > 8) {
1290 if ((uint64_t)atom.
size > (1<<30))
1293 if (atom.
size >= 10) {
1299 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1323 if (atom.
size >= (1<<28) || atom.
size < 7)
1327 if ((profile_level & 0xf0) != 0xc0)
1349 if (atom.
size <= 40)
1353 if ((uint64_t)atom.
size > (1<<30))
1367 unsigned int i, entries;
1391 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1394 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1427 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1428 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1435 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1459 unsigned int color_depth,
len, j;
1460 int color_greyscale;
1488 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1495 !memcmp(codec_name,
"Sorenson H263", 13))
1500 av_dlog(c->
fc,
"depth %d, ctab id %d\n",
1510 if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
1512 unsigned int color_start, color_count, color_end;
1513 unsigned char a,
r,
g,
b;
1515 if (color_greyscale) {
1516 int color_index, color_dec;
1519 color_count = 1 << color_depth;
1521 color_dec = 256 / (color_count - 1);
1522 for (j = 0; j < color_count; j++) {
1523 r = g = b = color_index;
1524 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1525 color_index -= color_dec;
1526 if (color_index < 0)
1529 }
else if (color_table_id) {
1532 color_count = 1 << color_depth;
1533 if (color_depth == 2)
1535 else if (color_depth == 4)
1540 for (j = 0; j < color_count; j++) {
1541 r = color_table[j * 3 + 0];
1542 g = color_table[j * 3 + 1];
1543 b = color_table[j * 3 + 2];
1544 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1551 if ((color_start <= 255) && (color_end <= 255)) {
1552 for (j = color_start; j <= color_end; j++) {
1563 sc->
palette[j] = (a << 24 ) | (r << 16) | (g << 8) | (b);
1574 int bits_per_sample,
flags;
1591 av_dlog(c->
fc,
"version =%d, isom =%d\n", version, c->
isom);
1593 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1600 }
else if (version == 2) {
1658 if (bits_per_sample) {
1683 y = (ycbcr >> 16) & 0xFF;
1684 cr = (ycbcr >> 8) & 0xFF;
1687 b = av_clip_uint8(1.164 * (y - 16) + 2.018 * (cb - 128));
1688 g = av_clip_uint8(1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128));
1689 r = av_clip_uint8(1.164 * (y - 16) + 1.596 * (cr - 128));
1691 return (r << 16) | (g << 8) | b;
1696 char buf[256] = {0};
1704 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
1708 for (i = 0; i < 16; i++) {
1709 uint32_t yuv =
AV_RB32(src + i * 4);
1712 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
1715 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
1755 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
1757 if (str_size > 0 && size >= (
int)str_size + 26) {
1758 char *reel_name =
av_malloc(str_size + 1);
1762 reel_name[str_size] = 0;
1764 if (*reel_name == 0) {
1789 #if CONFIG_DV_DEMUXER
1855 int codec_tag,
int format,
1861 (codec_tag != format &&
1863 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
1872 if ( codec_tag ==
AV_RL32(
"avc1") ||
1873 codec_tag ==
AV_RL32(
"hvc1") ||
1885 int pseudo_stream_id;
1892 for (pseudo_stream_id = 0;
1894 pseudo_stream_id++) {
1897 int ret, dref_id = 1;
1907 }
else if (size <= 7){
1921 av_dlog(c->
fc,
"size=%"PRId64
" 4CC= %c%c%c%c codec_type=%d\n", size,
1922 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
1946 }
else if (a.
size > 0)
1971 unsigned int i, entries;
1995 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2013 unsigned i, entries;
2031 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2048 unsigned int i, entries;
2060 av_dlog(c->
fc,
"keyframe_count = %d\n", entries);
2071 if (entries >= UINT_MAX /
sizeof(
int))
2079 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2096 unsigned int i, entries, sample_size, field_size, num_bytes;
2108 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
2127 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
2134 if (entries >= (UINT_MAX - 4) / field_size)
2144 num_bytes = (entries*field_size+4)>>3;
2152 if (
avio_read(pb, buf, num_bytes) < num_bytes) {
2160 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2178 unsigned int i, entries;
2180 int64_t total_sample_count=0;
2191 av_dlog(c->
fc,
"track[%i].stts.entries = %i\n",
2202 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2203 int sample_duration;
2210 if (sample_duration < 0) {
2213 sample_duration = 1;
2215 if (sample_count < 0) {
2222 av_dlog(c->
fc,
"sample_count=%d, sample_duration=%d\n",
2223 sample_count, sample_duration);
2227 && sample_count == 1
2228 && total_sample_count > 100
2229 && sample_duration/10 > duration / total_sample_count)
2230 sample_duration = duration / total_sample_count;
2231 duration+=(int64_t)sample_duration*sample_count;
2232 total_sample_count+=sample_count;
2261 unsigned int i, entries;
2276 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2282 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2289 av_dlog(c->
fc,
"count=%d, duration=%d\n",
2292 if (
FFABS(duration) > (1<<28) && i+2<entries) {
2317 unsigned int i, entries;
2319 uint32_t grouping_type;
2329 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2345 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2358 int64_t current_offset;
2359 int64_t current_dts = 0;
2360 unsigned int stts_index = 0;
2361 unsigned int stsc_index = 0;
2362 unsigned int stss_index = 0;
2363 unsigned int stps_index = 0;
2365 uint64_t stream_size = 0;
2369 int64_t empty_duration = 0;
2374 if (i == 0 && e->
time == -1) {
2378 edit_start_index = 1;
2379 }
else if (i == edit_start_index && e->
time >= 0) {
2380 start_time = e->
time;
2386 "a/v desync might occur, patch welcome\n");
2389 if ((empty_duration || start_time) && mov->
time_scale > 0) {
2407 unsigned int current_sample = 0;
2408 unsigned int stts_sample = 0;
2409 unsigned int sample_size;
2411 unsigned int rap_group_index = 0;
2412 unsigned int rap_group_sample = 0;
2463 if (rap_group_present && rap_group_index < sc->rap_group_count) {
2466 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
2467 rap_group_sample = 0;
2473 && !rap_group_present
2482 e->
pos = current_offset;
2484 e->
size = sample_size;
2487 av_dlog(mov->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2488 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
2489 current_offset, current_dts, sample_size, distance, keyframe);
2494 current_offset += sample_size;
2495 stream_size += sample_size;
2509 unsigned chunk_samples, total = 0;
2513 unsigned count, chunk_count;
2526 count = (chunk_samples+samples-1) / samples;
2528 count = (chunk_samples+1023) / 1024;
2531 if (i < sc->stsc_count - 1)
2535 total += chunk_count *
count;
2538 av_dlog(mov->
fc,
"chunk count %d\n", total);
2557 while (chunk_samples > 0) {
2559 unsigned size, samples;
2570 samples =
FFMIN(1024, chunk_samples);
2580 e->
pos = current_offset;
2585 av_dlog(mov->
fc,
"AVIndex stream %d, chunk %d, offset %"PRIx64
", dts %"PRId64
", "
2586 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
2589 current_offset +=
size;
2590 current_dts += samples;
2591 chunk_samples -= samples;
2603 char filename[1024];
2604 const char *src_path;
2608 src_path = strrchr(src,
'/');
2615 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
2616 if (ref->
path[l] ==
'/') {
2624 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
2625 memcpy(filename, src, src_path - src);
2626 filename[src_path -
src] = 0;
2636 }
else if (use_absolute_path) {
2638 "this is a possible security issue\n");
2663 if (!st)
return AVERROR(ENOMEM);
2666 if (!sc)
return AVERROR(ENOMEM);
2694 "stream %d, error opening alias: path='%s', dir='%s', "
2695 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
2711 #if FF_API_R_FRAME_RATE
2727 #if CONFIG_H261_DECODER
2730 #if CONFIG_H263_DECODER
2733 #if CONFIG_MPEG4_DECODER
2776 for (i = 0; i < 2; i++) {
2787 if (len < 12 || len - 12 > end -
avio_tell(pb))
2791 if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
2793 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
2808 if (strcmp(key,
"iTunSMPB") == 0) {
2809 int priming, remainder, samples;
2810 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
2811 if(priming>0 && priming<16384)
2815 if (strcmp(key,
"cdec") != 0) {
2839 if (len > atom.
size)
2842 if (tag ==
MKTAG(
'm',
'e',
'a',
'n') && len > 12) {
2849 domain_len =
avio_get_str(pb, len, domain,
sizeof(domain));
2856 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
2862 while (atom.
size > 8) {
2865 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
2879 int display_matrix[3][3];
2918 for (i = 0; i < 3; i++) {
2926 sc->
width = width >> 16;
2927 sc->
height = height >> 16;
2931 if (display_matrix[0][0] != (1 << 16) ||
2932 display_matrix[1][1] != (1 << 16) ||
2933 display_matrix[2][2] != (1 << 30) ||
2934 display_matrix[0][1] || display_matrix[0][2] ||
2935 display_matrix[1][0] || display_matrix[1][2] ||
2936 display_matrix[2][0] || display_matrix[2][1]) {
2945 for (i = 0; i < 3; i++)
2946 for (j = 0; j < 3; j++)
2950 if (!
isnan(rotate)) {
2951 char rotate_buf[64];
2955 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
2963 double disp_transform[2];
2965 #define SQR(a) ((a)*(double)(a))
2966 for (i = 0; i < 2; i++)
2967 disp_transform[i] = sqrt(
SQR(display_matrix[i][0]) +
SQR(display_matrix[i][1]));
2969 if (disp_transform[0] > 0 && disp_transform[1] > 0 &&
2970 disp_transform[0] < (1<<24) && disp_transform[1] < (1<<24) &&
2971 fabs((disp_transform[0] / disp_transform[1]) - 1.0) > 0.01)
2973 disp_transform[0] / disp_transform[1],
2984 int flags, track_id, i;
3006 "found fragment index for track %u\n", frag->
track_id);
3026 for (i = index->
current_item; i < index->item_count; i++) {
3029 "for track %u and moof_offset %"PRId64
"\n",
3038 "but it doesn't have an (in-order) entry for moof_offset "
3116 int data_offset = 0;
3117 unsigned entries, first_sample_flags = frag->
flags;
3136 av_dlog(c->
fc,
"flags 0x%x entries %d\n", flags, entries);
3166 av_dlog(c->
fc,
"first sample flags 0x%x\n", first_sample_flags);
3167 for (i = 0; i < entries && !pb->
eof_reached; i++) {
3168 unsigned sample_size = frag->
size;
3169 int sample_flags = i ? frag->
flags : first_sample_flags;
3170 unsigned sample_duration = frag->
duration;
3184 " sc->dts_shift %d ctts.duration %d"
3185 " sc->time_offset %"PRId64
" flags & MOV_TRUN_SAMPLE_CTS %d\n", pts,
3189 if (flags & MOV_TRUN_SAMPLE_CTS) {
3198 ", using it for dts\n", dts);
3205 else if (!found_keyframe)
3206 keyframe = found_keyframe =
3216 av_dlog(c->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
3218 offset, dts, sample_size, distance, keyframe);
3220 dts += sample_duration;
3221 offset += sample_size;
3250 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
3264 long cmov_len, moov_len;
3278 cmov_len = atom.
size - 6 * 4;
3289 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
3290 goto free_and_return;
3292 goto free_and_return;
3294 atom.
size = moov_len;
3331 for (i = 0; i < edit_count && !pb->
eof_reached; i++) {
3342 av_dlog(c->
fc,
"duration=%"PRId64
" time=%"PRId64
" rate=%f\n",
3365 static const uint8_t uuid_isml_manifest[] = {
3366 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
3367 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
3370 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
3373 ret =
avio_read(pb, uuid,
sizeof(uuid));
3376 }
else if (ret !=
sizeof(uuid)) {
3379 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
3382 size_t len = atom.
size -
sizeof(uuid);
3398 }
else if (ret != len) {
3404 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
3405 ptr +=
sizeof(
"systemBitrate=\"") - 1;
3414 ret = strtol(ptr, &endptr, 10);
3415 if (ret < 0 || errno || *endptr !=
'"') {
3441 && !memcmp(content,
"Anevia\x1A\x1A", 8)
3525 int64_t total_size = 0;
3536 atom.
size = INT64_MAX;
3541 if (atom.
size >= 8) {
3548 uint32_t *
type = (uint32_t *)buf + 1;
3551 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
3552 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
3557 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
3569 if (a.
size == 1 && total_size + 8 <= atom.
size) {
3574 av_dlog(c->
fc,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
3577 a.
size = atom.
size - total_size + 8;
3584 for (i = 0; mov_default_parse_table[i].
type; i++)
3585 if (mov_default_parse_table[i].
type == a.
type) {
3600 int err =
parse(c, pb, a);
3616 else if (left < 0) {
3618 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
3619 (
char*)&a.
type, -left);
3624 total_size += a.
size;
3627 if (total_size < atom.
size && atom.
size < 0x7ffff)
3639 int moov_offset = -1;
3645 if ((offset + 8) > (
unsigned int)p->
buf_size)
3650 case MKTAG(
'm',
'o',
'o',
'v'):
3651 moov_offset = offset + 4;
3652 case MKTAG(
'm',
'd',
'a',
't'):
3653 case MKTAG(
'p',
'n',
'o',
't'):
3654 case MKTAG(
'u',
'd',
't',
'a'):
3655 case MKTAG(
'f',
't',
'y',
'p'):
3658 offset + 12 > (
unsigned int)p->
buf_size ||
3661 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
3663 score =
FFMAX(score, 5);
3670 case MKTAG(
'e',
'd',
'i',
'w'):
3671 case MKTAG(
'w',
'i',
'd',
'e'):
3672 case MKTAG(
'f',
'r',
'e',
'e'):
3673 case MKTAG(
'j',
'u',
'n',
'k'):
3674 case MKTAG(
'p',
'i',
'c',
't'):
3678 case MKTAG(0x82,0x82,0x7f,0x7d):
3679 case MKTAG(
's',
'k',
'i',
'p'):
3680 case MKTAG(
'u',
'u',
'i',
'd'):
3681 case MKTAG(
'p',
'r',
'f',
'l'):
3693 offset = moov_offset;
3695 while(offset < (p->
buf_size - 16)){
3745 if (end < sample->timestamp) {
3757 if (len > sample->
size-2)
3759 title_len = 2*len + 1;
3772 else if (ch == 0xfffe)
3776 if (len == 1 || len == 2)
3921 int version, fieldlength, i, j;
3952 if (!index->
items) {
3967 for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
3969 for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
3971 for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
3986 if ((seek_ret =
avio_seek(f, stream_size - 4, SEEK_SET)) < 0) {
3991 if (mfra_size < 0 || mfra_size > stream_size) {
3995 if ((seek_ret =
avio_seek(f, -mfra_size, SEEK_CUR)) < 0) {
4015 seek_ret =
avio_seek(f, original_pos, SEEK_SET);
4018 "failed to seek back after looking for mfra\n");
4037 atom.
size = INT64_MAX;
4070 int tmcd_st_id = -1;
4076 if (tmcd_st_id < 0 || tmcd_st_id == i)
4175 int64_t best_dts = INT64_MAX;
4186 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
4189 sample = current_sample;
4249 #if CONFIG_DV_DEMUXER
4284 av_dlog(s,
"stream %d, pts %"PRId64
", dts %"PRId64
", pos 0x%"PRIx64
", duration %d\n",
4296 av_dlog(s,
"stream %d, timestamp %"PRId64
", sample %d\n", st->
index, timestamp, sample);
4297 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
4322 int64_t seek_timestamp, timestamp;
4329 st = s->
streams[stream_index];
4342 if (stream_index == i)
4351 #define OFFSET(x) offsetof(MOVContext, x)
4352 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
4354 {
"use_absolute_path",
4355 "allow using absolute path when opening alias, this is a possible security issue",
4361 "use mfra for fragment timestamps",
4366 FLAGS,
"use_mfra_for" },
4368 FLAGS,
"use_mfra_for" },
4370 FLAGS,
"use_mfra_for" },
4371 {
"export_all",
"Export unrecognized metadata entries",
OFFSET(export_all),
4373 {
"export_xmp",
"Export full XMP metadata",
OFFSET(export_xmp),
4386 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
4390 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2",