| Message ID | 20260810103846.1075936-18-barnabas.pocze@ideasonboard.com |
|---|---|
| State | Superseded |
| Headers | show |
| Series |
|
| Related | show |
Hi Barnabás, Quoting Barnabás Pőcze (2026-08-10 12:38:13) > The rkisp1 agc algorithms needs to save the current y target for the > wdr algorithm. Instead of having to recalculate it, just return it > as part of the result set. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Looks good to me. Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> Regards, Stefan > --- > src/ipa/libipa/agc_mean_luminance.cpp | 13 ++++++++----- > src/ipa/libipa/agc_mean_luminance.h | 3 ++- > src/ipa/rkisp1/algorithms/agc.cpp | 2 +- > 3 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp > index 8e6eafd853..fbb5df847e 100644 > --- a/src/ipa/libipa/agc_mean_luminance.cpp > +++ b/src/ipa/libipa/agc_mean_luminance.cpp > @@ -501,9 +501,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime, > * target > * \return The calculated initial gain > */ > -double AgcMeanLuminance::estimateInitialGain(const Traits &traits) const > +double AgcMeanLuminance::estimateInitialGain(const Traits &traits, double yTarget) const > { > - double yTarget = effectiveYTarget(); > double yGain = 1.0; > > /* > @@ -670,6 +669,9 @@ utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue) > /** > * \struct AgcMeanLuminance::Result > * \brief Collection of results of the mean luminance AGC algorithm > + * > + * \var AgcMeanLuminance::Result::yTarget > + * \brief The current y target including exposure compensation > */ > > /** > @@ -693,6 +695,7 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms) > */ > ExposureModeHelper &exposureModeHelper = > exposureModeHelpers_.at(params.exposureModeIndex); > + double yTarget = effectiveYTarget(); > > if (params.effectiveExposureValue == 0s) { > LOG(AgcMeanLuminance, Error) > @@ -703,10 +706,10 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms) > * doesn't get stuck with 0 in case the sensor driver allows a > * min exposure of 0. > */ > - return { exposureModeHelper.splitExposure(10ms) }; > + return { exposureModeHelper.splitExposure(10ms), yTarget }; > } > > - double gain = estimateInitialGain(params.traits); > + double gain = estimateInitialGain(params.traits, yTarget); > gain = constraintClampGain(params.constraintModeIndex, params.yHist, gain); > > /* > @@ -725,7 +728,7 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms) > newExposureValue = filterExposure(newExposureValue); > > frameCount_++; > - return { exposureModeHelper.splitExposure(newExposureValue) }; > + return { exposureModeHelper.splitExposure(newExposureValue), yTarget }; > } > > /** > diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h > index aa4c0369ac..6418fe2e65 100644 > --- a/src/ipa/libipa/agc_mean_luminance.h > +++ b/src/ipa/libipa/agc_mean_luminance.h > @@ -87,6 +87,7 @@ public: > }; > > struct Result : ExposureModeHelper::Result { > + double yTarget; > }; > > [[nodiscard]] Result calculateNewEv(const Params ¶ms); > @@ -103,7 +104,7 @@ private: > int parseConstraint(const ValueNode &modeDict, int32_t id); > int parseConstraintModes(const ValueNode &tuningData); > int parseExposureModes(const ValueNode &tuningData); > - double estimateInitialGain(const Traits &traits) const; > + double estimateInitialGain(const Traits &traits, double yTarget) const; > double constraintClampGain(uint32_t constraintModeIndex, > const Histogram &hist, > double gain) const; > diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp > index a4567c8258..8ed9d7ea6d 100644 > --- a/src/ipa/rkisp1/algorithms/agc.cpp > +++ b/src/ipa/rkisp1/algorithms/agc.cpp > @@ -741,7 +741,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, > activeState.agc.automatic.exposure = newEv.exposureTime / lineDuration; > activeState.agc.automatic.gain = newEv.analogueGain; > activeState.agc.automatic.quantizationGain = newEv.quantizationGain; > - activeState.agc.automatic.yTarget = agc_.effectiveYTarget(); > + activeState.agc.automatic.yTarget = newEv.yTarget; > /* > * Expand the target frame duration so that we do not run faster than > * the minimum frame duration when we have short exposures. > -- > 2.55.0 >
diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp index 8e6eafd853..fbb5df847e 100644 --- a/src/ipa/libipa/agc_mean_luminance.cpp +++ b/src/ipa/libipa/agc_mean_luminance.cpp @@ -501,9 +501,8 @@ void AgcMeanLuminance::setLimits(utils::Duration minExposureTime, * target * \return The calculated initial gain */ -double AgcMeanLuminance::estimateInitialGain(const Traits &traits) const +double AgcMeanLuminance::estimateInitialGain(const Traits &traits, double yTarget) const { - double yTarget = effectiveYTarget(); double yGain = 1.0; /* @@ -670,6 +669,9 @@ utils::Duration AgcMeanLuminance::filterExposure(utils::Duration exposureValue) /** * \struct AgcMeanLuminance::Result * \brief Collection of results of the mean luminance AGC algorithm + * + * \var AgcMeanLuminance::Result::yTarget + * \brief The current y target including exposure compensation */ /** @@ -693,6 +695,7 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms) */ ExposureModeHelper &exposureModeHelper = exposureModeHelpers_.at(params.exposureModeIndex); + double yTarget = effectiveYTarget(); if (params.effectiveExposureValue == 0s) { LOG(AgcMeanLuminance, Error) @@ -703,10 +706,10 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms) * doesn't get stuck with 0 in case the sensor driver allows a * min exposure of 0. */ - return { exposureModeHelper.splitExposure(10ms) }; + return { exposureModeHelper.splitExposure(10ms), yTarget }; } - double gain = estimateInitialGain(params.traits); + double gain = estimateInitialGain(params.traits, yTarget); gain = constraintClampGain(params.constraintModeIndex, params.yHist, gain); /* @@ -725,7 +728,7 @@ AgcMeanLuminance::calculateNewEv(const Params ¶ms) newExposureValue = filterExposure(newExposureValue); frameCount_++; - return { exposureModeHelper.splitExposure(newExposureValue) }; + return { exposureModeHelper.splitExposure(newExposureValue), yTarget }; } /** diff --git a/src/ipa/libipa/agc_mean_luminance.h b/src/ipa/libipa/agc_mean_luminance.h index aa4c0369ac..6418fe2e65 100644 --- a/src/ipa/libipa/agc_mean_luminance.h +++ b/src/ipa/libipa/agc_mean_luminance.h @@ -87,6 +87,7 @@ public: }; struct Result : ExposureModeHelper::Result { + double yTarget; }; [[nodiscard]] Result calculateNewEv(const Params ¶ms); @@ -103,7 +104,7 @@ private: int parseConstraint(const ValueNode &modeDict, int32_t id); int parseConstraintModes(const ValueNode &tuningData); int parseExposureModes(const ValueNode &tuningData); - double estimateInitialGain(const Traits &traits) const; + double estimateInitialGain(const Traits &traits, double yTarget) const; double constraintClampGain(uint32_t constraintModeIndex, const Histogram &hist, double gain) const; diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index a4567c8258..8ed9d7ea6d 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -741,7 +741,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, activeState.agc.automatic.exposure = newEv.exposureTime / lineDuration; activeState.agc.automatic.gain = newEv.analogueGain; activeState.agc.automatic.quantizationGain = newEv.quantizationGain; - activeState.agc.automatic.yTarget = agc_.effectiveYTarget(); + activeState.agc.automatic.yTarget = newEv.yTarget; /* * Expand the target frame duration so that we do not run faster than * the minimum frame duration when we have short exposures.