Commit ba8716df authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/mp3dec: perform seek resync in the correct direction

Fixes seeking to the last frame in CBR files
Fixes Ticket2773
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d04ec6ff
......@@ -288,6 +288,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);
......@@ -317,7 +318,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)
......@@ -330,7 +331,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment