From patchwork Thu Mar 2 12:57:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 18330 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CE8F3BF415 for ; Thu, 2 Mar 2023 12:57:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 479186267E; Thu, 2 Mar 2023 13:57:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677761856; bh=CsVRUrLtM+DPkqcg8JYVfC1YAZhrx6cZi+mu9APT53A=; h=To:Date:List-Id:List-Post:From:List-Subscribe:List-Unsubscribe: List-Archive:Reply-To:List-Help:Subject:From; b=ilbqyxN/8YtFnPGcTIuulOUROy/QgiM8/dohbtcc8e4bohCbd9kjEHp+wvFkne2Hc d+6JQhtNKrcwddxI/0tI6FeiePuZeYiOOy/PUmL6XRWm/uHDMhN4Vrq9DBYmqKJa9G OgCbi153w0zw7vgtVY5bWQrUpQzHTf4GWbzUoKzMd+tFBvwnPHnvacrdEmdGDMHDjg jYx6r0ZId6yYkH++qa935bIXsI4jQlWvo3pr3wddtgCPXO7/4CHhzGQDEhRMTb78b0 QLzr+MNE9Lls4NEyH6r0nvQ2UjtkJBAm4t/efG4qWmwzxtAFqmbBxqDC+3xT58XKJA c6I7VXBYU0Xhg== To: libcamera-devel@lists.libcamera.org Date: Thu, 2 Mar 2023 12:57:31 +0000 MIME-Version: 1.0 Message-ID: List-Id: List-Post: X-Patchwork-Original-From: David Plowman via libcamera-devel From: David Plowman Precedence: list X-Mailman-Version: 2.1.29 X-BeenThere: libcamera-devel@lists.libcamera.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: David Plowman List-Help: Subject: [libcamera-devel] [PATCH] ipa: raspberrypi: agc: Fix overflow in Y value calculation Content-Disposition: inline Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The maxVal variable in the computeInitialY function needs to be a uint64_t, otherwise the subsequent multiplications in the function can overflow on relatively high resolution images (when the counts in the regions go over 16 bits). Signed-off-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index ea0c82b5..4ea0dd41 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -584,7 +584,7 @@ void Agc::fetchAwbStatus(Metadata *imageMetadata) static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb, double weights[], double gain) { - constexpr unsigned int maxVal = 1 << Statistics::NormalisationFactorPow2; + constexpr uint64_t maxVal = 1 << Statistics::NormalisationFactorPow2; /* * Note how the calculation below means that equal weights give you * "average" metering (i.e. all pixels equally important).