[FFmpeg-devel] [PATCH] avcodec/mpegaudiodec_template: skip first frame after seeking
Michael Niedermayer
michaelni at gmx.at
Fri Apr 17 19:47:50 CEST 2015
On Fri, Apr 17, 2015 at 07:21:23PM +0200, wm4 wrote:
> On Fri, 17 Apr 2015 19:04:02 +0200
> Michael Niedermayer <michaelni at gmx.at> wrote:
>
> > This could be made optional if preferred
> > ---
> > libavcodec/mpegaudiodec_template.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
> > index 2326a90..70c17a1 100644
> > --- a/libavcodec/mpegaudiodec_template.c
> > +++ b/libavcodec/mpegaudiodec_template.c
> > @@ -87,6 +87,7 @@ typedef struct MPADecodeContext {
> > MPADSPContext mpadsp;
> > AVFloatDSPContext *fdsp;
> > AVFrame *frame;
> > + int flushed;
> > } MPADecodeContext;
> >
> > #define HEADER_SIZE 4
> > @@ -1645,6 +1646,11 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples,
> > }
> > }
> >
> > + if (s->flushed) {
> > + s->avctx->internal->skip_samples = FFMAX(s->avctx->internal->skip_samples, s->frame->nb_samples);
> > + s->flushed = 0;
> > + }
> > +
> > return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
> > }
> >
> > @@ -1723,6 +1729,7 @@ static void mp_flush(MPADecodeContext *ctx)
> > memset(ctx->mdct_buf, 0, sizeof(ctx->mdct_buf));
> > ctx->last_buf_size = 0;
> > ctx->dither_state = 0;
> > + ctx->flushed = 1;
> > }
> >
> > static void flush(AVCodecContext *avctx)
>
> Would this not break gapless audio if you seek back to the first frame
> after being done decoding? (Consider usecases like infinite looping.)
i did not test it but the skip value from AVPacket should override
this if its set
the first packet should contain skip sidedata or the mp3 would start
with a "half" empty output frame
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150417/792198c4/attachment.asc>
More information about the ffmpeg-devel
mailing list