[v3,13/35] ipa: libipa: lsc_polynomial: Do not inline functions
diff mbox series

Message ID 20260706-libipa-algorithms-v3-13-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 is no reason to inline the Polynomial class implementation.

Move functions implementation to the corresponding .cpp file.

While at it remove a rougue empty line between class members
definitions.

Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
---
 src/ipa/libipa/lsc_polynomial.cpp | 34 +++++++++++++++++++++++++++++++---
 src/ipa/libipa/lsc_polynomial.h   | 36 +++---------------------------------
 2 files changed, 34 insertions(+), 36 deletions(-)

Comments

Kieran Bingham July 6, 2026, 6:26 p.m. UTC | #1
Quoting Jacopo Mondi (2026-07-06 09:01:33)
> There is no reason to inline the Polynomial class implementation.
> 
> Move functions implementation to the corresponding .cpp file.
> 
> While at it remove a rougue empty line between class members
> definitions.
> 
> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>


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

> ---
>  src/ipa/libipa/lsc_polynomial.cpp | 34 +++++++++++++++++++++++++++++++---
>  src/ipa/libipa/lsc_polynomial.h   | 36 +++---------------------------------
>  2 files changed, 34 insertions(+), 36 deletions(-)
> 
> diff --git a/src/ipa/libipa/lsc_polynomial.cpp b/src/ipa/libipa/lsc_polynomial.cpp
> index d8981bd8a26a..a845d8b1783b 100644
> --- a/src/ipa/libipa/lsc_polynomial.cpp
> +++ b/src/ipa/libipa/lsc_polynomial.cpp
> @@ -47,7 +47,6 @@ namespace lsc {
>   */
>  
>  /**
> - * \fn Polynomial::sampleAtNormalizedPixelPos(double x, double y)
>   * \brief Sample the polynomial at the given normalized pixel position
>   *
>   * This functions samples the polynomial at the given pixel position divided by
> @@ -57,9 +56,20 @@ namespace lsc {
>   * \param y y position in normalized coordinates
>   * \return The sampled value
>   */
> +double Polynomial::sampleAtNormalizedPixelPos(double x, double y) const
> +{
> +       double dx = x - cnx_;
> +       double dy = y - cny_;
> +       double r = sqrt(dx * dx + dy * dy);
> +       double res = 1.0;
> +
> +       for (unsigned int i = 0; i < coefficients_.size(); i++)
> +               res += coefficients_[i] * std::pow(r, (i + 1) * 2);
> +
> +       return res;
> +}
>  
>  /**
> - * \fn Polynomial::getM()
>   * \brief Get the value m as described in the dng specification
>   *
>   * Returns m according to dng spec. m represents the Euclidean distance
> @@ -68,9 +78,17 @@ namespace lsc {
>   *
>   * \return The sampled value
>   */
> +double Polynomial::getM() const
> +{
> +       double cpx = imageSize_.width * cx_;
> +       double cpy = imageSize_.height * cy_;
> +       double mx = std::max(cpx, std::fabs(imageSize_.width - cpx));
> +       double my = std::max(cpy, std::fabs(imageSize_.height - cpy));
> +
> +       return sqrt(mx * mx + my * my);
> +}
>  
>  /**
> - * \fn Polynomial::setReferenceImageSize(const Size &size)
>   * \brief Set the reference image size
>   *
>   * Set the reference image size that is used for subsequent calls to getM() and
> @@ -78,6 +96,16 @@ namespace lsc {
>   *
>   * \param size The size of the reference image
>   */
> +void Polynomial::setReferenceImageSize(const Size &size)
> +{
> +       assert(!size.isNull());
> +       imageSize_ = size;
> +
> +       /* Calculate normalized centers */
> +       double m = getM();
> +       cnx_ = (size.width * cx_) / m;
> +       cny_ = (size.height * cy_) / m;
> +}
>  
>  } /* namespace lsc */
>  
> diff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h
> index 3be33edfe7d8..2caf46d2d759 100644
> --- a/src/ipa/libipa/lsc_polynomial.h
> +++ b/src/ipa/libipa/lsc_polynomial.h
> @@ -37,38 +37,9 @@ public:
>         {
>         }
>  
> -       double sampleAtNormalizedPixelPos(double x, double y) const
> -       {
> -               double dx = x - cnx_;
> -               double dy = y - cny_;
> -               double r = sqrt(dx * dx + dy * dy);
> -               double res = 1.0;
> -               for (unsigned int i = 0; i < coefficients_.size(); i++) {
> -                       res += coefficients_[i] * std::pow(r, (i + 1) * 2);
> -               }
> -               return res;
> -       }
> -
> -       double getM() const
> -       {
> -               double cpx = imageSize_.width * cx_;
> -               double cpy = imageSize_.height * cy_;
> -               double mx = std::max(cpx, std::fabs(imageSize_.width - cpx));
> -               double my = std::max(cpy, std::fabs(imageSize_.height - cpy));
> -
> -               return sqrt(mx * mx + my * my);
> -       }
> -
> -       void setReferenceImageSize(const Size &size)
> -       {
> -               assert(!size.isNull());
> -               imageSize_ = size;
> -
> -               /* Calculate normalized centers */
> -               double m = getM();
> -               cnx_ = (size.width * cx_) / m;
> -               cny_ = (size.height * cy_) / m;
> -       }
> +       double sampleAtNormalizedPixelPos(double x, double y) const;
> +       double getM() const;
> +       void setReferenceImageSize(const Size &size);
>  
>  private:
>         double cx_;
> @@ -76,7 +47,6 @@ private:
>         double cnx_;
>         double cny_;
>         std::array<double, 5> coefficients_;
> -
>         Size imageSize_;
>  };
>  
> 
> -- 
> 2.54.0
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/lsc_polynomial.cpp b/src/ipa/libipa/lsc_polynomial.cpp
index d8981bd8a26a..a845d8b1783b 100644
--- a/src/ipa/libipa/lsc_polynomial.cpp
+++ b/src/ipa/libipa/lsc_polynomial.cpp
@@ -47,7 +47,6 @@  namespace lsc {
  */
 
 /**
- * \fn Polynomial::sampleAtNormalizedPixelPos(double x, double y)
  * \brief Sample the polynomial at the given normalized pixel position
  *
  * This functions samples the polynomial at the given pixel position divided by
@@ -57,9 +56,20 @@  namespace lsc {
  * \param y y position in normalized coordinates
  * \return The sampled value
  */
+double Polynomial::sampleAtNormalizedPixelPos(double x, double y) const
+{
+	double dx = x - cnx_;
+	double dy = y - cny_;
+	double r = sqrt(dx * dx + dy * dy);
+	double res = 1.0;
+
+	for (unsigned int i = 0; i < coefficients_.size(); i++)
+		res += coefficients_[i] * std::pow(r, (i + 1) * 2);
+
+	return res;
+}
 
 /**
- * \fn Polynomial::getM()
  * \brief Get the value m as described in the dng specification
  *
  * Returns m according to dng spec. m represents the Euclidean distance
@@ -68,9 +78,17 @@  namespace lsc {
  *
  * \return The sampled value
  */
+double Polynomial::getM() const
+{
+	double cpx = imageSize_.width * cx_;
+	double cpy = imageSize_.height * cy_;
+	double mx = std::max(cpx, std::fabs(imageSize_.width - cpx));
+	double my = std::max(cpy, std::fabs(imageSize_.height - cpy));
+
+	return sqrt(mx * mx + my * my);
+}
 
 /**
- * \fn Polynomial::setReferenceImageSize(const Size &size)
  * \brief Set the reference image size
  *
  * Set the reference image size that is used for subsequent calls to getM() and
@@ -78,6 +96,16 @@  namespace lsc {
  *
  * \param size The size of the reference image
  */
+void Polynomial::setReferenceImageSize(const Size &size)
+{
+	assert(!size.isNull());
+	imageSize_ = size;
+
+	/* Calculate normalized centers */
+	double m = getM();
+	cnx_ = (size.width * cx_) / m;
+	cny_ = (size.height * cy_) / m;
+}
 
 } /* namespace lsc */
 
diff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h
index 3be33edfe7d8..2caf46d2d759 100644
--- a/src/ipa/libipa/lsc_polynomial.h
+++ b/src/ipa/libipa/lsc_polynomial.h
@@ -37,38 +37,9 @@  public:
 	{
 	}
 
-	double sampleAtNormalizedPixelPos(double x, double y) const
-	{
-		double dx = x - cnx_;
-		double dy = y - cny_;
-		double r = sqrt(dx * dx + dy * dy);
-		double res = 1.0;
-		for (unsigned int i = 0; i < coefficients_.size(); i++) {
-			res += coefficients_[i] * std::pow(r, (i + 1) * 2);
-		}
-		return res;
-	}
-
-	double getM() const
-	{
-		double cpx = imageSize_.width * cx_;
-		double cpy = imageSize_.height * cy_;
-		double mx = std::max(cpx, std::fabs(imageSize_.width - cpx));
-		double my = std::max(cpy, std::fabs(imageSize_.height - cpy));
-
-		return sqrt(mx * mx + my * my);
-	}
-
-	void setReferenceImageSize(const Size &size)
-	{
-		assert(!size.isNull());
-		imageSize_ = size;
-
-		/* Calculate normalized centers */
-		double m = getM();
-		cnx_ = (size.width * cx_) / m;
-		cny_ = (size.height * cy_) / m;
-	}
+	double sampleAtNormalizedPixelPos(double x, double y) const;
+	double getM() const;
+	void setReferenceImageSize(const Size &size);
 
 private:
 	double cx_;
@@ -76,7 +47,6 @@  private:
 	double cnx_;
 	double cny_;
 	std::array<double, 5> coefficients_;
-
 	Size imageSize_;
 };