[{"id":39828,"web_url":"https://patchwork.libcamera.org/comment/39828/","msgid":"<amNfuYSiUHP7WMFv@zed>","date":"2026-07-24T12:51:27","subject":"Re: [RFC PATCH v2 17/43] ipa: libipa: agc_mean_luminance:\n\tcalculateNewEv(): Return y target","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:43:00PM +0200, Barnabás Pőcze wrote:\n> Return the current applicable y target as part of the result set.\n\nIt would be nice to tell what it will be used for\n\nApart from that\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n>\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> ---\n>  src/ipa/libipa/agc_mean_luminance.cpp | 13 ++++++++-----\n>  src/ipa/libipa/agc_mean_luminance.h   |  3 ++-\n>  src/ipa/rkisp1/algorithms/agc.cpp     |  2 +-\n>  3 files changed, 11 insertions(+), 7 deletions(-)\n>\n> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n> index 5e12c4b475..d25b1e8322 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.cpp\n> +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n> @@ -502,9 +502,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime,\n>   * target\n>   * \\return The calculated initial gain\n>   */\n> -double AgcMeanLuminance::estimateInitialGain(const Traits &traits) const\n> +double AgcMeanLuminance::estimateInitialGain(const Traits &traits, double yTarget) const\n>  {\n> -\tdouble yTarget = effectiveYTarget();\n>  \tdouble yGain = 1.0;\n>\n>  \t/*\n> @@ -671,6 +670,9 @@ utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue)\n>  /**\n>   * \\struct AgcMeanLuminance::Result\n>   * \\brief Collection of results of the mean luminance AGC algorithm\n> + *\n> + * \\var AgcMeanLuminance::Result::yTarget\n> + * \\brief The current y target including exposure compensation\n>   */\n>\n>  /**\n> @@ -694,6 +696,7 @@ AgcMeanLuminance::calculateNewEv(const Params &params)\n>  \t */\n>  \tExposureModeHelper &exposureModeHelper =\n>  \t\texposureModeHelpers_.at(params.exposureModeIndex);\n> +\tdouble yTarget = effectiveYTarget();\n>\n>  \tif (params.effectiveExposureValue == 0s) {\n>  \t\tLOG(AgcMeanLuminance, Error)\n> @@ -704,10 +707,10 @@ AgcMeanLuminance::calculateNewEv(const Params &params)\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), yTarget };\n>  \t}\n>\n> -\tdouble gain = estimateInitialGain(params.traits);\n> +\tdouble gain = estimateInitialGain(params.traits, yTarget);\n>  \tgain = constraintClampGain(params.constraintModeIndex, params.yHist, gain);\n>\n>  \t/*\n> @@ -726,7 +729,7 @@ AgcMeanLuminance::calculateNewEv(const Params &params)\n>  \tnewExposureValue = filterExposure(newExposureValue);\n>\n>  \tframeCount_++;\n> -\treturn { exposureModeHelper.splitExposure(newExposureValue) };\n> +\treturn { exposureModeHelper.splitExposure(newExposureValue), yTarget };\n>  }\n>\n>  /**\n> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\n> index aa4c0369ac..6418fe2e65 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.h\n> +++ b/src/ipa/libipa/agc_mean_luminance.h\n> @@ -87,6 +87,7 @@ public:\n>  \t};\n>\n>  \tstruct Result : ExposureModeHelper::Result {\n> +\t\tdouble yTarget;\n>  \t};\n>\n>  \t[[nodiscard]] Result calculateNewEv(const Params &params);\n> @@ -103,7 +104,7 @@ private:\n>  \tint parseConstraint(const ValueNode &modeDict, int32_t id);\n>  \tint parseConstraintModes(const ValueNode &tuningData);\n>  \tint parseExposureModes(const ValueNode &tuningData);\n> -\tdouble estimateInitialGain(const Traits &traits) const;\n> +\tdouble estimateInitialGain(const Traits &traits, double yTarget) const;\n>  \tdouble constraintClampGain(uint32_t constraintModeIndex,\n>  \t\t\t\t   const Histogram &hist,\n>  \t\t\t\t   double gain) const;\n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index a4567c8258..8ed9d7ea6d 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -741,7 +741,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\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> +\tactiveState.agc.automatic.yTarget = newEv.yTarget;\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> --\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 7D90DBDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2026 12:51:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1882267F0E;\n\tFri, 24 Jul 2026 14:51:32 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E239F67E89\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2026 14:51:30 +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 54229524;\n\tFri, 24 Jul 2026 14:50:29 +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=\"P62cgjQ4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1784897429;\n\tbh=ArFiPxx4nab9v5vwS+NyOgWzQcZnVGm4ogIQ579cfVM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=P62cgjQ4V2sp42z0AINWdPa6dcN0/BqTcSPW5kZxqLnM7guNhTp1AF7WKrCfCe2kN\n\tkfRh+Pdv3cxz8Ly/4bklm9h8z2n7MviAxPkfXe+MY3n6lvmMfPy4ce4uKf131Tu+kH\n\tF/706dRimMW472ZjTsPIwggSy6NHWcMMwMHfST88=","Date":"Fri, 24 Jul 2026 14:51:27 +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 17/43] ipa: libipa: agc_mean_luminance:\n\tcalculateNewEv(): Return y target","Message-ID":"<amNfuYSiUHP7WMFv@zed>","References":"<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>\n\t<20260723154327.1357866-18-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-18-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>"}},{"id":39831,"web_url":"https://patchwork.libcamera.org/comment/39831/","msgid":"<f02111fa-67ef-4a7a-83c2-38754cc94f72@ideasonboard.com>","date":"2026-07-24T13:08:06","subject":"Re: [RFC PATCH v2 17/43] ipa: libipa: agc_mean_luminance:\n\tcalculateNewEv(): Return y target","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 07. 24. 14:51 keltezéssel, Jacopo Mondi írta:\n> Hi Barnabás\n> \n> On Thu, Jul 23, 2026 at 05:43:00PM +0200, Barnabás Pőcze wrote:\n>> Return the current applicable y target as part of the result set.\n> \n> It would be nice to tell what it will be used for\n\nI have adjusted the text:\n\n   The rkisp1 agc algorithms needs to save the current y target for the\n   wdr algorithm. Instead of having to recalculate it, just return it\n   as part of the result set.\n\n\n> \n> Apart from that\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> \n>>\n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> ---\n>>   src/ipa/libipa/agc_mean_luminance.cpp | 13 ++++++++-----\n>>   src/ipa/libipa/agc_mean_luminance.h   |  3 ++-\n>>   src/ipa/rkisp1/algorithms/agc.cpp     |  2 +-\n>>   3 files changed, 11 insertions(+), 7 deletions(-)\n>>\n>> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n>> index 5e12c4b475..d25b1e8322 100644\n>> --- a/src/ipa/libipa/agc_mean_luminance.cpp\n>> +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n>> @@ -502,9 +502,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime,\n>>    * target\n>>    * \\return The calculated initial gain\n>>    */\n>> -double AgcMeanLuminance::estimateInitialGain(const Traits &traits) const\n>> +double AgcMeanLuminance::estimateInitialGain(const Traits &traits, double yTarget) const\n>>   {\n>> -\tdouble yTarget = effectiveYTarget();\n>>   \tdouble yGain = 1.0;\n>>\n>>   \t/*\n>> @@ -671,6 +670,9 @@ utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue)\n>>   /**\n>>    * \\struct AgcMeanLuminance::Result\n>>    * \\brief Collection of results of the mean luminance AGC algorithm\n>> + *\n>> + * \\var AgcMeanLuminance::Result::yTarget\n>> + * \\brief The current y target including exposure compensation\n>>    */\n>>\n>>   /**\n>> @@ -694,6 +696,7 @@ AgcMeanLuminance::calculateNewEv(const Params &params)\n>>   \t */\n>>   \tExposureModeHelper &exposureModeHelper =\n>>   \t\texposureModeHelpers_.at(params.exposureModeIndex);\n>> +\tdouble yTarget = effectiveYTarget();\n>>\n>>   \tif (params.effectiveExposureValue == 0s) {\n>>   \t\tLOG(AgcMeanLuminance, Error)\n>> @@ -704,10 +707,10 @@ AgcMeanLuminance::calculateNewEv(const Params &params)\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), yTarget };\n>>   \t}\n>>\n>> -\tdouble gain = estimateInitialGain(params.traits);\n>> +\tdouble gain = estimateInitialGain(params.traits, yTarget);\n>>   \tgain = constraintClampGain(params.constraintModeIndex, params.yHist, gain);\n>>\n>>   \t/*\n>> @@ -726,7 +729,7 @@ AgcMeanLuminance::calculateNewEv(const Params &params)\n>>   \tnewExposureValue = filterExposure(newExposureValue);\n>>\n>>   \tframeCount_++;\n>> -\treturn { exposureModeHelper.splitExposure(newExposureValue) };\n>> +\treturn { exposureModeHelper.splitExposure(newExposureValue), yTarget };\n>>   }\n>>\n>>   /**\n>> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\n>> index aa4c0369ac..6418fe2e65 100644\n>> --- a/src/ipa/libipa/agc_mean_luminance.h\n>> +++ b/src/ipa/libipa/agc_mean_luminance.h\n>> @@ -87,6 +87,7 @@ public:\n>>   \t};\n>>\n>>   \tstruct Result : ExposureModeHelper::Result {\n>> +\t\tdouble yTarget;\n>>   \t};\n>>\n>>   \t[[nodiscard]] Result calculateNewEv(const Params &params);\n>> @@ -103,7 +104,7 @@ private:\n>>   \tint parseConstraint(const ValueNode &modeDict, int32_t id);\n>>   \tint parseConstraintModes(const ValueNode &tuningData);\n>>   \tint parseExposureModes(const ValueNode &tuningData);\n>> -\tdouble estimateInitialGain(const Traits &traits) const;\n>> +\tdouble estimateInitialGain(const Traits &traits, double yTarget) const;\n>>   \tdouble constraintClampGain(uint32_t constraintModeIndex,\n>>   \t\t\t\t   const Histogram &hist,\n>>   \t\t\t\t   double gain) const;\n>> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n>> index a4567c8258..8ed9d7ea6d 100644\n>> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n>> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n>> @@ -741,7 +741,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\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>> +\tactiveState.agc.automatic.yTarget = newEv.yTarget;\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>> --\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 A4560BDE17\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2026 13:08:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DDCB967F0A;\n\tFri, 24 Jul 2026 15:08:11 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E81A267E89\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2026 15:08:09 +0200 (CEST)","from [192.168.33.42] (185.182.215.156.nat.pool.zt.hu\n\t[185.182.215.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3D0B473B;\n\tFri, 24 Jul 2026 15:07:08 +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=\"MEZ/bW/I\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1784898428;\n\tbh=q4a0VYkrp4ar4ctUE+M8r9bP8xQ0IcupFuXeuwQc1uA=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=MEZ/bW/IlxkvktjHdmFkktjCFv8gDCoZOIabzVQW5N0XP+PhdYDaABarkGX/aMJpO\n\tUNRQs3L4WAzm+rzXpxww9aoBVczJrXV/m25V6VTcLwpDHsREpSzgRDZkDaHIcznacd\n\tRYu3PZLrkXigurl0FP9E7EeBfFrn2O7rysbxy94A=","Message-ID":"<f02111fa-67ef-4a7a-83c2-38754cc94f72@ideasonboard.com>","Date":"Fri, 24 Jul 2026 15:08:06 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [RFC PATCH v2 17/43] ipa: libipa: agc_mean_luminance:\n\tcalculateNewEv(): Return y target","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20260723154327.1357866-1-barnabas.pocze@ideasonboard.com>\n\t<20260723154327.1357866-18-barnabas.pocze@ideasonboard.com>\n\t<amNfuYSiUHP7WMFv@zed>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<amNfuYSiUHP7WMFv@zed>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}}]