Patch Detail
Show a patch.
GET /api/patches/27465/?format=api
{ "id": 27465, "url": "https://patchwork.libcamera.org/api/patches/27465/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27465/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260723154327.1357866-17-barnabas.pocze@ideasonboard.com>", "date": "2026-07-23T15:42:59", "name": "[RFC,v2,16/43] ipa: libipa: agc_mean_luminance: calculateNewEv(): Collect results", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "09ec8d6c7c7812e52ceda406fb575794abf24fb6", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27465/mbox/", "series": [ { "id": 6075, "url": "https://patchwork.libcamera.org/api/series/6075/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6075", "date": "2026-07-23T15:42:43", "name": "ipa: libipa: agc rework", "version": 2, "mbox": "https://patchwork.libcamera.org/series/6075/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27465/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27465/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 60A1CBDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jul 2026 15:43:56 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E804467F31;\n\tThu, 23 Jul 2026 17:43:55 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6BBA867EDE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jul 2026 17:43:34 +0200 (CEST)", "from pb-laptop.local (185.182.215.156.nat.pool.zt.hu\n\t[185.182.215.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8FF191C37\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jul 2026 17:42:33 +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=\"UG9UH4+A\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1784821353;\n\tbh=BUor4FFuTFvStj6cEasyaVz0CjfD/wopx30LsQF2m+M=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=UG9UH4+AUCKGHQ3I0xKbKaMAiEv7NOTmeKChmlOmmVCmJdeVcA8YXypKiIkp94ab4\n\tOroH3F41aPDWLAMBMVYVHEkrIBZ1yUkP7jHRMu1q/HjuZ6edZGWEU4VHzkmWu0YyQy\n\t+0RFW7HyTLpOd7x+EkCve7qZVXYoPkdp+bkYZIcI=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[RFC PATCH v2 16/43] ipa: libipa: agc_mean_luminance:\n\tcalculateNewEv(): Collect results", "Date": "Thu, 23 Jul 2026 17:42:59 +0200", "Message-ID": "<20260723154327.1357866-17-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.55.0", "In-Reply-To": "<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>", "References": "<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "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": "Add a new type that gives proper names to the returned quantities\ninstead of just using an `std::tuple`.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/ipa/ipu3/algorithms/agc.cpp | 10 ++++------\n src/ipa/libipa/agc_mean_luminance.cpp | 11 ++++++++---\n src/ipa/libipa/agc_mean_luminance.h | 7 ++++---\n src/ipa/libipa/exposure_mode_helper.cpp | 19 ++++++++++++++++++-\n src/ipa/libipa/exposure_mode_helper.h | 11 ++++++++---\n src/ipa/mali-c55/algorithms/agc.cpp | 10 ++++------\n src/ipa/rkisp1/algorithms/agc.cpp | 16 +++++++---------\n 7 files changed, 53 insertions(+), 31 deletions(-)", "diff": "diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\nindex ac5b6e7513..e74db62960 100644\n--- a/src/ipa/ipu3/algorithms/agc.cpp\n+++ b/src/ipa/ipu3/algorithms/agc.cpp\n@@ -237,9 +237,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-\tutils::Duration newExposureTime;\n-\tdouble aGain, qGain, dGain;\n-\tstd::tie(newExposureTime, aGain, qGain, dGain) = agc_.calculateNewEv({\n+\tconst auto &newEv = agc_.calculateNewEv({\n \t\t.traits = AgcTraits{\n \t\t\trgbTriples_,\n \t\t\t{{\n@@ -257,12 +255,12 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \n \tLOG(IPU3Agc, Debug)\n \t\t<< \"Divided up exposure time, analogue gain and digital gain are \"\n-\t\t<< newExposureTime << \", \" << aGain << \" and \" << dGain;\n+\t\t<< newEv.exposureTime << \", \" << newEv.analogueGain << \" and \" << newEv.digitalGain;\n \n \tIPAActiveState &activeState = context.activeState;\n \t/* Update the estimated exposure time and gain. */\n-\tactiveState.agc.exposure = newExposureTime / context.configuration.sensor.lineDuration;\n-\tactiveState.agc.gain = aGain;\n+\tactiveState.agc.exposure = newEv.exposureTime / context.configuration.sensor.lineDuration;\n+\tactiveState.agc.gain = newEv.analogueGain;\n \n \tmetadata.set(controls::AnalogueGain, frameContext.sensor.gain);\n \tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\ndiff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex e8679c66be..5e12c4b475 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -668,6 +668,11 @@ utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue)\n * \\brief The index of the exposure mode to use\n */\n \n+/**\n+ * \\struct AgcMeanLuminance::Result\n+ * \\brief Collection of results of the mean luminance AGC algorithm\n+ */\n+\n /**\n * \\brief Calculate the new exposure value and split it between exposure time\n * and gain\n@@ -680,7 +685,7 @@ utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue)\n * \\return Tuple of exposure time, analogue gain, quantization gain and digital\n * gain\n */\n-std::tuple<utils::Duration, double, double, double>\n+AgcMeanLuminance::Result\n AgcMeanLuminance::calculateNewEv(const Params ¶ms)\n {\n \t/*\n@@ -699,7 +704,7 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms)\n \t\t * doesn't get stuck with 0 in case the sensor driver allows a\n \t\t * min exposure of 0.\n \t\t */\n-\t\treturn exposureModeHelper.splitExposure(10ms);\n+\t\treturn { exposureModeHelper.splitExposure(10ms) };\n \t}\n \n \tdouble gain = estimateInitialGain(params.traits);\n@@ -721,7 +726,7 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms)\n \tnewExposureValue = filterExposure(newExposureValue);\n \n \tframeCount_++;\n-\treturn exposureModeHelper.splitExposure(newExposureValue);\n+\treturn { exposureModeHelper.splitExposure(newExposureValue) };\n }\n \n /**\ndiff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\nindex 9b82d97ab6..aa4c0369ac 100644\n--- a/src/ipa/libipa/agc_mean_luminance.h\n+++ b/src/ipa/libipa/agc_mean_luminance.h\n@@ -9,7 +9,6 @@\n \n #include <map>\n #include <memory>\n-#include <tuple>\n #include <vector>\n \n #include <libcamera/base/utils.h>\n@@ -87,8 +86,10 @@ public:\n \t\tuint32_t exposureModeIndex;\n \t};\n \n-\tstd::tuple<utils::Duration, double, double, double>\n-\tcalculateNewEv(const Params ¶ms);\n+\tstruct Result : ExposureModeHelper::Result {\n+\t};\n+\n+\t[[nodiscard]] Result calculateNewEv(const Params ¶ms);\n \n \tdouble effectiveYTarget() const;\n \ndiff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\nindex 01c5cba8e2..762e27b4fd 100644\n--- a/src/ipa/libipa/exposure_mode_helper.cpp\n+++ b/src/ipa/libipa/exposure_mode_helper.cpp\n@@ -153,6 +153,23 @@ double ExposureModeHelper::clampGain(double gain, double *quantizationGain) cons\n \treturn clamped;\n }\n \n+/**\n+ * \\struct ExposureModeHelper::Result\n+ * \\brief Result of splitExposure()\n+ *\n+ * \\var ExposureModeHelper::Result::exposureTime\n+ * \\brief The applicable exposure time\n+ *\n+ * \\var ExposureModeHelper::Result::analogueGain\n+ * \\brief The applicable analogue gain\n+ *\n+ * \\var ExposureModeHelper::Result::quantizationGain\n+ * \\brief The applicable quantization gain\n+ *\n+ * \\var ExposureModeHelper::Result::digitalGain\n+ * \\brief The applicable digital gain\n+ */\n+\n /**\n * \\brief Split exposure into exposure time and gain\n * \\param[in] exposure Exposure value\n@@ -190,7 +207,7 @@ double ExposureModeHelper::clampGain(double gain, double *quantizationGain) cons\n * \\return Tuple of exposure time, analogue gain, quantization gain and digital\n * gain\n */\n-std::tuple<utils::Duration, double, double, double>\n+ExposureModeHelper::Result\n ExposureModeHelper::splitExposure(utils::Duration exposure) const\n {\n \tASSERT(maxExposureTime_);\ndiff --git a/src/ipa/libipa/exposure_mode_helper.h b/src/ipa/libipa/exposure_mode_helper.h\nindex 968192ddc5..2bab20f974 100644\n--- a/src/ipa/libipa/exposure_mode_helper.h\n+++ b/src/ipa/libipa/exposure_mode_helper.h\n@@ -7,7 +7,6 @@\n \n #pragma once\n \n-#include <tuple>\n #include <utility>\n #include <vector>\n \n@@ -30,8 +29,14 @@ public:\n \tvoid setLimits(utils::Duration minExposureTime, utils::Duration maxExposureTime,\n \t\t double minGain, double maxGain);\n \n-\tstd::tuple<utils::Duration, double, double, double>\n-\tsplitExposure(utils::Duration exposure) const;\n+\tstruct Result {\n+\t\tutils::Duration exposureTime;\n+\t\tdouble analogueGain;\n+\t\tdouble quantizationGain;\n+\t\tdouble digitalGain;\n+\t};\n+\n+\t[[nodiscard]] Result splitExposure(utils::Duration exposure) const;\n \n \tutils::Duration minExposureTime() const { return minExposureTime_; }\n \tutils::Duration maxExposureTime() const { return maxExposureTime_; }\ndiff --git a/src/ipa/mali-c55/algorithms/agc.cpp b/src/ipa/mali-c55/algorithms/agc.cpp\nindex fb97b87c6e..821f43e9fd 100644\n--- a/src/ipa/mali-c55/algorithms/agc.cpp\n+++ b/src/ipa/mali-c55/algorithms/agc.cpp\n@@ -332,9 +332,7 @@ void Agc::process(IPAContext &context,\n \tutils::Duration currentShutter = exposure * configuration.sensor.lineDuration;\n \tutils::Duration effectiveExposureValue = currentShutter * analogueGain;\n \n-\tutils::Duration shutterTime;\n-\tdouble aGain, qGain, dGain;\n-\tstd::tie(shutterTime, aGain, qGain, dGain) = agc_.calculateNewEv({\n+\tconst auto &newEv = agc_.calculateNewEv({\n \t\t.traits = AgcTraits(statistics_),\n \t\t.yHist = statistics_.yHist,\n \t\t.effectiveExposureValue = effectiveExposureValue,\n@@ -344,10 +342,10 @@ void Agc::process(IPAContext &context,\n \n \tLOG(MaliC55Agc, Debug)\n \t\t<< \"Divided up shutter, analogue gain and digital gain are \"\n-\t\t<< shutterTime << \", \" << aGain << \" and \" << dGain;\n+\t\t<< newEv.exposureTime << \", \" << newEv.analogueGain << \" and \" << newEv.digitalGain;\n \n-\tactiveState.agc.automatic.exposure = shutterTime / configuration.sensor.lineDuration;\n-\tactiveState.agc.automatic.sensorGain = aGain;\n+\tactiveState.agc.automatic.exposure = newEv.exposureTime / configuration.sensor.lineDuration;\n+\tactiveState.agc.automatic.sensorGain = newEv.analogueGain;\n \n \tmetadata.set(controls::ExposureTime, currentShutter.get<std::micro>());\n \tmetadata.set(controls::AnalogueGain, frameContext.agc.sensorGain);\ndiff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 8b4bcbd71b..a4567c8258 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -720,9 +720,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \tagc_.setExposureCompensation(pow(2.0, frameContext.agc.exposureValue));\n \tagc_.setLux(frameContext.lux.lux);\n \n-\tutils::Duration newExposureTime;\n-\tdouble aGain, qGain, dGain;\n-\tstd::tie(newExposureTime, aGain, qGain, dGain) = agc_.calculateNewEv({\n+\tconst auto &newEv = agc_.calculateNewEv({\n \t\t.traits = AgcTraits{\n \t\t\t{ params->ae.exp_mean, context.hw.numAeCells },\n \t\t\tmeteringModes_.at(frameContext.agc.meteringMode),\n@@ -735,21 +733,21 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \n \tLOG(RkISP1Agc, Debug)\n \t\t<< \"Divided up exposure time, analogue gain, quantization gain\"\n-\t\t<< \" and digital gain are \" << newExposureTime << \", \" << aGain\n-\t\t<< \", \" << qGain << \" and \" << dGain;\n+\t\t<< \" and digital gain are \" << newEv.exposureTime << \", \" << newEv.analogueGain\n+\t\t<< \", \" << newEv.quantizationGain << \" and \" << newEv.digitalGain;\n \n \tIPAActiveState &activeState = context.activeState;\n \t/* Update the estimated exposure and gain. */\n-\tactiveState.agc.automatic.exposure = newExposureTime / lineDuration;\n-\tactiveState.agc.automatic.gain = aGain;\n-\tactiveState.agc.automatic.quantizationGain = qGain;\n+\tactiveState.agc.automatic.exposure = newEv.exposureTime / lineDuration;\n+\tactiveState.agc.automatic.gain = newEv.analogueGain;\n+\tactiveState.agc.automatic.quantizationGain = newEv.quantizationGain;\n \tactiveState.agc.automatic.yTarget = agc_.effectiveYTarget();\n \t/*\n \t * Expand the target frame duration so that we do not run faster than\n \t * the minimum frame duration when we have short exposures.\n \t */\n \tprocessFrameDuration(context, frameContext,\n-\t\t\t std::max(frameContext.agc.minFrameDuration, newExposureTime));\n+\t\t\t std::max(frameContext.agc.minFrameDuration, newEv.exposureTime));\n \n \tfillMetadata(context, frameContext, metadata);\n }\n", "prefixes": [ "RFC", "v2", "16/43" ] }