[{"id":37046,"web_url":"https://patchwork.libcamera.org/comment/37046/","msgid":"<176407190512.1127434.13155849903534616110@ping.linuxembedded.co.uk>","date":"2025-11-25T11:58:25","subject":"Re: [RFC PATCH v2 03/13] libcamera: ipa: simple: Generalise tracking\n\tmatrix changes","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2025-11-20 10:45:38)\n> IPAActiveState::ccm stores the colour correction matrix (CCM) and\n> whether it has been changed.  The change flag is later used when\n> recomputing or not the lookup tables.\n> \n> But the CCM may include other corrections than just the sensor colour\n> correction, for example white balance and saturation adjustments.  These\n> things should be separated and IPAActiveState::ccm should represent just\n> the CCM itself.\n> \n> As the first step towards that cleanup, let's separate the change flag\n> from the CCM.  And wrap the only remaining member of\n> IPAActiveState::ccm.\n> \n> Also, let's reset the separated change flag in the lookup tables; it'll\n> be no longer tied to just CCM handling.\n> \n> This patch doesn't change actual behaviour and it still reports the\n> combined matrix as CCM in metadata.  This is addressed in the followup\n> patches.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/ipa/simple/algorithms/ccm.cpp | 7 +++----\n>  src/ipa/simple/algorithms/lut.cpp | 5 +++--\n>  src/ipa/simple/ipa_context.h      | 6 ++----\n>  3 files changed, 8 insertions(+), 10 deletions(-)\n> \n> diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp\n> index d7d3dda76..e05e5bc28 100644\n> --- a/src/ipa/simple/algorithms/ccm.cpp\n> +++ b/src/ipa/simple/algorithms/ccm.cpp\n> @@ -94,8 +94,7 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>         if (frame > 0 &&\n>             utils::abs_diff(ct, lastCt_) < kTemperatureThreshold &&\n>             saturation == lastSaturation_) {\n> -               frameContext.ccm = context.activeState.ccm.ccm;\n> -               context.activeState.ccm.changed = false;\n> +               frameContext.ccm = context.activeState.ccm;\n>                 return;\n>         }\n>  \n> @@ -105,9 +104,9 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,\n>         if (saturation)\n>                 applySaturation(ccm, saturation.value());\n>  \n> -       context.activeState.ccm.ccm = ccm;\n> +       context.activeState.ccm = ccm;\n>         frameContext.saturation = saturation;\n> -       context.activeState.ccm.changed = true;\n> +       context.activeState.matrixChanged = true;\n>         frameContext.ccm = ccm;\n>  }\n>  \n> diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp\n> index d4a79e101..1cd7ef92e 100644\n> --- a/src/ipa/simple/algorithms/lut.cpp\n> +++ b/src/ipa/simple/algorithms/lut.cpp\n> @@ -125,11 +125,11 @@ void Lut::prepare(IPAContext &context,\n>                         params->green[i] = gammaTable[static_cast<unsigned int>(lutGains.g())];\n>                         params->blue[i] = gammaTable[static_cast<unsigned int>(lutGains.b())];\n>                 }\n> -       } else if (context.activeState.ccm.changed || gammaUpdateNeeded) {\n> +       } else if (context.activeState.matrixChanged || gammaUpdateNeeded) {\n>                 Matrix<float, 3, 3> gainCcm = { { gains.r(), 0, 0,\n>                                                   0, gains.g(), 0,\n>                                                   0, 0, gains.b() } };\n> -               auto ccm = context.activeState.ccm.ccm * gainCcm;\n> +               auto ccm = context.activeState.ccm * gainCcm;\n>                 auto &red = params->redCcm;\n>                 auto &green = params->greenCcm;\n>                 auto &blue = params->blueCcm;\n> @@ -145,6 +145,7 @@ void Lut::prepare(IPAContext &context,\n>                         blue[i].b = ccmValue(i, ccm[2][2]);\n>                         params->gammaLut[i] = gammaTable[i / div];\n>                 }\n> +               context.activeState.matrixChanged = false;\n>         }\n>  }\n>  \n> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h\n> index 330fe39cb..b6b3cbfed 100644\n> --- a/src/ipa/simple/ipa_context.h\n> +++ b/src/ipa/simple/ipa_context.h\n> @@ -60,10 +60,8 @@ struct IPAActiveState {\n>                 double contrast;\n>         } gamma;\n>  \n> -       struct {\n> -               Matrix<float, 3, 3> ccm;\n> -               bool changed;\n> -       } ccm;\n> +       Matrix<float, 3, 3> ccm;\n> +       bool matrixChanged = false;\n>  \n>         struct {\n>                 /* 0..2 range, 1.0 = normal */\n> -- \n> 2.51.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0BC49C3338\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Nov 2025 11:58:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DA44060A9E;\n\tTue, 25 Nov 2025 12:58:29 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD3F6609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Nov 2025 12:58:28 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E5082C5;\n\tTue, 25 Nov 2025 12:56:19 +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=\"ITPzu2N/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764071779;\n\tbh=ztZ13mn/qh1KtgiAfj8GRuvC8/MM6ZHDeY5oqTY/SgQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ITPzu2N/CE1O3JhWGvIf4eK1+K0nC7lkdsGLDm2W9j/G5+trTJd8JF02Oz07Pjq1W\n\tVGeVk7wyJX5M0d8gq+F5bo3fu9SexN6tg5Jaj6P4qJehDyBJKleoyr8IG884U9WMCo\n\teYZ+zCzm9rCHTZw5aQC22L0eJaLyWyVt9E9k9h3A=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251120104548.80268-4-mzamazal@redhat.com>","References":"<20251120104548.80268-1-mzamazal@redhat.com>\n\t<20251120104548.80268-4-mzamazal@redhat.com>","Subject":"Re: [RFC PATCH v2 03/13] libcamera: ipa: simple: Generalise tracking\n\tmatrix changes","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>, =?utf-8?b?QmFybmFiw6FzIFDFkWN6?=\n\t=?utf-8?q?e?= <barnabas.pocze@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Tue, 25 Nov 2025 11:58:25 +0000","Message-ID":"<176407190512.1127434.13155849903534616110@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>"}}]