[libcamera-devel,v7,2/7] libcamera: Add ColorSpace fields to StreamConfiguration
diff mbox series

Message ID 20211126104045.4756-3-david.plowman@raspberrypi.com
State Superseded
Headers show
Series
  • Colour spaces
Related show

Commit Message

David Plowman Nov. 26, 2021, 10:40 a.m. UTC
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@raspberrypi.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
---
 include/libcamera/stream.h |  3 +++
 src/libcamera/stream.cpp   | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

Comments

Jacopo Mondi Nov. 30, 2021, 7:59 p.m. UTC | #1
Hi David,

On Fri, Nov 26, 2021 at 10:40:40AM +0000, David Plowman wrote:
> 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@raspberrypi.com>
> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>  include/libcamera/stream.h |  3 +++
>  src/libcamera/stream.cpp   | 19 +++++++++++++++++++
>  2 files changed, 22 insertions(+)
>
> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> index 41ec02b1..f0ae7e62 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..b281c309 100644
> --- a/src/libcamera/stream.cpp
> +++ b/src/libcamera/stream.cpp
> @@ -329,6 +329,25 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
>   * \brief Requested number of buffers to allocate for the stream
>   */
>
> +/**
> + * \var StreamConfiguration::colorSpace
> + * \brief The ColorSpace for this stream
> + *
> + * This field allows a ColorSpace to be selected for this Stream.
> + *
> + * The field is optional and an application can choose to leave it unset.
> + * On some platforms, generateConfiguration() may provide default values

"On some platform" might not be that helpful for application
developers. True, I've pushed for having ColorSpace optional, so you
can rightfully tell me to go look somewhere else :)

Let's say that if a platform supports colorspaces (which I hope will
soon mean all platforms) then it is expected the field to be set after
a generateConfiguration().

> + * here which the application can of course override.

s/of course//

> + *
> + * If a specific ColorSpace is requested but the Camera cannot deliver it,
> + * then the StreamConfiguration will be adjusted to a value that can be
> + * delivered. In this case the validate() method will indicate via its
> + * return value that the CameraConfiguration has been adjusted.
> + *
> + * Note that platforms will typically have different constraints on what
> + * color spaces can be supported and in what combinations.
> + */
> +

With the above comments optionally considered
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>  /**
>   * \fn StreamConfiguration::stream()
>   * \brief Retrieve the stream associated with the configuration
> --
> 2.30.2
>

Patch
diff mbox series

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 41ec02b1..f0ae7e62 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..b281c309 100644
--- a/src/libcamera/stream.cpp
+++ b/src/libcamera/stream.cpp
@@ -329,6 +329,25 @@  StreamConfiguration::StreamConfiguration(const StreamFormats &formats)
  * \brief Requested number of buffers to allocate for the stream
  */
 
+/**
+ * \var StreamConfiguration::colorSpace
+ * \brief The ColorSpace for this stream
+ *
+ * This field allows a ColorSpace to be selected for this Stream.
+ *
+ * The field is optional and an application can choose to leave it unset.
+ * On some platforms, generateConfiguration() may provide default values
+ * here which the application can of course override.
+ *
+ * If a specific ColorSpace is requested but the Camera cannot deliver it,
+ * then the StreamConfiguration will be adjusted to a value that can be
+ * delivered. In this case the validate() method will indicate via its
+ * return value that the CameraConfiguration has been adjusted.
+ *
+ * Note that platforms will typically have different constraints on what
+ * color spaces can be supported and in what combinations.
+ */
+
 /**
  * \fn StreamConfiguration::stream()
  * \brief Retrieve the stream associated with the configuration