[v2,09/37] libcamera: software_isp: Move param select code to Debayer base class
diff mbox series

Message ID 20250824-b4-v0-5-2-gpuisp-v2-a-v2-9-96f4576c814e@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Aug. 24, 2025, 12:48 a.m. UTC
Move the parameter selection code into the Debayer base class in-order to
facilitate reuse of the lookup tables in the eGL shaders.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 src/libcamera/software_isp/debayer.cpp     | 27 +++++++++++++++++++++++++++
 src/libcamera/software_isp/debayer.h       |  3 +++
 src/libcamera/software_isp/debayer_cpu.cpp | 19 +------------------
 3 files changed, 31 insertions(+), 18 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index 29fdcbbfd4eba4a23c520b22784bf003f22a93f4..fc2438c0d0161a36da2769d95836f282836b143d 100644
--- a/src/libcamera/software_isp/debayer.cpp
+++ b/src/libcamera/software_isp/debayer.cpp
@@ -187,4 +187,31 @@  Debayer::~Debayer()
  * \brief Signals when the output buffer is ready
  */
 
+/**
+ * \fn void Debayer::setParams(DebayerParams &params)
+ * \brief Select the bayer params to use for the next frame debayer
+ * \param[in] params The parameters to be used in debayering
+ */
+void Debayer::setParams(DebayerParams &params)
+{
+	green_ = params.green;
+	greenCcm_ = params.greenCcm;
+	if (swapRedBlueGains_) {
+		red_ = params.blue;
+		blue_ = params.red;
+		redCcm_ = params.blueCcm;
+		blueCcm_ = params.redCcm;
+		for (unsigned int i = 0; i < 256; i++) {
+			std::swap(redCcm_[i].r, redCcm_[i].b);
+			std::swap(blueCcm_[i].r, blueCcm_[i].b);
+		}
+	} else {
+		red_ = params.red;
+		blue_ = params.blue;
+		redCcm_ = params.redCcm;
+		blueCcm_ = params.blueCcm;
+	}
+	gammaLut_ = params.gammaLut;
+}
+
 } /* namespace libcamera */
diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h
index 01b6e916f2a7199c592abd8a57ef549eaf388a8b..5f692bcbdeec1447c596ebbdc984585948a34880 100644
--- a/src/libcamera/software_isp/debayer.h
+++ b/src/libcamera/software_isp/debayer.h
@@ -82,6 +82,9 @@  public:
 
 private:
 	virtual Size patternSize(PixelFormat inputFormat) = 0;
+
+protected:
+	void setParams(DebayerParams &params);
 };
 
 } /* namespace libcamera */
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index 408ce2baa5e8a23902cbf0ca2b9ea87e73b4e882..6ed17e9fc144bc7c3472d999b1e9c23236020963 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -746,24 +746,7 @@  void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
 	for (const FrameBuffer::Plane &plane : output->planes())
 		dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);
 
-	green_ = params.green;
-	greenCcm_ = params.greenCcm;
-	if (swapRedBlueGains_) {
-		red_ = params.blue;
-		blue_ = params.red;
-		redCcm_ = params.blueCcm;
-		blueCcm_ = params.redCcm;
-		for (unsigned int i = 0; i < 256; i++) {
-			std::swap(redCcm_[i].r, redCcm_[i].b);
-			std::swap(blueCcm_[i].r, blueCcm_[i].b);
-		}
-	} else {
-		red_ = params.red;
-		blue_ = params.blue;
-		redCcm_ = params.redCcm;
-		blueCcm_ = params.blueCcm;
-	}
-	gammaLut_ = params.gammaLut;
+	setParams(params);
 
 	/* Copy metadata from the input buffer */
 	FrameMetadata &metadata = output->_d()->metadata();