ipa: software_isp: AGC: Only use integers for exposure calculations

Exposure is an integer, instead of re-using the "double next" used
for again calculations, doing intermediate calculations with double
precision, use a local next variable of an integer type.

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
Tested-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Hans de Goede
2025-09-30 17:04:26 +02:00
committed by Kieran Bingham
parent 5d62463915
commit b5c89375f9
+4 -5
View File
@@ -51,19 +51,18 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
static constexpr uint8_t kExpNumeratorUp = kExpDenominator + 1;
static constexpr uint8_t kExpNumeratorDown = kExpDenominator - 1;
double next;
int32_t &exposure = frameContext.sensor.exposure;
double &again = frameContext.sensor.gain;
if (exposureMSV < kExposureOptimal - kExposureSatisfactory) {
if (exposure < context.configuration.agc.exposureMax) {
next = exposure * kExpNumeratorUp / kExpDenominator;
int32_t next = exposure * kExpNumeratorUp / kExpDenominator;
if (next - exposure < 1)
exposure += 1;
else
exposure = next;
} else {
next = again * kExpNumeratorUp / kExpDenominator;
double next = again * kExpNumeratorUp / kExpDenominator;
if (next - again < context.configuration.agc.againMinStep)
again += context.configuration.agc.againMinStep;
else
@@ -73,13 +72,13 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
if (exposureMSV > kExposureOptimal + kExposureSatisfactory) {
if (again > context.configuration.agc.again10) {
next = again * kExpNumeratorDown / kExpDenominator;
double next = again * kExpNumeratorDown / kExpDenominator;
if (again - next < context.configuration.agc.againMinStep)
again -= context.configuration.agc.againMinStep;
else
again = next;
} else {
next = exposure * kExpNumeratorDown / kExpDenominator;
int32_t next = exposure * kExpNumeratorDown / kExpDenominator;
if (exposure - next < 1)
exposure -= 1;
else