[FFmpeg-devel] [PATCH] lavf/qsv_scale: add interpolation methods support

Xiang, Haihao haihao.xiang at intel.com
Thu Dec 10 14:44:07 EET 2020


On Thu, 2020-12-10 at 14:52 +0300, Artem Galin wrote:
> On Wed, 2 Dec 2020 at 04:25, Xiang, Haihao <haihao.xiang at intel.com> wrote:
> 
> > On Tue, 2020-12-01 at 22:42 +0000, Artem Galin wrote:
> > > Since 1.33 API version
> > > 
> > 
> > 
https://github.com/Intel-Media-SDK/MediaSDK/blob/master/api/include/mfxstructures.h#L2088
> > > 
> > > Signed-off-by: Artem Galin <artem.galin at intel.com>
> > > ---
> > >  libavfilter/vf_scale_qsv.c | 17 +++++++++++++++++
> > >  1 file changed, 17 insertions(+)
> > > 
> > > diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> > > index 5064dcbb60..1a6121c295 100644
> > > --- a/libavfilter/vf_scale_qsv.c
> > > +++ b/libavfilter/vf_scale_qsv.c
> > > @@ -70,6 +70,7 @@ enum var_name {
> > >  };
> > > 
> > >  #define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
> > > +#define QSV_HAVE_INTERPOLATION_METHOD QSV_VERSION_ATLEAST(1, 33)
> > > 
> > >  typedef struct QSVScaleContext {
> > >      const AVClass *class;
> > > @@ -95,6 +96,7 @@ typedef struct QSVScaleContext {
> > >      mfxExtVPPScaling         scale_conf;
> > >  #endif
> > >      int                      mode;
> > > +    int                      interpmethod;
> > > 
> > >      mfxExtBuffer             *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
> > >      int                      num_ext_buf;
> > > @@ -409,6 +411,10 @@ static int init_out_session(AVFilterContext *ctx)
> > >      s->scale_conf.Header.BufferId     = MFX_EXTBUFF_VPP_SCALING;
> > >      s->scale_conf.Header.BufferSz     = sizeof(mfxExtVPPScaling);
> > >      s->scale_conf.ScalingMode         = s->mode;
> > > +#if QSV_HAVE_INTERPOLATION_METHOD
> > > +    s->scale_conf.InterpolationMethod = s->interpmethod;
> > > +    av_log(ctx, AV_LOG_VERBOSE, "Interpolation method: %d\n", s-
> > > > interpmethod);
> > > 
> > > +#endif
> > >      s->ext_buffers[s->num_ext_buf++]  = (mfxExtBuffer*)&s->scale_conf;
> > >      av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %d\n", s->mode);
> > >  #endif
> > > @@ -624,6 +630,17 @@ static const AVOption options[] = {
> > >      { "low_power",
> > > "",                      0,             AV_OPT_TYPE_CONST,  { .i64 = 1},
> > > 0,   0,     FLAGS, "mode"},
> > >      {
> > > "hq",        "",                      0,             AV_OPT_TYPE_CONST,
> > 
> > {
> > > .i64 = 2}, 0,   0,     FLAGS, "mode"},
> > >  #endif
> > > +#if QSV_HAVE_INTERPOLATION_METHOD
> > > +    { "interpmethod",  "set interpolation method", OFFSET(interpmethod),
> > > AV_OPT_TYPE_INT,   { .i64 = MFX_INTERPOLATION_DEFAULT},
> > > MFX_INTERPOLATION_DEFAULT, MFX_INTERPOLATION_ADVANCED, FLAGS,
> > 
> > "interpmethod"},
> > > +    { "nearest",       "nearest neighbor
> > > method",  0,                    AV_OPT_TYPE_CONST, { .i64 =
> > > MFX_INTERPOLATION_NEAREST_NEIGHBOR}, INT_MIN, INT_MAX, FLAGS,
> > 
> > "interpmethod"},
> > > +    { "bilinear",      "bilinear
> > > method",          0,                    AV_OPT_TYPE_CONST, { .i64 =
> > > MFX_INTERPOLATION_BILINEAR},         INT_MIN, INT_MAX, FLAGS,
> > 
> > "interpmethod"},
> > > +    { "advanced",      "advanced
> > > method",          0,                    AV_OPT_TYPE_CONST, { .i64 =
> > > MFX_INTERPOLATION_ADVANCED},         INT_MIN, INT_MAX, FLAGS,
> > 
> > "interpmethod"},
> > > +#else
> > > +    { "interpmethod",  "(not supported)",          OFFSET(interpmethod),
> > > AV_OPT_TYPE_INT,   { .i64 = 0}, 0, INT_MAX, FLAGS, "interpmethod"},
> > > +    {
> > > "nearest",       "",                         0,
> > 
> > AV_OPT_TYPE
> > > _CONST, { .i64 = 1}, 0, 0, FLAGS, "interpmethod"},
> > > +    {
> > > "bilinear",      "",                         0,
> > 
> > AV_OPT_TYPE
> > > _CONST, { .i64 = 2}, 0, 0, FLAGS, "interpmethod"},
> > > +    {
> > > "advanced",      "",                         0,
> > 
> > AV_OPT_TYPE
> > > _CONST, { .i64 = 3}, 0, 0, FLAGS, "interpmethod"},
> > > +#endif
> > > 
> > 
> > Why is this option added for !QSV_HAVE_INTERPOLATION_METHOD?
> > 
> > 
> 
> We are not getting error “interpmethod option not found” if API version is
> less than 1.33

Thanks for the explanation, your patch looks good me. 

Regards
Haihao

> 
> > >      { NULL },
> > >  };
> > 
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list