diff options
author | Aman Gupta <aman@tmm1.net> | 2017-12-03 17:32:22 -0800 |
---|---|---|
committer | Matthieu Bouron <matthieu.bouron@gmail.com> | 2017-12-16 00:52:27 +0100 |
commit | 8bf4e6d3ce25723832625dddbf1c06ab20ab5828 (patch) | |
tree | e63c80887ad5d8a0570ccdfefa1bb25bd13bc1a8 /libavcodec | |
parent | e4d9f05ca79909e2853834c8f80a52bc9cf0e6b6 (diff) | |
download | ffmpeg-streaming-8bf4e6d3ce25723832625dddbf1c06ab20ab5828.zip ffmpeg-streaming-8bf4e6d3ce25723832625dddbf1c06ab20ab5828.tar.gz |
lavc/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mediacodecdec.c | 5 | ||||
-rw-r--r-- | libavcodec/mediacodecdec_common.c | 14 | ||||
-rw-r--r-- | libavcodec/version.h | 2 |
3 files changed, 17 insertions, 4 deletions
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 1b5ae4a..b698cea 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -520,8 +520,9 @@ static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = { &(const AVCodecHWConfigInternal) { .public = { .pix_fmt = AV_PIX_FMT_MEDIACODEC, - .methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC, - .device_type = AV_HWDEVICE_TYPE_NONE, + .methods = AV_CODEC_HW_CONFIG_METHOD_AD_HOC | + AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX, + .device_type = AV_HWDEVICE_TYPE_MEDIACODEC, }, .hwaccel = NULL, }, diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c index cb2f6ae..a9147f3 100644 --- a/libavcodec/mediacodecdec_common.c +++ b/libavcodec/mediacodecdec_common.c @@ -24,6 +24,7 @@ #include <sys/types.h> #include "libavutil/common.h" +#include "libavutil/hwcontext_mediacodec.h" #include "libavutil/mem.h" #include "libavutil/log.h" #include "libavutil/pixfmt.h" @@ -476,7 +477,18 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s, if (pix_fmt == AV_PIX_FMT_MEDIACODEC) { AVMediaCodecContext *user_ctx = avctx->hwaccel_context; - if (user_ctx && user_ctx->surface) { + if (avctx->hw_device_ctx) { + AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)(avctx->hw_device_ctx->data); + if (device_ctx->type == AV_HWDEVICE_TYPE_MEDIACODEC) { + if (device_ctx->hwctx) { + AVMediaCodecDeviceContext *mediacodec_ctx = (AVMediaCodecDeviceContext *)device_ctx->hwctx; + s->surface = ff_mediacodec_surface_ref(mediacodec_ctx->surface, avctx); + av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface); + } + } + } + + if (!s->surface && user_ctx && user_ctx->surface) { s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx); av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface); } diff --git a/libavcodec/version.h b/libavcodec/version.h index b529f00..d55de89 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 7 +#define LIBAVCODEC_VERSION_MINOR 8 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |