From 29892f1c56c6657a9d650aff203912212c295bd0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 18 Nov 2024 21:07:01 +0200 Subject: ipa: libipa: colour: Use the RGB class to model RGB values The rec601LuminanceFromRGB() and estimateCCT() functions take RGB triplets as three variables. Replace them with instances of the RGB class and adapt the users accordingly. Only variables passed directly to these functions are converted to RGB instances, further conversion of IPA modules to the RGB class will be performed separately. While at it, fix a typo in the documentation of the estimateCCT() function. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal --- src/ipa/ipu3/algorithms/agc.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/ipa/ipu3/algorithms/agc.cpp') diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index 46669203..39d0aebb 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -178,18 +178,16 @@ Histogram Agc::parseStatistics(const ipu3_uapi_stats_3a *stats, */ double Agc::estimateLuminance(double gain) const { - double redSum = 0, greenSum = 0, blueSum = 0; + RGB sum{ 0.0 }; for (unsigned int i = 0; i < rgbTriples_.size(); i++) { - redSum += std::min(std::get<0>(rgbTriples_[i]) * gain, 255.0); - greenSum += std::min(std::get<1>(rgbTriples_[i]) * gain, 255.0); - blueSum += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0); + sum.r() += std::min(std::get<0>(rgbTriples_[i]) * gain, 255.0); + sum.g() += std::min(std::get<1>(rgbTriples_[i]) * gain, 255.0); + sum.b() += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0); } - double ySum = rec601LuminanceFromRGB(redSum * rGain_, - greenSum * gGain_, - blueSum * bGain_); - + RGB gains{{ rGain_, gGain_, bGain_ }}; + double ySum = rec601LuminanceFromRGB(sum * gains); return ySum / (bdsGrid_.height * bdsGrid_.width) / 255; } -- cgit v1.2.1