[RFC,1/2] libcamera: debayer: Move sizes() to DebayerCpu implementation
diff mbox series

Message ID 20240130181311.43745-2-hdegoede@redhat.com
State New
Headers show
Series
  • libcamera: debayer_cpu: Stop requiring 2 lines of padding at the top/bottom
Related show

Commit Message

Hans de Goede Jan. 30, 2024, 6:13 p.m. UTC
The amount of padding needed for interpolation at the borders depends
on the implementation.

Stop assuming that all implementations need a pattern-width x pattern-height
border around the output size for padding and move the sizes()
method out of the base-class.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../libcamera/internal/software_isp/debayer.h | 26 +------------------
 .../internal/software_isp/debayer_cpu.h       |  1 +
 src/libcamera/software_isp/debayer_cpu.cpp    | 26 +++++++++++++++++++
 3 files changed, 28 insertions(+), 25 deletions(-)

Patch
diff mbox series

diff --git a/include/libcamera/internal/software_isp/debayer.h b/include/libcamera/internal/software_isp/debayer.h
index 9109bf32..ab1ce994 100644
--- a/include/libcamera/internal/software_isp/debayer.h
+++ b/include/libcamera/internal/software_isp/debayer.h
@@ -94,31 +94,7 @@  public:
 	 *
 	 * \return The valid size ranges or an empty range if there are none.
 	 */
-	SizeRange sizes(PixelFormat inputFormat, const Size &inputSize)
-	{
-		Size pattern_size = patternSize(inputFormat);
-
-		if (pattern_size.isNull())
-			return {};
-
-		/*
-		 * For debayer interpolation a border of pattern-height x pattern-width
-		 * is kept around the entire image. Combined with a minimum-size of
-		 * pattern-height x pattern-width this means the input-size needs to be
-		 * at least (3 * pattern-height) x (3 * pattern-width).
-		 */
-		if (inputSize.width < (3 * pattern_size.width) ||
-		    inputSize.height < (3 * pattern_size.height)) {
-			LOG(Debayer, Warning)
-				<< "Input format size too small: " << inputSize.toString();
-			return {};
-		}
-
-		return SizeRange(Size(pattern_size.width, pattern_size.height),
-				 Size((inputSize.width - 2 * pattern_size.width) & ~(pattern_size.width - 1),
-				      (inputSize.height - 2 * pattern_size.height) & ~(pattern_size.height - 1)),
-				 pattern_size.width, pattern_size.height);
-	}
+	virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;
 
 	/**
 	 * \brief Signals when the input buffer is ready.
diff --git a/include/libcamera/internal/software_isp/debayer_cpu.h b/include/libcamera/internal/software_isp/debayer_cpu.h
index 52af117f..bcb634d5 100644
--- a/include/libcamera/internal/software_isp/debayer_cpu.h
+++ b/include/libcamera/internal/software_isp/debayer_cpu.h
@@ -62,6 +62,7 @@  public:
 		strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);
 
 	void process(FrameBuffer *input, FrameBuffer *output, DebayerParams params);
+	SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);
 
 	/**
 	 * \brief Get the file descriptor for the statistics.
diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp
index b6393925..14fc383e 100644
--- a/src/libcamera/software_isp/debayer_cpu.cpp
+++ b/src/libcamera/software_isp/debayer_cpu.cpp
@@ -945,4 +945,30 @@  void DebayerCpu::process(FrameBuffer *input, FrameBuffer *output, DebayerParams
 	inputBufferReady.emit(input);
 }
 
+SizeRange DebayerCpu::sizes(PixelFormat inputFormat, const Size &inputSize)
+{
+	Size pattern_size = patternSize(inputFormat);
+
+	if (pattern_size.isNull())
+		return {};
+
+	/*
+	 * For debayer interpolation a border of pattern-height x pattern-width
+	 * is kept around the entire image. Combined with a minimum-size of
+	 * pattern-height x pattern-width this means the input-size needs to be
+	 * at least (3 * pattern-height) x (3 * pattern-width).
+	 */
+	if (inputSize.width < (3 * pattern_size.width) ||
+	    inputSize.height < (3 * pattern_size.height)) {
+		LOG(Debayer, Warning)
+			<< "Input format size too small: " << inputSize.toString();
+		return {};
+	}
+
+	return SizeRange(Size(pattern_size.width, pattern_size.height),
+			 Size((inputSize.width - 2 * pattern_size.width) & ~(pattern_size.width - 1),
+			      (inputSize.height - 2 * pattern_size.height) & ~(pattern_size.height - 1)),
+			 pattern_size.width, pattern_size.height);
+}
+
 } /* namespace libcamera */