From patchwork Fri Jul 12 14:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20656 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 24944BD87C for ; Fri, 12 Jul 2024 14:32:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ABC6A63374; Fri, 12 Jul 2024 16:32:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rDv3g0sS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A074063369 for ; Fri, 12 Jul 2024 16:32:41 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.101.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CCCC6471; Fri, 12 Jul 2024 16:32:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720794726; bh=LCq8SKORXeGtsgkrM/bufoXzyT6SZprfYNLDGcaZQMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rDv3g0sSMj9s8hQh0aNe2fpKFkuf9zxS29koRB2l5cUfpgqygBU6pcxhnN6y8PBR1 6Pbh9HbIiZcms/cown9ezOXYHTFRg2VI4laLzictu1YDYIg+6yden15XIjvnyX/Bd6 op/qJZL2ajlo2gXyrOSkjy6jEbHdbHfixBVMun5Y= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits Date: Fri, 12 Jul 2024 16:32:02 +0200 Message-ID: <20240712143227.3036702-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> References: <20240712143227.3036702-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" When the color gains where set manually it was possible to specify a gain that wrapped the hardware limits. It would also be possible to further tune the floating point limits, but that is an error prone approach. So the limits are imposed on the integers, just before writing to the hardware. This noticeably reduces some oscillations in the awb regulation. Signed-off-by: Stefan Klug Reviewed-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/awb.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index a01fe5d90973..1a5d4776970a 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -120,10 +120,14 @@ void Awb::prepare(IPAContext &context, const uint32_t frame, frameContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue; } - params->others.awb_gain_config.gain_green_b = 256 * frameContext.awb.gains.green; - params->others.awb_gain_config.gain_blue = 256 * frameContext.awb.gains.blue; - params->others.awb_gain_config.gain_red = 256 * frameContext.awb.gains.red; - params->others.awb_gain_config.gain_green_r = 256 * frameContext.awb.gains.green; + params->others.awb_gain_config.gain_green_b = + std::clamp(256 * frameContext.awb.gains.green, 0, 0x3ff); + params->others.awb_gain_config.gain_blue = + std::clamp(256 * frameContext.awb.gains.blue, 0, 0x3ff); + params->others.awb_gain_config.gain_red = + std::clamp(256 * frameContext.awb.gains.red, 0, 0x3ff); + params->others.awb_gain_config.gain_green_r = + std::clamp(256 * frameContext.awb.gains.green, 0, 0x3ff); /* Update the gains. */ params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN; From patchwork Fri Jul 12 14:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20657 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 4B347BD87C for ; Fri, 12 Jul 2024 14:32:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F404D63374; Fri, 12 Jul 2024 16:32:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fQaZENxM"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7738563369 for ; Fri, 12 Jul 2024 16:32:44 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.101.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 05B69735; Fri, 12 Jul 2024 16:32:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720794730; bh=D8QQ2O6bD21mRk+8P5ndPfrEC3oD0xcu/FW4WljJd/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fQaZENxMSTWdUuNP0H2LDR/FafXOybQiKc4Kfb0QqtXu6xJgPNCNHK//MKu0EIUbI 9Sn9xHjKUcfD9fiWWVNruVAJZxZOOjtdx3TULf5ljFDkxX4A1PWTqGvuFB98xMUqoe Uxexq9thlfUYIsURQ/y2oXNzByKYMFbFtYfdDoc4= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 2/5] ipa rkisp1: Remove temperatureK from FrameContext Date: Fri, 12 Jul 2024 16:32:03 +0200 Message-ID: <20240712143227.3036702-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> References: <20240712143227.3036702-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 frame context is used to store data used for processing that frame. It is later used to either act as input for other algorithms or to fill the metadata. For the colour temperature this is not needed, as the meatadata shall not contain the value that was active when the image was processed, but the value that was calculated based on the statistics for that image. This is no functional change. Signed-off-by: Stefan Klug Reviewed-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/awb.cpp | 7 ++----- src/ipa/rkisp1/ipa_context.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 1a5d4776970a..18f750207793 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -277,7 +277,6 @@ void Awb::process(IPAContext &context, */ if (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold && blueMean < kMeanMinThreshold) { - frameContext.awb.temperatureK = activeState.awb.temperatureK; return; } @@ -309,21 +308,19 @@ void Awb::process(IPAContext &context, activeState.awb.gains.automatic.blue = blueGain; activeState.awb.gains.automatic.green = 1.0; - frameContext.awb.temperatureK = activeState.awb.temperatureK; - metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled); metadata.set(controls::ColourGains, { static_cast(frameContext.awb.gains.red), static_cast(frameContext.awb.gains.blue) }); - metadata.set(controls::ColourTemperature, frameContext.awb.temperatureK); + metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); LOG(RkISP1Awb, Debug) << std::showpoint << "Means [" << redMean << ", " << greenMean << ", " << blueMean << "], gains [" << activeState.awb.gains.automatic.red << ", " << activeState.awb.gains.automatic.green << ", " << activeState.awb.gains.automatic.blue << "], temp " - << frameContext.awb.temperatureK << "K"; + << activeState.awb.temperatureK << "K"; } REGISTER_IPA_ALGORITHM(Awb, "Awb") diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 1d0e9030af1c..27a9bf62fc16 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -136,7 +136,6 @@ struct IPAFrameContext : public FrameContext { double blue; } gains; - unsigned int temperatureK; bool autoEnabled; } awb; From patchwork Fri Jul 12 14:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20658 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 260ECBD87C for ; Fri, 12 Jul 2024 14:32:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AB01B6336F; Fri, 12 Jul 2024 16:32:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="tcnzMPx6"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E3F56336D for ; Fri, 12 Jul 2024 16:32:47 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.101.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E9EBC7E3; Fri, 12 Jul 2024 16:32:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720794733; bh=m9noFd5imylmPZI1gUS+wu1vDgxSb8W5byBqHMSuASc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tcnzMPx6mW6BAzOb6/rIFVqbiKTY9/HCOx/+4fuxepRPjlHeL4FdO1CFVOR5D+JEc 8Yei2HcYGaIdJEK7nfSmSDVdNnsDs/kvdv+MLzXQTuZNWmooo+2+QellajUNikRP/R Z25vHhXyn/Tw5IbDfVHK7cSj5g334IcaL/TvWbO0= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 3/5] ipa: rkisp1: awb: Unconditionally fill metadata Date: Fri, 12 Jul 2024 16:32:04 +0200 Message-ID: <20240712143227.3036702-4-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> References: <20240712143227.3036702-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" When the colour temperature estimation gets skipped, the metadata isn't populated. Fix that by filling the metadata early in the function. Signed-off-by: Stefan Klug Reviewed-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/awb.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 18f750207793..4ccafd48dedd 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -222,6 +222,12 @@ void Awb::process(IPAContext &context, double redMean; double blueMean; + metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled); + metadata.set(controls::ColourGains, { + static_cast(frameContext.awb.gains.red), + static_cast(frameContext.awb.gains.blue) + }); + if (rgbMode_) { greenMean = awb->awb_mean[0].mean_y_or_g; redMean = awb->awb_mean[0].mean_cr_or_r; @@ -277,11 +283,15 @@ void Awb::process(IPAContext &context, */ if (redMean < kMeanMinThreshold && greenMean < kMeanMinThreshold && blueMean < kMeanMinThreshold) { + metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); return; } activeState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean); + /* Metadata shall contain the up to date measurement */ + metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); + /* * Estimate the red and blue gains to apply in a grey world. The green * gain is hardcoded to 1.0. Avoid divisions by zero by clamping the @@ -308,13 +318,6 @@ void Awb::process(IPAContext &context, activeState.awb.gains.automatic.blue = blueGain; activeState.awb.gains.automatic.green = 1.0; - metadata.set(controls::AwbEnable, frameContext.awb.autoEnabled); - metadata.set(controls::ColourGains, { - static_cast(frameContext.awb.gains.red), - static_cast(frameContext.awb.gains.blue) - }); - metadata.set(controls::ColourTemperature, activeState.awb.temperatureK); - LOG(RkISP1Awb, Debug) << std::showpoint << "Means [" << redMean << ", " << greenMean << ", " << blueMean << "], gains [" << activeState.awb.gains.automatic.red << ", " From patchwork Fri Jul 12 14:32:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20659 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 CBB26BD87C for ; Fri, 12 Jul 2024 14:32:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7ABA163373; Fri, 12 Jul 2024 16:32:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jqoQNQge"; 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 1487663372 for ; Fri, 12 Jul 2024 16:32:50 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.101.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A3707E3; Fri, 12 Jul 2024 16:32:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720794735; bh=OEQXcnvfJAWBJFeZ9U8XQW/mbkS+E3NsjUOxJ3so064=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jqoQNQgeJQulGjJ4THplGyYtjXoDWOf4Bjy0Vs7vcCoU4qsB4Oe5LYzYaRLySEINZ bLQ5HLwFnQHyQqUrmgtZuSI3+rty/TgK5xhq9D8B2Du9kkLGQioW7EKaaNcxxKxqdU GneZgKbFzVFkTQVY/3xrtkGYF2EDdoNh8uUv6yGA= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 4/5] ipa: rkisp1: ccm: Fix ccm metadata output Date: Fri, 12 Jul 2024 16:32:05 +0200 Message-ID: <20240712143227.3036702-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> References: <20240712143227.3036702-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" Only the first three entries of the matrix were set. Fix that. Fixes: cbfdfa42cacc ("ipa: rkisp1: algorithms: Add crosstalk algorithm") Signed-off-by: Stefan Klug Reviewed-by: Daniel Scally Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/ccm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index c1f5403a8ab2..4c4e3f5029a4 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -135,7 +135,7 @@ void Ccm::process([[maybe_unused]] IPAContext &context, float m[9]; for (unsigned int i = 0; i < 3; i++) { for (unsigned int j = 0; j < 3; j++) - m[i] = frameContext.ccm.ccm[i][j]; + m[i * 3 + j] = frameContext.ccm.ccm[i][j]; } metadata.set(controls::ColourCorrectionMatrix, m); } From patchwork Fri Jul 12 14:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20660 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 E14B5BD87C for ; Fri, 12 Jul 2024 14:32:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D3C1F63372; Fri, 12 Jul 2024 16:32:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SrCvfnB3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E7B063372 for ; Fri, 12 Jul 2024 16:32:52 +0200 (CEST) Received: from ideasonboard.com (unknown [94.31.101.36]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0D540735; Fri, 12 Jul 2024 16:32:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720794738; bh=1gZQWRmZ893KdtpMNUXNhK9auXPX4O9wMFNsd0gwQuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SrCvfnB3gHXuASzNt0mciO8ldePGwqf4cj4+uBvdUJXmC2yLc5OhFntrhKg+cHmKK gHilq/0R2/4UdncYHW+MO9H6uCcyrBf7d04vfU1lz8+McCkDAuKBjuHWQ3tKaYXcrL s4zBw12tY2QOO11l3xREbK5rOSj1lSQtfNknaO3A= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 5/5] ipa: rkisp1: ccm: Ensure metadata contains valid ccm Date: Fri, 12 Jul 2024 16:32:06 +0200 Message-ID: <20240712143227.3036702-6-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712143227.3036702-1-stefan.klug@ideasonboard.com> References: <20240712143227.3036702-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" When the colour temperature does not change between frames, the ccm inside the frame context is not updated and the metadata contains invalid data. Fix that by caching the ccm inside the active state. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/ccm.cpp | 7 +++++-- src/ipa/rkisp1/ipa_context.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp index 4c4e3f5029a4..e9b1e78b7ec1 100644 --- a/src/ipa/rkisp1/algorithms/ccm.cpp +++ b/src/ipa/rkisp1/algorithms/ccm.cpp @@ -101,7 +101,7 @@ void Ccm::setParameters(rkisp1_params_cfg *params, /** * \copydoc libcamera::ipa::Algorithm::prepare */ -void Ccm::prepare(IPAContext &context, const uint32_t frame, +void Ccm::prepare([[maybe_unused]] IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, rkisp1_params_cfg *params) { @@ -111,13 +111,16 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame, * \todo The colour temperature will likely be noisy, add filtering to * avoid updating the CCM matrix all the time. */ - if (frame > 0 && ct == ct_) + if (frame > 0 && ct == ct_) { + frameContext.ccm.ccm = context.activeState.ccm.ccm; return; + } ct_ = ct; Matrix ccm = ccm_.get(ct); Matrix offsets = offsets_.get(ct); + context.activeState.ccm.ccm = ccm; frameContext.ccm.ccm = ccm; setParameters(params, ccm, offsets); diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 27a9bf62fc16..061efc0c578e 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -97,6 +97,10 @@ struct IPAActiveState { bool autoEnabled; } awb; + struct { + Matrix ccm; + } ccm; + struct { int8_t brightness; uint8_t contrast;