[FFmpeg-devel] [PATCH 1/2] avcodec/mlpenc: encode last frame too

Paul B Mahol onemda at gmail.com
Fri Aug 9 16:17:24 EEST 2019


On Wed, Nov 29, 2017 at 4:26 AM James Almer <jamrial at gmail.com> wrote:

> On 11/28/2017 4:55 PM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol <onemda at gmail.com>
> > ---
> >  libavcodec/mlpenc.c | 22 +++++++++++-----------
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> >
> > diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
> > index 7536d3b2f5..c588f5b904 100644
> > --- a/libavcodec/mlpenc.c
> > +++ b/libavcodec/mlpenc.c
> > @@ -2225,29 +2225,27 @@ static int mlp_encode_frame(AVCodecContext
> *avctx, AVPacket *avpkt,
> >      int restart_frame, ret;
> >      uint8_t *data;
> >
> > -    if ((ret = ff_alloc_packet2(avctx, avpkt, 87500 * avctx->channels,
> 0)) < 0)
> > -        return ret;
> > -
> > -    if (!frame)
> > -        return 1;
> > -
> >      /* add current frame to queue */
> >      if (frame) {
> >          if ((ret = ff_af_queue_add(&ctx->afq, frame)) < 0)
> >              return ret;
> > +    } else {
> > +        if (ctx->last_frame == ctx->inout_buffer) {
> > +            return 0;
> > +        }
> >      }
> >
> > -    data = frame->data[0];
> > +
> > +    if ((ret = ff_alloc_packet2(avctx, avpkt, 87500 * avctx->channels,
> 0)) < 0)
> > +        return ret;
> > +
> > +    data = frame ? frame->data[0] : NULL;
> >
> >      ctx->frame_index = avctx->frame_number % ctx->max_restart_interval;
> >
> >      ctx->inout_buffer = ctx->major_inout_buffer
> >                        + ctx->frame_index * ctx->one_sample_buffer_size;
> >
> > -    if (ctx->last_frame == ctx->inout_buffer) {
> > -        return 0;
> > -    }
> > -
> >      ctx->sample_buffer = ctx->major_scratch_buffer
> >                         + ctx->frame_index * ctx->one_sample_buffer_size;
> >
> > @@ -2333,6 +2331,8 @@ input_and_return:
> >                  number_of_samples +=
> ctx->frame_size[(ctx->starting_frame_index + index) %
> ctx->max_restart_interval];
> >              }
> >              ctx->number_of_samples = number_of_samples;
> > +            if (!ctx->number_of_samples)
> > +                break;
> >
> >              for (index = 0; index < ctx->seq_size[seq_index]; index++) {
> >                  clear_channel_params(ctx, ctx->seq_channel_params +
> index*(ctx->avctx->channels));
> >
>
> After this patch the sample from ticket 6216 prints a "Trying to remove
> 40 samples, but the queue is empty" warning during encoding.
>
>
Because frame queue is never actually used, its just dead code here.


More information about the ffmpeg-devel mailing list