diff mbox series

[FFmpeg-devel] avfilter/vpp_qsv: fix regression on older api versions (e.g. 1.11)

Message ID pull.15.ffstaging.FFmpeg.1641093136327.ffmpegagent@gmail.com
State New
Headers show
Series [FFmpeg-devel] avfilter/vpp_qsv: fix regression on older api versions (e.g. 1.11) | expand

Checks

Context Check Description
andriy/commit_msg_x86 warning Please wrap lines in the body of the commit message between 60 and 72 characters.
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/commit_msg_ppc warning Please wrap lines in the body of the commit message between 60 and 72 characters.
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

Aman Karmani Jan. 2, 2022, 3:12 a.m. UTC
From: softworkz <softworkz@hotmail.com>

Commit 8b83dad82512a6948b63408f964463b063ad24c9 introduced a regression in a way
that scaling via vpp_qsv didn't work any longer for devices with an MSDK runtime
version lower than 1.19. This is true for older CPUs which are stuck at 1.11.
The commit added checks for the compile-sdk version but it didn't test for the
runtime version.

Signed-off-by: softworkz <softworkz@hotmail.com>
---
    avfilter/vpp_qsv: fix regression on older api versions (e.g. 1.11)
    
    Fix a recently introduced regression when using QSV VPP.

Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-15%2Fsoftworkz%2Fqsv_vpp_regression-v1
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging-15/softworkz/qsv_vpp_regression-v1
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/15

 libavfilter/vf_vpp_qsv.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)


base-commit: d6b2357eddca392ee137cb2a92ff178a0a7d0cce
diff mbox series

Patch

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index ab58a5777e..09590157e3 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -139,8 +139,9 @@  static const AVOption options[] = {
     { "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 },
     { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS },
+#ifdef QSV_HAVE_SCALING_CONFIG
     { "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" },
-
+#endif
     { NULL }
 };
 
@@ -304,6 +305,7 @@  static int config_output(AVFilterLink *outlink)
     QSVVPPParam     param = { NULL };
     QSVVPPCrop      crop  = { 0 };
     mfxExtBuffer    *ext_buf[ENH_FILTERS_COUNT];
+    mfxVersion      mfx_version;
     AVFilterLink    *inlink = ctx->inputs[0];
     enum AVPixelFormat in_format;
 
@@ -317,6 +319,11 @@  static int config_output(AVFilterLink *outlink)
     param.ext_buf       = ext_buf;
     param.async_depth   = vpp->async_depth;
 
+    if (MFXQueryVersion(vpp->qsv->session, &mfx_version) < 0) {
+        av_log(ctx, AV_LOG_ERROR, "Failed to query mfx version.\n");
+        return AVERROR(EINVAL);
+    }
+
     if (inlink->format == AV_PIX_FMT_QSV) {
          if (!inlink->hw_frames_ctx || !inlink->hw_frames_ctx->data)
              return AVERROR(EINVAL);
@@ -467,19 +474,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 (inlink->w != outlink->w || inlink->h != outlink->h) {
+        if (QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 1, 19)) {
+            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 ||