From patchwork Tue Oct 15 20:38:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 21632 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 DE209C32F9 for ; Tue, 15 Oct 2024 20:38:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 80CBD65389; Tue, 15 Oct 2024 22:38:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Khu/PueQ"; 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 39E3360537 for ; Tue, 15 Oct 2024 22:38:30 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:64d4:9f74:8308:300d]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 62243A2F; Tue, 15 Oct 2024 22:36:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729024608; bh=p1riyG/LTntAVP1PqslNRVZai5xYT3WAenywG3UB/3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Khu/PueQV1VHEYFJ5YW/QhplmcLCLFr/zD41Iw6x4H9eoFnDU23it3XiClN0h6B3z /5zrD5bZacG0dibMZ31k/YYxhWE+hadi361EBe+TwyH4SdKUweh5H8kz3d+8yYPep8 fRfX92iL16Mad7mMr0Qt2pu5X3oqwB9R93aNP3G0= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 2/4] ipa: rkisp1: algorithms: awb: Check for correct stats type Date: Tue, 15 Oct 2024 22:38:13 +0200 Message-ID: <20241015203820.574326-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241015203820.574326-1-stefan.klug@ideasonboard.com> References: <20241015203820.574326-1-stefan.klug@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" Sometimes the ISP produces statistics only with a subset of statistic types being valid. It doesn't happen often, but it happens. Check for the RKISP1_CIF_ISP_STAT_AWB bit to prevent using invalid or outdated data. For simpler code structure, the ColourTemperature metadata entry gets written unconditionally and overwritten later if needed. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/awb.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 955a9ff4a897..86bcf20f6527 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -215,6 +215,10 @@ void Awb::process(IPAContext &context, static_cast(frameContext.awb.gains.red), static_cast(frameContext.awb.gains.blue) }); + metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); + + if (!(stats && stats->meas_type & RKISP1_CIF_ISP_STAT_AWB)) + return; if (rgbMode_) { greenMean = awb->awb_mean[0].mean_y_or_g; @@ -270,10 +274,8 @@ void Awb::process(IPAContext &context, * meaningfully calculate gains. Freeze the algorithm in that case. */ if (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold && - blueMean < kMeanMinThreshold) { - metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); + blueMean < kMeanMinThreshold) return; - } activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);