v4l2: Add adobe colorspace support

Use the new primaries and transfer function for Adobe RGB.
Explicitly list the colorimetry instead of using the default GStreamer
ones. The defaults for BT2020, for example, do not match.
Explicitly set the matrix of SRGB to RGB.
This commit is contained in:
Wim Taymans 2016-01-21 10:49:44 +01:00
parent 70db210315
commit 681bab62e5

View file

@ -1892,14 +1892,23 @@ gst_v4l2_object_get_colorspace (enum v4l2_colorspace colorspace,
/* First step, set the defaults for each primaries */ /* First step, set the defaults for each primaries */
switch (colorspace) { switch (colorspace) {
case V4L2_COLORSPACE_SMPTE170M: case V4L2_COLORSPACE_SMPTE170M:
ret = gst_video_colorimetry_from_string (cinfo, cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
GST_VIDEO_COLORIMETRY_BT601); cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT601;
cinfo->transfer = GST_VIDEO_TRANSFER_BT709;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
break; break;
case V4L2_COLORSPACE_REC709: case V4L2_COLORSPACE_REC709:
ret = gst_video_colorimetry_from_string (cinfo, cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
GST_VIDEO_COLORIMETRY_BT709); cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT709;
cinfo->transfer = GST_VIDEO_TRANSFER_BT709;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
break; break;
case V4L2_COLORSPACE_SRGB: case V4L2_COLORSPACE_SRGB:
cinfo->range = GST_VIDEO_COLOR_RANGE_0_255;
cinfo->matrix = GST_VIDEO_COLOR_MATRIX_RGB;
cinfo->transfer = GST_VIDEO_TRANSFER_SRGB;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
break;
case V4L2_COLORSPACE_JPEG: case V4L2_COLORSPACE_JPEG:
/* This is in fact sYCC */ /* This is in fact sYCC */
cinfo->range = GST_VIDEO_COLOR_RANGE_0_255; cinfo->range = GST_VIDEO_COLOR_RANGE_0_255;
@ -1908,17 +1917,22 @@ gst_v4l2_object_get_colorspace (enum v4l2_colorspace colorspace,
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709; cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT709;
break; break;
case V4L2_COLORSPACE_ADOBERGB: case V4L2_COLORSPACE_ADOBERGB:
GST_FIXME ("AdobeRGB is not yet supported by GStreamer"); cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
/* We are missing the primaries and the transfer function */ cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT601;
ret = FALSE; cinfo->transfer = GST_VIDEO_TRANSFER_ADOBERGB;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_ADOBERGB;
break; break;
case V4L2_COLORSPACE_BT2020: case V4L2_COLORSPACE_BT2020:
ret = gst_video_colorimetry_from_string (cinfo, cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
GST_VIDEO_COLORIMETRY_BT2020); cinfo->matrix = GST_VIDEO_COLOR_MATRIX_BT2020;
cinfo->transfer = GST_VIDEO_TRANSFER_BT709;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_BT2020;
break; break;
case V4L2_COLORSPACE_SMPTE240M: case V4L2_COLORSPACE_SMPTE240M:
ret = gst_video_colorimetry_from_string (cinfo, cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
GST_VIDEO_COLORIMETRY_SMPTE240M); cinfo->matrix = GST_VIDEO_COLOR_MATRIX_SMPTE240M;
cinfo->transfer = GST_VIDEO_TRANSFER_SMPTE240M;
cinfo->primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE240M;
break; break;
case V4L2_COLORSPACE_470_SYSTEM_M: case V4L2_COLORSPACE_470_SYSTEM_M:
cinfo->range = GST_VIDEO_COLOR_RANGE_16_235; cinfo->range = GST_VIDEO_COLOR_RANGE_16_235;
@ -2005,8 +2019,7 @@ gst_v4l2_object_get_colorspace (enum v4l2_colorspace colorspace,
cinfo->transfer = GST_VIDEO_TRANSFER_SRGB; cinfo->transfer = GST_VIDEO_TRANSFER_SRGB;
break; break;
case V4L2_XFER_FUNC_ADOBERGB: case V4L2_XFER_FUNC_ADOBERGB:
GST_FIXME ("AdobeRGB is not yet supported by GStreamer"); cinfo->transfer = GST_VIDEO_TRANSFER_ADOBERGB;
cinfo->transfer = GST_VIDEO_TRANSFER_UNKNOWN;
break; break;
case V4L2_XFER_FUNC_SMPTE240M: case V4L2_XFER_FUNC_SMPTE240M:
cinfo->transfer = GST_VIDEO_TRANSFER_SMPTE240M; cinfo->transfer = GST_VIDEO_TRANSFER_SMPTE240M;