[{"id":20201,"web_url":"https://patchwork.libcamera.org/comment/20201/","msgid":"<163421005144.3829429.16301359406188619093@Monstersaurus>","date":"2021-10-14T11:14:11","subject":"Re: [libcamera-devel] [PATCH 09/13] ipa: ipu3: agc: Rename gains\n\tproperly","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jean-Michel Hautbois (2021-10-13 16:41:21)\n> We have mixed terms between gain, analogue gain and the exposure value\n> gain.\n> \n> Makes it clear when we are using the analogue gain from the sensor, and\n\ns/Makes/Make/\n\n> when we are using the calculated gain to be applied to the exposure\n> value to reach the target.\n> \n\nSounds helpful to me.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 17 +++++++++--------\n>  1 file changed, 9 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 3ec1c60c..bd28998a 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -123,7 +123,7 @@ void Agc::filterExposure()\n>         LOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << filteredExposure_;\n>  }\n>  \n> -void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n> +void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)\n>  {\n>         /* Algorithm initialization should wait for first valid frames */\n>         /* \\todo - have a number of frames given by DelayedControls ?\n> @@ -135,16 +135,17 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n>         if (std::abs(iqMean_ - kEvGainTarget * knumHistogramBins) <= 1) {\n>                 LOG(IPU3Agc, Debug) << \"!!! Good exposure with iqMean = \" << iqMean_;\n>         } else {\n> -               double newGain = kEvGainTarget * knumHistogramBins / iqMean_;\n> +               double evGain = kEvGainTarget * knumHistogramBins / iqMean_;\n>  \n>                 /* extracted from Rpi::Agc::computeTargetExposure */\n>                 Duration currentShutter = exposure * lineDuration_;\n> -               currentExposureNoDg_ = currentShutter * gain;\n> +               currentExposureNoDg_ = currentShutter * analogueGain;\n>                 LOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentExposureNoDg_\n>                                     << \" Shutter speed \" << currentShutter\n> -                                   << \" Gain \" << gain;\n> +                                   << \" Gain \" << analogueGain\n> +                                   << \" Needed ev gain \" << evGain;\n>  \n> -               currentExposure_ = currentExposureNoDg_ * newGain;\n> +               currentExposure_ = currentExposureNoDg_ * evGain;\n>                 Duration maxTotalExposure = kMaxShutterSpeed * kMaxGain;\n>                 currentExposure_ = std::min(currentExposure_, maxTotalExposure);\n>                 LOG(IPU3Agc, Debug) << \"Target total exposure \" << currentExposure_\n> @@ -180,7 +181,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n>                                 << stepGain;\n>  \n>                 exposure = shutterTime / lineDuration_;\n> -               gain = stepGain;\n> +               analogueGain = stepGain;\n>         }\n>         lastFrame_ = frameCount_;\n>  }\n> @@ -188,9 +189,9 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n>  void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  {\n>         uint32_t &exposure = context.frameContext.agc.exposure;\n> -       double &gain = context.frameContext.agc.gain;\n> +       double &analogueGain = context.frameContext.agc.gain;\n>         processBrightness(stats, context.configuration.grid.bdsGrid);\n> -       lockExposureGain(exposure, gain);\n> +       lockExposureGain(exposure, analogueGain);\n>         frameCount_++;\n>  }\n>  \n> -- \n> 2.30.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 7A0D3C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Oct 2021 11:14:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8F3D68F4D;\n\tThu, 14 Oct 2021 13:14:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D9D8668541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 13:14:13 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 745A02F3;\n\tThu, 14 Oct 2021 13:14:13 +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=\"T4TqhM9L\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634210053;\n\tbh=uaDz96TBVpMn4eKRNZOwOySl2xymOcBwhnQuUupFSKw=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=T4TqhM9LXyTBMbF/mVA7oCiQ1diUy3Sto2bul+81D9SbR1ktdKPc/wEHGboPQgt+6\n\t7L1kszeaMba16r/tBkXBZvv+miZTw3J4FzL0IBePKHPwHEUGGO8za6LxpwwA/SBDAc\n\t8OF9Tlv+XGD/VWG7MRbZ8k5lNG/wbsAF83ehrOvQ=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211013154125.133419-10-jeanmichel.hautbois@ideasonboard.com>","References":"<20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211013154125.133419-10-jeanmichel.hautbois@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 14 Oct 2021 12:14:11 +0100","Message-ID":"<163421005144.3829429.16301359406188619093@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH 09/13] ipa: ipu3: agc: Rename gains\n\tproperly","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":20219,"web_url":"https://patchwork.libcamera.org/comment/20219/","msgid":"<YWjWYzKAgg8s2fH1@pendragon.ideasonboard.com>","date":"2021-10-15T01:16:19","subject":"Re: [libcamera-devel] [PATCH 09/13] ipa: ipu3: agc: Rename gains\n\tproperly","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nThank you for the patch.\n\nOn Wed, Oct 13, 2021 at 05:41:21PM +0200, Jean-Michel Hautbois wrote:\n> We have mixed terms between gain, analogue gain and the exposure value\n> gain.\n> \n> Makes it clear when we are using the analogue gain from the sensor, and\n> when we are using the calculated gain to be applied to the exposure\n> value to reach the target.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 17 +++++++++--------\n>  1 file changed, 9 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 3ec1c60c..bd28998a 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -123,7 +123,7 @@ void Agc::filterExposure()\n>  \tLOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << filteredExposure_;\n>  }\n>  \n> -void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n> +void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)\n>  {\n>  \t/* Algorithm initialization should wait for first valid frames */\n>  \t/* \\todo - have a number of frames given by DelayedControls ?\n> @@ -135,16 +135,17 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n>  \tif (std::abs(iqMean_ - kEvGainTarget * knumHistogramBins) <= 1) {\n>  \t\tLOG(IPU3Agc, Debug) << \"!!! Good exposure with iqMean = \" << iqMean_;\n>  \t} else {\n> -\t\tdouble newGain = kEvGainTarget * knumHistogramBins / iqMean_;\n> +\t\tdouble evGain = kEvGainTarget * knumHistogramBins / iqMean_;\n>  \n>  \t\t/* extracted from Rpi::Agc::computeTargetExposure */\n>  \t\tDuration currentShutter = exposure * lineDuration_;\n> -\t\tcurrentExposureNoDg_ = currentShutter * gain;\n> +\t\tcurrentExposureNoDg_ = currentShutter * analogueGain;\n>  \t\tLOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentExposureNoDg_\n>  \t\t\t\t    << \" Shutter speed \" << currentShutter\n> -\t\t\t\t    << \" Gain \" << gain;\n> +\t\t\t\t    << \" Gain \" << analogueGain\n> +\t\t\t\t    << \" Needed ev gain \" << evGain;\n>  \n> -\t\tcurrentExposure_ = currentExposureNoDg_ * newGain;\n> +\t\tcurrentExposure_ = currentExposureNoDg_ * evGain;\n>  \t\tDuration maxTotalExposure = kMaxShutterSpeed * kMaxGain;\n>  \t\tcurrentExposure_ = std::min(currentExposure_, maxTotalExposure);\n>  \t\tLOG(IPU3Agc, Debug) << \"Target total exposure \" << currentExposure_\n> @@ -180,7 +181,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n>  \t\t\t\t<< stepGain;\n>  \n>  \t\texposure = shutterTime / lineDuration_;\n> -\t\tgain = stepGain;\n> +\t\tanalogueGain = stepGain;\n>  \t}\n>  \tlastFrame_ = frameCount_;\n>  }\n> @@ -188,9 +189,9 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n>  void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)\n>  {\n>  \tuint32_t &exposure = context.frameContext.agc.exposure;\n> -\tdouble &gain = context.frameContext.agc.gain;\n> +\tdouble &analogueGain = context.frameContext.agc.gain;\n>  \tprocessBrightness(stats, context.configuration.grid.bdsGrid);\n> -\tlockExposureGain(exposure, gain);\n> +\tlockExposureGain(exposure, analogueGain);\n>  \tframeCount_++;\n>  }\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 A40B9C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Oct 2021 01:16:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1328168F50;\n\tFri, 15 Oct 2021 03:16:36 +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 2F92568F4D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 03:16:35 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 923262E3;\n\tFri, 15 Oct 2021 03:16:34 +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=\"X9E3a3jS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634260594;\n\tbh=P7d9gTxl01+CHEQE0H6nI6qm0BaK1oua/h+zylmCnOM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=X9E3a3jS5T2yEOOO5PZRCOVawgJUF7EILYBIjdRUNGCFl4TE/UwoqhUGnAt7WPlCn\n\twasu3OJT5Tw/0GrpqfOG3IPmkyi6ic2CTAxHaxGMDiULzYVdfA/XJ4dzB+f0LNLV+i\n\tHEHnVYvkogAevc58BtYUK69XEvBmawIDnOYut4GU=","Date":"Fri, 15 Oct 2021 04:16:19 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YWjWYzKAgg8s2fH1@pendragon.ideasonboard.com>","References":"<20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211013154125.133419-10-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211013154125.133419-10-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 09/13] ipa: ipu3: agc: Rename gains\n\tproperly","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]