Message ID | 20211111110605.105202-9-jeanmichel.hautbois@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Quoting Jean-Michel Hautbois (2021-11-11 11:05:59) > Previously, the exposure value was calculated based on the estimated > shutter time and gain applied. Now that we have the real values for the > current frame, use those before estimating the next one and rename the > variable accordingly. > > As the exposure value is updated in the beginning of the computation, > there is no need to initialize effectiveExposureValue anymore in the > configure call. > > Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> > --- > src/ipa/ipu3/algorithms/agc.cpp | 25 +++++++++---------------- > src/ipa/ipu3/algorithms/agc.h | 2 +- > 2 files changed, 10 insertions(+), 17 deletions(-) > > diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp > index fd05822b..e828d9cb 100644 > --- a/src/ipa/ipu3/algorithms/agc.cpp > +++ b/src/ipa/ipu3/algorithms/agc.cpp > @@ -81,7 +81,7 @@ static constexpr double kNormalizedLumaTarget = 0.16; > Agc::Agc() > : frameCount_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0), > maxExposureLines_(0), filteredExposure_(0s), currentExposure_(0s), > - prevExposureValue_(0s) > + effectiveExposureValue_(0s) > { > } > > @@ -112,10 +112,6 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo) > context.frameContext.agc.gain = minAnalogueGain_; > context.frameContext.agc.exposure = minExposureLines_; > > - prevExposureValue_ = context.frameContext.agc.gain > - * context.frameContext.agc.exposure > - * lineDuration_; > - > return 0; > } > > @@ -222,6 +218,13 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain) > > /* Calculate the shutter time in seconds */ > utils::Duration currentShutter = exposure * lineDuration_; > + > + /* > + * Update the exposure value for the next computation using the values > + * of exposure and gain really used by the sensor. > + */ > + effectiveExposureValue_ = currentShutter * analogueGain; > + Does this need to be a class variable? Can't it now just be a local? > LOG(IPU3Agc, Debug) << "Actual total exposure " << currentShutter * analogueGain > << " Shutter speed " << currentShutter > << " Gain " << analogueGain > @@ -239,7 +242,7 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain) > * Calculate the current exposure value for the scene as the latest > * exposure value applied multiplied by the new estimated gain. > */ > - currentExposure_ = prevExposureValue_ * evGain; > + currentExposure_ = effectiveExposureValue_ * evGain; > utils::Duration minShutterSpeed = minExposureLines_ * lineDuration_; > utils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_; > > @@ -271,16 +274,6 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain) > /* Update the estimated exposure and gain. */ > frameContext.agc.exposure = shutterTime / lineDuration_; > frameContext.agc.gain = stepGain; > - > - /* > - * Update the exposure value for the next process call. > - * > - * \todo Obtain the values of the exposure time and analog gain > - * that were actually used by the sensor, either from embedded > - * data when available, or from the delayed controls > - * infrastructure in case a slow down caused a mismatch. > - */ > - prevExposureValue_ = shutterTime * analogueGain; > } > > /** > diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h > index 79736283..1a58c79c 100644 > --- a/src/ipa/ipu3/algorithms/agc.h > +++ b/src/ipa/ipu3/algorithms/agc.h > @@ -54,7 +54,7 @@ private: > > utils::Duration filteredExposure_; > utils::Duration currentExposure_; > - utils::Duration prevExposureValue_; > + utils::Duration effectiveExposureValue_; > > uint32_t stride_; > }; > -- > 2.32.0 >
diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index fd05822b..e828d9cb 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -81,7 +81,7 @@ static constexpr double kNormalizedLumaTarget = 0.16; Agc::Agc() : frameCount_(0), iqMean_(0.0), lineDuration_(0s), minExposureLines_(0), maxExposureLines_(0), filteredExposure_(0s), currentExposure_(0s), - prevExposureValue_(0s) + effectiveExposureValue_(0s) { } @@ -112,10 +112,6 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo) context.frameContext.agc.gain = minAnalogueGain_; context.frameContext.agc.exposure = minExposureLines_; - prevExposureValue_ = context.frameContext.agc.gain - * context.frameContext.agc.exposure - * lineDuration_; - return 0; } @@ -222,6 +218,13 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain) /* Calculate the shutter time in seconds */ utils::Duration currentShutter = exposure * lineDuration_; + + /* + * Update the exposure value for the next computation using the values + * of exposure and gain really used by the sensor. + */ + effectiveExposureValue_ = currentShutter * analogueGain; + LOG(IPU3Agc, Debug) << "Actual total exposure " << currentShutter * analogueGain << " Shutter speed " << currentShutter << " Gain " << analogueGain @@ -239,7 +242,7 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain) * Calculate the current exposure value for the scene as the latest * exposure value applied multiplied by the new estimated gain. */ - currentExposure_ = prevExposureValue_ * evGain; + currentExposure_ = effectiveExposureValue_ * evGain; utils::Duration minShutterSpeed = minExposureLines_ * lineDuration_; utils::Duration maxShutterSpeed = maxExposureLines_ * lineDuration_; @@ -271,16 +274,6 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double currentYGain) /* Update the estimated exposure and gain. */ frameContext.agc.exposure = shutterTime / lineDuration_; frameContext.agc.gain = stepGain; - - /* - * Update the exposure value for the next process call. - * - * \todo Obtain the values of the exposure time and analog gain - * that were actually used by the sensor, either from embedded - * data when available, or from the delayed controls - * infrastructure in case a slow down caused a mismatch. - */ - prevExposureValue_ = shutterTime * analogueGain; } /** diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h index 79736283..1a58c79c 100644 --- a/src/ipa/ipu3/algorithms/agc.h +++ b/src/ipa/ipu3/algorithms/agc.h @@ -54,7 +54,7 @@ private: utils::Duration filteredExposure_; utils::Duration currentExposure_; - utils::Duration prevExposureValue_; + utils::Duration effectiveExposureValue_; uint32_t stride_; };
Previously, the exposure value was calculated based on the estimated shutter time and gain applied. Now that we have the real values for the current frame, use those before estimating the next one and rename the variable accordingly. As the exposure value is updated in the beginning of the computation, there is no need to initialize effectiveExposureValue anymore in the configure call. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> --- src/ipa/ipu3/algorithms/agc.cpp | 25 +++++++++---------------- src/ipa/ipu3/algorithms/agc.h | 2 +- 2 files changed, 10 insertions(+), 17 deletions(-)