@@ -67,8 +67,8 @@ Agc::Agc()
void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV)
{
- int32_t &exposure = frameContext.sensor.exposure;
- double &again = frameContext.sensor.gain;
+ int32_t exposure = frameContext.sensor.exposure;
+ double again = frameContext.sensor.gain;
double error = kExposureOptimal - exposureMSV;
@@ -115,6 +115,9 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
again = std::clamp(again, context.configuration.agc.againMin,
context.configuration.agc.againMax);
+ frameContext.agc.exposure = exposure;
+ frameContext.agc.gain = again;
+
context.activeState.agc.exposure = exposure;
context.activeState.agc.again = again;
@@ -150,8 +153,8 @@ void Agc::process(IPAContext &context,
* Use the new exposure and gain values calculated the last time
* there were valid stats.
*/
- frameContext.sensor.exposure = context.activeState.agc.exposure;
- frameContext.sensor.gain = context.activeState.agc.again;
+ frameContext.agc.exposure = context.activeState.agc.exposure;
+ frameContext.agc.gain = context.activeState.agc.again;
return;
}
@@ -66,6 +66,11 @@ struct IPAActiveState {
struct IPAFrameContext : public FrameContext {
Matrix<float, 3, 3> ccm;
+ struct {
+ int32_t exposure;
+ double gain;
+ } agc;
+
struct {
int32_t exposure;
double gain;
@@ -320,10 +320,11 @@ void IPASoftSimple::processStats(const uint32_t frame,
ControlList ctrls(sensorInfoMap_);
- auto &againNew = frameContext.sensor.gain;
- ctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure);
- ctrls.set(V4L2_CID_ANALOGUE_GAIN,
- static_cast<int32_t>(camHelper_ ? camHelper_->gainCode(againNew) : againNew));
+ int32_t againNew = camHelper_
+ ? camHelper_->gainCode(frameContext.agc.gain)
+ : static_cast<int32_t>(frameContext.agc.gain);
+ ctrls.set(V4L2_CID_EXPOSURE, frameContext.agc.exposure);
+ ctrls.set(V4L2_CID_ANALOGUE_GAIN, againNew);
setSensorControls.emit(ctrls);
}
In the agc algorithm do not overwrite the sensor exposure/gain values, instead add a new "agc" member to the frame context and update that. No functional changes are intended as the agc algorithm runs last. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> --- src/ipa/simple/algorithms/agc.cpp | 11 +++++++---- src/ipa/simple/ipa_context.h | 5 +++++ src/ipa/simple/soft_simple.cpp | 9 +++++---- 3 files changed, 17 insertions(+), 8 deletions(-)