@@ -941,8 +941,8 @@ void AgcChannel::divideUpExposure()
/* Finally work out the digital gain that we will need. */
filtered_.totalExposureNoDG = analogueGain * exposureTime;
double digitalGain = filtered_.totalExposure / filtered_.totalExposureNoDG;
- /* Limit dg by what is allowed. */
- digitalGain = std::min(digitalGain, config_.maxDigitalGain);
+ /* Limit dg by what is allowed (and to 1.0 to avoid saturation issues). */
+ digitalGain = std::clamp(digitalGain, 1.0, config_.maxDigitalGain);
/* Update total exposure, in case the dg went down. */
filtered_.totalExposure = filtered_.totalExposureNoDG * digitalGain;
Digital gain is used to adjust overall image exposure when the target exposure cannot be achieved (for example, cannot go high enough). But when the target exposure is lower than we can achieve, the digital gain was being set to values less than unity, causing saturation problems. The fix is simply to clamp the digital gain at the bottom to 1.0, resulting in images that, while "too bright", saturate correctly. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> --- src/ipa/rpi/controller/rpi/agc_channel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)