From: Chris Cunningham <chcunning...@chromium.org>

"Fast seek" uses linear interpolation to find the position of the
requested seek time. For CBR this is more direct than using the
mp3 TOC and bypassing the TOC avoids problems when the TOC is
corrupted (e.g. https://crbug.com/545914).

For VBR, fast seek is not precise, so continue to prefer the TOC
when available.
---
 libavformat/mp3dec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 32ca00c..e12266c 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -515,8 +515,10 @@ static int mp3_seek(AVFormatContext *s, int stream_index, 
int64_t timestamp,
             filesize = size - s->internal->data_offset;
     }
 
-    if (   (mp3->is_cbr || fast_seek)
-        && (mp3->usetoc == 0 || !mp3->xing_toc)
+    // When fast seeking, prefer to use the TOC when available for VBR files
+    // since av_rescale may not be accurate for VBR. For CBR, rescaling is
+    // always accurate and more direct than a TOC lookup.
+    if (fast_seek && (mp3->is_cbr || !mp3->xing_toc)
         && st->duration > 0
         && filesize > 0) {
         ie = &ie1;
-- 
2.6.0.rc2.230.g3dd15c0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to