[FFmpeg-devel] [PATCH] HW accelerator: Indicate when HW acceleration is in use

Mark Thompson sw at jkqxz.net
Sat Nov 4 21:08:39 EET 2017


On 03/11/17 18:35, Michele Lim wrote:
> Having clear indication of when a hardware accelerator is in
> operation prevents false assumptions, for e.g., in situations when
> the command line argument inadvertently omits options for enabling
> it, resulting to the framework silently switching to the SW path.
> 
> Signed-off-by: Michele Lim <michele.lim at intel.com>
> ---
>  fftools/ffmpeg_hw.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c
> index a4d1cad..f071746 100644
> --- a/fftools/ffmpeg_hw.c
> +++ b/fftools/ffmpeg_hw.c
> @@ -306,6 +306,8 @@ int hw_device_setup_for_decode(InputStream *ist)
>      if (!ist->dec_ctx->hw_device_ctx)
>          return AVERROR(ENOMEM);
>  
> +    /* Indicate HW accelerator has been prepared for decode */
> +    av_log(ist->dec_ctx, AV_LOG_INFO, "HW accelerator prepared for decode: %s\n", av_hwdevice_get_type_name(type));
>      return 0;
>  }
>  
> @@ -331,6 +333,9 @@ int hw_device_setup_for_encode(OutputStream *ost)
>          // No device required.
>          return 0;
>      }
> +
> +    /* Indicate HW accelerator has been prepared for encode */
> +    av_log(ost->enc_ctx, AV_LOG_INFO, "HW accelerator prepared for encode: %s\n", av_hwdevice_get_type_name(type));
>  }
>  
>  static int hwaccel_retrieve_data(AVCodecContext *avctx, AVFrame *input)
> 

I don't think this does what you want.  It is only a preparation step which sets hardware devices which might then be used by a codec, and tells you little about whether it is actually used in practice.  Consider that your message will appear when setting -hwaccel_device and decoding with a random codec with no hardware support, and also when a codec does support some hardware but not the actual stream being decoded (e.g. H.264 4:2:2).

If you want a message like this (which I admit ambivalence to, but if other people think it's useful then sure), I think it has to be logged later when we actually know whether the hardware is usable - either inside lavc or in ffmpeg.c after a frame is returned.

- Mark


More information about the ffmpeg-devel mailing list