From 6d60f264d1e05bd19640b66bc72bda9f303bf72d Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Thu, 9 Feb 2023 12:47:35 +0000 Subject: ipa: raspberrypi: Use the generic statistics structure in the algorithms Repurpose the StatisticsPtr type from being a shared_ptr to shared_ptr. 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 Reviewed-by: David Plowman Tested-by: Nick Hollinghurst Signed-off-by: Kieran Bingham --- src/ipa/raspberrypi/controller/rpi/af.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/ipa/raspberrypi/controller/rpi/af.cpp') diff --git a/src/ipa/raspberrypi/controller/rpi/af.cpp b/src/ipa/raspberrypi/controller/rpi/af.cpp index 2e72f239..a6236518 100644 --- a/src/ipa/raspberrypi/controller/rpi/af.cpp +++ b/src/ipa/raspberrypi/controller/rpi/af.cpp @@ -352,14 +352,12 @@ bool Af::getPhase(PdafData const &data, double &phase, double &conf) const } } -double Af::getContrast(struct bcm2835_isp_stats_focus const focus_stats[FOCUS_REGIONS]) const +double Af::getContrast(const FocusRegions &focusStats) const { uint32_t sumWc = 0; - for (unsigned i = 0; i < FOCUS_REGIONS; ++i) { - unsigned w = contrastWeights_[i]; - sumWc += w * (focus_stats[i].contrast_val[1][1] >> 10); - } + for (unsigned i = 0; i < focusStats.numRegions(); ++i) + sumWc += contrastWeights_[i] * focusStats.get(i).val; return (sumWeights_ == 0) ? 0.0 : (double)sumWc / (double)sumWeights_; } @@ -666,7 +664,7 @@ void Af::prepare(Metadata *imageMetadata) void Af::process(StatisticsPtr &stats, [[maybe_unused]] Metadata *imageMetadata) { (void)imageMetadata; - prevContrast_ = getContrast(stats->focus_stats); + prevContrast_ = getContrast(stats->focusRegions); } /* Controls */ -- cgit v1.2.1