[v6,17/24] ipa: libipa: agc: Take parameters from active state for calculation
diff mbox series

Message ID 20261102101610.877390-18-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • ipa: libipa: agc: Take exposure margin into account
Related show

Commit Message

Barnabás Pőcze Nov. 2, 2026, 10:16 a.m. UTC
The `frameContext` is of an already completed frame, its exposure/gain/etc
is of no real concern for future frames, so take the most recent settings
from the active state. This is still not ideal, but better than the
previous status quo.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/agc.cpp | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp
index f40f4b0947..5849925fb2 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -1048,24 +1048,22 @@  void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,
 	double minAnalogueGain;
 	double maxAnalogueGain;
 
-	/* \todo This uses the configuration from an already completed frame. */
-
-	if (frameContext.autoExposureEnabled) {
+	if (state.autoExposureEnabled) {
 		minExposureTime = session.minExposureTime;
-		maxExposureTime = std::clamp(frameContext.maxFrameDuration,
+		maxExposureTime = std::clamp(state.maxFrameDuration,
 					     session.minExposureTime,
 					     session.maxExposureTime);
 	} else {
-		minExposureTime = lineDuration * frameContext.exposure;
+		minExposureTime = lineDuration * state.manual.exposure;
 		maxExposureTime = minExposureTime;
 	}
 
-	if (frameContext.autoGainEnabled) {
+	if (state.autoGainEnabled) {
 		minAnalogueGain = session.minAnalogueGain;
 		maxAnalogueGain = session.maxAnalogueGain;
 	} else {
-		minAnalogueGain = frameContext.gain;
-		maxAnalogueGain = frameContext.gain;
+		minAnalogueGain = state.manual.gain;
+		maxAnalogueGain = state.manual.gain;
 	}
 
 	std::visit(utils::overloaded{
@@ -1111,10 +1109,10 @@  void AgcAlgorithm::process(const agc::Session &session, agc::ActiveState &state,
 				.traits = params->traits,
 				.yHist = params->yHist,
 				.effectiveExposureValue = effectiveExposureValue,
-				.constraintModeIndex = frameContext.constraintMode,
-				.exposureModeIndex = frameContext.exposureMode,
+				.constraintModeIndex = state.constraintMode,
+				.exposureModeIndex = state.exposureMode,
 				.lux = params->lux,
-				.exposureCompensation = std::pow(2.0, frameContext.exposureValue),
+				.exposureCompensation = std::pow(2.0, state.exposureValue),
 			});
 
 			/* Update the estimated exposure and gain. */