forked from FFmpeg/FFmpeg
avformat/mov: Factorize sanity check out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
858acd8d02
commit
16b3d3e3eb
1 changed files with 21 additions and 13 deletions
|
@ -5081,6 +5081,24 @@ static int mov_update_iamf_streams(MOVContext *c, const AVStream *st)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int sanity_checks(void *log_obj, MOVStreamContext *sc, int index)
|
||||||
|
{
|
||||||
|
if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
|
||||||
|
(!sc->sample_size && !sc->sample_count))) ||
|
||||||
|
(!sc->chunk_count && sc->sample_count)) {
|
||||||
|
av_log(log_obj, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
|
||||||
|
index);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {
|
||||||
|
av_log(log_obj, AV_LOG_ERROR, "stream %d, contradictionary STSC and STCO\n",
|
||||||
|
index);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -5113,19 +5131,9 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||||
av_freep(&sc->stsc_data);
|
av_freep(&sc->stsc_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sanity checks */
|
ret = sanity_checks(c->fc, sc, st->index);
|
||||||
if ((sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
|
if (ret)
|
||||||
(!sc->sample_size && !sc->sample_count))) ||
|
return ret > 1 ? AVERROR_INVALIDDATA : 0;
|
||||||
(!sc->chunk_count && sc->sample_count)) {
|
|
||||||
av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
|
|
||||||
st->index);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (sc->stsc_count && sc->stsc_data[ sc->stsc_count - 1 ].first > sc->chunk_count) {
|
|
||||||
av_log(c->fc, AV_LOG_ERROR, "stream %d, contradictionary STSC and STCO\n",
|
|
||||||
st->index);
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
fix_timescale(c, sc);
|
fix_timescale(c, sc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue