summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/alsc.h
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-03-27 13:20:23 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-03-31 13:29:18 +0100
commitaf946958daf38974b614fb1a007366bd78e110fb (patch)
tree39517326b32b6807af80ce1cb00f31feccea95b3 /src/ipa/raspberrypi/controller/rpi/alsc.h
parentf6cc78b446de8dc03251aa5aab094852bca77285 (diff)
ipa: raspberrypi: Generalise the ALSC algorithm
Remove any hard-coded assumptions about the target hardware platform from the ALSC algorithm. Instead, use the "target" string provided by the camera tuning config and generalised statistics structures to determing parameters such as grid and region sizes. The ALSC calculations use run-time allocated arrays/vectors on every frame. Allocating these might add a non-trivial run-time penalty. Replace these dynamic allocations with a set of reusable pre-allocated vectors during the init phase. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/alsc.h')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/alsc.h29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.h b/src/ipa/raspberrypi/controller/rpi/alsc.h
index 9167c9ff..85e998db 100644
--- a/src/ipa/raspberrypi/controller/rpi/alsc.h
+++ b/src/ipa/raspberrypi/controller/rpi/alsc.h
@@ -6,9 +6,13 @@
*/
#pragma once
+#include <array>
#include <mutex>
#include <condition_variable>
#include <thread>
+#include <vector>
+
+#include <libcamera/geometry.h>
#include "../algorithm.h"
#include "../alsc_status.h"
@@ -20,7 +24,7 @@ namespace RPiController {
struct AlscCalibration {
double ct;
- double table[AlscCellsX * AlscCellsY];
+ std::vector<double> table;
};
struct AlscConfig {
@@ -36,13 +40,14 @@ struct AlscConfig {
uint16_t minG;
double omega;
uint32_t nIter;
- double luminanceLut[AlscCellsX * AlscCellsY];
+ std::vector<double> luminanceLut;
double luminanceStrength;
std::vector<AlscCalibration> calibrationsCr;
std::vector<AlscCalibration> calibrationsCb;
double defaultCt; /* colour temperature if no metadata found */
double threshold; /* iteration termination threshold */
double lambdaBound; /* upper/lower bound for lambda from a value of 1 */
+ libcamera::Size tableSize;
};
class Alsc : public Algorithm
@@ -62,7 +67,7 @@ private:
AlscConfig config_;
bool firstTime_;
CameraMode cameraMode_;
- double luminanceTable_[AlscCellsX * AlscCellsY];
+ std::vector<double> luminanceTable_;
std::thread asyncThread_;
void asyncFunc(); /* asynchronous thread function */
std::mutex mutex_;
@@ -88,8 +93,8 @@ private:
int frameCount_;
/* counts up to startupFrames for Process function */
int frameCount2_;
- double syncResults_[3][AlscCellsY][AlscCellsX];
- double prevSyncResults_[3][AlscCellsY][AlscCellsX];
+ std::array<std::vector<double>, 3> syncResults_;
+ std::array<std::vector<double>, 3> prevSyncResults_;
void waitForAysncThread();
/*
* The following are for the asynchronous thread to use, though the main
@@ -100,12 +105,16 @@ private:
void fetchAsyncResults();
double ct_;
RgbyRegions statistics_;
- double asyncResults_[3][AlscCellsY][AlscCellsX];
- double asyncLambdaR_[AlscCellsX * AlscCellsY];
- double asyncLambdaB_[AlscCellsX * AlscCellsY];
+ std::array<std::vector<double>, 3> asyncResults_;
+ std::vector<double> asyncLambdaR_;
+ std::vector<double> asyncLambdaB_;
void doAlsc();
- double lambdaR_[AlscCellsX * AlscCellsY];
- double lambdaB_[AlscCellsX * AlscCellsY];
+ std::vector<double> lambdaR_;
+ std::vector<double> lambdaB_;
+
+ /* Temporaries for the computations */
+ std::array<std::vector<double>, 5> tmpC_;
+ std::array<std::vector<std::array<double, 4>>, 3> tmpM_;
};
} /* namespace RPiController */