From da0926bc4b2dc28599ee2000ee9fb375b38d4f9e Mon Sep 17 00:00:00 2001 From: Milan Zamazal Date: Wed, 28 Jan 2026 12:43:57 +0100 Subject: [PATCH] libcamera: ipa: simple: Apply gain matrix in awb Now, when we have a combined matrix, we can apply AWB gains to it directly in awb.cpp. Reviewed-by: Robert Mader Signed-off-by: Milan Zamazal Reviewed-by: Kieran Bingham Signed-off-by: Kieran Bingham --- src/ipa/simple/algorithms/awb.cpp | 5 +++++ src/ipa/simple/algorithms/lut.cpp | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp index 18d97f70..31726658 100644 --- a/src/ipa/simple/algorithms/awb.cpp +++ b/src/ipa/simple/algorithms/awb.cpp @@ -40,6 +40,11 @@ void Awb::prepare(IPAContext &context, [[maybe_unused]] DebayerParams *params) { auto &gains = context.activeState.awb.gains; + Matrix gainMatrix = { { gains.r(), 0, 0, + 0, gains.g(), 0, + 0, 0, gains.b() } }; + context.activeState.combinedMatrix = + context.activeState.combinedMatrix * gainMatrix; /* Just report, the gains are applied in LUT algorithm. */ frameContext.gains.red = gains.r(); frameContext.gains.blue = gains.b(); diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index 9740f8c8..d8e92c61 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -107,10 +107,7 @@ void Lut::prepare(IPAContext &context, params->blue[i] = gammaTable[static_cast(lutGains.b())]; } } else if (context.activeState.matrixChanged || gammaUpdateNeeded) { - Matrix gainMatrix = { { gains.r(), 0, 0, - 0, gains.g(), 0, - 0, 0, gains.b() } }; - auto matrix = context.activeState.combinedMatrix * gainMatrix; + auto &matrix = context.activeState.combinedMatrix; auto &red = params->redCcm; auto &green = params->greenCcm; auto &blue = params->blueCcm;