@@ -340,6 +340,9 @@ void Agc::queueRequest(IPAContext &context,
}
frameContext.agc.minFrameDuration = agc.minFrameDuration;
frameContext.agc.maxFrameDuration = agc.maxFrameDuration;
+
+ /* V-blank needs to be valid for the start controls handling. Update it. */
+ processFrameDuration(context, frameContext);
}
/**
@@ -383,6 +386,12 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,
frameContext.agc.yTarget = context.activeState.agc.automatic.yTarget;
+ /*
+ * Expand the target frame duration so that we do not run faster than
+ * the minimum frame duration when we have short exposures.
+ */
+ processFrameDuration(context, frameContext);
+
if (frame > 0 && !frameContext.agc.updateMetering)
return;
@@ -511,11 +520,13 @@ double Agc::estimateLuminance(double gain) const
* Compute and populate vblank from the target frame duration.
*/
void Agc::processFrameDuration(IPAContext &context,
- IPAFrameContext &frameContext,
- utils::Duration frameDuration)
+ IPAFrameContext &frameContext)
{
IPACameraSensorInfo &sensorInfo = context.sensorInfo;
utils::Duration lineDuration = context.configuration.sensor.lineDuration;
+ utils::Duration frameDuration = frameContext.agc.exposure * lineDuration;
+
+ frameDuration = std::max(frameDuration, frameContext.agc.minFrameDuration);
frameContext.agc.vblank = (frameDuration / lineDuration) - sensorInfo.outputSize.height;
@@ -539,8 +550,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
ControlList &metadata)
{
if (!stats) {
- processFrameDuration(context, frameContext,
- frameContext.agc.minFrameDuration);
fillMetadata(context, frameContext, metadata);
return;
}
@@ -642,12 +651,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
activeState.agc.automatic.gain = aGain;
activeState.agc.automatic.quantizationGain = qGain;
activeState.agc.automatic.yTarget = effectiveYTarget();
- /*
- * Expand the target frame duration so that we do not run faster than
- * the minimum frame duration when we have short exposures.
- */
- processFrameDuration(context, frameContext,
- std::max(frameContext.agc.minFrameDuration, newExposureTime));
fillMetadata(context, frameContext, metadata);
expMeans_ = {};
@@ -51,8 +51,7 @@ private:
ControlList &metadata);
double estimateLuminance(double gain) const override;
void processFrameDuration(IPAContext &context,
- IPAFrameContext &frameContext,
- utils::Duration frameDuration);
+ IPAFrameContext &frameContext);
Span<const uint8_t> expMeans_;
Span<const uint8_t> weights_;