[FFmpeg-devel] [PATCH] avcodec/mpegaudiodec_template: skip first frame after seeking
wm4
nfxjfg at googlemail.com
Fri Apr 17 19:21:23 CEST 2015
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.)
More information about the ffmpeg-devel
mailing list