diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-05-25 18:44:34 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-30 00:32:36 +0200 |
commit | 29e97cd6c3f2307e79b48a9e02cd0c6e055476ae (patch) | |
tree | 98049db387e1ffcb39eb3949850191a7edf0e880 /libavformat/mov.c | |
parent | 4c2b3f47382ea46c7886951c3dab0ac357d54392 (diff) | |
download | ffmpeg-29e97cd6c3f2307e79b48a9e02cd0c6e055476ae.tar.gz |
avformat/mov: Try to detect and support files with invalid sample sizes
Fixes Ticket2605
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r-- | libavformat/mov.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index 7048920e75..1c03b1553a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1988,10 +1988,22 @@ static void mov_build_index(MOVContext *mov, AVStream *st) st->index_entries_allocated_size = (st->nb_index_entries + sc->sample_count) * sizeof(*st->index_entries); for (i = 0; i < sc->chunk_count; i++) { + int64_t next_offset = i+1 < sc->chunk_count ? sc->chunk_offsets[i+1] : INT64_MAX; current_offset = sc->chunk_offsets[i]; while (stsc_index + 1 < sc->stsc_count && i + 1 == sc->stsc_data[stsc_index + 1].first) stsc_index++; + + if (next_offset > current_offset && sc->sample_size>0 && sc->sample_size < sc->stsz_sample_size && + sc->stsc_data[stsc_index].count * (int64_t)sc->stsz_sample_size > next_offset - current_offset) { + av_log(mov->fc, AV_LOG_WARNING, "STSZ sample size %d invalid (too large), ignoring\n", sc->stsz_sample_size); + sc->stsz_sample_size = sc->sample_size; + } + if (sc->stsz_sample_size>0 && sc->stsz_sample_size < sc->sample_size) { + av_log(mov->fc, AV_LOG_WARNING, "STSZ sample size %d invalid (too small), ignoring\n", sc->stsz_sample_size); + sc->stsz_sample_size = sc->sample_size; + } + for (j = 0; j < sc->stsc_data[stsc_index].count; j++) { int keyframe = 0; if (current_sample >= sc->sample_count) { |