From patchwork Mon Feb 17 10:01:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22790 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 237D2C327D for ; Mon, 17 Feb 2025 10:02:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A8E0968673; Mon, 17 Feb 2025 11:02:25 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Aj81ANCs"; 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 361396866B for ; Mon, 17 Feb 2025 11:02:19 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:b47f:e20a:c4c7:ece1]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id F1F7A842; Mon, 17 Feb 2025 11:00:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1739786458; bh=Joq1eQL/Prjqoq7XSKLWjPq1On6oyzRirl6eiup8ERM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aj81ANCshS5qcRg+kLOIVrQ3c9YJ3pKpU8zp7rWJLCitoUg6HY9rLaph+/RMutYzh w30mU7RPUaxvkFpgTVxpTprJKShqLHv5o9rHBfPgG9vuOnkyjOjcp5pHO66f8uIGS2 ePn3IzzPa9cuxdvUQpQkg3v0hjc9n51II6Z1UxfQ= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 04/10] ipa: rkisp1: Refactor automatic/manual structure in IPAActiveState Date: Mon, 17 Feb 2025 11:01:45 +0100 Message-ID: <20250217100203.297894-5-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250217100203.297894-1-stefan.klug@ideasonboard.com> References: <20250217100203.297894-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" Swap gains and automatic/manual in the IPAActiveState structure. This is in preparation to adding another member, which is easier in this structure. This is also in sync with how it is modeled in agc. This patch contains no functional changes. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/awb.cpp | 24 ++++++++++++------------ src/ipa/rkisp1/ipa_context.h | 9 ++++++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index cffaa06a22c1..147277c98bb2 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -74,8 +74,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData) int Awb::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { - context.activeState.awb.gains.manual = RGB{ 1.0 }; - context.activeState.awb.gains.automatic = RGB{ 1.0 }; + context.activeState.awb.manual.gains = RGB{ 1.0 }; + context.activeState.awb.automatic.gains = RGB{ 1.0 }; context.activeState.awb.autoEnabled = true; context.activeState.awb.temperatureK = kDefaultColourTemperature; @@ -120,8 +120,8 @@ void Awb::queueRequest(IPAContext &context, const auto &colourTemperature = controls.get(controls::ColourTemperature); bool update = false; if (colourGains) { - awb.gains.manual.r() = (*colourGains)[0]; - awb.gains.manual.b() = (*colourGains)[1]; + awb.manual.gains.r() = (*colourGains)[0]; + awb.manual.gains.b() = (*colourGains)[1]; /* * \todo: Colour temperature reported in metadata is now * incorrect, as we can't deduce the temperature from the gains. @@ -130,17 +130,17 @@ void Awb::queueRequest(IPAContext &context, update = true; } else if (colourTemperature && colourGainCurve_) { const auto &gains = colourGainCurve_->getInterpolated(*colourTemperature); - awb.gains.manual.r() = gains[0]; - awb.gains.manual.b() = gains[1]; + awb.manual.gains.r() = gains[0]; + awb.manual.gains.b() = gains[1]; awb.temperatureK = *colourTemperature; update = true; } if (update) LOG(RkISP1Awb, Debug) - << "Set colour gains to " << awb.gains.manual; + << "Set colour gains to " << awb.manual.gains; - frameContext.awb.gains = awb.gains.manual; + frameContext.awb.gains = awb.manual.gains; frameContext.awb.temperatureK = awb.temperatureK; } @@ -155,7 +155,7 @@ void Awb::prepare(IPAContext &context, const uint32_t frame, * most up-to-date automatic values we can read. */ if (frameContext.awb.autoEnabled) { - frameContext.awb.gains = context.activeState.awb.gains.automatic; + frameContext.awb.gains = context.activeState.awb.automatic.gains; frameContext.awb.temperatureK = context.activeState.awb.temperatureK; } @@ -332,14 +332,14 @@ void Awb::process(IPAContext &context, /* Filter the values to avoid oscillations. */ double speed = 0.2; - gains = gains * speed + activeState.awb.gains.automatic * (1 - speed); + gains = gains * speed + activeState.awb.automatic.gains * (1 - speed); - activeState.awb.gains.automatic = gains; + activeState.awb.automatic.gains = gains; LOG(RkISP1Awb, Debug) << std::showpoint << "Means " << rgbMeans << ", gains " - << activeState.awb.gains.automatic << ", temp " + << activeState.awb.automatic.gains << ", temp " << activeState.awb.temperatureK << "K"; } diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index c765b928a55f..1a374c96cd1a 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -89,9 +89,12 @@ struct IPAActiveState { struct { struct { - RGB manual; - RGB automatic; - } gains; + RGB gains; + } manual; + + struct { + RGB gains; + } automatic; unsigned int temperatureK; bool autoEnabled;