{"id":18330,"url":"https://patchwork.libcamera.org/api/1.1/patches/18330/?format=json","web_url":"https://patchwork.libcamera.org/patch/18330/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<mailman.54.1677761855.25031.libcamera-devel@lists.libcamera.org>","date":"2023-03-02T12:57:31","name":"[libcamera-devel] ipa: raspberrypi: agc: Fix overflow in Y value calculation","commit_ref":"85541db7bbb5caba1ba0ed5fe85cf5855d024e0b","pull_url":null,"state":"accepted","archived":false,"hash":"569072ff574d799fbe986b96d21ba80403ba88c0","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18330/mbox/","series":[{"id":3783,"url":"https://patchwork.libcamera.org/api/1.1/series/3783/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3783","date":"2023-03-02T12:57:31","name":"[libcamera-devel] ipa: raspberrypi: agc: Fix overflow in Y value calculation","version":1,"mbox":"https://patchwork.libcamera.org/series/3783/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18330/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18330/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CE8F3BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Mar 2023 12:57:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 479186267E;\n\tThu,  2 Mar 2023 13:57:36 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677761856;\n\tbh=CsVRUrLtM+DPkqcg8JYVfC1YAZhrx6cZi+mu9APT53A=;\n\th=To:Date:List-Id:List-Post:From:List-Subscribe:List-Unsubscribe:\n\tList-Archive:Reply-To:List-Help:Subject:From;\n\tb=ilbqyxN/8YtFnPGcTIuulOUROy/QgiM8/dohbtcc8e4bohCbd9kjEHp+wvFkne2Hc\n\td+6JQhtNKrcwddxI/0tI6FeiePuZeYiOOy/PUmL6XRWm/uHDMhN4Vrq9DBYmqKJa9G\n\tOgCbi153w0zw7vgtVY5bWQrUpQzHTf4GWbzUoKzMd+tFBvwnPHnvacrdEmdGDMHDjg\n\tjYx6r0ZId6yYkH++qa935bIXsI4jQlWvo3pr3wddtgCPXO7/4CHhzGQDEhRMTb78b0\n\tQLzr+MNE9Lls4NEyH6r0nvQ2UjtkJBAm4t/efG4qWmwzxtAFqmbBxqDC+3xT58XKJA\n\tc6I7VXBYU0Xhg==","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  2 Mar 2023 12:57:31 +0000","MIME-Version":"1.0","Message-ID":"<mailman.54.1677761855.25031.libcamera-devel@lists.libcamera.org>","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Precedence":"list","X-Mailman-Version":"2.1.29","X-BeenThere":"libcamera-devel@lists.libcamera.org","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","Subject":"[libcamera-devel] [PATCH] ipa: raspberrypi: agc: Fix overflow in Y\n\tvalue calculation","Content-Type":"message/rfc822","Content-Disposition":"inline","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The maxVal variable in the computeInitialY function needs to be a\nuint64_t, otherwise the subsequent multiplications in the function\ncan overflow on relatively high resolution images (when the counts in\nthe regions go over 16 bits).\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)","diff":"diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex ea0c82b5..4ea0dd41 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -584,7 +584,7 @@ void Agc::fetchAwbStatus(Metadata *imageMetadata)\n static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,\n \t\t\t      double weights[], double gain)\n {\n-\tconstexpr unsigned int maxVal = 1 << Statistics::NormalisationFactorPow2;\n+\tconstexpr uint64_t maxVal = 1 << Statistics::NormalisationFactorPow2;\n \t/*\n \t * Note how the calculation below means that equal weights give you\n \t * \"average\" metering (i.e. all pixels equally important).\n","prefixes":["libcamera-devel"]}