summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/cam_helper_imx708.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/cam_helper_imx708.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/cam_helper_imx708.cpp')
-rw-r--r--src/ipa/raspberrypi/cam_helper_imx708.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/ipa/raspberrypi/cam_helper_imx708.cpp b/src/ipa/raspberrypi/cam_helper_imx708.cpp
index 4c43c8e7..1f213d3c 100644
--- a/src/ipa/raspberrypi/cam_helper_imx708.cpp
+++ b/src/ipa/raspberrypi/cam_helper_imx708.cpp
@@ -78,14 +78,14 @@ private:
bool parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp);
void putAGCStatistics(StatisticsPtr stats);
- uint32_t aeHistLinear_[128];
+ Histogram aeHistLinear_;
uint32_t aeHistAverage_;
bool aeHistValid_;
};
CamHelperImx708::CamHelperImx708()
: CamHelper(std::make_unique<MdParserSmia>(registerList), frameIntegrationDiff),
- aeHistLinear_{ 0 }, aeHistAverage_(0), aeHistValid_(false)
+ aeHistLinear_{}, aeHistAverage_(0), aeHistValid_(false)
{
}
@@ -264,9 +264,11 @@ bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len,
bool CamHelperImx708::parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp)
{
- static const uint32_t ISP_PIPELINE_BITS = 13;
+ static constexpr unsigned int PipelineBits = Statistics::NormalisationFactorPow2;
+
uint64_t count = 0, sum = 0;
size_t step = bpp >> 1; /* bytes per histogram bin */
+ uint32_t hist[128];
if (len < 144 * step)
return false;
@@ -280,12 +282,12 @@ bool CamHelperImx708::parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp)
if (ptr[3] != 0x55)
return false;
uint32_t c = (ptr[0] << 14) + (ptr[1] << 6) + (ptr[2] >> 2);
- aeHistLinear_[i] = c >> 2; /* pixels to quads */
+ hist[i] = c >> 2; /* pixels to quads */
if (i != 0) {
count += c;
sum += c *
- (i * (1u << (ISP_PIPELINE_BITS - 7)) +
- (1u << (ISP_PIPELINE_BITS - 8)));
+ (i * (1u << (PipelineBits - 7)) +
+ (1u << (PipelineBits - 8)));
}
ptr += step;
}
@@ -301,15 +303,16 @@ bool CamHelperImx708::parseAEHist(const uint8_t *ptr, size_t len, unsigned bpp)
uint32_t c = (ptr[0] << 14) + (ptr[1] << 6) + (ptr[2] >> 2);
count += c;
sum += c *
- ((3u << ISP_PIPELINE_BITS) >> (17 - i));
+ ((3u << PipelineBits) >> (17 - i));
ptr += step;
}
if ((unsigned)((ptr[0] << 12) + (ptr[1] << 4) + (ptr[2] >> 4)) !=
- aeHistLinear_[1]) {
+ hist[1]) {
LOG(IPARPI, Error) << "Lin/Log histogram mismatch";
return false;
}
+ aeHistLinear_ = Histogram(hist, 128);
aeHistAverage_ = count ? (sum / count) : 0;
return count != 0;
@@ -329,13 +332,12 @@ void CamHelperImx708::putAGCStatistics(StatisticsPtr stats)
* scaled by a fiddle-factor so that a conventional (non-HDR) y_target
* of e.g. 0.17 will map to a suitable level for HDR.
*/
- memcpy(stats->hist[0].g_hist, aeHistLinear_, sizeof(stats->hist[0].g_hist));
+ stats->yHist = aeHistLinear_;
constexpr unsigned int HdrHeadroomFactor = 4;
uint64_t v = HdrHeadroomFactor * aeHistAverage_;
- for (int i = 0; i < AGC_REGIONS; i++) {
- struct bcm2835_isp_stats_region &r = stats->agc_stats[i];
- r.r_sum = r.b_sum = r.g_sum = r.counted * v;
+ for (auto &region : stats->agcRegions) {
+ region.val.rSum = region.val.gSum = region.val.bSum = region.counted * v;
}
}