[{"id":39498,"web_url":"https://patchwork.libcamera.org/comment/39498/","msgid":"<178272758039.36676.16957299347041587991@ping.linuxembedded.co.uk>","date":"2026-06-29T10:06:20","subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Daniel Scally (2026-06-26 14:05:50)\n> The AGC algorithm stores red, blue and green gains as type double\n> class members. Switch to using a single member of type RGB<double>\n> instead to simplify the code.\n> \n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n> Changes in v2:\n> \n>         - New patch\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 9 ++++-----\n>  src/ipa/ipu3/algorithms/agc.h   | 6 +++---\n>  2 files changed, 7 insertions(+), 8 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index d6a7036c6504acb106f5c773b529ad80b8349f85..b8b880b357a4770efd6810a3bdf616dd25ce93e4 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -186,8 +186,7 @@ double Agc::estimateLuminance(double gain) const\n>                 sum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);\n>         }\n>  \n> -       RGB<double> gains{{ rGain_, gGain_, bGain_ }};\n> -       double ySum = rec601LuminanceFromRGB(sum * gains);\n> +       double ySum = rec601LuminanceFromRGB(sum * gains_);\n>         return ySum / (bdsGrid_.height * bdsGrid_.width) / 255;\n>  }\n>  \n> @@ -208,9 +207,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>                   ControlList &metadata)\n>  {\n>         Histogram hist = parseStatistics(stats, context.configuration.grid.bdsGrid);\n> -       rGain_ = context.activeState.awb.gains.red;\n> -       gGain_ = context.activeState.awb.gains.blue;\n> -       bGain_ = context.activeState.awb.gains.green;\n> +       gains_ = RGB<double>({ context.activeState.awb.gains.red,\n> +                              context.activeState.awb.gains.blue,\n> +                              context.activeState.awb.gains.green });\n\nCan this construct from:\n\tgains_ = RGB<double>(context.activeState.awb.gains);\n\n?\n\nIt might not, and it's not 'wrong' so:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n>  \n>         /*\n>          * The Agc algorithm needs to know the effective exposure value that was\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index d274a2350485f8f9a3870b24ceb29927cb9c2bec..12ddb173ff89b7de68dd544a194292f4d14efdbb 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -13,6 +13,8 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> +#include \"libcamera/internal/vector.h\"\n> +\n>  #include \"libipa/agc_mean_luminance.h\"\n>  #include \"libipa/histogram.h\"\n>  \n> @@ -49,9 +51,7 @@ private:\n>         double maxAnalogueGain_;\n>  \n>         uint32_t stride_;\n> -       double rGain_;\n> -       double gGain_;\n> -       double bGain_;\n> +       RGB<double> gains_;\n>         ipu3_uapi_grid_config bdsGrid_;\n>         std::vector<std::tuple<uint8_t, uint8_t, uint8_t>> rgbTriples_;\n>  };\n> \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 0E68DC3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2026 10:06:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 351FF65F04;\n\tMon, 29 Jun 2026 12:06:25 +0200 (CEST)","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 1031D65F04\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 12:06:23 +0200 (CEST)","from monstersaurus.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 DE75834;\n\tMon, 29 Jun 2026 12:05:39 +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=\"s0UaUMnI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782727540;\n\tbh=XTQ3YryAf3NyfVujyBtVFZdVJcm8Y4Edqkuoe1JSgEk=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=s0UaUMnIehkd1e/jIuPdV80KMlEyWpwKJ9Geqzsh7zfC+xfBZR9+xK8dBzlO+0ipB\n\tO58jwB9lMK7aFF3DFfg/tS5/qe+/MTwuFBpJJODsRLVBcBEYrTvYx00iRibAs7Kgmd\n\to8KyHB0hgDSKsCVQs1m7zcK7n2lJIW+79GsI1jeA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>","References":"<20260626-ipu3-libipa-rework-v2-0-41546e23de3e@ideasonboard.com>\n\t<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>","Subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Daniel Scally <dan.scally@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 29 Jun 2026 11:06:20 +0100","Message-ID":"<178272758039.36676.16957299347041587991@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":39507,"web_url":"https://patchwork.libcamera.org/comment/39507/","msgid":"<ee749a46-50d4-4b70-a1ab-51e8f2c6e2f1@ideasonboard.com>","date":"2026-06-30T08:24:59","subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 06. 29. 12:06 keltezéssel, Kieran Bingham írta:\n> Quoting Daniel Scally (2026-06-26 14:05:50)\n>> The AGC algorithm stores red, blue and green gains as type double\n>> class members. Switch to using a single member of type RGB<double>\n>> instead to simplify the code.\n>>\n>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n>> ---\n>> Changes in v2:\n>>\n>>          - New patch\n>> ---\n>>   src/ipa/ipu3/algorithms/agc.cpp | 9 ++++-----\n>>   src/ipa/ipu3/algorithms/agc.h   | 6 +++---\n>>   2 files changed, 7 insertions(+), 8 deletions(-)\n>>\n>> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n>> index d6a7036c6504acb106f5c773b529ad80b8349f85..b8b880b357a4770efd6810a3bdf616dd25ce93e4 100644\n>> --- a/src/ipa/ipu3/algorithms/agc.cpp\n>> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n>> @@ -186,8 +186,7 @@ double Agc::estimateLuminance(double gain) const\n>>                  sum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);\n>>          }\n>>   \n>> -       RGB<double> gains{{ rGain_, gGain_, bGain_ }};\n>> -       double ySum = rec601LuminanceFromRGB(sum * gains);\n>> +       double ySum = rec601LuminanceFromRGB(sum * gains_);\n>>          return ySum / (bdsGrid_.height * bdsGrid_.width) / 255;\n>>   }\n>>   \n>> @@ -208,9 +207,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>>                    ControlList &metadata)\n>>   {\n>>          Histogram hist = parseStatistics(stats, context.configuration.grid.bdsGrid);\n>> -       rGain_ = context.activeState.awb.gains.red;\n>> -       gGain_ = context.activeState.awb.gains.blue;\n>> -       bGain_ = context.activeState.awb.gains.green;\n>> +       gains_ = RGB<double>({ context.activeState.awb.gains.red,\n>> +                              context.activeState.awb.gains.blue,\n>> +                              context.activeState.awb.gains.green });\n> \n> Can this construct from:\n> \tgains_ = RGB<double>(context.activeState.awb.gains);\n> \n> ?\n> \n> It might not, and it's not 'wrong' so:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nIt would require changing `ipu3::IPAActiveState::gains` to be e.g. `RGB<double>`\nbecause it is just a struct of unnamed type; this shouldn't be too hard as far\nas I can tell, if it's deemed to be worth it.\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n> \n> \n>>   \n>>          /*\n>>           * The Agc algorithm needs to know the effective exposure value that was\n>> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n>> index d274a2350485f8f9a3870b24ceb29927cb9c2bec..12ddb173ff89b7de68dd544a194292f4d14efdbb 100644\n>> --- a/src/ipa/ipu3/algorithms/agc.h\n>> +++ b/src/ipa/ipu3/algorithms/agc.h\n>> @@ -13,6 +13,8 @@\n>>   \n>>   #include <libcamera/geometry.h>\n>>   \n>> +#include \"libcamera/internal/vector.h\"\n>> +\n>>   #include \"libipa/agc_mean_luminance.h\"\n>>   #include \"libipa/histogram.h\"\n>>   \n>> @@ -49,9 +51,7 @@ private:\n>>          double maxAnalogueGain_;\n>>   \n>>          uint32_t stride_;\n>> -       double rGain_;\n>> -       double gGain_;\n>> -       double bGain_;\n>> +       RGB<double> gains_;\n>>          ipu3_uapi_grid_config bdsGrid_;\n>>          std::vector<std::tuple<uint8_t, uint8_t, uint8_t>> rgbTriples_;\n>>   };\n>>\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 E3737C3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Jun 2026 08:25:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F4CE65F47;\n\tTue, 30 Jun 2026 10:25:06 +0200 (CEST)","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 55AA7658C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Jun 2026 10:25:04 +0200 (CEST)","from [192.168.33.31] (185.221.140.128.nat.pool.zt.hu\n\t[185.221.140.128])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 515C5D52;\n\tTue, 30 Jun 2026 10:24:20 +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=\"Nb2X/7R2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782807860;\n\tbh=OS4Y3uZx5KyMUKztJviz7k0Avi8qOoahxKut2Ldjdgk=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=Nb2X/7R2gPX2pEDkmIx79Ab6GVmcneHzkSnMNhivy8ovQAEHKFGMWaCpEb22xl0kl\n\ta9k15nZryFVTjQiMwwScpN/vLbAsrQ3SBA7K3Abo0jxj4glYoaJ37QIYduS0CV/yo3\n\t+MxVFIHc52RZWWIhqRvgi7qStf30NEDAHo1fV+EE=","Message-ID":"<ee749a46-50d4-4b70-a1ab-51e8f2c6e2f1@ideasonboard.com>","Date":"Tue, 30 Jun 2026 10:24:59 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20260626-ipu3-libipa-rework-v2-0-41546e23de3e@ideasonboard.com>\n\t<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>\n\t<178272758039.36676.16957299347041587991@ping.linuxembedded.co.uk>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<178272758039.36676.16957299347041587991@ping.linuxembedded.co.uk>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":39508,"web_url":"https://patchwork.libcamera.org/comment/39508/","msgid":"<1ec96377-3c01-4114-a181-a7259df1dc22@ideasonboard.com>","date":"2026-06-30T08:29:22","subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Barnabas\n\nOn 30/06/2026 09:24, Barnabás Pőcze wrote:\n> 2026. 06. 29. 12:06 keltezéssel, Kieran Bingham írta:\n>> Quoting Daniel Scally (2026-06-26 14:05:50)\n>>> The AGC algorithm stores red, blue and green gains as type double\n>>> class members. Switch to using a single member of type RGB<double>\n>>> instead to simplify the code.\n>>>\n>>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n>>> ---\n>>> Changes in v2:\n>>>\n>>>          - New patch\n>>> ---\n>>>   src/ipa/ipu3/algorithms/agc.cpp | 9 ++++-----\n>>>   src/ipa/ipu3/algorithms/agc.h   | 6 +++---\n>>>   2 files changed, 7 insertions(+), 8 deletions(-)\n>>>\n>>> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n>>> index d6a7036c6504acb106f5c773b529ad80b8349f85..b8b880b357a4770efd6810a3bdf616dd25ce93e4 100644\n>>> --- a/src/ipa/ipu3/algorithms/agc.cpp\n>>> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n>>> @@ -186,8 +186,7 @@ double Agc::estimateLuminance(double gain) const\n>>>                  sum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);\n>>>          }\n>>> -       RGB<double> gains{{ rGain_, gGain_, bGain_ }};\n>>> -       double ySum = rec601LuminanceFromRGB(sum * gains);\n>>> +       double ySum = rec601LuminanceFromRGB(sum * gains_);\n>>>          return ySum / (bdsGrid_.height * bdsGrid_.width) / 255;\n>>>   }\n>>> @@ -208,9 +207,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>>>                    ControlList &metadata)\n>>>   {\n>>>          Histogram hist = parseStatistics(stats, context.configuration.grid.bdsGrid);\n>>> -       rGain_ = context.activeState.awb.gains.red;\n>>> -       gGain_ = context.activeState.awb.gains.blue;\n>>> -       bGain_ = context.activeState.awb.gains.green;\n>>> +       gains_ = RGB<double>({ context.activeState.awb.gains.red,\n>>> +                              context.activeState.awb.gains.blue,\n>>> +                              context.activeState.awb.gains.green });\n>>\n>> Can this construct from:\n>>     gains_ = RGB<double>(context.activeState.awb.gains);\n>>\n>> ?\n>>\n>> It might not, and it's not 'wrong' so:\n>>\n>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> It would require changing `ipu3::IPAActiveState::gains` to be e.g. `RGB<double>`\n> because it is just a struct of unnamed type; this shouldn't be too hard as far\n> as I can tell, if it's deemed to be worth it.\n\nThat struct is dropped in the next patch anyway, and replaced with ipa::ActiveState::awb. I can \nchange this patch if we want, but it doesn't seem worthwhile to me.\n\n> \n> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nThanks!\n\nDan\n> \n> \n>>\n>>\n>>>          /*\n>>>           * The Agc algorithm needs to know the effective exposure value that was\n>>> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n>>> index d274a2350485f8f9a3870b24ceb29927cb9c2bec..12ddb173ff89b7de68dd544a194292f4d14efdbb 100644\n>>> --- a/src/ipa/ipu3/algorithms/agc.h\n>>> +++ b/src/ipa/ipu3/algorithms/agc.h\n>>> @@ -13,6 +13,8 @@\n>>>   #include <libcamera/geometry.h>\n>>> +#include \"libcamera/internal/vector.h\"\n>>> +\n>>>   #include \"libipa/agc_mean_luminance.h\"\n>>>   #include \"libipa/histogram.h\"\n>>> @@ -49,9 +51,7 @@ private:\n>>>          double maxAnalogueGain_;\n>>>          uint32_t stride_;\n>>> -       double rGain_;\n>>> -       double gGain_;\n>>> -       double bGain_;\n>>> +       RGB<double> gains_;\n>>>          ipu3_uapi_grid_config bdsGrid_;\n>>>          std::vector<std::tuple<uint8_t, uint8_t, uint8_t>> rgbTriples_;\n>>>   };\n>>>\n>>> -- \n>>> 2.43.0\n>>>\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 39EA8C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Jun 2026 08:29:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4254865F4A;\n\tTue, 30 Jun 2026 10:29:27 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CFC83658C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Jun 2026 10:29:25 +0200 (CEST)","from [192.168.0.43]\n\t(chfd-03-b2-v4wan-176392-cust229.vm15.cable.virginm.net\n\t[82.19.20.230])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E1CA4D52;\n\tTue, 30 Jun 2026 10:28:41 +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=\"AAVuNkI6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782808122;\n\tbh=uKRtZS990m+4TOdf1bT2YDcJX2Tm6S/1doSmn0tGGLE=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=AAVuNkI65itCQ+zWlbcc+V35aSAVXRqOlOsE57pzX8jiHLalDjEAqQITXXGoncI37\n\tfoImTm0vJayNfHoDFtXx89TCxDHa/+1DjxtFoF6JJQyk5yUAw465yb8RkEzWVmzcKq\n\tm1vjIDX6OwWQEH1l/euSmevy3i8wIXXXAlAjGM84=","Message-ID":"<1ec96377-3c01-4114-a181-a7259df1dc22@ideasonboard.com>","Date":"Tue, 30 Jun 2026 09:29:22 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","References":"<20260626-ipu3-libipa-rework-v2-0-41546e23de3e@ideasonboard.com>\n\t<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>\n\t<178272758039.36676.16957299347041587991@ping.linuxembedded.co.uk>\n\t<ee749a46-50d4-4b70-a1ab-51e8f2c6e2f1@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","In-Reply-To":"<ee749a46-50d4-4b70-a1ab-51e8f2c6e2f1@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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":39522,"web_url":"https://patchwork.libcamera.org/comment/39522/","msgid":"<178281669606.471733.16813291465484665324@ping.linuxembedded.co.uk>","date":"2026-06-30T10:51:36","subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Dan Scally (2026-06-30 09:29:22)\n> Hi Barnabas\n> \n> On 30/06/2026 09:24, Barnabás Pőcze wrote:\n> > 2026. 06. 29. 12:06 keltezéssel, Kieran Bingham írta:\n> >> Quoting Daniel Scally (2026-06-26 14:05:50)\n> >>> The AGC algorithm stores red, blue and green gains as type double\n> >>> class members. Switch to using a single member of type RGB<double>\n> >>> instead to simplify the code.\n> >>>\n> >>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> >>> ---\n> >>> Changes in v2:\n> >>>\n> >>>          - New patch\n> >>> ---\n> >>>   src/ipa/ipu3/algorithms/agc.cpp | 9 ++++-----\n> >>>   src/ipa/ipu3/algorithms/agc.h   | 6 +++---\n> >>>   2 files changed, 7 insertions(+), 8 deletions(-)\n> >>>\n> >>> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> >>> index d6a7036c6504acb106f5c773b529ad80b8349f85..b8b880b357a4770efd6810a3bdf616dd25ce93e4 100644\n> >>> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> >>> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> >>> @@ -186,8 +186,7 @@ double Agc::estimateLuminance(double gain) const\n> >>>                  sum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);\n> >>>          }\n> >>> -       RGB<double> gains{{ rGain_, gGain_, bGain_ }};\n> >>> -       double ySum = rec601LuminanceFromRGB(sum * gains);\n> >>> +       double ySum = rec601LuminanceFromRGB(sum * gains_);\n> >>>          return ySum / (bdsGrid_.height * bdsGrid_.width) / 255;\n> >>>   }\n> >>> @@ -208,9 +207,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> >>>                    ControlList &metadata)\n> >>>   {\n> >>>          Histogram hist = parseStatistics(stats, context.configuration.grid.bdsGrid);\n> >>> -       rGain_ = context.activeState.awb.gains.red;\n> >>> -       gGain_ = context.activeState.awb.gains.blue;\n> >>> -       bGain_ = context.activeState.awb.gains.green;\n> >>> +       gains_ = RGB<double>({ context.activeState.awb.gains.red,\n> >>> +                              context.activeState.awb.gains.blue,\n> >>> +                              context.activeState.awb.gains.green });\n> >>\n> >> Can this construct from:\n> >>     gains_ = RGB<double>(context.activeState.awb.gains);\n> >>\n> >> ?\n> >>\n> >> It might not, and it's not 'wrong' so:\n> >>\n> >> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > \n> > It would require changing `ipu3::IPAActiveState::gains` to be e.g. `RGB<double>`\n> > because it is just a struct of unnamed type; this shouldn't be too hard as far\n> > as I can tell, if it's deemed to be worth it.\n> \n> That struct is dropped in the next patch anyway, and replaced with ipa::ActiveState::awb. I can \n> change this patch if we want, but it doesn't seem worthwhile to me.\n\nabsolutely, leave it as is!\n--\nKieran\n\n> \n> > \n> > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\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 24775C3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Jun 2026 10:51:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 330CB65F6D;\n\tTue, 30 Jun 2026 12:51:40 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F371F65F55\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Jun 2026 12:51:38 +0200 (CEST)","from monstersaurus.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 E7284D52;\n\tTue, 30 Jun 2026 12:50:54 +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=\"gaOVvFCS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1782816655;\n\tbh=HfF7HQ88u84+muGdDHsu9vekR8Vzh08KrfPPwKBhC8g=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=gaOVvFCSjZqU2xXGFBF3Vqhnw8YBZlEv6iqWqi/xzE0Z0+8vKJK1T78Qldp8OeqgS\n\tp5D1GeBn4g5NErq1aXnEe68wJmpwzV3l4SmAsDU/KEqFEoVadGdyggffKVNKWQmyFB\n\twxz7nwFTC9zMyYVQ+li2FDjzXSWkcA7sg75Gt9X0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<1ec96377-3c01-4114-a181-a7259df1dc22@ideasonboard.com>","References":"<20260626-ipu3-libipa-rework-v2-0-41546e23de3e@ideasonboard.com>\n\t<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>\n\t<178272758039.36676.16957299347041587991@ping.linuxembedded.co.uk>\n\t<ee749a46-50d4-4b70-a1ab-51e8f2c6e2f1@ideasonboard.com>\n\t<1ec96377-3c01-4114-a181-a7259df1dc22@ideasonboard.com>","Subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>,\n\tDan Scally <dan.scally@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 30 Jun 2026 11:51:36 +0100","Message-ID":"<178281669606.471733.16813291465484665324@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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":39640,"web_url":"https://patchwork.libcamera.org/comment/39640/","msgid":"<ak5qVetda9n5Er-K@zed>","date":"2026-07-08T15:18:59","subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Dan\n\nOn Fri, Jun 26, 2026 at 02:05:50PM +0100, Daniel Scally wrote:\n> The AGC algorithm stores red, blue and green gains as type double\n> class members. Switch to using a single member of type RGB<double>\n> instead to simplify the code.\n>\n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n> ---\n> Changes in v2:\n>\n>         - New patch\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 9 ++++-----\n>  src/ipa/ipu3/algorithms/agc.h   | 6 +++---\n>  2 files changed, 7 insertions(+), 8 deletions(-)\n>\n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index d6a7036c6504acb106f5c773b529ad80b8349f85..b8b880b357a4770efd6810a3bdf616dd25ce93e4 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -186,8 +186,7 @@ double Agc::estimateLuminance(double gain) const\n>  \t\tsum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);\n>  \t}\n>\n> -\tRGB<double> gains{{ rGain_, gGain_, bGain_ }};\n> -\tdouble ySum = rec601LuminanceFromRGB(sum * gains);\n> +\tdouble ySum = rec601LuminanceFromRGB(sum * gains_);\n>  \treturn ySum / (bdsGrid_.height * bdsGrid_.width) / 255;\n>  }\n>\n> @@ -208,9 +207,9 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>  \t\t  ControlList &metadata)\n>  {\n>  \tHistogram hist = parseStatistics(stats, context.configuration.grid.bdsGrid);\n> -\trGain_ = context.activeState.awb.gains.red;\n> -\tgGain_ = context.activeState.awb.gains.blue;\n> -\tbGain_ = context.activeState.awb.gains.green;\n> +\tgains_ = RGB<double>({ context.activeState.awb.gains.red,\n> +\t\t\t       context.activeState.awb.gains.blue,\n> +\t\t\t       context.activeState.awb.gains.green });\n>\n>  \t/*\n>  \t * The Agc algorithm needs to know the effective exposure value that was\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index d274a2350485f8f9a3870b24ceb29927cb9c2bec..12ddb173ff89b7de68dd544a194292f4d14efdbb 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -13,6 +13,8 @@\n>\n>  #include <libcamera/geometry.h>\n>\n> +#include \"libcamera/internal/vector.h\"\n> +\n>  #include \"libipa/agc_mean_luminance.h\"\n>  #include \"libipa/histogram.h\"\n>\n> @@ -49,9 +51,7 @@ private:\n>  \tdouble maxAnalogueGain_;\n>\n>  \tuint32_t stride_;\n> -\tdouble rGain_;\n> -\tdouble gGain_;\n> -\tdouble bGain_;\n> +\tRGB<double> gains_;\n>  \tipu3_uapi_grid_config bdsGrid_;\n>  \tstd::vector<std::tuple<uint8_t, uint8_t, uint8_t>> rgbTriples_;\n>  };\n>\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 A2D94C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jul 2026 15:19:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 88A22660A2;\n\tWed,  8 Jul 2026 17:19:04 +0200 (CEST)","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 4221F6608D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jul 2026 17:19:03 +0200 (CEST)","from ideasonboard.com (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 11F81EAA;\n\tWed,  8 Jul 2026 17:18:13 +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=\"LCCDjPEC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783523893;\n\tbh=4z2o+kTNb3ydP8+W8w+NFn+6fOwz1kpKbiOozd8zB70=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LCCDjPEC1mBqWib0TX/tpOs2T187tBfFdStxGHMPEgjviGCQ7NA+qotUZvUoBmRog\n\tS0WcCYiwKCSQK9kcRkcDkJC52aRjup/w/EwN4IuJp8+KVchaouA1Y2amxozv4T6zUg\n\tvjOFljRJ4rDo/14+6zUirXAMsjzWRcC+13LgbNcE=","Date":"Wed, 8 Jul 2026 17:18:59 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 03/12] ipa: ipu3: Convert from separate gains to\n\tRGB<double> in AGC","Message-ID":"<ak5qVetda9n5Er-K@zed>","References":"<20260626-ipu3-libipa-rework-v2-0-41546e23de3e@ideasonboard.com>\n\t<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com>","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>"}}]