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

Mark Thompson sw at jkqxz.net
Fri Dec 15 19:05:21 EET 2017


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


More information about the ffmpeg-devel mailing list