[PATCH v1 2/8] ipa: rkisp1: Use generic Interpolator class

Stefan Klug stefan.klug at ideasonboard.com
Mon Aug 26 17:22:00 CEST 2024


Replace all occurrences of the MatrixInterpolator with the generic one.

Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/awb.cpp |  4 ++--
 src/ipa/rkisp1/algorithms/awb.h   |  5 +++--
 src/ipa/rkisp1/algorithms/ccm.cpp | 18 ++++++------------
 src/ipa/rkisp1/algorithms/ccm.h   |  6 +++---
 4 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index d482eda5b541..9b181c163e0b 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -53,7 +53,7 @@ int Awb::init(IPAContext &context, const YamlObject &tuningData)
 							 kMaxColourTemperature,
 							 kDefaultColourTemperature);
 
-	MatrixInterpolator<double, 2, 1> gains;
+	Interpolator<Matrix<double, 2, 1>> gains;
 	int ret = gains.readYaml(tuningData["gains"], "ct", "gains");
 	if (ret < 0)
 		LOG(RkISP1Awb, Warning)
@@ -124,7 +124,7 @@ void Awb::queueRequest(IPAContext &context,
 
 	const auto &colourTemperature = controls.get(controls::ColourTemperature);
 	if (colourTemperature && !awb.autoEnabled && gains_ && !colourGains) {
-		Matrix<double, 2, 1> gains = gains_->get(*colourTemperature);
+		Matrix<double, 2, 1> gains = gains_->getInterpolated(*colourTemperature);
 		awb.gains.manual.red = gains[0][0];
 		awb.gains.manual.blue = gains[1][0];
 
diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
index a010e6d1cb3c..9e44f1c278ab 100644
--- a/src/ipa/rkisp1/algorithms/awb.h
+++ b/src/ipa/rkisp1/algorithms/awb.h
@@ -9,7 +9,8 @@
 
 #include <optional>
 
-#include "libipa/matrix_interpolator.h"
+#include "libipa/interpolator.h"
+#include "libipa/matrix.h"
 
 #include "algorithm.h"
 
@@ -39,7 +40,7 @@ public:
 private:
 	uint32_t estimateCCT(double red, double green, double blue);
 
-	std::optional<MatrixInterpolator<double, 2, 1>> gains_;
+	std::optional<Interpolator<Matrix<double, 2, 1>>> gains_;
 	bool rgbMode_;
 };
 
diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
index fe7246f8b185..5a29d20e6cdb 100644
--- a/src/ipa/rkisp1/algorithms/ccm.cpp
+++ b/src/ipa/rkisp1/algorithms/ccm.cpp
@@ -23,7 +23,7 @@
 #include "libcamera/internal/yaml_parser.h"
 
 #include "../utils.h"
-#include "libipa/matrix_interpolator.h"
+#include "libipa/interpolator.h"
 
 /**
  * \file ccm.h
@@ -50,7 +50,7 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
 		LOG(RkISP1Ccm, Warning)
 			<< "Failed to parse 'ccm' "
 			<< "parameter from tuning file; falling back to unit matrix";
-		ccm_.reset();
+		ccm_.setData({ { 0, Matrix<float, 3, 3>::identity() } });
 	}
 
 	ret = offsets_.readYaml(tuningData["ccms"], "ct", "offsets");
@@ -58,14 +58,8 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
 		LOG(RkISP1Ccm, Warning)
 			<< "Failed to parse 'offsets' "
 			<< "parameter from tuning file; falling back to zero offsets";
-		/*
-		 * MatrixInterpolator::reset() resets to identity matrices
-		 * while here we need zero matrices so we need to construct it
-		 * ourselves.
-		 */
-		Matrix<int16_t, 3, 1> m({ 0, 0, 0 });
-		std::map<unsigned int, Matrix<int16_t, 3, 1>> matrices = { { 0, m } };
-		offsets_ = MatrixInterpolator<int16_t, 3, 1>(matrices);
+
+		offsets_.setData({ { 0, Matrix<int16_t, 3, 1>({ 0, 0, 0 }) } });
 	}
 
 	return 0;
@@ -117,8 +111,8 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame,
 	}
 
 	ct_ = ct;
-	Matrix<float, 3, 3> ccm = ccm_.get(ct);
-	Matrix<int16_t, 3, 1> offsets = offsets_.get(ct);
+	Matrix<float, 3, 3> ccm = ccm_.getInterpolated(ct);
+	Matrix<int16_t, 3, 1> offsets = offsets_.getInterpolated(ct);
 
 	context.activeState.ccm.ccm = ccm;
 	frameContext.ccm.ccm = ccm;
diff --git a/src/ipa/rkisp1/algorithms/ccm.h b/src/ipa/rkisp1/algorithms/ccm.h
index 30cb882180cc..4efe9c00c3c9 100644
--- a/src/ipa/rkisp1/algorithms/ccm.h
+++ b/src/ipa/rkisp1/algorithms/ccm.h
@@ -9,8 +9,8 @@
 
 #include <linux/rkisp1-config.h>
 
+#include "libipa/interpolator.h"
 #include "libipa/matrix.h"
-#include "libipa/matrix_interpolator.h"
 
 #include "algorithm.h"
 
@@ -40,8 +40,8 @@ private:
 			   const Matrix<int16_t, 3, 1> &offsets);
 
 	unsigned int ct_;
-	MatrixInterpolator<float, 3, 3> ccm_;
-	MatrixInterpolator<int16_t, 3, 1> offsets_;
+	Interpolator<Matrix<float, 3, 3>> ccm_;
+	Interpolator<Matrix<int16_t, 3, 1>> offsets_;
 };
 
 } /* namespace ipa::rkisp1::algorithms */
-- 
2.43.0



More information about the libcamera-devel mailing list