libcamera: software_isp: debayer: Latch contrastExp not contrast to debayer parameters

Pass contrastExp as calculated in lut to debayer params not the raw
contrast. This way we calculate contrastExp once per frame in lut and pass
the calculated value into the shaders, instead of passing contrast and
calculating contrastExp once per pixel in the shaders.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Robert Mader <robert.mader@collabora.com>
Tested-by: Hans de Goede <johannes.goede@oss.qualcomm.com> # ThinkPad T14s gen 6 (arm64) ov02c10 + X1c gen 12 ov08x40
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> # Lenovo X13s
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Bryan O'Donoghue
2026-01-06 17:00:36 +00:00
committed by Kieran Bingham
parent c63f2c72cd
commit a1a6253ff9
4 changed files with 7 additions and 5 deletions
+4 -3
View File
@@ -60,12 +60,13 @@ void Lut::updateGammaTable(IPAContext &context)
const auto blackLevel = context.activeState.blc.level;
const unsigned int blackIndex = blackLevel * gammaTable.size() / 256;
const auto contrast = context.activeState.knobs.contrast.value_or(1.0);
/* Convert 0..2 to 0..infinity; avoid actual inifinity at tan(pi/2) */
double contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));
const float divisor = gammaTable.size() - blackIndex - 1.0;
for (unsigned int i = blackIndex; i < gammaTable.size(); i++) {
double normalized = (i - blackIndex) / divisor;
/* Convert 0..2 to 0..infinity; avoid actual inifinity at tan(pi/2) */
double contrastExp = tan(std::clamp(contrast * M_PI_4, 0.0, M_PI_2 - 0.00001));
/* Apply simple S-curve */
if (normalized < 0.5)
normalized = 0.5 * std::pow(normalized / 0.5, contrastExp);
@@ -84,7 +85,7 @@ void Lut::updateGammaTable(IPAContext &context)
gammaTable[blackIndex]);
context.activeState.gamma.blackLevel = blackLevel;
context.activeState.gamma.contrast = contrast;
context.activeState.gamma.contrastExp = contrastExp;
}
int16_t Lut::ccmValue(unsigned int i, float ccm) const
@@ -149,7 +150,7 @@ void Lut::prepare(IPAContext &context,
}
params->gamma = context.configuration.gamma;
params->contrast = context.activeState.gamma.contrast;
params->contrastExp = context.activeState.gamma.contrastExp;
}
void Lut::process([[maybe_unused]] IPAContext &context,
+1
View File
@@ -59,6 +59,7 @@ struct IPAActiveState {
std::array<double, kGammaLookupSize> gammaTable;
uint8_t blackLevel;
double contrast;
double contrastExp;
} gamma;
struct {
+1 -1
View File
@@ -116,7 +116,7 @@ namespace libcamera {
*/
/**
* \var DebayerParams::contrast
* \var DebayerParams::contrastExp
* \brief Contrast value for GPUISP
*/