[{"id":37811,"web_url":"https://patchwork.libcamera.org/comment/37811/","msgid":"<bacf3a54-c816-4d6b-a086-1b1ce0db5532@ideasonboard.com>","date":"2026-01-21T16:23:28","subject":"Re: [PATCH v3 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","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> The combined matrix must be reset to the initial value before each frame\n> is prepared.  This must be done outside algorithms because any of the\n> algorithms may be disabled while the matrix must be always initialised.\n> \n> Let's initialise the combined matrix to the identity matrix (which keeps\n> the pixel values unchanged) in software ISP just before calling\n> `prepare' on the algorithms.\n> \n> Matrix updates can no longer be skipped in ccm.cpp, otherwise the CCM\n> won't be applied if there is no temperature or saturation change.  We\n> explicitly track whether the CCM has been set up completely rather than\n> relying on the frame number, to avoid missing the initialisation in case\n> the first frame is skipped due to some error.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   src/ipa/simple/algorithms/ccm.cpp | 31 +++++++++++++++----------------\n>   src/ipa/simple/algorithms/ccm.h   |  2 ++\n>   src/ipa/simple/soft_simple.cpp    |  2 ++\n>   3 files changed, 19 insertions(+), 16 deletions(-)\n> \n> [...]\n> diff --git a/src/ipa/simple/algorithms/ccm.h b/src/ipa/simple/algorithms/ccm.h\n> index 8279a3d59..19bf283af 100644\n> --- a/src/ipa/simple/algorithms/ccm.h\n> +++ b/src/ipa/simple/algorithms/ccm.h\n> @@ -47,6 +47,8 @@ private:\n>   \tunsigned int lastCt_;\n>   \tstd::optional<float> lastSaturation_;\n>   \tInterpolator<Matrix<float, 3, 3>> ccm_;\n> +\tMatrix<float, 3, 3> currentCcm_;\n> +\tbool ccmAssigned_ = false;\n\n\nCould std::optional<Matrix<...>> be used here?\n\n\n>   };\n>   \n>   } /* namespace ipa::soft::algorithms */\n> diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\n> index 57836c73c..732e82510 100644\n> --- a/src/ipa/simple/soft_simple.cpp\n> +++ b/src/ipa/simple/soft_simple.cpp\n> @@ -282,6 +282,8 @@ void IPASoftSimple::queueRequest(const uint32_t frame, const ControlList &contro\n>   \n>   void IPASoftSimple::computeParams(const uint32_t frame)\n>   {\n> +\tcontext_.activeState.combinedMatrix = Matrix<float, 3, 3>::identity();\n> +\n>   \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n>   \tfor (auto const &algo : algorithms())\n>   \t\talgo->prepare(context_, frame, frameContext, params_);","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 44082C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Jan 2026 16:23:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8D85261FC5;\n\tWed, 21 Jan 2026 17:23:33 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A14061FBB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jan 2026 17:23:32 +0100 (CET)","from [192.168.33.24] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1C6501C6;\n\tWed, 21 Jan 2026 17:23:00 +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=\"S5Fz8Qnc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769012580;\n\tbh=gF38Qvh6d1OYKbT4MaeFMHjBUWVUOzDlv1OpMOc5J2c=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=S5Fz8QnclWDrON499Xdw9sJmUV8sHZg8yb8sa4mbHiwPSCQ8TrA44VnmcZKO9lUu/\n\tJrdfWRVtIOhzRkl1XsfHlLdoo3cCgOUXR1QoNgSBNyTqlxo7usIur5CfWKNMR/1qM6\n\tr+VPN/YFAhHFkIxQycxg9Ceh3YuFDVN330Q/KukQ=","Message-ID":"<bacf3a54-c816-4d6b-a086-1b1ce0db5532@ideasonboard.com>","Date":"Wed, 21 Jan 2026 17:23:28 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","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-7-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-7-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":37813,"web_url":"https://patchwork.libcamera.org/comment/37813/","msgid":"<57627c2d-cba0-421e-83cc-117ecc2db2f7@ideasonboard.com>","date":"2026-01-21T16:30:51","subject":"Re: [PATCH v3 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","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> The combined matrix must be reset to the initial value before each frame\n> is prepared.  This must be done outside algorithms because any of the\n> algorithms may be disabled while the matrix must be always initialised.\n> \n> Let's initialise the combined matrix to the identity matrix (which keeps\n> the pixel values unchanged) in software ISP just before calling\n> `prepare' on the algorithms.\n> \n> Matrix updates can no longer be skipped in ccm.cpp, otherwise the CCM\n> won't be applied if there is no temperature or saturation change.  We\n> explicitly track whether the CCM has been set up completely rather than\n> relying on the frame number, to avoid missing the initialisation in case\n> the first frame is skipped due to some error.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   src/ipa/simple/algorithms/ccm.cpp | 31 +++++++++++++++----------------\n>   src/ipa/simple/algorithms/ccm.h   |  2 ++\n>   src/ipa/simple/soft_simple.cpp    |  2 ++\n>   3 files changed, 19 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp\n> index a3e8cd6c4..8992a8ee1 100644\n> --- a/src/ipa/simple/algorithms/ccm.cpp\n> +++ b/src/ipa/simple/algorithms/ccm.cpp\n> @@ -83,7 +83,7 @@ void Ccm::applySaturation(Matrix<float, 3, 3> &ccm, float saturation)\n>   \tccm = ycbcr2rgb * saturationMatrix * rgb2ycbcr * ccm;\n>   }\n>   \n> -void Ccm::prepare(IPAContext &context, const uint32_t frame,\n> +void Ccm::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>   \t\t  IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)\n>   {\n>   \tauto &saturation = context.activeState.knobs.saturation;\n> @@ -91,24 +91,23 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>   \tconst unsigned int ct = context.activeState.awb.temperatureK;\n>   \n>   \t/* Change CCM only on saturation or bigger temperature changes. */\n> -\tif (frame > 0 &&\n> -\t    utils::abs_diff(ct, lastCt_) < kTemperatureThreshold &&\n> -\t    saturation == lastSaturation_) {\n> -\t\tframeContext.ccm = context.activeState.ccm;\n> -\t\treturn;\n> +\tif (!ccmAssigned_ ||\n> +\t    utils::abs_diff(ct, lastCt_) >= kTemperatureThreshold ||\n> +\t    saturation != lastSaturation_) {\n> +\t\tcurrentCcm_ = ccm_.getInterpolated(ct);\n> +\t\tccmAssigned_ = true;\n> +\t\tif (saturation)\n> +\t\t\tapplySaturation(currentCcm_, saturation.value());\n> +\t\tlastCt_ = ct;\n> +\t\tlastSaturation_ = saturation;\n> +\t\tcontext.activeState.matrixChanged = true;\n>   \t}\n>   \n> -\tlastCt_ = ct;\n> -\tlastSaturation_ = saturation;\n> -\tMatrix<float, 3, 3> ccm = ccm_.getInterpolated(ct);\n> -\tif (saturation)\n> -\t\tapplySaturation(ccm, saturation.value());\n> -\n> -\tcontext.activeState.combinedMatrix = ccm;\n> -\tcontext.activeState.ccm = ccm;\n> +\tcontext.activeState.combinedMatrix =\n> +\t\tcurrentCcm_ * context.activeState.combinedMatrix;\n> +\tcontext.activeState.ccm = currentCcm_;\n\nIt seems to me that after these changes `context.activeState.ccm` becomes\nessentially unused, can it be removed? Or I suppose one of `context.activeState.ccm`\nand `currentCcm_` appears to be unnecessary in the end.\n\n\n\n>   \tframeContext.saturation = saturation;\n> -\tcontext.activeState.matrixChanged = true;\n> -\tframeContext.ccm = ccm;\n> +\tframeContext.ccm = currentCcm_;\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 EE70ABDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Jan 2026 16:30:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B653461FC4;\n\tWed, 21 Jan 2026 17:30:56 +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 1D18A61F9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jan 2026 17:30:55 +0100 (CET)","from [192.168.33.24] (185.221.143.114.nat.pool.zt.hu\n\t[185.221.143.114])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A2C51C6;\n\tWed, 21 Jan 2026 17:30:23 +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=\"nA+3gxI1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769013023;\n\tbh=thXmsn4vDwr7YWlT63FWeaYMn1tnpafB2k+DYXhwBkA=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=nA+3gxI17fiarfQugs/PDBP+jo6nmhkKRKkYERm+ibGa/fj1GwGYwhu3BhPObqf0a\n\tMbxg/e6CcG3Ltg+FUkqrx6YKWifNIP9vly9CF3cVjo3eIPH7x5Qp0ds5nwirf9hsDX\n\tVDcbBM79jP4lxvTpNmRT0TEDoX0pj4CtdowETyxU=","Message-ID":"<57627c2d-cba0-421e-83cc-117ecc2db2f7@ideasonboard.com>","Date":"Wed, 21 Jan 2026 17:30:51 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","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-7-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-7-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":37822,"web_url":"https://patchwork.libcamera.org/comment/37822/","msgid":"<85ldhq98fl.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-21T17:34:06","subject":"Re: [PATCH v3 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","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. 14. 12:30 keltezéssel, Milan Zamazal írta:\n>> The combined matrix must be reset to the initial value before each frame\n>> is prepared.  This must be done outside algorithms because any of the\n>> algorithms may be disabled while the matrix must be always initialised.\n>> Let's initialise the combined matrix to the identity matrix (which keeps\n>> the pixel values unchanged) in software ISP just before calling\n>> `prepare' on the algorithms.\n>> Matrix updates can no longer be skipped in ccm.cpp, otherwise the CCM\n>> won't be applied if there is no temperature or saturation change.  We\n>> explicitly track whether the CCM has been set up completely rather than\n>> relying on the frame number, to avoid missing the initialisation in case\n>> the first frame is skipped due to some error.\n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>   src/ipa/simple/algorithms/ccm.cpp | 31 +++++++++++++++----------------\n>>   src/ipa/simple/algorithms/ccm.h   |  2 ++\n>>   src/ipa/simple/soft_simple.cpp    |  2 ++\n>>   3 files changed, 19 insertions(+), 16 deletions(-)\n>> [...]\n>> diff --git a/src/ipa/simple/algorithms/ccm.h b/src/ipa/simple/algorithms/ccm.h\n>> index 8279a3d59..19bf283af 100644\n>> --- a/src/ipa/simple/algorithms/ccm.h\n>> +++ b/src/ipa/simple/algorithms/ccm.h\n>> @@ -47,6 +47,8 @@ private:\n>>   \tunsigned int lastCt_;\n>>   \tstd::optional<float> lastSaturation_;\n>>   \tInterpolator<Matrix<float, 3, 3>> ccm_;\n>> +\tMatrix<float, 3, 3> currentCcm_;\n>> +\tbool ccmAssigned_ = false;\n>\n>\n> Could std::optional<Matrix<...>> be used here?\n\nYes, that's better, I'll change it.\n\n>>   };\n>>     } /* namespace ipa::soft::algorithms */\n>> diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp\n>> index 57836c73c..732e82510 100644\n>> --- a/src/ipa/simple/soft_simple.cpp\n>> +++ b/src/ipa/simple/soft_simple.cpp\n>> @@ -282,6 +282,8 @@ void IPASoftSimple::queueRequest(const uint32_t frame, const ControlList &contro\n>>     void IPASoftSimple::computeParams(const uint32_t frame)\n>>   {\n>> +\tcontext_.activeState.combinedMatrix = Matrix<float, 3, 3>::identity();\n>> +\n>>   \tIPAFrameContext &frameContext = context_.frameContexts.get(frame);\n>>   \tfor (auto const &algo : algorithms())\n>>   \t\talgo->prepare(context_, frame, frameContext, params_);","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 358FBBDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Jan 2026 17:34:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 47F2361FC4;\n\tWed, 21 Jan 2026 18:34:13 +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 DDBE561F9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jan 2026 18:34:11 +0100 (CET)","from mail-wr1-f71.google.com (mail-wr1-f71.google.com\n\t[209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-470-tMSVU8U5NC6M9H7-uXFcMA-1; Wed, 21 Jan 2026 12:34:09 -0500","by mail-wr1-f71.google.com with SMTP id\n\tffacd0b85a97d-435991d4a3aso36229f8f.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jan 2026 09:34:08 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb ([213.175.37.14])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4804704087asm3495355e9.6.2026.01.21.09.34.06\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 21 Jan 2026 09:34:06 -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=\"MmlKLmGQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1769016850;\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=jUuW4vKHZE5QnAZDxTbPG7ijXYL141meXiuCpncGwJw=;\n\tb=MmlKLmGQ8Rgt0oydQo9Pz6Ke30y9uJr9x/A2898yKlUC/gWKt5+yHsnQm6QvZaaRKPK93y\n\t2Tptbo+scqC8R1Mnee068No2rZPy7aa8fgUei7K5BJxtVPYG8h0KMimU5NsVNdODsr6qgq\n\tDEtwUTpwHzVFSEHto+CQJOUGXPYvhyo=","X-MC-Unique":"tMSVU8U5NC6M9H7-uXFcMA-1","X-Mimecast-MFC-AGG-ID":"tMSVU8U5NC6M9H7-uXFcMA_1769016848","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1769016847; x=1769621647;\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=elUo17n6p8r/JiRG8dD/lSREBoQ+lCLt0jmjC590AmE=;\n\tb=qA3jkptLGG2UCPmkzD6uW2scfd1dvYHAowS4rJGbgm749yJE4KqNdKU0vMhPnQKUP0\n\tusYFJCmjryP4PqgPvVzfA/ljIKRLn6UHuTLJGaWybT0BaIZphPmFVSzX24KMLH1KYn21\n\tP/F6PRYtsvTLB6RaWwrQhC2jnznKl/0D4iRaBQA4d5V/VdNazvPFqBG5uLDf2+47YL5s\n\t+DGASvktOXcEkQr5ilfVQJaslQntoOCltDJhHX9ijHeLQQfY/5fWBPuWA1onhwOgiFU+\n\txoKqc87lRce+QwIAw4iSepOIXgsOp/8F81AJcmB2ydl71zsOCP8U5uYfKvEJM7gx0RJa\n\tYOrQ==","X-Gm-Message-State":"AOJu0YwP9FdXKsIqPOoLRJAFRFqQ2aOC9gNJLCtLYYm0KOObG8VQArfI\n\t2/Wjlx1zq7ve547yPD2cT8pZ1kAkKpN17xomzsmcK/UXQBj59f3NxjvZrW6Tgsfwe+cCBcvK40l\n\t0RGLu+ptkdd8VOQzUTbSxVJUHSx4azc2QPRrUlVMh+IS2Pxn6oh6einxw5ZFZEOOPcJd8JdRe9n\n\tQHBleiwlI=","X-Gm-Gg":"AZuq6aKVpSNGOTm/1BopBkULpPWB14vhuLuFjnzqJUlATb9APz0cFgbbq+aMfgx96gO\n\tbZ0zDQBdWPdfzp/Q4pyJDutDXvxF6onZUUE8uMrh9um3kAxtdd8sNdaZZmu7L3/t4Mvay/Zr2wx\n\tpUGC0LFSVfo051SerpLTCdyXc7TIuMd2+G7/0hnWSAefEZJr8YIVaLmLoYIAgnQQwb1w5PQ2+7x\n\tvXbiiZsYyPiXnTbY2sgf7sSruFvWtTRRWP5Ts+czrEHDuLA1DyOS7c7Oz10JNWxBn1IncRaiEFc\n\tDNSxsvX81cqNSFeWeyNYviRuzj6HO+9SHWGKYZ21d0IoBNJzYadbEelmo4fzuuPJMWpx83mhZBm\n\tuBts6QHfV1s65gjlx9kedI4tuzQ==","X-Received":["by 2002:a05:600c:8b27:b0:46e:32dd:1b1a with SMTP id\n\t5b1f17b1804b1-48022668fd4mr247999175e9.7.1769016847646; \n\tWed, 21 Jan 2026 09:34:07 -0800 (PST)","by 2002:a05:600c:8b27:b0:46e:32dd:1b1a with SMTP id\n\t5b1f17b1804b1-48022668fd4mr247998805e9.7.1769016847250; \n\tWed, 21 Jan 2026 09:34:07 -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 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","In-Reply-To":"<bacf3a54-c816-4d6b-a086-1b1ce0db5532@ideasonboard.com> (\n\t=?utf-8?b?IkJhcm5hYsOhcyBQxZFjemUiJ3M=?= message of \"Wed,\n\t21 Jan 2026  17:23:28 +0100\")","References":"<20260114113016.25162-1-mzamazal@redhat.com>\n\t<20260114113016.25162-7-mzamazal@redhat.com>\n\t<bacf3a54-c816-4d6b-a086-1b1ce0db5532@ideasonboard.com>","Date":"Wed, 21 Jan 2026 18:34:06 +0100","Message-ID":"<85ldhq98fl.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":"ncLJSTF_C58jBQNjphs0XSFTifPqezkvgl0W6fntQbY_1769016848","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":37823,"web_url":"https://patchwork.libcamera.org/comment/37823/","msgid":"<85h5se98eb.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-21T17:34:52","subject":"Re: [PATCH v3 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","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. 14. 12:30 keltezéssel, Milan Zamazal írta:\n>> The combined matrix must be reset to the initial value before each frame\n>> is prepared.  This must be done outside algorithms because any of the\n>> algorithms may be disabled while the matrix must be always initialised.\n>> Let's initialise the combined matrix to the identity matrix (which keeps\n>> the pixel values unchanged) in software ISP just before calling\n>> `prepare' on the algorithms.\n>> Matrix updates can no longer be skipped in ccm.cpp, otherwise the CCM\n>> won't be applied if there is no temperature or saturation change.  We\n>> explicitly track whether the CCM has been set up completely rather than\n>> relying on the frame number, to avoid missing the initialisation in case\n>> the first frame is skipped due to some error.\n>> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n>> ---\n>>   src/ipa/simple/algorithms/ccm.cpp | 31 +++++++++++++++----------------\n>>   src/ipa/simple/algorithms/ccm.h   |  2 ++\n>>   src/ipa/simple/soft_simple.cpp    |  2 ++\n>>   3 files changed, 19 insertions(+), 16 deletions(-)\n>> diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp\n>> index a3e8cd6c4..8992a8ee1 100644\n>> --- a/src/ipa/simple/algorithms/ccm.cpp\n>> +++ b/src/ipa/simple/algorithms/ccm.cpp\n>> @@ -83,7 +83,7 @@ void Ccm::applySaturation(Matrix<float, 3, 3> &ccm, float saturation)\n>>   \tccm = ycbcr2rgb * saturationMatrix * rgb2ycbcr * ccm;\n>>   }\n>>   -void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>> +void Ccm::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>>   \t\t  IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)\n>>   {\n>>   \tauto &saturation = context.activeState.knobs.saturation;\n>> @@ -91,24 +91,23 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>>   \tconst unsigned int ct = context.activeState.awb.temperatureK;\n>>     \t/* Change CCM only on saturation or bigger temperature changes. */\n>> -\tif (frame > 0 &&\n>> -\t    utils::abs_diff(ct, lastCt_) < kTemperatureThreshold &&\n>> -\t    saturation == lastSaturation_) {\n>> -\t\tframeContext.ccm = context.activeState.ccm;\n>> -\t\treturn;\n>> +\tif (!ccmAssigned_ ||\n>> +\t    utils::abs_diff(ct, lastCt_) >= kTemperatureThreshold ||\n>> +\t    saturation != lastSaturation_) {\n>> +\t\tcurrentCcm_ = ccm_.getInterpolated(ct);\n>> +\t\tccmAssigned_ = true;\n>> +\t\tif (saturation)\n>> +\t\t\tapplySaturation(currentCcm_, saturation.value());\n>> +\t\tlastCt_ = ct;\n>> +\t\tlastSaturation_ = saturation;\n>> +\t\tcontext.activeState.matrixChanged = true;\n>>   \t}\n>>   -\tlastCt_ = ct;\n>> -\tlastSaturation_ = saturation;\n>> -\tMatrix<float, 3, 3> ccm = ccm_.getInterpolated(ct);\n>> -\tif (saturation)\n>> -\t\tapplySaturation(ccm, saturation.value());\n>> -\n>> -\tcontext.activeState.combinedMatrix = ccm;\n>> -\tcontext.activeState.ccm = ccm;\n>> +\tcontext.activeState.combinedMatrix =\n>> +\t\tcurrentCcm_ * context.activeState.combinedMatrix;\n>> +\tcontext.activeState.ccm = currentCcm_;\n>\n> It seems to me that after these changes `context.activeState.ccm` becomes\n> essentially unused, can it be removed? Or I suppose one of `context.activeState.ccm`\n> and `currentCcm_` appears to be unnecessary in the end.\n\nYes, I'll remove context.activeState.ccm.\n\n>>   \tframeContext.saturation = saturation;\n>> -\tcontext.activeState.matrixChanged = true;\n>> -\tframeContext.ccm = ccm;\n>> +\tframeContext.ccm = currentCcm_;\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 9E2B0BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 21 Jan 2026 17:34:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 631A461FCB;\n\tWed, 21 Jan 2026 18:34:59 +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 26CC361F9F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jan 2026 18:34:58 +0100 (CET)","from mail-wr1-f72.google.com (mail-wr1-f72.google.com\n\t[209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-113-9tsDhVhLNWexpsrczvZblg-1; Wed, 21 Jan 2026 12:34:55 -0500","by mail-wr1-f72.google.com with SMTP id\n\tffacd0b85a97d-430fc83f58dso43108f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 21 Jan 2026 09:34:54 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb ([213.175.46.86])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4356999810bsm38174409f8f.40.2026.01.21.09.34.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 21 Jan 2026 09:34:52 -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=\"H73EEPao\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1769016897;\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=mSpmzzR0Tt/iAhc3VWivTPlQxeSMOnba9vN/9qUpcjg=;\n\tb=H73EEPaoFZdaAIdjJ0q7CCdlp87M5k+w9EwpWlKuSq+JQwlrakIQggvIeqS+txgesFqvBm\n\tU6QlWHtxBIkXwacDf51uwiBaMLEn3/g5387xH7aOcVxQv7w1RoAtuOpcd9lR4Y4rys5IHI\n\tcu+sRMzIERNY8fZKsraY/WsnH033znA=","X-MC-Unique":"9tsDhVhLNWexpsrczvZblg-1","X-Mimecast-MFC-AGG-ID":"9tsDhVhLNWexpsrczvZblg_1769016894","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1769016894; x=1769621694;\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=spz/Bs+P2RXATrzUCsBbpUU93fug7ulF22PgjEYmRdw=;\n\tb=XpSaPAPXOIfMHv94fonStE4wGIxvHbJwnDg7l6r/4+tvwmay3/MFvWyrzH8XFzMOoC\n\tE5S+vMl3STBO/cHAjTKOCKKWNueuzHr4i6EgTFHoUOms90Xvd2hiV7q+QMBu4qYXOctH\n\t4uZy4WhMyaY7S13iOL974v28Ay2tHCuwxuyQ+uK6JS3FdAaGbsW6PMEt9CTW3DzQpErN\n\tF0OfPP0rudzU0kNwc0hF0bOVYcXP2et8XrRpnFToa2yrvWhNlDoWi/ceEi5H6rkEwtlU\n\tfXjY3jUVv8gQekVOClWNCRUV2iY4jc2UskF9Xj0i+UrzPn03g3mLsMJPNvUsiO2cZHwb\n\tX1Fg==","X-Gm-Message-State":"AOJu0Yy+gmj+i5xO14DJlWYRzdYXvoZyXi+fMPwMNZt2vrgVMN9zAqgK\n\tJMmgzfsB72WUsybDXZpLyQDVuzBmB7HIHmiUTHORt+rT1JgyYB5P1/BJWPjXg2V3m1YKxS5YEHs\n\tpiaAksalZ9dMr9Lc4Jl4G0q/py7KNfPdJEuBwjPS80s1meYjgYtDAqNCpW812DmLDPZ6FfmL7wm\n\tA=","X-Gm-Gg":"AZuq6aLUMNZaoOd1dlnbubA1PjToEQA//uf0FGDT98YbrzyCaV5/NEq1l3SCZaqmhsa\n\toEBUIlgJ/UJihDVb26JRZl/4zQNEEeuN4hsxPuzmDcGfPfoI/ZZn/k3YCV5yEfts/0IuTMUHN2W\n\tspK7+UTDAZIGN3Rwoo8YiO9vP8Dkzxz85dQM93N/WUHdzA5Ze+Wuq0cElfaMOIOt36VRZbqB5Th\n\toenQ3rjfmePcsFRjyZj5X4ESP6yanJDlPdy3gFVQI3J4jNa4sd3VF856SEZyQxOEdAigQXofKFg\n\tm6GAsyABEYeaROxsiZ7hU1kppGcigGkwzLUQnDQeZr65gT0VoIoEf5P8IuXP4/+VEDD3WZHetSV\n\twI7ri44EUuNQQjwM+4cGfv0iZLQ==","X-Received":["by 2002:a5d:63d2:0:b0:435:9ce0:f93c with SMTP id\n\tffacd0b85a97d-4359ce0fa98mr4598270f8f.62.1769016893699; \n\tWed, 21 Jan 2026 09:34:53 -0800 (PST)","by 2002:a5d:63d2:0:b0:435:9ce0:f93c with SMTP id\n\tffacd0b85a97d-4359ce0fa98mr4598236f8f.62.1769016893265; \n\tWed, 21 Jan 2026 09:34:53 -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 06/14] libcamera: ipa: simple: Initialise the general\n\tcorrection matrix","In-Reply-To":"<57627c2d-cba0-421e-83cc-117ecc2db2f7@ideasonboard.com> (\n\t=?utf-8?b?IkJhcm5hYsOhcyBQxZFjemUiJ3M=?= message of \"Wed,\n\t21 Jan 2026  17:30:51 +0100\")","References":"<20260114113016.25162-1-mzamazal@redhat.com>\n\t<20260114113016.25162-7-mzamazal@redhat.com>\n\t<57627c2d-cba0-421e-83cc-117ecc2db2f7@ideasonboard.com>","Date":"Wed, 21 Jan 2026 18:34:52 +0100","Message-ID":"<85h5se98eb.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":"telmY6slfeyAh3Lf80_vaVnLz7JL7VpU-o_UzL1DNCg_1769016894","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>"}}]