ipa: rpi: Fix gamma lookup table generation for PiSP platform
generateLut was failing to fill in the final slope value, meaning that fully saturated pixels would full slightly short (the slope of the final piecewise linear segment would default to zero). The loop is slightly reorganised to fix the problem. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@rasbperrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
3c08aaef14
commit
033bb2cce3
@@ -80,36 +80,30 @@ int generateLut(const ipa::Pwl &pwl, uint32_t *lut, std::size_t lutSize,
|
||||
if (pwl.empty())
|
||||
return -EINVAL;
|
||||
|
||||
int lastY = 0;
|
||||
int nextY = pwl.eval(0);
|
||||
for (unsigned int i = 0; i < lutSize; i++) {
|
||||
int x, y;
|
||||
if (i < 32)
|
||||
x = i * 512;
|
||||
else if (i < 48)
|
||||
x = (i - 32) * 1024 + 16384;
|
||||
unsigned int nextI = i + 1;
|
||||
|
||||
int nextX;
|
||||
if (nextI < 32)
|
||||
nextX = nextI * 512;
|
||||
else if (nextI < 48)
|
||||
nextX = (nextI - 32) * 1024 + 16384;
|
||||
else
|
||||
x = std::min(65535u, (i - 48) * 2048 + 32768);
|
||||
nextX = (nextI - 48) * 2048 + 32768;
|
||||
|
||||
y = pwl.eval(x);
|
||||
if (y < 0 || (i && y < lastY)) {
|
||||
LOG(IPARPI, Error)
|
||||
<< "Malformed PWL for Gamma, disabling!";
|
||||
return -1;
|
||||
int y = nextY;
|
||||
nextY = pwl.eval(nextX);
|
||||
|
||||
unsigned int slope = nextY - y;
|
||||
if (slope >= (1u << SlopeBits)) {
|
||||
slope = (1u << SlopeBits) - 1;
|
||||
LOG(IPARPI, Info)
|
||||
<< "Maximum Gamma slope exceeded, adjusting!";
|
||||
nextY = y + slope;
|
||||
}
|
||||
|
||||
if (i) {
|
||||
unsigned int slope = y - lastY;
|
||||
if (slope >= (1u << SlopeBits)) {
|
||||
slope = (1u << SlopeBits) - 1;
|
||||
LOG(IPARPI, Info)
|
||||
<< ("Maximum Gamma slope exceeded, adjusting!");
|
||||
y = lastY + slope;
|
||||
}
|
||||
lut[i - 1] |= slope << PosBits;
|
||||
}
|
||||
|
||||
lut[i] = y;
|
||||
lastY = y;
|
||||
lut[i] = y | (slope << PosBits);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user