summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2025-02-27 20:58:10 +0100
committerStefan Klug <stefan.klug@ideasonboard.com>2025-02-28 10:00:51 +0100
commiteb550486c737305dd7e86187e9d76d95d35a9cfd (patch)
treedeb5158780f4d2c0250125732199c970419c11c6
parentd748bdc66d3344761292adc8a611b74e4dfeb88f (diff)
ipa: libipa: Fix bug in ExposureModeHelper that leads to oscillations in AEGC
The ExposureModeHelper::splitExposures() runs through the configured stages to find the best gain/exposure time pair. It first raises the exposure time until it reaches the limit of the current stage. Then it raises the gain until that also reaches the limit of the current stage. After that it continues with the next stage until a match is found. Due to a slight mistake in the initial code, the second step doesn't work as expected because the exposure time gets divided by the gain of the current stage, effectively leading to a jump of the gain value from the maximum gain of the last stage to the maximum gain of the current stage instead of gradually increasing the gain value. Depending on the tuning file this leads to very visible oscillations and jumps in the brightness. Fix by clamping the exposure time in the second step to the maximum exposure time of the current stage. While at it, add two comments for easier understanding. Fixes: 34c9ab62827b ("ipa: libipa: Add ExposureModeHelper") Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
-rw-r--r--src/ipa/libipa/exposure_mode_helper.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp
index f235316d..0c1e99e3 100644
--- a/src/ipa/libipa/exposure_mode_helper.cpp
+++ b/src/ipa/libipa/exposure_mode_helper.cpp
@@ -182,6 +182,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
* the stage limits are initialised.
*/
+ /* Clamp the gain to lastStageGain and regulate exposureTime. */
if (stageExposureTime * lastStageGain >= exposure) {
exposureTime = clampExposureTime(exposure / clampGain(lastStageGain));
gain = clampGain(exposure / exposureTime);
@@ -189,8 +190,9 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
return { exposureTime, gain, exposure / (exposureTime * gain) };
}
+ /* Clamp the exposureTime to stageExposureTime and regulate gain. */
if (stageExposureTime * stageGain >= exposure) {
- exposureTime = clampExposureTime(exposure / clampGain(stageGain));
+ exposureTime = clampExposureTime(stageExposureTime);
gain = clampGain(exposure / exposureTime);
return { exposureTime, gain, exposure / (exposureTime * gain) };