[{"id":37721,"web_url":"https://patchwork.libcamera.org/comment/37721/","msgid":"<256a8c4f-87a5-4b9d-a841-841852615e70@ideasonboard.com>","date":"2026-01-19T10:29:04","subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 14. 12:30 keltezéssel, Milan Zamazal írta:\n> Now, when we have a combined matrix, we can apply AWB gains to it\n> directly in awb.cpp.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   src/ipa/simple/algorithms/awb.cpp | 7 ++++++-\n>   src/ipa/simple/algorithms/lut.cpp | 5 +----\n>   2 files changed, 7 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n> index a391359fb..4d2f1df15 100644\n> --- a/src/ipa/simple/algorithms/awb.cpp\n> +++ b/src/ipa/simple/algorithms/awb.cpp\n> @@ -1,6 +1,6 @@\n>   /* SPDX-License-Identifier: LGPL-2.1-or-later */\n>   /*\n> - * Copyright (C) 2024, Red Hat Inc.\n> + * Copyright (C) 2024-2025 Red Hat Inc.\n>    *\n>    * Auto white balance\n>    */\n> @@ -40,6 +40,11 @@ void Awb::prepare(IPAContext &context,\n>   \t\t  [[maybe_unused]] DebayerParams *params)\n>   {\n>   \tauto &gains = context.activeState.awb.gains;\n> +\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n> +\t\t\t\t\t     0, gains.g(), 0,\n> +\t\t\t\t\t     0, 0, gains.b() } };\n> +\tcontext.activeState.combinedMatrix =\n> +\t\tcontext.activeState.combinedMatrix * gainMatrix;\n>   \t/* Just report, the gains are applied in LUT algorithm. */\n>   \tframeContext.gains.red = gains.r();\n>   \tframeContext.gains.blue = gains.b();\n> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\n> index 25b188b91..a6dbd7b1d 100644\n> --- a/src/ipa/simple/algorithms/lut.cpp\n> +++ b/src/ipa/simple/algorithms/lut.cpp\n> @@ -108,10 +108,7 @@ void Lut::prepare(IPAContext &context,\n>   \t\t\tparams->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];\n>   \t\t}\n>   \t} else if (context.activeState.matrixChanged || gammaUpdateNeeded) {\n> -\t\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n> -\t\t\t\t\t\t     0, gains.g(), 0,\n> -\t\t\t\t\t\t     0, 0, gains.b() } };\n> -\t\tauto matrix = context.activeState.combinedMatrix * gainMatrix;\n> +\t\tauto &matrix = context.activeState.combinedMatrix;\n\nIs it not a concern that this change will make it so that depending on `IPAContext::ccmEnabled`\nthe gains are applied in two different places (files, even)? If I'm not mistaken,\nthis split remains even after all changes have been applied?\n\n\n\n>   \t\tauto &red = params->redCcm;\n>   \t\tauto &green = params->greenCcm;\n>   \t\tauto &blue = params->blueCcm;","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 81FDBBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jan 2026 10:29:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A8EEC61FC3;\n\tMon, 19 Jan 2026 11:29:08 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B2B461F9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 11:29:07 +0100 (CET)","from [192.168.33.17] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2831A2D9;\n\tMon, 19 Jan 2026 11:28:37 +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=\"jTf3jgit\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768818517;\n\tbh=bV4lCGmM7oXnfsghLYTNox2Md3Zwo6Egrrn35oCpy2g=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=jTf3jgitX1MucF5UJsosCBi3HRYMbrDSCxrpN3fmIMj8R26EevhLVRsPcGONH3PLb\n\tls+zplgnWt/aozvfB0mLwKGBFZjeV207AgzODqQjGa4D6ahuIiUStWXFtQ4TjU8QHb\n\tR7pf/THd2kjHvbuLuTufeST643M13CJBRD3MLFAU=","Message-ID":"<256a8c4f-87a5-4b9d-a841-841852615e70@ideasonboard.com>","Date":"Mon, 19 Jan 2026 11:29:04 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>","References":"<20260114113016.25162-1-mzamazal@redhat.com>\n\t<20260114113016.25162-11-mzamazal@redhat.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260114113016.25162-11-mzamazal@redhat.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":37739,"web_url":"https://patchwork.libcamera.org/comment/37739/","msgid":"<85o6mp3bv9.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-19T14:39:38","subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Barnabás,\n\nthank you for review.\n\nBarnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:\n\n> 2026. 01. 14. 12:30 keltezéssel, Milan Zamazal írta:\n>> Now, when we have a combined matrix, we can apply AWB gains to it\n>> directly in awb.cpp.\n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>   src/ipa/simple/algorithms/awb.cpp | 7 ++++++-\n>>   src/ipa/simple/algorithms/lut.cpp | 5 +----\n>>   2 files changed, 7 insertions(+), 5 deletions(-)\n>> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n>> index a391359fb..4d2f1df15 100644\n>> --- a/src/ipa/simple/algorithms/awb.cpp\n>> +++ b/src/ipa/simple/algorithms/awb.cpp\n>> @@ -1,6 +1,6 @@\n>>   /* SPDX-License-Identifier: LGPL-2.1-or-later */\n>>   /*\n>> - * Copyright (C) 2024, Red Hat Inc.\n>> + * Copyright (C) 2024-2025 Red Hat Inc.\n>>    *\n>>    * Auto white balance\n>>    */\n>> @@ -40,6 +40,11 @@ void Awb::prepare(IPAContext &context,\n>>   \t\t  [[maybe_unused]] DebayerParams *params)\n>>   {\n>>   \tauto &gains = context.activeState.awb.gains;\n>> +\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n>> +\t\t\t\t\t     0, gains.g(), 0,\n>> +\t\t\t\t\t     0, 0, gains.b() } };\n>> +\tcontext.activeState.combinedMatrix =\n>> +\t\tcontext.activeState.combinedMatrix * gainMatrix;\n>>   \t/* Just report, the gains are applied in LUT algorithm. */\n>>   \tframeContext.gains.red = gains.r();\n>>   \tframeContext.gains.blue = gains.b();\n>> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\n>> index 25b188b91..a6dbd7b1d 100644\n>> --- a/src/ipa/simple/algorithms/lut.cpp\n>> +++ b/src/ipa/simple/algorithms/lut.cpp\n>> @@ -108,10 +108,7 @@ void Lut::prepare(IPAContext &context,\n>>   \t\t\tparams->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];\n>>   \t\t}\n>>   \t} else if (context.activeState.matrixChanged || gammaUpdateNeeded) {\n>> -\t\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n>> -\t\t\t\t\t\t     0, gains.g(), 0,\n>> -\t\t\t\t\t\t     0, 0, gains.b() } };\n>> -\t\tauto matrix = context.activeState.combinedMatrix * gainMatrix;\n>> +\t\tauto &matrix = context.activeState.combinedMatrix;\n>\n> Is it not a concern that this change will make it so that depending on `IPAContext::ccmEnabled`\n> the gains are applied in two different places (files, even)? If I'm not mistaken,\n> this split remains even after all changes have been applied?\n\nIt's not perfect but how to do better?  I really don't want to keep LUT\ntable construction in algorithms.  And not applying the gains here would\nmean passing the algorithms common job on each debayering, just because\nof the special handling of non-CCM CPU ISP.\n\n>>   \t\tauto &red = params->redCcm;\n>>   \t\tauto &green = params->greenCcm;\n>>   \t\tauto &blue = params->blueCcm;","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 A421ABDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jan 2026 14:39:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAFEA61FBF;\n\tMon, 19 Jan 2026 15:39:46 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 59B70606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 15:39:45 +0100 (CET)","from mail-wm1-f70.google.com (mail-wm1-f70.google.com\n\t[209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-556-M5wweqXPNXyJ0lUYxpdt5A-1; Mon, 19 Jan 2026 09:39:42 -0500","by mail-wm1-f70.google.com with SMTP id\n\t5b1f17b1804b1-47d28e7960fso46732065e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jan 2026 06:39:41 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-47f428acd0csm251890565e9.6.2026.01.19.06.39.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 19 Jan 2026 06:39:39 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"H2G//goJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1768833584;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=yg6FYGLSrOZycsfRQTn33jTXeiAMZYgs7N2hmgmcpF8=;\n\tb=H2G//goJHn7+4eCf1QGEdj+jlnxkK6vIwEQIgYyK6uWdztkfyYnwTVhTFxdyJr+pbGu6tu\n\tb8gj/QKfHwtNKhsYXCBr6vcXTFjcMHl76gEa+QLh0QNGtfjWESEF9Y8YBnRd1QLV6RC8cM\n\twS26g3md3/MkN8jpbFD/BwjILe46IdY=","X-MC-Unique":"M5wweqXPNXyJ0lUYxpdt5A-1","X-Mimecast-MFC-AGG-ID":"M5wweqXPNXyJ0lUYxpdt5A_1768833581","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1768833581; x=1769438381;\n\th=content-transfer-encoding:mime-version:user-agent:message-id:date\n\t:references:in-reply-to:subject:cc:to:from:x-gm-gg\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=dkz3zqg3jDxB9WWhIEhTr51hTsKwd8Yir3AqM7LxIyg=;\n\tb=M62MY9101wV+QBFy3gaGZ5w4Mj2yiaZHlbXZYDQSEobeVt+MabZblbl2/H+vUNtHRF\n\tRssI0JyK9ujVgO14pJZ6hyAqViXH3YNid2LrbbZ8/f2cEyuT+q1Bl3a7LnI3K8RP0QCU\n\ty8fvuKx8ttERBMwnpLoTFxLtr5abbhVG9lwwQO8tOy2LDeVemTBqNc2TbFX6oli+d7Zt\n\t4vOtc6Rufd3p7RViQEOUEi4h+uUKvqUpFHZOIQNGmwNfrqy1F6VwLTE7DAVpvIfYkLfs\n\tkHwWHIGWWE3Gos8Om9mM1zh57nFw1yUtO/oZfB6muc6Asrr7jL2qmf+Qzk0xHp/MdAr6\n\tQZeg==","X-Gm-Message-State":"AOJu0YxiZogOKBTok2Xk8OI6FjV0AWM+7HtZPx3V6iNQfMAkPWI/Nmrk\n\t3njZldYy/fOJrxGukBx+KshdiORemReLkDaHiv0G/BL/tDdPLpovG/sqfsjh6ZBD50LaziaFTWr\n\tDPyv83aLIZcLADu7uaJZGRqHO3/q15gt0fBqPq4vw5Ii2WQyV49BscP4kfuEn4f6aZC2tz4kFik\n\tc=","X-Gm-Gg":"AY/fxX7g6K228ghQGITsKdDDu5rkdYdXk4Vx8G3BhjGzJt1+LDFdvIxz9w/f2kMsb/y\n\tS6a1HuKVgnTMhr/OKaz/f7rdtd3KkfHsnlH/WYIM7Uc08pZd5gq/R/ILM3xu6U+/IcQTllpxfAQ\n\tMTLL8jhdcW/oile6x7aYISclXCLkKqmAbeaz41tzlduMv9XZZpghs5MTIqzFnZr731NiMzG91iq\n\tSOHqBrEGGW29revNMl7vXAHld1yhSewtYBq/1B/+8Pk3kedxzBvoeB8WFNk5Pv4r0H+8ZhNnABF\n\tPchz9PaepUhh9jwcBQE+MQIdv+KQox22Y5LLoQ9LC6WqkFXjSLOAlH+VObV3kHJcy2BAXzf58iB\n\tujFJc0eSImy6Ejob/8jSkisWQzu9xsTQoqDtd0UdfHSv6wvoEM+TSpliB9mt4VyM=","X-Received":["by 2002:a05:600c:4e50:b0:47e:e946:3a59 with SMTP id\n\t5b1f17b1804b1-4801e3503fbmr144094305e9.34.1768833580777; \n\tMon, 19 Jan 2026 06:39:40 -0800 (PST)","by 2002:a05:600c:4e50:b0:47e:e946:3a59 with SMTP id\n\t5b1f17b1804b1-4801e3503fbmr144093775e9.34.1768833580247; \n\tMon, 19 Jan 2026 06:39:40 -0800 (PST)"],"From":"Milan Zamazal <mzamazal@redhat.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","In-Reply-To":"<256a8c4f-87a5-4b9d-a841-841852615e70@ideasonboard.com> (\n\t=?utf-8?b?IkJhcm5hYsOhcyBQxZFjemUiJ3M=?= message of \"Mon,\n\t19 Jan 2026  11:29:04 +0100\")","References":"<20260114113016.25162-1-mzamazal@redhat.com>\n\t<20260114113016.25162-11-mzamazal@redhat.com>\n\t<256a8c4f-87a5-4b9d-a841-841852615e70@ideasonboard.com>","Date":"Mon, 19 Jan 2026 15:39:38 +0100","Message-ID":"<85o6mp3bv9.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"4IijSE7cPLbD6R5CraPd_vuc0YocKVogqQM64hY_3lk_1768833581","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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":37767,"web_url":"https://patchwork.libcamera.org/comment/37767/","msgid":"<addf9406-17e7-46e6-876d-16b270811e9a@ideasonboard.com>","date":"2026-01-20T15:55:20","subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"2026. 01. 19. 15:39 keltezéssel, Milan Zamazal írta:\n> Hi Barnabás,\n> \n> thank you for review.\n> \n> Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:\n> \n>> 2026. 01. 14. 12:30 keltezéssel, Milan Zamazal írta:\n>>> Now, when we have a combined matrix, we can apply AWB gains to it\n>>> directly in awb.cpp.\n>>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>>> ---\n>>>    src/ipa/simple/algorithms/awb.cpp | 7 ++++++-\n>>>    src/ipa/simple/algorithms/lut.cpp | 5 +----\n>>>    2 files changed, 7 insertions(+), 5 deletions(-)\n>>> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n>>> index a391359fb..4d2f1df15 100644\n>>> --- a/src/ipa/simple/algorithms/awb.cpp\n>>> +++ b/src/ipa/simple/algorithms/awb.cpp\n>>> @@ -1,6 +1,6 @@\n>>>    /* SPDX-License-Identifier: LGPL-2.1-or-later */\n>>>    /*\n>>> - * Copyright (C) 2024, Red Hat Inc.\n>>> + * Copyright (C) 2024-2025 Red Hat Inc.\n>>>     *\n>>>     * Auto white balance\n>>>     */\n>>> @@ -40,6 +40,11 @@ void Awb::prepare(IPAContext &context,\n>>>    \t\t  [[maybe_unused]] DebayerParams *params)\n>>>    {\n>>>    \tauto &gains = context.activeState.awb.gains;\n>>> +\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n>>> +\t\t\t\t\t     0, gains.g(), 0,\n>>> +\t\t\t\t\t     0, 0, gains.b() } };\n>>> +\tcontext.activeState.combinedMatrix =\n>>> +\t\tcontext.activeState.combinedMatrix * gainMatrix;\n>>>    \t/* Just report, the gains are applied in LUT algorithm. */\n>>>    \tframeContext.gains.red = gains.r();\n>>>    \tframeContext.gains.blue = gains.b();\n>>> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\n>>> index 25b188b91..a6dbd7b1d 100644\n>>> --- a/src/ipa/simple/algorithms/lut.cpp\n>>> +++ b/src/ipa/simple/algorithms/lut.cpp\n>>> @@ -108,10 +108,7 @@ void Lut::prepare(IPAContext &context,\n>>>    \t\t\tparams->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];\n>>>    \t\t}\n>>>    \t} else if (context.activeState.matrixChanged || gammaUpdateNeeded) {\n>>> -\t\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n>>> -\t\t\t\t\t\t     0, gains.g(), 0,\n>>> -\t\t\t\t\t\t     0, 0, gains.b() } };\n>>> -\t\tauto matrix = context.activeState.combinedMatrix * gainMatrix;\n>>> +\t\tauto &matrix = context.activeState.combinedMatrix;\n>>\n>> Is it not a concern that this change will make it so that depending on `IPAContext::ccmEnabled`\n>> the gains are applied in two different places (files, even)? If I'm not mistaken,\n>> this split remains even after all changes have been applied?\n> \n> It's not perfect but how to do better?  I really don't want to keep LUT\n> table construction in algorithms.  And not applying the gains here would\n> mean passing the algorithms common job on each debayering, just because\n> of the special handling of non-CCM CPU ISP.\n\nNot sure to be honest, it's just that it seems to me that splitting things\nmay not be ideal. The whole \"Lut\" algorithm is essentially merged into\n`DebayerCpu` by the end, right? As far as I can see `context.activeState.awb.gains`\nwill go into `DebayerParams::gains`, so everything is available there to keep\nthe awb gains handling together. Or am I missing something? Maybe something\nwith the order? But as far as I can tell it is applied last (in the \"Lut\"\nalgorithm before this change set).\n\n\n> \n>>>    \t\tauto &red = params->redCcm;\n>>>    \t\tauto &green = params->greenCcm;\n>>>    \t\tauto &blue = params->blueCcm;\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 9E52AC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Jan 2026 15:55:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4F88E61FCC;\n\tTue, 20 Jan 2026 16:55:27 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5364C61FBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jan 2026 16:55:25 +0100 (CET)","from [192.168.33.23] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 91B7E2147;\n\tTue, 20 Jan 2026 16:54:53 +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=\"nvtPINzG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1768924494;\n\tbh=FY5BYZ1n4zAVCLIPc4C1T0lSYmbMvzx/c4VP3LZ76VM=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=nvtPINzG6LatFbQgh11JJaSoO4souOxYlZG6sIsEDVFuFTuG7t+W/i9mvcpcEO903\n\twgvVPP5j8wuWgfK5DgfGZUSELlrrcNNdR1RNcf0qNLrYuLzneCDsrxeEAX5UnG7zx8\n\tUVEs3JlksnahE/0Trk8QVllFQkLcRvq1vrteJbf0=","Message-ID":"<addf9406-17e7-46e6-876d-16b270811e9a@ideasonboard.com>","Date":"Tue, 20 Jan 2026 16:55:20 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","References":"<20260114113016.25162-1-mzamazal@redhat.com>\n\t<20260114113016.25162-11-mzamazal@redhat.com>\n\t<256a8c4f-87a5-4b9d-a841-841852615e70@ideasonboard.com>\n\t<85o6mp3bv9.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<85o6mp3bv9.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","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":37771,"web_url":"https://patchwork.libcamera.org/comment/37771/","msgid":"<85wm1curno.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-20T17:20:59","subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:\n\n> 2026. 01. 19. 15:39 keltezéssel, Milan Zamazal írta:\n>> Hi Barnabás,\n>> thank you for review.\n>> Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:\n>> \n>>> 2026. 01. 14. 12:30 keltezéssel, Milan Zamazal írta:\n>>>> Now, when we have a combined matrix, we can apply AWB gains to it\n>>>> directly in awb.cpp.\n>>>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>>>> ---\n>>>>    src/ipa/simple/algorithms/awb.cpp | 7 ++++++-\n>>>>    src/ipa/simple/algorithms/lut.cpp | 5 +----\n>>>>    2 files changed, 7 insertions(+), 5 deletions(-)\n>>>> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp\n>>>> index a391359fb..4d2f1df15 100644\n>>>> --- a/src/ipa/simple/algorithms/awb.cpp\n>>>> +++ b/src/ipa/simple/algorithms/awb.cpp\n>>>> @@ -1,6 +1,6 @@\n>>>>    /* SPDX-License-Identifier: LGPL-2.1-or-later */\n>>>>    /*\n>>>> - * Copyright (C) 2024, Red Hat Inc.\n>>>> + * Copyright (C) 2024-2025 Red Hat Inc.\n>>>>     *\n>>>>     * Auto white balance\n>>>>     */\n>>>> @@ -40,6 +40,11 @@ void Awb::prepare(IPAContext &context,\n>>>>    \t\t  [[maybe_unused]] DebayerParams *params)\n>>>>    {\n>>>>    \tauto &gains = context.activeState.awb.gains;\n>>>> +\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n>>>> +\t\t\t\t\t     0, gains.g(), 0,\n>>>> +\t\t\t\t\t     0, 0, gains.b() } };\n>>>> +\tcontext.activeState.combinedMatrix =\n>>>> +\t\tcontext.activeState.combinedMatrix * gainMatrix;\n>>>>    \t/* Just report, the gains are applied in LUT algorithm. */\n>>>>    \tframeContext.gains.red = gains.r();\n>>>>    \tframeContext.gains.blue = gains.b();\n>>>> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\n>>>> index 25b188b91..a6dbd7b1d 100644\n>>>> --- a/src/ipa/simple/algorithms/lut.cpp\n>>>> +++ b/src/ipa/simple/algorithms/lut.cpp\n>>>> @@ -108,10 +108,7 @@ void Lut::prepare(IPAContext &context,\n>>>>    \t\t\tparams->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];\n>>>>    \t\t}\n>>>>    \t} else if (context.activeState.matrixChanged || gammaUpdateNeeded) {\n>>>> -\t\tMatrix<float, 3, 3> gainMatrix = { { gains.r(), 0, 0,\n>>>> -\t\t\t\t\t\t     0, gains.g(), 0,\n>>>> -\t\t\t\t\t\t     0, 0, gains.b() } };\n>>>> -\t\tauto matrix = context.activeState.combinedMatrix * gainMatrix;\n>>>> +\t\tauto &matrix = context.activeState.combinedMatrix;\n>>>\n>>> Is it not a concern that this change will make it so that depending on `IPAContext::ccmEnabled`\n>>> the gains are applied in two different places (files, even)? If I'm not mistaken,\n>>> this split remains even after all changes have been applied?\n>> It's not perfect but how to do better?  I really don't want to keep LUT\n>> table construction in algorithms.  And not applying the gains here would\n>> mean passing the algorithms common job on each debayering, just because\n>> of the special handling of non-CCM CPU ISP.\n>\n> Not sure to be honest, it's just that it seems to me that splitting things\n> may not be ideal. The whole \"Lut\" algorithm is essentially merged into\n> `DebayerCpu` by the end, right? \n\nRight.\n\n> As far as I can see `context.activeState.awb.gains` will go into\n> `DebayerParams::gains`, so everything is available there to keep the\n> awb gains handling together. Or am I missing something? Maybe\n> something with the order? But as far as I can tell it is applied last\n> (in the \"Lut\" algorithm before this change set).\n\nWhite balance should be applied before saturation.  This doesn't apply\nin LUT construction, because saturation is disabled when the correction\nmatrix is not used.  We can make a common code in the Debayer ancestor\nfor CPU and GPU processing to deal with applying the gains and\nsaturation but then I don't see a good enough reason not to do it in\nalgorithms directly.\n\nOne way to avoid the special handling of gains in CPU ISP without the\nmatrix would be to always use the matrix in CPU ISP.  But it has a big\nperformance impact and GPU ISP is a new thing.  We may consider this\noption later.\n\n>> \n>>>>    \t\tauto &red = params->redCcm;\n>>>>    \t\tauto &green = params->greenCcm;\n>>>>    \t\tauto &blue = params->blueCcm;\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 5ED2DC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 20 Jan 2026 17:21:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E9AA61FC4;\n\tTue, 20 Jan 2026 18:21:08 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A59C61A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jan 2026 18:21:06 +0100 (CET)","from mail-wr1-f70.google.com (mail-wr1-f70.google.com\n\t[209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-571-OMr5cM6VOjGtMG2UdJW7bA-1; Tue, 20 Jan 2026 12:21:02 -0500","by mail-wr1-f70.google.com with SMTP id\n\tffacd0b85a97d-430f4609e80so3839279f8f.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 20 Jan 2026 09:21:02 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4356996cf58sm31108702f8f.22.2026.01.20.09.21.00\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 20 Jan 2026 09:21:00 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"BgG3p5OQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1768929665;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=0eKtKBnio5k25PHD7wfCrJkqBOCAZo2yI6KvIOi0G0g=;\n\tb=BgG3p5OQlHcr97MGDBSvQOmmfRhXuSwe3s6QQ0LOtaojzNhg9moQ7EDneAY7WGcmMAQyj0\n\tMBHrUtjYYTBpeBbdSi5qYKDUWqnbw0dav5Jm0URB8ULmCYHEN72DwFYmkDs2DEcfBA/rjp\n\t87MmP76YLHtOlR5FajgP1GzLqn1WswQ=","X-MC-Unique":"OMr5cM6VOjGtMG2UdJW7bA-1","X-Mimecast-MFC-AGG-ID":"OMr5cM6VOjGtMG2UdJW7bA_1768929661","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1768929661; x=1769534461;\n\th=content-transfer-encoding:mime-version:user-agent:message-id:date\n\t:references:in-reply-to:subject:cc:to:from:x-gm-gg\n\t:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n\tbh=rIcKgXdiMmN5rZxcVTzvYd06tmJ2HgJWCNz44UrOHBA=;\n\tb=PyA7qkjT1N6f0FngHdbICMppA47qh5/UiV1mAR80yEtbdfETmn7IzwKW96Kpy47TJR\n\tWMLA2sSnaWnyp5SYkfeagjd5I0SQ/XNFRjCAKV1+wUV4TojTw/NIeHfk1UWujIIjDhrz\n\tpvxzl8h/hf2AEE+VDpZgNopjPfkJ2uhUZO2Yv3FyhtXVQLEXGDfSVxOL/FBcFxsKrJWm\n\t2WJpSc7gnH33G1tR1eIZNEzZ1MIUGRB6RnsO/HqWfLJ0vhDo/9euVBQsWZJNzbJ+oN/g\n\tObUwBLtsojVXfRd54zuvpk89+DmS0xBPnEBj9EwPIsrs3nIuzsp52vd4x92ZyLgAylSq\n\tQxuQ==","X-Gm-Message-State":"AOJu0Yx6R81ZGeNvOhXhA3769osi0olIn6X7Nt3yp8+zx9rjPdNX4+jK\n\tlMKkNe3/iAb38oHKgXBYKqI40JGWVAIVZkDK1BRD2vC7o0qYSSwXbwDDBWsyK/c/PDKGxpvd8lE\n\tYxYzP7sRApENbke+Z0YyQoGgPikMMRri+7juRwsabXLkOjqAEWJO3pleUshhFhcJ59PpxgkOJOv\n\tI=","X-Gm-Gg":"AZuq6aJadB3ZPJUY24JEOhxsu7uqomK+C4uk9YcwDnRJpoEMjaKq1a4DJ5mlzGRY9Xt\n\t2al/kYlS6lb3jHV3ab0HNwc2HBJ+t6+3b38Rd1A1oAgmROw9pMXE0pbG57XIVRVypNH1qxaSoN0\n\tpJ2QzCn4+/cZWV513LSqH55mQ91tdd3XvFYc07iuAOO3ZLedNlN7iwtwxU4p6X34Ii7wtoZ5OZC\n\tiBuVIbpe1M6GXALmjSZkYGWjrS/ZOxt+s1LBJEMoghTOkMBChbihopmMdkP1zrONXX626rSYUA9\n\tLXqgzoqL/QvklGZbPVUYUw2Lhopc4DpE2K0MrgXZvMakeBbRWsTUa5f+JSHt9CTaE6AqXrkb1ZA\n\tuNgVKclSMJYBN2Qc7laVIA4/NhOgC5el7qEhs00vUtVy6TAgzMCQZj77XPsU/mdQ=","X-Received":["by 2002:a5d:5f96:0:b0:435:9770:9ecb with SMTP id\n\tffacd0b85a97d-4359770a2d4mr1159771f8f.56.1768929661431; \n\tTue, 20 Jan 2026 09:21:01 -0800 (PST)","by 2002:a5d:5f96:0:b0:435:9770:9ecb with SMTP id\n\tffacd0b85a97d-4359770a2d4mr1159739f8f.56.1768929660979; \n\tTue, 20 Jan 2026 09:21:00 -0800 (PST)"],"From":"Milan Zamazal <mzamazal@redhat.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,  Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH v3 10/14] libcamera: ipa: simple: Apply gain matrix in\n\tawb","In-Reply-To":"<addf9406-17e7-46e6-876d-16b270811e9a@ideasonboard.com> (\n\t=?utf-8?b?IkJhcm5hYsOhcyBQxZFjemUiJ3M=?= message of \"Tue,\n\t20 Jan 2026  16:55:20 +0100\")","References":"<20260114113016.25162-1-mzamazal@redhat.com>\n\t<20260114113016.25162-11-mzamazal@redhat.com>\n\t<256a8c4f-87a5-4b9d-a841-841852615e70@ideasonboard.com>\n\t<85o6mp3bv9.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>\n\t<addf9406-17e7-46e6-876d-16b270811e9a@ideasonboard.com>","Date":"Tue, 20 Jan 2026 18:20:59 +0100","Message-ID":"<85wm1curno.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"o0mGv9OBL3JruLfjw5UWYJGE1XMbND4G0o0N_ExrMYw_1768929661","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>"}}]