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>
This commit is contained in:
Naushir Patuck 2023-03-27 13:20:23 +01:00 committed by Kieran Bingham
parent f6cc78b446
commit af946958da
4 changed files with 224 additions and 168 deletions

View file

@ -14,6 +14,7 @@
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
#include <vector>
#include <linux/bcm2835-isp.h>
@ -174,7 +175,7 @@ private:
void applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls);
void applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls);
void applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls);
void resampleTable(uint16_t dest[], double const src[12][16], int destW, int destH);
void resampleTable(uint16_t dest[], const std::vector<double> &src, int destW, int destH);
std::map<unsigned int, MappedFrameBuffer> buffers_;
@ -1769,7 +1770,7 @@ void IPARPi::applyAF(const struct AfStatus *afStatus, ControlList &lensCtrls)
* Resamples a 16x12 table with central sampling to destW x destH with corner
* sampling.
*/
void IPARPi::resampleTable(uint16_t dest[], double const src[12][16],
void IPARPi::resampleTable(uint16_t dest[], const std::vector<double> &src,
int destW, int destH)
{
/*
@ -1794,8 +1795,8 @@ void IPARPi::resampleTable(uint16_t dest[], double const src[12][16],
double yf = y - yLo;
int yHi = yLo < 11 ? yLo + 1 : 11;
yLo = yLo > 0 ? yLo : 0;
double const *rowAbove = src[yLo];
double const *rowBelow = src[yHi];
double const *rowAbove = src.data() + yLo * 16;
double const *rowBelow = src.data() + yHi * 16;
for (int i = 0; i < destW; i++) {
double above = rowAbove[xLo[i]] * (1 - xf[i]) + rowAbove[xHi[i]] * xf[i];
double below = rowBelow[xLo[i]] * (1 - xf[i]) + rowBelow[xHi[i]] * xf[i];