From patchwork Fri Apr 29 01:54:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 35496 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp35087pzb; Thu, 28 Apr 2022 18:55:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/8tG7UcRnFDrbkmbpfvlOCS9K+d7pRogiwyxvYN8ASZyQ3nag3Uic/XUytz5O1n/0WCFJ X-Received: by 2002:a05:6402:524e:b0:423:e919:8eb4 with SMTP id t14-20020a056402524e00b00423e9198eb4mr39230093edd.153.1651197311190; Thu, 28 Apr 2022 18:55:11 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h2-20020a50cdc2000000b00425f2e8a5b2si4962621edj.247.2022.04.28.18.55.10; Thu, 28 Apr 2022 18:55:11 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=Vn8OnGwr; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1870A68B361; Fri, 29 Apr 2022 04:55:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2058.outbound.protection.outlook.com [40.92.90.58]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C210768AF4F for ; Fri, 29 Apr 2022 04:54:55 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MAXJi3xvHAo9YBUs+0UAnu7PrMW6RTMTinLUnWjrZxdtvQyfL0UMeJgzlYY7kYULnYGMpIZt/SSpXBzTuplAXvNQSeiQZO3WOmeoDuzz8Qw20Y/j68FlJyJvrTg/difOPfuHWZZmrssYgjvqdK0BC9ZRnI27htxNNM9PwCUioC6llBHxO/A5h+AC4sZss+QlvefjprpPFy1i4UdLj6tOfs/ELe2XzWModimtnvOkdVpJMur8zBWpWn+UOkTI1ET6iOvLGVpxyTGSQmPXr0HV1Z5f+1S4Th3fInOML7x92c2wtQ1Bnq3OlP30yzSpMBGkNmOaM5ltKnCpDbr7/l44Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v9D8g7XqFTRWtmIp1E36OnjrmQ9ItR1nsmwra3HfiFo=; b=etdbhKOLxHXJkjr3RSnW15DbzM323nR5uaTtNY2PZmLn4Hk9bO416yHygQS+xX/tqvqGGJGuoj3oAnR3qKtrYeX9c3Uc3My7pL6EMsjaRVPv1x6VGahn+qkGMWrLJq5bbXK9NAKnr4SRtWar2pAcFb4LLH8xEwS8nQdxHALw5SvOxdt29xKDxIoiYGphA9i+krqabbKjvER2WcUJY7Ol2h0J+olSsDDFYMeT1AQdmg9Yn8+UTO+sjgwiT2E08YCmpNcLU5oNELnX02xb2tE3iCULiuv6RQ11AL0ENqTxI15IyDoTWDCbcS01bgvIHECOArZo2LDchrHO3HXYA9iXyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v9D8g7XqFTRWtmIp1E36OnjrmQ9ItR1nsmwra3HfiFo=; b=Vn8OnGwrCYD/JrsUd1HtmRftzfqIOQDRxwntD/70XIxhts/quRLM0sziEZGaWHVMYCodKL12HgcdXypz4Ep//tLBwqzMCnMwMSrSDzmMj2lhlYUKUooKKLA63zntWvRVuVvsJo7Hw+ouXdjb2BTYvXwjHVOcxrfk7ThQePs3mNW3E+mcKkTeDKp3mg926H9XcWLPArLPC/Z3IB9H8salSw+6tDXoFZY9gEJSwksBamxV8Rve8mllpJmdDz3rhpn7iqMA/RAAAeYzeL0xUM8b8uZQ6w9TqcLYO78q7H0NViC4MXAaoxntA8EBqNBGJGTMs5ZHZzZTCt4zRm9+qPJ2RA== Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) by AS8PR01MB8715.eurprd01.prod.exchangelabs.com (2603:10a6:20b:44e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.12; Fri, 29 Apr 2022 01:54:49 +0000 Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431]) by AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431%6]) with mapi id 15.20.5186.021; Fri, 29 Apr 2022 01:54:49 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Apr 2022 03:54:36 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220429015436.666932-1-andreas.rheinhardt@outlook.com> References: <20220429015436.666932-1-andreas.rheinhardt@outlook.com> X-TMN: [8c7zI0UmffWKEmEmg3ijMRTCIYS0XI2D] X-ClientProxiedBy: ZR0P278CA0037.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::6) To AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) X-Microsoft-Original-Message-ID: <20220429015436.666932-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cbf5e947-deb9-489e-2b01-08da29833e47 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNVjun0oR/i13Mcum9OXxCMZ0hjg3H95Zn/ZO5eIsIrnHBLjvKaeUMTmdQ+9CFIu6+eh15//TdipuCSFQKsMoJivjiqhBFynMlehVvFm3phe+gcNcVacT70G/ixC2k3I6plBoGJcSOhR7FXKEsx3XrZSQUmxPb0ckpcMQXU86xeCsxH64G+diOMZjn7e9juq+Ot9QzaRwILKs4ftMgrnWzyC7rNjZITux3jjsN1w5DOI1yR7LayCBCp38UDx34ZcxcXh2q9pJuyFBL0AUqHDIgEfYqvWtY9JUqfW71FaiQeHYkEASCr2FL5VZ+2FRwlAfP1hwe1MxpciZLGpxiTwYYutGKGgyQToysDmKkpDcb0nHeOVASLIAjJEBiIOXA9kNDb5N23ZxE77UoW533P723V0q6TNL61/mLAowrOmjK698eOVYbYIDNqAzKzO+rnj38+sl/BEUaD+AovAvqq9FvVbxXc0sAvG4/sHBSY+XodWbCU4ZJBDb3JE/Ek04JPLToFtyUNV9I775fNYzBxBcUUCurFfUEAimFsP5nCEnKjXhRLsXmolNVCjLv920ursNx4on3xGJcjLAXD2hDR2IBJLcpFtNO6f4incdyedx5xxKRD1tZnusIn5IyTAGci1Yb1HAtGABmYxkUGwJVBbvhx06XGtCntZexOSFYFZYUN9blM0NRo6GdzIUlAHd6h+9mdh/2SEeb8QBj9i4FjD6a4lcY36jYMUyt4= X-MS-TrafficTypeDiagnostic: AS8PR01MB8715:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jsiYRNub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X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: cbf5e947-deb9-489e-2b01-08da29833e47 X-MS-Exchange-CrossTenant-AuthSource: AS8PR01MB7944.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2022 01:54:49.1620 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR01MB8715 Subject: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_colormap: Avoid allocation of small array 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: dW0KFiijNMLW The number of elements is always two or three. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_colormap.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libavfilter/vf_colormap.c b/libavfilter/vf_colormap.c index d5c5bec39c..106333ced8 100644 --- a/libavfilter/vf_colormap.c +++ b/libavfilter/vf_colormap.c @@ -24,6 +24,7 @@ */ #include "libavutil/attributes.h" +#include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/opt.h" #include "avfilter.h" @@ -134,20 +135,15 @@ static void gauss_solve_triangular(const double *A, const int *p, double *b, int static int gauss_solve(double *A, double *b, int n) { - int *p = av_calloc(n, sizeof(*p)); + int p[3] = { 0 }; - if (!p) - return 1; + av_assert2(n <= FF_ARRAY_ELEMS(p)); - if (!gauss_make_triangular(A, p, n)) { - av_freep(&p); + if (!gauss_make_triangular(A, p, n)) return 1; - } gauss_solve_triangular(A, p, b, n); - av_freep(&p); - return 0; }