{"id":24152,"url":"https://patchwork.libcamera.org/api/1.1/patches/24152/?format=json","web_url":"https://patchwork.libcamera.org/patch/24152/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20250818082909.2001635-3-stefan.klug@ideasonboard.com>","date":"2025-08-18T08:28:40","name":"[RFC,2/4] ipa: rkisp1: agc: Do not derive from AgcMeanLuminance","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ba62bb430f96eb4f1801def4564faca4c6b611ff","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24152/mbox/","series":[{"id":5390,"url":"https://patchwork.libcamera.org/api/1.1/series/5390/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5390","date":"2025-08-18T08:28:38","name":"libipa: agc_mean_luminance: Use composition instead of","version":1,"mbox":"https://patchwork.libcamera.org/series/5390/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24152/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24152/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 63848C3295\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 Aug 2025 08:30:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A37CF6925B;\n\tMon, 18 Aug 2025 10:30:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EDFC6924E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 Aug 2025 10:30:00 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:766d:a405:f64e:fe3a])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 585222394; \n\tMon, 18 Aug 2025 10:29:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"org0UC7g\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1755505743;\n\tbh=eK3pAHARES+7ig02SFZHMKMxMjhj4BNnIWKXsBNeTOg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=org0UC7gV5WS7wqrT9r2DuJgoLAH7ozrf0nMeen+gnWoCn+NT8Sm8vAvnJK8Ksrxp\n\tVg5r+NoSLVGUBt4FxaNvEWk2pRcHRv3o2MFiaH2nlZfkNp4R05jZwXw93o2SNBwgnC\n\tb3Qj4Sxl3cj1KKb1JY+Oxc6YGnK9b4xJSQHGR4nE=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[RFC PATCH 2/4] ipa: rkisp1: agc: Do not derive from\n\tAgcMeanLuminance","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","Content-Transfer-Encoding":"8bit","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":"There is no need to derive from AgcMeanLuminance anymore. Use\ncomposition for easier understanding.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 24 ++++++++++++------------\n src/ipa/rkisp1/algorithms/agc.h   |  3 ++-\n 2 files changed, 14 insertions(+), 13 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 3a078f9753f6..f7dc025ee050 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -138,7 +138,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData)\n {\n \tint ret;\n \n-\tret = parseTuningData(tuningData);\n+\tret = agc_.parseTuningData(tuningData);\n \tif (ret)\n \t\treturn ret;\n \n@@ -158,7 +158,7 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData)\n \t/* \\todo Move this to the Camera class */\n \tcontext.ctrlMap[&controls::AeEnable] = ControlInfo(false, true, true);\n \tcontext.ctrlMap[&controls::ExposureValue] = ControlInfo(-8.0f, 8.0f, 0.0f);\n-\tcontext.ctrlMap.merge(controls());\n+\tcontext.ctrlMap.merge(agc_.controls());\n \n \treturn 0;\n }\n@@ -183,9 +183,9 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \tcontext.activeState.agc.exposureValue = 0.0;\n \n \tcontext.activeState.agc.constraintMode =\n-\t\tstatic_cast<controls::AeConstraintModeEnum>(constraintModes().begin()->first);\n+\t\tstatic_cast<controls::AeConstraintModeEnum>(agc_.constraintModes().begin()->first);\n \tcontext.activeState.agc.exposureMode =\n-\t\tstatic_cast<controls::AeExposureModeEnum>(exposureModeHelpers().begin()->first);\n+\t\tstatic_cast<controls::AeExposureModeEnum>(agc_.exposureModeHelpers().begin()->first);\n \tcontext.activeState.agc.meteringMode =\n \t\tstatic_cast<controls::AeMeteringModeEnum>(meteringModes_.begin()->first);\n \n@@ -199,12 +199,12 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \tcontext.configuration.agc.measureWindow.h_size = configInfo.outputSize.width;\n \tcontext.configuration.agc.measureWindow.v_size = configInfo.outputSize.height;\n \n-\tsetLimits(context.configuration.sensor.minExposureTime,\n+\tagc_.setLimits(context.configuration.sensor.minExposureTime,\n \t\t  context.configuration.sensor.maxExposureTime,\n \t\t  context.configuration.sensor.minAnalogueGain,\n \t\t  context.configuration.sensor.maxAnalogueGain);\n \n-\tresetFrameCount();\n+\tagc_.resetFrameCount();\n \n \treturn 0;\n }\n@@ -553,7 +553,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t\tmaxAnalogueGain = frameContext.agc.gain;\n \t}\n \n-\tsetLimits(minExposureTime, maxExposureTime, minAnalogueGain, maxAnalogueGain);\n+\tagc_.setLimits(minExposureTime, maxExposureTime, minAnalogueGain, maxAnalogueGain);\n \n \t/*\n \t * The Agc algorithm needs to know the effective exposure value that was\n@@ -563,7 +563,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tdouble analogueGain = frameContext.sensor.gain;\n \tutils::Duration effectiveExposureValue = exposureTime * analogueGain;\n \n-\tsetExposureCompensation(pow(2.0, frameContext.agc.exposureValue));\n+\tagc_.setExposureCompensation(pow(2.0, frameContext.agc.exposureValue));\n \n \tAgcMeanLuminance::EstimateLuminanceFn estimateLuminanceFn = std::bind(\n \t\t&Agc::estimateLuminance, this,\n@@ -574,10 +574,10 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tutils::Duration newExposureTime;\n \tdouble aGain, dGain;\n \tstd::tie(newExposureTime, aGain, dGain) =\n-\t\tcalculateNewEv(estimateLuminanceFn,\n-\t\t\t       frameContext.agc.constraintMode,\n-\t\t\t       frameContext.agc.exposureMode,\n-\t\t\t       hist, effectiveExposureValue);\n+\t\tagc_.calculateNewEv(estimateLuminanceFn,\n+\t\t\t\t    frameContext.agc.constraintMode,\n+\t\t\t\t    frameContext.agc.exposureMode,\n+\t\t\t\t    hist, effectiveExposureValue);\n \n \tLOG(RkISP1Agc, Debug)\n \t\t<< \"Divided up exposure time, analogue gain and digital gain are \"\ndiff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h\nindex 742c8f7371f3..02ba04bd2641 100644\n--- a/src/ipa/rkisp1/algorithms/agc.h\n+++ b/src/ipa/rkisp1/algorithms/agc.h\n@@ -22,7 +22,7 @@ namespace libcamera {\n \n namespace ipa::rkisp1::algorithms {\n \n-class Agc : public Algorithm, public AgcMeanLuminance\n+class Agc : public Algorithm\n {\n public:\n \tAgc();\n@@ -55,6 +55,7 @@ private:\n \t\t\t\t  IPAFrameContext &frameContext,\n \t\t\t\t  utils::Duration frameDuration);\n \n+\tAgcMeanLuminance agc_;\n \n \tstd::map<int32_t, std::vector<uint8_t>> meteringModes_;\n };\n","prefixes":["RFC","2/4"]}