[{"id":24059,"web_url":"https://patchwork.libcamera.org/comment/24059/","msgid":"<9085aa28-86b9-e996-afe1-698bd49eef8e@ideasonboard.com>","date":"2022-07-22T14:55:22","subject":"Re: [libcamera-devel] [RFC PATCH 05/12] ipa: rkisp1: Rename\n\tframeContext to activeState","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch\n\nOn 7/21/22 17:43, Kieran Bingham via libcamera-devel wrote:\n> Move the existing frame context structure to the IPAActiveState.\n> This structure should store the most up to date results for the IPA\n> which may be shared to other algorithms that operate on the data.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nLooks good!\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   src/ipa/rkisp1/algorithms/agc.cpp | 20 +++++++++---------\n>   src/ipa/rkisp1/algorithms/awb.cpp | 34 +++++++++++++++----------------\n>   src/ipa/rkisp1/algorithms/blc.cpp |  2 +-\n>   src/ipa/rkisp1/ipa_context.h      |  7 +++++--\n>   src/ipa/rkisp1/rkisp1.cpp         | 12 +++++------\n>   5 files changed, 39 insertions(+), 36 deletions(-)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index a1bb7d972926..483e941fe427 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -73,8 +73,8 @@ Agc::Agc()\n>   int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n>   {\n>   \t/* Configure the default exposure and gain. */\n> -\tcontext.frameContext.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n> -\tcontext.frameContext.agc.exposure = 10ms / context.configuration.sensor.lineDuration;\n> +\tcontext.activeState.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n> +\tcontext.activeState.agc.exposure = 10ms / context.configuration.sensor.lineDuration;\n>   \n>   \t/*\n>   \t * According to the RkISP1 documentation:\n> @@ -98,7 +98,7 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n>   \tcontext.configuration.agc.measureWindow.h_size = 3 * configInfo.outputSize.width / 4;\n>   \tcontext.configuration.agc.measureWindow.v_size = 3 * configInfo.outputSize.height / 4;\n>   \n> -\t/* \\todo Use actual frame index by populating it in the frameContext. */\n> +\t/* \\todo Use actual frame index by populating it in the activeState. */\n>   \tframeCount_ = 0;\n>   \treturn 0;\n>   }\n> @@ -140,18 +140,18 @@ utils::Duration Agc::filterExposure(utils::Duration exposureValue)\n>   \n>   /**\n>    * \\brief Estimate the new exposure and gain values\n> - * \\param[inout] frameContext The shared IPA frame Context\n> + * \\param[inout] context The shared IPA Context\n>    * \\param[in] yGain The gain calculated on the current brightness level\n>    * \\param[in] iqMeanGain The gain calculated based on the relative luminance target\n>    */\n>   void Agc::computeExposure(IPAContext &context, double yGain, double iqMeanGain)\n>   {\n>   \tIPASessionConfiguration &configuration = context.configuration;\n> -\tIPAFrameContext &frameContext = context.frameContext;\n> +\tIPAActiveState &activeState = context.activeState;\n>   \n>   \t/* Get the effective exposure and gain applied on the sensor. */\n> -\tuint32_t exposure = frameContext.sensor.exposure;\n> -\tdouble analogueGain = frameContext.sensor.gain;\n> +\tuint32_t exposure = activeState.sensor.exposure;\n> +\tdouble analogueGain = activeState.sensor.gain;\n>   \n>   \t/* Use the highest of the two gain estimates. */\n>   \tdouble evGain = std::max(yGain, iqMeanGain);\n> @@ -216,8 +216,8 @@ void Agc::computeExposure(IPAContext &context, double yGain, double iqMeanGain)\n>   \t\t\t      << stepGain;\n>   \n>   \t/* Update the estimated exposure and gain. */\n> -\tframeContext.agc.exposure = shutterTime / configuration.sensor.lineDuration;\n> -\tframeContext.agc.gain = stepGain;\n> +\tactiveState.agc.exposure = shutterTime / configuration.sensor.lineDuration;\n> +\tactiveState.agc.gain = stepGain;\n>   }\n>   \n>   /**\n> @@ -324,7 +324,7 @@ void Agc::process(IPAContext &context,\n>    */\n>   void Agc::prepare(IPAContext &context, rkisp1_params_cfg *params)\n>   {\n> -\tif (context.frameContext.frameCount > 0)\n> +\tif (context.activeState.frameCount > 0)\n>   \t\treturn;\n>   \n>   \t/* Configure the measurement window. */\n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 9f00364d12b1..427aaeb1e955 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -35,9 +35,9 @@ LOG_DEFINE_CATEGORY(RkISP1Awb)\n>   int Awb::configure(IPAContext &context,\n>   \t\t   const IPACameraSensorInfo &configInfo)\n>   {\n> -\tcontext.frameContext.awb.gains.red = 1.0;\n> -\tcontext.frameContext.awb.gains.blue = 1.0;\n> -\tcontext.frameContext.awb.gains.green = 1.0;\n> +\tcontext.activeState.awb.gains.red = 1.0;\n> +\tcontext.activeState.awb.gains.blue = 1.0;\n> +\tcontext.activeState.awb.gains.green = 1.0;\n>   \n>   \t/*\n>   \t * Define the measurement window for AWB as a centered rectangle\n> @@ -72,16 +72,16 @@ uint32_t Awb::estimateCCT(double red, double green, double blue)\n>    */\n>   void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params)\n>   {\n> -\tparams->others.awb_gain_config.gain_green_b = 256 * context.frameContext.awb.gains.green;\n> -\tparams->others.awb_gain_config.gain_blue = 256 * context.frameContext.awb.gains.blue;\n> -\tparams->others.awb_gain_config.gain_red = 256 * context.frameContext.awb.gains.red;\n> -\tparams->others.awb_gain_config.gain_green_r = 256 * context.frameContext.awb.gains.green;\n> +\tparams->others.awb_gain_config.gain_green_b = 256 * context.activeState.awb.gains.green;\n> +\tparams->others.awb_gain_config.gain_blue = 256 * context.activeState.awb.gains.blue;\n> +\tparams->others.awb_gain_config.gain_red = 256 * context.activeState.awb.gains.red;\n> +\tparams->others.awb_gain_config.gain_green_r = 256 * context.activeState.awb.gains.green;\n>   \n>   \t/* Update the gains. */\n>   \tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;\n>   \n>   \t/* If we already have configured the gains and window, return. */\n> -\tif (context.frameContext.frameCount > 0)\n> +\tif (context.activeState.frameCount > 0)\n>   \t\treturn;\n>   \n>   \t/* Configure the gains to apply. */\n> @@ -125,7 +125,7 @@ void Awb::process([[maybe_unused]] IPAContext &context,\n>   {\n>   \tconst rkisp1_cif_isp_stat *params = &stats->params;\n>   \tconst rkisp1_cif_isp_awb_stat *awb = &params->awb;\n> -\tIPAFrameContext &frameContext = context.frameContext;\n> +\tIPAActiveState &activeState = context.activeState;\n>   \n>   \t/* Get the YCbCr mean values */\n>   \tdouble yMean = awb->awb_mean[0].mean_y_or_g;\n> @@ -157,22 +157,22 @@ void Awb::process([[maybe_unused]] IPAContext &context,\n>   \n>   \t/* Filter the values to avoid oscillations. */\n>   \tdouble speed = 0.2;\n> -\tredGain = speed * redGain + (1 - speed) * frameContext.awb.gains.red;\n> -\tblueGain = speed * blueGain + (1 - speed) * frameContext.awb.gains.blue;\n> +\tredGain = speed * redGain + (1 - speed) * activeState.awb.gains.red;\n> +\tblueGain = speed * blueGain + (1 - speed) * activeState.awb.gains.blue;\n>   \n>   \t/*\n>   \t * Gain values are unsigned integer value, range 0 to 4 with 8 bit\n>   \t * fractional part.\n>   \t */\n> -\tframeContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);\n> -\tframeContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);\n> +\tactiveState.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);\n> +\tactiveState.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);\n>   \t/* Hardcode the green gain to 1.0. */\n> -\tframeContext.awb.gains.green = 1.0;\n> +\tactiveState.awb.gains.green = 1.0;\n>   \n> -\tframeContext.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n> +\tactiveState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n>   \n> -\tLOG(RkISP1Awb, Debug) << \"Gain found for red: \" << context.frameContext.awb.gains.red\n> -\t\t\t      << \" and for blue: \" << context.frameContext.awb.gains.blue;\n> +\tLOG(RkISP1Awb, Debug) << \"Gain found for red: \" << context.activeState.awb.gains.red\n> +\t\t\t      << \" and for blue: \" << context.activeState.awb.gains.blue;\n>   }\n>   \n>   REGISTER_IPA_ALGORITHM(Awb, \"Awb\")\n> diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\n> index a58569fa2dc2..4d55a2d529cb 100644\n> --- a/src/ipa/rkisp1/algorithms/blc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/blc.cpp\n> @@ -68,7 +68,7 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,\n>   void BlackLevelCorrection::prepare(IPAContext &context,\n>   \t\t\t\t   rkisp1_params_cfg *params)\n>   {\n> -\tif (context.frameContext.frameCount > 0)\n> +\tif (context.activeState.frameCount > 0)\n>   \t\treturn;\n>   \n>   \tif (!tuningParameters_)\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index f387cacea363..341fef2e68fe 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -40,7 +40,7 @@ struct IPASessionConfiguration {\n>   \t} hw;\n>   };\n>   \n> -struct IPAFrameContext {\n> +struct IPAActiveState {\n>   \tstruct {\n>   \t\tuint32_t exposure;\n>   \t\tdouble gain;\n> @@ -64,9 +64,12 @@ struct IPAFrameContext {\n>   \tunsigned int frameCount;\n>   };\n>   \n> +struct IPAFrameContext {\n> +};\n> +\n>   struct IPAContext {\n>   \tIPASessionConfiguration configuration;\n> -\tIPAFrameContext frameContext;\n> +\tIPAActiveState activeState;\n>   };\n>   \n>   } /* namespace ipa::rkisp1 */\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 21166b0f1ba6..9629ccbf4247 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -224,7 +224,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n>   \tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n>   \tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n>   \n> -\tcontext_.frameContext.frameCount = 0;\n> +\tcontext_.activeState.frameCount = 0;\n>   \n>   \tfor (auto const &algo : algorithms()) {\n>   \t\tint ret = algo->configure(context_, info);\n> @@ -284,7 +284,7 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n>   \t\talgo->prepare(context_, params);\n>   \n>   \tparamsBufferReady.emit(frame);\n> -\tcontext_.frameContext.frameCount++;\n> +\tcontext_.activeState.frameCount++;\n>   }\n>   \n>   void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,\n> @@ -294,9 +294,9 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n>   \t\treinterpret_cast<rkisp1_stat_buffer *>(\n>   \t\t\tmappedBuffers_.at(bufferId).planes()[0].data());\n>   \n> -\tcontext_.frameContext.sensor.exposure =\n> +\tcontext_.activeState.sensor.exposure =\n>   \t\tsensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n> -\tcontext_.frameContext.sensor.gain =\n> +\tcontext_.activeState.sensor.gain =\n>   \t\tcamHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n>   \n>   \tunsigned int aeState = 0;\n> @@ -311,8 +311,8 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n>   \n>   void IPARkISP1::setControls(unsigned int frame)\n>   {\n> -\tuint32_t exposure = context_.frameContext.agc.exposure;\n> -\tuint32_t gain = camHelper_->gainCode(context_.frameContext.agc.gain);\n> +\tuint32_t exposure = context_.activeState.agc.exposure;\n> +\tuint32_t gain = camHelper_->gainCode(context_.activeState.agc.gain);\n>   \n>   \tControlList ctrls(ctrls_);\n>   \tctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure));","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 ED369BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Jul 2022 14:55:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 509EC6330F;\n\tFri, 22 Jul 2022 16:55:28 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 122A1601B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Jul 2022 16:55:27 +0200 (CEST)","from [IPV6:2401:4900:1f3f:a2d:c6dd:7a7c:3d3c:dbb9] (unknown\n\t[IPv6:2401:4900:1f3f:a2d:c6dd:7a7c:3d3c:dbb9])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ECD3F6D5;\n\tFri, 22 Jul 2022 16:55:25 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658501728;\n\tbh=U9OG7txT11OfeiYeYZGum9rZG5CuoM0OIcLF85qCl2E=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=OnBwN3kUumyfrmGPvlKPPBou3ltwgf73O4BwHG9MSvmpnGHfWWSAXXaxURetk+wWO\n\tKwo5vU9W9TkbCYf28ql7vCTMusP6RK4bORhMbhxrMpG3QPA4uHHnzMyW8nqXCy7SOQ\n\th6uMcDDgv0jAJqh1Pod6Tzrla7H7JmqJmaAXcjY4vnh+UmKx8RCr3E2PyZ3mVFpl26\n\tzPOkP18BmjLWj50jYh/6GT0h8VDnz2/Z3kYRO2vszZPjRIHU7ma73MiOJMw0GDzXne\n\tga1AdueSLBpMusRi20FeImGtSMb+UTlAaFa/V0P3W9zlx+pcoEBNXvU5iOc1cVHxqZ\n\tCVtiTvJh+u0pA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658501726;\n\tbh=U9OG7txT11OfeiYeYZGum9rZG5CuoM0OIcLF85qCl2E=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=oD9RTz0on0HXyf8WfaM2Je1ZpYj7PqfQKXtRZRBd/+SEdqE/xwrp3XBm/xiRy1Oz1\n\tqIIh/5EkyTQG5BNE7MOPw703S8M8suRyxFF9LTNxSg0ORjUyQkUFd5e9JGc+r4IA9l\n\tFhGVVFtl/vn/asiwLbsgDp897gFBCg07DVHVsY8g="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"oD9RTz0o\"; dkim-atps=neutral","Message-ID":"<9085aa28-86b9-e996-afe1-698bd49eef8e@ideasonboard.com>","Date":"Fri, 22 Jul 2022 20:25:22 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.4.1","Content-Language":"en-US","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","References":"<20220721121310.1286862-1-kieran.bingham@ideasonboard.com>\n\t<20220721121310.1286862-6-kieran.bingham@ideasonboard.com>","In-Reply-To":"<20220721121310.1286862-6-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [RFC PATCH 05/12] ipa: rkisp1: Rename\n\tframeContext to activeState","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>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24107,"web_url":"https://patchwork.libcamera.org/comment/24107/","msgid":"<20220725152405.ccsz6cjdnhdonncu@uno.localdomain>","date":"2022-07-25T15:24:05","subject":"Re: [libcamera-devel] [RFC PATCH 05/12] ipa: rkisp1: Rename\n\tframeContext to activeState","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran\n\nOn Thu, Jul 21, 2022 at 01:13:03PM +0100, Kieran Bingham via libcamera-devel wrote:\n> Move the existing frame context structure to the IPAActiveState.\n> This structure should store the most up to date results for the IPA\n> which may be shared to other algorithms that operate on the data.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 20 +++++++++---------\n>  src/ipa/rkisp1/algorithms/awb.cpp | 34 +++++++++++++++----------------\n>  src/ipa/rkisp1/algorithms/blc.cpp |  2 +-\n>  src/ipa/rkisp1/ipa_context.h      |  7 +++++--\n>  src/ipa/rkisp1/rkisp1.cpp         | 12 +++++------\n>  5 files changed, 39 insertions(+), 36 deletions(-)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index a1bb7d972926..483e941fe427 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -73,8 +73,8 @@ Agc::Agc()\n>  int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n>  {\n>  \t/* Configure the default exposure and gain. */\n> -\tcontext.frameContext.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n> -\tcontext.frameContext.agc.exposure = 10ms / context.configuration.sensor.lineDuration;\n> +\tcontext.activeState.agc.gain = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);\n> +\tcontext.activeState.agc.exposure = 10ms / context.configuration.sensor.lineDuration;\n>\n>  \t/*\n>  \t * According to the RkISP1 documentation:\n> @@ -98,7 +98,7 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n>  \tcontext.configuration.agc.measureWindow.h_size = 3 * configInfo.outputSize.width / 4;\n>  \tcontext.configuration.agc.measureWindow.v_size = 3 * configInfo.outputSize.height / 4;\n>\n> -\t/* \\todo Use actual frame index by populating it in the frameContext. */\n> +\t/* \\todo Use actual frame index by populating it in the activeState. */\n>  \tframeCount_ = 0;\n>  \treturn 0;\n>  }\n> @@ -140,18 +140,18 @@ utils::Duration Agc::filterExposure(utils::Duration exposureValue)\n>\n>  /**\n>   * \\brief Estimate the new exposure and gain values\n> - * \\param[inout] frameContext The shared IPA frame Context\n> + * \\param[inout] context The shared IPA Context\n>   * \\param[in] yGain The gain calculated on the current brightness level\n>   * \\param[in] iqMeanGain The gain calculated based on the relative luminance target\n>   */\n>  void Agc::computeExposure(IPAContext &context, double yGain, double iqMeanGain)\n>  {\n>  \tIPASessionConfiguration &configuration = context.configuration;\n> -\tIPAFrameContext &frameContext = context.frameContext;\n> +\tIPAActiveState &activeState = context.activeState;\n>\n>  \t/* Get the effective exposure and gain applied on the sensor. */\n> -\tuint32_t exposure = frameContext.sensor.exposure;\n> -\tdouble analogueGain = frameContext.sensor.gain;\n> +\tuint32_t exposure = activeState.sensor.exposure;\n> +\tdouble analogueGain = activeState.sensor.gain;\n>\n>  \t/* Use the highest of the two gain estimates. */\n>  \tdouble evGain = std::max(yGain, iqMeanGain);\n> @@ -216,8 +216,8 @@ void Agc::computeExposure(IPAContext &context, double yGain, double iqMeanGain)\n>  \t\t\t      << stepGain;\n>\n>  \t/* Update the estimated exposure and gain. */\n> -\tframeContext.agc.exposure = shutterTime / configuration.sensor.lineDuration;\n> -\tframeContext.agc.gain = stepGain;\n> +\tactiveState.agc.exposure = shutterTime / configuration.sensor.lineDuration;\n> +\tactiveState.agc.gain = stepGain;\n>  }\n>\n>  /**\n> @@ -324,7 +324,7 @@ void Agc::process(IPAContext &context,\n>   */\n>  void Agc::prepare(IPAContext &context, rkisp1_params_cfg *params)\n>  {\n> -\tif (context.frameContext.frameCount > 0)\n> +\tif (context.activeState.frameCount > 0)\n>  \t\treturn;\n>\n>  \t/* Configure the measurement window. */\n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 9f00364d12b1..427aaeb1e955 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -35,9 +35,9 @@ LOG_DEFINE_CATEGORY(RkISP1Awb)\n>  int Awb::configure(IPAContext &context,\n>  \t\t   const IPACameraSensorInfo &configInfo)\n>  {\n> -\tcontext.frameContext.awb.gains.red = 1.0;\n> -\tcontext.frameContext.awb.gains.blue = 1.0;\n> -\tcontext.frameContext.awb.gains.green = 1.0;\n> +\tcontext.activeState.awb.gains.red = 1.0;\n> +\tcontext.activeState.awb.gains.blue = 1.0;\n> +\tcontext.activeState.awb.gains.green = 1.0;\n>\n>  \t/*\n>  \t * Define the measurement window for AWB as a centered rectangle\n> @@ -72,16 +72,16 @@ uint32_t Awb::estimateCCT(double red, double green, double blue)\n>   */\n>  void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params)\n>  {\n> -\tparams->others.awb_gain_config.gain_green_b = 256 * context.frameContext.awb.gains.green;\n> -\tparams->others.awb_gain_config.gain_blue = 256 * context.frameContext.awb.gains.blue;\n> -\tparams->others.awb_gain_config.gain_red = 256 * context.frameContext.awb.gains.red;\n> -\tparams->others.awb_gain_config.gain_green_r = 256 * context.frameContext.awb.gains.green;\n> +\tparams->others.awb_gain_config.gain_green_b = 256 * context.activeState.awb.gains.green;\n> +\tparams->others.awb_gain_config.gain_blue = 256 * context.activeState.awb.gains.blue;\n> +\tparams->others.awb_gain_config.gain_red = 256 * context.activeState.awb.gains.red;\n> +\tparams->others.awb_gain_config.gain_green_r = 256 * context.activeState.awb.gains.green;\n>\n>  \t/* Update the gains. */\n>  \tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;\n>\n>  \t/* If we already have configured the gains and window, return. */\n> -\tif (context.frameContext.frameCount > 0)\n> +\tif (context.activeState.frameCount > 0)\n>  \t\treturn;\n>\n>  \t/* Configure the gains to apply. */\n> @@ -125,7 +125,7 @@ void Awb::process([[maybe_unused]] IPAContext &context,\n>  {\n>  \tconst rkisp1_cif_isp_stat *params = &stats->params;\n>  \tconst rkisp1_cif_isp_awb_stat *awb = &params->awb;\n> -\tIPAFrameContext &frameContext = context.frameContext;\n> +\tIPAActiveState &activeState = context.activeState;\n>\n>  \t/* Get the YCbCr mean values */\n>  \tdouble yMean = awb->awb_mean[0].mean_y_or_g;\n> @@ -157,22 +157,22 @@ void Awb::process([[maybe_unused]] IPAContext &context,\n>\n>  \t/* Filter the values to avoid oscillations. */\n>  \tdouble speed = 0.2;\n> -\tredGain = speed * redGain + (1 - speed) * frameContext.awb.gains.red;\n> -\tblueGain = speed * blueGain + (1 - speed) * frameContext.awb.gains.blue;\n> +\tredGain = speed * redGain + (1 - speed) * activeState.awb.gains.red;\n> +\tblueGain = speed * blueGain + (1 - speed) * activeState.awb.gains.blue;\n>\n>  \t/*\n>  \t * Gain values are unsigned integer value, range 0 to 4 with 8 bit\n>  \t * fractional part.\n>  \t */\n> -\tframeContext.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);\n> -\tframeContext.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);\n> +\tactiveState.awb.gains.red = std::clamp(redGain, 0.0, 1023.0 / 256);\n> +\tactiveState.awb.gains.blue = std::clamp(blueGain, 0.0, 1023.0 / 256);\n>  \t/* Hardcode the green gain to 1.0. */\n> -\tframeContext.awb.gains.green = 1.0;\n> +\tactiveState.awb.gains.green = 1.0;\n>\n> -\tframeContext.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n> +\tactiveState.awb.temperatureK = estimateCCT(redMean, greenMean, blueMean);\n>\n> -\tLOG(RkISP1Awb, Debug) << \"Gain found for red: \" << context.frameContext.awb.gains.red\n> -\t\t\t      << \" and for blue: \" << context.frameContext.awb.gains.blue;\n> +\tLOG(RkISP1Awb, Debug) << \"Gain found for red: \" << context.activeState.awb.gains.red\n> +\t\t\t      << \" and for blue: \" << context.activeState.awb.gains.blue;\n>  }\n>\n>  REGISTER_IPA_ALGORITHM(Awb, \"Awb\")\n> diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\n> index a58569fa2dc2..4d55a2d529cb 100644\n> --- a/src/ipa/rkisp1/algorithms/blc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/blc.cpp\n> @@ -68,7 +68,7 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,\n>  void BlackLevelCorrection::prepare(IPAContext &context,\n>  \t\t\t\t   rkisp1_params_cfg *params)\n>  {\n> -\tif (context.frameContext.frameCount > 0)\n> +\tif (context.activeState.frameCount > 0)\n>  \t\treturn;\n>\n>  \tif (!tuningParameters_)\n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index f387cacea363..341fef2e68fe 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -40,7 +40,7 @@ struct IPASessionConfiguration {\n>  \t} hw;\n>  };\n>\n> -struct IPAFrameContext {\n> +struct IPAActiveState {\n>  \tstruct {\n>  \t\tuint32_t exposure;\n>  \t\tdouble gain;\n> @@ -64,9 +64,12 @@ struct IPAFrameContext {\n>  \tunsigned int frameCount;\n>  };\n>\n> +struct IPAFrameContext {\n> +};\n> +\n>  struct IPAContext {\n>  \tIPASessionConfiguration configuration;\n> -\tIPAFrameContext frameContext;\n> +\tIPAActiveState activeState;\n>  };\n>\n>  } /* namespace ipa::rkisp1 */\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 21166b0f1ba6..9629ccbf4247 100644\n> --- a/src/ipa/rkisp1/rkisp1.cpp\n> +++ b/src/ipa/rkisp1/rkisp1.cpp\n> @@ -224,7 +224,7 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,\n>  \tcontext_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain);\n>  \tcontext_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain);\n>\n> -\tcontext_.frameContext.frameCount = 0;\n> +\tcontext_.activeState.frameCount = 0;\n>\n>  \tfor (auto const &algo : algorithms()) {\n>  \t\tint ret = algo->configure(context_, info);\n> @@ -284,7 +284,7 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)\n>  \t\talgo->prepare(context_, params);\n>\n>  \tparamsBufferReady.emit(frame);\n> -\tcontext_.frameContext.frameCount++;\n> +\tcontext_.activeState.frameCount++;\n>  }\n>\n>  void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,\n> @@ -294,9 +294,9 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n>  \t\treinterpret_cast<rkisp1_stat_buffer *>(\n>  \t\t\tmappedBuffers_.at(bufferId).planes()[0].data());\n>\n> -\tcontext_.frameContext.sensor.exposure =\n> +\tcontext_.activeState.sensor.exposure =\n>  \t\tsensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();\n> -\tcontext_.frameContext.sensor.gain =\n> +\tcontext_.activeState.sensor.gain =\n>  \t\tcamHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());\n>\n>  \tunsigned int aeState = 0;\n> @@ -311,8 +311,8 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId\n>\n>  void IPARkISP1::setControls(unsigned int frame)\n>  {\n> -\tuint32_t exposure = context_.frameContext.agc.exposure;\n> -\tuint32_t gain = camHelper_->gainCode(context_.frameContext.agc.gain);\n> +\tuint32_t exposure = context_.activeState.agc.exposure;\n> +\tuint32_t gain = camHelper_->gainCode(context_.activeState.agc.gain);\n>\n>  \tControlList ctrls(ctrls_);\n>  \tctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure));\n> --\n> 2.34.1\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 5F6CBC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 25 Jul 2022 15:24:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BFA5063312;\n\tMon, 25 Jul 2022 17:24:10 +0200 (CEST)","from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::225])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B29366330A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 Jul 2022 17:24:08 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 1C8721C0013;\n\tMon, 25 Jul 2022 15:24:07 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658762650;\n\tbh=tV7EtiKmWg5nWT1Kwa0xRQyh14C+33Ubyp1J9QHxIhc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=X1DLST6G4N+qmxsXNggYZ+OsDztkYwURO/x2DejqxKPRX7UnAhFAaDNN5ZIBl2vQC\n\tmZd6FXalwNLSMld3zjtOiBv1HHdkGGvleTTKiEX0MmfLw7giQl9pmL4IK/msYXNw68\n\tEpKkU8mzgM/t1Wd728yDQ3KvXTgJiWilFdcgQ6RCe/grx0VjDxWdopiV04yjYWmeao\n\tU62PLtr11OKj4Mqi3wYMD0xk8aIVEA76KnrzpgT2K63H2kr9BRPIabC4Ju9N21QFKY\n\t+aVeZukXKwexa1EZHothlmZzVZMioL04jpquM4OeCi9tE9yMsweeLWjrqByCmEtnk9\n\t9ZzZsrp5CZckw==","Date":"Mon, 25 Jul 2022 17:24:05 +0200","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20220725152405.ccsz6cjdnhdonncu@uno.localdomain>","References":"<20220721121310.1286862-1-kieran.bingham@ideasonboard.com>\n\t<20220721121310.1286862-6-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220721121310.1286862-6-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH 05/12] ipa: rkisp1: Rename\n\tframeContext to activeState","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>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]