[FFmpeg-devel] mp3 seeking issue.

Don Moir donmoir at comcast.net
Sun Oct 21 23:09:10 CEST 2012

>> 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:

>--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.

Probably need to check  flush_mp3on4 in mpegaudiodec.c as well since it essentially does the same thing.

More information about the ffmpeg-devel mailing list