diff mbox

[FFmpeg-devel] HW accelerator: Indicate when hardware acceleration is used for processing encode or decode.

Message ID 1513296191-16611-1-git-send-email-michele.lim@intel.com
State New
Headers show

Commit Message

Michele Lim Dec. 15, 2017, 12:03 a.m. UTC
Clear indication of when a hardware accelerator is in operation
prevents false assumptions in situations when the command line
argument inadvertently omits certain required options for
enabling it.
---
 libavutil/hwcontext_vaapi.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Mark Thompson Dec. 15, 2017, 5:05 p.m. UTC | #1
On 15/12/17 00:03, Michele Lim wrote:
> Clear indication of when a hardware accelerator is in operation
> prevents false assumptions in situations when the command line
> argument inadvertently omits certain required options for
> enabling it.
> ---
>  libavutil/hwcontext_vaapi.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 29698d1..0decf6d 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1193,8 +1193,11 @@ static void vaapi_device_free(AVHWDeviceContext *ctx)
>      AVVAAPIDeviceContext *hwctx = ctx->hwctx;
>      VAAPIDevicePriv      *priv  = ctx->user_opaque;
>  
> -    if (hwctx->display)
> +    if (hwctx->display)  {
>          vaTerminate(hwctx->display);
> +        /* Indicate hardware acceleration was utilized to complete either encode or decode */
> +        av_log(ctx, AV_LOG_INFO, "Processing completed with HW acceleration\n");
> +    }
>  
>  #if HAVE_VAAPI_X11
>      if (priv->x11_display)
> 

Closing a device does not tell you anything about whether it was used.

E.g. consider:

ffmpeg -y -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -i vp8-input.webm -an -f null -

where /dev/dri/renderD128 is a device which does not support VP8.  With this patch you would get:

...
    Stream #0:0(eng): Video: vp8, yuv420p(progressive), 540x360, SAR 1:1 DAR 3:2, 23.98 fps, 23.98 tbr, 1k tbn, 1k tbc (default)
...
[vp8 @ 0x564d9be02c80] No support for codec vp8 profile 1.
[vp8 @ 0x564d9be02c80] Failed setup for format vaapi_vld: hwaccel initialisation returned error.
...
    Stream #0:0(eng): Video: wrapped_avframe, yuv420p, 540x360 [SAR 1:1 DAR 3:2], q=2-31, 200 kb/s, 23.98 fps, 23.98 tbn, 23.98 tbc (default)
...
[AVHWDeviceContext @ 0x55d57926ab00] Processing completed with HW acceleration

Except, it wasn't.

- Mark
diff mbox

Patch

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 29698d1..0decf6d 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -1193,8 +1193,11 @@  static void vaapi_device_free(AVHWDeviceContext *ctx)
     AVVAAPIDeviceContext *hwctx = ctx->hwctx;
     VAAPIDevicePriv      *priv  = ctx->user_opaque;
 
-    if (hwctx->display)
+    if (hwctx->display)  {
         vaTerminate(hwctx->display);
+        /* Indicate hardware acceleration was utilized to complete either encode or decode */
+        av_log(ctx, AV_LOG_INFO, "Processing completed with HW acceleration\n");
+    }
 
 #if HAVE_VAAPI_X11
     if (priv->x11_display)