|
|
@@ -69,18 +69,18 @@ typedef struct { |
|
|
int first; |
|
|
int first; |
|
|
int count; |
|
|
int count; |
|
|
int id; |
|
|
int id; |
|
|
} MOV_stsc_t; |
|
|
|
|
|
|
|
|
} MOVStsc; |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
typedef struct { |
|
|
uint32_t type; |
|
|
uint32_t type; |
|
|
char *path; |
|
|
char *path; |
|
|
} MOV_dref_t; |
|
|
|
|
|
|
|
|
} MOVDref; |
|
|
|
|
|
|
|
|
typedef struct { |
|
|
typedef struct { |
|
|
uint32_t type; |
|
|
uint32_t type; |
|
|
int64_t offset; |
|
|
int64_t offset; |
|
|
int64_t size; /* total size (excluding the size and type fields) */ |
|
|
int64_t size; /* total size (excluding the size and type fields) */ |
|
|
} MOV_atom_t; |
|
|
|
|
|
|
|
|
} MOVAtom; |
|
|
|
|
|
|
|
|
struct MOVParseTableEntry; |
|
|
struct MOVParseTableEntry; |
|
|
|
|
|
|
|
|
@@ -109,12 +109,12 @@ typedef struct MOVStreamContext { |
|
|
unsigned int chunk_count; |
|
|
unsigned int chunk_count; |
|
|
int64_t *chunk_offsets; |
|
|
int64_t *chunk_offsets; |
|
|
unsigned int stts_count; |
|
|
unsigned int stts_count; |
|
|
MOV_stts_t *stts_data; |
|
|
|
|
|
|
|
|
MOVStts *stts_data; |
|
|
unsigned int ctts_count; |
|
|
unsigned int ctts_count; |
|
|
MOV_stts_t *ctts_data; |
|
|
|
|
|
|
|
|
MOVStts *ctts_data; |
|
|
unsigned int edit_count; /* number of 'edit' (elst atom) */ |
|
|
unsigned int edit_count; /* number of 'edit' (elst atom) */ |
|
|
unsigned int sample_to_chunk_sz; |
|
|
unsigned int sample_to_chunk_sz; |
|
|
MOV_stsc_t *sample_to_chunk; |
|
|
|
|
|
|
|
|
MOVStsc *sample_to_chunk; |
|
|
int sample_to_ctime_index; |
|
|
int sample_to_ctime_index; |
|
|
int sample_to_ctime_sample; |
|
|
int sample_to_ctime_sample; |
|
|
unsigned int sample_size; |
|
|
unsigned int sample_size; |
|
|
@@ -131,7 +131,7 @@ typedef struct MOVStreamContext { |
|
|
int pseudo_stream_id; ///< -1 means demux all ids |
|
|
int pseudo_stream_id; ///< -1 means demux all ids |
|
|
int16_t audio_cid; ///< stsd audio compression id |
|
|
int16_t audio_cid; ///< stsd audio compression id |
|
|
unsigned drefs_count; |
|
|
unsigned drefs_count; |
|
|
MOV_dref_t *drefs; |
|
|
|
|
|
|
|
|
MOVDref *drefs; |
|
|
int dref_id; |
|
|
int dref_id; |
|
|
int wrong_dts; ///< dts are wrong due to negative ctts |
|
|
int wrong_dts; ///< dts are wrong due to negative ctts |
|
|
} MOVStreamContext; |
|
|
} MOVStreamContext; |
|
|
@@ -163,15 +163,15 @@ typedef struct MOVContext { |
|
|
/* links atom IDs to parse functions */ |
|
|
/* links atom IDs to parse functions */ |
|
|
typedef struct MOVParseTableEntry { |
|
|
typedef struct MOVParseTableEntry { |
|
|
uint32_t type; |
|
|
uint32_t type; |
|
|
int (*parse)(MOVContext *ctx, ByteIOContext *pb, MOV_atom_t atom); |
|
|
|
|
|
|
|
|
int (*parse)(MOVContext *ctx, ByteIOContext *pb, MOVAtom atom); |
|
|
} MOVParseTableEntry; |
|
|
} MOVParseTableEntry; |
|
|
|
|
|
|
|
|
static const MOVParseTableEntry mov_default_parse_table[]; |
|
|
static const MOVParseTableEntry mov_default_parse_table[]; |
|
|
|
|
|
|
|
|
static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
int64_t total_size = 0; |
|
|
int64_t total_size = 0; |
|
|
MOV_atom_t a; |
|
|
|
|
|
|
|
|
MOVAtom a; |
|
|
int i; |
|
|
int i; |
|
|
int err = 0; |
|
|
int err = 0; |
|
|
|
|
|
|
|
|
@@ -232,7 +232,7 @@ static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return err; |
|
|
return err; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -246,7 +246,7 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs)); |
|
|
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs)); |
|
|
|
|
|
|
|
|
for (i = 0; i < sc->drefs_count; i++) { |
|
|
for (i = 0; i < sc->drefs_count; i++) { |
|
|
MOV_dref_t *dref = &sc->drefs[i]; |
|
|
|
|
|
|
|
|
MOVDref *dref = &sc->drefs[i]; |
|
|
uint32_t size = get_be32(pb); |
|
|
uint32_t size = get_be32(pb); |
|
|
int64_t next = url_ftell(pb) + size - 4; |
|
|
int64_t next = url_ftell(pb) + size - 4; |
|
|
|
|
|
|
|
|
@@ -300,7 +300,7 @@ static int mov_read_dref(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
uint32_t type; |
|
|
uint32_t type; |
|
|
@@ -373,7 +373,7 @@ static const AVCodecTag mp4_audio_types[] = { |
|
|
{ CODEC_ID_NONE, 0 }, |
|
|
{ CODEC_ID_NONE, 0 }, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
int tag, len; |
|
|
int tag, len; |
|
|
@@ -431,7 +431,7 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* this atom contains actual media data */ |
|
|
/* this atom contains actual media data */ |
|
|
static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
if(atom.size == 0) /* wrong one (MP4) */ |
|
|
if(atom.size == 0) /* wrong one (MP4) */ |
|
|
return 0; |
|
|
return 0; |
|
|
@@ -439,7 +439,7 @@ static int mov_read_mdat(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; /* now go for moov */ |
|
|
return 0; /* now go for moov */ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
uint32_t type = get_le32(pb); |
|
|
uint32_t type = get_le32(pb); |
|
|
|
|
|
|
|
|
@@ -452,7 +452,7 @@ static int mov_read_ftyp(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* this atom should contain all header atoms */ |
|
|
/* this atom should contain all header atoms */ |
|
|
static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
if (mov_read_default(c, pb, atom) < 0) |
|
|
if (mov_read_default(c, pb, atom) < 0) |
|
|
return -1; |
|
|
return -1; |
|
|
@@ -462,14 +462,14 @@ static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; /* now go for mdat */ |
|
|
return 0; /* now go for mdat */ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_moof(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_moof(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
c->fragment.moof_offset = url_ftell(pb) - 8; |
|
|
c->fragment.moof_offset = url_ftell(pb) - 8; |
|
|
dprintf(c->fc, "moof offset %llx\n", c->fragment.moof_offset); |
|
|
dprintf(c->fc, "moof offset %llx\n", c->fragment.moof_offset); |
|
|
return mov_read_default(c, pb, atom); |
|
|
return mov_read_default(c, pb, atom); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -498,7 +498,7 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
int version = get_byte(pb); /* version */ |
|
|
int version = get_byte(pb); /* version */ |
|
|
get_be24(pb); /* flags */ |
|
|
get_be24(pb); /* flags */ |
|
|
@@ -534,7 +534,7 @@ static int mov_read_mvhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
|
|
|
|
|
|
@@ -554,7 +554,7 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
int little_endian = get_be16(pb); |
|
|
int little_endian = get_be16(pb); |
|
|
@@ -581,7 +581,7 @@ static int mov_read_enda(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */ |
|
|
/* FIXME modify qdm2/svq3/h264 decoders to take full atom as extradata */ |
|
|
static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
uint64_t size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; |
|
|
uint64_t size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; |
|
|
@@ -600,7 +600,7 @@ static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
|
|
|
|
|
|
@@ -627,7 +627,7 @@ static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
* This function reads atom content and puts data in extradata without tag |
|
|
* This function reads atom content and puts data in extradata without tag |
|
|
* nor size unlike mov_read_extradata. |
|
|
* nor size unlike mov_read_extradata. |
|
|
*/ |
|
|
*/ |
|
|
static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
|
|
|
|
|
|
@@ -643,7 +643,7 @@ static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_stco(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -708,7 +708,7 @@ static enum CodecID mov_get_lpcm_codec_id(int bps, int flags) |
|
|
return CODEC_ID_NONE; |
|
|
return CODEC_ID_NONE; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -723,7 +723,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
//Parsing Sample description table |
|
|
//Parsing Sample description table |
|
|
enum CodecID id; |
|
|
enum CodecID id; |
|
|
int dref_id; |
|
|
int dref_id; |
|
|
MOV_atom_t a = { 0, 0, 0 }; |
|
|
|
|
|
|
|
|
MOVAtom a = { 0, 0, 0 }; |
|
|
int64_t start_pos = url_ftell(pb); |
|
|
int64_t start_pos = url_ftell(pb); |
|
|
int size = get_be32(pb); /* size */ |
|
|
int size = get_be32(pb); /* size */ |
|
|
uint32_t format = get_le32(pb); /* data format */ |
|
|
uint32_t format = get_le32(pb); /* data format */ |
|
|
@@ -1022,7 +1022,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -1033,13 +1033,13 @@ static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
entries = get_be32(pb); |
|
|
entries = get_be32(pb); |
|
|
|
|
|
|
|
|
if(entries >= UINT_MAX / sizeof(MOV_stsc_t)) |
|
|
|
|
|
|
|
|
if(entries >= UINT_MAX / sizeof(*sc->sample_to_chunk)) |
|
|
return -1; |
|
|
return -1; |
|
|
|
|
|
|
|
|
dprintf(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries); |
|
|
dprintf(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries); |
|
|
|
|
|
|
|
|
sc->sample_to_chunk_sz = entries; |
|
|
sc->sample_to_chunk_sz = entries; |
|
|
sc->sample_to_chunk = av_malloc(entries * sizeof(MOV_stsc_t)); |
|
|
|
|
|
|
|
|
sc->sample_to_chunk = av_malloc(entries * sizeof(*sc->sample_to_chunk)); |
|
|
if (!sc->sample_to_chunk) |
|
|
if (!sc->sample_to_chunk) |
|
|
return -1; |
|
|
return -1; |
|
|
for(i=0; i<entries; i++) { |
|
|
for(i=0; i<entries; i++) { |
|
|
@@ -1050,7 +1050,7 @@ static int mov_read_stsc(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -1078,7 +1078,7 @@ static int mov_read_stss(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -1108,7 +1108,7 @@ static int mov_read_stsz(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -1119,11 +1119,11 @@ static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
get_byte(pb); /* version */ |
|
|
get_byte(pb); /* version */ |
|
|
get_be24(pb); /* flags */ |
|
|
get_be24(pb); /* flags */ |
|
|
entries = get_be32(pb); |
|
|
entries = get_be32(pb); |
|
|
if(entries >= UINT_MAX / sizeof(MOV_stts_t)) |
|
|
|
|
|
|
|
|
if(entries >= UINT_MAX / sizeof(*sc->stts_data)) |
|
|
return -1; |
|
|
return -1; |
|
|
|
|
|
|
|
|
sc->stts_count = entries; |
|
|
sc->stts_count = entries; |
|
|
sc->stts_data = av_malloc(entries * sizeof(MOV_stts_t)); |
|
|
|
|
|
|
|
|
sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data)); |
|
|
if (!sc->stts_data) |
|
|
if (!sc->stts_data) |
|
|
return -1; |
|
|
return -1; |
|
|
dprintf(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); |
|
|
dprintf(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); |
|
|
@@ -1153,7 +1153,7 @@ static int mov_read_stts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
AVStream *st = c->fc->streams[c->fc->nb_streams-1]; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
MOVStreamContext *sc = st->priv_data; |
|
|
@@ -1162,11 +1162,11 @@ static int mov_read_ctts(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
get_byte(pb); /* version */ |
|
|
get_byte(pb); /* version */ |
|
|
get_be24(pb); /* flags */ |
|
|
get_be24(pb); /* flags */ |
|
|
entries = get_be32(pb); |
|
|
entries = get_be32(pb); |
|
|
if(entries >= UINT_MAX / sizeof(MOV_stts_t)) |
|
|
|
|
|
|
|
|
if(entries >= UINT_MAX / sizeof(*sc->ctts_data)) |
|
|
return -1; |
|
|
return -1; |
|
|
|
|
|
|
|
|
sc->ctts_count = entries; |
|
|
sc->ctts_count = entries; |
|
|
sc->ctts_data = av_malloc(entries * sizeof(MOV_stts_t)); |
|
|
|
|
|
|
|
|
sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data)); |
|
|
if (!sc->ctts_data) |
|
|
if (!sc->ctts_data) |
|
|
return -1; |
|
|
return -1; |
|
|
dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries); |
|
|
dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries); |
|
|
@@ -1295,7 +1295,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st) |
|
|
sc->sample_count = st->nb_index_entries; |
|
|
sc->sample_count = st->nb_index_entries; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
AVStream *st; |
|
|
AVStream *st; |
|
|
MOVStreamContext *sc; |
|
|
MOVStreamContext *sc; |
|
|
@@ -1370,7 +1370,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_ilst(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_ilst(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
int ret; |
|
|
int ret; |
|
|
c->itunes_metadata = 1; |
|
|
c->itunes_metadata = 1; |
|
|
@@ -1379,14 +1379,14 @@ static int mov_read_ilst(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
url_fskip(pb, 4); // version + flags |
|
|
url_fskip(pb, 4); // version + flags |
|
|
atom.size -= 4; |
|
|
atom.size -= 4; |
|
|
return mov_read_default(c, pb, atom); |
|
|
return mov_read_default(c, pb, atom); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
get_be32(pb); // type |
|
|
get_be32(pb); // type |
|
|
get_be32(pb); // unknown |
|
|
get_be32(pb); // unknown |
|
|
@@ -1395,7 +1395,7 @@ static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
char *str = NULL; |
|
|
char *str = NULL; |
|
|
int size; |
|
|
int size; |
|
|
@@ -1434,7 +1434,7 @@ static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOV_atom_t ato |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
int i; |
|
|
int i; |
|
|
int width; |
|
|
int width; |
|
|
@@ -1505,7 +1505,7 @@ static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_tfhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_tfhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
MOVFragment *frag = &c->fragment; |
|
|
MOVFragment *frag = &c->fragment; |
|
|
MOVTrackExt *trex = NULL; |
|
|
MOVTrackExt *trex = NULL; |
|
|
@@ -1540,7 +1540,7 @@ static int mov_read_tfhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_trex(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_trex(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
MOVTrackExt *trex; |
|
|
MOVTrackExt *trex; |
|
|
|
|
|
|
|
|
@@ -1560,7 +1560,7 @@ static int mov_read_trex(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
MOVFragment *frag = &c->fragment; |
|
|
MOVFragment *frag = &c->fragment; |
|
|
AVStream *st; |
|
|
AVStream *st; |
|
|
@@ -1631,7 +1631,7 @@ static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
/* this atom should be null (from specs), but some buggy files put the 'moov' atom inside it... */ |
|
|
/* this atom should be null (from specs), but some buggy files put the 'moov' atom inside it... */ |
|
|
/* like the files created with Adobe Premiere 5.0, for samples see */ |
|
|
/* like the files created with Adobe Premiere 5.0, for samples see */ |
|
|
/* http://graphics.tudelft.nl/~wouter/publications/soundtests/ */ |
|
|
/* http://graphics.tudelft.nl/~wouter/publications/soundtests/ */ |
|
|
static int mov_read_wide(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_wide(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
int err; |
|
|
int err; |
|
|
|
|
|
|
|
|
@@ -1652,7 +1652,7 @@ static int mov_read_wide(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
return err; |
|
|
return err; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static int mov_read_cmov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_cmov(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
#ifdef CONFIG_ZLIB |
|
|
#ifdef CONFIG_ZLIB |
|
|
ByteIOContext ctx; |
|
|
ByteIOContext ctx; |
|
|
@@ -1705,7 +1705,7 @@ free_and_return: |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/* edit list atom */ |
|
|
/* edit list atom */ |
|
|
static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) |
|
|
|
|
|
|
|
|
static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom) |
|
|
{ |
|
|
{ |
|
|
MOVStreamContext *sc = c->fc->streams[c->fc->nb_streams-1]->priv_data; |
|
|
MOVStreamContext *sc = c->fc->streams[c->fc->nb_streams-1]->priv_data; |
|
|
int i, edit_count; |
|
|
int i, edit_count; |
|
|
@@ -1834,7 +1834,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) |
|
|
MOVContext *mov = s->priv_data; |
|
|
MOVContext *mov = s->priv_data; |
|
|
ByteIOContext *pb = s->pb; |
|
|
ByteIOContext *pb = s->pb; |
|
|
int err; |
|
|
int err; |
|
|
MOV_atom_t atom = { 0, 0, 0 }; |
|
|
|
|
|
|
|
|
MOVAtom atom = { 0, 0, 0 }; |
|
|
|
|
|
|
|
|
mov->fc = s; |
|
|
mov->fc = s; |
|
|
/* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ |
|
|
/* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ |
|
|
@@ -1887,7 +1887,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) |
|
|
if (!sample) { |
|
|
if (!sample) { |
|
|
mov->found_mdat = 0; |
|
|
mov->found_mdat = 0; |
|
|
if (!url_is_streamed(s->pb) || |
|
|
if (!url_is_streamed(s->pb) || |
|
|
mov_read_default(mov, s->pb, (MOV_atom_t){ 0, 0, INT64_MAX }) < 0 || |
|
|
|
|
|
|
|
|
mov_read_default(mov, s->pb, (MOVAtom){ 0, 0, INT64_MAX }) < 0 || |
|
|
url_feof(s->pb)) |
|
|
url_feof(s->pb)) |
|
|
return -1; |
|
|
return -1; |
|
|
dprintf(s, "read fragments, offset 0x%llx\n", url_ftell(s->pb)); |
|
|
dprintf(s, "read fragments, offset 0x%llx\n", url_ftell(s->pb)); |
|
|
|