From 442842b4b4d88bc44e653bda5b8546dda5c2cb7a Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Wed, 30 Oct 2024 17:30:43 +0100 Subject: ipa: rkisp1: Have algos initialize FrameContext The RkISP1 AGC algorithms assumes the metering mode to be "MeteringMatrix" and pre-fill an array of weights associated with it stored in meteringModes_[MeteringMatrix] when intializing the algorithm in parseMeteringModes(). It laters fetches the weights when computing parameters using the FrameContext.agc.meteringMode as index of the meteringModes_ array. When a Request gets queued to the algorithm, the FrameContext.agc.meteringMode index is populated from the algorithm's active state, and optionally updated if the application has specified a different metering mode. In case of Request underrun however, a non-initialized FrameContext gets provided to the algorithm, causing an (unhandled) exception when accessing the meteringModes_ array. To handle the situation when a Request underrun occours and let algorithms initialize a FrameContext to safe defaults: - Add an 'underrun' flag to FrameContext - Add an 'initFrameContext()' function to RkISP1 algorithms - If a FrameContext is get() before being allocated, pass it through the algorithms' initFrameContext() to safely initialize it Signed-off-by: Jacopo Mondi --- src/ipa/rkisp1/rkisp1.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/ipa/rkisp1/rkisp1.cpp') diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 005c17ca..78459c80 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -353,6 +353,15 @@ void IPARkISP1::processStats(const uint32_t frame, const uint32_t bufferId, { IPAFrameContext &frameContext = context_.frameContexts.get(frame); + if (frameContext.underrun) { + for (auto const &a : algorithms()) { + Algorithm *algo = static_cast(a.get()); + if (algo->disabled_) + continue; + algo->initFrameContext(context_, frameContext); + } + } + /* * In raw capture mode, the ISP is bypassed and no statistics buffer is * provided. -- cgit v1.2.1