[v3,3/6] ipa: rkisp1: Use centralised libipa helpers
diff mbox series

Message ID 20241115074628.417215-4-dan.scally@ideasonboard.com
State Accepted
Headers show
Series
  • Centralise common functions in IPA modules
Related show

Commit Message

Dan Scally Nov. 15, 2024, 7:46 a.m. UTC
Use the centralised libipa helpers instead of open-coding common
functions.

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
Changes in v3:

	- None

Changes in v2:

	- Dropped the ipa:: prefix for function calls

 src/ipa/rkisp1/algorithms/awb.cpp | 18 ++----------------
 src/ipa/rkisp1/algorithms/awb.h   |  2 --
 2 files changed, 2 insertions(+), 18 deletions(-)

Comments

Kieran Bingham Nov. 15, 2024, 11:58 a.m. UTC | #1
Quoting Daniel Scally (2024-11-15 07:46:25)
> Use the centralised libipa helpers instead of open-coding common
> functions.
> 
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
> ---
> Changes in v3:
> 
>         - None
> 
> Changes in v2:
> 
>         - Dropped the ipa:: prefix for function calls
> 
>  src/ipa/rkisp1/algorithms/awb.cpp | 18 ++----------------
>  src/ipa/rkisp1/algorithms/awb.h   |  2 --
>  2 files changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index b3c00bef..5c1d9511 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -16,6 +16,8 @@
>  
>  #include <libcamera/ipa/core_ipa_interface.h>
>  
> +#include "libipa/colours.h"
> +


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

>  /**
>   * \file awb.h
>   */
> @@ -178,22 +180,6 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
>         }
>  }
>  
> -uint32_t Awb::estimateCCT(double red, double green, double blue)
> -{
> -       /* Convert the RGB values to CIE tristimulus values (XYZ) */
> -       double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);
> -       double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);
> -       double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);
> -
> -       /* Calculate the normalized chromaticity values */
> -       double x = X / (X + Y + Z);
> -       double y = Y / (X + Y + Z);
> -
> -       /* Calculate CCT */
> -       double n = (x - 0.3320) / (0.1858 - y);
> -       return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;
> -}
> -
>  /**
>   * \copydoc libcamera::ipa::Algorithm::process
>   */
> diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
> index b3b2c0bb..6ac3a5c3 100644
> --- a/src/ipa/rkisp1/algorithms/awb.h
> +++ b/src/ipa/rkisp1/algorithms/awb.h
> @@ -32,8 +32,6 @@ public:
>                      ControlList &metadata) override;
>  
>  private:
> -       uint32_t estimateCCT(double red, double green, double blue);
> -
>         bool rgbMode_;
>  };
>  
> -- 
> 2.30.2
>
Milan Zamazal Nov. 15, 2024, 1:58 p.m. UTC | #2
Daniel Scally <dan.scally@ideasonboard.com> writes:

> Use the centralised libipa helpers instead of open-coding common
> functions.
>
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

> ---
> Changes in v3:
>
> 	- None
>
> Changes in v2:
>
> 	- Dropped the ipa:: prefix for function calls
>
>  src/ipa/rkisp1/algorithms/awb.cpp | 18 ++----------------
>  src/ipa/rkisp1/algorithms/awb.h   |  2 --
>  2 files changed, 2 insertions(+), 18 deletions(-)
>
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index b3c00bef..5c1d9511 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -16,6 +16,8 @@
>  
>  #include <libcamera/ipa/core_ipa_interface.h>
>  
> +#include "libipa/colours.h"
> +
>  /**
>   * \file awb.h
>   */
> @@ -178,22 +180,6 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
>  	}
>  }
>  
> -uint32_t Awb::estimateCCT(double red, double green, double blue)
> -{
> -	/* Convert the RGB values to CIE tristimulus values (XYZ) */
> -	double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);
> -	double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);
> -	double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);
> -
> -	/* Calculate the normalized chromaticity values */
> -	double x = X / (X + Y + Z);
> -	double y = Y / (X + Y + Z);
> -
> -	/* Calculate CCT */
> -	double n = (x - 0.3320) / (0.1858 - y);
> -	return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;
> -}
> -
>  /**
>   * \copydoc libcamera::ipa::Algorithm::process
>   */
> diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
> index b3b2c0bb..6ac3a5c3 100644
> --- a/src/ipa/rkisp1/algorithms/awb.h
> +++ b/src/ipa/rkisp1/algorithms/awb.h
> @@ -32,8 +32,6 @@ public:
>  		     ControlList &metadata) override;
>  
>  private:
> -	uint32_t estimateCCT(double red, double green, double blue);
> -
>  	bool rgbMode_;
>  };
Laurent Pinchart Nov. 18, 2024, 12:49 a.m. UTC | #3
Hi Dan,

Thank you for the patch.

On Fri, Nov 15, 2024 at 07:46:25AM +0000, Daniel Scally wrote:
> Use the centralised libipa helpers instead of open-coding common
> functions.
> 
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> Changes in v3:
> 
> 	- None
> 
> Changes in v2:
> 
> 	- Dropped the ipa:: prefix for function calls
> 
>  src/ipa/rkisp1/algorithms/awb.cpp | 18 ++----------------
>  src/ipa/rkisp1/algorithms/awb.h   |  2 --
>  2 files changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
> index b3c00bef..5c1d9511 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -16,6 +16,8 @@
>  
>  #include <libcamera/ipa/core_ipa_interface.h>
>  
> +#include "libipa/colours.h"
> +
>  /**
>   * \file awb.h
>   */
> @@ -178,22 +180,6 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,
>  	}
>  }
>  
> -uint32_t Awb::estimateCCT(double red, double green, double blue)
> -{
> -	/* Convert the RGB values to CIE tristimulus values (XYZ) */
> -	double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);
> -	double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);
> -	double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);
> -
> -	/* Calculate the normalized chromaticity values */
> -	double x = X / (X + Y + Z);
> -	double y = Y / (X + Y + Z);
> -
> -	/* Calculate CCT */
> -	double n = (x - 0.3320) / (0.1858 - y);
> -	return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;
> -}
> -
>  /**
>   * \copydoc libcamera::ipa::Algorithm::process
>   */
> diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
> index b3b2c0bb..6ac3a5c3 100644
> --- a/src/ipa/rkisp1/algorithms/awb.h
> +++ b/src/ipa/rkisp1/algorithms/awb.h
> @@ -32,8 +32,6 @@ public:
>  		     ControlList &metadata) override;
>  
>  private:
> -	uint32_t estimateCCT(double red, double green, double blue);
> -
>  	bool rgbMode_;
>  };
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index b3c00bef..5c1d9511 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -16,6 +16,8 @@ 
 
 #include <libcamera/ipa/core_ipa_interface.h>
 
+#include "libipa/colours.h"
+
 /**
  * \file awb.h
  */
@@ -178,22 +180,6 @@  void Awb::prepare(IPAContext &context, const uint32_t frame,
 	}
 }
 
-uint32_t Awb::estimateCCT(double red, double green, double blue)
-{
-	/* Convert the RGB values to CIE tristimulus values (XYZ) */
-	double X = (-0.14282) * (red) + (1.54924) * (green) + (-0.95641) * (blue);
-	double Y = (-0.32466) * (red) + (1.57837) * (green) + (-0.73191) * (blue);
-	double Z = (-0.68202) * (red) + (0.77073) * (green) + (0.56332) * (blue);
-
-	/* Calculate the normalized chromaticity values */
-	double x = X / (X + Y + Z);
-	double y = Y / (X + Y + Z);
-
-	/* Calculate CCT */
-	double n = (x - 0.3320) / (0.1858 - y);
-	return 449 * n * n * n + 3525 * n * n + 6823.3 * n + 5520.33;
-}
-
 /**
  * \copydoc libcamera::ipa::Algorithm::process
  */
diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
index b3b2c0bb..6ac3a5c3 100644
--- a/src/ipa/rkisp1/algorithms/awb.h
+++ b/src/ipa/rkisp1/algorithms/awb.h
@@ -32,8 +32,6 @@  public:
 		     ControlList &metadata) override;
 
 private:
-	uint32_t estimateCCT(double red, double green, double blue);
-
 	bool rgbMode_;
 };