From patchwork Thu Jul 29 05:24:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29095 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp5501249ios; Wed, 28 Jul 2021 22:28:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykVm+BUGJhoGLDgzq5DvacIIiOBrG+ISnBBgDKP9f6YNzuPPHPm1A92qMGeGhaEyrNilSK X-Received: by 2002:a17:906:9b1:: with SMTP id q17mr2896471eje.546.1627536509061; Wed, 28 Jul 2021 22:28:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627536509; cv=none; d=google.com; s=arc-20160816; b=o8LsH3lqJSusHwy3K3k0WnOJOvaOi1TOgPZ6WgPo1wmV6JeYuHmMBB348JXfl4LsIt uL0wpNmsKaVWkb+U0W//3Fwl77Fn0q4l0AEtd1DOpxeUX6RAJjnIqrUhQx88ptbkZhVP Ruj4roOYRjUzlyJwvGAmJ5jqDu5z/rBPNYRqkKjDLXoVM7bFYLDLYTmfn4BvWSL93cts Fszx3IAZ4Z5d+qOK4mHy5dObPakGPBaMh4KeIgwilKp/0W6H3ZXFdRiSg0Fec75HuLE/ WEgWJvjat3q2BK6tSMY0pR6WGjlHwDHnQOJ6tNjAEM5X2OIjUC5qRhJVBHkemZfxTZvV PHVA== 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=9oIAj5G0T0pqT4yHqmywP+/50ryEJ5wTBbqFEfO1crM=; b=tHrv75KWPCjBgk/k3LWGxjF4nRiVr8Z6hSKyMgV5JbwAfvElD+VVmpgfNdBBGt/O+k C4YSIzNa320BaUltgSjBBLY3D102ICfnkHxP2RLev5GVXFcKde+QaYOb8fxFVl4jmgzV Hc0UitakUFU7eCjpAFeftFw8Ntei+Y53VJvJHIMBPClkyt28NQmRP3ALLZ+7MuR0/aTg I5gpdmAbAm0f4WTJT+39pffcKaxsIZxiMXiLYM03dBdNlZ3PEMcJraSdDR1lFddqZEhH 2un974iBKKqhYdpsa37aInS7lUc6IvlfGt9Yfrb5TP2C8xPQ83H1Tnb8XMo8xTNrby2h ggEg== 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 dm18si1793356edb.411.2021.07.28.22.28.28; Wed, 28 Jul 2021 22:28:29 -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 D7E5868A56A; Thu, 29 Jul 2021 08:26:24 +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 C40D868A4A3 for ; Thu, 29 Jul 2021 08:26:16 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10059"; a="200023586" X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="200023586" 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:51 -0700 X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="456730082" 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:50 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Jul 2021 13:24:53 +0800 Message-Id: <20210729052509.30992-6-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 05/21] 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: 2vszhV1Pxr5k 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 cc8fe1645e..c0fc0d4154 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -162,14 +162,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 }; @@ -199,30 +204,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;