From d8685a579ccf3246b11eef404786cdd9f19f087e Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Mon, 27 Mar 2023 13:20:26 +0100 Subject: ipa: raspberrypi: Generalise the contrast algorithm Generalise the contrast algorithm code by removing any hard-coded assumptions about the target hardware platform. Instead, the algorithm code creates a generic Pwl that gets returned to the IPA, where it gets converted to the bcm2835 hardware specific lookup table. As a drive-by, remove an unused mutex. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/ipa/raspberrypi/controller/rpi/contrast.cpp | 30 +++++-------------------- 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'src/ipa/raspberrypi/controller/rpi/contrast.cpp') diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index a4f8c4f0..bee1eadd 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -65,34 +65,19 @@ void Contrast::setContrast(double contrast) contrast_ = contrast; } -static void fillInStatus(ContrastStatus &status, double brightness, - double contrast, Pwl &gammaCurve) -{ - status.brightness = brightness; - status.contrast = contrast; - for (unsigned int i = 0; i < ContrastNumPoints - 1; i++) { - int x = i < 16 ? i * 1024 - : (i < 24 ? (i - 16) * 2048 + 16384 - : (i - 24) * 4096 + 32768); - status.points[i].x = x; - status.points[i].y = std::min(65535.0, gammaCurve.eval(x)); - } - status.points[ContrastNumPoints - 1].x = 65535; - status.points[ContrastNumPoints - 1].y = 65535; -} - void Contrast::initialise() { /* * Fill in some default values as Prepare will run before Process gets * called. */ - fillInStatus(status_, brightness_, contrast_, config_.gammaCurve); + status_.brightness = brightness_; + status_.contrast = contrast_; + status_.gammaCurve = config_.gammaCurve; } void Contrast::prepare(Metadata *imageMetadata) { - std::unique_lock lock(mutex_); imageMetadata->set("contrast.status", status_); } @@ -183,12 +168,9 @@ void Contrast::process(StatisticsPtr &stats, * And fill in the status for output. Use more points towards the bottom * of the curve. */ - ContrastStatus status; - fillInStatus(status, brightness_, contrast_, gammaCurve); - { - std::unique_lock lock(mutex_); - status_ = status; - } + status_.brightness = brightness_; + status_.contrast = contrast_; + status_.gammaCurve = std::move(gammaCurve); } /* Register algorithm with the system. */ -- cgit v1.2.1