From patchwork Thu Aug 5 08:18:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29288 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp190629ioh; Thu, 5 Aug 2021 01:22:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWPsOpLBP8IYkiVP9603BFINBC4vKycXL+7X79HDhgQhVlScN6qUn+d41EYZiltPBht3xE X-Received: by 2002:a05:6402:228f:: with SMTP id cw15mr5205524edb.150.1628151738801; Thu, 05 Aug 2021 01:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628151738; cv=none; d=google.com; s=arc-20160816; b=jfhIlbyJDwL4VWNFQy27f0M9lBrQBv6mCktcx4llN5y07/hDaGFP787/LG+yqgkle8 zE1YpyZFaCiL37r10Ci8GBRBJJEV+kq3irE2KeuA58cdTjHlSrmazlVrmefHgvsl9lMK FE/pB0nwouTC2y9cSB/dj7HdlJTCwj4fC0NZ+gvMOo8jRKlRJnywdm2NnA8ZJpR3k9L2 S7lPIzVZY8pILLSzojYqid8ypd2YLcWWdeJfDUgopn6hff/u+3YHgwxeAUg5bfnuFCaD sDJnIeszbX0HKgNwWYPvkmIWLEZ/IF6KFw5vIKG3IXxDoDrkiPg0RJWIS+RnFNFOoiBy wnpQ== 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=G1dRpSCnefyILlq1WmJWpnYaMILSpm/Uc5Kbi8Q+Zbk=; b=HBAGeDCTOQiZRhoVK9A1x2IWD/7gwVegar3K1HedyCaTDPdIzfmzbY544HDieTE1d7 Tqv2DjNBvb9Dip9NpjOI/SkmycpTXl1O5QAVlca3Ys87AmNT/r3vakhF7eYZHzzQRCVG xgVKyrrVH8Zn5kBjkNz4e4QX02qmOe39C1KjU+y2L/l3+GddxENb8FWqahT68gghFqlQ MKl5QggWPLwvwJpZovvG3J7JQY+hA6ud+IrF8fTdsBowlHn7XV0gvoINoJa61E+lL9om 7ddm7rigbUG60ZG3xO0vPrdHUx7L/iIMuvmSq3Ni+iXST6UFyLTlXXFwY0jwGH58X6zc oHGw== 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 nb37si5233306ejc.415.2021.08.05.01.22.18; Thu, 05 Aug 2021 01:22:18 -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 3683968A21C; Thu, 5 Aug 2021 11:21:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FB1668A380 for ; Thu, 5 Aug 2021 11:21:19 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10066"; a="236062019" X-IronPort-AV: E=Sophos;i="5.84,296,1620716400"; d="scan'208";a="236062019" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2021 01:19:43 -0700 X-IronPort-AV: E=Sophos;i="5.84,296,1620716400"; d="scan'208";a="522442380" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2021 01:19:42 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 16:18:55 +0800 Message-Id: <20210805081910.9386-6-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210805081910.9386-1-haihao.xiang@intel.com> References: <20210805081910.9386-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v5 05/20] lavfi/vpp_qsv: handle NULL pointer when evaluating an expression 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: qcu8O+mWLl79 This is in preparation for re-using VPPContext but with a different option array for scale_qsv filter --- libavfilter/vf_vpp_qsv.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 5f0502089c..5d3c314ae8 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -169,14 +169,19 @@ enum var_name { static int eval_expr(AVFilterContext *ctx) { #define PASS_EXPR(e, s) {\ - ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \ - if (ret < 0) {\ - av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s);\ - goto release;\ + if (s) {\ + ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \ + if (ret < 0) { \ + av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s); \ + goto release; \ + } \ }\ } -#define CALC_EXPR(e, v, i) {\ - i = v = av_expr_eval(e, var_values, NULL); \ +#define CALC_EXPR(e, v, i, d) {\ + if (e)\ + i = v = av_expr_eval(e, var_values, NULL); \ + else\ + i = v = d;\ } VPPContext *vpp = ctx->priv; double var_values[VAR_VARS_NB] = { NAN }; @@ -206,30 +211,29 @@ static int eval_expr(AVFilterContext *ctx) 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); + CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w, var_values[VAR_IW]); + CALC_EXPR(ch_expr, var_values[CH], vpp->crop_h, var_values[VAR_IH]); /* calc again in case cw is relative to ch */ - CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w); + CALC_EXPR(cw_expr, var_values[CW], vpp->crop_w, var_values[VAR_IW]); CALC_EXPR(w_expr, var_values[VAR_OUT_W] = var_values[VAR_OW] = var_values[VAR_W], - vpp->out_width); + vpp->out_width, var_values[CW]); CALC_EXPR(h_expr, var_values[VAR_OUT_H] = var_values[VAR_OH] = var_values[VAR_H], - vpp->out_height); + vpp->out_height, var_values[CH]); /* 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], - vpp->out_width); + vpp->out_width, var_values[CW]); - - CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x); - CALC_EXPR(cy_expr, var_values[CY], vpp->crop_y); + CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x, (var_values[VAR_IW] - var_values[VAR_OW]) / 2); + CALC_EXPR(cy_expr, var_values[CY], vpp->crop_y, (var_values[VAR_IH] - var_values[VAR_OH]) / 2); /* calc again in case cx is relative to cy */ - CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x); + CALC_EXPR(cx_expr, var_values[CX], vpp->crop_x, (var_values[VAR_IW] - var_values[VAR_OW]) / 2); if ((vpp->crop_w != var_values[VAR_IW]) || (vpp->crop_h != var_values[VAR_IH])) vpp->use_crop = 1;