[v2,3/9] ipa: rkisp1: Use generic Interpolator class
diff mbox series

Message ID 20240913075750.35115-4-stefan.klug@ideasonboard.com
State Superseded
Headers show
Series
  • Implement polynomial lsc support
Related show

Commit Message

Stefan Klug Sept. 13, 2024, 7:57 a.m. UTC
Replace all occurrences of the MatrixInterpolator with the generic one.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/ccm.cpp | 18 ++++++------------
 src/ipa/rkisp1/algorithms/ccm.h   |  6 +++---
 2 files changed, 9 insertions(+), 15 deletions(-)

Comments

Kieran Bingham Sept. 13, 2024, 9:13 a.m. UTC | #1
Quoting Stefan Klug (2024-09-13 08:57:21)
> Replace all occurrences of the MatrixInterpolator with the generic one.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
> ---
>  src/ipa/rkisp1/algorithms/ccm.cpp | 18 ++++++------------
>  src/ipa/rkisp1/algorithms/ccm.h   |  6 +++---
>  2 files changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
> index 1ca0e73f81ad..6b7d2e2cd5b3 100644
> --- a/src/ipa/rkisp1/algorithms/ccm.cpp
> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp
> @@ -19,7 +19,7 @@
>  #include "libcamera/internal/yaml_parser.h"
>  
>  #include "../utils.h"
> -#include "libipa/matrix_interpolator.h"
> +#include "libipa/interpolator.h"
>  
>  /**
>   * \file ccm.h
> @@ -46,7 +46,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");
> @@ -54,14 +54,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;
> @@ -106,8 +100,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 9daadb6834b1..46a1416e6be5 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_;

I like this.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>  };
>  
>  } /* namespace ipa::rkisp1::algorithms */
> -- 
> 2.43.0
>
Paul Elder Sept. 13, 2024, 10:19 a.m. UTC | #2
On Fri, Sep 13, 2024 at 09:57:21AM +0200, Stefan Klug wrote:
> Replace all occurrences of the MatrixInterpolator with the generic one.
> 
> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/ipa/rkisp1/algorithms/ccm.cpp | 18 ++++++------------
>  src/ipa/rkisp1/algorithms/ccm.h   |  6 +++---
>  2 files changed, 9 insertions(+), 15 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
> index 1ca0e73f81ad..6b7d2e2cd5b3 100644
> --- a/src/ipa/rkisp1/algorithms/ccm.cpp
> +++ b/src/ipa/rkisp1/algorithms/ccm.cpp
> @@ -19,7 +19,7 @@
>  #include "libcamera/internal/yaml_parser.h"
>  
>  #include "../utils.h"
> -#include "libipa/matrix_interpolator.h"
> +#include "libipa/interpolator.h"
>  
>  /**
>   * \file ccm.h
> @@ -46,7 +46,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");
> @@ -54,14 +54,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;
> @@ -106,8 +100,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 9daadb6834b1..46a1416e6be5 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
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/ccm.cpp b/src/ipa/rkisp1/algorithms/ccm.cpp
index 1ca0e73f81ad..6b7d2e2cd5b3 100644
--- a/src/ipa/rkisp1/algorithms/ccm.cpp
+++ b/src/ipa/rkisp1/algorithms/ccm.cpp
@@ -19,7 +19,7 @@ 
 #include "libcamera/internal/yaml_parser.h"
 
 #include "../utils.h"
-#include "libipa/matrix_interpolator.h"
+#include "libipa/interpolator.h"
 
 /**
  * \file ccm.h
@@ -46,7 +46,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");
@@ -54,14 +54,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;
@@ -106,8 +100,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 9daadb6834b1..46a1416e6be5 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 */