[{"id":20198,"web_url":"https://patchwork.libcamera.org/comment/20198/","msgid":"<163420870775.3829429.2916416443732834283@Monstersaurus>","date":"2021-10-14T10:51:47","subject":"Re: [libcamera-devel] [PATCH 05/13] ipa: ipu3: agc: Rename exposure\n\tvalues properly","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:17)\n> The exposure value is filtered in filterExposure() using the\n> currentExposure_ and setting a prevExposure_ variable. This is misnamed\n> as it is not the previous exposure, but a filtered value.\n> \n> Rename it accordingly.\n> \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 | 28 ++++++++++++++--------------\n>  src/ipa/ipu3/algorithms/agc.h   |  4 ++--\n>  2 files changed, 16 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 5eafe82c..7c2d4201 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -49,7 +49,7 @@ static constexpr double kEvGainTarget = 0.5;\n>  \n>  Agc::Agc()\n>         : frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n> -         maxExposureTime_(0s), prevExposure_(0s), prevExposureNoDg_(0s),\n> +         maxExposureTime_(0s), filteredExposure_(0s), filteredExposureNoDg_(0s),\n>           currentExposure_(0s), currentExposureNoDg_(0s)\n>  {\n>  }\n> @@ -94,24 +94,24 @@ void Agc::processBrightness(const ipu3_uapi_stats_3a *stats,\n>  void Agc::filterExposure()\n>  {\n>         double speed = 0.2;\n> -       if (prevExposure_ == 0s) {\n> +       if (filteredExposure_ == 0s) {\n>                 /* DG stands for digital gain.*/\n> -               prevExposure_ = currentExposure_;\n> -               prevExposureNoDg_ = currentExposureNoDg_;\n> +               filteredExposure_ = currentExposure_;\n> +               filteredExposureNoDg_ = currentExposureNoDg_;\n>         } else {\n>                 /*\n>                  * If we are close to the desired result, go faster to avoid making\n>                  * multiple micro-adjustments.\n>                  * \\ todo: Make this customisable?\n>                  */\n> -               if (prevExposure_ < 1.2 * currentExposure_ &&\n> -                   prevExposure_ > 0.8 * currentExposure_)\n> +               if (filteredExposure_ < 1.2 * currentExposure_ &&\n> +                   filteredExposure_ > 0.8 * currentExposure_)\n>                         speed = sqrt(speed);\n>  \n> -               prevExposure_ = speed * currentExposure_ +\n> -                               prevExposure_ * (1.0 - speed);\n> -               prevExposureNoDg_ = speed * currentExposureNoDg_ +\n> -                               prevExposureNoDg_ * (1.0 - speed);\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> @@ -119,10 +119,10 @@ void Agc::filterExposure()\n>          * in the ISP to hide it (which will cause nasty oscillation).\n>          */\n>         double fastReduceThreshold = 0.4;\n> -       if (prevExposureNoDg_ <\n> -           prevExposure_ * fastReduceThreshold)\n> -               prevExposureNoDg_ = prevExposure_ * fastReduceThreshold;\n> -       LOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << prevExposure_;\n> +       if (filteredExposureNoDg_ <\n> +           filteredExposure_ * fastReduceThreshold)\n> +               filteredExposureNoDg_ = filteredExposure_ * fastReduceThreshold;\n> +       LOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << filteredExposure_;\n>  }\n>  \n>  void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 64b71c65..cd4d4855 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -46,8 +46,8 @@ private:\n>         Duration lineDuration_;\n>         Duration maxExposureTime_;\n>  \n> -       Duration prevExposure_;\n> -       Duration prevExposureNoDg_;\n> +       Duration filteredExposure_;\n> +       Duration filteredExposureNoDg_;\n>         Duration currentExposure_;\n>         Duration currentExposureNoDg_;\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 154FBBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Oct 2021 10:51:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE37E68F4D;\n\tThu, 14 Oct 2021 12:51:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D47768541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 12:51:50 +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 EF41A2F3;\n\tThu, 14 Oct 2021 12:51:49 +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=\"cKRs4U2l\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634208710;\n\tbh=qEGtwBz3FDamkU3zHgvryb1Vj52Ch2xhUPgx22BWVlo=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=cKRs4U2l6wSi8i+O4JYiHW0nzB8l1FdE78iVG2w6iayXHqK/pj6EqmHJsxEB+bfkw\n\t7C5woY2CKkCD/RwGqTwaiR/f2K/OjuB9FRokRYHMuIlcxxgAocmUznDaWoCsO+yCuD\n\tJlqvRIKAcYd8YgA9t+v2lrobWINWNLIVZSv44lZY=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211013154125.133419-6-jeanmichel.hautbois@ideasonboard.com>","References":"<20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211013154125.133419-6-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 11:51:47 +0100","Message-ID":"<163420870775.3829429.2916416443732834283@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH 05/13] ipa: ipu3: agc: Rename exposure\n\tvalues properly","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":20215,"web_url":"https://patchwork.libcamera.org/comment/20215/","msgid":"<YWi2HPVFBKmDVS1X@pendragon.ideasonboard.com>","date":"2021-10-14T22:58:36","subject":"Re: [libcamera-devel] [PATCH 05/13] ipa: ipu3: agc: Rename exposure\n\tvalues properly","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:17PM +0200, Jean-Michel Hautbois wrote:\n> The exposure value is filtered in filterExposure() using the\n> currentExposure_ and setting a prevExposure_ variable. This is misnamed\n> as it is not the previous exposure, but a filtered value.\n> \n> Rename it accordingly.\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 | 28 ++++++++++++++--------------\n>  src/ipa/ipu3/algorithms/agc.h   |  4 ++--\n>  2 files changed, 16 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 5eafe82c..7c2d4201 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -49,7 +49,7 @@ static constexpr double kEvGainTarget = 0.5;\n>  \n>  Agc::Agc()\n>  \t: frameCount_(0), lastFrame_(0), iqMean_(0.0), lineDuration_(0s),\n> -\t  maxExposureTime_(0s), prevExposure_(0s), prevExposureNoDg_(0s),\n> +\t  maxExposureTime_(0s), filteredExposure_(0s), filteredExposureNoDg_(0s),\n>  \t  currentExposure_(0s), currentExposureNoDg_(0s)\n>  {\n>  }\n> @@ -94,24 +94,24 @@ void Agc::processBrightness(const ipu3_uapi_stats_3a *stats,\n>  void Agc::filterExposure()\n>  {\n>  \tdouble speed = 0.2;\n> -\tif (prevExposure_ == 0s) {\n> +\tif (filteredExposure_ == 0s) {\n>  \t\t/* DG stands for digital gain.*/\n> -\t\tprevExposure_ = currentExposure_;\n> -\t\tprevExposureNoDg_ = currentExposureNoDg_;\n> +\t\tfilteredExposure_ = currentExposure_;\n> +\t\tfilteredExposureNoDg_ = currentExposureNoDg_;\n>  \t} else {\n>  \t\t/*\n>  \t\t * If we are close to the desired result, go faster to avoid making\n>  \t\t * multiple micro-adjustments.\n>  \t\t * \\ todo: Make this customisable?\n>  \t\t */\n> -\t\tif (prevExposure_ < 1.2 * currentExposure_ &&\n> -\t\t    prevExposure_ > 0.8 * currentExposure_)\n> +\t\tif (filteredExposure_ < 1.2 * currentExposure_ &&\n> +\t\t    filteredExposure_ > 0.8 * currentExposure_)\n>  \t\t\tspeed = sqrt(speed);\n>  \n> -\t\tprevExposure_ = speed * currentExposure_ +\n> -\t\t\t\tprevExposure_ * (1.0 - speed);\n> -\t\tprevExposureNoDg_ = speed * currentExposureNoDg_ +\n> -\t\t\t\tprevExposureNoDg_ * (1.0 - speed);\n> +\t\tfilteredExposure_ = speed * currentExposure_ +\n> +\t\t\t\tfilteredExposure_ * (1.0 - speed);\n> +\t\tfilteredExposureNoDg_ = speed * currentExposureNoDg_ +\n> +\t\t\t\tfilteredExposureNoDg_ * (1.0 - speed);\n>  \t}\n>  \t/*\n>  \t * We can't let the no_dg exposure deviate too far below the\n> @@ -119,10 +119,10 @@ void Agc::filterExposure()\n>  \t * in the ISP to hide it (which will cause nasty oscillation).\n>  \t */\n>  \tdouble fastReduceThreshold = 0.4;\n> -\tif (prevExposureNoDg_ <\n> -\t    prevExposure_ * fastReduceThreshold)\n> -\t\tprevExposureNoDg_ = prevExposure_ * fastReduceThreshold;\n> -\tLOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << prevExposure_;\n> +\tif (filteredExposureNoDg_ <\n> +\t    filteredExposure_ * fastReduceThreshold)\n> +\t\tfilteredExposureNoDg_ = filteredExposure_ * fastReduceThreshold;\n> +\tLOG(IPU3Agc, Debug) << \"After filtering, total_exposure \" << filteredExposure_;\n>  }\n>  \n>  void Agc::lockExposureGain(uint32_t &exposure, double &gain)\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 64b71c65..cd4d4855 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -46,8 +46,8 @@ private:\n>  \tDuration lineDuration_;\n>  \tDuration maxExposureTime_;\n>  \n> -\tDuration prevExposure_;\n> -\tDuration prevExposureNoDg_;\n> +\tDuration filteredExposure_;\n> +\tDuration filteredExposureNoDg_;\n>  \tDuration currentExposure_;\n>  \tDuration currentExposureNoDg_;\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 750C4C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Oct 2021 22:58:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E34EE68F50;\n\tFri, 15 Oct 2021 00:58:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 302CF60501\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 00:58:52 +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 9D62DB91;\n\tFri, 15 Oct 2021 00:58:51 +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=\"uTtvi1dH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634252331;\n\tbh=/voYPGQIGHrGXVznXT0PuCFfTCyDhN22WEt0H11lAW8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=uTtvi1dHelRkLjkVzIXh9dvoEUYpVQ3teLAdVvekzjF3rpAy/PE+Vze0mTS/+/85S\n\tKd3ZAgqSr3H1+WGiVctJvohkZZ0nppkg74U0eixaOMk9GlHZMxOVVT7WR6OSmXgD5V\n\trO9X41x0+FiOpiE5Ic+ZK3iLWF83XxxArB6FZrSs=","Date":"Fri, 15 Oct 2021 01:58:36 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YWi2HPVFBKmDVS1X@pendragon.ideasonboard.com>","References":"<20211013154125.133419-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211013154125.133419-6-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211013154125.133419-6-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 05/13] ipa: ipu3: agc: Rename exposure\n\tvalues properly","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>"}}]