From patchwork Wed Nov 18 16:46:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: GuyliandeJong X-Patchwork-Id: 29025 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 72E5FC3304 for ; Wed, 18 Nov 2026 16:47:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 225606A8FE; Wed, 18 Nov 2026 17:47:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=proton.me header.i=@proton.me header.b="zdXzrKSo"; dkim-atps=neutral Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 963906A8FE for ; Wed, 18 Nov 2026 17:47:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=2wu4aqv7ozej7bfzjsu6nskhei.protonmail2; t=1795020423; x=1795279623; bh=qB+naVC0UAJMNggIFtM2xDRQP0oEroimoMbk2KUo3+8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=zdXzrKSoM6dlYCtPn0OjlJNCbNY+xAHGT9fhHpglthymcoCXrnCemo+c1jS/M2RxD LOaDYx/Ix8gIRf+4+HENMZ3Ktp/Wt64qqFg+YkQxBRcIK1gIADuh8NjyOBxu8OQoCV QBrgd/Ohsm8hOQ5dcDaQVM0yOfKWonrU0w7lrKHxOi9hPOuwUjah634Vg49cPjI1r9 Kay/bqw/lVRNcR4wi4x37m8Vmm9s+8qWxt4VA3sT01NjplJWbZOvdb6sNL+lFR/KO0 yD624UaAPO4CCGk+5hz+/WopVLKY9mxuSf0BaTrspMPWoLcW04jAWqKRHt04rpQwKF U1mdJy32fK/dg== Date: Wed, 18 Nov 2026 16:46:57 +0000 To: libcamera-devel@lists.libcamera.org From: GuyliandeJong Cc: Daniel Scally , Barnabas Pocze , Afonso Figuinha Subject: [PATCH 4/6] ipa: ipu3: awb: Report statistics without enough zones as invalid Message-ID: <20261118164621.15513-5-guyliandejong@proton.me> In-Reply-To: <20261118164621.15513-1-guyliandejong@proton.me> References: <20261118164621.15513-1-guyliandejong@proton.me> Feedback-ID: 112452169:user:proton X-Pm-Message-ID: e508942b00f7636841479a04fa84edd1af684c78 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" When too few statistics zones are usable, for instance in a very dark frame, calculateRgbMeans() returns a default constructed Ipu3AwbStats with zero RGB means. Ipu3AwbStats::valid() always returns true, so AwbAlgorithm processes these zero means as real data: the estimated colour temperature drops to 0K and the gains are computed from zero means. On an OV9734 this happens for one dark frame at stream start. The reported colour temperature drops from about 3200K to 0K, and the CCM and the gains of the following frames are computed from it. Track whether the statistics hold RGB means, and report them as invalid otherwise, so that AwbAlgorithm skips the frame as the IPU3 AWB did before it was ported to AwbAlgorithm. Fixes: b95dd9d14963 ("ipa: ipu3: awb: Port to the new libipa AwbAlgorithm") Signed-off-by: GuyliandeJong --- src/ipa/ipu3/algorithms/awb.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 84d9f62e..57fd0beb 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -42,7 +42,7 @@ public: * \param rgbMeans A vector of doubles representing the RGB mean values */ Ipu3AwbStats(const RGB &rgbMeans) - : rgbMeans_(rgbMeans) + : rgbMeans_(rgbMeans), valid_(true) { rg_ = rgbMeans_.r() / rgbMeans_.g(); bg_ = rgbMeans_.b() / rgbMeans_.g(); @@ -54,8 +54,9 @@ public: private: RGB rgbMeans_; - double rg_; - double bg_; + double rg_ = 0.0; + double bg_ = 0.0; + bool valid_ = false; }; double Ipu3AwbStats::computeColourError(const RGB &gains) const @@ -78,10 +79,11 @@ bool Ipu3AwbStats::valid() const * whether there's enough information in the statistics for a frame to * be useful. The IPU3 implementation already drops any statistics zone * with an average value below a threshold though so we don't need to do - * it in libipa. Report all stats as valid. + * it in libipa. The statistics are only invalid when too few zones + * are left to compute RGB means. */ - return true; + return valid_; } RGB Ipu3AwbStats::rgbMeans() const