From patchwork Thu Apr 3 15:49:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23131 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 7C950C327D for ; Thu, 3 Apr 2025 15:50:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A2B968AB7; Thu, 3 Apr 2025 17:50:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VecF87Wg"; 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 3F0D2689A2 for ; Thu, 3 Apr 2025 17:50:20 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:6d9d:9854:3fc1:4bb2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8BEA419DF; Thu, 3 Apr 2025 17:48:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1743695306; bh=Sbt6LwHK1YT9TZAYtQnDyRTKlwqAeTCuFXpew9fnwkY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VecF87WgMzr/Jm0R2j43rOW0MGfIQxVR7ZnYrZjeDMY0S5nZdKwoP0lmvhMzkGrEU 7+VRsK7UjMOFqO7WjyMdHG3se8Et3mN3B/gVngzgtrsM7t4ZWVgVkMRXt7kL6DeE7p EgkK44+yjPBj0IGoq8By9QBXJWkxZtESTS8DD5yM= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , Kieran Bingham , Laurent Pinchart Subject: [PATCH v3 15/16] ipa: rkisp1: awb: Take the CCM into account for the AWB gains calculation Date: Thu, 3 Apr 2025 17:49:20 +0200 Message-ID: <20250403154925.382973-16-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250403154925.382973-1-stefan.klug@ideasonboard.com> References: <20250403154925.382973-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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changes in v2: - Improved commit message - Added comment in the code Changes in v3: - Fixed typo in comment --- 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 47b29725af51..03449e87e1a0 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -397,6 +397,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