[libcamera-devel] [PATCH v5 23/33] ipa: rkisp1: dpf: Store per-frame information in frame context
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Sep 27 04:36:32 CEST 2022
Rework the algorithm's usage of the active state, to store the value of
controls for the last queued request in the queueRequest() function, and
store a copy of the values in the corresponding frame context. The
latter is used in the prepare() function to populate the ISP parameters
with values corresponding to the right frame.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
---
Changes since v4:
- Only update parameters when values have changed
---
src/ipa/rkisp1/algorithms/dpf.cpp | 30 +++++++++++++++++-------------
src/ipa/rkisp1/ipa_context.cpp | 15 ++++++++++++---
src/ipa/rkisp1/ipa_context.h | 6 +++++-
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp
index b8d0c7b85639..f7bc371da52e 100644
--- a/src/ipa/rkisp1/algorithms/dpf.cpp
+++ b/src/ipa/rkisp1/algorithms/dpf.cpp
@@ -176,10 +176,11 @@ int Dpf::init([[maybe_unused]] IPAContext &context,
*/
void Dpf::queueRequest(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
+ IPAFrameContext &frameContext,
const ControlList &controls)
{
auto &dpf = context.activeState.dpf;
+ bool update = false;
const auto &denoise = controls.get(controls::draft::NoiseReductionMode);
if (denoise) {
@@ -187,35 +188,40 @@ void Dpf::queueRequest(IPAContext &context,
switch (*denoise) {
case controls::draft::NoiseReductionModeOff:
- dpf.denoise = false;
- dpf.updateParams = true;
+ if (dpf.denoise) {
+ dpf.denoise = false;
+ update = true;
+ }
break;
case controls::draft::NoiseReductionModeMinimal:
case controls::draft::NoiseReductionModeHighQuality:
case controls::draft::NoiseReductionModeFast:
- dpf.denoise = true;
- dpf.updateParams = true;
+ if (!dpf.denoise) {
+ dpf.denoise = true;
+ update = true;
+ }
break;
default:
LOG(RkISP1Dpf, Error)
<< "Unsupported denoise value "
<< *denoise;
+ break;
}
}
+
+ frameContext.dpf.denoise = dpf.denoise;
+ frameContext.dpf.update = update;
}
/**
* \copydoc libcamera::ipa::Algorithm::prepare
*/
void Dpf::prepare(IPAContext &context, const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
- rkisp1_params_cfg *params)
+ IPAFrameContext &frameContext, rkisp1_params_cfg *params)
{
if (!initialized_)
return;
- auto &dpf = context.activeState.dpf;
-
if (frame == 0) {
params->others.dpf_config = config_;
params->others.dpf_strength_config = strengthConfig_;
@@ -245,12 +251,10 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,
RKISP1_CIF_ISP_MODULE_DPF_STRENGTH;
}
- if (dpf.updateParams) {
+ if (frameContext.dpf.update) {
params->module_en_update |= RKISP1_CIF_ISP_MODULE_DPF;
- if (dpf.denoise)
+ if (frameContext.dpf.denoise)
params->module_ens |= RKISP1_CIF_ISP_MODULE_DPF;
-
- dpf.updateParams = false;
}
}
diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp
index fdc8e7df0b76..c7cd007b2428 100644
--- a/src/ipa/rkisp1/ipa_context.cpp
+++ b/src/ipa/rkisp1/ipa_context.cpp
@@ -168,9 +168,6 @@ namespace libcamera::ipa::rkisp1 {
*
* \var IPAActiveState::dpf.denoise
* \brief Indicates if denoise is activated
- *
- * \var IPAActiveState::dpf.updateParams
- * \brief Indicates if ISP parameters need to be updated
*/
/**
@@ -251,6 +248,18 @@ namespace libcamera::ipa::rkisp1 {
* compared to the previous frame
*/
+/**
+ * \var IPAFrameContext::dpf
+ * \brief Denoise Pre-Filter parameters for this frame
+ *
+ * \var IPAFrameContext::dpf.denoise
+ * \brief Indicates if denoise is activated
+ *
+ * \var IPAFrameContext::dpf.update
+ * \brief Indicates if the denoise pre-filter parameters have been updated
+ * compared to the previous frame
+ */
+
/**
* \var IPAFrameContext::sensor
* \brief Sensor configuration that used been used for this frame
diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h
index cc217aec511a..81b632a15960 100644
--- a/src/ipa/rkisp1/ipa_context.h
+++ b/src/ipa/rkisp1/ipa_context.h
@@ -80,7 +80,6 @@ struct IPAActiveState {
struct {
bool denoise;
- bool updateParams;
} dpf;
struct {
@@ -114,6 +113,11 @@ struct IPAFrameContext : public FrameContext {
bool update;
} cproc;
+ struct {
+ bool denoise;
+ bool update;
+ } dpf;
+
struct {
uint32_t exposure;
double gain;
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list