{"id":25067,"url":"https://patchwork.libcamera.org/api/patches/25067/?format=json","web_url":"https://patchwork.libcamera.org/patch/25067/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20251114-exposure-limits-v3-15-b7c07feba026@ideasonboard.com>","date":"2025-11-14T14:17:10","name":"[v3,15/19] ipa: libipa: agc: Fold resetFrameCount() in configure()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e23e231e063f2ecd01ab93fcaf1f71a174388e7e","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25067/mbox/","series":[{"id":5590,"url":"https://patchwork.libcamera.org/api/series/5590/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5590","date":"2025-11-14T14:16:55","name":"libipa: agc: Calculate exposure limits","version":3,"mbox":"https://patchwork.libcamera.org/series/5590/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25067/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25067/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 513AAC3335\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Nov 2025 14:17:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E793D60A8B;\n\tFri, 14 Nov 2025 15:17:41 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 981D660AA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Nov 2025 15:17:23 +0100 (CET)","from [192.168.1.101] (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 98EB0664;\n\tFri, 14 Nov 2025 15:15:22 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"l6eeKo2D\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763129722;\n\tbh=0XZ1znvJpiyjfJV5NSov+PyuvJO/BC3mfohGSQTTJ0A=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=l6eeKo2D4Eeradkbh7Eai9O4drUb/yn54U5t2WlfEhlSl6MJFXFt4TWBBrAo5K1cB\n\tLaEoKV0VfZwSkG7th9X08BV6zP0iHQmrAY4hEpOJZR9Lw6EFOK3eQxuHNDg1182r3K\n\t3Ycs6gz75cAfdfz99fmzuWZKvZ1jlQhQ/HRth1Pw=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Fri, 14 Nov 2025 15:17:10 +0100","Subject":"[PATCH v3 15/19] ipa: libipa: agc: Fold resetFrameCount() in\n\tconfigure()","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","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?= <niklas.soderlund@ragnatech.se>,\n\tRobert Mader <robert.mader@collabora.com>, \n\tlibcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","X-Mailer":"b4 0.14.2","X-Developer-Signature":"v=1; a=openpgp-sha256; l=4878;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=0XZ1znvJpiyjfJV5NSov+PyuvJO/BC3mfohGSQTTJ0A=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpFznsloNNoJLHrOUanq48h5ZyPmMS6mlrlOGJ5\n\tURsFecr2fSJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaRc57AAKCRByNAaPFqFW\n\tPAZjEACNK56VSIjDSXNgZBgzG82x4j4CGqjTxpumCzP3jzct1ta+ZydLl61U/ax9r6xoW+4o/5A\n\tBm3HaO7TgF/43qxylI4Bv+xVy0QNgTFnWOkdnpH/Hl9vp/FChk9s5z/7s7iUz4v5bBhArjtDHM+\n\tWKBvcqbqwWXJRu5l66GLgzNupqg9/yrkhmH7Ue5qhKArPDoCW5x4fF27eY+KhRvRXNOd+q0naaF\n\tHQj+JnzVxkmiMyga3WXVDpUNL9xRwcChLcBSoSRctmsiJT1nOQdQfPuPH+jHolGur0776iI1Unt\n\t1pdYRWM7sjGxZwPpHQtbloW7PNxRKwO3E5xq6g7uxQ/sI2u2fjOKiRstJ/yc9osbKBZN4Ea6nro\n\tp5E8Xp1wHCE5FGTPNgjmRvgJo1Ib8uZTfp7AaJju/SVeOldqx7qtqwYU0KA/OgLg9OrNUq4zrkc\n\tjEwVXVFuOkedO1GnRD36PbaDr9T5+4vreIJjgpXhpud4VpwKUkE2Z4J7DxRVmMnMKKaAt9vMjW5\n\twWg4FzpnmwlJiRfGR+r+ThXZY7OJIXiOMst7BEv/z0XksNtD9y1X1oYnqmjwXUd+CxbmGXV3/L3\n\tqHVg55Il4R4ZkNVriZC1njRWzCd9EumsOtZuIZXcSaBS4fieRQyLrvfeUBhio5+ItdmrZgK4W/X\n\tSi+j3kLXHXjkpjg==","X-Developer-Key":"i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The AgcMeanLuminance::resetFrameCount() function has to be called\nafter a call to AgcMeanLuminance::configure(). As the two calls always\nhappen one after another, do not require each IPA implementation to do\nthat but fold instead the call to resetFrameCount() in\nAgcMeanLuminance::configure().\n\nUpdate the AgcMeanLuminance class documentation accordingly.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp       |  2 --\n src/ipa/libipa/agc_mean_luminance.cpp | 19 ++++++-------------\n src/ipa/libipa/agc_mean_luminance.h   |  9 ++++-----\n src/ipa/mali-c55/algorithms/agc.cpp   |  2 --\n src/ipa/rkisp1/algorithms/agc.cpp     |  2 --\n 5 files changed, 10 insertions(+), 24 deletions(-)","diff":"diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex 002ee574c02b79c25834a9d87a5881a9de52e39e..c9d41f93cff5b81710b76592303f1e0d10697326 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -128,8 +128,6 @@ int Agc::configure(IPAContext &context,\n \n \t/* \\todo Update AGC limits when FrameDurationLimits is passed in */\n \n-\tresetFrameCount();\n-\n \treturn 0;\n }\n \ndiff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex 9fc275ea9e5b81ce107eabe1982be3c44c01479c..725a23ef2f6f612c6d3408701246db7415fd8327 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -171,9 +171,10 @@ static constexpr double kMaxRelativeLuminanceTarget = 0.95;\n  *\n  * IPA modules that want to use this class to implement their AEGC algorithm\n  * should derive it and provide an overriding estimateLuminance() function for\n- * this class to use. They must call parseTuningData() in init(), and must also\n- * call resetFrameCounter() in configure(). They may then use calculateNewEv()\n- * in process(). To update the algorithm limits for example, in response to a\n+ * this class to use. They must call parseTuningData() in init() and the use the\n+ * sensor configuration data to call AgcMeanLuminance::configure() in their\n+ * configure() implementation. They may then use calculateNewEv() in process().\n+ * To update the algorithm limits for example, in response to a\n  * FrameDurationLimit control being passed in queueRequest()) then\n  * setExposureLimits() must be called with the new values.\n  */\n@@ -379,6 +380,8 @@ void AgcMeanLuminance::configure(const SensorConfiguration &config,\n \n \t\thelper->configure(sensorConfig, sensorHelper);\n \t}\n+\n+\tresetFrameCount();\n }\n \n /**\n@@ -692,16 +695,6 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n \treturn exposureModeHelper->splitExposure(newExposureValue);\n }\n \n-/**\n- * \\fn AgcMeanLuminance::resetFrameCount()\n- * \\brief Reset the frame counter\n- *\n- * This function resets the internal frame counter, which exists to help the\n- * algorithm decide whether it should respond instantly or not. The expectation\n- * is for derived classes to call this function before each camera start call in\n- * their configure() function.\n- */\n-\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\nindex 12316ca8bbd7d8b5783a948f5e01d5f0f56bfe3a..acbefc4e5765413bc803417eae1dbd0a943bc95e 100644\n--- a/src/ipa/libipa/agc_mean_luminance.h\n+++ b/src/ipa/libipa/agc_mean_luminance.h\n@@ -87,11 +87,6 @@ public:\n \n \tdouble effectiveYTarget() const;\n \n-\tvoid resetFrameCount()\n-\t{\n-\t\tframeCount_ = 0;\n-\t}\n-\n private:\n \tvirtual double estimateLuminance(const double gain) const = 0;\n \n@@ -104,6 +99,10 @@ private:\n \t\t\t\t   const Histogram &hist,\n \t\t\t\t   double gain);\n \tutils::Duration filterExposure(utils::Duration exposureValue);\n+\tvoid resetFrameCount()\n+\t{\n+\t\tframeCount_ = 0;\n+\t}\n \n \tdouble exposureCompensation_;\n \tuint64_t frameCount_;\ndiff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp\nindex 731b29ced1030ecb3f44b83ad28a0691dd5d2f0d..91b1438f7e5ca0498373c86fd75b91f9c5a81c3f 100644\n--- a/src/ipa/mali-c55/algorithms/agc.cpp\n+++ b/src/ipa/mali-c55/algorithms/agc.cpp\n@@ -186,8 +186,6 @@ int Agc::configure(IPAContext &context,\n \n \t/* \\todo Update AGC limits when FrameDurationLimits is passed in */\n \n-\tresetFrameCount();\n-\n \treturn 0;\n }\n \ndiff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex c8210e175186a282faf586378c5a0a761612047c..b9a94ba03c910f73420579dd6737d8d46b26e576 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -213,8 +213,6 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \n \tcontext.activeState.agc.automatic.yTarget = effectiveYTarget();\n \n-\tresetFrameCount();\n-\n \treturn 0;\n }\n \n","prefixes":["v3","15/19"]}