summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/awb.cpp
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-02-09 12:47:35 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-02-09 13:11:30 +0000
commit6d60f264d1e05bd19640b66bc72bda9f303bf72d (patch)
tree18d98783e0346b315dbeb61ba04af6f12377cb61 /src/ipa/raspberrypi/controller/rpi/awb.cpp
parente8dd0fdc8321dce4c15b55b895e9efb5181ddb4c (diff)
ipa: raspberrypi: Use the generic statistics structure in the algorithms
Repurpose the StatisticsPtr type from being a shared_ptr<bcm2835_isp_stats> to shared_ptr<RPiController::Statistics>. This removes any hardware specific header files and structures from the algorithms source code. Add a new function in the Raspberry Pi IPA to populate the generic statistics structure from the values provided by the hardware in the bcm2835_isp_stats structure. Update the Lux, AWB, AGC, ALSC, Contrast, and Focus algorithms to use the generic statistics structure appropriately in their calculations. Additionally, remove references to any hardware specific headers and defines in these source files. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Tested-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/awb.cpp')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/awb.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
index 04d1c878..ef3435d6 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
@@ -21,9 +21,6 @@ LOG_DEFINE_CATEGORY(RPiAwb)
#define NAME "rpi.awb"
-static constexpr unsigned int AwbStatsSizeX = DEFAULT_AWB_REGIONS_X;
-static constexpr unsigned int AwbStatsSizeY = DEFAULT_AWB_REGIONS_Y;
-
/*
* todo - the locking in this algorithm needs some tidying up as has been done
* elsewhere (ALSC and AGC).
@@ -401,17 +398,16 @@ void Awb::asyncFunc()
}
static void generateStats(std::vector<Awb::RGB> &zones,
- bcm2835_isp_stats_region *stats, double minPixels,
+ RgbyRegions &stats, double minPixels,
double minG)
{
- for (unsigned int i = 0; i < AwbStatsSizeX * AwbStatsSizeY; i++) {
+ for (auto const &region : stats) {
Awb::RGB zone;
- double counted = stats[i].counted;
- if (counted >= minPixels) {
- zone.G = stats[i].g_sum / counted;
+ if (region.counted >= minPixels) {
+ zone.G = region.val.gSum / region.counted;
if (zone.G >= minG) {
- zone.R = stats[i].r_sum / counted;
- zone.B = stats[i].b_sum / counted;
+ zone.R = region.val.rSum / region.counted;
+ zone.B = region.val.bSum / region.counted;
zones.push_back(zone);
}
}
@@ -425,7 +421,7 @@ void Awb::prepareStats()
* LSC has already been applied to the stats in this pipeline, so stop
* any LSC compensation. We also ignore config_.fast in this version.
*/
- generateStats(zones_, statistics_->awb_stats, config_.minPixels,
+ generateStats(zones_, statistics_->awbRegions, config_.minPixels,
config_.minG);
/*
* apply sensitivities, so values appear to come from our "canonical"
@@ -641,7 +637,7 @@ void Awb::awbBayes()
* valid... not entirely sure about this.
*/
Pwl prior = interpolatePrior();
- prior *= zones_.size() / (double)(AwbStatsSizeX * AwbStatsSizeY);
+ prior *= zones_.size() / (double)(statistics_->awbRegions.numRegions());
prior.map([](double x, double y) {
LOG(RPiAwb, Debug) << "(" << x << "," << y << ")";
});