[v3,11/39] libcamera: software_isp: Move param select code to Debayer base class
diff mbox series

Message ID 20251015012251.17508-12-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Oct. 15, 2025, 1:22 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(-)

Comments

Kieran Bingham Oct. 15, 2025, 9:54 p.m. UTC | #1
Quoting Bryan O'Donoghue (2025-10-15 02:22:23)
> Move the parameter selection code into the Debayer base class in-order to
> facilitate reuse of the lookup tables in the eGL shaders.

All just a move so:

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

> 
> 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(-)
> 
> diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
> index 937d5e2e..cf74b92b 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 2cbf0823..c04c289d 100644
> --- a/src/libcamera/software_isp/debayer.h
> +++ b/src/libcamera/software_isp/debayer.h
> @@ -93,6 +93,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 42a0f374..6be5cdbd 100644
> --- a/src/libcamera/software_isp/debayer_cpu.cpp
> +++ b/src/libcamera/software_isp/debayer_cpu.cpp
> @@ -758,24 +758,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();
> -- 
> 2.51.0
>
Milan Zamazal Oct. 16, 2025, 8:30 a.m. UTC | #2
Bryan O'Donoghue <bryan.odonoghue@linaro.org> writes:

> 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>

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

> ---
>  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(-)
>
> diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
> index 937d5e2e..cf74b92b 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 2cbf0823..c04c289d 100644
> --- a/src/libcamera/software_isp/debayer.h
> +++ b/src/libcamera/software_isp/debayer.h
> @@ -93,6 +93,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 42a0f374..6be5cdbd 100644
> --- a/src/libcamera/software_isp/debayer_cpu.cpp
> +++ b/src/libcamera/software_isp/debayer_cpu.cpp
> @@ -758,24 +758,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();

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp
index 937d5e2e..cf74b92b 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 2cbf0823..c04c289d 100644
--- a/src/libcamera/software_isp/debayer.h
+++ b/src/libcamera/software_isp/debayer.h
@@ -93,6 +93,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 42a0f374..6be5cdbd 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -758,24 +758,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();