[FFmpeg-devel] [PATCH] lavfi/vf_vpp_qsv: add support for new scaling modes

Xiang, Haihao haihao.xiang at intel.com
Mon Feb 6 09:52:16 EET 2023


On Vr, 2023-02-03 at 14:36 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang <haihao.xiang at intel.com>
> 
> The new modes work on new platforms and are avaialable only for oneVPL.
> 
> Signed-off-by: Haihao Xiang <haihao.xiang at intel.com>
> ---
>  libavfilter/vf_vpp_qsv.c | 31 ++++++++++++++++++++++++++++---
>  1 file changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> index 65484fa091..ac77f7bb4b 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -504,8 +504,15 @@ static int config_output(AVFilterLink *outlink)
>  
>      if (inlink->w != outlink->w || inlink->h != outlink->h || in_format !=
> vpp->out_format) {
>          if (QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 1, 19)) {
> +            int mode = vpp->scale_mode;
> +
> +#if QSV_ONEVPL
> +            if (mode > 2)
> +                mode = MFX_SCALING_MODE_VENDOR + mode - 2;
> +#endif
> +
>              INIT_MFX_EXTBUF(scale_conf, MFX_EXTBUFF_VPP_SCALING);
> -            SET_MFX_PARAM_FIELD(scale_conf, ScalingMode, vpp->scale_mode);
> +            SET_MFX_PARAM_FIELD(scale_conf, ScalingMode, mode);
>          } else
>              av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale & format
> conversion "
>                     "option is not supported with this MSDK version.\n");
> @@ -679,10 +686,19 @@ static const AVOption vpp_options[] = {
>      { "height", "Output video height(0=input video height, -1=keep input
> video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255,
> .flags = FLAGS },
>      { "format", "Output pixel format", OFFSET(output_format_str),
> AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
>      { "async_depth", "Internal parallelization depth, the higher the value
> the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0
> }, 0, INT_MAX, .flags = FLAGS },
> -    { "scale_mode", "scale & format conversion mode: 0=auto, 1=low power,
> 2=high quality", OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 =
> MFX_SCALING_MODE_DEFAULT }, MFX_SCALING_MODE_DEFAULT,
> MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale mode" },
> +#if QSV_ONEVPL
> +    { "scale_mode", "scaling & format conversion mode (mode compute(3), vd(4)
> and ve(5) are only available on some platforms)", OFFSET(scale_mode),
> AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 5, .flags = FLAGS, "scale mode" },
> +#else
> +    { "scale_mode", "scaling & format conversion mode", OFFSET(scale_mode),
> AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT },
> MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale
> mode" },
> +#endif
>      { "auto",      "auto mode",             0,    AV_OPT_TYPE_CONST,  { .i64
> = MFX_SCALING_MODE_DEFAULT},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
>      { "low_power", "low power mode",        0,    AV_OPT_TYPE_CONST,  { .i64
> = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
>      { "hq",        "high quality mode",     0,    AV_OPT_TYPE_CONST,  { .i64
> = MFX_SCALING_MODE_QUALITY},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
> +#if QSV_ONEVPL
> +    { "compute",   "compute",               0,    AV_OPT_TYPE_CONST,  { .i64
> = 3},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
> +    { "vd",        "vd",                    0,    AV_OPT_TYPE_CONST,  { .i64
> = 4},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
> +    { "ve",        "ve",                    0,    AV_OPT_TYPE_CONST,  { .i64
> = 5},  INT_MIN, INT_MAX, FLAGS, "scale mode"},
> +#endif
>  
>      { "rate", "Generate output at frame rate or field rate, available only
> for deinterlace mode",
>        OFFSET(field_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "rate"
> },
> @@ -735,9 +751,18 @@ static const AVOption qsvscale_options[] = {
>      { "h",      "Output video height(0=input video height, -1=keep input
> video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags =
> FLAGS },
>      { "format", "Output pixel format", OFFSET(output_format_str),
> AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
>  
> -    { "mode",      "set scaling
> mode",    OFFSET(scale_mode),    AV_OPT_TYPE_INT,    { .i64 =
> MFX_SCALING_MODE_DEFAULT}, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY,
> FLAGS, "mode"},
> +#if QSV_ONEVPL
> +    { "mode",      "scaling & format conversion mode (mode compute(3), vd(4)
> and ve(5) are only available on some
> platforms)",    OFFSET(scale_mode),    AV_OPT_TYPE_INT,    { .i64 = 0}, 0, 5,
> FLAGS, "mode"},
> +#else
> +    { "mode",      "scaling & format conversion
> mode",    OFFSET(scale_mode),    AV_OPT_TYPE_INT,    { .i64 =
> MFX_SCALING_MODE_DEFAULT}, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY,
> FLAGS, "mode"},
> +#endif
>      { "low_power", "low power
> mode",        0,             AV_OPT_TYPE_CONST,  { .i64 =
> MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "mode"},
>      { "hq",        "high quality
> mode",     0,             AV_OPT_TYPE_CONST,  { .i64 =
> MFX_SCALING_MODE_QUALITY},  INT_MIN, INT_MAX, FLAGS, "mode"},
> +#if QSV_ONEVPL
> +    {
> "compute",   "compute",               0,             AV_OPT_TYPE_CONST,  {
> .i64 = 3},  INT_MIN, INT_MAX, FLAGS, "mode"},
> +    {
> "vd",        "vd",                    0,             AV_OPT_TYPE_CONST,  {
> .i64 = 4},  INT_MIN, INT_MAX, FLAGS, "mode"},
> +    {
> "ve",        "ve",                    0,             AV_OPT_TYPE_CONST,  {
> .i64 = 5},  INT_MIN, INT_MAX, FLAGS, "mode"},
> +#endif
>  
>      { NULL },
>  };

Will apply,

- Haihao



More information about the ffmpeg-devel mailing list