summaryrefslogtreecommitdiff
path: root/src/ipa/rpi/controller/rpi/agc.cpp
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2023-05-03 13:20:32 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-05-04 20:58:57 +0300
commit503bebd0ed80886569629e7ce11d40fa28721c84 (patch)
tree13bcbca170fc99d8007664a9d37a19dfb64d4951 /src/ipa/rpi/controller/rpi/agc.cpp
parentd903fdbe313a908b9e67024e897323eeca657fb5 (diff)
ipa: raspberrypi: agc: Move weights out of AGC
The region weights for the the AGC zones are handled by the AGC algorithm. Apply them directly in the IPA (vc4.cpp) to the statistics that we pass to the AGC. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/rpi/controller/rpi/agc.cpp')
-rw-r--r--src/ipa/rpi/controller/rpi/agc.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp
index e6fb7b8d..e79c82e2 100644
--- a/src/ipa/rpi/controller/rpi/agc.cpp
+++ b/src/ipa/rpi/controller/rpi/agc.cpp
@@ -292,6 +292,18 @@ unsigned int Agc::getConvergenceFrames() const
return config_.convergenceFrames;
}
+std::vector<double> const &Agc::getWeights() const
+{
+ /*
+ * In case someone calls setMeteringMode and then this before the
+ * algorithm has run and updated the meteringMode_ pointer.
+ */
+ auto it = config_.meteringModes.find(meteringModeName_);
+ if (it == config_.meteringModes.end())
+ return meteringMode_->weights;
+ return it->second.weights;
+}
+
void Agc::setEv(double ev)
{
ev_ = ev;
@@ -595,19 +607,16 @@ static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,
ASSERT(weights.size() == stats->agcRegions.numRegions());
/*
- * Note how the calculation below means that equal weights give you
- * "average" metering (i.e. all pixels equally important).
+ * 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;
for (unsigned int i = 0; i < stats->agcRegions.numRegions(); i++) {
auto &region = stats->agcRegions.get(i);
- double rAcc = std::min<double>(region.val.rSum * gain, (maxVal - 1) * region.counted);
- double gAcc = std::min<double>(region.val.gSum * gain, (maxVal - 1) * region.counted);
- double bAcc = std::min<double>(region.val.bSum * gain, (maxVal - 1) * region.counted);
- rSum += rAcc * weights[i];
- gSum += gAcc * weights[i];
- bSum += bAcc * weights[i];
- pixelSum += region.counted * weights[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);
+ pixelSum += region.counted;
}
if (pixelSum == 0.0) {
LOG(RPiAgc, Warning) << "computeInitialY: pixelSum is zero";