From 8c84efa486270e1bd5566baa1a3fb152bfa14604 Mon Sep 17 00:00:00 2001 From: Milan Zamazal Date: Fri, 27 Sep 2024 15:46:21 +0200 Subject: libcamera: software_isp: Use floating point for color parameters It's more natural to represent color gains as floating point numbers rather than using a particular pixel-related representation. double is used rather than float because it's a more common floating point type in libcamera algorithms. Otherwise there is no obvious reason to select one over the other here. The constructed color tables still use integer representation for efficiency. Black level still uses pixel (integer) values, for consistency with other libcamera parts. Signed-off-by: Milan Zamazal Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- src/ipa/simple/algorithms/lut.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/ipa/simple/algorithms/lut.cpp') diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index 644b4f84..9744e773 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -63,15 +63,18 @@ void Lut::prepare(IPAContext &context, const unsigned int gammaTableSize = gammaTable.size(); for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) { - const unsigned int div = static_cast(DebayerParams::kRGBLookupSize) * - 256 / gammaTableSize; + const double div = static_cast(DebayerParams::kRGBLookupSize) / + gammaTableSize; /* Apply gamma after gain! */ unsigned int idx; - idx = std::min({ i * gains.red / div, gammaTableSize - 1 }); + idx = std::min({ static_cast(i * gains.red / div), + gammaTableSize - 1 }); params->red[i] = gammaTable[idx]; - idx = std::min({ i * gains.green / div, gammaTableSize - 1 }); + idx = std::min({ static_cast(i * gains.green / div), + gammaTableSize - 1 }); params->green[i] = gammaTable[idx]; - idx = std::min({ i * gains.blue / div, gammaTableSize - 1 }); + idx = std::min({ static_cast(i * gains.blue / div), + gammaTableSize - 1 }); params->blue[i] = gammaTable[idx]; } } -- cgit v1.2.1