[{"id":37912,"web_url":"https://patchwork.libcamera.org/comment/37912/","msgid":"<176917793023.302817.16647165526141982894@localhost>","date":"2026-01-23T14:18:50","subject":"Re: [PATCH v6 11/16] ipa: mali-c55: Reduce AWB calculations to float\n\tprecision","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Quoting Kieran Bingham (2026-01-21 18:37:30)\n> The AWB calculations are determined using double precision, and then\n> will be soon stored in a quantized float.\n> \n> Use float types for the intermediate types after the sums have been\n> converted to an average to remove static cast assignments.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> ---\n> v5:\n>  - New in v5\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/mali-c55/algorithms/awb.cpp | 12 ++++++------\n>  1 file changed, 6 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/ipa/mali-c55/algorithms/awb.cpp b/src/ipa/mali-c55/algorithms/awb.cpp\n> index 964e810882a9..b179dd7f0c1c 100644\n> --- a/src/ipa/mali-c55/algorithms/awb.cpp\n> +++ b/src/ipa/mali-c55/algorithms/awb.cpp\n> @@ -159,7 +159,7 @@ void Awb::process(IPAContext &context, const uint32_t frame,\n>          * Sometimes the first frame's statistics have no valid pixels, in which\n>          * case we'll just assume a grey world until they say otherwise.\n>          */\n> -       double rgAvg, bgAvg;\n> +       float rgAvg, bgAvg;\n>         if (!counted_zones) {\n>                 rgAvg = 1.0;\n>                 bgAvg = 1.0;\n> @@ -174,15 +174,15 @@ void Awb::process(IPAContext &context, const uint32_t frame,\n>          * figure by the gains that were applied when the statistics for this\n>          * frame were generated.\n>          */\n> -       double rRatio = rgAvg / frameContext.awb.rGain;\n> -       double bRatio = bgAvg / frameContext.awb.bGain;\n> +       float rRatio = rgAvg / frameContext.awb.rGain;\n> +       float bRatio = bgAvg / frameContext.awb.bGain;\n>  \n>         /*\n>          * And then we can simply invert the ratio to find the gain we should\n>          * apply.\n>          */\n> -       double rGain = 1 / rRatio;\n> -       double bGain = 1 / bRatio;\n> +       float rGain = 1 / rRatio;\n> +       float bGain = 1 / bRatio;\n>  \n>         /*\n>          * Running at full speed, this algorithm results in oscillations in the\n> @@ -190,7 +190,7 @@ void Awb::process(IPAContext &context, const uint32_t frame,\n>          * changes in gain, unless we're in the startup phase in which case we\n>          * want to fix the miscolouring as quickly as possible.\n>          */\n> -       double speed = frame < kNumStartupFrames ? 1.0 : 0.2;\n> +       float speed = frame < kNumStartupFrames ? 1.0 : 0.2;\n>         rGain = speed * rGain + context.activeState.awb.rGain * (1.0 - speed);\n>         bGain = speed * bGain + context.activeState.awb.bGain * (1.0 - speed);\n\nPrecision wise this should all be fine. So\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nCheers,\nStefan\n\n>  \n> -- \n> 2.52.0\n>","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 C71B7C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Jan 2026 14:18:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B325661FCB;\n\tFri, 23 Jan 2026 15:18:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2AA0B61FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Jan 2026 15:18:53 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:1d92:9f27:5dd1:dc89])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id BE2FA103D; \n\tFri, 23 Jan 2026 15:18:19 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"L2bhDhxk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769177899;\n\tbh=bLs8O183dATIhEDwnSDBOYAGRGVfC1eTXoN1gTfce74=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=L2bhDhxkyH3oykFdENrbTytSPdHoaQd5gFvrfodMPlFlj1f/CwAVR/8RnvgBt2STb\n\twA3DVN9VYhrNx7UPOAi5PFPBpfY+ZIoA5SvccLkSBVzM9zKJSNI5MziZgIA1in3FF/\n\tClMjq8K3qwmn6+ajSxSnHAWNbfRhLybhOMgUp1NY=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260121173737.376113-12-kieran.bingham@ideasonboard.com>","References":"<20260121173737.376113-1-kieran.bingham@ideasonboard.com>\n\t<20260121173737.376113-12-kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v6 11/16] ipa: mali-c55: Reduce AWB calculations to float\n\tprecision","From":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Fri, 23 Jan 2026 15:18:50 +0100","Message-ID":"<176917793023.302817.16647165526141982894@localhost>","User-Agent":"alot/0.12.dev8+g2c003385c862.d20250602","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","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/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]