Commit 92eef26e authored by wm4's avatar wm4 Committed by Michael Niedermayer

avformat/mp3dec: fix gapless audio when seeking in CBR mode

Removing a bunch of questionable hacks makes it work. These hacks
apparently try to make concatenated mp3s with Lame headers seekable,
which doesn't make too much sense anyway. The main change is that we
trust the Xing header file size field now (the same field is used for
seeking with Xing TOC). Note that a mp3 might contain an unknown number
of unsupported additional tags, so we can't reliably compute this size
manually.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 4efc0e64
...@@ -437,16 +437,10 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, ...@@ -437,16 +437,10 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp,
&& st->duration > 0 && st->duration > 0
&& mp3->header_filesize > s->internal->data_offset && mp3->header_filesize > s->internal->data_offset
&& mp3->frames) { && mp3->frames) {
int64_t filesize = avio_size(s->pb);
int64_t duration;
if (filesize <= s->internal->data_offset)
filesize = mp3->header_filesize;
filesize -= s->internal->data_offset;
duration = av_rescale(st->duration, filesize, mp3->header_filesize - s->internal->data_offset);
ie = &ie1; ie = &ie1;
timestamp = av_clip64(timestamp, 0, duration); timestamp = av_clip64(timestamp, 0, st->duration);
ie->timestamp = timestamp; ie->timestamp = timestamp;
ie->pos = av_rescale(timestamp, filesize, duration) + s->internal->data_offset; ie->pos = av_rescale(timestamp, mp3->header_filesize, st->duration) + s->internal->data_offset;
} else if (mp3->xing_toc) { } else if (mp3->xing_toc) {
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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