@@ -51,8 +51,8 @@ namespace RPiController {
* modules may produce one or more frames that are not yet correctly exposed,
* or where the metadata may be suspect. We have the following functions:
* HideFramesStartup(): Tell the pipeline handler not to return this many
- * frames at start-up. This can also be used to hide initial frames
- * while the AGC and other algorithms are sorting themselves out.
+ * frames at start-up. Statistics from frames hidden at start-up or
+ * after a mode switch are not passed to the control algorithms.
* HideFramesModeSwitch(): Tell the pipeline handler not to return this
* many frames after a mode switch (other than start-up). Some sensors
* may produce innvalid frames after a mode switch; others may not.
@@ -373,6 +373,7 @@ void IpaBase::start(const ControlList &controls, StartResult *result)
result->startupFrameCount = std::max({ agcConvergenceFrames, awbConvergenceFrames });
result->invalidFrameCount = invalidCount_;
+ hiddenFrameCount_ = invalidCount_;
invalidCount_ = std::max({ invalidCount_, agcConvergenceFrames, awbConvergenceFrames });
@@ -467,6 +468,12 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms)
if (frameCount_ >= mistrustCount_)
helper_->prepare(embeddedBuffer, rpiMetadata);
+ /*
+ * Without inline statistics, processStats() runs after frameCount_ has
+ * been incremented, so record here whether this frame is hidden.
+ */
+ hiddenFrame_ = frameCount_ < hiddenFrameCount_;
+
bool delayedRequestControls = false;
delayedMetadata.get<bool>("ipa.request_controls", delayedRequestControls);
@@ -534,7 +541,8 @@ void IpaBase::processStats(const ProcessParams ¶ms)
rpiMetadata.set("focus.status", statistics->focusRegions);
helper_->process(statistics, rpiMetadata);
- controller_.process(statistics, &rpiMetadata);
+ if (!hiddenFrame_)
+ controller_.process(statistics, &rpiMetadata);
}
struct AgcStatus agcStatus;
@@ -122,12 +122,18 @@ private:
/* Number of frames that need to be marked as dropped on startup. */
unsigned int invalidCount_;
+ /* Frames hidden by the camera helper, a subset of invalidCount_. */
+ unsigned int hiddenFrameCount_;
+
/* Frame timestamp for the last run of the controller. */
uint64_t lastRunTimestamp_;
/* Do we run a Controller::process() for this frame? */
bool processPending_;
+ /* Is this frame hidden by the camera helper? */
+ bool hiddenFrame_;
+
/* Distinguish the first camera start from others. */
bool firstStart_;
Control algorithms currently run on frames with mistrusted metadata, so AGC reacts to statistics of hidden start-up frames. Those hidden after a mode switch have also not been accounted for. Fixes: 93bed4da915c ("ipa: rpi: Gate CamHelper::prepare() by the mistrust count") Signed-off-by: Danius Kalvaitis <danius@kurokesu.com> --- Tested on a Raspberry Pi CM5 with imx462 in a bright scene. Without this patch, AGC acts on hidden frame statistics after a mode switch and applications receive one dark frame. At start-up the dip lands only on frames flagged FrameStartup, but settled exposure reaches applications 2 frames later. With this patch, both dips are gone. A mode switch takes 2 frames longer to settle, as AGC no longer makes an oversized step toward its target. src/ipa/rpi/cam_helper/cam_helper.h | 4 ++-- src/ipa/rpi/common/ipa_base.cpp | 10 +++++++++- src/ipa/rpi/common/ipa_base.h | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-)