From patchwork Wed Mar 19 16:11:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22994 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 12DACC32FE for ; Wed, 19 Mar 2025 16:12:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C454368976; Wed, 19 Mar 2025 17:12:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VuLcKH+w"; 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 42FFA68974 for ; Wed, 19 Mar 2025 17:12:44 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:760:e5ca:4814:99c7]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5195A8FA; Wed, 19 Mar 2025 17:11:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742400661; bh=SYgo4zWmdHpgF5xlz5lNmREp87ksn1IFDvh0ws3M3aE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VuLcKH+wBQDHwfx4i1X2zeJdTgiDsZL7TjPij1jebuyuG/1J00xvk2oBxWDd7BeNY t0KCiKPjY2MvtxykwDeOV75JjPtqOpHqrEXHUx4Mnonkymbvw6bgeRfen/7IAaxcTp dsR67dRUvCxW4ttmnpANN3nBMsN2wigLsTa35DEw= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v2 16/17] ipa: rkisp1: awb: Take the CCM into account for the AWB gains calculation Date: Wed, 19 Mar 2025 17:11:21 +0100 Message-ID: <20250319161152.63625-17-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250319161152.63625-1-stefan.klug@ideasonboard.com> References: <20250319161152.63625-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" The AWB measurements are taken after the CCM. This can be seen by enabling debug logging on AWB, disabling AWB (stats will still be processed) and manually chaning the CCM. This means that the estimated colour temperature and the corresponding CCM also lead to changed rgbMeans which in turn leads to oscillations. Fix that by applying the inverse transform on the rgbMeans. Signed-off-by: Stefan Klug --- Changes in v2: - Improved commit message - Added comment in the code --- src/ipa/rkisp1/algorithms/awb.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 324bc14b42a0..e8b04d03748d 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -412,6 +412,12 @@ RGB Awb::calculateRgbMeans(const IPAFrameContext &frameContext, const rk rgbMeans = rgbMeans.max(0.0); } + /* + * The ISP computes the AWB means after applying the ccm. Apply the + * inverse as we want to get the raw means before the colour gains. + */ + rgbMeans = frameContext.ccm.ccm.inverse() * rgbMeans; + /* * The ISP computes the AWB means after applying the colour gains, * divide by the gains that were used to get the raw means from the