Mercurial > libavformat.hg
changeset 4646:774c340b9e41 libavformat
MOV: fix demuxing fragmented files
author | alexc |
---|---|
date | Wed, 04 Mar 2009 07:57:09 +0000 |
parents | a9a2c60d0e84 |
children | a9c659873a1e |
files | mov.c |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mov.c Wed Mar 04 05:40:53 2009 +0000 +++ b/mov.c Wed Mar 04 07:57:09 2009 +0000 @@ -1586,7 +1586,7 @@ flags = get_be24(pb); track_id = get_be32(pb); - if (!track_id || track_id > c->fc->nb_streams) + if (!track_id) return -1; frag->track_id = track_id; for (i = 0; i < c->trex_count; i++) @@ -1635,7 +1635,7 @@ static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { MOVFragment *frag = &c->fragment; - AVStream *st; + AVStream *st = NULL; MOVStreamContext *sc; uint64_t offset; int64_t dts; @@ -1643,9 +1643,16 @@ unsigned entries, first_sample_flags = frag->flags; int flags, distance, i; - if (!frag->track_id || frag->track_id > c->fc->nb_streams) + for (i = 0; i < c->fc->nb_streams; i++) { + if (c->fc->streams[i]->id == frag->track_id) { + st = c->fc->streams[i]; + break; + } + } + if (!st) { + av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id); return -1; - st = c->fc->streams[frag->track_id-1]; + } sc = st->priv_data; if (sc->pseudo_stream_id+1 != frag->stsd_id) return 0;