[v2,5/9] ipa: libipa: agc: Take parameters from active state for calculation
diff mbox series

Message ID 20260925102551.137108-6-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 Sept. 25, 2026, 10:25 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 af4a3bf443..af38a20426 100644
--- a/src/ipa/libipa/agc.cpp
+++ b/src/ipa/libipa/agc.cpp
@@ -743,24 +743,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{
@@ -806,10 +804,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. */