diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-10-25 19:35:55 +0200 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-10-26 01:15:06 +0200 |
commit | 8e72a8d1c278a6e9e41e218012d38eb102f27c9c (patch) | |
tree | ba792b8554242f610bc0b72a0122ae733617f4dc | |
parent | a4b705b4cbb57c1cc32d6e368e0176510ef3c2e3 (diff) | |
download | ffmpeg-8e72a8d1c278a6e9e41e218012d38eb102f27c9c.tar.gz |
avformat/mp3dec: perform seek resync in the correct direction
Fixes seeking to the last frame in CBR files
Fixes Ticket2773
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit ba8716df7fb541fb690d1a898cda0e12f9011faf)
-rw-r--r-- | libavformat/mp3dec.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 05cbece529..08f33241bd 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -283,6 +283,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, AVStream *st = s->streams[0]; int64_t ret = av_index_search_timestamp(st, timestamp, flags); int i, j; + int dir = (flags&AVSEEK_FLAG_BACKWARD) ? -1 : 1; if (mp3->is_cbr && st->duration > 0 && mp3->header_filesize > s->data_offset) { int64_t filesize = avio_size(s->pb); @@ -312,7 +313,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, #define MIN_VALID 3 for(i=0; i<4096; i++) { - int64_t pos = ie->pos + i; + int64_t pos = ie->pos + i*dir; for(j=0; j<MIN_VALID; j++) { ret = check(s, pos); if(ret < 0) @@ -325,7 +326,7 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, if(j!=MIN_VALID) i=0; - ret = avio_seek(s->pb, ie->pos + i, SEEK_SET); + ret = avio_seek(s->pb, ie->pos + i*dir, SEEK_SET); if (ret < 0) return ret; ff_update_cur_dts(s, st, ie->timestamp); |