summaryrefslogtreecommitdiffstats
path: root/libavcodec/mediacodecdec_common.c
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2018-03-10 23:43:42 -0800
committerAman Gupta <aman@tmm1.net>2018-03-12 01:23:30 -0700
commit936312d18c985335d8e90b04bb15b4227bce7b31 (patch)
tree33474f9c6a5a3ab235ce88be6b07edb7b3c41139 /libavcodec/mediacodecdec_common.c
parent939440ad1aa820bed51f54d273b4fa6c5016d9f9 (diff)
downloadffmpeg-streaming-936312d18c985335d8e90b04bb15b4227bce7b31.zip
ffmpeg-streaming-936312d18c985335d8e90b04bb15b4227bce7b31.tar.gz
avcodec/mediacodecdec: add debug logging around hw buffer lifecycle
Some Android devices are very finicky about how quicky output buffers are returned back to the decoder, especially when they are associated with a Surface. This commit adds a new counter that keeps track of exactly how many hw output buffers are being retained by the user, along with DEBUG level logging that makes it easy to track the lifecycle of these buffers. Signed-off-by: Aman Gupta <aman@tmm1.net> Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Diffstat (limited to 'libavcodec/mediacodecdec_common.c')
-rw-r--r--libavcodec/mediacodecdec_common.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index 5064809..2697af3 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -179,6 +179,10 @@ static void mediacodec_buffer_release(void *opaque, uint8_t *data)
int released = atomic_load(&buffer->released);
if (!released && (ctx->delay_flush || buffer->serial == atomic_load(&ctx->serial))) {
+ atomic_fetch_sub(&ctx->hw_buffer_count, 1);
+ av_log(ctx->avctx, AV_LOG_DEBUG,
+ "Releasing output buffer %zd (%p) ts=%"PRId64" on free() [%d pending]\n",
+ buffer->index, buffer, buffer->pts, atomic_load(&ctx->hw_buffer_count));
ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, 0);
}
@@ -246,6 +250,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
frame->data[3] = (uint8_t *)buffer;
+ atomic_fetch_add(&s->hw_buffer_count, 1);
+ av_log(avctx, AV_LOG_DEBUG,
+ "Wrapping output buffer %zd (%p) ts=%"PRId64" [%d pending]\n",
+ buffer->index, buffer, buffer->pts, atomic_load(&s->hw_buffer_count));
+
return 0;
fail:
av_freep(buffer);
@@ -429,6 +438,7 @@ static int mediacodec_dec_flush_codec(AVCodecContext *avctx, MediaCodecDecContex
s->flushing = 0;
s->eos = 0;
atomic_fetch_add(&s->serial, 1);
+ atomic_init(&s->hw_buffer_count, 0);
status = ff_AMediaCodec_flush(codec);
if (status < 0) {
@@ -454,6 +464,7 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s,
s->avctx = avctx;
atomic_init(&s->refcount, 1);
+ atomic_init(&s->hw_buffer_count, 0);
atomic_init(&s->serial, 1);
pix_fmt = ff_get_format(avctx, pix_fmts);
OpenPOWER on IntegriCloud