From 171dd67520b649a5b7a0f4fbff72ac88bbedfeab Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 2 Mar 2014 00:18:25 +0100 Subject: [PATCH] avformat/mp3dec: optimize mp3_seek() for dir < 0 this minimizes the amount of protocol seeks and reading needed in that case Signed-off-by: Michael Niedermayer --- libavformat/mp3dec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index c1ce173737..ba77bce238 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -318,6 +318,8 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, return -1; } + if (dir < 0) + avio_seek(s->pb, FFMAX(ie->pos - 4096, 0), SEEK_SET); ret = avio_seek(s->pb, ie->pos, SEEK_SET); if (ret < 0) return ret; -- 2.11.0