[libcamera-devel] [RFC PATCH 1/4] libcamera: colorspace: Rectify ColorSpace::Srgb preset

Umang Jain umang.jain at ideasonboard.com
Tue Aug 2 20:57:16 CEST 2022


Rectify the ColorSpace::Srgb to denote that it does not use
any Y'Cbcr encoding and uses full range.

The kernel on the other hand, recommends to use Rec601 as the encoding
for V4L2_COLORSPACE_SRGB. It is not very explicit but it can be
inferred that the kernel assumes V4L2_COLORSPACE_SRGB is a YUV-encoded
one. However, when the data is in RGB, no encoding is required (and
this is denoted by YcbcrEncoding::None in libcamera).

Hence, to be clear on the libcamera colorspace API, rectify the
ColorSpace::Srgb preset to use YcbcrEncoding::None.

Signed-off-by: Umang Jain <umang.jain at ideasonboard.com>
---
 src/libcamera/color_space.cpp | 9 +++------
 src/libcamera/v4l2_device.cpp | 2 --
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp
index caf39760..73148228 100644
--- a/src/libcamera/color_space.cpp
+++ b/src/libcamera/color_space.cpp
@@ -254,16 +254,13 @@ const ColorSpace ColorSpace::Jpeg = {
 };
 
 /**
- * \brief A constant representing the sRGB color space
- *
- * This is identical to the JPEG color space except that the Y'CbCr
- * range is limited rather than full.
+ * \brief A constant representing the sRGB color space (non-YUV format)
  */
 const ColorSpace ColorSpace::Srgb = {
 	Primaries::Rec709,
 	TransferFunction::Srgb,
-	YcbcrEncoding::Rec601,
-	Range::Limited
+	YcbcrEncoding::None,
+	Range::Full
 };
 
 /**
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 3fc8438f..a4446fbf 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -746,7 +746,6 @@ void V4L2Device::eventAvailable()
 static const std::map<uint32_t, ColorSpace> v4l2ToColorSpace = {
 	{ V4L2_COLORSPACE_RAW, ColorSpace::Raw },
 	{ V4L2_COLORSPACE_JPEG, ColorSpace::Jpeg },
-	{ V4L2_COLORSPACE_SRGB, ColorSpace::Srgb },
 	{ V4L2_COLORSPACE_SMPTE170M, ColorSpace::Smpte170m },
 	{ V4L2_COLORSPACE_REC709, ColorSpace::Rec709 },
 	{ V4L2_COLORSPACE_BT2020, ColorSpace::Rec2020 },
@@ -772,7 +771,6 @@ static const std::map<uint32_t, ColorSpace::Range> v4l2ToRange = {
 static const std::vector<std::pair<ColorSpace, v4l2_colorspace>> colorSpaceToV4l2 = {
 	{ ColorSpace::Raw, V4L2_COLORSPACE_RAW },
 	{ ColorSpace::Jpeg, V4L2_COLORSPACE_JPEG },
-	{ ColorSpace::Srgb, V4L2_COLORSPACE_SRGB },
 	{ ColorSpace::Smpte170m, V4L2_COLORSPACE_SMPTE170M },
 	{ ColorSpace::Rec709, V4L2_COLORSPACE_REC709 },
 	{ ColorSpace::Rec2020, V4L2_COLORSPACE_BT2020 },
-- 
2.31.1



More information about the libcamera-devel mailing list