[libcamera-devel] [PATCH v6 2/7] libcamera: Add ColorSpace fields to StreamConfiguration

David Plowman david.plowman at raspberrypi.com
Thu Nov 18 16:19:28 CET 2021


This is so that applications can choose appropriate color spaces which
will then be passed down to the V4L2 devices.

The ColorSpace field is actually optional. If it is not set you will
get the driver's default color space.

Signed-off-by: David Plowman <david.plowman at raspberrypi.com>
---
 include/libcamera/stream.h |  3 +++
 src/libcamera/stream.cpp   | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 0c55e716..bea88eb4 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -12,6 +12,7 @@
 #include <string>
 #include <vector>
 
+#include <libcamera/color_space.h>
 #include <libcamera/framebuffer.h>
 #include <libcamera/geometry.h>
 #include <libcamera/pixel_format.h>
@@ -47,6 +48,8 @@ struct StreamConfiguration {
 
 	unsigned int bufferCount;
 
+	std::optional<ColorSpace> colorSpace;
+
 	Stream *stream() const { return stream_; }
 	void setStream(Stream *stream) { stream_ = stream; }
 	const StreamFormats &formats() const { return formats_; }
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
index b421e17e..300b3af7 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -329,6 +329,20 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
  * \brief Requested number of buffers to allocate for the stream
  */
 
+/**
+ * \var StreamConfiguration::colorSpace
+ * \brief The ColorSpace for this stream
+ *
+ * A suitable color space may be set here or chosen by an application.
+ * Alternatively the color space may be left unset, in which case it will
+ * be up to the driver to choose a color space.
+ *
+ * If the system cannot deliver the requested color space, the validate()
+ * method will overwrite the value here with what it can deliver. Note that
+ * platforms may enforce extra contraints here, such as requiring all output
+ * streams to share the same color space.
+ */
+
 /**
  * \fn StreamConfiguration::stream()
  * \brief Retrieve the stream associated with the configuration
-- 
2.20.1



More information about the libcamera-devel mailing list