From patchwork Mon Jan 14 12:39:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 11739 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D9F2444D19B for ; Mon, 14 Jan 2019 14:39:51 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0838068A8CD; Mon, 14 Jan 2019 14:39:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E693B68A8CC for ; Mon, 14 Jan 2019 14:39:32 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2019 04:39:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,477,1539673200"; d="scan'208";a="291400985" Received: from media_lj_kbl.sh.intel.com ([10.239.160.161]) by orsmga005.jf.intel.com with ESMTP; 14 Jan 2019 04:39:44 -0800 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Mon, 14 Jan 2019 20:39:44 +0800 Message-Id: <20190114123944.12445-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] lavf/qsvvpp: add support for Motion Compensated Temporal Filter X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- 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 {