[4/5] software_isp: debayer_cpu: Select process inner loop by function pointer
diff mbox series

Message ID 20260216190204.106922-5-johannes.goede@oss.qualcomm.com
State Superseded
Headers show
Series
  • software_isp: debayer_cpu: Add multi-threading support
Related show

Commit Message

Hans de Goede Feb. 16, 2026, 7:02 p.m. UTC
At a processInner_ function pointer and set this to process2() /
process4() in configure instead of making the choise inline in process().

This is a preparation patch for making DebayerCpu support multi-threading.

Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
 src/libcamera/software_isp/debayer_cpu.cpp | 10 ++++++----
 src/libcamera/software_isp/debayer_cpu.h   |  4 ++++
 2 files changed, 10 insertions(+), 4 deletions(-)

Comments

Milan Zamazal Feb. 17, 2026, 9:48 p.m. UTC | #1
Hi Hans,

thank you for the patch.

Hans de Goede <johannes.goede@oss.qualcomm.com> writes:

> At a processInner_ function pointer and set this to process2() /

s/At/Add/

> process4() in configure instead of making the choise inline in process().

s/choise/choice/

> This is a preparation patch for making DebayerCpu support multi-threading.

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

> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
> ---
>  src/libcamera/software_isp/debayer_cpu.cpp | 10 ++++++----
>  src/libcamera/software_isp/debayer_cpu.h   |  4 ++++
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
> index e1d3c164..5e168554 100644
> --- a/src/libcamera/software_isp/debayer_cpu.cpp
> +++ b/src/libcamera/software_isp/debayer_cpu.cpp
> @@ -437,6 +437,11 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat,
>  		return invalidFmt();
>  	}
>  
> +	if (inputConfig_.patternSize.height == 2)
> +		processInner_ = &DebayerCpu::process2;
> +	else
> +		processInner_ = &DebayerCpu::process4;
> +
>  	if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) &&
>  	    bayerFormat.packing == BayerFormat::Packing::None &&
>  	    isStandardBayerOrder(bayerFormat.order)) {
> @@ -890,10 +895,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
>  
>  	threadData_[0].yStart = 0;
>  	threadData_[0].yEnd = window_.height;
> -	if (inputConfig_.patternSize.height == 2)
> -		process2(frame, in.planes()[0].data(), out.planes()[0].data(), &threadData_[0]);
> -	else
> -		process4(frame, in.planes()[0].data(), out.planes()[0].data(), &threadData_[0]);
> +	(this->*processInner_)(frame, in.planes()[0].data(), out.planes()[0].data(), &threadData_[0]);
>  
>  	metadata.planes()[0].bytesused = out.planes()[0].size();
>  
> diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h
> index a54418dc..b85dd11c 100644
> --- a/src/libcamera/software_isp/debayer_cpu.h
> +++ b/src/libcamera/software_isp/debayer_cpu.h
> @@ -87,6 +87,9 @@ private:
>  		bool processLastLinesSeperately;
>  	};
>  
> +	using processFn = void (DebayerCpu::*)(uint32_t frame, const uint8_t *src, uint8_t *dst,
> +					       DebayerCpuThreadData *threadData);
> +
>  	/* 8-bit raw bayer format */
>  	template<bool addAlphaByte, bool ccmEnabled>
>  	void debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]);
> @@ -164,6 +167,7 @@ private:
>  	unsigned int threadCount_;
>  	bool ccmEnabled_;
>  	DebayerParams params_;
> +	processFn processInner_;
>  };
>  
>  } /* namespace libcamera */

Patch
diff mbox series

diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index e1d3c164..5e168554 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -437,6 +437,11 @@  int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat,
 		return invalidFmt();
 	}
 
+	if (inputConfig_.patternSize.height == 2)
+		processInner_ = &DebayerCpu::process2;
+	else
+		processInner_ = &DebayerCpu::process4;
+
 	if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10 || bayerFormat.bitDepth == 12) &&
 	    bayerFormat.packing == BayerFormat::Packing::None &&
 	    isStandardBayerOrder(bayerFormat.order)) {
@@ -890,10 +895,7 @@  void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output
 
 	threadData_[0].yStart = 0;
 	threadData_[0].yEnd = window_.height;
-	if (inputConfig_.patternSize.height == 2)
-		process2(frame, in.planes()[0].data(), out.planes()[0].data(), &threadData_[0]);
-	else
-		process4(frame, in.planes()[0].data(), out.planes()[0].data(), &threadData_[0]);
+	(this->*processInner_)(frame, in.planes()[0].data(), out.planes()[0].data(), &threadData_[0]);
 
 	metadata.planes()[0].bytesused = out.planes()[0].size();
 
diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h
index a54418dc..b85dd11c 100644
--- a/src/libcamera/software_isp/debayer_cpu.h
+++ b/src/libcamera/software_isp/debayer_cpu.h
@@ -87,6 +87,9 @@  private:
 		bool processLastLinesSeperately;
 	};
 
+	using processFn = void (DebayerCpu::*)(uint32_t frame, const uint8_t *src, uint8_t *dst,
+					       DebayerCpuThreadData *threadData);
+
 	/* 8-bit raw bayer format */
 	template<bool addAlphaByte, bool ccmEnabled>
 	void debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[]);
@@ -164,6 +167,7 @@  private:
 	unsigned int threadCount_;
 	bool ccmEnabled_;
 	DebayerParams params_;
+	processFn processInner_;
 };
 
 } /* namespace libcamera */