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)
211 unsigned len,
const char *key)
223 char language[4] = { 0 };
225 uint16_t langcode = 0;
226 double longitude, latitude;
227 const char *key =
"location";
229 if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4)
249 snprintf(buf,
sizeof(buf),
"%+08.4f%+09.4f/", latitude, longitude);
250 if (*language && strcmp(language,
"und")) {
252 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
261 #ifdef MOV_EXPORT_ALL_METADATA
264 char str[1024], key2[16], language[4] = {0};
265 const char *key = NULL;
266 uint16_t langcode = 0;
267 uint32_t data_type = 0, str_size;
271 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
272 case MKTAG(0xa9,
'a',
'u',
't'):
273 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
274 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
275 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
276 case MKTAG(
'c',
'p',
'i',
'l'): key =
"compilation";
278 case MKTAG(
'c',
'p',
'r',
't'):
279 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
280 case MKTAG(0xa9,
'g',
'r',
'p'): key =
"grouping";
break;
281 case MKTAG(0xa9,
'l',
'y',
'r'): key =
"lyrics";
break;
282 case MKTAG(0xa9,
'c',
'm',
't'):
283 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
284 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
285 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
286 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
287 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
289 case MKTAG(0xa9,
't',
'o',
'o'):
290 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
291 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
292 case MKTAG(0xa9,
'm',
'a',
'k'): key =
"make";
break;
293 case MKTAG(0xa9,
'm',
'o',
'd'): key =
"model";
break;
294 case MKTAG(0xa9,
'x',
'y',
'z'): key =
"location";
break;
295 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
296 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
297 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
298 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
299 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
300 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
302 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
304 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
306 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
308 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
310 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
312 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
314 case MKTAG(
'@',
'P',
'R',
'M'):
316 case MKTAG(
'@',
'P',
'R',
'Q'):
318 case MKTAG(
'l',
'o',
'c',
'i'):
320 case MKTAG(
'X',
'M',
'P',
'_'):
327 if (tag ==
MKTAG(
'd',
'a',
't',
'a')) {
330 str_size = data_size - 16;
333 if (atom.
type ==
MKTAG(
'c',
'o',
'v',
'r')) {
347 str_size = atom.
size;
349 #ifdef MOV_EXPORT_ALL_METADATA
361 str_size =
FFMIN3(
sizeof(str)-1, str_size, atom.
size);
364 parse(c, pb, str_size, key);
366 if (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff))) {
376 if (*language && strcmp(language,
"und")) {
377 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
381 av_dlog(c->
fc,
"lang \"%3s\" ", language);
382 av_dlog(c->
fc,
"tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64
"\n",
383 key, str, (
char*)&atom.
type, str_size, atom.
size);
391 int i, nb_chapters, str_len,
version;
394 if ((atom.
size -= 5) < 0)
403 for (i = 0; i < nb_chapters; i++) {
410 if ((atom.
size -= 9+str_len) < 0)
420 #define MIN_DATA_ENTRY_BOX_SIZE 12
435 entries >= UINT_MAX /
sizeof(*sc->
drefs))
454 av_dlog(c->
fc,
"type %.4s size %d\n", (
char*)&dref->
type, size);
456 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
458 uint16_t volume_len,
len;
464 volume_len =
FFMIN(volume_len, 27);
466 dref->
volume[volume_len] = 0;
472 len =
FFMIN(len, 63);
487 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
501 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
503 memmove(dref->
path, dref->
path+volume_len, len);
506 for (j = 0; j <
len; j++)
507 if (dref->
path[j] ==
':')
510 }
else if (type == 0) {
518 for (j = 0; j <
len; j++)
519 if (dref->
dir[j] ==
':')
551 av_dlog(c->
fc,
"ctype= %.4s (0x%08x)\n", (
char*)&ctype, ctype);
552 av_dlog(c->
fc,
"stype= %.4s\n", (
char*)&type);
554 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
556 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
558 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
560 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
567 title_size = atom.
size - 24;
568 if (title_size > 0) {
573 title_str[title_size] = 0;
576 (!c->
isom && title_str[0] == title_size - 1), 0);
613 int ac3info, acmod, lfeon, bsmod;
620 bsmod = (ac3info >> 14) & 0x7;
621 acmod = (ac3info >> 11) & 0x7;
622 lfeon = (ac3info >> 10) & 0x1;
623 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
637 int eac3info, acmod, lfeon, bsmod;
648 bsmod = (eac3info >> 12) & 0x1f;
649 acmod = (eac3info >> 9) & 0x7;
650 lfeon = (eac3info >> 8) & 0x1;
709 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
712 }
else if (den != 0) {
733 char* comp_brands_str;
737 if (strcmp(type,
"qt "))
744 comp_brand_size = atom.
size - 8;
745 if (comp_brand_size < 0)
747 comp_brands_str =
av_malloc(comp_brand_size + 1);
748 if (!comp_brands_str)
750 avio_read(pb, comp_brands_str, comp_brand_size);
751 comp_brands_str[comp_brand_size] = 0;
790 if(time >= 2082844800)
793 ptm = gmtime(&timet);
795 strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm);
805 char language[4] = {0};
807 int64_t creation_time;
847 int64_t creation_time;
896 av_dlog(c->
fc,
"enda %d\n", little_endian);
897 if (little_endian == 1) {
921 unsigned mov_field_order;
930 if ((mov_field_order & 0xFF00) == 0x0100)
932 else if ((mov_field_order & 0xFF00) == 0x0200) {
933 switch (mov_field_order & 0xFF) {
969 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
982 }
else if (err < atom.
size) {
986 memset(buf + 8 + err, 0, FF_INPUT_BUFFER_PADDING_SIZE);
1038 codec->
width = 1440;
1059 if ((uint64_t)atom.
size > (1<<30))
1069 }
else if (atom.
size > 8) {
1090 if ((uint64_t)atom.
size > (1<<30))
1093 if (atom.
size >= 10) {
1099 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1119 if (atom.
size >= (1<<28) || atom.
size < 7)
1123 if ((profile_level & 0xf0) != 0xc0)
1145 if (atom.
size <= 40)
1149 if ((uint64_t)atom.
size > (1<<30))
1163 unsigned int i, entries;
1177 if (entries >= UINT_MAX/
sizeof(int64_t))
1185 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1188 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1221 ((format & 0xFFFF) ==
'm' + (
's' << 8) ||
1222 (format & 0xFFFF) ==
'T' + (
'S' << 8)))
1229 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1253 unsigned int color_depth,
len, j;
1254 int color_greyscale;
1282 if (!memcmp(codec_name,
"Planar Y'CbCr 8-bit 4:2:0", 25)) {
1289 !memcmp(codec_name,
"Sorenson H263", 13))
1294 av_dlog(c->
fc,
"depth %d, ctab id %d\n",
1304 if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
1306 unsigned int color_start, color_count, color_end;
1307 unsigned char a,
r,
g,
b;
1309 if (color_greyscale) {
1310 int color_index, color_dec;
1313 color_count = 1 << color_depth;
1315 color_dec = 256 / (color_count - 1);
1316 for (j = 0; j < color_count; j++) {
1317 r = g = b = color_index;
1318 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1319 color_index -= color_dec;
1320 if (color_index < 0)
1323 }
else if (color_table_id) {
1326 color_count = 1 << color_depth;
1327 if (color_depth == 2)
1329 else if (color_depth == 4)
1334 for (j = 0; j < color_count; j++) {
1335 r = color_table[j * 3 + 0];
1336 g = color_table[j * 3 + 1];
1337 b = color_table[j * 3 + 2];
1338 sc->
palette[j] = (0xFF
U << 24) | (r << 16) | (g << 8) | (b);
1345 if ((color_start <= 255) && (color_end <= 255)) {
1346 for (j = color_start; j <= color_end; j++) {
1357 sc->
palette[j] = (a << 24 ) | (r << 16) | (g << 8) | (b);
1368 int bits_per_sample,
flags;
1385 av_dlog(c->
fc,
"version =%d, isom =%d\n", version, c->
isom);
1387 (compatible_brands && strstr(compatible_brands->
value,
"qt "))) {
1394 }
else if (version == 2) {
1448 if (bits_per_sample) {
1473 y = (ycbcr >> 16) & 0xFF;
1474 cr = (ycbcr >> 8) & 0xFF;
1477 b = av_clip_uint8(1.164 * (y - 16) + 2.018 * (cb - 128));
1478 g = av_clip_uint8(1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128));
1479 r = av_clip_uint8(1.164 * (y - 16) + 1.596 * (cr - 128));
1481 return (r << 16) | (g << 8) | b;
1486 char buf[256] = {0};
1494 snprintf(buf,
sizeof(buf),
"size: %dx%d\n",
1498 for (i = 0; i < 16; i++) {
1499 uint32_t yuv =
AV_RB32(src + i * 4);
1502 av_strlcatf(buf,
sizeof(buf),
"%06"PRIx32
"%s", rgba, i != 15 ?
", " :
"");
1505 if (
av_strlcat(buf,
"\n",
sizeof(buf)) >=
sizeof(buf))
1538 if (format ==
AV_RB32(
"name") && (int64_t)size >= (int64_t)len + 18) {
1540 if (str_size > 0 && size >= (
int)str_size + 26) {
1541 char *reel_name =
av_malloc(str_size + 1);
1545 reel_name[str_size] = 0;
1547 if (*reel_name == 0) {
1572 #if CONFIG_DV_DEMUXER
1637 int codec_tag,
int format,
1643 (codec_tag != format &&
1645 : codec_tag !=
MKTAG(
'j',
'p',
'e',
'g')))) {
1654 if ( codec_tag ==
AV_RL32(
"avc1") ||
1655 codec_tag ==
AV_RL32(
"hvc1") ||
1667 int pseudo_stream_id;
1674 for (pseudo_stream_id = 0;
1676 pseudo_stream_id++) {
1679 int ret, dref_id = 1;
1689 }
else if (size <= 7){
1703 av_dlog(c->
fc,
"size=%"PRId64
" 4CC= %c%c%c%c codec_type=%d\n", size,
1704 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
1728 }
else if (a.
size > 0)
1753 unsigned int i, entries;
1769 if (entries >= UINT_MAX /
sizeof(*sc->
stsc_data))
1775 for (i = 0; i < entries && !pb->
eof_reached; i++) {
1793 unsigned i, entries;
1803 if (entries >= UINT_MAX /
sizeof(*sc->
stps_data))
1809 for (i = 0; i < entries && !pb->
eof_reached; i++) {
1826 unsigned int i, entries;
1838 av_dlog(c->
fc,
"keyframe_count = %d\n", entries);
1847 if (entries >= UINT_MAX /
sizeof(
int))
1853 for (i = 0; i < entries && !pb->
eof_reached; i++) {
1870 unsigned int i, entries, sample_size, field_size, num_bytes;
1882 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
1901 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
1908 if (entries >= UINT_MAX /
sizeof(
int) || entries >= (UINT_MAX - 4) / field_size)
1914 num_bytes = (entries*field_size+4)>>3;
1922 if (
avio_read(pb, buf, num_bytes) < num_bytes) {
1930 for (i = 0; i < entries && !pb->
eof_reached; i++) {
1948 unsigned int i, entries;
1950 int64_t total_sample_count=0;
1961 av_dlog(c->
fc,
"track[%i].stts.entries = %i\n",
1964 if (entries >= UINT_MAX /
sizeof(*sc->
stts_data))
1972 for (i = 0; i < entries && !pb->
eof_reached; i++) {
1973 int sample_duration;
1980 if (sample_duration < 0) {
1983 sample_duration = 1;
1985 if (sample_count < 0) {
1992 av_dlog(c->
fc,
"sample_count=%d, sample_duration=%d\n",
1993 sample_count, sample_duration);
1997 && sample_count == 1
1998 && total_sample_count > 100
1999 && sample_duration/10 > duration / total_sample_count)
2000 sample_duration = duration / total_sample_count;
2001 duration+=(int64_t)sample_duration*sample_count;
2002 total_sample_count+=sample_count;
2031 unsigned int i, entries;
2046 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
2052 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2059 av_dlog(c->
fc,
"count=%d, duration=%d\n",
2062 if (
FFABS(duration) > (1<<28) && i+2<entries) {
2087 unsigned int i, entries;
2089 uint32_t grouping_type;
2099 if (grouping_type !=
MKTAG(
'r',
'a',
'p',
' '))
2107 if (entries >= UINT_MAX /
sizeof(*sc->
rap_group))
2113 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2126 int64_t current_offset;
2127 int64_t current_dts = 0;
2128 unsigned int stts_index = 0;
2129 unsigned int stsc_index = 0;
2130 unsigned int stss_index = 0;
2131 unsigned int stps_index = 0;
2133 uint64_t stream_size = 0;
2153 unsigned int current_sample = 0;
2154 unsigned int stts_sample = 0;
2155 unsigned int sample_size;
2157 unsigned int rap_group_index = 0;
2158 unsigned int rap_group_sample = 0;
2209 if (rap_group_present && rap_group_index < sc->rap_group_count) {
2212 if (++rap_group_sample == sc->
rap_group[rap_group_index].
count) {
2213 rap_group_sample = 0;
2219 && !rap_group_present
2228 e->
pos = current_offset;
2230 e->
size = sample_size;
2233 av_dlog(mov->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2234 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
2235 current_offset, current_dts, sample_size, distance, keyframe);
2240 current_offset += sample_size;
2241 stream_size += sample_size;
2255 unsigned chunk_samples, total = 0;
2259 unsigned count, chunk_count;
2272 count = (chunk_samples+samples-1) / samples;
2274 count = (chunk_samples+1023) / 1024;
2277 if (i < sc->stsc_count - 1)
2281 total += chunk_count *
count;
2284 av_dlog(mov->
fc,
"chunk count %d\n", total);
2303 while (chunk_samples > 0) {
2305 unsigned size, samples;
2316 samples =
FFMIN(1024, chunk_samples);
2326 e->
pos = current_offset;
2331 av_dlog(mov->
fc,
"AVIndex stream %d, chunk %d, offset %"PRIx64
", dts %"PRId64
", "
2332 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
2335 current_offset +=
size;
2336 current_dts += samples;
2337 chunk_samples -= samples;
2349 char filename[1024];
2350 const char *src_path;
2354 src_path = strrchr(src,
'/');
2361 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
2362 if (ref->
path[l] ==
'/') {
2370 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
2371 memcpy(filename, src, src_path - src);
2372 filename[src_path -
src] = 0;
2382 }
else if (use_absolute_path) {
2384 "this is a possible security issue\n");
2409 if (!st)
return AVERROR(ENOMEM);
2412 if (!sc)
return AVERROR(ENOMEM);
2440 "stream %d, error opening alias: path='%s', dir='%s', "
2441 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
2456 #if FF_API_R_FRAME_RATE
2472 #if CONFIG_H261_DECODER
2475 #if CONFIG_H263_DECODER
2478 #if CONFIG_MPEG4_DECODER
2520 for (i = 0; i < 2; i++) {
2531 if (len < 12 || len - 12 > end -
avio_tell(pb))
2535 if (tag ==
MKTAG(
'n',
'a',
'm',
'e'))
2537 else if (tag ==
MKTAG(
'd',
'a',
't',
'a') && len > 4) {
2552 if (strcmp(key,
"iTunSMPB") == 0) {
2553 int priming, remainder, samples;
2554 if(sscanf(val,
"%*X %X %X %X", &priming, &remainder, &samples) == 3){
2555 if(priming>0 && priming<16384)
2559 if (strcmp(key,
"cdec") != 0) {
2583 if (len > atom.
size)
2586 if (tag ==
MKTAG(
'm',
'e',
'a',
'n') && len > 12) {
2593 domain_len =
avio_get_str(pb, len, domain,
sizeof(domain));
2600 "Unhandled or malformed custom metadata of size %"PRId64
"\n", atom.
size);
2606 while (atom.
size > 8) {
2609 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
2623 int64_t disp_transform[2];
2624 int display_matrix[3][3];
2663 for (i = 0; i < 3; i++) {
2671 sc->
width = width >> 16;
2672 sc->
height = height >> 16;
2676 if (display_matrix[0][0] != (1 << 16) ||
2677 display_matrix[1][1] != (1 << 16) ||
2678 display_matrix[2][2] != (1 << 30) ||
2679 display_matrix[0][1] || display_matrix[0][2] ||
2680 display_matrix[1][0] || display_matrix[1][2] ||
2681 display_matrix[2][0] || display_matrix[2][1]) {
2690 for (i = 0; i < 3; i++)
2691 for (j = 0; j < 3; j++)
2695 if (!
isnan(rotate)) {
2696 char rotate_buf[64];
2700 snprintf(rotate_buf,
sizeof(rotate_buf),
"%g", rotate);
2709 if (width && height &&
2710 ((display_matrix[0][0] != 65536 ||
2711 display_matrix[1][1] != 65536) &&
2712 !display_matrix[0][1] &&
2713 !display_matrix[1][0] &&
2714 !display_matrix[2][0] && !display_matrix[2][1])) {
2715 for (i = 0; i < 2; i++)
2717 (int64_t) width * display_matrix[0][i] +
2718 (int64_t) height * display_matrix[1][i] +
2719 ((int64_t) display_matrix[2][i] << 16);
2723 ((
double) disp_transform[0] * height) /
2724 ((
double) disp_transform[1] * width), INT_MAX);
2733 int flags, track_id, i;
2807 int data_offset = 0;
2808 unsigned entries, first_sample_flags = frag->
flags;
2827 av_dlog(c->
fc,
"flags 0x%x entries %d\n", flags, entries);
2857 av_dlog(c->
fc,
"first sample flags 0x%x\n", first_sample_flags);
2858 for (i = 0; i < entries && !pb->
eof_reached; i++) {
2859 unsigned sample_size = frag->
size;
2860 int sample_flags = i ? frag->
flags : first_sample_flags;
2861 unsigned sample_duration = frag->
duration;
2874 else if (!found_keyframe)
2875 keyframe = found_keyframe =
2882 av_dlog(c->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2884 offset, dts, sample_size, distance, keyframe);
2886 dts += sample_duration;
2887 offset += sample_size;
2916 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
2930 long cmov_len, moov_len;
2944 cmov_len = atom.
size - 6 * 4;
2955 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
2956 goto free_and_return;
2957 if (
ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
2958 goto free_and_return;
2960 atom.
size = moov_len;
2976 int i, edit_count,
version, edit_start_index = 0;
2987 if ((uint64_t)edit_count*12+8 > atom.
size)
2991 for (i=0; i<edit_count; i++){
3003 if (i == 0 && time == -1) {
3005 edit_start_index = 1;
3006 }
else if (i == edit_start_index && time >= 0)
3011 av_dlog(c->
fc,
"duration=%"PRId64
" time=%"PRId64
" rate=%f\n",
3012 duration, time, rate / 65536.0);
3017 "a/v desync might occur, patch welcome\n");
3037 static const uint8_t uuid_isml_manifest[] = {
3038 0xa5, 0xd4, 0x0b, 0x30, 0xe8, 0x14, 0x11, 0xdd,
3039 0xba, 0x2f, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66
3042 if (atom.
size <
sizeof(uuid) || atom.
size == INT64_MAX)
3045 ret =
avio_read(pb, uuid,
sizeof(uuid));
3048 }
else if (ret !=
sizeof(uuid)) {
3051 if (!memcmp(uuid, uuid_isml_manifest,
sizeof(uuid))) {
3054 size_t len = atom.
size -
sizeof(uuid);
3070 }
else if (ret != len) {
3076 while ((ptr =
av_stristr(ptr,
"systemBitrate=\""))) {
3077 ptr +=
sizeof(
"systemBitrate=\"") - 1;
3086 ret = strtol(ptr, &endptr, 10);
3087 if (ret < 0 || errno || *endptr !=
'"') {
3171 int64_t total_size = 0;
3176 atom.
size = INT64_MAX;
3181 if (atom.
size >= 8) {
3188 uint32_t *
type = (uint32_t *)buf + 1;
3191 if (*type ==
MKTAG(
'm',
'v',
'h',
'd') ||
3192 *type ==
MKTAG(
'c',
'm',
'o',
'v')) {
3197 if (atom.
type !=
MKTAG(
'r',
'o',
'o',
't') &&
3213 av_dlog(c->
fc,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
3216 a.
size = atom.
size - total_size + 8;
3223 for (i = 0; mov_default_parse_table[i].
type; i++)
3224 if (mov_default_parse_table[i].
type == a.
type) {
3239 int err =
parse(c, pb, a);
3252 else if (left < 0) {
3254 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
3255 (
char*)&a.
type, -left);
3260 total_size += a.
size;
3263 if (total_size < atom.
size && atom.
size < 0x7ffff)
3274 int moov_offset = -1;
3280 if ((offset + 8) > (
unsigned int)p->
buf_size)
3285 case MKTAG(
'm',
'o',
'o',
'v'):
3286 moov_offset = offset + 4;
3287 case MKTAG(
'm',
'd',
'a',
't'):
3288 case MKTAG(
'p',
'n',
'o',
't'):
3289 case MKTAG(
'u',
'd',
't',
'a'):
3290 case MKTAG(
'f',
't',
'y',
'p'):
3293 offset + 12 > (
unsigned int)p->
buf_size ||
3296 }
else if (tag ==
MKTAG(
'f',
't',
'y',
'p') &&
3298 score =
FFMAX(score, 5);
3305 case MKTAG(
'e',
'd',
'i',
'w'):
3306 case MKTAG(
'w',
'i',
'd',
'e'):
3307 case MKTAG(
'f',
'r',
'e',
'e'):
3308 case MKTAG(
'j',
'u',
'n',
'k'):
3309 case MKTAG(
'p',
'i',
'c',
't'):
3313 case MKTAG(0x82,0x82,0x7f,0x7d):
3314 case MKTAG(
's',
'k',
'i',
'p'):
3315 case MKTAG(
'u',
'u',
'i',
'd'):
3316 case MKTAG(
'p',
'r',
'f',
'l'):
3328 offset = moov_offset;
3330 while(offset < (p->
buf_size - 16)){
3335 av_log(NULL,
AV_LOG_WARNING,
"Found media data tag MPEG indicating this is a MOV-packed MPEG-PS.\n");
3380 if (end < sample->timestamp) {
3392 if (len > sample->
size-2)
3394 title_len = 2*len + 1;
3407 else if (ch == 0xfffe)
3411 if (len == 1 || len == 2)
3558 atom.
size = INT64_MAX;
3591 int tmcd_st_id = -1;
3597 if (tmcd_st_id < 0 || tmcd_st_id == i)
3685 int64_t best_dts = INT64_MAX;
3696 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
3699 sample = current_sample;
3759 #if CONFIG_DV_DEMUXER
3794 av_dlog(s,
"stream %d, pts %"PRId64
", dts %"PRId64
", pos 0x%"PRIx64
", duration %d\n",
3806 av_dlog(s,
"stream %d, timestamp %"PRId64
", sample %d\n", st->
index, timestamp, sample);
3807 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
3832 int64_t seek_timestamp, timestamp;
3839 st = s->
streams[stream_index];
3852 if (stream_index == i)
3862 {
"use_absolute_path",
3863 "allow using absolute path when opening alias, this is a possible security issue",
3879 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
3882 .extensions =
"mov,mp4,m4a,3gp,3g2,mj2",
3888 .priv_class = &mov_class,