[{"id":39820,"web_url":"https://patchwork.libcamera.org/comment/39820/","msgid":"<amNVNQDvo8dSG0Wf@zed>","date":"2026-07-24T12:06:30","subject":"Re: [RFC PATCH v2 12/43] ipa: libipa: agc_mean_luminance: Remove\n\tunnecessary `std::shared_ptr`","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Barnabás\n\nOn Thu, Jul 23, 2026 at 05:42:55PM +0200, Barnabás Pőcze wrote:\n> The `ExposureModeHelper` object can be directly in the map, so do that.\n>\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nIndeed\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n> ---\n>  src/ipa/libipa/agc_mean_luminance.cpp | 23 ++++++++---------------\n>  src/ipa/libipa/agc_mean_luminance.h   |  4 ++--\n>  2 files changed, 10 insertions(+), 17 deletions(-)\n>\n> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n> index 8284c15ce2..faa8a41fd7 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.cpp\n> +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n> @@ -332,10 +332,7 @@ int AgcMeanLuminance::parseExposureModes(const ValueNode &tuningData)\n>  \t\t\t\t});\n>  \t\t\t}\n>\n> -\t\t\tstd::shared_ptr<ExposureModeHelper> helper =\n> -\t\t\t\tstd::make_shared<ExposureModeHelper>(stages);\n> -\n> -\t\t\texposureModeHelpers_.try_emplace(it->second, std::move(helper));\n> +\t\t\texposureModeHelpers_.try_emplace(it->second, stages);\n>  \t\t\tavailableExposureModes.push_back(it->second);\n>  \t\t}\n>  \t}\n> @@ -347,12 +344,8 @@ int AgcMeanLuminance::parseExposureModes(const ValueNode &tuningData)\n>  \t * possible before touching gain.\n>  \t */\n>  \tif (availableExposureModes.empty()) {\n> -\t\tstd::vector<std::pair<utils::Duration, double>> stages = { };\n> -\n> -\t\tstd::shared_ptr<ExposureModeHelper> helper =\n> -\t\t\tstd::make_shared<ExposureModeHelper>(stages);\n> -\n> -\t\texposureModeHelpers_.try_emplace(controls::ExposureNormal, std::move(helper));\n> +\t\texposureModeHelpers_.try_emplace(controls::ExposureNormal,\n> +\t\t\t\t\t\t Span<std::pair<utils::Duration, double>>{});\n>  \t\tavailableExposureModes.push_back(controls::ExposureNormal);\n>  \t}\n>\n> @@ -373,7 +366,7 @@ void AgcMeanLuminance::configure(utils::Duration lineDuration,\n>  \t\t\t\t const CameraSensorHelper *sensorHelper)\n>  {\n>  \tfor (auto &[id, helper] : exposureModeHelpers_)\n> -\t\thelper->configure(lineDuration, sensorHelper);\n> +\t\thelper.configure(lineDuration, sensorHelper);\n>\n>  \tluxWarningEnabled_ = true;\n>  }\n> @@ -484,7 +477,7 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime,\n>  \t\t\t\t std::vector<AgcMeanLuminance::AgcConstraint> constraints)\n>  {\n>  \tfor (auto &[id, helper] : exposureModeHelpers_)\n> -\t\thelper->setLimits(minExposureTime, maxExposureTime, minGain, maxGain);\n> +\t\thelper.setLimits(minExposureTime, maxExposureTime, minGain, maxGain);\n>\n>  \tadditionalConstraints_ = std::move(constraints);\n>  }\n> @@ -684,7 +677,7 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n>  \t * The pipeline handler should validate that we have received an allowed\n>  \t * value for AeExposureMode.\n>  \t */\n> -\tstd::shared_ptr<ExposureModeHelper> exposureModeHelper =\n> +\tExposureModeHelper &exposureModeHelper =\n>  \t\texposureModeHelpers_.at(exposureModeIndex);\n>\n>  \tif (effectiveExposureValue == 0s) {\n> @@ -696,7 +689,7 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\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(traits);\n> @@ -718,7 +711,7 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n>  \tnewExposureValue = filterExposure(newExposureValue);\n>\n>  \tframeCount_++;\n> -\treturn exposureModeHelper->splitExposure(newExposureValue);\n> +\treturn exposureModeHelper.splitExposure(newExposureValue);\n>  }\n>\n>  /**\n> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\n> index f4e1680ab5..d5425cd20b 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.h\n> +++ b/src/ipa/libipa/agc_mean_luminance.h\n> @@ -69,7 +69,7 @@ public:\n>  \t\treturn constraintModes_;\n>  \t}\n>\n> -\tconst std::map<int32_t, std::shared_ptr<ExposureModeHelper>> &exposureModeHelpers() const\n> +\tconst std::map<int32_t, ExposureModeHelper> &exposureModeHelpers() const\n>  \t{\n>  \t\treturn exposureModeHelpers_;\n>  \t}\n> @@ -111,7 +111,7 @@ private:\n>\n>  \tstd::vector<AgcConstraint> additionalConstraints_;\n>  \tstd::map<int32_t, std::vector<AgcConstraint>> constraintModes_;\n> -\tstd::map<int32_t, std::shared_ptr<ExposureModeHelper>> exposureModeHelpers_;\n> +\tstd::map<int32_t, ExposureModeHelper> exposureModeHelpers_;\n>  \tControlInfoMap::Map controls_;\n>  };\n>\n> --\n> 2.55.0\n>","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 AA114BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2026 12:06:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAB2867F02;\n\tFri, 24 Jul 2026 14:06:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED19D67E89\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2026 14:06:33 +0200 (CEST)","from ideasonboard.com (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4EA79524;\n\tFri, 24 Jul 2026 14:05:32 +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=\"HIXbOoGI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1784894732;\n\tbh=rls4D+KlpenVcqZdL8AzJ8jtZ4fslSauny0crZWK8es=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=HIXbOoGI0zqXzUMXSe/vHQF80vk7PNvJkmQb3l3JLJHJWC1Zf/CPlENgPmTslKduN\n\teQ5+6mcLGm9z3iqtEe8cS4LS7NQlj6i8WIVueDQ/c2c2VTPgOgMl8DFtQ3so4s607z\n\tBu/npklo4XlC3j2oJQvHs4LMQySYHZKgx4l7zUDc=","Date":"Fri, 24 Jul 2026 14:06:30 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [RFC PATCH v2 12/43] ipa: libipa: agc_mean_luminance: Remove\n\tunnecessary `std::shared_ptr`","Message-ID":"<amNVNQDvo8dSG0Wf@zed>","References":"<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>\n\t<20260723154327.1357866-13-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20260723154327.1357866-13-barnabas.pocze@ideasonboard.com>","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>"}}]