| Message ID | 20261019184526.252977-5-barnabas.pocze@ideasonboard.com |
|---|---|
| State | Superseded |
| Headers | show |
| Series |
|
| Related | show |
Hi Barnabas On Mon, Oct 19, 2026 at 08:45:11PM +0200, Barnabás Pőcze wrote: > After the loop, `stageGain == lastStageGain`, so use `lastStageGain` in the > later calculation instead, and make `stageGain` "local" to the loop, just like > `stageExposure` already is. > > And with that, also move the calculation a bit later, just before the value > is actually used. > > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> > --- > src/ipa/libipa/exposure_mode_helper.cpp | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp > index 380edee825..51f4be98e2 100644 > --- a/src/ipa/libipa/exposure_mode_helper.cpp > +++ b/src/ipa/libipa/exposure_mode_helper.cpp > @@ -240,13 +240,11 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const > exposure / (exposureTime * gain * quantGain) }; > } > > - double stageGain = clampGain(1.0); > - double lastStageGain = stageGain; > + double lastStageGain = clampGain(1.0); > > for (const auto &stage : stages_) { > utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime, > &quantGain); > - stageGain = clampGain(stage.gain); > > /* > * We perform the clamping on both exposure time and gain in > @@ -267,6 +265,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const > } > > /* Clamp the exposureTime to stageExposureTime and regulate gain. */ > + const double stageGain = clampGain(stage.gain); > + > if (stageExposureTime * stageGain >= exposure) { > exposureTime = stageExposureTime; > gain = clampGain(exposure / exposureTime, &quantGain2); > @@ -283,10 +283,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const > * From here on all we can do is max out the exposure time, followed by > * the analogue gain. If we still haven't achieved the target we send > * the rest of the exposure time to digital gain. If we were given no > - * stages to use then the default stageGain of 1.0 is used so that > - * exposure time is maxed before gain is touched at all. > + * stages to use then the default gain of 1.0 is used so that exposure > + * time is maxed before gain is touched at all. > */ > - exposureTime = clampExposureTime(exposure / stageGain, &quantGain); > + exposureTime = clampExposureTime(exposure / lastStageGain, &quantGain); > gain = clampGain(exposure / exposureTime, &quantGain2); > quantGain *= quantGain2; > > -- > 2.56.0 >
diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index 380edee825..51f4be98e2 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -240,13 +240,11 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const exposure / (exposureTime * gain * quantGain) }; } - double stageGain = clampGain(1.0); - double lastStageGain = stageGain; + double lastStageGain = clampGain(1.0); for (const auto &stage : stages_) { utils::Duration stageExposureTime = clampExposureTime(stage.exposureTime, &quantGain); - stageGain = clampGain(stage.gain); /* * We perform the clamping on both exposure time and gain in @@ -267,6 +265,8 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const } /* Clamp the exposureTime to stageExposureTime and regulate gain. */ + const double stageGain = clampGain(stage.gain); + if (stageExposureTime * stageGain >= exposure) { exposureTime = stageExposureTime; gain = clampGain(exposure / exposureTime, &quantGain2); @@ -283,10 +283,10 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const * From here on all we can do is max out the exposure time, followed by * the analogue gain. If we still haven't achieved the target we send * the rest of the exposure time to digital gain. If we were given no - * stages to use then the default stageGain of 1.0 is used so that - * exposure time is maxed before gain is touched at all. + * stages to use then the default gain of 1.0 is used so that exposure + * time is maxed before gain is touched at all. */ - exposureTime = clampExposureTime(exposure / stageGain, &quantGain); + exposureTime = clampExposureTime(exposure / lastStageGain, &quantGain); gain = clampGain(exposure / exposureTime, &quantGain2); quantGain *= quantGain2;
After the loop, `stageGain == lastStageGain`, so use `lastStageGain` in the later calculation instead, and make `stageGain` "local" to the loop, just like `stageExposure` already is. And with that, also move the calculation a bit later, just before the value is actually used. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/ipa/libipa/exposure_mode_helper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)