From patchwork Thu Feb 19 15:05:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 26208 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 599B8C32F1 for ; Thu, 19 Feb 2026 15:05:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C24FB6227B; Thu, 19 Feb 2026 16:05:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PBzn9lkR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AE85162254 for ; Thu, 19 Feb 2026 16:05:11 +0100 (CET) Received: from ping.linuxembedded.co.uk (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9065D259E; Thu, 19 Feb 2026 16:04:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1771513458; bh=4AD4w6srHMQImIIhm/+qGTzISyhaPIWnXBj7164B2CE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PBzn9lkRj0ZZ+iAo8YUGf88AUqrsQXdOTogwWk6ef//I1cuj4omXyZUDCRMeFVXrF b9++5XpZinvBrcSF0lW+ENU1CHUyNOy8MoUMCJySloRcg7fGVRnPfhWTaIcsTh1X+r 4qESwMxLxEPfvoFam3kDafeENYoHRff9zOJpTu9A= From: Kieran Bingham Date: Thu, 19 Feb 2026 15:05:12 +0000 Subject: [PATCH v8 11/15] ipa: mali-c55: Reduce AWB calculations to float precision MIME-Version: 1.0 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 , =?utf-8?q?Barnab?= =?utf-8?b?w6FzIFDFkWN6ZQ==?= , Stefan Klug , Laurent Pinchart X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771513507; l=2428; i=kieran.bingham@ideasonboard.com; s=20260207; h=from:subject:message-id; bh=4AD4w6srHMQImIIhm/+qGTzISyhaPIWnXBj7164B2CE=; b=9w1XHVy9K1BytXqjF7UgzwozKqe2XzaZMu8dNBoPjossu6QEgk5IGn+IcAPudvQ02bOZ1JoDi cBUii5cjVApBOeJxGUBzke/zlZFklssyAZ89iJOmYRjEGKGPfxtYmj7 X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=FVXKN7YuwHc6UtbRUeTMAmranfsQomA+vnilfglWdaY= X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The AWB calculations are determined using double precision, and then will be soon stored in a quantized float. Use float types for the intermediate types after the sums have been converted to an average to remove static cast assignments. Reviewed-by: Barnabás Pőcze Reviewed-by: Stefan Klug Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- v8: - Use 1.0f and 0.2f to prevent double usage --- src/ipa/mali-c55/algorithms/awb.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ipa/mali-c55/algorithms/awb.cpp b/src/ipa/mali-c55/algorithms/awb.cpp index 964e810882a9..fab73294a88f 100644 --- a/src/ipa/mali-c55/algorithms/awb.cpp +++ b/src/ipa/mali-c55/algorithms/awb.cpp @@ -159,7 +159,7 @@ void Awb::process(IPAContext &context, const uint32_t frame, * Sometimes the first frame's statistics have no valid pixels, in which * case we'll just assume a grey world until they say otherwise. */ - double rgAvg, bgAvg; + float rgAvg, bgAvg; if (!counted_zones) { rgAvg = 1.0; bgAvg = 1.0; @@ -174,15 +174,15 @@ void Awb::process(IPAContext &context, const uint32_t frame, * figure by the gains that were applied when the statistics for this * frame were generated. */ - double rRatio = rgAvg / frameContext.awb.rGain; - double bRatio = bgAvg / frameContext.awb.bGain; + float rRatio = rgAvg / frameContext.awb.rGain; + float bRatio = bgAvg / frameContext.awb.bGain; /* * And then we can simply invert the ratio to find the gain we should * apply. */ - double rGain = 1 / rRatio; - double bGain = 1 / bRatio; + float rGain = 1 / rRatio; + float bGain = 1 / bRatio; /* * Running at full speed, this algorithm results in oscillations in the @@ -190,7 +190,7 @@ void Awb::process(IPAContext &context, const uint32_t frame, * changes in gain, unless we're in the startup phase in which case we * want to fix the miscolouring as quickly as possible. */ - double speed = frame < kNumStartupFrames ? 1.0 : 0.2; + float speed = frame < kNumStartupFrames ? 1.0f : 0.2f; rGain = speed * rGain + context.activeState.awb.rGain * (1.0 - speed); bGain = speed * bGain + context.activeState.awb.bGain * (1.0 - speed);