[{"id":20901,"web_url":"https://patchwork.libcamera.org/comment/20901/","msgid":"<c79a1a5b-ab8a-eb74-f249-3d4d15f40956@ideasonboard.com>","date":"2021-11-12T09:40:04","subject":"Re: [libcamera-devel] [PATCH v4 09/14] ipa: ipu3: agc: Use exposure\n\tin time for storage","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi JM,\n\nOn 11/11/21 7:39 PM, Jean-Michel Hautbois wrote:\n> The minimum and maximum exposure are stored in lines. Replace it by\n> values in time to simplify the calculations.\n>\n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   src/ipa/ipu3/algorithms/agc.cpp | 21 +++++++++------------\n>   src/ipa/ipu3/algorithms/agc.h   |  4 ++--\n>   2 files changed, 11 insertions(+), 14 deletions(-)\n>\n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index d736f21c..86b71886 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -79,8 +79,8 @@ static constexpr uint32_t kMaxLuminance = 255;\n>   static constexpr double kNormalizedLumaTarget = 0.16;\n>   \n>   Agc::Agc()\n> -\t: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0),\n> -\t  maxExposureLines_(0), filteredExposure_(0s), currentExposure_(0s)\n> +\t: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minShutterSpeed_(0s),\n> +\t  maxShutterSpeed_(0s), filteredExposure_(0s), currentExposure_(0s)\n>   {\n>   }\n>   \n> @@ -99,17 +99,16 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>   \tlineDuration_ = configInfo.sensorInfo.lineLength * 1.0s\n>   \t\t      / configInfo.sensorInfo.pixelRate;\n>   \n> -\t/* \\todo replace the exposure in lines storage with time based ones. */\n> -\tminExposureLines_ = context.configuration.agc.minShutterSpeed / lineDuration_;\n> -\tmaxExposureLines_ = std::min(context.configuration.agc.maxShutterSpeed / lineDuration_,\n> -\t\t\t\t     kMaxShutterSpeed / lineDuration_);\n> +\tminShutterSpeed_ = context.configuration.agc.minShutterSpeed;\n> +\tmaxShutterSpeed_ = std::min(context.configuration.agc.maxShutterSpeed,\n> +\t\t\t\t    kMaxShutterSpeed);\n>   \n>   \tminAnalogueGain_ = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n>   \tmaxAnalogueGain_ = std::min(context.configuration.agc.maxAnalogueGain, kMaxAnalogueGain);\n>   \n>   \t/* Configure the default exposure and gain. */\n>   \tcontext.frameContext.agc.gain = minAnalogueGain_;\n> -\tcontext.frameContext.agc.exposure = minExposureLines_;\n> +\tcontext.frameContext.agc.exposure = minShutterSpeed_ / lineDuration_;\n>   \n>   \treturn 0;\n>   }\n> @@ -242,11 +241,9 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>   \t * exposure value applied multiplied by the new estimated gain.\n>   \t */\n>   \tcurrentExposure_ = effectiveExposureValue * evGain;\n> -\tutils::Duration minShutterSpeed = minExposureLines_ * lineDuration_;\n> -\tutils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_;\n>   \n>   \t/* Clamp the exposure value to the min and max authorized */\n> -\tutils::Duration maxTotalExposure = maxShutterSpeed * maxAnalogueGain_;\n> +\tutils::Duration maxTotalExposure = maxShutterSpeed_ * maxAnalogueGain_;\n>   \tcurrentExposure_ = std::min(currentExposure_, maxTotalExposure);\n>   \tLOG(IPU3Agc, Debug) << \"Target total exposure \" << currentExposure_\n>   \t\t\t    << \", maximum is \" << maxTotalExposure;\n> @@ -256,14 +253,14 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>   \n>   \t/* Divide the exposure value as new exposure and gain values */\n>   \tutils::Duration exposureValue = filteredExposure_;\n> -\tutils::Duration shutterTime = minShutterSpeed;\n> +\tutils::Duration shutterTime;\n>   \n>   \t/*\n>   \t* Push the shutter time up to the maximum first, and only then\n>   \t* increase the gain.\n>   \t*/\n>   \tshutterTime = std::clamp<utils::Duration>(exposureValue / minAnalogueGain_,\n> -\t\t\t\t\t\t  minShutterSpeed, maxShutterSpeed);\n> +\t\t\t\t\t\t  minShutterSpeed_, maxShutterSpeed_);\n>   \tdouble stepGain = std::clamp(exposureValue / shutterTime,\n>   \t\t\t\t     minAnalogueGain_, maxAnalogueGain_);\n>   \tLOG(IPU3Agc, Debug) << \"Divided up shutter and gain are \"\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 1d085b40..f14d56b7 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -46,8 +46,8 @@ private:\n>   \tdouble iqMean_;\n>   \n>   \tutils::Duration lineDuration_;\n> -\tuint32_t minExposureLines_;\n> -\tuint32_t maxExposureLines_;\n> +\tutils::Duration minShutterSpeed_;\n> +\tutils::Duration maxShutterSpeed_;\n>   \n>   \tdouble minAnalogueGain_;\n>   \tdouble maxAnalogueGain_;","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 78260BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 09:40:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C07E76033C;\n\tFri, 12 Nov 2021 10:40:11 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 52CE960234\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Nov 2021 10:40:10 +0100 (CET)","from [192.168.1.106] (unknown [103.251.226.254])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A3D474C;\n\tFri, 12 Nov 2021 10:40:09 +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=\"ME9vKSIt\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636710010;\n\tbh=BDpwQ6OG2PHmdDHYY1VnLQo9G1fGKCvyDTQ2Fh/ILis=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=ME9vKSItj9oGmL5kpWgM/jsPj9tYdJcKw2iMOuF0AH32ak4wEMoPlDw9lRuDc7dKb\n\tmdn+MgueeyDMecyiHB8zE4brBdNLAliieDMvF4HjOuRRINQ9/l72FrpDNzgAFXJLsS\n\tsp7Vf23YLWGRgA4lLDW494RvfxGOzNJQylnknc30=","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-10-jeanmichel.hautbois@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<c79a1a5b-ab8a-eb74-f249-3d4d15f40956@ideasonboard.com>","Date":"Fri, 12 Nov 2021 15:10:04 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20211111140928.136111-10-jeanmichel.hautbois@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH v4 09/14] ipa: ipu3: agc: Use exposure\n\tin time for storage","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":20937,"web_url":"https://patchwork.libcamera.org/comment/20937/","msgid":"<20211112231816.GG8453@jade.amanokami.net>","date":"2021-11-12T23:18:16","subject":"Re: [libcamera-devel] [PATCH v4 09/14] ipa: ipu3: agc: Use exposure\n\tin time for storage","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Jean-Michel,\n\nimo the subject could be a bit more clear:\n\n\"Store exposure in units of time\"\n\nOn Thu, Nov 11, 2021 at 03:09:23PM +0100, Jean-Michel Hautbois wrote:\n> The minimum and maximum exposure are stored in lines. Replace it by\n> values in time to simplify the calculations.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 21 +++++++++------------\n>  src/ipa/ipu3/algorithms/agc.h   |  4 ++--\n>  2 files changed, 11 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index d736f21c..86b71886 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -79,8 +79,8 @@ static constexpr uint32_t kMaxLuminance = 255;\n>  static constexpr double kNormalizedLumaTarget = 0.16;\n>  \n>  Agc::Agc()\n> -\t: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0),\n> -\t  maxExposureLines_(0), filteredExposure_(0s), currentExposure_(0s)\n> +\t: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minShutterSpeed_(0s),\n> +\t  maxShutterSpeed_(0s), filteredExposure_(0s), currentExposure_(0s)\n\nTo me it sounds a bit strange that speed is measured in seconds, but oh\nwell :p\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n>  {\n>  }\n>  \n> @@ -99,17 +99,16 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)\n>  \tlineDuration_ = configInfo.sensorInfo.lineLength * 1.0s\n>  \t\t      / configInfo.sensorInfo.pixelRate;\n>  \n> -\t/* \\todo replace the exposure in lines storage with time based ones. */\n> -\tminExposureLines_ = context.configuration.agc.minShutterSpeed / lineDuration_;\n> -\tmaxExposureLines_ = std::min(context.configuration.agc.maxShutterSpeed / lineDuration_,\n> -\t\t\t\t     kMaxShutterSpeed / lineDuration_);\n> +\tminShutterSpeed_ = context.configuration.agc.minShutterSpeed;\n> +\tmaxShutterSpeed_ = std::min(context.configuration.agc.maxShutterSpeed,\n> +\t\t\t\t    kMaxShutterSpeed);\n>  \n>  \tminAnalogueGain_ = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n>  \tmaxAnalogueGain_ = std::min(context.configuration.agc.maxAnalogueGain, kMaxAnalogueGain);\n>  \n>  \t/* Configure the default exposure and gain. */\n>  \tcontext.frameContext.agc.gain = minAnalogueGain_;\n> -\tcontext.frameContext.agc.exposure = minExposureLines_;\n> +\tcontext.frameContext.agc.exposure = minShutterSpeed_ / lineDuration_;\n>  \n>  \treturn 0;\n>  }\n> @@ -242,11 +241,9 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>  \t * exposure value applied multiplied by the new estimated gain.\n>  \t */\n>  \tcurrentExposure_ = effectiveExposureValue * evGain;\n> -\tutils::Duration minShutterSpeed = minExposureLines_ * lineDuration_;\n> -\tutils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_;\n>  \n>  \t/* Clamp the exposure value to the min and max authorized */\n> -\tutils::Duration maxTotalExposure = maxShutterSpeed * maxAnalogueGain_;\n> +\tutils::Duration maxTotalExposure = maxShutterSpeed_ * maxAnalogueGain_;\n>  \tcurrentExposure_ = std::min(currentExposure_, maxTotalExposure);\n>  \tLOG(IPU3Agc, Debug) << \"Target total exposure \" << currentExposure_\n>  \t\t\t    << \", maximum is \" << maxTotalExposure;\n> @@ -256,14 +253,14 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)\n>  \n>  \t/* Divide the exposure value as new exposure and gain values */\n>  \tutils::Duration exposureValue = filteredExposure_;\n> -\tutils::Duration shutterTime = minShutterSpeed;\n> +\tutils::Duration shutterTime;\n>  \n>  \t/*\n>  \t* Push the shutter time up to the maximum first, and only then\n>  \t* increase the gain.\n>  \t*/\n>  \tshutterTime = std::clamp<utils::Duration>(exposureValue / minAnalogueGain_,\n> -\t\t\t\t\t\t  minShutterSpeed, maxShutterSpeed);\n> +\t\t\t\t\t\t  minShutterSpeed_, maxShutterSpeed_);\n>  \tdouble stepGain = std::clamp(exposureValue / shutterTime,\n>  \t\t\t\t     minAnalogueGain_, maxAnalogueGain_);\n>  \tLOG(IPU3Agc, Debug) << \"Divided up shutter and gain are \"\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 1d085b40..f14d56b7 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -46,8 +46,8 @@ private:\n>  \tdouble iqMean_;\n>  \n>  \tutils::Duration lineDuration_;\n> -\tuint32_t minExposureLines_;\n> -\tuint32_t maxExposureLines_;\n> +\tutils::Duration minShutterSpeed_;\n> +\tutils::Duration maxShutterSpeed_;\n>  \n>  \tdouble minAnalogueGain_;\n>  \tdouble maxAnalogueGain_;\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 5D915BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Nov 2021 23:18:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AF4B26036B;\n\tSat, 13 Nov 2021 00:18:29 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 33D3E600B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Nov 2021 00:18:28 +0100 (CET)","from jade.amanokami.net (KD027085206038.au-net.ne.jp\n\t[27.85.206.38])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D14F49CA;\n\tSat, 13 Nov 2021 00:18:24 +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=\"ubjfBhrg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1636759107;\n\tbh=Jelmpol9zvb4gNDiX7a4phh8UNMRd9hr/zKzFKBEvFk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ubjfBhrgPRQyezp53tSrvpjDzmt5mQvVGTtYNrSdxOPm4WRigY8hgIdj3TE0foUD3\n\tFpp2VjPg8K5tjLd64PFa4/XENk9Vp9RRLh/nxY+IS2g9pXSRZEyKIr8GIYnAKK6OEB\n\t83q6+Op2iObjd7uykd52jBshfKAhm/rKzBf2Ltmg=","Date":"Sat, 13 Nov 2021 08:18:16 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<20211112231816.GG8453@jade.amanokami.net>","References":"<20211111140928.136111-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20211111140928.136111-10-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20211111140928.136111-10-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 09/14] ipa: ipu3: agc: Use exposure\n\tin time for storage","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>"}}]