ipa: ipu3: agc: Store exposure in units of time
The minimum and maximum exposure are stored in lines. Replace it by values in time to simplify the calculations. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
93af8ea616
commit
891ec3f872
2 changed files with 11 additions and 14 deletions
|
@ -79,8 +79,8 @@ static constexpr uint32_t kMaxLuminance = 255;
|
||||||
static constexpr double kNormalizedLumaTarget = 0.16;
|
static constexpr double kNormalizedLumaTarget = 0.16;
|
||||||
|
|
||||||
Agc::Agc()
|
Agc::Agc()
|
||||||
: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0),
|
: frameCount_(0), iqMean_(0.0), lineDuration_(0s), minShutterSpeed_(0s),
|
||||||
maxExposureLines_(0), filteredExposure_(0s), currentExposure_(0s)
|
maxShutterSpeed_(0s), filteredExposure_(0s), currentExposure_(0s)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,17 +99,16 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)
|
||||||
lineDuration_ = configInfo.sensorInfo.lineLength * 1.0s
|
lineDuration_ = configInfo.sensorInfo.lineLength * 1.0s
|
||||||
/ configInfo.sensorInfo.pixelRate;
|
/ configInfo.sensorInfo.pixelRate;
|
||||||
|
|
||||||
/* \todo replace the exposure in lines storage with time based ones. */
|
minShutterSpeed_ = context.configuration.agc.minShutterSpeed;
|
||||||
minExposureLines_ = context.configuration.agc.minShutterSpeed / lineDuration_;
|
maxShutterSpeed_ = std::min(context.configuration.agc.maxShutterSpeed,
|
||||||
maxExposureLines_ = std::min(context.configuration.agc.maxShutterSpeed / lineDuration_,
|
kMaxShutterSpeed);
|
||||||
kMaxShutterSpeed / lineDuration_);
|
|
||||||
|
|
||||||
minAnalogueGain_ = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);
|
minAnalogueGain_ = std::max(context.configuration.agc.minAnalogueGain, kMinAnalogueGain);
|
||||||
maxAnalogueGain_ = std::min(context.configuration.agc.maxAnalogueGain, kMaxAnalogueGain);
|
maxAnalogueGain_ = std::min(context.configuration.agc.maxAnalogueGain, kMaxAnalogueGain);
|
||||||
|
|
||||||
/* Configure the default exposure and gain. */
|
/* Configure the default exposure and gain. */
|
||||||
context.frameContext.agc.gain = minAnalogueGain_;
|
context.frameContext.agc.gain = minAnalogueGain_;
|
||||||
context.frameContext.agc.exposure = minExposureLines_;
|
context.frameContext.agc.exposure = minShutterSpeed_ / lineDuration_;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -236,11 +235,9 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)
|
||||||
* exposure value applied multiplied by the new estimated gain.
|
* exposure value applied multiplied by the new estimated gain.
|
||||||
*/
|
*/
|
||||||
currentExposure_ = effectiveExposureValue * evGain;
|
currentExposure_ = effectiveExposureValue * evGain;
|
||||||
utils::Duration minShutterSpeed = minExposureLines_ * lineDuration_;
|
|
||||||
utils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_;
|
|
||||||
|
|
||||||
/* Clamp the exposure value to the min and max authorized */
|
/* Clamp the exposure value to the min and max authorized */
|
||||||
utils::Duration maxTotalExposure = maxShutterSpeed * maxAnalogueGain_;
|
utils::Duration maxTotalExposure = maxShutterSpeed_ * maxAnalogueGain_;
|
||||||
currentExposure_ = std::min(currentExposure_, maxTotalExposure);
|
currentExposure_ = std::min(currentExposure_, maxTotalExposure);
|
||||||
LOG(IPU3Agc, Debug) << "Target total exposure " << currentExposure_
|
LOG(IPU3Agc, Debug) << "Target total exposure " << currentExposure_
|
||||||
<< ", maximum is " << maxTotalExposure;
|
<< ", maximum is " << maxTotalExposure;
|
||||||
|
@ -250,14 +247,14 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain)
|
||||||
|
|
||||||
/* Divide the exposure value as new exposure and gain values */
|
/* Divide the exposure value as new exposure and gain values */
|
||||||
utils::Duration exposureValue = filteredExposure_;
|
utils::Duration exposureValue = filteredExposure_;
|
||||||
utils::Duration shutterTime = minShutterSpeed;
|
utils::Duration shutterTime;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Push the shutter time up to the maximum first, and only then
|
* Push the shutter time up to the maximum first, and only then
|
||||||
* increase the gain.
|
* increase the gain.
|
||||||
*/
|
*/
|
||||||
shutterTime = std::clamp<utils::Duration>(exposureValue / minAnalogueGain_,
|
shutterTime = std::clamp<utils::Duration>(exposureValue / minAnalogueGain_,
|
||||||
minShutterSpeed, maxShutterSpeed);
|
minShutterSpeed_, maxShutterSpeed_);
|
||||||
double stepGain = std::clamp(exposureValue / shutterTime,
|
double stepGain = std::clamp(exposureValue / shutterTime,
|
||||||
minAnalogueGain_, maxAnalogueGain_);
|
minAnalogueGain_, maxAnalogueGain_);
|
||||||
LOG(IPU3Agc, Debug) << "Divided up shutter and gain are "
|
LOG(IPU3Agc, Debug) << "Divided up shutter and gain are "
|
||||||
|
|
|
@ -45,8 +45,8 @@ private:
|
||||||
double iqMean_;
|
double iqMean_;
|
||||||
|
|
||||||
utils::Duration lineDuration_;
|
utils::Duration lineDuration_;
|
||||||
uint32_t minExposureLines_;
|
utils::Duration minShutterSpeed_;
|
||||||
uint32_t maxExposureLines_;
|
utils::Duration maxShutterSpeed_;
|
||||||
|
|
||||||
double minAnalogueGain_;
|
double minAnalogueGain_;
|
||||||
double maxAnalogueGain_;
|
double maxAnalogueGain_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue