[FFmpeg-devel] [PATCH 1/3] avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codec

Aman Gupta ffmpeg at tmm1.net
Tue May 7 12:09:02 EEST 2019


On Thu, May 2, 2019 at 1:20 AM Matthieu Bouron <matthieu.bouron at gmail.com>
wrote:

> On Wed, Apr 24, 2019 at 09:59:28AM +0200, Matthieu Bouron wrote:
> > Avoids returning EAGAIN after signaling EOF to the codec in
> > ff_mediacodec_dec_send() so we can try to receive a frame before
> > returning in mediacodec_receive_frame().
> >
> > This helps avoiding an extra round-trip between avcodec_send_frame() and
> > avcodec_receive_frame() while draining the remaining frames.
> > ---
> >  libavcodec/mediacodecdec.c        | 1 +
> >  libavcodec/mediacodecdec_common.c | 2 +-
> >  2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
> > index 3a4240aa95..e353e34bd5 100644
> > --- a/libavcodec/mediacodecdec.c
> > +++ b/libavcodec/mediacodecdec.c
> > @@ -461,6 +461,7 @@ static int mediacodec_receive_frame(AVCodecContext
> *avctx, AVFrame *frame)
> >              ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt,
> true);
> >              if (ret < 0)
> >                  return ret;
> > +            return ff_mediacodec_dec_receive(avctx, s->ctx, frame,
> true);
> >          } else if (ret == AVERROR(EAGAIN) &&
> s->ctx->current_input_buffer < 0) {
> >              return ff_mediacodec_dec_receive(avctx, s->ctx, frame,
> true);
> >          } else if (ret < 0) {
> > diff --git a/libavcodec/mediacodecdec_common.c
> b/libavcodec/mediacodecdec_common.c
> > index 7c2661f672..f7a06cdc6d 100644
> > --- a/libavcodec/mediacodecdec_common.c
> > +++ b/libavcodec/mediacodecdec_common.c
> > @@ -631,7 +631,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx,
> MediaCodecDecContext *s,
> >                     "Queued input buffer %zd size=%zd ts=%"PRIi64"\n",
> index, size, pts);
> >
> >              s->draining = 1;
> > -            break;
> > +            return 0;
> >          } else {
> >              size = FFMIN(pkt->size - offset, size);
> >              memcpy(data, pkt->data + offset, size);
> > --
> > 2.21.0
> >
>
> Ping.
>

Did not test, but the diffs look reasonable to me.


>
> --
> Matthieu B.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list