[{"id":29671,"web_url":"https://patchwork.libcamera.org/comment/29671/","msgid":"<ZleE2qlZpw1Qaqy7@pyrite.rasen.tech>","date":"2024-05-29T19:41:14","subject":"Re: [PATCH v2] ipa: libipa: Change constraint Y target to piecewise\n\tlinear function","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Thu, May 30, 2024 at 04:33:22AM +0900, Paul Elder wrote:\n> Change the constraint luminance target from a scalar value to a\n> piecewise linear function that needs to be sampled by the estimated lux\n> value.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n\nI forgot to mention that this patch also depends on v3 of the series\n\"ipa: Move Pwl from Raspberry Pi\"\n\n\nPaul\n\n> Changes in v2:\n> - s/FPoint/PointF/\n> - construct default Pwl with *two* points so that it actually constructs\n>   properly\n> ---\n>  src/ipa/libipa/agc_mean_luminance.cpp | 15 +++++++++------\n>  src/ipa/libipa/agc_mean_luminance.h   |  4 ++--\n>  2 files changed, 11 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n> index 5b79d5d59..5eaa86c82 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.cpp\n> +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n> @@ -168,8 +168,10 @@ void AgcMeanLuminance::parseConstraint(const YamlObject &modeDict, int32_t id)\n>  \t\tAgcConstraint::Bound bound = static_cast<AgcConstraint::Bound>(idx);\n>  \t\tdouble qLo = content[\"qLo\"].get<double>().value_or(0.98);\n>  \t\tdouble qHi = content[\"qHi\"].get<double>().value_or(1.0);\n> -\t\tdouble yTarget =\n> -\t\t\tcontent[\"yTarget\"].getList<double>().value_or(std::vector<double>{ 0.5 }).at(0);\n> +\t\tPwl yTarget;\n> +\t\tint ret = yTarget.readYaml(content[\"yTarget\"]);\n> +\t\tif (ret < 0)\n> +\t\t\tyTarget = Pwl({ PointF(0, 0.5), PointF(1000, 0.5) });\n>  \n>  \t\tAgcConstraint constraint = { bound, qLo, qHi, yTarget };\n>  \n> @@ -221,7 +223,7 @@ int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData)\n>  \t\t\tAgcConstraint::Bound::lower,\n>  \t\t\t0.98,\n>  \t\t\t1.0,\n> -\t\t\t0.5\n> +\t\t\tPwl({ PointF(0, 0.5), PointF(1000, 0.5) })\n>  \t\t};\n>  \n>  \t\tconstraintModes_[controls::ConstraintNormal].insert(\n> @@ -471,16 +473,17 @@ double AgcMeanLuminance::estimateInitialGain(double lux) const\n>   * \\param[in] constraintModeIndex The index of the constraint to adhere to\n>   * \\param[in] hist A histogram over which to calculate inter-quantile means\n>   * \\param[in] gain The gain to clamp\n> + * \\param[in] lux The lux value at which to sample the constraint luminance target pwl\n>   *\n>   * \\return The gain clamped within the constraint bounds\n>   */\n>  double AgcMeanLuminance::constraintClampGain(uint32_t constraintModeIndex,\n>  \t\t\t\t\t     const Histogram &hist,\n> -\t\t\t\t\t     double gain)\n> +\t\t\t\t\t     double gain, double lux)\n>  {\n>  \tstd::vector<AgcConstraint> &constraints = constraintModes_[constraintModeIndex];\n>  \tfor (const AgcConstraint &constraint : constraints) {\n> -\t\tdouble newGain = constraint.yTarget * hist.bins() /\n> +\t\tdouble newGain = constraint.yTarget.eval(constraint.yTarget.domain().clamp(lux)) * hist.bins() /\n>  \t\t\t\t hist.interQuantileMean(constraint.qLo, constraint.qHi);\n>  \n>  \t\tif (constraint.bound == AgcConstraint::Bound::lower &&\n> @@ -559,7 +562,7 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n>  \t\texposureModeHelpers_.at(exposureModeIndex);\n>  \n>  \tdouble gain = estimateInitialGain(lux);\n> -\tgain = constraintClampGain(constraintModeIndex, yHist, gain);\n> +\tgain = constraintClampGain(constraintModeIndex, yHist, gain, lux);\n>  \n>  \t/*\n>  \t * We don't check whether we're already close to the target, because\n> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\n> index 6ec2a0dc9..d43f673dd 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.h\n> +++ b/src/ipa/libipa/agc_mean_luminance.h\n> @@ -38,7 +38,7 @@ public:\n>  \t\tBound bound;\n>  \t\tdouble qLo;\n>  \t\tdouble qHi;\n> -\t\tdouble yTarget;\n> +\t\tPwl yTarget;\n>  \t};\n>  \n>  \tint parseTuningData(const YamlObject &tuningData);\n> @@ -80,7 +80,7 @@ private:\n>  \tdouble estimateInitialGain(double lux) const;\n>  \tdouble constraintClampGain(uint32_t constraintModeIndex,\n>  \t\t\t\t   const Histogram &hist,\n> -\t\t\t\t   double gain);\n> +\t\t\t\t   double gain, double lux);\n>  \tutils::Duration filterExposure(utils::Duration exposureValue);\n>  \n>  \tuint64_t frameCount_;\n> -- \n> 2.39.2\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 9864EBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 May 2024 19:41:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8B787634B7;\n\tWed, 29 May 2024 21:41:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 678206347E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 21:41:21 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CDF74149B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 May 2024 21:41:16 +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=\"gK5IMXIo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717011677;\n\tbh=PX+7vx9FuqjsicaETfNPgayL2tMFTlVf0MXhJFigNLQ=;\n\th=Date:From:To:Subject:References:In-Reply-To:From;\n\tb=gK5IMXIoQkMrsycfsuHM8HOBFed/7q2gFb0wK1AXn3xkJlnXs4P1kRdv1aMu5eh7t\n\t0lawZtVpPju+JwaemSdJGPfNM+4URVhpPUU5YhZUZLstacjDYDDV1qXQzPAjjjkwwH\n\tIj+Oo47nFUSdbJ+MoxY65YkHJP8zBkgE93jWFTrY=","Date":"Thu, 30 May 2024 04:41:14 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2] ipa: libipa: Change constraint Y target to piecewise\n\tlinear function","Message-ID":"<ZleE2qlZpw1Qaqy7@pyrite.rasen.tech>","References":"<20240529193322.835594-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240529193322.835594-1-paul.elder@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":29753,"web_url":"https://patchwork.libcamera.org/comment/29753/","msgid":"<171741745864.2248009.525608196154206173@ping.linuxembedded.co.uk>","date":"2024-06-03T12:24:18","subject":"Re: [PATCH v2] ipa: libipa: Change constraint Y target to piecewise\n\tlinear function","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Paul Elder (2024-05-29 20:33:22)\n> Change the constraint luminance target from a scalar value to a\n> piecewise linear function that needs to be sampled by the estimated lux\n> value.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v2:\n> - s/FPoint/PointF/\n> - construct default Pwl with *two* points so that it actually constructs\n>   properly\n> ---\n>  src/ipa/libipa/agc_mean_luminance.cpp | 15 +++++++++------\n>  src/ipa/libipa/agc_mean_luminance.h   |  4 ++--\n>  2 files changed, 11 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n> index 5b79d5d59..5eaa86c82 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.cpp\n> +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n> @@ -168,8 +168,10 @@ void AgcMeanLuminance::parseConstraint(const YamlObject &modeDict, int32_t id)\n>                 AgcConstraint::Bound bound = static_cast<AgcConstraint::Bound>(idx);\n>                 double qLo = content[\"qLo\"].get<double>().value_or(0.98);\n>                 double qHi = content[\"qHi\"].get<double>().value_or(1.0);\n> -               double yTarget =\n> -                       content[\"yTarget\"].getList<double>().value_or(std::vector<double>{ 0.5 }).at(0);\n> +               Pwl yTarget;\n> +               int ret = yTarget.readYaml(content[\"yTarget\"]);\n> +               if (ret < 0)\n> +                       yTarget = Pwl({ PointF(0, 0.5), PointF(1000, 0.5) });\n\nIs the 'length' of the Pwl arbitrary? Does it extend if we go above\n'1000' here? From this snipped/hunk - I don't know what units/reference\n0 and 1000 are? Is it the lux value?\n\nCan any reasoning for 0...1000 be documented? I assume 0.5 is just 'half\nbrightness target' if that's sufficiently self explanatory then fine -\nbut even that might warrant a couple of words in why it's chosen?\n\nGoogling lux levels tells me:\n\n- Direct Sunlight\t32,000 to 100,000\n- Ambient Daylight\t10,000 to 25,000\n- Overcast Daylight\t1000\n- Sunset & Sunrise\t400\n\nDoes that impact the choice of '1000' here? As the two points make a\nlinear that will always return 0.5 - I assume it doesn't matter here,\nand\n\n  Pwl({ PointF(0, 0.5), PointF(1, 0.5) });\n\nwould also have been equivalent ?\n\n>  \n>                 AgcConstraint constraint = { bound, qLo, qHi, yTarget };\n>  \n> @@ -221,7 +223,7 @@ int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData)\n>                         AgcConstraint::Bound::lower,\n>                         0.98,\n>                         1.0,\n> -                       0.5\n> +                       Pwl({ PointF(0, 0.5), PointF(1000, 0.5) })\n\nShould this be some pre-constructed global const if it's going to be\nused in multiple places?\n\n\n>                 };\n>  \n>                 constraintModes_[controls::ConstraintNormal].insert(\n> @@ -471,16 +473,17 @@ double AgcMeanLuminance::estimateInitialGain(double lux) const\n>   * \\param[in] constraintModeIndex The index of the constraint to adhere to\n>   * \\param[in] hist A histogram over which to calculate inter-quantile means\n>   * \\param[in] gain The gain to clamp\n> + * \\param[in] lux The lux value at which to sample the constraint luminance target pwl\n>   *\n>   * \\return The gain clamped within the constraint bounds\n>   */\n>  double AgcMeanLuminance::constraintClampGain(uint32_t constraintModeIndex,\n>                                              const Histogram &hist,\n> -                                            double gain)\n> +                                            double gain, double lux)\n>  {\n>         std::vector<AgcConstraint> &constraints = constraintModes_[constraintModeIndex];\n>         for (const AgcConstraint &constraint : constraints) {\n> -               double newGain = constraint.yTarget * hist.bins() /\n> +               double newGain = constraint.yTarget.eval(constraint.yTarget.domain().clamp(lux)) * hist.bins() /\n>                                  hist.interQuantileMean(constraint.qLo, constraint.qHi);\n>  \n>                 if (constraint.bound == AgcConstraint::Bound::lower &&\n> @@ -559,7 +562,7 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n>                 exposureModeHelpers_.at(exposureModeIndex);\n>  \n>         double gain = estimateInitialGain(lux);\n> -       gain = constraintClampGain(constraintModeIndex, yHist, gain);\n> +       gain = constraintClampGain(constraintModeIndex, yHist, gain, lux);\n>  \n>         /*\n>          * We don't check whether we're already close to the target, because\n> diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\n> index 6ec2a0dc9..d43f673dd 100644\n> --- a/src/ipa/libipa/agc_mean_luminance.h\n> +++ b/src/ipa/libipa/agc_mean_luminance.h\n> @@ -38,7 +38,7 @@ public:\n>                 Bound bound;\n>                 double qLo;\n>                 double qHi;\n> -               double yTarget;\n> +               Pwl yTarget;\n>         };\n>  \n>         int parseTuningData(const YamlObject &tuningData);\n> @@ -80,7 +80,7 @@ private:\n>         double estimateInitialGain(double lux) const;\n>         double constraintClampGain(uint32_t constraintModeIndex,\n>                                    const Histogram &hist,\n> -                                  double gain);\n> +                                  double gain, double lux);\n>         utils::Duration filterExposure(utils::Duration exposureValue);\n>  \n>         uint64_t frameCount_;\n> -- \n> 2.39.2\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 B862DBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  3 Jun 2024 12:24:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C25F8634CA;\n\tMon,  3 Jun 2024 14:24:22 +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 787C461A3B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  3 Jun 2024 14:24:21 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F2A3A38;\n\tMon,  3 Jun 2024 14:24:14 +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=\"ApET6Spj\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717417454;\n\tbh=Mj/Ug6oEqfx4LATT1RZKDhtDM6dxtanuMUMvEIUovpA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ApET6SpjqDTjmBp+mT4j+YG+jpPzJ3v25ZmodGKrjrbIOfhRMF0/DLOPF3ctxYfeO\n\t3wUDDEYLzGBJgVhA7nKtZ5wbvK9DzuYS6jFhjAjkqCvcTQCPMc0XWdryF6BGi5Kzkc\n\tml8PRciG4r6D1PzJGLVxdXZll1SfQdbHx0IK8wFk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240529193322.835594-1-paul.elder@ideasonboard.com>","References":"<20240529193322.835594-1-paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v2] ipa: libipa: Change constraint Y target to piecewise\n\tlinear function","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 03 Jun 2024 13:24:18 +0100","Message-ID":"<171741745864.2248009.525608196154206173@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":29779,"web_url":"https://patchwork.libcamera.org/comment/29779/","msgid":"<ZmA3HEW7YAIsk3oS@pyrite.rasen.tech>","date":"2024-06-05T09:59:56","subject":"Re: [PATCH v2] ipa: libipa: Change constraint Y target to piecewise\n\tlinear function","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Mon, Jun 03, 2024 at 01:24:18PM +0100, Kieran Bingham wrote:\n> Quoting Paul Elder (2024-05-29 20:33:22)\n> > Change the constraint luminance target from a scalar value to a\n> > piecewise linear function that needs to be sampled by the estimated lux\n> > value.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > \n> > ---\n> > Changes in v2:\n> > - s/FPoint/PointF/\n> > - construct default Pwl with *two* points so that it actually constructs\n> >   properly\n> > ---\n> >  src/ipa/libipa/agc_mean_luminance.cpp | 15 +++++++++------\n> >  src/ipa/libipa/agc_mean_luminance.h   |  4 ++--\n> >  2 files changed, 11 insertions(+), 8 deletions(-)\n> > \n> > diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\n> > index 5b79d5d59..5eaa86c82 100644\n> > --- a/src/ipa/libipa/agc_mean_luminance.cpp\n> > +++ b/src/ipa/libipa/agc_mean_luminance.cpp\n> > @@ -168,8 +168,10 @@ void AgcMeanLuminance::parseConstraint(const YamlObject &modeDict, int32_t id)\n> >                 AgcConstraint::Bound bound = static_cast<AgcConstraint::Bound>(idx);\n> >                 double qLo = content[\"qLo\"].get<double>().value_or(0.98);\n> >                 double qHi = content[\"qHi\"].get<double>().value_or(1.0);\n> > -               double yTarget =\n> > -                       content[\"yTarget\"].getList<double>().value_or(std::vector<double>{ 0.5 }).at(0);\n> > +               Pwl yTarget;\n> > +               int ret = yTarget.readYaml(content[\"yTarget\"]);\n> > +               if (ret < 0)\n> > +                       yTarget = Pwl({ PointF(0, 0.5), PointF(1000, 0.5) });\n> \n> Is the 'length' of the Pwl arbitrary? Does it extend if we go above\n> '1000' here? From this snipped/hunk - I don't know what units/reference\n> 0 and 1000 are? Is it the lux value?\n> \n> Can any reasoning for 0...1000 be documented? I assume 0.5 is just 'half\n> brightness target' if that's sufficiently self explanatory then fine -\n> but even that might warrant a couple of words in why it's chosen?\n> \n> Googling lux levels tells me:\n> \n> - Direct Sunlight\t32,000 to 100,000\n> - Ambient Daylight\t10,000 to 25,000\n> - Overcast Daylight\t1000\n> - Sunset & Sunrise\t400\n> \n> Does that impact the choice of '1000' here? As the two points make a\n> linear that will always return 0.5 - I assume it doesn't matter here,\n> and\n> \n>   Pwl({ PointF(0, 0.5), PointF(1, 0.5) });\n> \n> would also have been equivalent ?\n\nYes it would be. Since this is a constant function, the input doesn't\nmatter and extrapolation and clamping are equivalent.\n\n> \n> >  \n> >                 AgcConstraint constraint = { bound, qLo, qHi, yTarget };\n> >  \n> > @@ -221,7 +223,7 @@ int AgcMeanLuminance::parseConstraintModes(const YamlObject &tuningData)\n> >                         AgcConstraint::Bound::lower,\n> >                         0.98,\n> >                         1.0,\n> > -                       0.5\n> > +                       Pwl({ PointF(0, 0.5), PointF(1000, 0.5) })\n> \n> Should this be some pre-constructed global const if it's going to be\n> used in multiple places?\n\nProbably? It's used three times; twice here and once more for\nrelativeLuminance.\n\n\nPaul\n\n> \n> \n> >                 };\n> >  \n> >                 constraintModes_[controls::ConstraintNormal].insert(\n> > @@ -471,16 +473,17 @@ double AgcMeanLuminance::estimateInitialGain(double lux) const\n> >   * \\param[in] constraintModeIndex The index of the constraint to adhere to\n> >   * \\param[in] hist A histogram over which to calculate inter-quantile means\n> >   * \\param[in] gain The gain to clamp\n> > + * \\param[in] lux The lux value at which to sample the constraint luminance target pwl\n> >   *\n> >   * \\return The gain clamped within the constraint bounds\n> >   */\n> >  double AgcMeanLuminance::constraintClampGain(uint32_t constraintModeIndex,\n> >                                              const Histogram &hist,\n> > -                                            double gain)\n> > +                                            double gain, double lux)\n> >  {\n> >         std::vector<AgcConstraint> &constraints = constraintModes_[constraintModeIndex];\n> >         for (const AgcConstraint &constraint : constraints) {\n> > -               double newGain = constraint.yTarget * hist.bins() /\n> > +               double newGain = constraint.yTarget.eval(constraint.yTarget.domain().clamp(lux)) * hist.bins() /\n> >                                  hist.interQuantileMean(constraint.qLo, constraint.qHi);\n> >  \n> >                 if (constraint.bound == AgcConstraint::Bound::lower &&\n> > @@ -559,7 +562,7 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n> >                 exposureModeHelpers_.at(exposureModeIndex);\n> >  \n> >         double gain = estimateInitialGain(lux);\n> > -       gain = constraintClampGain(constraintModeIndex, yHist, gain);\n> > +       gain = constraintClampGain(constraintModeIndex, yHist, gain, lux);\n> >  \n> >         /*\n> >          * We don't check whether we're already close to the target, because\n> > diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h\n> > index 6ec2a0dc9..d43f673dd 100644\n> > --- a/src/ipa/libipa/agc_mean_luminance.h\n> > +++ b/src/ipa/libipa/agc_mean_luminance.h\n> > @@ -38,7 +38,7 @@ public:\n> >                 Bound bound;\n> >                 double qLo;\n> >                 double qHi;\n> > -               double yTarget;\n> > +               Pwl yTarget;\n> >         };\n> >  \n> >         int parseTuningData(const YamlObject &tuningData);\n> > @@ -80,7 +80,7 @@ private:\n> >         double estimateInitialGain(double lux) const;\n> >         double constraintClampGain(uint32_t constraintModeIndex,\n> >                                    const Histogram &hist,\n> > -                                  double gain);\n> > +                                  double gain, double lux);\n> >         utils::Duration filterExposure(utils::Duration exposureValue);\n> >  \n> >         uint64_t frameCount_;\n> > -- \n> > 2.39.2\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 62F7BBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Jun 2024 10:00:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D743B65442;\n\tWed,  5 Jun 2024 12:00:05 +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 256C46543B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jun 2024 12:00:04 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-156.catv02.itscom.jp\n\t[175.177.49.156])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C7C5E14B0;\n\tWed,  5 Jun 2024 11:59:54 +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=\"H/K+FEmp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1717581595;\n\tbh=OY4jFOFtpkwiRH/vedbcQnd+m2cpN3eRnBg6ZRZEEKI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=H/K+FEmpjyhjPEaCmvUnE+yO4v09ulfiWGhTIWZ/+vwz7RTuFVeglobs+JFLnEp3u\n\tJQfh1tpgwGesBumZCxm1Wa03b5OXEcjs8DNTdazLMwr06auv6d6xSdf0EesxjKXGfA\n\tlzVf6EArRUT3gAg/TJNgO2wCmSGEBOnQqHMqDJGY=","Date":"Wed, 5 Jun 2024 18:59:56 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2] ipa: libipa: Change constraint Y target to piecewise\n\tlinear function","Message-ID":"<ZmA3HEW7YAIsk3oS@pyrite.rasen.tech>","References":"<20240529193322.835594-1-paul.elder@ideasonboard.com>\n\t<171741745864.2248009.525608196154206173@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<171741745864.2248009.525608196154206173@ping.linuxembedded.co.uk>","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>"}}]