summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3/algorithms/agc.cpp
diff options
context:
space:
mode:
authorJean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>2022-02-24 16:11:12 +0100
committerUmang Jain <umang.jain@ideasonboard.com>2022-03-11 20:47:32 +0530
commitb5d2adbeabeacdba6e887de2aef39aa320f4abe1 (patch)
treea02b36fb70092db8f5b0743dea243c64ef5669c3 /src/ipa/ipu3/algorithms/agc.cpp
parente3900d1bf9fdb7200cfda7b73e59b5aac03c6f18 (diff)
ipa: ipu3: agc: Introduce lineDuration in IPASessionConfiguration
Instead of having a local cached value for line duration, store it in the IPASessionConfiguration::sensor structure. While at it, configure the default analogue gain and shutter speed to controlled fixed values. The latter is set to be 10ms as it will in most cases be close to the one needed, making the AGC faster to converge. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/algorithms/agc.cpp')
-rw-r--r--src/ipa/ipu3/algorithms/agc.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index a929085c..1eb1bcef 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -71,7 +71,7 @@ static constexpr uint32_t kNumStartupFrames = 10;
static constexpr double kRelativeLuminanceTarget = 0.16;
Agc::Agc()
- : frameCount_(0), lineDuration_(0s), minShutterSpeed_(0s),
+ : frameCount_(0), minShutterSpeed_(0s),
maxShutterSpeed_(0s), filteredExposure_(0s)
{
}
@@ -83,13 +83,13 @@ Agc::Agc()
*
* \return 0
*/
-int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)
+int Agc::configure(IPAContext &context,
+ [[maybe_unused]] const IPAConfigInfo &configInfo)
{
- stride_ = context.configuration.grid.stride;
+ IPASessionConfiguration &configuration = context.configuration;
+ IPAFrameContext &frameContext = context.frameContext;
- /* \todo use the IPAContext to provide the limits */
- lineDuration_ = configInfo.sensorInfo.lineLength * 1.0s
- / configInfo.sensorInfo.pixelRate;
+ stride_ = configuration.grid.stride;
minShutterSpeed_ = context.configuration.agc.minShutterSpeed;
maxShutterSpeed_ = std::min(context.configuration.agc.maxShutterSpeed,
@@ -99,8 +99,8 @@ int Agc::configure(IPAContext &context, const IPAConfigInfo &configInfo)
maxAnalogueGain_ = std::min(context.configuration.agc.maxAnalogueGain, kMaxAnalogueGain);
/* Configure the default exposure and gain. */
- context.frameContext.agc.gain = minAnalogueGain_;
- context.frameContext.agc.exposure = minShutterSpeed_ / lineDuration_;
+ frameContext.agc.gain = std::max(minAnalogueGain_, kMinAnalogueGain);
+ frameContext.agc.exposure = 10ms / configuration.sensor.lineDuration;
return 0;
}
@@ -182,9 +182,11 @@ utils::Duration Agc::filterExposure(utils::Duration exposureValue)
* \param[in] yGain The gain calculated based on the relative luminance target
* \param[in] iqMeanGain The gain calculated based on the relative luminance target
*/
-void Agc::computeExposure(IPAFrameContext &frameContext, double yGain,
+void Agc::computeExposure(IPAContext &context, double yGain,
double iqMeanGain)
{
+ const IPASessionConfiguration &configuration = context.configuration;
+ IPAFrameContext &frameContext = context.frameContext;
/* Get the effective exposure and gain applied on the sensor. */
uint32_t exposure = frameContext.sensor.exposure;
double analogueGain = frameContext.sensor.gain;
@@ -200,7 +202,7 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double yGain,
/* extracted from Rpi::Agc::computeTargetExposure */
/* Calculate the shutter time in seconds */
- utils::Duration currentShutter = exposure * lineDuration_;
+ utils::Duration currentShutter = exposure * configuration.sensor.lineDuration;
/*
* Update the exposure value for the next computation using the values
@@ -247,7 +249,7 @@ void Agc::computeExposure(IPAFrameContext &frameContext, double yGain,
<< stepGain;
/* Update the estimated exposure and gain. */
- frameContext.agc.exposure = shutterTime / lineDuration_;
+ frameContext.agc.exposure = shutterTime / configuration.sensor.lineDuration;
frameContext.agc.gain = stepGain;
}
@@ -354,7 +356,7 @@ void Agc::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
break;
}
- computeExposure(context.frameContext, yGain, iqMeanGain);
+ computeExposure(context, yGain, iqMeanGain);
frameCount_++;
}