[{"id":20206,"web_url":"https://patchwork.libcamera.org/comment/20206/","msgid":"<163421161222.3829429.13959844115431747310@Monstersaurus>","date":"2021-10-14T11:40:12","subject":"Re: [libcamera-devel] [PATCH 13/13] ipa: ipu3: agc: Remove unused\n\tvariables","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:25)\n> We currently control the exposure value by the shutter speed and the\n> analogue gain. We can't use the digital gain to have more than the\n> maximum exposure value calculated because we are not controlling it.\n\nDo you mean, because we are not setting the digital gain in the ISP?\n\n\n> Remove unused code associated with this digital gain.\n\nIf it's unused, I'm happy to see it go, and the code simplified ;-)\n\nUnless you think we should be adding the plumbing to allow setting the\ndigital gain on the ISP:\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 | 19 +++----------------\n>  src/ipa/ipu3/algorithms/agc.h   |  2 --\n>  2 files changed, 3 insertions(+), 18 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 81eaf436..0177bb92 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -46,8 +46,7 @@ static constexpr double kEvGainTarget = 0.5;\n>  Agc::Agc()\n>         : frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n>           minExposureLines_(0), maxExposureLines_(0), filteredExposure_(0s),\n> -         filteredExposureNoDg_(0s), currentExposure_(0s),\n> -         currentExposureNoDg_(0s), prevExposureValue(0s)\n> +         currentExposure_(0s), prevExposureValue(0s)\n>  {\n>  }\n>  \n> @@ -96,7 +95,6 @@ void Agc::filterExposure()\n>         if (filteredExposure_ == 0s) {\n>                 /* DG stands for digital gain.*/\n>                 filteredExposure_ = currentExposure_;\n> -               filteredExposureNoDg_ = currentExposureNoDg_;\n>         } else {\n>                 /*\n>                  * If we are close to the desired result, go faster to avoid making\n> @@ -109,18 +107,8 @@ void Agc::filterExposure()\n>  \n>                 filteredExposure_ = speed * currentExposure_ +\n>                                 filteredExposure_ * (1.0 - speed);\n> -               filteredExposureNoDg_ = speed * currentExposureNoDg_ +\n> -                               filteredExposureNoDg_ * (1.0 - speed);\n>         }\n> -       /*\n> -        * We can't let the no_dg exposure deviate too far below the\n> -        * total exposure, as there might not be enough digital gain available\n> -        * in the ISP to hide it (which will cause nasty oscillation).\n> -        */\n> -       double fastReduceThreshold = 0.4;\n> -       if (filteredExposureNoDg_ <\n> -           filteredExposure_ * fastReduceThreshold)\n> -               filteredExposureNoDg_ = filteredExposure_ * fastReduceThreshold;\n> +\n>         LOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << filteredExposure_;\n>  }\n>  \n> @@ -136,8 +124,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)\n>  \n>         /* extracted from Rpi::Agc::computeTargetExposure */\n>         Duration currentShutter = exposure * lineDuration_;\n> -       currentExposureNoDg_ = currentShutter * analogueGain;\n> -       LOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentExposureNoDg_\n> +       LOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentShutter * analogueGain\n>                                 << \" Shutter speed \" << currentShutter\n>                                 << \" Gain \" << analogueGain\n>                                 << \" Needed ev gain \" << evGain;\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 32817c4f..5b34c013 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -48,9 +48,7 @@ private:\n>         uint32_t maxExposureLines_;\n>  \n>         Duration filteredExposure_;\n> -       Duration filteredExposureNoDg_;\n>         Duration currentExposure_;\n> -       Duration currentExposureNoDg_;\n>         Duration prevExposureValue;\n>  \n>         uint32_t stride_;\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 DF975C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Oct 2021 11:40:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A06A68F4F;\n\tThu, 14 Oct 2021 13:40:16 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1610868541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 13:40:15 +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 BABB62F3;\n\tThu, 14 Oct 2021 13:40: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=\"Pc84H3zE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634211614;\n\tbh=t1s3G24lTXSx0MCkY367c+84vwGS3+yWvOZ9IeodFOY=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=Pc84H3zEw9sX7h3xGDuesweU+twg7O9B0NrnMC4U0Y+ooFhY96SA/u+h2RiZqm/wY\n\tcZqz8+jXKGlc6r+LUv5TQzo3Bq0LzffbjnvdJuW4UButPnXknEk9o6qwK2PmRMUviZ\n\tKCO8UTQOFJcIx/XsOth/xKhfThWgMIsFLNEKzrok=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211013154125.133419-14-jeanmichel.hautbois@ideasonboard.com>","References":"<20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211013154125.133419-14-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:40:12 +0100","Message-ID":"<163421161222.3829429.13959844115431747310@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH 13/13] ipa: ipu3: agc: Remove unused\n\tvariables","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":20223,"web_url":"https://patchwork.libcamera.org/comment/20223/","msgid":"<YWjb8r/MYnQDK7iX@pendragon.ideasonboard.com>","date":"2021-10-15T01:40:02","subject":"Re: [libcamera-devel] [PATCH 13/13] ipa: ipu3: agc: Remove unused\n\tvariables","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Oct 14, 2021 at 12:40:12PM +0100, Kieran Bingham wrote:\n> Quoting Jean-Michel Hautbois (2021-10-13 16:41:25)\n> > We currently control the exposure value by the shutter speed and the\n> > analogue gain. We can't use the digital gain to have more than the\n> > maximum exposure value calculated because we are not controlling it.\n> \n> Do you mean, because we are not setting the digital gain in the ISP?\n> \n> > Remove unused code associated with this digital gain.\n> \n> If it's unused, I'm happy to see it go, and the code simplified ;-)\n> \n> Unless you think we should be adding the plumbing to allow setting the\n> digital gain on the ISP:\n\nI think we should do so eventually, yes. We can simplify the code in the\nmeantime, but it will be an important improvement for low-light\nconditions.\n\n> Reviewed-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 | 19 +++----------------\n> >  src/ipa/ipu3/algorithms/agc.h   |  2 --\n> >  2 files changed, 3 insertions(+), 18 deletions(-)\n> > \n> > diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> > index 81eaf436..0177bb92 100644\n> > --- a/src/ipa/ipu3/algorithms/agc.cpp\n> > +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> > @@ -46,8 +46,7 @@ static constexpr double kEvGainTarget = 0.5;\n> >  Agc::Agc()\n> >         : frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n> >           minExposureLines_(0), maxExposureLines_(0), filteredExposure_(0s),\n> > -         filteredExposureNoDg_(0s), currentExposure_(0s),\n> > -         currentExposureNoDg_(0s), prevExposureValue(0s)\n> > +         currentExposure_(0s), prevExposureValue(0s)\n> >  {\n> >  }\n> >  \n> > @@ -96,7 +95,6 @@ void Agc::filterExposure()\n> >         if (filteredExposure_ == 0s) {\n> >                 /* DG stands for digital gain.*/\n> >                 filteredExposure_ = currentExposure_;\n> > -               filteredExposureNoDg_ = currentExposureNoDg_;\n> >         } else {\n> >                 /*\n> >                  * If we are close to the desired result, go faster to avoid making\n> > @@ -109,18 +107,8 @@ void Agc::filterExposure()\n> >  \n> >                 filteredExposure_ = speed * currentExposure_ +\n> >                                 filteredExposure_ * (1.0 - speed);\n> > -               filteredExposureNoDg_ = speed * currentExposureNoDg_ +\n> > -                               filteredExposureNoDg_ * (1.0 - speed);\n> >         }\n> > -       /*\n> > -        * We can't let the no_dg exposure deviate too far below the\n> > -        * total exposure, as there might not be enough digital gain available\n> > -        * in the ISP to hide it (which will cause nasty oscillation).\n> > -        */\n> > -       double fastReduceThreshold = 0.4;\n> > -       if (filteredExposureNoDg_ <\n> > -           filteredExposure_ * fastReduceThreshold)\n> > -               filteredExposureNoDg_ = filteredExposure_ * fastReduceThreshold;\n> > +\n> >         LOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << filteredExposure_;\n> >  }\n> >  \n> > @@ -136,8 +124,7 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)\n> >  \n> >         /* extracted from Rpi::Agc::computeTargetExposure */\n> >         Duration currentShutter = exposure * lineDuration_;\n> > -       currentExposureNoDg_ = currentShutter * analogueGain;\n> > -       LOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentExposureNoDg_\n> > +       LOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentShutter * analogueGain\n> >                                 << \" Shutter speed \" << currentShutter\n> >                                 << \" Gain \" << analogueGain\n> >                                 << \" Needed ev gain \" << evGain;\n> > diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> > index 32817c4f..5b34c013 100644\n> > --- a/src/ipa/ipu3/algorithms/agc.h\n> > +++ b/src/ipa/ipu3/algorithms/agc.h\n> > @@ -48,9 +48,7 @@ private:\n> >         uint32_t maxExposureLines_;\n> >  \n> >         Duration filteredExposure_;\n> > -       Duration filteredExposureNoDg_;\n> >         Duration currentExposure_;\n> > -       Duration currentExposureNoDg_;\n> >         Duration prevExposureValue;\n> >  \n> >         uint32_t stride_;","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 C1518C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Oct 2021 01:40:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5508468F50;\n\tFri, 15 Oct 2021 03:40:20 +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 D455668F4D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 03:40:18 +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 366822E3;\n\tFri, 15 Oct 2021 03:40:18 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AsQDWMwX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634262018;\n\tbh=vLMq9lWVarGQ8r/R8EIZ44HtWxznErDfz8DQhj04bmU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AsQDWMwXdn02JzEZH0fHaJJ63FG1gzTmNDBP4aGFnH8/IzUX1TggFzxHweNxiZtd4\n\tvk++oGdgsHPkTz0sXzyGj1FX7zpqmQ05iERVkAS3jqn2A18rFuOKHbgHaC6LEswa39\n\tJUZNS7XvetvZoNi5t1Do4xmb89Cm8izX2HF9xb8Q=","Date":"Fri, 15 Oct 2021 04:40:02 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<YWjb8r/MYnQDK7iX@pendragon.ideasonboard.com>","References":"<20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211013154125.133419-14-jeanmichel.hautbois@ideasonboard.com>\n\t<163421161222.3829429.13959844115431747310@Monstersaurus>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<163421161222.3829429.13959844115431747310@Monstersaurus>","Subject":"Re: [libcamera-devel] [PATCH 13/13] ipa: ipu3: agc: Remove unused\n\tvariables","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>"}}]