69 unsigned len,
const char *key)
78 snprintf(buf,
sizeof(buf),
"%d", current);
80 snprintf(buf,
sizeof(buf),
"%d/%d", current, total);
87 unsigned len,
const char *key)
96 snprintf(buf,
sizeof(buf),
"%d",
avio_r8(pb));
103 unsigned len,
const char *key)
107 snprintf(buf,
sizeof(buf),
"%d",
avio_r8(pb));
114 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)
169 #ifdef MOV_EXPORT_ALL_METADATA
172 char str[1024], key2[16], language[4] = {0};
173 const char *key =
NULL;
174 uint16_t str_size, langcode = 0;
175 uint32_t data_type = 0;
179 case MKTAG(0xa9,
'n',
'a',
'm'): key =
"title";
break;
180 case MKTAG(0xa9,
'a',
'u',
't'):
181 case MKTAG(0xa9,
'A',
'R',
'T'): key =
"artist";
break;
182 case MKTAG(
'a',
'A',
'R',
'T'): key =
"album_artist";
break;
183 case MKTAG(0xa9,
'w',
'r',
't'): key =
"composer";
break;
184 case MKTAG(
'c',
'p',
'r',
't'):
185 case MKTAG(0xa9,
'c',
'p',
'y'): key =
"copyright";
break;
186 case MKTAG(0xa9,
'c',
'm',
't'):
187 case MKTAG(0xa9,
'i',
'n',
'f'): key =
"comment";
break;
188 case MKTAG(0xa9,
'a',
'l',
'b'): key =
"album";
break;
189 case MKTAG(0xa9,
'd',
'a',
'y'): key =
"date";
break;
190 case MKTAG(0xa9,
'g',
'e',
'n'): key =
"genre";
break;
191 case MKTAG(
'g',
'n',
'r',
'e'): key =
"genre";
193 case MKTAG(0xa9,
't',
'o',
'o'):
194 case MKTAG(0xa9,
's',
'w',
'r'): key =
"encoder";
break;
195 case MKTAG(0xa9,
'e',
'n',
'c'): key =
"encoder";
break;
196 case MKTAG(
'd',
'e',
's',
'c'): key =
"description";
break;
197 case MKTAG(
'l',
'd',
'e',
's'): key =
"synopsis";
break;
198 case MKTAG(
't',
'v',
's',
'h'): key =
"show";
break;
199 case MKTAG(
't',
'v',
'e',
'n'): key =
"episode_id";
break;
200 case MKTAG(
't',
'v',
'n',
'n'): key =
"network";
break;
201 case MKTAG(
't',
'r',
'k',
'n'): key =
"track";
203 case MKTAG(
'd',
'i',
's',
'k'): key =
"disc";
205 case MKTAG(
't',
'v',
'e',
's'): key =
"episode_sort";
207 case MKTAG(
't',
'v',
's',
'n'): key =
"season_number";
209 case MKTAG(
's',
't',
'i',
'k'): key =
"media_type";
211 case MKTAG(
'h',
'd',
'v',
'd'): key =
"hd_video";
213 case MKTAG(
'p',
'g',
'a',
'p'): key =
"gapless_playback";
220 if (tag ==
MKTAG(
'd',
'a',
't',
'a')) {
223 str_size = data_size - 16;
232 str_size = atom.
size;
234 #ifdef MOV_EXPORT_ALL_METADATA
236 snprintf(tmp_key, 5,
"%.4s", (
char*)&atom.
type);
246 str_size =
FFMIN3(
sizeof(str)-1, str_size, atom.
size);
249 parse(c, pb, str_size, key);
251 if (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff))) {
258 if (*language && strcmp(language,
"und")) {
259 snprintf(key2,
sizeof(key2),
"%s-%s", key, language);
263 av_dlog(c->
fc,
"lang \"%3s\" ", language);
264 av_dlog(c->
fc,
"tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64
"\n",
265 key, str, (
char*)&atom.
type, str_size, atom.
size);
273 int i, nb_chapters, str_len,
version;
276 if ((atom.
size -= 5) < 0)
285 for (i = 0; i < nb_chapters; i++) {
292 if ((atom.
size -= 9+str_len) < 0)
304 int64_t total_size = 0;
314 if (atom.
size >= 8) {
318 av_dlog(c->
fc,
"type: %08x '%.4s' parent:'%.4s' sz: %"PRId64
" %"PRId64
" %"PRId64
"\n",
335 for (i = 0; mov_default_parse_table[i].
type; i++)
336 if (mov_default_parse_table[i].type == a.
type) {
351 int err =
parse(c, pb, a);
362 "overread end of atom '%.4s' by %"PRId64
" bytes\n",
363 (
char*)&a.
type, -left);
368 total_size += a.
size;
371 if (total_size < atom.
size && atom.
size < 0x7ffff)
390 if (entries >= UINT_MAX /
sizeof(*sc->
drefs))
407 av_dlog(c->
fc,
"type %.4s size %d\n", (
char*)&dref->
type, size);
409 if (dref->
type ==
MKTAG(
'a',
'l',
'i',
's') && size > 150) {
411 uint16_t volume_len,
len;
417 volume_len =
FFMIN(volume_len, 27);
419 dref->
volume[volume_len] = 0;
425 len =
FFMIN(len, 63);
440 for (type = 0; type != -1 &&
avio_tell(pb) < next; ) {
452 if (len > volume_len && !strncmp(dref->
path, dref->
volume, volume_len)) {
454 memmove(dref->
path, dref->
path+volume_len, len);
457 for (j = 0; j <
len; j++)
458 if (dref->
path[j] ==
':')
461 }
else if (type == 0) {
468 for (j = 0; j <
len; j++)
469 if (dref->
dir[j] ==
':')
499 av_dlog(c->
fc,
"ctype= %.4s (0x%08x)\n", (
char*)&ctype, ctype);
500 av_dlog(c->
fc,
"stype= %.4s\n", (
char*)&type);
502 if (type ==
MKTAG(
'v',
'i',
'd',
'e'))
504 else if (type ==
MKTAG(
's',
'o',
'u',
'n'))
506 else if (type ==
MKTAG(
'm',
'1',
'a',
' '))
508 else if ((type ==
MKTAG(
's',
'u',
'b',
'p')) || (type ==
MKTAG(
'c',
'l',
'c',
'p')))
548 int ac3info, acmod, lfeon, bsmod;
555 bsmod = (ac3info >> 14) & 0x7;
556 acmod = (ac3info >> 11) & 0x7;
557 lfeon = (ac3info >> 10) & 0x1;
558 st->
codec->
channels = ((
int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
573 uint32_t
flags, layout_tag, bitmap, num_descr, label_mask;
590 if (atom.
size < 16ULL + num_descr * 20ULL)
593 av_dlog(c->
fc,
"chan: size=%ld version=%u flags=%u layout=%u bitmap=%u num_descr=%u\n",
594 atom.
size, version, flags, layout_tag, bitmap, num_descr);
597 for (i = 0; i < num_descr; i++) {
598 uint32_t label, cflags;
604 if (layout_tag == 0) {
606 if (mask_incr == 0) {
610 label_mask |= mask_incr;
647 "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
650 }
else if (den != 0) {
671 char minor_ver_str[11];
672 char* comp_brands_str;
673 uint8_t type[5] = {0};
676 if (strcmp(type,
"qt "))
681 snprintf(minor_ver_str,
sizeof(minor_ver_str),
"%d", minor_ver);
684 comp_brand_size = atom.
size - 8;
685 if (comp_brand_size < 0)
687 comp_brands_str =
av_malloc(comp_brand_size + 1);
688 if (!comp_brands_str)
690 avio_read(pb, comp_brands_str, comp_brand_size);
691 comp_brands_str[comp_brand_size] = 0;
726 strftime(buffer,
sizeof(buffer),
"%Y-%m-%d %H:%M:%S", ptm);
736 char language[4] = {0};
738 time_t creation_time;
778 time_t creation_time;
822 if ((uint64_t)atom.
size > (1<<30))
848 av_dlog(c->
fc,
"enda %d\n", little_endian);
849 if (little_endian == 1) {
873 unsigned mov_field_order;
882 if ((mov_field_order & 0xFF00) == 0x0100)
884 else if ((mov_field_order & 0xFF00) == 0x0200) {
885 switch (mov_field_order & 0xFF) {
915 if (size > INT_MAX || (uint64_t)atom.
size > INT_MAX)
937 if ((uint64_t)atom.
size > (1<<30))
948 }
else if (atom.
size > 8) {
969 if ((uint64_t)atom.
size > (1<<30))
972 if (atom.
size >= 10) {
978 if (type ==
MKTAG(
'f',
'i',
'e',
'l') && size == atom.
size)
1001 if (atom.
size <= 40)
1005 if ((uint64_t)atom.
size > (1<<30))
1022 unsigned int i, entries;
1036 if (entries >= UINT_MAX/
sizeof(int64_t))
1044 if (atom.
type ==
MKTAG(
's',
't',
'c',
'o'))
1045 for (i=0; i<entries; i++)
1047 else if (atom.
type ==
MKTAG(
'c',
'o',
'6',
'4'))
1048 for (i=0; i<entries; i++)
1095 int j, pseudo_stream_id;
1102 for (pseudo_stream_id=0; pseudo_stream_id<entries; pseudo_stream_id++) {
1138 if (
id<=0 && ((format&0xFFFF) ==
'm'+(
's'<<8) || (format&0xFFFF) ==
'T'+(
'S'<<8)))
1144 format && format !=
MKTAG(
'm',
'p',
'4',
's')) {
1157 av_dlog(c->
fc,
"size=%d 4CC= %c%c%c%c codec_type=%d\n", size,
1158 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
1162 unsigned int color_depth,
len;
1163 int color_greyscale;
1192 av_dlog(c->
fc,
"depth %d, ctab id %d\n",
1199 if ((color_depth == 2) || (color_depth == 4) ||
1200 (color_depth == 8)) {
1202 unsigned int color_start, color_count, color_end;
1203 unsigned char r,
g,
b;
1205 if (color_greyscale) {
1206 int color_index, color_dec;
1209 color_count = 1 << color_depth;
1211 color_dec = 256 / (color_count - 1);
1212 for (j = 0; j < color_count; j++) {
1213 r = g = b = color_index;
1215 (r << 16) | (g << 8) | (
b);
1216 color_index -= color_dec;
1217 if (color_index < 0)
1223 color_count = 1 << color_depth;
1224 if (color_depth == 2)
1226 else if (color_depth == 4)
1231 for (j = 0; j < color_count; j++) {
1232 r = color_table[j * 3 + 0];
1233 g = color_table[j * 3 + 1];
1234 b = color_table[j * 3 + 2];
1236 (r << 16) | (g << 8) | (
b);
1243 if ((color_start <= 255) &&
1244 (color_end <= 255)) {
1245 for (j = color_start; j <= color_end; j++) {
1258 (r << 16) | (g << 8) | (
b);
1265 int bits_per_sample,
flags;
1289 }
else if (version==2) {
1298 if (format ==
MKTAG(
'l',
'p',
'c',
'm'))
1340 if (bits_per_sample) {
1348 if (format !=
AV_RL32(
"mp4s"))
1363 }
else if (a.
size > 0)
1372 #if CONFIG_DV_DEMUXER
1444 unsigned int i, entries;
1460 if (entries >= UINT_MAX /
sizeof(*sc->
stsc_data))
1467 for (i=0; i<entries; i++) {
1479 unsigned i, entries;
1489 if (entries >= UINT_MAX /
sizeof(*sc->
stps_data))
1496 for (i = 0; i < entries; i++) {
1508 unsigned int i, entries;
1520 av_dlog(c->
fc,
"keyframe_count = %d\n", entries);
1524 if (entries >= UINT_MAX /
sizeof(
int))
1532 for (i=0; i<entries; i++) {
1543 unsigned int i, entries, sample_size, field_size, num_bytes;
1555 if (atom.
type ==
MKTAG(
's',
't',
's',
'z')) {
1573 if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
1580 if (entries >= UINT_MAX /
sizeof(
int) || entries >= (UINT_MAX - 4) / field_size)
1586 num_bytes = (entries*field_size+4)>>3;
1594 if (
avio_read(pb, buf, num_bytes) < num_bytes) {
1602 for (i=0; i<entries; i++)
1613 unsigned int i, entries;
1615 int64_t total_sample_count=0;
1626 av_dlog(c->
fc,
"track[%i].stts.entries = %i\n",
1631 if (entries >= UINT_MAX /
sizeof(*sc->
stts_data))
1641 for (i=0; i<entries; i++) {
1642 int sample_duration;
1647 if (sample_count < 0) {
1654 av_dlog(c->
fc,
"sample_count=%d, sample_duration=%d\n",
1655 sample_count, sample_duration);
1657 duration+=(int64_t)sample_duration*sample_count;
1658 total_sample_count+=sample_count;
1671 unsigned int i, entries;
1686 if (entries >= UINT_MAX /
sizeof(*sc->
ctts_data))
1693 for (i=0; i<entries; i++) {
1711 int64_t current_offset;
1712 int64_t current_dts = 0;
1713 unsigned int stts_index = 0;
1714 unsigned int stsc_index = 0;
1715 unsigned int stss_index = 0;
1716 unsigned int stps_index = 0;
1718 uint64_t stream_size = 0;
1738 unsigned int current_sample = 0;
1739 unsigned int stts_sample = 0;
1740 unsigned int sample_size;
1783 e->
pos = current_offset;
1785 e->
size = sample_size;
1788 av_dlog(mov->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
1789 "size %d, distance %d, keyframe %d\n", st->
index, current_sample,
1790 current_offset, current_dts, sample_size, distance, keyframe);
1793 current_offset += sample_size;
1794 stream_size += sample_size;
1808 unsigned chunk_samples, total = 0;
1812 unsigned count, chunk_count;
1824 count = (chunk_samples+samples-1) /
samples;
1826 count = (chunk_samples+1023) / 1024;
1829 if (i < sc->stsc_count - 1)
1833 total += chunk_count * count;
1836 av_dlog(mov->
fc,
"chunk count %d\n", total);
1853 while (chunk_samples > 0) {
1866 samples =
FFMIN(1024, chunk_samples);
1876 e->
pos = current_offset;
1881 av_dlog(mov->
fc,
"AVIndex stream %d, chunk %d, offset %"PRIx64
", dts %"PRId64
", "
1882 "size %d, duration %d\n", st->
index, i, current_offset, current_dts,
1885 current_offset +=
size;
1899 char filename[1024];
1904 src_path = strrchr(src,
'/');
1911 for (i = 0, l = strlen(ref->
path) - 1; l >= 0; l--)
1912 if (ref->
path[l] ==
'/') {
1920 if (i == ref->
nlvl_to - 1 && src_path - src <
sizeof(filename)) {
1921 memcpy(filename, src, src_path - src);
1922 filename[src_path - src] = 0;
1944 if (!st)
return AVERROR(ENOMEM);
1947 if (!sc)
return AVERROR(ENOMEM);
1986 "stream %d, error opening alias: path='%s', dir='%s', "
1987 "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
2009 #if CONFIG_H261_DECODER
2012 #if CONFIG_H263_DECODER
2015 #if CONFIG_MPEG4_DECODER
2045 while (atom.
size > 8) {
2048 if (tag ==
MKTAG(
'h',
'd',
'l',
'r')) {
2062 int64_t disp_transform[2];
2063 int display_matrix[3][2];
2105 for (i = 0; i < 3; i++) {
2113 sc->
width = width >> 16;
2114 sc->
height = height >> 16;
2120 if (width && height &&
2121 ((display_matrix[0][0] != 65536 ||
2122 display_matrix[1][1] != 65536) &&
2123 !display_matrix[0][1] &&
2124 !display_matrix[1][0] &&
2125 !display_matrix[2][0] && !display_matrix[2][1])) {
2126 for (i = 0; i < 2; i++)
2128 (int64_t) width * display_matrix[0][i] +
2129 (int64_t) height * display_matrix[1][i] +
2130 ((int64_t) display_matrix[2][i] << 16);
2134 ((
double) disp_transform[0] * height) /
2135 ((
double) disp_transform[1] * width), INT_MAX);
2144 int flags, track_id, i;
2210 int data_offset = 0;
2211 unsigned entries, first_sample_flags = frag->
flags;
2230 av_dlog(c->
fc,
"flags 0x%x entries %d\n", flags, entries);
2256 if (flags & 0x001) data_offset =
avio_rb32(pb);
2257 if (flags & 0x004) first_sample_flags =
avio_rb32(pb);
2261 av_dlog(c->
fc,
"first sample flags 0x%x\n", first_sample_flags);
2262 for (i = 0; i < entries; i++) {
2263 unsigned sample_size = frag->
size;
2264 int sample_flags = i ? frag->
flags : first_sample_flags;
2265 unsigned sample_duration = frag->
duration;
2268 if (flags & 0x100) sample_duration =
avio_rb32(pb);
2269 if (flags & 0x200) sample_size =
avio_rb32(pb);
2270 if (flags & 0x400) sample_flags =
avio_rb32(pb);
2275 (flags & 0x004 && !i && !sample_flags) || sample_flags & 0x2000000))
2279 av_dlog(c->
fc,
"AVIndex stream %d, sample %d, offset %"PRIx64
", dts %"PRId64
", "
2281 offset, dts, sample_size, distance, keyframe);
2283 dts += sample_duration;
2284 offset += sample_size;
2306 if (atom.
type !=
MKTAG(
'm',
'd',
'a',
't')) {
2320 long cmov_len, moov_len;
2334 cmov_len = atom.
size - 6 * 4;
2345 if (uncompress (moov_data, (uLongf *) &moov_len, (
const Bytef *)cmov_data, cmov_len) != Z_OK)
2346 goto free_and_return;
2348 goto free_and_return;
2350 atom.
size = moov_len;
2376 if ((uint64_t)edit_count*12+8 > atom.
size)
2379 for (i=0; i<edit_count; i++){
2390 if (i == 0 && time >= -1) {
2397 "a/v desync might occur, patch welcome\n");
2463 unsigned int offset;
2471 if ((offset + 8) > (
unsigned int)p->
buf_size)
2476 case MKTAG(
'j',
'P',
' ',
' '):
2477 case MKTAG(
'm',
'o',
'o',
'v'):
2478 case MKTAG(
'm',
'd',
'a',
't'):
2479 case MKTAG(
'p',
'n',
'o',
't'):
2480 case MKTAG(
'u',
'd',
't',
'a'):
2481 case MKTAG(
'f',
't',
'y',
'p'):
2484 case MKTAG(
'e',
'd',
'i',
'w'):
2485 case MKTAG(
'w',
'i',
'd',
'e'):
2486 case MKTAG(
'f',
'r',
'e',
'e'):
2487 case MKTAG(
'j',
'u',
'n',
'k'):
2488 case MKTAG(
'p',
'i',
'c',
't'):
2490 case MKTAG(0x82,0x82,0x7f,0x7d):
2491 case MKTAG(
's',
'k',
'i',
'p'):
2492 case MKTAG(
'u',
'u',
'i',
'd'):
2493 case MKTAG(
'p',
'r',
'f',
'l'):
2542 if (len > sample->
size-2)
2544 title_len = 2*len + 1;
2557 else if (ch == 0xfffe)
2561 if (len == 1 || len == 2)
2620 ((msc->
pb != s->
pb && dts < best_dts) || (msc->
pb == s->
pb &&
2623 sample = current_sample;
2674 #if CONFIG_DV_DEMUXER
2709 av_dlog(s,
"stream %d, pts %"PRId64
", dts %"PRId64
", pos 0x%"PRIx64
", duration %d\n",
2717 int sample, time_sample;
2721 av_dlog(s,
"stream %d, timestamp %"PRId64
", sample %d\n", st->
index, timestamp, sample);
2722 if (sample < 0 && st->nb_index_entries && timestamp < st->index_entries[0].timestamp)
2747 int64_t seek_timestamp, timestamp;
2753 if (sample_time < 0)
2756 st = s->
streams[stream_index];
2766 if (stream_index == i)
2790 if (sc->
pb && sc->
pb != s->
pb)
2809 .
name =
"mov,mp4,m4a,3gp,3g2,mj2",
int itunes_metadata
metadata are itunes style
static int mov_read_moof(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 ...
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.
void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
AV_WL32 AV_WL24 AV_WL16 AV_RB32
static int mov_read_wide(MOVContext *c, AVIOContext *pb, MOVAtom atom)
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.
const AVCodecTag codec_movaudio_tags[]
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)
static ColorEntry color_table[]
uint64_t base_data_offset
int64_t pos
byte position in stream, -1 if unknown
static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
#define AV_LOG_WARNING
Something somehow does not look correct.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
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
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
Compute codec id for 'lpcm' tag.
uint64_t ff_mov_get_channel_layout(uint32_t tag, uint32_t bitmap)
mov 'chan' tag reading/writing.
static const uint8_t ff_qt_default_palette_256[256 *3]
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
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).
unsigned int avio_rb16(AVIOContext *s)
enum CodecID video_codec_id
Forced video codec_id.
static int mov_read_udta_string(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...
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int found_moov
'moov' atom has been found
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
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_read_smi(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_probe(AVProbeData *p)
static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size)
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
Opaque data information usually continuous.
unsigned int sample_count
unsigned int avio_rb32(AVIOContext *s)
int dts_shift
dts shift when ctts is negative
int id
format-specific stream ID
enum AVStreamParseType need_parsing
AVInputFormat ff_mov_demuxer
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define AV_CH_LOW_FREQUENCY
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 read_header(FFV1Context *f)
#define AVERROR_EOF
End of file.
bitstream reader API header.
static av_cold int read_close(AVFormatContext *ctx)
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 av_get_bits_per_sample(enum CodecID codec_id)
Return codec bits per sample.
enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
audio conversion routines
int64_t time_offset
time offset of the first edit list entry
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.
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.
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned int avio_rl32(AVIOContext *s)
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int color_table_id
color table ID
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
static void mov_metadata_creation_time(AVDictionary **metadata, time_t time)
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
static AVDictionary * metadata
AVRational avg_frame_rate
Average framerate.
const AVCodecTag ff_codec_wav_tags[]
int min_distance
Minimum distance between this and the previous keyframe, used to avoid unneeded searching.
const AVCodecTag ff_codec_movsubtitle_tags[]
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
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)
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
A list of all streams in the file.
static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, int flags)
static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *key)
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int bit_rate
the average bitrate
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
unsigned int avio_rb24(AVIOContext *s)
static const AVIOInterruptCB int_cb
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)
int width
picture width / height.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
static int mov_open_dref(AVIOContext **pb, char *src, MOVDref *ref, AVIOInterruptCB *int_cb)
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_WB16 AV_RB8
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
uint32_t ff_mov_get_channel_label(uint32_t label)
Get the channel layout for the specified channel layout tag.
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int read_probe(AVProbeData *p)
static int mov_read_close(AVFormatContext *s)
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
as in Berlin toast format
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...
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
struct MOVContext MOVContext
int64_t duration
duration of the longest track
int ff_mov_lang_to_iso639(unsigned code, char to[4])
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
int frame_size
Samples per packet, initialized when calling 'init'.
DVDemuxContext * dv_demux
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
static const uint32_t mac_to_unicode[128]
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
enum AVMediaType codec_type
#define MP4DecConfigDescrTag
static void mov_read_chapters(AVFormatContext *s)
int sample_rate
samples per second
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
static const MOVParseTableEntry mov_default_parse_table[]
static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_ilst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
rational number numerator/denominator
MOVFragment fragment
current fragment in moof atom
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint8_t ff_qt_default_palette_16[16 *3]
static int mov_read_mac_string(MOVContext *c, AVIOContext *pb, int len, char *dst, int dstlen)
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
This structure contains the data a format has to probe a file.
static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
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 int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
unsigned * stps_data
partial sync sample for mpeg-2 open gop
struct MOVParseTableEntry MOVParseTableEntry
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)
int64_t duration
Decoding: duration of the stream, in stream time base.
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 AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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))
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen)
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int64_t nb_frames
number of frames in this stream if known or 0
static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)
CodecID
Identify the syntax and semantics of the bitstream.
unsigned int index_entries_allocated_size
int eof_reached
true if eof reached
int channels
number of audio channels
void * priv_data
Format private data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int pseudo_stream_id
-1 means demux all ids
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)
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
const char *const ff_id3v1_genre_str[ID3v1_GENRE_MAX+1]
ID3v1 genres.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
const AVCodecTag codec_movvideo_tags[]
#define AV_NOPTS_VALUE
Undefined timestamp value.
preferred ID for decoding MPEG audio layer 1, 2 or 3