diff options
author | wm4 <nfxjfg@googlemail.com> | 2015-04-17 17:27:00 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-04-17 17:48:22 +0200 |
commit | 92eef26e67ea8d2265854594344f8db17b9ce299 (patch) | |
tree | c5c3ce523b06284aa3f60f1780a9dfca2ce84cd0 /libavformat/mp3dec.c | |
parent | 4efc0e6451fa77e1e1d5b4b3873917c1916765f1 (diff) | |
download | ffmpeg-streaming-92eef26e67ea8d2265854594344f8db17b9ce299.zip ffmpeg-streaming-92eef26e67ea8d2265854594344f8db17b9ce299.tar.gz |
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: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mp3dec.c')
-rw-r--r-- | libavformat/mp3dec.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 1692d88..06bc1d0 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -437,16 +437,10 @@ static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, && st->duration > 0 && mp3->header_filesize > s->internal->data_offset && 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; - timestamp = av_clip64(timestamp, 0, duration); + timestamp = av_clip64(timestamp, 0, st->duration); 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) { if (ret < 0) return ret; |