Re: [libav-devel] [PATCH 10/10] avconv: Test avcodec_probe_hw()

2017-03-28 Thread wm4
On Mon, 27 Mar 2017 21:38:19 +0100
Mark Thompson  wrote:

> Test only, not to commit in this form.
> ---
>  avtools/avconv_hw.c | 29 -
>  1 file changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/avtools/avconv_hw.c b/avtools/avconv_hw.c
> index fd1618389..71a3c2772 100644
> --- a/avtools/avconv_hw.c
> +++ b/avtools/avconv_hw.c
> @@ -376,8 +376,35 @@ fail:
>  int hwaccel_decode_init(AVCodecContext *avctx)
>  {
>  InputStream *ist = avctx->opaque;
> +AVBufferRef *hw_frames_ref;
> +AVHWFramesContext *hw_frames;
> +int err;
> +
> +if (!avctx->hw_device_ctx)
> +return AVERROR(ENOSYS);
> +
> +hw_frames_ref = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
> +if (!hw_frames_ref)
> +return AVERROR(ENOMEM);
> +hw_frames = (AVHWFramesContext*)hw_frames_ref->data;
> +
> +err = avcodec_probe_hw(avctx, hw_frames_ref);
> +if (err < 0) {
> +av_log(avctx, AV_LOG_ERROR, "Decode with %s not supported: %d.\n",
> +   av_hwdevice_get_type_name(hw_frames->device_ctx->type), err);
> +goto fail;
> +}
> +
> +av_log(avctx, AV_LOG_ERROR, "Decode with %s supported; %d frames "
> +   "of type %d/%d and size %dx%d are required.\n",
> +   av_hwdevice_get_type_name(hw_frames->device_ctx->type),
> +   hw_frames->initial_pool_size, hw_frames->format, 
> hw_frames->sw_format,
> +   hw_frames->width, hw_frames->height);
>  
>  ist->hwaccel_retrieve_data = &hwaccel_retrieve_data;
>  
> -return 0;
> +err = 0;
> +fail:
> +av_buffer_unref(&hw_frames_ref);
> +return err;
>  }

LGTM, under the condition of whatever happening to patch 3/10.

All the other patches I didn't comment on LGTM as well.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 10/10] avconv: Test avcodec_probe_hw()

2017-03-27 Thread Mark Thompson
Test only, not to commit in this form.
---
 avtools/avconv_hw.c | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/avtools/avconv_hw.c b/avtools/avconv_hw.c
index fd1618389..71a3c2772 100644
--- a/avtools/avconv_hw.c
+++ b/avtools/avconv_hw.c
@@ -376,8 +376,35 @@ fail:
 int hwaccel_decode_init(AVCodecContext *avctx)
 {
 InputStream *ist = avctx->opaque;
+AVBufferRef *hw_frames_ref;
+AVHWFramesContext *hw_frames;
+int err;
+
+if (!avctx->hw_device_ctx)
+return AVERROR(ENOSYS);
+
+hw_frames_ref = av_hwframe_ctx_alloc(avctx->hw_device_ctx);
+if (!hw_frames_ref)
+return AVERROR(ENOMEM);
+hw_frames = (AVHWFramesContext*)hw_frames_ref->data;
+
+err = avcodec_probe_hw(avctx, hw_frames_ref);
+if (err < 0) {
+av_log(avctx, AV_LOG_ERROR, "Decode with %s not supported: %d.\n",
+   av_hwdevice_get_type_name(hw_frames->device_ctx->type), err);
+goto fail;
+}
+
+av_log(avctx, AV_LOG_ERROR, "Decode with %s supported; %d frames "
+   "of type %d/%d and size %dx%d are required.\n",
+   av_hwdevice_get_type_name(hw_frames->device_ctx->type),
+   hw_frames->initial_pool_size, hw_frames->format, 
hw_frames->sw_format,
+   hw_frames->width, hw_frames->height);
 
 ist->hwaccel_retrieve_data = &hwaccel_retrieve_data;
 
-return 0;
+err = 0;
+fail:
+av_buffer_unref(&hw_frames_ref);
+return err;
 }
-- 
2.11.0

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel