[{"id":36780,"web_url":"https://patchwork.libcamera.org/comment/36780/","msgid":"<176294064762.567526.5666750019128244894@ping.linuxembedded.co.uk>","date":"2025-11-12T09:44:07","subject":"Re: [RFC PATCH 3/7] 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-12 08:27:11)\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 tight to just CCM handling.\n\ntight? tied?\n\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/ipa/simple/algorithms/ccm.cpp | 7 +++----\n>  src/ipa/simple/algorithms/lut.cpp | 6 ++++--\n>  src/ipa/simple/ipa_context.h      | 6 ++----\n>  3 files changed, 9 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\nI'm a bit weary here that we're reporting CCM as the metadata which is\nnow actually a combined result.\n\nShould we splitting out the components and reporting them individually\nin the metadata? The fact we're combining them to a single Matrix is an\nimplementation detail isn't it ?\n\n--\nKieran\n\n\n\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 d1d5f7271..dead55f34 100644\n> --- a/src/ipa/simple/algorithms/lut.cpp\n> +++ b/src/ipa/simple/algorithms/lut.cpp\n> @@ -118,11 +118,12 @@ 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> +\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> @@ -138,6 +139,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 F1AD9C3263\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 12 Nov 2025 09:44:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 118E860A80;\n\tWed, 12 Nov 2025 10:44:11 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F179606E6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Nov 2025 10:44:10 +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 0F46382E;\n\tWed, 12 Nov 2025 10:42:11 +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=\"Zxn4EtmG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1762940531;\n\tbh=dC+Mvv/yqCH0fpf2nd3gFhO4G6OIr9RrqDExybycWkc=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Zxn4EtmGorYrHh1q1HK615NLOfNL64fbV5jNUVUjIGKnAYDe4gQpCtaelAhqD32dT\n\tWXFfhHSG9cUdF3mZe9Mhum1vZ7jKG0Y9yq9CoyttbHQusxvrWNOBRu1lQoa0f08Wzj\n\t1/MUfyR19pRR0UwZGFJ6GEh20USP4LqEKy85+bCM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251112082715.17823-4-mzamazal@redhat.com>","References":"<20251112082715.17823-1-mzamazal@redhat.com>\n\t<20251112082715.17823-4-mzamazal@redhat.com>","Subject":"Re: [RFC PATCH 3/7] libcamera: ipa: simple: Generalise tracking\n\tmatrix changes","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Wed, 12 Nov 2025 09:44:07 +0000","Message-ID":"<176294064762.567526.5666750019128244894@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>"}}]