glcolorconvert incorrectly converts RGB planar video
I am writing an application that connects to an RTSP server and receives a video stream encoded with H.265 with RGB, full-range planar colors. According to the H.265 standard, planar RGB is signaled by setting chroma_format_idc to 4:4:4 and setting matrix_coeffs to GBR (referred to as RGB). See Rec. ITU-T H.265 v8, Table E.5.
GstH265Parse
correctly recognizes this format and sets chroma-format: 4:4:4
and colorimetry: 1:1:16:4
(the first 1 in the colorimetry string means an RGB matrix).
However, validate_colorimetry
from video-info.c
thinks an RGB matrix is invalid for Y444.
if ((GST_VIDEO_FORMAT_INFO_IS_YUV (finfo)
|| GST_VIDEO_FORMAT_INFO_IS_GRAY (finfo))
&& info->colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_RGB) {
GST_WARNING
("color matrix RGB is only supported with RGB format, %s is not",
finfo->name);
return FALSE;
}
As a result, gst_video_info_from_caps
changes the RGB matrix to BT601. Moreover, it overwrites the 0...255 range with 16...235. Consequently, glcolorconvert
treats GBR values as luma and two chroma components, producing incorrect colors.
The full graph is attached.