[FFmpeg-devel] [PATCH] Flushing the MP2 Decoder

Brian Brice bbrice
Fri Jan 11 19:44:03 CET 2008


On Jan 11, 2008 12:19 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>
> On Fri, Jan 11, 2008 at 10:18:58AM -0600, Brian Brice wrote:
> > On Jan 11, 2008 6:16 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > >
> > > On Thu, Jan 10, 2008 at 07:01:46PM -0600, Brian Brice wrote:
> > > > Hello,
> > > >
> > > > I believe I've found an issue with seeking relating to the MP2
> > > > decoder.  It's most notable in the scenario that you've been decoding
> > > > frames that have sound, seek to an area of silence, then continue
> > > > decoding.  After the seek, the first frame returned from the decoder
> > > > has a blip of sound from the previous audio.
> > > >
> > > > Currently, there isn't a flush implementation for the MP2 decoder.  In
> > > > researching what exactly needs to be flushed, I've noticed some fields
> > > > in MPADecodeContext that were previously set, causing the blip.
> > > >
> > > > I've attached my implementation of a flush function for the MP2 decoder.
> > > >
> > > > Thanks!
> > > >
> > > > --
> > > > Brian Brice
> > > > http://www.heapify.org/
> > >
> > > > --- libavcodec/mpegaudiodec.c.orig    2008-01-10 18:50:54.988827100 -0600
> > > > +++ libavcodec/mpegaudiodec.c 2008-01-10 18:59:13.629452100 -0600
> > > > @@ -2417,6 +2417,9 @@
> > > >
> > > >  static void flush(AVCodecContext *avctx){
> > > >      MPADecodeContext *s = avctx->priv_data;
> > > > +    memset(s->synth_buf, 0, sizeof(s->synth_buf));
> > >
> > > > +    memset(s->synth_buf_offset, 0, sizeof(s->synth_buf_offset));
> > > > +    s->dither_state= 0;
> > >
> > > this is not needed
> >
> > This is what I've been looking to, if it's needed and why it's needed.
> >
> > The scenario again is this: Decoding audio that has noticable sound in
> > it, performing a seek operation to a location that has only silence,
> > then continue decoding from this new location.  The first frame of
> > audio back after the seek returns data that has sound in it when it
> > shouldn't.  I went stepping around into the MP2 decoder to see what
> > data is kept around from the previous audio that could do this.
> >
> > Within mp_decode_layer2(), s->sb_samples is pretty much set to all 0's
> > (silence) as expected.  Then within ff_mpa_synth_filter(), these 0's
> > are changed due to data laying around in s->synth_buf.
> >
> > If this isn't cleared, then a "blip" is heard when playing that
> > decoded audio back.  If I cleared out synth_buf within the flush
> > operation, then the "blip" is not heard.
>
> Thats all obvious, but neither dither_state nor synth_buf_offset need to
> be cleared. Ive applied the sane looking parts of your patch.

Excellent.  This works too.  Thanks!

[...]


-- 
Brian Brice
http://www.heapify.org/




More information about the ffmpeg-devel mailing list