summaryrefslogtreecommitdiffstats
path: root/libavcodec/mediacodec.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2018-03-06 13:07:32 -0800
committerAman Gupta <aman@tmm1.net>2018-03-07 16:22:47 -0800
commit2a0eb8685728ccb260e42f60e1dbefe47ababbc3 (patch)
treef84f97754d63a1bbf77baccc9520e5b8d24dff41 /libavcodec/mediacodec.c
parent840f6eb77aed6c9dc2eff1a89add3611ec305262 (diff)
downloadffmpeg-streaming-2a0eb8685728ccb260e42f60e1dbefe47ababbc3.zip
ffmpeg-streaming-2a0eb8685728ccb260e42f60e1dbefe47ababbc3.tar.gz
avcodec/mediacodecdec: add delay_flush option
The default behavior of the mediacodec decoder before this commit was to delay flushes until all pending hardware frames were returned to the decoder. This was useful for certain types of applications, but was unexpected behavior for others. The new default behavior with this commit is now to execute flushes immediately to invalidate all pending frames. The old behavior can be enabled by setting delay_flush=1. With the new behavior, video players implementing seek can simply call flush on the decoder without having to worry about whether they have one or more mediacodec frames still buffered in their rendering pipeline. Previously, all these frames had to be explictly freed (or rendered) before the seek/flush would execute. The new behavior matches the behavior of all other lavc decoders, reducing the amount of special casing required when using the mediacodec decoder. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Diffstat (limited to 'libavcodec/mediacodec.c')
-rw-r--r--libavcodec/mediacodec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/mediacodec.c b/libavcodec/mediacodec.c
index d492eef..bf1b747 100644
--- a/libavcodec/mediacodec.c
+++ b/libavcodec/mediacodec.c
@@ -91,7 +91,7 @@ int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render)
MediaCodecDecContext *ctx = buffer->ctx;
int released = atomic_fetch_add(&buffer->released, 1);
- if (!released) {
+ if (!released && (ctx->delay_flush || buffer->serial == atomic_load(&ctx->serial))) {
return ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, render);
}
OpenPOWER on IntegriCloud