From 1ddb8797b5eed65ec62287ae39ba4bc473b09cf7 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 29 Jul 2024 14:39:06 -0400 Subject: [PATCH] v4l2object: SRGB colorspace is documented limited-range Split JPEG and SRGB so that we can follow the specified difference. The SRGB definition in V4L2 does not follow the standard, and is document so. This is also why JPEG colorspace exists. Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2object.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c index 19d8e08ab7..e8582fb32f 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c @@ -2280,6 +2280,11 @@ gst_v4l2_object_get_colorspace (GstV4l2Object * v4l2object, cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709; break; case V4L2_COLORSPACE_SRGB: + cinfo->range = GST_VIDEO_COLOR_RANGE_16_235; + cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT601; + cinfo->transfer = GST_VIDEO_TRANSFER_SRGB; + cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709; + break; case V4L2_COLORSPACE_JPEG: cinfo->range = GST_VIDEO_COLOR_RANGE_0_255; cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT601; @@ -3821,12 +3826,16 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps, /* We first pick the main colorspace from the primaries */ switch (info.colorimetry.primaries) { case GST_VIDEO_COLOR_PRIMARIES_BT709: - /* There is two colorspaces using these primaries, use the range to - * differentiate */ - if (info.colorimetry.range == GST_VIDEO_COLOR_RANGE_16_235) - colorspace = V4L2_COLORSPACE_REC709; - else - colorspace = V4L2_COLORSPACE_SRGB; + /* There is three colorspaces using these primaries, use the range + * and format type to differentiate them */ + if (info.colorimetry.range == GST_VIDEO_COLOR_RANGE_16_235) { + if (GST_VIDEO_INFO_IS_RGB (&info)) + colorspace = V4L2_COLORSPACE_SRGB; + else + colorspace = V4L2_COLORSPACE_REC709; + } else { + colorspace = V4L2_COLORSPACE_JPEG; + } break; case GST_VIDEO_COLOR_PRIMARIES_BT2020: colorspace = V4L2_COLORSPACE_BT2020;