[{"id":20858,"web_url":"https://patchwork.libcamera.org/comment/20858/","msgid":"<163663756417.2258438.3942878835399920968@Monstersaurus>","date":"2021-11-11T13:32:44","subject":"Re: [libcamera-devel] [PATCH v3 08/14] ipa: ipu3: agc: Update\n\tprevious exposure value","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-11-11 11:05:59)\n> Previously, the exposure value was calculated based on the estimated\n> shutter time and gain applied. Now that we have the real values for the\n> current frame, use those before estimating the next one and rename the\n> variable accordingly.\n> \n> As the exposure value is updated in the beginning of the computation,\n> there is no need to initialize effectiveExposureValue anymore in the\n> configure call.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 25 +++++++++----------------\n>  src/ipa/ipu3/algorithms/agc.h   |  2 +-\n>  2 files changed, 10 insertions(+), 17 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index fd05822b..e828d9cb 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -81,7 +81,7 @@ static constexpr double kNormalizedLumaTarget = 0.16;\n>  Agc::Agc()\n>         : frameCount_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0),\n>           maxExposureLines_(0), filteredExposure_(0s), currentExposure_(0s),\n> -         prevExposureValue_(0s)\n> +         effectiveExposureValue_(0s)\n>  {\n>  }\n>  \n> @@ -112,10 +112,6 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>         context.frameContext.agc.gain = minAnalogueGain_;\n>         context.frameContext.agc.exposure = minExposureLines_;\n>  \n> -       prevExposureValue_ = context.frameContext.agc.gain\n> -                          * context.frameContext.agc.exposure\n> -                          * lineDuration_;\n> -\n>         return 0;\n>  }\n>  \n> @@ -222,6 +218,13 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>  \n>         /* Calculate the shutter time in seconds */\n>         utils::Duration currentShutter = exposure * lineDuration_;\n> +\n> +       /*\n> +        * Update the exposure value for the next computation using the values\n> +        * of exposure and gain really used by the sensor.\n> +        */\n> +       effectiveExposureValue_ = currentShutter * analogueGain;\n> +\n\nDoes this need to be a class variable? Can't it now just be a local?\n\n>         LOG(IPU3Agc, Debug) << \"Actual total exposure \" << currentShutter * analogueGain\n>                             << \" Shutter speed \" << currentShutter\n>                             << \" Gain \" << analogueGain\n> @@ -239,7 +242,7 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>          * Calculate the current exposure value for the scene as the latest\n>          * exposure value applied multiplied by the new estimated gain.\n>          */\n> -       currentExposure_ = prevExposureValue_ * evGain;\n> +       currentExposure_ = effectiveExposureValue_ * evGain;\n>         utils::Duration minShutterSpeed = minExposureLines_ * lineDuration_;\n>         utils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_;\n>  \n> @@ -271,16 +274,6 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>         /* Update the estimated exposure and gain. */\n>         frameContext.agc.exposure = shutterTime / lineDuration_;\n>         frameContext.agc.gain = stepGain;\n> -\n> -       /*\n> -        * Update the exposure value for the next process call.\n> -        *\n> -        * \\todo Obtain the values of the exposure time and analog gain\n> -        * that were actually used by the sensor, either from embedded\n> -        * data when available, or from the delayed controls\n> -        * infrastructure in case a slow down caused a mismatch.\n> -        */\n> -       prevExposureValue_ = shutterTime * analogueGain;\n>  }\n>  \n>  /**\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 79736283..1a58c79c 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -54,7 +54,7 @@ private:\n>  \n>         utils::Duration filteredExposure_;\n>         utils::Duration currentExposure_;\n> -       utils::Duration prevExposureValue_;\n> +       utils::Duration effectiveExposureValue_;\n>  \n>         uint32_t stride_;\n>  };\n> -- \n> 2.32.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 C6146BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Nov 2021 13:32:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 356DF60361;\n\tThu, 11 Nov 2021 14:32:49 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2273760345\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Nov 2021 14:32:47 +0100 (CET)","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 B306F4A0;\n\tThu, 11 Nov 2021 14:32:46 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XZWvCALN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636637566;\n\tbh=0p9DV902DVpR9OuPqwLuIjMXmtm2ueuAJbbypLGXod8=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=XZWvCALNaF1B2uosGy2t4RlwaotHK0kM2kPswifMu1M/9GVLuMCVgyacpFOLpFbfj\n\tSCLBJS6KEjnOPqGrVySgID710JRneyMrMsnc/lqspWl0W8RVSP2xGbrfbSPgjQ39eI\n\t0tJHoFbuOCIZwbvEcisPdlHXxm0rqBGq82JM7Vog=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211111110605.105202-9-jeanmichel.hautbois@ideasonboard.com>","References":"<20211111110605.105202-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111110605.105202-9-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, 11 Nov 2021 13:32:44 +0000","Message-ID":"<163663756417.2258438.3942878835399920968@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH v3 08/14] ipa: ipu3: agc: Update\n\tprevious exposure value","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>"}}]