From patchwork Fri Nov 14 14:17:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 25067 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 513AAC3335 for ; Fri, 14 Nov 2025 14:17:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E793D60A8B; Fri, 14 Nov 2025 15:17:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="l6eeKo2D"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 981D660AA7 for ; Fri, 14 Nov 2025 15:17:23 +0100 (CET) Received: from [192.168.1.101] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 98EB0664; Fri, 14 Nov 2025 15:15:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1763129722; bh=0XZ1znvJpiyjfJV5NSov+PyuvJO/BC3mfohGSQTTJ0A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l6eeKo2D4Eeradkbh7Eai9O4drUb/yn54U5t2WlfEhlSl6MJFXFt4TWBBrAo5K1cB LaEoKV0VfZwSkG7th9X08BV6zP0iHQmrAY4hEpOJZR9Lw6EFOK3eQxuHNDg1182r3K 3Ycs6gz75cAfdfz99fmzuWZKvZ1jlQhQ/HRth1Pw= From: Jacopo Mondi Date: Fri, 14 Nov 2025 15:17:10 +0100 Subject: [PATCH v3 15/19] ipa: libipa: agc: Fold resetFrameCount() in configure() MIME-Version: 1.0 Message-Id: <20251114-exposure-limits-v3-15-b7c07feba026@ideasonboard.com> References: <20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com> In-Reply-To: <20251114-exposure-limits-v3-0-b7c07feba026@ideasonboard.com> To: =?utf-8?q?Niklas_S=C3=B6derlund?= , Robert Mader , libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4878; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=0XZ1znvJpiyjfJV5NSov+PyuvJO/BC3mfohGSQTTJ0A=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpFznsloNNoJLHrOUanq48h5ZyPmMS6mlrlOGJ5 URsFecr2fSJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaRc57AAKCRByNAaPFqFW PAZjEACNK56VSIjDSXNgZBgzG82x4j4CGqjTxpumCzP3jzct1ta+ZydLl61U/ax9r6xoW+4o/5A Bm3HaO7TgF/43qxylI4Bv+xVy0QNgTFnWOkdnpH/Hl9vp/FChk9s5z/7s7iUz4v5bBhArjtDHM+ WKBvcqbqwWXJRu5l66GLgzNupqg9/yrkhmH7Ue5qhKArPDoCW5x4fF27eY+KhRvRXNOd+q0naaF HQj+JnzVxkmiMyga3WXVDpUNL9xRwcChLcBSoSRctmsiJT1nOQdQfPuPH+jHolGur0776iI1Unt 1pdYRWM7sjGxZwPpHQtbloW7PNxRKwO3E5xq6g7uxQ/sI2u2fjOKiRstJ/yc9osbKBZN4Ea6nro p5E8Xp1wHCE5FGTPNgjmRvgJo1Ib8uZTfp7AaJju/SVeOldqx7qtqwYU0KA/OgLg9OrNUq4zrkc jEwVXVFuOkedO1GnRD36PbaDr9T5+4vreIJjgpXhpud4VpwKUkE2Z4J7DxRVmMnMKKaAt9vMjW5 wWg4FzpnmwlJiRfGR+r+ThXZY7OJIXiOMst7BEv/z0XksNtD9y1X1oYnqmjwXUd+CxbmGXV3/L3 qHVg55Il4R4ZkNVriZC1njRWzCd9EumsOtZuIZXcSaBS4fieRQyLrvfeUBhio5+ItdmrZgK4W/X Si+j3kLXHXjkpjg== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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 AgcMeanLuminance::resetFrameCount() function has to be called after a call to AgcMeanLuminance::configure(). As the two calls always happen one after another, do not require each IPA implementation to do that but fold instead the call to resetFrameCount() in AgcMeanLuminance::configure(). Update the AgcMeanLuminance class documentation accordingly. Signed-off-by: Jacopo Mondi --- src/ipa/ipu3/algorithms/agc.cpp | 2 -- src/ipa/libipa/agc_mean_luminance.cpp | 19 ++++++------------- src/ipa/libipa/agc_mean_luminance.h | 9 ++++----- src/ipa/mali-c55/algorithms/agc.cpp | 2 -- src/ipa/rkisp1/algorithms/agc.cpp | 2 -- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index 002ee574c02b79c25834a9d87a5881a9de52e39e..c9d41f93cff5b81710b76592303f1e0d10697326 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -128,8 +128,6 @@ int Agc::configure(IPAContext &context, /* \todo Update AGC limits when FrameDurationLimits is passed in */ - resetFrameCount(); - return 0; } diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 9fc275ea9e5b81ce107eabe1982be3c44c01479c..725a23ef2f6f612c6d3408701246db7415fd8327 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -171,9 +171,10 @@ static constexpr double kMaxRelativeLuminanceTarget = 0.95; * * IPA modules that want to use this class to implement their AEGC algorithm * should derive it and provide an overriding estimateLuminance() function for - * this class to use. They must call parseTuningData() in init(), and must also - * call resetFrameCounter() in configure(). They may then use calculateNewEv() - * in process(). To update the algorithm limits for example, in response to a + * this class to use. They must call parseTuningData() in init() and the use the + * sensor configuration data to call AgcMeanLuminance::configure() in their + * configure() implementation. They may then use calculateNewEv() in process(). + * To update the algorithm limits for example, in response to a * FrameDurationLimit control being passed in queueRequest()) then * setExposureLimits() must be called with the new values. */ @@ -379,6 +380,8 @@ void AgcMeanLuminance::configure(const SensorConfiguration &config, helper->configure(sensorConfig, sensorHelper); } + + resetFrameCount(); } /** @@ -692,16 +695,6 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex, return exposureModeHelper->splitExposure(newExposureValue); } -/** - * \fn AgcMeanLuminance::resetFrameCount() - * \brief Reset the frame counter - * - * This function resets the internal frame counter, which exists to help the - * algorithm decide whether it should respond instantly or not. The expectation - * is for derived classes to call this function before each camera start call in - * their configure() function. - */ - } /* namespace ipa */ } /* namespace libcamera */ diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h index 12316ca8bbd7d8b5783a948f5e01d5f0f56bfe3a..acbefc4e5765413bc803417eae1dbd0a943bc95e 100644 --- a/src/ipa/libipa/agc_mean_luminance.h +++ b/src/ipa/libipa/agc_mean_luminance.h @@ -87,11 +87,6 @@ public: double effectiveYTarget() const; - void resetFrameCount() - { - frameCount_ = 0; - } - private: virtual double estimateLuminance(const double gain) const = 0; @@ -104,6 +99,10 @@ private: const Histogram &hist, double gain); utils::Duration filterExposure(utils::Duration exposureValue); + void resetFrameCount() + { + frameCount_ = 0; + } double exposureCompensation_; uint64_t frameCount_; diff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp index 731b29ced1030ecb3f44b83ad28a0691dd5d2f0d..91b1438f7e5ca0498373c86fd75b91f9c5a81c3f 100644 --- a/src/ipa/mali-c55/algorithms/agc.cpp +++ b/src/ipa/mali-c55/algorithms/agc.cpp @@ -186,8 +186,6 @@ int Agc::configure(IPAContext &context, /* \todo Update AGC limits when FrameDurationLimits is passed in */ - resetFrameCount(); - return 0; } diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index c8210e175186a282faf586378c5a0a761612047c..b9a94ba03c910f73420579dd6737d8d46b26e576 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -213,8 +213,6 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) context.activeState.agc.automatic.yTarget = effectiveYTarget(); - resetFrameCount(); - return 0; }