{"id":26208,"url":"https://patchwork.libcamera.org/api/patches/26208/?format=json","web_url":"https://patchwork.libcamera.org/patch/26208/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20260219-kbingham-quantizers-v8-11-2b6ff68ead26@ideasonboard.com>","date":"2026-02-19T15:05:12","name":"[v8,11/15] ipa: mali-c55: Reduce AWB calculations to float precision","commit_ref":"6b5ecd96ff06d4c30172e2657cafcf69ecf4c13f","pull_url":null,"state":"accepted","archived":false,"hash":"cacb0633412dd6a6af542b70221be2624bf985aa","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26208/mbox/","series":[{"id":5802,"url":"https://patchwork.libcamera.org/api/series/5802/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5802","date":"2026-02-19T15:05:01","name":"libipa: Introduce a Quantized type","version":8,"mbox":"https://patchwork.libcamera.org/series/5802/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26208/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26208/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 599B8C32F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Feb 2026 15:05:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C24FB6227B;\n\tThu, 19 Feb 2026 16:05:22 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE85162254\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Feb 2026 16:05:11 +0100 (CET)","from ping.linuxembedded.co.uk\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9065D259E;\n\tThu, 19 Feb 2026 16:04:18 +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=\"PBzn9lkR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1771513458;\n\tbh=4AD4w6srHMQImIIhm/+qGTzISyhaPIWnXBj7164B2CE=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=PBzn9lkRj0ZZ+iAo8YUGf88AUqrsQXdOTogwWk6ef//I1cuj4omXyZUDCRMeFVXrF\n\tb9++5XpZinvBrcSF0lW+ENU1CHUyNOy8MoUMCJySloRcg7fGVRnPfhWTaIcsTh1X+r\n\t4qESwMxLxEPfvoFam3kDafeENYoHRff9zOJpTu9A=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Date":"Thu, 19 Feb 2026 15:05:12 +0000","Subject":"[PATCH v8 11/15] ipa: mali-c55: Reduce AWB calculations to float\n\tprecision","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"8bit","Message-Id":"<20260219-kbingham-quantizers-v8-11-2b6ff68ead26@ideasonboard.com>","References":"<20260219-kbingham-quantizers-v8-0-2b6ff68ead26@ideasonboard.com>","In-Reply-To":"<20260219-kbingham-quantizers-v8-0-2b6ff68ead26@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>, =?utf-8?q?Barnab?=\n\t=?utf-8?b?w6FzIFDFkWN6ZQ==?= <barnabas.pocze@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>, Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>","X-Mailer":"b4 0.14.3","X-Developer-Signature":"v=1; a=ed25519-sha256; t=1771513507; l=2428;\n\ti=kieran.bingham@ideasonboard.com; s=20260207;\n\th=from:subject:message-id; \n\tbh=4AD4w6srHMQImIIhm/+qGTzISyhaPIWnXBj7164B2CE=;\n\tb=9w1XHVy9K1BytXqjF7UgzwozKqe2XzaZMu8dNBoPjossu6QEgk5IGn+IcAPudvQ02bOZ1JoDi\n\tcBUii5cjVApBOeJxGUBzke/zlZFklssyAZ89iJOmYRjEGKGPfxtYmj7","X-Developer-Key":"i=kieran.bingham@ideasonboard.com; a=ed25519;\n\tpk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY=","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>"},"content":"The AWB calculations are determined using double precision, and then\nwill be soon stored in a quantized float.\n\nUse float types for the intermediate types after the sums have been\nconverted to an average to remove static cast assignments.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\n\nv8:\n - Use 1.0f and 0.2f to prevent double usage\n---\n src/ipa/mali-c55/algorithms/awb.cpp | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)","diff":"diff --git a/src/ipa/mali-c55/algorithms/awb.cpp b/src/ipa/mali-c55/algorithms/awb.cpp\nindex 964e810882a9..fab73294a88f 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 \t * Sometimes the first frame's statistics have no valid pixels, in which\n \t * case we'll just assume a grey world until they say otherwise.\n \t */\n-\tdouble rgAvg, bgAvg;\n+\tfloat rgAvg, bgAvg;\n \tif (!counted_zones) {\n \t\trgAvg = 1.0;\n \t\tbgAvg = 1.0;\n@@ -174,15 +174,15 @@ void Awb::process(IPAContext &context, const uint32_t frame,\n \t * figure by the gains that were applied when the statistics for this\n \t * frame were generated.\n \t */\n-\tdouble rRatio = rgAvg / frameContext.awb.rGain;\n-\tdouble bRatio = bgAvg / frameContext.awb.bGain;\n+\tfloat rRatio = rgAvg / frameContext.awb.rGain;\n+\tfloat bRatio = bgAvg / frameContext.awb.bGain;\n \n \t/*\n \t * And then we can simply invert the ratio to find the gain we should\n \t * apply.\n \t */\n-\tdouble rGain = 1 / rRatio;\n-\tdouble bGain = 1 / bRatio;\n+\tfloat rGain = 1 / rRatio;\n+\tfloat bGain = 1 / bRatio;\n \n \t/*\n \t * 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 \t * changes in gain, unless we're in the startup phase in which case we\n \t * want to fix the miscolouring as quickly as possible.\n \t */\n-\tdouble speed = frame < kNumStartupFrames ? 1.0 : 0.2;\n+\tfloat speed = frame < kNumStartupFrames ? 1.0f : 0.2f;\n \trGain = speed * rGain + context.activeState.awb.rGain * (1.0 - speed);\n \tbGain = speed * bGain + context.activeState.awb.bGain * (1.0 - speed);\n \n","prefixes":["v8","11/15"]}