mov: Make sure no streams after the header lack a timescale.
Fixes division by 0 Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
cc5c2ef09d
commit
eb3dc23705
@ -2170,6 +2170,16 @@ static int mov_open_dref(AVIOContext **pb, const char *src, MOVDref *ref,
|
|||||||
return AVERROR(ENOENT);
|
return AVERROR(ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fix_timescale(MOVContext *c, MOVStreamContext *sc)
|
||||||
|
{
|
||||||
|
if (sc->time_scale <= 0) {
|
||||||
|
av_log(c->fc, AV_LOG_WARNING, "stream %d, timescale not set\n", sc->ffindex);
|
||||||
|
sc->time_scale = c->time_scale;
|
||||||
|
if (sc->time_scale <= 0)
|
||||||
|
sc->time_scale = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||||
{
|
{
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
@ -2197,12 +2207,7 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sc->time_scale <= 0) {
|
fix_timescale(c, sc);
|
||||||
av_log(c->fc, AV_LOG_WARNING, "stream %d, timescale not set\n", st->index);
|
|
||||||
sc->time_scale = c->time_scale;
|
|
||||||
if (sc->time_scale <= 0)
|
|
||||||
sc->time_scale = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
avpriv_set_pts_info(st, 64, 1, sc->time_scale);
|
avpriv_set_pts_info(st, 64, 1, sc->time_scale);
|
||||||
|
|
||||||
@ -3180,6 +3185,7 @@ static int mov_read_header(AVFormatContext *s)
|
|||||||
for (i = 0; i < s->nb_streams; i++) {
|
for (i = 0; i < s->nb_streams; i++) {
|
||||||
AVStream *st = s->streams[i];
|
AVStream *st = s->streams[i];
|
||||||
MOVStreamContext *sc = st->priv_data;
|
MOVStreamContext *sc = st->priv_data;
|
||||||
|
fix_timescale(mov, sc);
|
||||||
if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->codec_id == AV_CODEC_ID_AAC) {
|
if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->codec_id == AV_CODEC_ID_AAC) {
|
||||||
st->skip_samples = sc->start_pad;
|
st->skip_samples = sc->start_pad;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user