@@ -241,12 +241,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
}
double stageGain = clampGain(1.0);
- double lastStageGain = stageGain;
for (const auto &stage : stages_) {
utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime,
&quantGain);
- stageGain = clampGain(stage.gain);
/*
* We perform the clamping on both exposure time and gain in
@@ -256,9 +254,9 @@ 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 / lastStageGain, &quantGain);
+ /* Clamp the gain to that of the last stage and regulate exposure time. */
+ if (stageExposureTime * stageGain >= exposure) {
+ exposureTime = clampExposureTime(exposure / stageGain, &quantGain);
gain = clampGain(exposure / exposureTime, &quantGain2);
quantGain *= quantGain2;
@@ -266,7 +264,9 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
exposure / (exposureTime * gain * quantGain) };
}
- /* Clamp the exposureTime to stageExposureTime and regulate gain. */
+ /* Clamp the exposure time to stageExposureTime and regulate gain. */
+ stageGain = clampGain(stage.gain);
+
if (stageExposureTime * stageGain >= exposure) {
exposureTime = stageExposureTime;
gain = clampGain(exposure / exposureTime, &quantGain2);
@@ -275,8 +275,6 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const
return { exposureTime, gain, quantGain,
exposure / (exposureTime * gain * quantGain) };
}
-
- lastStageGain = stageGain;
}
/*