Message ID | 20241020152821.240726-5-mike.rudenko@gmail.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
On 2024-10-20 at 18:28 +03, Mikhail Rudenko <mike.rudenko@gmail.com> wrote: > The results of AGC algorithm currently travel a long way before being > actually applied. Let's consider the common case when 4 requests are > used and frames 0-3 are queued before start(). AGC is first run when > frame 0 stats are ready, and exposure/gain are saved in > activeState. Then, when frame 4 is queued, they are stored in > corresponding frameContext. Four frames later, frame 4 is captured, > and after processing the stats buffer, exposure/gain are extracted > from frameContext and queued to delayedControls in setControls(). On > frame 5, delayedControls apply them. Assuming a control delay of 2, the > settings will become effective for frame 7. So, it takes 7 frames for > the AGC algorithm to get feedback. This results in suboptimal > convergence rate. > > If we instead use just computed exposure/gain from the activeState in > setControls, the delay is reduced from 7 frames to 3 frames. Tests > on OV4689 sensor show faster convergence and no unwanted side effects. Oops - forgot Signed-off-by: Mikhail Rudenko <mike.rudenko@gmail.com> > --- > src/ipa/rkisp1/rkisp1.cpp | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp > index 680a7eee..8793d59f 100644 > --- a/src/ipa/rkisp1/rkisp1.cpp > +++ b/src/ipa/rkisp1/rkisp1.cpp > @@ -458,9 +458,11 @@ void IPARkISP1::setControls(unsigned int frame) > * internal sensor delays and other timing parameters into account. > */ > > - IPAFrameContext &frameContext = context_.frameContexts.get(frame); > - uint32_t exposure = frameContext.agc.exposure; > - uint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain); > + const auto &agc = context_.activeState.agc; > + uint32_t exposure = agc.autoEnabled ? > + agc.automatic.exposure : agc.manual.exposure; > + uint32_t gain = context_.camHelper->gainCode(agc.autoEnabled ? > + agc.automatic.gain : agc.manual.gain); > > ControlList ctrls(sensorControls_); > ctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure)); -- Best regards, Mikhail Rudenko
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 680a7eee..8793d59f 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -458,9 +458,11 @@ void IPARkISP1::setControls(unsigned int frame) * internal sensor delays and other timing parameters into account. */ - IPAFrameContext &frameContext = context_.frameContexts.get(frame); - uint32_t exposure = frameContext.agc.exposure; - uint32_t gain = context_.camHelper->gainCode(frameContext.agc.gain); + const auto &agc = context_.activeState.agc; + uint32_t exposure = agc.autoEnabled ? + agc.automatic.exposure : agc.manual.exposure; + uint32_t gain = context_.camHelper->gainCode(agc.autoEnabled ? + agc.automatic.gain : agc.manual.gain); ControlList ctrls(sensorControls_); ctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure));