[v3,19/35] ipa: rksip1: lsc: Make parseSizes() a class function
diff mbox series

Message ID 20260706-libipa-algorithms-v3-19-968757b038bb@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: libipa: Introduce libipa algorithms
Related show

Commit Message

Jacopo Mondi July 6, 2026, 8:01 a.m. UTC
There are no reasons to have it as a static helper.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/rkisp1/algorithms/lsc.cpp | 60 +++++++++++++++++++--------------------
 src/ipa/rkisp1/algorithms/lsc.h   |  2 ++
 2 files changed, 32 insertions(+), 30 deletions(-)

Comments

Kieran Bingham July 6, 2026, 6:38 p.m. UTC | #1
Quoting Jacopo Mondi (2026-07-06 09:01:39)
> There are no reasons to have it as a static helper.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Not much in it for me here, but I won't object or block it.


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

> ---
>  src/ipa/rkisp1/algorithms/lsc.cpp | 60 +++++++++++++++++++--------------------
>  src/ipa/rkisp1/algorithms/lsc.h   |  2 ++
>  2 files changed, 32 insertions(+), 30 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
> index 974534175e06..0312ce2f8bb1 100644
> --- a/src/ipa/rkisp1/algorithms/lsc.cpp
> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp
> @@ -34,36 +34,6 @@ namespace {
>  
>  constexpr int kColourTemperatureQuantization = 10;
>  
> -std::vector<double> parseSizes(const ValueNode &tuningData,
> -                              const char *prop)
> -{
> -       std::vector<double> sizes =
> -               tuningData[prop].get<std::vector<double>>().value_or(utils::defopt);
> -       if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) {
> -               LOG(RkISP1Lsc, Error)
> -                       << "Invalid '" << prop << "' values: expected "
> -                       << RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE
> -                       << " elements, got " << sizes.size();
> -               return {};
> -       }
> -
> -       /*
> -        * The sum of all elements must be 0.5 to satisfy hardware constraints.
> -        * Validate it here, allowing a 1% tolerance as rounding errors may
> -        * prevent an exact match (further adjustments will be performed in
> -        * LensShadingCorrection::prepare()).
> -        */
> -       double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
> -       if (sum < 0.495 || sum > 0.505) {
> -               LOG(RkISP1Lsc, Error)
> -                       << "Invalid '" << prop << "' values: sum of the elements"
> -                       << " should be 0.5, got " << sum;
> -               return {};
> -       }
> -
> -       return sizes;
> -}
> -
>  unsigned int quantize(unsigned int value, unsigned int step)
>  {
>         return std::lround(value / static_cast<double>(step)) * step;
> @@ -138,6 +108,36 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,
>         return 0;
>  }
>  
> +std::vector<double> LensShadingCorrection::parseSizes(const ValueNode &tuningData,
> +                                                     const char *prop)
> +{
> +       std::vector<double> sizes =
> +               tuningData[prop].get<std::vector<double>>().value_or(utils::defopt);
> +       if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) {
> +               LOG(RkISP1Lsc, Error)
> +                       << "Invalid '" << prop << "' values: expected "
> +                       << RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE
> +                       << " elements, got " << sizes.size();
> +               return {};
> +       }
> +
> +       /*
> +        * The sum of all elements must be 0.5 to satisfy hardware constraints.
> +        * Validate it here, allowing a 1% tolerance as rounding errors may
> +        * prevent an exact match (further adjustments will be performed in
> +        * LensShadingCorrection::prepare()).
> +        */
> +       double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
> +       if (sum < 0.495 || sum > 0.505) {
> +               LOG(RkISP1Lsc, Error)
> +                       << "Invalid '" << prop << "' values: sum of the elements"
> +                       << " should be 0.5, got " << sum;
> +               return {};
> +       }
> +
> +       return sizes;
> +}
> +
>  /**
>   * \copydoc libcamera::ipa::Algorithm::configure
>   */
> diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h
> index 2a428293cb2e..ee037353bbe4 100644
> --- a/src/ipa/rkisp1/algorithms/lsc.h
> +++ b/src/ipa/rkisp1/algorithms/lsc.h
> @@ -39,6 +39,8 @@ public:
>  private:
>         void setParameters(rkisp1_cif_isp_lsc_config &config);
>         void copyTable(rkisp1_cif_isp_lsc_config &config, const lsc::Components &set0);
> +       std::vector<double> parseSizes(const ValueNode &tuningData,
> +                                      const char *prop);
>  
>         std::vector<double> xSize_;
>         std::vector<double> ySize_;
> 
> -- 
> 2.54.0
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
index 974534175e06..0312ce2f8bb1 100644
--- a/src/ipa/rkisp1/algorithms/lsc.cpp
+++ b/src/ipa/rkisp1/algorithms/lsc.cpp
@@ -34,36 +34,6 @@  namespace {
 
 constexpr int kColourTemperatureQuantization = 10;
 
-std::vector<double> parseSizes(const ValueNode &tuningData,
-			       const char *prop)
-{
-	std::vector<double> sizes =
-		tuningData[prop].get<std::vector<double>>().value_or(utils::defopt);
-	if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) {
-		LOG(RkISP1Lsc, Error)
-			<< "Invalid '" << prop << "' values: expected "
-			<< RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE
-			<< " elements, got " << sizes.size();
-		return {};
-	}
-
-	/*
-	 * The sum of all elements must be 0.5 to satisfy hardware constraints.
-	 * Validate it here, allowing a 1% tolerance as rounding errors may
-	 * prevent an exact match (further adjustments will be performed in
-	 * LensShadingCorrection::prepare()).
-	 */
-	double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
-	if (sum < 0.495 || sum > 0.505) {
-		LOG(RkISP1Lsc, Error)
-			<< "Invalid '" << prop << "' values: sum of the elements"
-			<< " should be 0.5, got " << sum;
-		return {};
-	}
-
-	return sizes;
-}
-
 unsigned int quantize(unsigned int value, unsigned int step)
 {
 	return std::lround(value / static_cast<double>(step)) * step;
@@ -138,6 +108,36 @@  int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,
 	return 0;
 }
 
+std::vector<double> LensShadingCorrection::parseSizes(const ValueNode &tuningData,
+						      const char *prop)
+{
+	std::vector<double> sizes =
+		tuningData[prop].get<std::vector<double>>().value_or(utils::defopt);
+	if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) {
+		LOG(RkISP1Lsc, Error)
+			<< "Invalid '" << prop << "' values: expected "
+			<< RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE
+			<< " elements, got " << sizes.size();
+		return {};
+	}
+
+	/*
+	 * The sum of all elements must be 0.5 to satisfy hardware constraints.
+	 * Validate it here, allowing a 1% tolerance as rounding errors may
+	 * prevent an exact match (further adjustments will be performed in
+	 * LensShadingCorrection::prepare()).
+	 */
+	double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
+	if (sum < 0.495 || sum > 0.505) {
+		LOG(RkISP1Lsc, Error)
+			<< "Invalid '" << prop << "' values: sum of the elements"
+			<< " should be 0.5, got " << sum;
+		return {};
+	}
+
+	return sizes;
+}
+
 /**
  * \copydoc libcamera::ipa::Algorithm::configure
  */
diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h
index 2a428293cb2e..ee037353bbe4 100644
--- a/src/ipa/rkisp1/algorithms/lsc.h
+++ b/src/ipa/rkisp1/algorithms/lsc.h
@@ -39,6 +39,8 @@  public:
 private:
 	void setParameters(rkisp1_cif_isp_lsc_config &config);
 	void copyTable(rkisp1_cif_isp_lsc_config &config, const lsc::Components &set0);
+	std::vector<double> parseSizes(const ValueNode &tuningData,
+				       const char *prop);
 
 	std::vector<double> xSize_;
 	std::vector<double> ySize_;