From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B00E543D8A for ; Mon, 9 Jan 2023 07:12:58 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A171068BBF9; Mon, 9 Jan 2023 09:12:40 +0200 (EET) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3B5BC68B9F1 for ; Mon, 9 Jan 2023 09:12:33 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673248358; x=1704784358; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=15uv8NhLMm3Kx8Ynpn5SDjMlcnzFt1yo/MxRtvP6yyM=; b=mzJmqHkslOxSg/hGGd506vukjSWhpzYJOGnfEqwAUahKb9kXx+mzhG3d wx61xKnzUMI17F1JtaVHZjlUGdqU3MEIOOGCuTw3PGo0mtm2R7O/8RV68 d5pZGaFsGli35Aw6s/5Uu8IN24wusBJxm7att3HqOEI6w3Ze4PoRxKiTT SWv51Qt9/av1trPP3DIhDUOqTR/VrRtIi59cBK5qmLIB+t4mhHmgPeqGS JdKwzbkcwQgEmV+Ss6bm95g+RaF05DsjHeGE6h6IQivBk6NlhKgg80QQn 8HlcZUCaT/ftk9VB8IjY9xhCg8QvOaACWmOMMHDGidK36hwrrvhlpDtMV g==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="385110841" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="385110841" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 23:12:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="745262796" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="745262796" Received: from xhh-tgl64.sh.intel.com ([10.238.2.19]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 23:12:27 -0800 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Jan 2023 15:12:05 +0800 Message-Id: <20230109071210.1829699-3-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109071210.1829699-1-haihao.xiang@intel.com> References: <20230109071210.1829699-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] lavfi/vf_vpp_qsv: allow special values for the output video dimensions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Haihao Xiang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Haihao Xiang Special values are: 0 = original width/height -1 = keep original aspect This is in preparation for reusing the code for other QSV filters. Signed-off-by: Haihao Xiang --- libavfilter/vf_vpp_qsv.c | 47 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 3a0a395732..cf11cd7fdc 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -59,6 +59,11 @@ typedef struct VPPContext{ mfxExtVPPMirroring mirroring_conf; mfxExtVPPScaling scale_conf; + /** + * New dimensions. Special values are: + * 0 = original width/height + * -1 = keep original aspect + */ int out_width; int out_height; /** @@ -127,10 +132,10 @@ static const AVOption options[] = { { "cx", "set the x crop area expression", OFFSET(cx), AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, 0, 0, FLAGS }, { "cy", "set the y crop area expression", OFFSET(cy), AV_OPT_TYPE_STRING, { .str = "(in_h-out_h)/2" }, 0, 0, FLAGS }, - { "w", "Output video width", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, - { "width", "Output video width", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, - { "h", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, - { "height", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, + { "w", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, + { "width", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, + { "h", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, + { "height", "Output video height(0=input video height, -1=keep input video aspect)", 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 }, { "scale_mode", "scale & format conversion 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" }, @@ -276,6 +281,7 @@ static int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; VPPContext *vpp = ctx->priv; int ret; + int64_t ow, oh; if (vpp->framerate.den == 0 || vpp->framerate.num == 0) vpp->framerate = inlink->frame_rate; @@ -289,11 +295,38 @@ static int config_input(AVFilterLink *inlink) return ret; } - if (vpp->out_height == 0 || vpp->out_width == 0) { - vpp->out_width = inlink->w; - vpp->out_height = inlink->h; + ow = vpp->out_width; + oh = vpp->out_height; + + /* sanity check params */ + if (ow < -1 || oh < -1) { + av_log(ctx, AV_LOG_ERROR, "Size values less than -1 are not acceptable.\n"); + return AVERROR(EINVAL); } + if (ow == -1 && oh == -1) + vpp->out_width = vpp->out_height = 0; + + if (!(ow = vpp->out_width)) + ow = inlink->w; + + if (!(oh = vpp->out_height)) + oh = inlink->h; + + if (ow == -1) + ow = av_rescale(oh, inlink->w, inlink->h); + + if (oh == -1) + oh = av_rescale(ow, inlink->h, inlink->w); + + if (ow > INT_MAX || oh > INT_MAX || + (oh * inlink->w) > INT_MAX || + (ow * inlink->h) > INT_MAX) + av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n"); + + vpp->out_width = ow; + vpp->out_height = oh; + if (vpp->use_crop) { vpp->crop_x = FFMAX(vpp->crop_x, 0); vpp->crop_y = FFMAX(vpp->crop_y, 0); -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".