[FFmpeg-devel] [PATCH] lavf/qsvvpp: add support for Motion Compensated Temporal Filter
Linjie Fu
linjie.fu at intel.com
Mon Jan 14 14:39:44 EET 2019
Add support for Motion Compensated Temporal Filter in QSV VPP.
[1, 20] to indicate the filter-strength of MCTF, 0 stands for AUTO mode,
-1 stands for default OFF.
A strength of MCTF process controls degree of possible changes of pixel
values eligible for MCTF.
The limitation of MSDK API version:
Media SDK >= 1.26
Signed-off-by: Linjie Fu <linjie.fu at intel.com>
---
libavfilter/vf_vpp_qsv.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 41a9f38962..f8984cccc4 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -43,6 +43,8 @@
/* number of video enhancement filters */
#define ENH_FILTERS_COUNT (5)
+#define QSV_HAVE_MCTF QSV_VERSION_ATLEAST(1, 26)
+
typedef struct VPPContext{
const AVClass *class;
@@ -52,6 +54,7 @@ typedef struct VPPContext{
mfxExtVPPDeinterlacing deinterlace_conf;
mfxExtVPPFrameRateConversion frc_conf;
mfxExtVPPDenoise denoise_conf;
+ mfxExtVppMctf mctf_conf;
mfxExtVPPDetail detail_conf;
mfxExtVPPProcAmp procamp_conf;
@@ -62,6 +65,7 @@ typedef struct VPPContext{
int use_frc; /* use framerate conversion */
int deinterlace; /* deinterlace mode : 0=off, 1=bob, 2=advanced */
int denoise; /* Enable Denoise algorithm. Value [0, 100] */
+ int mctf; /* Enable Motion Compensated Temporal Filter (MCTF) algorithm. Value [-1, 20] */
int detail; /* Enable Detail Enhancement algorithm. */
/* Level is the optional, value [0, 100] */
int use_crop; /* 1 = use crop; 0=none */
@@ -94,6 +98,7 @@ static const AVOption options[] = {
{ "saturation", "ProcAmp saturation", OFFSET(saturation), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
{ "contrast", "ProcAmp contrast", OFFSET(contrast), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
{ "brightness", "ProcAmp brightness", OFFSET(brightness), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, -100.0, 100.0, .flags = FLAGS},
+ { "mctf", "mctf filter strength: 0=auto", OFFSET(mctf), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 20, .flags = FLAGS },
{ "cw", "set the width crop area expression", OFFSET(cw), AV_OPT_TYPE_STRING, { .str = "iw" }, CHAR_MIN, CHAR_MAX, FLAGS },
{ "ch", "set the height crop area expression", OFFSET(ch), AV_OPT_TYPE_STRING, { .str = "ih" }, CHAR_MIN, CHAR_MAX, FLAGS },
@@ -301,6 +306,21 @@ static int config_output(AVFilterLink *outlink)
param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->denoise_conf;
}
+ if (vpp->mctf >= 0) {
+#ifdef QSV_HAVE_MCTF
+ memset(&vpp->mctf_conf, 0, sizeof(mfxExtVppMctf));
+ vpp->mctf_conf.Header.BufferId = MFX_EXTBUFF_VPP_MCTF;
+ vpp->mctf_conf.Header.BufferSz = sizeof(mfxExtVppMctf);
+ vpp->mctf_conf.FilterStrength = vpp->mctf;
+
+ param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->mctf_conf;
+#else
+ av_log(ctx, AV_LOG_WARNING, "The QSV VPP MCTF option is "
+ "not supported with this MSDK version.\n");
+ vpp->mctf = -1;
+#endif
+ }
+
if (vpp->detail) {
memset(&vpp->detail_conf, 0, sizeof(mfxExtVPPDetail));
vpp->detail_conf.Header.BufferId = MFX_EXTBUFF_VPP_DETAIL;
@@ -322,7 +342,7 @@ static int config_output(AVFilterLink *outlink)
param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->procamp_conf;
}
- if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
+ if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise || vpp->mctf >= 0 ||
vpp->detail || vpp->procamp || inlink->w != outlink->w || inlink->h != outlink->h)
return ff_qsvvpp_create(ctx, &vpp->qsv, ¶m);
else {
--
2.17.1
More information about the ffmpeg-devel
mailing list