diff mbox series

[FFmpeg-devel,v1] avfilter/vf_vpp_qsv: add scale mode option

Message ID 20210224014158.7302-1-fei.w.wang@intel.com
State New
Headers show
Series [FFmpeg-devel,v1] avfilter/vf_vpp_qsv: add scale mode option | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Fei Wang Feb. 24, 2021, 1:41 a.m. UTC
The option allow user to set diffenent scaling mode from
auto/low-power/high-quality.

More details:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

Comments

Xiang, Haihao March 12, 2021, 6:29 a.m. UTC | #1
On Wed, 2021-02-24 at 09:41 +0800, Fei Wang wrote:
> The option allow user to set diffenent scaling mode from
> auto/low-power/high-quality.
> 
> More details:
> 
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
> 
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> index 5d57707455..effc459d3b 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -43,8 +43,9 @@
>  
>  /* number of video enhancement filters */
>  #define ENH_FILTERS_COUNT (7)
> -#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17)
> -#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
> +#define QSV_HAVE_ROTATION       QSV_VERSION_ATLEAST(1, 17)
> +#define QSV_HAVE_MIRRORING      QSV_VERSION_ATLEAST(1, 19)
> +#define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19)
>  
>  typedef struct VPPContext{
>      const AVClass *class;
> @@ -59,6 +60,9 @@ typedef struct VPPContext{
>      mfxExtVPPProcAmp procamp_conf;
>      mfxExtVPPRotation rotation_conf;
>      mfxExtVPPMirroring mirroring_conf;
> +#ifdef QSV_HAVE_SCALING_CONFIG
> +    mfxExtVPPScaling scale_conf;
> +#endif
>  
>      int out_width;
>      int out_height;
> @@ -83,6 +87,8 @@ typedef struct VPPContext{
>      int rotate;                 /* rotate angle : [0, 90, 180, 270] */
>      int hflip;                  /* flip mode : 0 = off, 1 = HORIZONTAL flip
> */
>  
> +    int scale_mode;             /* scale mode : 0 = auto, 1 = low power, 2 =
> high quality */
> +
>      /* param for the procamp */
>      int    procamp;            /* enable procamp */
>      float  hue;
> @@ -128,6 +134,7 @@ static const AVOption options[] = {
>      { "h",      "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, {
> .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
>      { "height", "Output video height", 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 },
> +    { "scale_mode", "scale 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" },
>  
>      { NULL }
>  };
> @@ -454,6 +461,20 @@ static int config_output(AVFilterLink *outlink)
>  #endif
>      }
>  
> +    if (inlink->w != outlink->w || inlink->h != outlink->h) {
> +#ifdef QSV_HAVE_SCALING_CONFIG
> +        memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
> +        vpp->scale_conf.Header.BufferId    = MFX_EXTBUFF_VPP_SCALING;
> +        vpp->scale_conf.Header.BufferSz    = sizeof(mfxExtVPPScaling);
> +        vpp->scale_conf.ScalingMode        = vpp->scale_mode;
> +
> +        param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->scale_conf;
> +#else
> +        av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale option is "
> +            "not supported with this MSDK version.\n");
> +#endif
> +    }
> +
>      if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
>          vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip ||
>          inlink->w != outlink->w || inlink->h != outlink->h || in_format !=
> vpp->out_format)

LGTM 

Thanks
Haihao
Linjie Fu March 22, 2021, 12:12 p.m. UTC | #2
On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com> wrote:
>
> The option allow user to set diffenent scaling mode from
> auto/low-power/high-quality.
>
> More details:
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
>
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
>  1 file changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> index 5d57707455..effc459d3b 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -43,8 +43,9 @@
>
>  /* number of video enhancement filters */
>  #define ENH_FILTERS_COUNT (7)
> -#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17)
> -#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
> +#define QSV_HAVE_ROTATION       QSV_VERSION_ATLEAST(1, 17)
> +#define QSV_HAVE_MIRRORING      QSV_VERSION_ATLEAST(1, 19)
> +#define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19)
>
>  typedef struct VPPContext{
>      const AVClass *class;
> @@ -59,6 +60,9 @@ typedef struct VPPContext{
>      mfxExtVPPProcAmp procamp_conf;
>      mfxExtVPPRotation rotation_conf;
>      mfxExtVPPMirroring mirroring_conf;
> +#ifdef QSV_HAVE_SCALING_CONFIG
> +    mfxExtVPPScaling scale_conf;
> +#endif
>
>      int out_width;
>      int out_height;
> @@ -83,6 +87,8 @@ typedef struct VPPContext{
>      int rotate;                 /* rotate angle : [0, 90, 180, 270] */
>      int hflip;                  /* flip mode : 0 = off, 1 = HORIZONTAL flip */
>
> +    int scale_mode;             /* scale mode : 0 = auto, 1 = low power, 2 = high quality */
> +
>      /* param for the procamp */
>      int    procamp;            /* enable procamp */
>      float  hue;
> @@ -128,6 +134,7 @@ static const AVOption options[] = {
>      { "h",      "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
>      { "height", "Output video height", 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 },
> +    { "scale_mode", "scale 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" },
>
>      { NULL }
>  };
> @@ -454,6 +461,20 @@ static int config_output(AVFilterLink *outlink)
>  #endif
>      }
>
> +    if (inlink->w != outlink->w || inlink->h != outlink->h) {
> +#ifdef QSV_HAVE_SCALING_CONFIG
> +        memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
> +        vpp->scale_conf.Header.BufferId    = MFX_EXTBUFF_VPP_SCALING;
> +        vpp->scale_conf.Header.BufferSz    = sizeof(mfxExtVPPScaling);
> +        vpp->scale_conf.ScalingMode        = vpp->scale_mode;
> +
> +        param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->scale_conf;
> +#else
> +        av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale option is "
> +            "not supported with this MSDK version.\n");
> +#endif
> +    }
> +
>      if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
>          vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip ||
>          inlink->w != outlink->w || inlink->h != outlink->h || in_format != vpp->out_format)
> --
> 2.17.1
>
Looks reasonable, and it seems the default behaviour is QUALITY mode
on all platforms except for APL:
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/shared/src/mfx_vpp_vaapi.cpp#L1258

- linjie
Fei Wang March 24, 2021, 6:15 a.m. UTC | #3
On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
> On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
> wrote:
> > 
> > The option allow user to set diffenent scaling mode from
> > auto/low-power/high-quality.
> > 
> > More details:
> > 
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
> > 
> > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > ---
> >  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
> >  1 file changed, 23 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> > index 5d57707455..effc459d3b 100644
> > --- a/libavfilter/vf_vpp_qsv.c
> > +++ b/libavfilter/vf_vpp_qsv.c
> > @@ -43,8 +43,9 @@
> > 
> >  /* number of video enhancement filters */
> >  #define ENH_FILTERS_COUNT (7)
> > -#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17)
> > -#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
> > +#define QSV_HAVE_ROTATION       QSV_VERSION_ATLEAST(1, 17)
> > +#define QSV_HAVE_MIRRORING      QSV_VERSION_ATLEAST(1, 19)
> > +#define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19)
> > 
> >  typedef struct VPPContext{
> >      const AVClass *class;
> > @@ -59,6 +60,9 @@ typedef struct VPPContext{
> >      mfxExtVPPProcAmp procamp_conf;
> >      mfxExtVPPRotation rotation_conf;
> >      mfxExtVPPMirroring mirroring_conf;
> > +#ifdef QSV_HAVE_SCALING_CONFIG
> > +    mfxExtVPPScaling scale_conf;
> > +#endif
> > 
> >      int out_width;
> >      int out_height;
> > @@ -83,6 +87,8 @@ typedef struct VPPContext{
> >      int rotate;                 /* rotate angle : [0, 90, 180,
> > 270] */
> >      int hflip;                  /* flip mode : 0 = off, 1 =
> > HORIZONTAL flip */
> > 
> > +    int scale_mode;             /* scale mode : 0 = auto, 1 = low
> > power, 2 = high quality */
> > +
> >      /* param for the procamp */
> >      int    procamp;            /* enable procamp */
> >      float  hue;
> > @@ -128,6 +134,7 @@ static const AVOption options[] = {
> >      { "h",      "Output video height", OFFSET(oh),
> > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
> >      { "height", "Output video height", 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 },
> > +    { "scale_mode", "scale 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" },
> > 
> >      { NULL }
> >  };
> > @@ -454,6 +461,20 @@ static int config_output(AVFilterLink
> > *outlink)
> >  #endif
> >      }
> > 
> > +    if (inlink->w != outlink->w || inlink->h != outlink->h) {
> > +#ifdef QSV_HAVE_SCALING_CONFIG
> > +        memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
> > +        vpp->scale_conf.Header.BufferId    =
> > MFX_EXTBUFF_VPP_SCALING;
> > +        vpp->scale_conf.Header.BufferSz    =
> > sizeof(mfxExtVPPScaling);
> > +        vpp->scale_conf.ScalingMode        = vpp->scale_mode;
> > +
> > +        param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> > >scale_conf;
> > +#else
> > +        av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale option is "
> > +            "not supported with this MSDK version.\n");
> > +#endif
> > +    }
> > +
> >      if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp-
> > >denoise ||
> >          vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip
> > ||
> >          inlink->w != outlink->w || inlink->h != outlink->h ||
> > in_format != vpp->out_format)
> > --
> > 2.17.1
> > 
> 
> Looks reasonable, and it seems the default behaviour is QUALITY mode
> on all platforms except for APL:

That's right. If scale_mode is set to auto, MSDK will choose different
mode(high-quality/low-power) on different platform.

> 
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/shared/src/mfx_vpp_vaapi.cpp#L1258
> 
> - linjie
Linjie Fu Aug. 3, 2021, 2:43 p.m. UTC | #4
On Wed, Mar 24, 2021 at 2:15 PM Wang, Fei W <fei.w.wang@intel.com> wrote:

> On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
> > On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
> > wrote:
> > >
> > > The option allow user to set diffenent scaling mode from
> > > auto/low-power/high-quality.
> > >
> > > More details:
> > >
>
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
> > >
> > > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > > ---
> > >  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
> > >  1 file changed, 23 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> > > index 5d57707455..effc459d3b 100644
> > > --- a/libavfilter/vf_vpp_qsv.c
> > > +++ b/libavfilter/vf_vpp_qsv.c
> > > @@ -43,8 +43,9 @@
> > >
> > >  /* number of video enhancement filters */
> > >  #define ENH_FILTERS_COUNT (7)
> > > -#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17)
> > > -#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
> > > +#define QSV_HAVE_ROTATION       QSV_VERSION_ATLEAST(1, 17)
> > > +#define QSV_HAVE_MIRRORING      QSV_VERSION_ATLEAST(1, 19)
> > > +#define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19)
> > >
> > >  typedef struct VPPContext{
> > >      const AVClass *class;
> > > @@ -59,6 +60,9 @@ typedef struct VPPContext{
> > >      mfxExtVPPProcAmp procamp_conf;
> > >      mfxExtVPPRotation rotation_conf;
> > >      mfxExtVPPMirroring mirroring_conf;
> > > +#ifdef QSV_HAVE_SCALING_CONFIG
> > > +    mfxExtVPPScaling scale_conf;
> > > +#endif
> > >
> > >      int out_width;
> > >      int out_height;
> > > @@ -83,6 +87,8 @@ typedef struct VPPContext{
> > >      int rotate;                 /* rotate angle : [0, 90, 180,
> > > 270] */
> > >      int hflip;                  /* flip mode : 0 = off, 1 =
> > > HORIZONTAL flip */
> > >
> > > +    int scale_mode;             /* scale mode : 0 = auto, 1 = low
> > > power, 2 = high quality */
> > > +
> > >      /* param for the procamp */
> > >      int    procamp;            /* enable procamp */
> > >      float  hue;
> > > @@ -128,6 +134,7 @@ static const AVOption options[] = {
> > >      { "h",      "Output video height", OFFSET(oh),
> > > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
> > >      { "height", "Output video height", 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 },
> > > +    { "scale_mode", "scale 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" },
> > >
> > >      { NULL }
> > >  };
> > > @@ -454,6 +461,20 @@ static int config_output(AVFilterLink
> > > *outlink)
> > >  #endif
> > >      }
> > >
> > > +    if (inlink->w != outlink->w || inlink->h != outlink->h) {
> > > +#ifdef QSV_HAVE_SCALING_CONFIG
> > > +        memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
> > > +        vpp->scale_conf.Header.BufferId    =
> > > MFX_EXTBUFF_VPP_SCALING;
> > > +        vpp->scale_conf.Header.BufferSz    =
> > > sizeof(mfxExtVPPScaling);
> > > +        vpp->scale_conf.ScalingMode        = vpp->scale_mode;
> > > +
> > > +        param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> > > >scale_conf;
> > > +#else
> > > +        av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale option is "
> > > +            "not supported with this MSDK version.\n");
> > > +#endif
> > > +    }
> > > +
> > >      if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp-
> > > >denoise ||
> > >          vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip
> > > ||
> > >          inlink->w != outlink->w || inlink->h != outlink->h ||
> > > in_format != vpp->out_format)
> > > --
> > > 2.17.1
> > >
> >
> > Looks reasonable, and it seems the default behaviour is QUALITY mode
> > on all platforms except for APL:
>
> That's right. If scale_mode is set to auto, MSDK will choose different
> mode(high-quality/low-power) on different platform.
>

Applied, thx.

- linjie
Gyan Doshi Aug. 3, 2021, 2:53 p.m. UTC | #5
On 2021-08-03 20:13, Linjie Fu wrote:
> On Wed, Mar 24, 2021 at 2:15 PM Wang, Fei W <fei.w.wang@intel.com> wrote:
>
>> On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
>>> On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
>>> wrote:
>>>> The option allow user to set diffenent scaling mode from
>>>> auto/low-power/high-quality.
>>>>
>>>> More details:
>>>>
>> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
>>>> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
>>>> ---
>>>>   libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
>>>>   1 file changed, 23 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
>>>> index 5d57707455..effc459d3b 100644
>>>> --- a/libavfilter/vf_vpp_qsv.c
>>>> +++ b/libavfilter/vf_vpp_qsv.c
>>>> @@ -43,8 +43,9 @@
>>>>
>>>>   /* number of video enhancement filters */
>>>>   #define ENH_FILTERS_COUNT (7)
>>>> -#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17)
>>>> -#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
>>>> +#define QSV_HAVE_ROTATION       QSV_VERSION_ATLEAST(1, 17)
>>>> +#define QSV_HAVE_MIRRORING      QSV_VERSION_ATLEAST(1, 19)
>>>> +#define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19)
>>>>
>>>>   typedef struct VPPContext{
>>>>       const AVClass *class;
>>>> @@ -59,6 +60,9 @@ typedef struct VPPContext{
>>>>       mfxExtVPPProcAmp procamp_conf;
>>>>       mfxExtVPPRotation rotation_conf;
>>>>       mfxExtVPPMirroring mirroring_conf;
>>>> +#ifdef QSV_HAVE_SCALING_CONFIG
>>>> +    mfxExtVPPScaling scale_conf;
>>>> +#endif
>>>>
>>>>       int out_width;
>>>>       int out_height;
>>>> @@ -83,6 +87,8 @@ typedef struct VPPContext{
>>>>       int rotate;                 /* rotate angle : [0, 90, 180,
>>>> 270] */
>>>>       int hflip;                  /* flip mode : 0 = off, 1 =
>>>> HORIZONTAL flip */
>>>>
>>>> +    int scale_mode;             /* scale mode : 0 = auto, 1 = low
>>>> power, 2 = high quality */
>>>> +
>>>>       /* param for the procamp */
>>>>       int    procamp;            /* enable procamp */
>>>>       float  hue;
>>>> @@ -128,6 +134,7 @@ static const AVOption options[] = {
>>>>       { "h",      "Output video height", OFFSET(oh),
>>>> AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
>>>>       { "height", "Output video height", 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 },
>>>> +    { "scale_mode", "scale 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" },
>>>>
>>>>       { NULL }
>>>>   };
>>>> @@ -454,6 +461,20 @@ static int config_output(AVFilterLink
>>>> *outlink)
>>>>   #endif
>>>>       }
>>>>
>>>> +    if (inlink->w != outlink->w || inlink->h != outlink->h) {
>>>> +#ifdef QSV_HAVE_SCALING_CONFIG
>>>> +        memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
>>>> +        vpp->scale_conf.Header.BufferId    =
>>>> MFX_EXTBUFF_VPP_SCALING;
>>>> +        vpp->scale_conf.Header.BufferSz    =
>>>> sizeof(mfxExtVPPScaling);
>>>> +        vpp->scale_conf.ScalingMode        = vpp->scale_mode;
>>>> +
>>>> +        param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
>>>>> scale_conf;
>>>> +#else
>>>> +        av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale option is "
>>>> +            "not supported with this MSDK version.\n");
>>>> +#endif
>>>> +    }
>>>> +
>>>>       if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp-
>>>>> denoise ||
>>>>           vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip
>>>> ||
>>>>           inlink->w != outlink->w || inlink->h != outlink->h ||
>>>> in_format != vpp->out_format)
>>>> --
>>>> 2.17.1
>>>>
>>> Looks reasonable, and it seems the default behaviour is QUALITY mode
>>> on all platforms except for APL:
>> That's right. If scale_mode is set to auto, MSDK will choose different
>> mode(high-quality/low-power) on different platform.
>>
> Applied, thx.

Can you add a docs entry for this filter?

Thanks,
Gyan
Andreas Rheinhardt Aug. 4, 2021, 12:30 a.m. UTC | #6
Linjie Fu:
> On Wed, Mar 24, 2021 at 2:15 PM Wang, Fei W <fei.w.wang@intel.com> wrote:
> 
>> On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
>>> On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
>>> wrote:
>>>>
>>>> The option allow user to set diffenent scaling mode from
>>>> auto/low-power/high-quality.
>>>>
>>>> More details:
>>>>
>>
>> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
>>>>
>>>> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
>>>> ---
>>>>  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
>>>>  1 file changed, 23 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
>>>> index 5d57707455..effc459d3b 100644
>>>> --- a/libavfilter/vf_vpp_qsv.c
>>>> +++ b/libavfilter/vf_vpp_qsv.c
>>>> @@ -43,8 +43,9 @@
>>>>
>>>>  /* number of video enhancement filters */
>>>>  #define ENH_FILTERS_COUNT (7)

You forgot to increment this number; see
https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/283004.html

- Andreas
Linjie Fu Aug. 4, 2021, 1:47 a.m. UTC | #7
Hi Andreas,On Wed, Aug 4, 2021 at 8:30 AM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Linjie Fu:
> > On Wed, Mar 24, 2021 at 2:15 PM Wang, Fei W <fei.w.wang@intel.com>
> wrote:
> >
> >> On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
> >>> On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
> >>> wrote:
> >>>>
> >>>> The option allow user to set diffenent scaling mode from
> >>>> auto/low-power/high-quality.
> >>>>
> >>>> More details:
> >>>>
> >>
> >>
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
> >>>>
> >>>> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> >>>> ---
> >>>>  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
> >>>>  1 file changed, 23 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> >>>> index 5d57707455..effc459d3b 100644
> >>>> --- a/libavfilter/vf_vpp_qsv.c
> >>>> +++ b/libavfilter/vf_vpp_qsv.c
> >>>> @@ -43,8 +43,9 @@
> >>>>
> >>>>  /* number of video enhancement filters */
> >>>>  #define ENH_FILTERS_COUNT (7)
>
> You forgot to increment this number; see
> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/283004.html


Thanks for the reminder, patch lgtm.
Xiang, Haihao Aug. 4, 2021, 5:09 a.m. UTC | #8
On Wed, 2021-08-04 at 09:47 +0800, Linjie Fu wrote:
> Hi Andreas,On Wed, Aug 4, 2021 at 8:30 AM Andreas Rheinhardt <
> andreas.rheinhardt@outlook.com> wrote:
> 
> > Linjie Fu:
> > > On Wed, Mar 24, 2021 at 2:15 PM Wang, Fei W <fei.w.wang@intel.com>
> > 
> > wrote:
> > > 
> > > > On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
> > > > > On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
> > > > > wrote:
> > > > > > 
> > > > > > The option allow user to set diffenent scaling mode from
> > > > > > auto/low-power/high-quality.
> > > > > > 
> > > > > > More details:
> > > > > > 
> > > > 
> > > > 
> > 
> > 
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
> > > > > > 
> > > > > > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > > > > > ---
> > > > > >  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
> > > > > >  1 file changed, 23 insertions(+), 2 deletions(-)
> > > > > > 
> > > > > > diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> > > > > > index 5d57707455..effc459d3b 100644
> > > > > > --- a/libavfilter/vf_vpp_qsv.c
> > > > > > +++ b/libavfilter/vf_vpp_qsv.c
> > > > > > @@ -43,8 +43,9 @@
> > > > > > 
> > > > > >  /* number of video enhancement filters */
> > > > > >  #define ENH_FILTERS_COUNT (7)
> > 
> > You forgot to increment this number; see
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/283004.html
> 
> 
> Thanks for the reminder, patch lgtm.

I have a similar patch in my patchset: clean-up QSV filters 
http://ffmpeg.org/pipermail/ffmpeg-devel/2021-July/282742.html, 

ENH_FILTERS_COUNT is defined to 8 in 
http://ffmpeg.org/pipermail/ffmpeg-devel/2021-July/282759.html. Could you please
merge Andreas's patch? If so, I may rebase my patchset against the latest FFmpeg

Thanks
Haihao
Andreas Rheinhardt Aug. 4, 2021, 11 a.m. UTC | #9
Xiang, Haihao:
> On Wed, 2021-08-04 at 09:47 +0800, Linjie Fu wrote:
>> Hi Andreas,On Wed, Aug 4, 2021 at 8:30 AM Andreas Rheinhardt <
>> andreas.rheinhardt@outlook.com> wrote:
>>
>>> Linjie Fu:
>>>> On Wed, Mar 24, 2021 at 2:15 PM Wang, Fei W <fei.w.wang@intel.com>
>>>
>>> wrote:
>>>>
>>>>> On Mon, 2021-03-22 at 20:12 +0800, Linjie Fu wrote:
>>>>>> On Wed, Feb 24, 2021 at 9:44 AM Fei Wang <fei.w.wang@intel.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> The option allow user to set diffenent scaling mode from
>>>>>>> auto/low-power/high-quality.
>>>>>>>
>>>>>>> More details:
>>>>>>>
>>>>>
>>>>>
>>>
>>>
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/doc/mediasdk-man.md#mfxExtVPPScaling
>>>>>>>
>>>>>>> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
>>>>>>> ---
>>>>>>>  libavfilter/vf_vpp_qsv.c | 25 +++++++++++++++++++++++--
>>>>>>>  1 file changed, 23 insertions(+), 2 deletions(-)
>>>>>>>
>>>>>>> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
>>>>>>> index 5d57707455..effc459d3b 100644
>>>>>>> --- a/libavfilter/vf_vpp_qsv.c
>>>>>>> +++ b/libavfilter/vf_vpp_qsv.c
>>>>>>> @@ -43,8 +43,9 @@
>>>>>>>
>>>>>>>  /* number of video enhancement filters */
>>>>>>>  #define ENH_FILTERS_COUNT (7)
>>>
>>> You forgot to increment this number; see
>>> https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/283004.html
>>
>>
>> Thanks for the reminder, patch lgtm.
> 
> I have a similar patch in my patchset: clean-up QSV filters 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2021-July/282742.html, 
> 
> ENH_FILTERS_COUNT is defined to 8 in 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2021-July/282759.html. Could you please
> merge Andreas's patch? If so, I may rebase my patchset against the latest FFmpeg
> 
I just pushed mine.

- Andreas
diff mbox series

Patch

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 5d57707455..effc459d3b 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -43,8 +43,9 @@ 
 
 /* number of video enhancement filters */
 #define ENH_FILTERS_COUNT (7)
-#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17)
-#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
+#define QSV_HAVE_ROTATION       QSV_VERSION_ATLEAST(1, 17)
+#define QSV_HAVE_MIRRORING      QSV_VERSION_ATLEAST(1, 19)
+#define QSV_HAVE_SCALING_CONFIG QSV_VERSION_ATLEAST(1, 19)
 
 typedef struct VPPContext{
     const AVClass *class;
@@ -59,6 +60,9 @@  typedef struct VPPContext{
     mfxExtVPPProcAmp procamp_conf;
     mfxExtVPPRotation rotation_conf;
     mfxExtVPPMirroring mirroring_conf;
+#ifdef QSV_HAVE_SCALING_CONFIG
+    mfxExtVPPScaling scale_conf;
+#endif
 
     int out_width;
     int out_height;
@@ -83,6 +87,8 @@  typedef struct VPPContext{
     int rotate;                 /* rotate angle : [0, 90, 180, 270] */
     int hflip;                  /* flip mode : 0 = off, 1 = HORIZONTAL flip */
 
+    int scale_mode;             /* scale mode : 0 = auto, 1 = low power, 2 = high quality */
+
     /* param for the procamp */
     int    procamp;            /* enable procamp */
     float  hue;
@@ -128,6 +134,7 @@  static const AVOption options[] = {
     { "h",      "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
     { "height", "Output video height", 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 },
+    { "scale_mode", "scale 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" },
 
     { NULL }
 };
@@ -454,6 +461,20 @@  static int config_output(AVFilterLink *outlink)
 #endif
     }
 
+    if (inlink->w != outlink->w || inlink->h != outlink->h) {
+#ifdef QSV_HAVE_SCALING_CONFIG
+        memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
+        vpp->scale_conf.Header.BufferId    = MFX_EXTBUFF_VPP_SCALING;
+        vpp->scale_conf.Header.BufferSz    = sizeof(mfxExtVPPScaling);
+        vpp->scale_conf.ScalingMode        = vpp->scale_mode;
+
+        param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->scale_conf;
+#else
+        av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale option is "
+            "not supported with this MSDK version.\n");
+#endif
+    }
+
     if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
         vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip ||
         inlink->w != outlink->w || inlink->h != outlink->h || in_format != vpp->out_format)