ipa: ipu3: agc: Refactor condition on exposure correction

Simplify the reading by removing one level of indentation to return
early when the change is small between two calls.

Reword the LOG() message when we are correctly exposed, and move the
lastFrame_ variable to update it even if the change is small.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jean-Michel Hautbois 2021-10-12 20:38:10 +02:00
parent cd0b3402ea
commit cbf2c9a612

View file

@ -138,10 +138,15 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)
if ((frameCount_ < kInitialFrameMinAECount) || (frameCount_ - lastFrame_ < kFrameSkipCount))
return;
lastFrame_ = frameCount_;
/* Are we correctly exposed ? */
if (std::abs(iqMean_ - kEvGainTarget * knumHistogramBins) <= 1) {
LOG(IPU3Agc, Debug) << "!!! Good exposure with iqMean = " << iqMean_;
} else {
LOG(IPU3Agc, Debug) << "We are well exposed (iqMean = "
<< iqMean_ << ")";
return;
}
double evGain = kEvGainTarget * knumHistogramBins / iqMean_;
/* extracted from Rpi::Agc::computeTargetExposure */
@ -192,8 +197,6 @@ void Agc::lockExposureGain(uint32_t &exposure, double &analogueGain)
*/
prevExposureValue_ = shutterTime * analogueGain;
}
lastFrame_ = frameCount_;
}
void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
{