[v2,03/12] ipa: ipu3: Convert from separate gains to RGB<double> in AGC
diff mbox series

Message ID 20260626-ipu3-libipa-rework-v2-3-41546e23de3e@ideasonboard.com
State New
Headers show
Series
  • libipa: Re-work IPU3 IPA to use libipa algorithms
Related show

Commit Message

Dan Scally June 26, 2026, 1:05 p.m. UTC
The AGC algorithm stores red, blue and green gains as type double
class members. Switch to using a single member of type RGB<double>
instead to simplify the code.

Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
Changes in v2:

        - New patch
---
 src/ipa/ipu3/algorithms/agc.cpp | 9 ++++-----
 src/ipa/ipu3/algorithms/agc.h   | 6 +++---
 2 files changed, 7 insertions(+), 8 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index d6a7036c6504acb106f5c773b529ad80b8349f85..b8b880b357a4770efd6810a3bdf616dd25ce93e4 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -186,8 +186,7 @@  double Agc::estimateLuminance(double gain) const
 		sum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);
 	}
 
-	RGB<double> gains{{ rGain_, gGain_, bGain_ }};
-	double ySum = rec601LuminanceFromRGB(sum * gains);
+	double ySum = rec601LuminanceFromRGB(sum * gains_);
 	return ySum / (bdsGrid_.height * bdsGrid_.width) / 255;
 }
 
@@ -208,9 +207,9 @@  void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
 		  ControlList &metadata)
 {
 	Histogram hist = parseStatistics(stats, context.configuration.grid.bdsGrid);
-	rGain_ = context.activeState.awb.gains.red;
-	gGain_ = context.activeState.awb.gains.blue;
-	bGain_ = context.activeState.awb.gains.green;
+	gains_ = RGB<double>({ context.activeState.awb.gains.red,
+			       context.activeState.awb.gains.blue,
+			       context.activeState.awb.gains.green });
 
 	/*
 	 * The Agc algorithm needs to know the effective exposure value that was
diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h
index d274a2350485f8f9a3870b24ceb29927cb9c2bec..12ddb173ff89b7de68dd544a194292f4d14efdbb 100644
--- a/src/ipa/ipu3/algorithms/agc.h
+++ b/src/ipa/ipu3/algorithms/agc.h
@@ -13,6 +13,8 @@ 
 
 #include <libcamera/geometry.h>
 
+#include "libcamera/internal/vector.h"
+
 #include "libipa/agc_mean_luminance.h"
 #include "libipa/histogram.h"
 
@@ -49,9 +51,7 @@  private:
 	double maxAnalogueGain_;
 
 	uint32_t stride_;
-	double rGain_;
-	double gGain_;
-	double bGain_;
+	RGB<double> gains_;
 	ipu3_uapi_grid_config bdsGrid_;
 	std::vector<std::tuple<uint8_t, uint8_t, uint8_t>> rgbTriples_;
 };