[{"id":33378,"web_url":"https://patchwork.libcamera.org/comment/33378/","msgid":"<173979396594.1238111.14662615852792891390@ping.linuxembedded.co.uk>","date":"2025-02-17T12:06:05","subject":"Re: [PATCH 04/10] ipa: rkisp1: Refactor automatic/manual structure\n\tin IPAActiveState","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-02-17 10:01:45)\n> Swap gains and automatic/manual in the IPAActiveState structure. This is\n> in preparation to adding another member, which is easier in this\n> structure.  This is also in sync with how it is modeled in agc. This\n> patch contains no functional changes.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 24 ++++++++++++------------\n>  src/ipa/rkisp1/ipa_context.h      |  9 ++++++---\n>  2 files changed, 18 insertions(+), 15 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index cffaa06a22c1..147277c98bb2 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -74,8 +74,8 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)\n>  int Awb::configure(IPAContext &context,\n>                    const IPACameraSensorInfo &configInfo)\n>  {\n> -       context.activeState.awb.gains.manual = RGB<double>{ 1.0 };\n> -       context.activeState.awb.gains.automatic = RGB<double>{ 1.0 };\n> +       context.activeState.awb.manual.gains = RGB<double>{ 1.0 };\n> +       context.activeState.awb.automatic.gains = RGB<double>{ 1.0 };\n>         context.activeState.awb.autoEnabled = true;\n>         context.activeState.awb.temperatureK = kDefaultColourTemperature;\n>  \n> @@ -120,8 +120,8 @@ void Awb::queueRequest(IPAContext &context,\n>         const auto &colourTemperature = controls.get(controls::ColourTemperature);\n>         bool update = false;\n>         if (colourGains) {\n> -               awb.gains.manual.r() = (*colourGains)[0];\n> -               awb.gains.manual.b() = (*colourGains)[1];\n> +               awb.manual.gains.r() = (*colourGains)[0];\n> +               awb.manual.gains.b() = (*colourGains)[1];\n>                 /*\n>                  * \\todo: Colour temperature reported in metadata is now\n>                  * incorrect, as we can't deduce the temperature from the gains.\n> @@ -130,17 +130,17 @@ void Awb::queueRequest(IPAContext &context,\n>                 update = true;\n>         } else if (colourTemperature && colourGainCurve_) {\n>                 const auto &gains = colourGainCurve_->getInterpolated(*colourTemperature);\n> -               awb.gains.manual.r() = gains[0];\n> -               awb.gains.manual.b() = gains[1];\n> +               awb.manual.gains.r() = gains[0];\n> +               awb.manual.gains.b() = gains[1];\n>                 awb.temperatureK = *colourTemperature;\n>                 update = true;\n>         }\n>  \n>         if (update)\n>                 LOG(RkISP1Awb, Debug)\n> -                       << \"Set colour gains to \" << awb.gains.manual;\n> +                       << \"Set colour gains to \" << awb.manual.gains;\n>  \n> -       frameContext.awb.gains = awb.gains.manual;\n> +       frameContext.awb.gains = awb.manual.gains;\n>         frameContext.awb.temperatureK = awb.temperatureK;\n>  }\n>  \n> @@ -155,7 +155,7 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>          * most up-to-date automatic values we can read.\n>          */\n>         if (frameContext.awb.autoEnabled) {\n> -               frameContext.awb.gains = context.activeState.awb.gains.automatic;\n> +               frameContext.awb.gains = context.activeState.awb.automatic.gains;\n>                 frameContext.awb.temperatureK = context.activeState.awb.temperatureK;\n>         }\n>  \n> @@ -332,14 +332,14 @@ void Awb::process(IPAContext &context,\n>  \n>         /* Filter the values to avoid oscillations. */\n>         double speed = 0.2;\n> -       gains = gains * speed + activeState.awb.gains.automatic * (1 - speed);\n> +       gains = gains * speed + activeState.awb.automatic.gains * (1 - speed);\n>  \n> -       activeState.awb.gains.automatic = gains;\n> +       activeState.awb.automatic.gains = gains;\n>  \n>         LOG(RkISP1Awb, Debug)\n>                 << std::showpoint\n>                 << \"Means \" << rgbMeans << \", gains \"\n> -               << activeState.awb.gains.automatic << \", temp \"\n> +               << activeState.awb.automatic.gains << \", temp \"\n>                 << activeState.awb.temperatureK << \"K\";\n>  }\n>  \n> diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> index c765b928a55f..1a374c96cd1a 100644\n> --- a/src/ipa/rkisp1/ipa_context.h\n> +++ b/src/ipa/rkisp1/ipa_context.h\n> @@ -89,9 +89,12 @@ struct IPAActiveState {\n>  \n>         struct {\n>                 struct {\n> -                       RGB<double> manual;\n> -                       RGB<double> automatic;\n> -               } gains;\n> +                       RGB<double> gains;\n> +               } manual;\n> +\n> +               struct {\n> +                       RGB<double> gains;\n> +               } automatic;\n\nWill we always add everything to both manual and automatic? I.e. should\nshould this be a defined as a structure struct AgcState or something\nwith\n\tstruct AgcState {\n\t\tRGB<double> gains;\n\t};\n\n\tAgcState manual;\n\tAgcState automatic;\n\n?\n\n>  \n>                 unsigned int temperatureK;\n>                 bool autoEnabled;\n> -- \n> 2.43.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 695BFBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 12:06:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1DD4868668;\n\tMon, 17 Feb 2025 13:06:11 +0100 (CET)","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 123AE61865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 13:06:09 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C31E9842;\n\tMon, 17 Feb 2025 13:04:47 +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=\"TMAU4FK1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1739793887;\n\tbh=mJqDIDB/fQesCPsh23646AMgTzo45SqXNf4uwABccp4=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=TMAU4FK1Pfz4WR1M+mpnXGBNZoTK4/nv+fSNtkpqVS8OrMvMIcj2on41xewiZVHms\n\tbNTZEtoUQS/7/DKM6xyNK07iVWrtErTpFbn+AlzHvoCUKd8IadmXSg9NjU+s/qtpCr\n\tsSP4f9SPH7RDFvyCyPpcFlr/a3DGO6gJvLyRZ2ac=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250217100203.297894-5-stefan.klug@ideasonboard.com>","References":"<20250217100203.297894-1-stefan.klug@ideasonboard.com>\n\t<20250217100203.297894-5-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH 04/10] ipa: rkisp1: Refactor automatic/manual structure\n\tin IPAActiveState","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 17 Feb 2025 12:06:05 +0000","Message-ID":"<173979396594.1238111.14662615852792891390@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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":33379,"web_url":"https://patchwork.libcamera.org/comment/33379/","msgid":"<173979501811.1238111.9673815918372744091@ping.linuxembedded.co.uk>","date":"2025-02-17T12:23:38","subject":"Re: [PATCH 04/10] ipa: rkisp1: Refactor automatic/manual structure\n\tin IPAActiveState","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Kieran Bingham (2025-02-17 12:06:05)\n> Quoting Stefan Klug (2025-02-17 10:01:45)\n> > Swap gains and automatic/manual in the IPAActiveState structure. This is\n> > in preparation to adding another member, which is easier in this\n> > structure.  This is also in sync with how it is modeled in agc. This\n> > patch contains no functional changes.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 24 ++++++++++++------------\n\n<snip>\n\n> > diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\n> > index c765b928a55f..1a374c96cd1a 100644\n> > --- a/src/ipa/rkisp1/ipa_context.h\n> > +++ b/src/ipa/rkisp1/ipa_context.h\n> > @@ -89,9 +89,12 @@ struct IPAActiveState {\n> >  \n> >         struct {\n> >                 struct {\n> > -                       RGB<double> manual;\n> > -                       RGB<double> automatic;\n> > -               } gains;\n> > +                       RGB<double> gains;\n> > +               } manual;\n> > +\n> > +               struct {\n> > +                       RGB<double> gains;\n> > +               } automatic;\n> \n> Will we always add everything to both manual and automatic? I.e. should\n> should this be a defined as a structure struct AgcState or something\n> with\n>         struct AgcState {\n>                 RGB<double> gains;\n>         };\n> \n>         AgcState manual;\n>         AgcState automatic;\n> \n> ?\n\nPerhaps even more so if we should then just put an AgcState agc into the\nFrameContext for directly assigning the \n\t\n\tFrameContext.agc = ManualMode ?\n\t\t\t   activeState.agc.manual : activeState.agc.automatic;\n\n> \n> >  \n> >                 unsigned int temperatureK;\n> >                 bool autoEnabled;\n> > -- \n> > 2.43.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 D076CBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 12:23:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 071806866A;\n\tMon, 17 Feb 2025 13:23:43 +0100 (CET)","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 8AFEC61865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 13:23:41 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1068E842;\n\tMon, 17 Feb 2025 13:22:20 +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=\"te5fZX5X\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1739794940;\n\tbh=nggIG9Hf5xI7vx6DYM1lk5D+x06hIcQYbSNETfLmaAc=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=te5fZX5Xkf8HxqvAN/yXvvGmD9m4Y1x1/MT7R61bM9cGMkE6fucHYQSQDMm/Jvu3A\n\tZy3h/cmPxheG7V6mjEialWNyDHMkvHbLXfJ9FhIZykxAGsNdaCVvGHnLkuSNDK9OgM\n\tOhEeX6ClHbs2DDI3Bgie0u4fe4qzX29IOQ+8bKxw=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<173979396594.1238111.14662615852792891390@ping.linuxembedded.co.uk>","References":"<20250217100203.297894-1-stefan.klug@ideasonboard.com>\n\t<20250217100203.297894-5-stefan.klug@ideasonboard.com>\n\t<173979396594.1238111.14662615852792891390@ping.linuxembedded.co.uk>","Subject":"Re: [PATCH 04/10] ipa: rkisp1: Refactor automatic/manual structure\n\tin IPAActiveState","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 17 Feb 2025 12:23:38 +0000","Message-ID":"<173979501811.1238111.9673815918372744091@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]