gl: add support for Y212_LE / Y212_BE format

Because the color value is stored in MSB, so we can reuse the
Y210 code for P012_LE / P012_BE

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=Y212_LE ! glimagesink
This commit is contained in:
Haihao Xiang 2020-03-30 14:37:26 +08:00
parent fb1c284026
commit 5f859203ad
4 changed files with 21 additions and 5 deletions

View file

@ -945,8 +945,14 @@ _init_supported_formats (GstGLContext * context, gboolean output,
#endif
}
if (!context || (gst_gl_format_is_supported (context, GST_GL_RG16)))
if (!context || (gst_gl_format_is_supported (context, GST_GL_RG16))) {
_append_value_string_list (supported_formats, "Y210", NULL);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
_append_value_string_list (supported_formats, "Y212_LE", NULL);
#else
_append_value_string_list (supported_formats, "Y212_BE", NULL);
#endif
}
}
/* copies the given caps */
@ -1537,6 +1543,8 @@ _get_n_textures (GstVideoFormat v_format)
case GST_VIDEO_FORMAT_RGB10A2_LE:
case GST_VIDEO_FORMAT_Y410:
case GST_VIDEO_FORMAT_Y210:
case GST_VIDEO_FORMAT_Y212_LE:
case GST_VIDEO_FORMAT_Y212_BE:
return 1;
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
@ -1691,6 +1699,8 @@ _YUV_to_RGB (GstGLColorConvert * convert)
break;
}
case GST_VIDEO_FORMAT_Y210:
case GST_VIDEO_FORMAT_Y212_LE:
case GST_VIDEO_FORMAT_Y212_BE:
{
info->templ = &templ_YUY2_UYVY_to_RGB;
info->frag_body =
@ -1821,6 +1831,8 @@ _RGB_to_YUV (GstGLColorConvert * convert)
break;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_Y210:
case GST_VIDEO_FORMAT_Y212_LE:
case GST_VIDEO_FORMAT_Y212_BE:
info->templ = &templ_RGB_to_YUY2_UYVY;
info->frag_body = g_strdup_printf (templ_RGB_to_YUY2_UYVY_BODY,
pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],

View file

@ -88,9 +88,10 @@ struct _GstGLColorConvertClass
* The currently supported formats that can be converted
*/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define COLOR_CONVERT_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE"
#define COLOR_CONVERT_EXT_FORMATS \
", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE"
#else
#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE"
#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE, Y212_BE"
#endif
#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \

View file

@ -214,6 +214,8 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
case GST_VIDEO_FORMAT_P016_BE:
return plane == 0 ? GST_GL_R16 : GST_GL_RG16;
case GST_VIDEO_FORMAT_Y210:
case GST_VIDEO_FORMAT_Y212_LE:
case GST_VIDEO_FORMAT_Y212_BE:
return GST_GL_RG16;
default:
n_plane_components = 4;

View file

@ -51,9 +51,10 @@ GType gst_gl_memory_allocator_get_type(void);
* List of video formats that are supported by #GstGLMemory
*/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define MEMORY_VIDEO_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE"
#define MEMORY_VIDEO_EXT_FORMATS \
", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE, Y212_LE"
#else
#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE"
#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE, Y212_BE"
#endif
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \