From patchwork Mon Aug 18 08:28:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24152 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 63848C3295 for ; Mon, 18 Aug 2025 08:30:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A37CF6925B; Mon, 18 Aug 2025 10:30:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="org0UC7g"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EDFC6924E for ; Mon, 18 Aug 2025 10:30:00 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:766d:a405:f64e:fe3a]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 585222394; Mon, 18 Aug 2025 10:29:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1755505743; bh=eK3pAHARES+7ig02SFZHMKMxMjhj4BNnIWKXsBNeTOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=org0UC7gV5WS7wqrT9r2DuJgoLAH7ozrf0nMeen+gnWoCn+NT8Sm8vAvnJK8Ksrxp Vg5r+NoSLVGUBt4FxaNvEWk2pRcHRv3o2MFiaH2nlZfkNp4R05jZwXw93o2SNBwgnC b3Qj4Sxl3cj1KKb1JY+Oxc6YGnK9b4xJSQHGR4nE= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [RFC PATCH 2/4] ipa: rkisp1: agc: Do not derive from AgcMeanLuminance Date: Mon, 18 Aug 2025 10:28:40 +0200 Message-ID: <20250818082909.2001635-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250818082909.2001635-1-stefan.klug@ideasonboard.com> References: <20250818082909.2001635-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" There is no need to derive from AgcMeanLuminance anymore. Use composition for easier understanding. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 24 ++++++++++++------------ src/ipa/rkisp1/algorithms/agc.h | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 3a078f9753f6..f7dc025ee050 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -138,7 +138,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) { int ret; - ret = parseTuningData(tuningData); + ret = agc_.parseTuningData(tuningData); if (ret) return ret; @@ -158,7 +158,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) /* \todo Move this to the Camera class */ context.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true); context.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f); - context.ctrlMap.merge(controls()); + context.ctrlMap.merge(agc_.controls()); return 0; } @@ -183,9 +183,9 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.activeState.agc.exposureValue = 0.0; context.activeState.agc.constraintMode = - static_cast(constraintModes().begin()->first); + static_cast(agc_.constraintModes().begin()->first); context.activeState.agc.exposureMode = - static_cast(exposureModeHelpers().begin()->first); + static_cast(agc_.exposureModeHelpers().begin()->first); context.activeState.agc.meteringMode = static_cast(meteringModes_.begin()->first); @@ -199,12 +199,12 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.configuration.agc.measureWindow.h_size = configInfo.outputSize.width; context.configuration.agc.measureWindow.v_size = configInfo.outputSize.height; - setLimits(context.configuration.sensor.minExposureTime, + agc_.setLimits(context.configuration.sensor.minExposureTime, context.configuration.sensor.maxExposureTime, context.configuration.sensor.minAnalogueGain, context.configuration.sensor.maxAnalogueGain); - resetFrameCount(); + agc_.resetFrameCount(); return 0; } @@ -553,7 +553,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, maxAnalogueGain = frameContext.agc.gain; } - setLimits(minExposureTime, maxExposureTime, minAnalogueGain, maxAnalogueGain); + agc_.setLimits(minExposureTime, maxExposureTime, minAnalogueGain, maxAnalogueGain); /* * The Agc algorithm needs to know the effective exposure value that was @@ -563,7 +563,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, double analogueGain = frameContext.sensor.gain; utils::Duration effectiveExposureValue = exposureTime * analogueGain; - setExposureCompensation(pow(2.0, frameContext.agc.exposureValue)); + agc_.setExposureCompensation(pow(2.0, frameContext.agc.exposureValue)); AgcMeanLuminance::EstimateLuminanceFn estimateLuminanceFn = std::bind( &Agc::estimateLuminance, this, @@ -574,10 +574,10 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, utils::Duration newExposureTime; double aGain, dGain; std::tie(newExposureTime, aGain, dGain) = - calculateNewEv(estimateLuminanceFn, - frameContext.agc.constraintMode, - frameContext.agc.exposureMode, - hist, effectiveExposureValue); + agc_.calculateNewEv(estimateLuminanceFn, + frameContext.agc.constraintMode, + frameContext.agc.exposureMode, + hist, effectiveExposureValue); LOG(RkISP1Agc, Debug) << "Divided up exposure time, analogue gain and digital gain are " diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index 742c8f7371f3..02ba04bd2641 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -22,7 +22,7 @@ namespace libcamera { namespace ipa::rkisp1::algorithms { -class Agc : public Algorithm, public AgcMeanLuminance +class Agc : public Algorithm { public: Agc(); @@ -55,6 +55,7 @@ private: IPAFrameContext &frameContext, utils::Duration frameDuration); + AgcMeanLuminance agc_; std::map> meteringModes_; };