glcolorconvert: Ensure glcolorconvert does not miss supported RGB formats
Issue
gst-launch-1.0 videotestsrc num-buffers=10 ! video/x-raw,format=NV12,width=1920,height=1080 ! glupload ! glcolorconvert ! "video/x-raw(memory:GLMemory),format=RGB16,texture-target=2D" ! gldownload ! filesink location=./test.rgb
When using gstreamer 1.24.0
, the above pipeline will fail with the following error log:
0:00:00.088643768 7026 0xaaaad15a43e0 ERROR GST_PIPELINE gst/parse/grammar.y:1128:gst_parse_perform_link: could not link glcolorconvertelement0 to gldownloadelement0, glcolorconvertelement0 can't handle caps video/x-raw(memory:GLMemory), format=(string)RGB16, texture-target=(string)2D
WARNING: erroneous pipeline: could not link glcolorconvertelement0 to gldownloadelement0, glcolorconvertelement0
can't handle caps video/x-raw(memory:GLMemory), format=(string)RGB16, texture-target=(string)2D
troubleshoot
This is because when calculating the transformable supported RGB
formats of glcolorconvert
, some RGB
formats, such as RGB16
, may be omitted. The problematic code is as follows:
gst_gl_color_convert_caps_transform_format_info (GstGLContext * context,
gboolean output, GstCaps * caps)
{
_init_value_string_list (&rgb_formats, "RGBA", "ARGB", "BGRA", "ABGR", "RGBx",
"xRGB", "BGRx", "xBGR", "RGB", "BGR", "ARGB64", "BGR10A2_LE",
"RGB10A2_LE", "RGBA64_LE", "RGBA64_BE", "RBGA", NULL);
_init_supported_formats (context, output, &supported_formats);
gst_value_intersect (&supported_rgb_formats, &rgb_formats,
&supported_formats);
... ...
}
glcolorconvert
can only support outputting RGB16
format under specific conditions, so rgd_formats
does not have RGB16
.
Due to the fact that supported_rgb_formats
are the intersection of rgb_formats
and supported_rgb_formats
, supported_rgb
formats may miss the RGB16
format.
Solution
Add 'RGB16' and other RGB-related formats to rgd_formats
list.