[FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: add support for low-power encoding

Mark Thompson sw at jkqxz.net
Wed Feb 7 12:50:59 EET 2018


On 06/02/18 08:17, Haihao Xiang wrote:
> Although VAEntrypointEncSliceLP was added in old version of VAAPI, we
> never implemented it for VAAPI H265 encoder before. so it is reasonable
> to require VAAPI 1.0
> 
> Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>
> ---
>  libavcodec/vaapi_encode_h265.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index f3b4f6c7e26..efe1148127f 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -65,6 +65,7 @@ typedef struct VAAPIEncodeH265Options {
>      int aud;
>      int profile;
>      int level;
> +    int low_power;
>  } VAAPIEncodeH265Options;
>  
>  
> @@ -914,7 +915,18 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
>                 avctx->profile);
>          return AVERROR(EINVAL);
>      }
> -    ctx->va_entrypoint = VAEntrypointEncSlice;
> +
> +    if (opt->low_power) {
> +#if VA_CHECK_VERSION(1, 0, 0)
> +        ctx->va_entrypoint = VAEntrypointEncSliceLP;
> +#else
> +        av_log(avctx, AV_LOG_ERROR, "Low-power encoding is not "
> +               "supported with this VAAPI version.\n");
> +        return AVERROR(EINVAL);
> +#endif
> +    } else {
> +        ctx->va_entrypoint = VAEntrypointEncSlice;
> +    }
>  
>      if (avctx->bit_rate > 0) {
>          if (avctx->rc_max_rate == avctx->bit_rate)
> @@ -986,6 +998,10 @@ static const AVOption vaapi_encode_h265_options[] = {
>      { LEVEL("6.2", 186) },
>  #undef LEVEL
>  
> +    { "low_power", "Use low-power encoding mode (experimental: only supported "

Do you want to copy this comment?

> +      "on some platforms, does not support all features)",
> +      OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
> +
>      { NULL },
>  };
>  
> 

How can I test this (and the following patch)?  It doesn't appear to exist on any current platform/driver.

I don't like how this code is being copied around, but I guess it would work for now.  I'll look into doing something more sensible here.

- Mark


More information about the ffmpeg-devel mailing list