summaryrefslogtreecommitdiff
path: root/src/ipa/rpi/controller
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-11-18 21:07:01 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-11-26 19:05:20 +0200
commit29892f1c56c6657a9d650aff203912212c295bd0 (patch)
tree287034218ce0a0593fe1429f2dc0f8a99dcd8b7c /src/ipa/rpi/controller
parentcb3e3095d611462d839d6aec29d8a39cd38abf7c (diff)
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Diffstat (limited to 'src/ipa/rpi/controller')
-rw-r--r--src/ipa/rpi/controller/rpi/agc_channel.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp
index 14335943..79c45973 100644
--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp
+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp
@@ -13,6 +13,7 @@
#include <libcamera/base/log.h>
#include "libipa/colours.h"
+#include "libipa/vector.h"
#include "../awb_status.h"
#include "../device_status.h"
@@ -681,12 +682,13 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,
* Note that the weights are applied by the IPA to the statistics directly,
* before they are given to us here.
*/
- double rSum = 0, gSum = 0, bSum = 0, pixelSum = 0;
+ ipa::RGB<double> sum{ 0.0 };
+ double pixelSum = 0;
for (unsigned int i = 0; i < stats->agcRegions.numRegions(); i++) {
auto &region = stats->agcRegions.get(i);
- rSum += std::min<double>(region.val.rSum * gain, (maxVal - 1) * region.counted);
- gSum += std::min<double>(region.val.gSum * gain, (maxVal - 1) * region.counted);
- bSum += std::min<double>(region.val.bSum * gain, (maxVal - 1) * region.counted);
+ sum.r() += std::min<double>(region.val.rSum * gain, (maxVal - 1) * region.counted);
+ sum.g() += std::min<double>(region.val.gSum * gain, (maxVal - 1) * region.counted);
+ sum.b() += std::min<double>(region.val.bSum * gain, (maxVal - 1) * region.counted);
pixelSum += region.counted;
}
if (pixelSum == 0.0) {
@@ -694,14 +696,11 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,
return 0;
}
- double ySum;
/* Factor in the AWB correction if needed. */
- if (stats->agcStatsPos == Statistics::AgcStatsPos::PreWb) {
- ySum = ipa::rec601LuminanceFromRGB(rSum * awb.gainR,
- gSum * awb.gainG,
- bSum * awb.gainB);
- } else
- ySum = ipa::rec601LuminanceFromRGB(rSum, gSum, bSum);
+ if (stats->agcStatsPos == Statistics::AgcStatsPos::PreWb)
+ sum *= ipa::RGB<double>{{ awb.gainR, awb.gainR, awb.gainB }};
+
+ double ySum = ipa::rec601LuminanceFromRGB(sum);
return ySum / pixelSum / (1 << 16);
}