From patchwork Fri Mar 15 16:34:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 12316 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 BCEFB448666 for ; Fri, 15 Mar 2019 10:35:00 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9CF8968A551; Fri, 15 Mar 2019 10:35:00 +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 46598689D10 for ; Fri, 15 Mar 2019 10:34:53 +0200 (EET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Mar 2019 01:34:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,481,1544515200"; d="scan'208";a="140975211" Received: from media_lj_kbl.sh.intel.com ([10.239.13.124]) by FMSMGA003.fm.intel.com with ESMTP; 15 Mar 2019 01:34:44 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Sat, 16 Mar 2019 00:34:42 +0800 Message-Id: <20190315163442.28230-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/2] lavf/vf_vpp_qsv: add transpose support for QSV VPP 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 transpose support for qsv_vpp: - rotation: [0, 3] support clockwise rotation of 0, 90, 180, 270; - mirror: [0, 1] support horizontal mirroring; ffmpeg -hwaccel qsv -v verbose -c:v h264_qsv -i input.h264 -vf 'format=qsv,vpp_qsv=rotation=1' -c:v h264_qsv output.h264 ffmpeg -hwaccel qsv -v verbose -c:v h264_qsv -i input.h264 -vf 'format=qsv,vpp_qsv=mirror=1' -c:v h264_qsv output.h264 ffmpeg -hwaccel qsv -v verbose -c:v h264_qsv -i input.h264 -vf 'format=qsv,vpp_qsv=rotation=2,vpp_qsv=mirror=1' -c:v h264_qsv output.h264 Signed-off-by: Linjie Fu --- libavfilter/vf_vpp_qsv.c | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 41a9f38962..edbe944321 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -41,7 +41,9 @@ #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM) /* number of video enhancement filters */ -#define ENH_FILTERS_COUNT (5) +#define ENH_FILTERS_COUNT (7) +#define QSV_HAVE_ROTATION QSV_VERSION_ATLEAST(1, 17) +#define QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19) typedef struct VPPContext{ const AVClass *class; @@ -54,6 +56,8 @@ typedef struct VPPContext{ mfxExtVPPDenoise denoise_conf; mfxExtVPPDetail detail_conf; mfxExtVPPProcAmp procamp_conf; + mfxExtVPPRotation rotation_conf; + mfxExtVPPMirroring mirroring_conf; int out_width; int out_height; @@ -70,6 +74,9 @@ typedef struct VPPContext{ int crop_x; int crop_y; + int rotation; /* rotation mode : 0=0, 1=90, 2=180, 3=270 */ + int mirror; /* mirror mode : 0=off, 1=HORIZONTAL */ + /* param for the procamp */ int procamp; /* enable procamp */ float hue; @@ -95,6 +102,9 @@ static const AVOption options[] = { { "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}, + { "rotation", "clockwise rotation: 90 * [0, 3]", OFFSET(rotation), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 3, .flags = FLAGS}, + { "mirror", "horizontal mirror [0, 1]", OFFSET(mirror), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .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 }, { "cx", "set the x crop area expression", OFFSET(cx), AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, CHAR_MIN, CHAR_MAX, FLAGS }, @@ -322,8 +332,39 @@ static int config_output(AVFilterLink *outlink) param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->procamp_conf; } + if (vpp->rotation) { +#ifdef QSV_HAVE_ROTATION + memset(&vpp->rotation_conf, 0, sizeof(mfxExtVPPRotation)); + vpp->rotation_conf.Header.BufferId = MFX_EXTBUFF_VPP_ROTATION; + vpp->rotation_conf.Header.BufferSz = sizeof(mfxExtVPPRotation); + vpp->rotation_conf.Angle = 90 * vpp->rotation; + + param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->rotation_conf; +#else + av_log(ctx, AV_LOG_WARNING, "The QSV VPP rotation option is " + "not supported with this MSDK version.\n"); + vpp->rotation = 0; +#endif + } + + if (vpp->mirror) { +#ifdef QSV_HAVE_MIRRORING + memset(&vpp->mirroring_conf, 0, sizeof(mfxExtVPPMirroring)); + vpp->mirroring_conf.Header.BufferId = MFX_EXTBUFF_VPP_MIRRORING; + vpp->mirroring_conf.Header.BufferSz = sizeof(mfxExtVPPMirroring); + vpp->mirroring_conf.Type = vpp->mirror; + + param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->mirroring_conf; +#else + av_log(ctx, AV_LOG_WARNING, "The QSV VPP mirror option is " + "not supported with this MSDK version.\n"); + vpp->mirror = 0; +#endif + } + if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise || - vpp->detail || vpp->procamp || inlink->w != outlink->w || inlink->h != outlink->h) + vpp->rotation || vpp->mirror || vpp->detail || vpp->procamp || + inlink->w != outlink->w || inlink->h != outlink->h) return ff_qsvvpp_create(ctx, &vpp->qsv, ¶m); else { av_log(ctx, AV_LOG_VERBOSE, "qsv vpp pass through mode.\n");