From patchwork Wed Jan 21 17:37:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 25918 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 84A51C32E7 for ; Wed, 21 Jan 2026 17:38:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E2A5661FF5; Wed, 21 Jan 2026 18:37:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OMD/CzJy"; 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 CAF9B61FCA for ; Wed, 21 Jan 2026 18:37:44 +0100 (CET) Received: from Monstersaurus.hippo-penny.ts.net (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D0DA821D0; Wed, 21 Jan 2026 18:37:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1769017032; bh=jUXrNpD5O+E67bCsFbHO1Y9uWRmV5hk6P4zDQcH5uHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OMD/CzJyEQjcGss9KpFk/EXJOpAHsP9lE9UztzQBOgHPD3RufFqnC6Iyxt3qZr8Uk bufkxcdmrt5ZMWOto9OPXF9ZvR5PhpIf6ZO8B7+7BKa1vvnM5GcedN6P3Vh0Qvfdj3 Fzm80h5Ng3hvqzGWGI4NmQwj56nD49idz5ApLzlI= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH v6 11/16] ipa: mali-c55: Reduce AWB calculations to float precision Date: Wed, 21 Jan 2026 17:37:30 +0000 Message-ID: <20260121173737.376113-12-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121173737.376113-1-kieran.bingham@ideasonboard.com> References: <20260121173737.376113-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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. Signed-off-by: Kieran Bingham --- v5: - New in v5 Signed-off-by: Kieran Bingham --- 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..b179dd7f0c1c 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.0 : 0.2; rGain = speed * rGain + context.activeState.awb.rGain * (1.0 - speed); bGain = speed * bGain + context.activeState.awb.bGain * (1.0 - speed);