[FFmpeg-devel] mp3 seeking issue.

Dale Curtis dalecurtis at chromium.org
Sun Oct 21 19:51:50 CEST 2012


On Sun, Oct 21, 2012 at 12:45 AM, Reimar Döffinger <Reimar.Doeffinger at gmx.de
> wrote:

>
> I think this is a very long standing bug in the MP3 decoder, it probably
> does not reset some of the state in the flush function.
> Nobody ever investigated it properly to my knowledge.


I had some time this morning, I'm not sure if this is correct but it gets
rid of most of the seek artifacting:

diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 77f86c5..1c1e317 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -1716,6 +1716,9 @@ static void flush(AVCodecContext *avctx)
 {
     MPADecodeContext *s = avctx->priv_data;
     memset(s->synth_buf, 0, sizeof(s->synth_buf));
+    memset(s->last_buf, 0, sizeof(s->last_buf));
+    memset(s->sb_samples, 0, sizeof(s->sb_samples));
+
     s->last_buf_size = 0;
 }

There's still a slight clicking noise, but otherwise it sounds much better.


More information about the ffmpeg-devel mailing list