diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-07-07 12:50:41 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-07-07 12:50:41 +0200 |
commit | 19d416333114bd9bc2a76132709bf0a4463605bd (patch) | |
tree | 5fe2ca2c572327eab9008bd97b5449169a8fefe4 /libavformat/mp3dec.c | |
parent | 4cc32e5cad98e3037bce9ca945ea6e5fbcfd5d09 (diff) | |
download | ffmpeg-19d416333114bd9bc2a76132709bf0a4463605bd.tar.gz |
avformat/mp3dec: read TOC even if not all needed information is available
This fixes hyothetical bugs with parsing of elements after the TOC
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mp3dec.c')
-rw-r--r-- | libavformat/mp3dec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 522ccf7baa..d2f35d0725 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -93,22 +93,24 @@ static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration { int i; MP3DecContext *mp3 = s->priv_data; + int fill_index = mp3->usetoc && duration > 0; if (!filesize && !(filesize = avio_size(s->pb))) { av_log(s, AV_LOG_WARNING, "Cannot determine file size, skipping TOC table.\n"); - return; + fill_index = 0; } for (i = 0; i < XING_TOC_COUNT; i++) { uint8_t b = avio_r8(s->pb); - if (mp3->usetoc) + if (fill_index) av_add_index_entry(s->streams[0], av_rescale(b, filesize, 256), av_rescale(i, duration, XING_TOC_COUNT), 0, 0, AVINDEX_KEYFRAME); } - mp3->xing_toc = 1; + if (fill_index) + mp3->xing_toc = 1; } /** @@ -146,7 +148,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base) frames = avio_rb32(s->pb); if(v & XING_FLAG_SIZE) size = avio_rb32(s->pb); - if (v & XING_FLAG_TOC && frames) + if (v & XING_FLAG_TOC) read_xing_toc(s, size, av_rescale_q(frames, (AVRational){spf, c.sample_rate}, st->time_base)); if(v & 8) |