[libcamera-devel] [PATCH v1 2/7] ipa: libipa: Create a common ISP header to store the structure types

Jean-Michel Hautbois jeanmichel.hautbois at ideasonboard.com
Mon Jun 28 22:22:50 CEST 2021


Each ISP may use the same AWB or AGC algorithms. In order to avoid
duplicated code, create a header with the main structures used for now.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois at ideasonboard.com>
---
 src/ipa/ipu3/ipu3_agc.h |   1 +
 src/ipa/ipu3/ipu3_awb.h |  30 +----------
 src/ipa/libipa/isp.h    | 110 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+), 29 deletions(-)
 create mode 100644 src/ipa/libipa/isp.h

diff --git a/src/ipa/ipu3/ipu3_agc.h b/src/ipa/ipu3/ipu3_agc.h
index 3deca3ae..6ca9af8e 100644
--- a/src/ipa/ipu3/ipu3_agc.h
+++ b/src/ipa/ipu3/ipu3_agc.h
@@ -17,6 +17,7 @@
 #include <libcamera/geometry.h>
 
 #include "libipa/algorithm.h"
+#include "libipa/isp.h"
 
 namespace libcamera {
 
diff --git a/src/ipa/ipu3/ipu3_awb.h b/src/ipa/ipu3/ipu3_awb.h
index 122cf68c..6ae111fd 100644
--- a/src/ipa/ipu3/ipu3_awb.h
+++ b/src/ipa/ipu3/ipu3_awb.h
@@ -14,6 +14,7 @@
 #include <libcamera/geometry.h>
 
 #include "libipa/algorithm.h"
+#include "libipa/isp.h"
 
 namespace libcamera {
 
@@ -42,35 +43,6 @@ public:
 		unsigned char padding[3];
 	} __attribute__((packed));
 
-	/* \todo Make these three structs available to all the ISPs ? */
-	struct RGB {
-		RGB(double _R = 0, double _G = 0, double _B = 0)
-			: R(_R), G(_G), B(_B)
-		{
-		}
-		double R, G, B;
-		RGB &operator+=(RGB const &other)
-		{
-			R += other.R, G += other.G, B += other.B;
-			return *this;
-		}
-	};
-
-	struct IspStatsRegion {
-		unsigned int counted;
-		unsigned int uncounted;
-		unsigned long long rSum;
-		unsigned long long gSum;
-		unsigned long long bSum;
-	};
-
-	struct AwbStatus {
-		double temperatureK;
-		double redGain;
-		double greenGain;
-		double blueGain;
-	};
-
 private:
 	void generateZones(std::vector<RGB> &zones);
 	void generateAwbStats(const ipu3_uapi_stats_3a *stats);
diff --git a/src/ipa/libipa/isp.h b/src/ipa/libipa/isp.h
new file mode 100644
index 00000000..a15803d6
--- /dev/null
+++ b/src/ipa/libipa/isp.h
@@ -0,0 +1,110 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Ideas On Board
+ *
+ * isp.h - ISP statistics interface
+ */
+#ifndef __LIBCAMERA_IPA_LIBIPA_ISP_H__
+#define __LIBCAMERA_IPA_LIBIPA_ISP_H__
+
+namespace libcamera {
+
+namespace ipa {
+/**
+ * \struct RGB
+ * \brief RGB
+ *
+ * \fn RGB::RGB
+ * \brief Construct a RGB structure
+ * \param[in] _R Red value to set, defaults to 0
+ * \param[in] _G Green value to set, defaults to 0
+ * \param[in] _B Blue value to set, defaults to 0
+ *
+ * \var RGB::R
+ * \brief Red value of the RGB structure
+ *
+ * \var RGB::G
+ * \brief Green value of the RGB structure
+ *
+ * \var RGB::B
+ * \brief Blue value of the RGB structure
+ *
+ * \fn RGB &RGB::operator+=(RGB const &other)
+ * \brief Add each RGB value to another RGB structure
+ * \param[in] other An RGB structure
+ * \return An RGB structure containing the added R, G and B values
+ */
+struct RGB {
+	RGB(double _R = 0, double _G = 0, double _B = 0)
+		: R(_R), G(_G), B(_B)
+	{
+	}
+	double R, G, B;
+	RGB &operator+=(RGB const &other)
+	{
+		R += other.R, G += other.G, B += other.B;
+		return *this;
+	}
+};
+
+/**
+ * \struct IspStatsRegion
+ * \brief RGB statistics for a given region
+ *
+ * The IspStatsRegion structure is intended to abstract the ISP specific
+ * statistics and use an agnostic algorithm to compute AWB.
+ *
+ * \var IspStatsRegion::counted
+ * \brief Number of pixels used to calculate the sums
+ *
+ * \var IspStatsRegion::uncounted
+ * \brief Remaining number of pixels in the region
+ *
+ * \var IspStatsRegion::rSum
+ * \brief Sum of the red values in the region
+ *
+ * \var IspStatsRegion::gSum
+ * \brief Sum of the green values in the region
+ *
+ * \var IspStatsRegion::bSum
+ * \brief Sum of the blue values in the region
+ */
+struct IspStatsRegion {
+	unsigned int counted;
+	unsigned int uncounted;
+	unsigned long long rSum;
+	unsigned long long gSum;
+	unsigned long long bSum;
+};
+
+/**
+ * \struct AwbStatus
+ * \brief AWB parameters calculated
+ *
+ * The AwbStatus structure is intended to store the AWB
+ * parameters calculated by the algorithm
+ *
+ * \var AwbStatus::temperatureK
+ * \brief Color temperature calculated
+ *
+ * \var AwbStatus::redGain
+ * \brief Gain calculated for the red channel
+ *
+ * \var AwbStatus::greenGain
+ * \brief Gain calculated for the green channel
+ *
+ * \var AwbStatus::blueGain
+ * \brief Gain calculated for the blue channel
+ */
+struct AwbStatus {
+	double temperatureK;
+	double redGain;
+	double greenGain;
+	double blueGain;
+};
+
+} /* namespace ipa */
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_IPA_LIBIPA_ISP_H__ */
-- 
2.30.2



More information about the libcamera-devel mailing list