summaryrefslogtreecommitdiff
path: root/libavcodec/mediacodecdec_common.h
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2018-02-15 19:52:14 -0800
committerMatthieu Bouron <matthieu.bouron@gmail.com>2018-02-19 15:27:34 +0100
commitf611fef37cca44b89d0d7e6dfd1ac257736b5f7a (patch)
tree27a8862aabc93c9510ec58133514b5d6a3a0fbc7 /libavcodec/mediacodecdec_common.h
parent56f77b0f678de74404ae3a64f6ba664ea4449348 (diff)
downloadffmpeg-f611fef37cca44b89d0d7e6dfd1ac257736b5f7a.tar.gz
avcodec/mediacodecdec: refactor to take advantage of new decoding api
This refactor splits up the main mediacodec decode loop into two send/receive helpers, which are then used to rewrite the receive_frame callback and take full advantage of the new decoding api. Since we can now request packets on demand with ff_decode_get_packet(), the fifo buffer is no longer necessary and has been removed. This change was motivated by behavior observed on certain Android TV devices, featuring hardware mpeg2/h264 decoders which also deinterlace content (to produce multiple frames per field). Previously, this code caused buffering issues because queueInputBuffer() was always invoked before each dequeueOutputBuffer(), even though twice as many output buffers were being generated. With this patch, the decoder will always attempt to drain new frames first before sending more data into the underlying codec. Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Diffstat (limited to 'libavcodec/mediacodecdec_common.h')
-rw-r--r--libavcodec/mediacodecdec_common.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/mediacodecdec_common.h b/libavcodec/mediacodecdec_common.h
index 10f38277b5..32d16d3e3a 100644
--- a/libavcodec/mediacodecdec_common.h
+++ b/libavcodec/mediacodecdec_common.h
@@ -25,6 +25,7 @@
#include <stdint.h>
#include <stdatomic.h>
+#include <stdbool.h>
#include <sys/types.h>
#include "libavutil/frame.h"
@@ -69,11 +70,14 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx,
const char *mime,
FFAMediaFormat *format);
-int ff_mediacodec_dec_decode(AVCodecContext *avctx,
- MediaCodecDecContext *s,
- AVFrame *frame,
- int *got_frame,
- AVPacket *pkt);
+int ff_mediacodec_dec_send(AVCodecContext *avctx,
+ MediaCodecDecContext *s,
+ AVPacket *pkt);
+
+int ff_mediacodec_dec_receive(AVCodecContext *avctx,
+ MediaCodecDecContext *s,
+ AVFrame *frame,
+ bool wait);
int ff_mediacodec_dec_flush(AVCodecContext *avctx,
MediaCodecDecContext *s);