aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthieu Bouron <matthieu.bouron@gmail.com>2019-04-24 09:59:28 +0200
committerMatthieu Bouron <matthieu.bouron@gmail.com>2019-06-13 11:41:18 +0200
commitd83985ce11d0f68d293e52fdccfc62fe9d28d54f (patch)
treec7520e1db5856d6296a916f8c901e46a3a148610
parentcaabe1b4956d054bc3b077ae03a0d4205dbb843e (diff)
downloadffmpeg-d83985ce11d0f68d293e52fdccfc62fe9d28d54f.tar.gz
avcodec/mediacodecdec: try to receive a frame after signaling EOF to the codec
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.
-rw-r--r--libavcodec/mediacodecdec.c1
-rw-r--r--libavcodec/mediacodecdec_common.c2
2 files changed, 2 insertions, 1 deletions
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);