Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set

2017-12-03 Thread Mark Thompson
On 02/12/17 23:14, Aman Gupta wrote:
> From: Aman Gupta 
> 
> ---
>  libavcodec/mediacodecdec_common.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/mediacodecdec_common.c 
> b/libavcodec/mediacodecdec_common.c
> index cb2f6ae5e5..e524ffe0e4 100644
> --- a/libavcodec/mediacodecdec_common.c
> +++ b/libavcodec/mediacodecdec_common.c
> @@ -24,6 +24,7 @@
>  #include 
>  
>  #include "libavutil/common.h"
> +#include "libavutil/hwcontext_mediacodec.h"
>  #include "libavutil/mem.h"
>  #include "libavutil/log.h"
>  #include "libavutil/pixfmt.h"
> @@ -475,8 +476,12 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, 
> MediaCodecDecContext *s,
>  pix_fmt = ff_get_format(avctx, pix_fmts);
>  if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
>  AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
> +AVMediaCodecDeviceContext *device_ctx = avctx->hw_device_ctx;

Er, no.  AVCodecContext.hw_device_ctx is an AVBufferRef containing an 
AVHWDeviceContext - you need to dereference through it to get the 
AVMediaCodecDeviceContext.

>  
> -if (user_ctx && user_ctx->surface) {
> +if (device_ctx && device_ctx->surface) {
> +s->surface = ff_mediacodec_surface_ref(device_ctx->surface, 
> avctx);
> +av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
> +} else if (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);
>  }
> 

You want to add the hw-config metadata as well, I think.

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] libavcodec/mediacodec: use AVMediaCodecDeviceContext hw_device_ctx if set

2017-12-02 Thread Aman Gupta
From: Aman Gupta 

---
 libavcodec/mediacodecdec_common.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index cb2f6ae5e5..e524ffe0e4 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -24,6 +24,7 @@
 #include 
 
 #include "libavutil/common.h"
+#include "libavutil/hwcontext_mediacodec.h"
 #include "libavutil/mem.h"
 #include "libavutil/log.h"
 #include "libavutil/pixfmt.h"
@@ -475,8 +476,12 @@ int ff_mediacodec_dec_init(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 pix_fmt = ff_get_format(avctx, pix_fmts);
 if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
 AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
+AVMediaCodecDeviceContext *device_ctx = avctx->hw_device_ctx;
 
-if (user_ctx && user_ctx->surface) {
+if (device_ctx && device_ctx->surface) {
+s->surface = ff_mediacodec_surface_ref(device_ctx->surface, avctx);
+av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
+} else if (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);
 }
-- 
2.13.6 (Apple Git-96)

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel