summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1/algorithms
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-09-08 00:39:53 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-09-28 05:41:14 +0300
commita90dc9bc5c05e0144f9e34bf1afcd832bfaf605b (patch)
tree09883331c06385c63bbf3355cc5a91a16ef36ea4 /src/ipa/rkisp1/algorithms
parent3c3e0aa12362a9652d93cc26d6b28a1572070159 (diff)
ipa: rkisp1: filter: Store per-frame information in frame context
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@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/ipa/rkisp1/algorithms')
-rw-r--r--src/ipa/rkisp1/algorithms/filter.cpp49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/ipa/rkisp1/algorithms/filter.cpp b/src/ipa/rkisp1/algorithms/filter.cpp
index 837560eb..4b89c05a 100644
--- a/src/ipa/rkisp1/algorithms/filter.cpp
+++ b/src/ipa/rkisp1/algorithms/filter.cpp
@@ -44,15 +44,20 @@ static constexpr uint32_t kFiltModeDefault = 0x000004f2;
*/
void Filter::queueRequest(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
+ IPAFrameContext &frameContext,
const ControlList &controls)
{
auto &filter = context.activeState.filter;
+ bool update = false;
const auto &sharpness = controls.get(controls::Sharpness);
if (sharpness) {
- filter.sharpness = std::round(std::clamp(*sharpness, 0.0f, 10.0f));
- filter.updateParams = true;
+ unsigned int value = std::round(std::clamp(*sharpness, 0.0f, 10.0f));
+
+ if (filter.sharpness != value) {
+ filter.sharpness = value;
+ update = true;
+ }
LOG(RkISP1Filter, Debug) << "Set sharpness to " << *sharpness;
}
@@ -63,42 +68,48 @@ void Filter::queueRequest(IPAContext &context,
switch (*denoise) {
case controls::draft::NoiseReductionModeOff:
- filter.denoise = 0;
- filter.updateParams = true;
+ if (filter.denoise != 0) {
+ filter.denoise = 0;
+ update = true;
+ }
break;
case controls::draft::NoiseReductionModeMinimal:
- filter.denoise = 1;
- filter.updateParams = true;
+ if (filter.denoise != 1) {
+ filter.denoise = 1;
+ update = true;
+ }
break;
case controls::draft::NoiseReductionModeHighQuality:
case controls::draft::NoiseReductionModeFast:
- filter.denoise = 3;
- filter.updateParams = true;
+ if (filter.denoise != 3) {
+ filter.denoise = 3;
+ update = true;
+ }
break;
default:
LOG(RkISP1Filter, Error)
<< "Unsupported denoise value "
<< *denoise;
+ break;
}
}
+
+ frameContext.filter.denoise = filter.denoise;
+ frameContext.filter.sharpness = filter.sharpness;
+ frameContext.filter.update = update;
}
/**
* \copydoc libcamera::ipa::Algorithm::prepare
*/
-void Filter::prepare(IPAContext &context,
+void Filter::prepare([[maybe_unused]] IPAContext &context,
[[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
- rkisp1_params_cfg *params)
+ IPAFrameContext &frameContext, rkisp1_params_cfg *params)
{
- auto &filter = context.activeState.filter;
-
/* Check if the algorithm configuration has been updated. */
- if (!filter.updateParams)
+ if (!frameContext.filter.update)
return;
- filter.updateParams = false;
-
static constexpr uint16_t filt_fac_sh0[] = {
0x04, 0x07, 0x0a, 0x0c, 0x10, 0x14, 0x1a, 0x1e, 0x24, 0x2a, 0x30
};
@@ -147,8 +158,8 @@ void Filter::prepare(IPAContext &context,
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};
- uint8_t denoise = filter.denoise;
- uint8_t sharpness = filter.sharpness;
+ uint8_t denoise = frameContext.filter.denoise;
+ uint8_t sharpness = frameContext.filter.sharpness;
auto &flt_config = params->others.flt_config;
flt_config.fac_sh0 = filt_fac_sh0[sharpness];