[RFC 1/2] libcamera: debayer: Move sizes() to DebayerCpu implementation
Hans de Goede
hdegoede at redhat.com
Tue Jan 30 19:13:10 CET 2024
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 at 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(-)
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 */
--
2.43.0
More information about the libcamera-devel
mailing list