From patchwork Thu Jul 29 05:24:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29096 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp5501094ios; Wed, 28 Jul 2021 22:28:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0WqqEuRHjd4B1ocySmJiF4yTkYxontVtq3fQTXRwzgkkgfNJ5lptKajDjJNw7+3NB6m4l X-Received: by 2002:a17:906:95cf:: with SMTP id n15mr2882300ejy.531.1627536490316; Wed, 28 Jul 2021 22:28:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627536490; cv=none; d=google.com; s=arc-20160816; b=k8yN3Vl8NMLvyCl9FkZJfQ4DwhSpto0cu3EenZKE6WUBEh8lWw3s/JmJsKsjCmO/Yw gkQl+bpJK09+jx2ku7ITTs1H8ntpkvaHW0luY0nKvyrStn4yrzMW9iT6fbhcYMHQYtTL lrIinlb+nOShq/YMLQs5ucCt+mb5LxxM/nBEygIzcwF0k3GHYxRutk6iRYJ5aVWuUDq7 6K2WdVJhLX3RKaVk6Jy61qHA1J16s9KBZnMRJh8HskDCm6l1y9p5PWQ3SGrZPvcNGkhs lHSpIIoaT4PCnecStkKo2wSNdZY6/gCjl2c4FWoBZOQ7A9DN+JuUavXHe/Q8ElWXhFfa lsCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=0HTyhSD9gXvzFH6aHtAWxSFpehaf3j8LhhMys+98AiE=; b=j7GWY4NLNjKBeUDjrz1JG3BhCcqY1RUG7HSD7qLo1Je5xBRlnpPuTS/o1kh4Vhhy3G ht5pgdmFClLk+YK3Auh13OQ2MBZZ6B2noP5UkrR38Qrx7jzs396nM68B2PNaW+oxPfhU igu+dO47Up9Bi3f19RUqu6Xsvg73uvUwT/qgItQFtUegJBwD8EzrNVe2ixIXsY3UnpXT Qa8EGVKf0mJw3P321TD/q1elqNM3ZWrs3rl5RADRaq1AMy6vbr6aZp02DWrFajMshPYG 2RMhprBGKD6dejsXei3b4evOPfsN8Ly+YZCjnTiMsAigHUx2EVratN0EICn75uUiQg0w 5Itw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ee43si1786084edb.264.2021.07.28.22.28.10; Wed, 28 Jul 2021 22:28:10 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1157668A57B; Thu, 29 Jul 2021 08:26:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CC538689D48 for ; Thu, 29 Jul 2021 08:26:10 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10059"; a="200023585" X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="200023585" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 22:25:50 -0700 X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="456730077" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 22:25:49 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Jul 2021 13:24:52 +0800 Message-Id: <20210729052509.30992-5-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210729052509.30992-1-haihao.xiang@intel.com> References: <20210729052509.30992-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 04/21] lavfi/vpp_qsv: add "a", "dar" and "sar" variables 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: FI/k0UpuuF6I Also fix the coding style for VAR index. This is in preparation for re-using VPPContext for scale_qsv filter --- libavfilter/vf_vpp_qsv.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index fa4288f69f..cc8fe1645e 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -140,18 +140,22 @@ static const char *const var_names[] = { "ch", "cx", "cy", + "a", "dar", + "sar", NULL }; enum var_name { - VAR_iW, VAR_IN_W, - VAR_iH, VAR_IN_H, - VAR_oW, VAR_OUT_W, VAR_W, - VAR_oH, VAR_OUT_H, VAR_H, + VAR_IW, VAR_IN_W, + VAR_IH, VAR_IN_H, + VAR_OW, VAR_OUT_W, VAR_W, + VAR_OH, VAR_OUT_H, VAR_H, CW, CH, CX, CY, + VAR_A, VAR_DAR, + VAR_SAR, VAR_VARS_NB }; @@ -183,12 +187,17 @@ static int eval_expr(AVFilterContext *ctx) PASS_EXPR(cx_expr, vpp->cx); PASS_EXPR(cy_expr, vpp->cy); - var_values[VAR_iW] = + var_values[VAR_IW] = var_values[VAR_IN_W] = ctx->inputs[0]->w; - var_values[VAR_iH] = + var_values[VAR_IH] = var_values[VAR_IN_H] = ctx->inputs[0]->h; + var_values[VAR_A] = (double)var_values[VAR_IN_W] / var_values[VAR_IN_H]; + var_values[VAR_SAR] = ctx->inputs[0]->sample_aspect_ratio.num ? + (double)ctx->inputs[0]->sample_aspect_ratio.num / ctx->inputs[0]->sample_aspect_ratio.den : 1; + var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR]; + /* crop params */ CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w); CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h); @@ -197,15 +206,15 @@ static int eval_expr(AVFilterContext *ctx) CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w); CALC_EXPR(w_expr, - var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W], + var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W], vpp->out_width); CALC_EXPR(h_expr, - var_values[VAR_OUT_H] = var_values[VAR_oH] = var_values[VAR_H], + var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H], vpp->out_height); /* calc again in case ow is relative to oh */ CALC_EXPR(w_expr, - var_values[VAR_OUT_W] = var_values[VAR_oW] = var_values[VAR_W], + var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W], vpp->out_width); @@ -215,7 +224,7 @@ static int eval_expr(AVFilterContext *ctx) /* calc again in case cx is relative to cy */ CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x); - if ((vpp->crop_w != var_values[VAR_iW]) || (vpp->crop_h != var_values[VAR_iH])) + if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != var_values[VAR_IH])) vpp->use_crop = 1; release: