glimagesink: add support for Y210 format

Y210 is a 10-bit YUY2, so we may re-use the YUY2 shaders but gl format
is set to RG16

Sample pipeline:
gst-launch-1.0 videotestsrc ! video/x-raw,format=Y210 ! glimagesink
This commit is contained in:
Haihao Xiang 2019-10-12 12:00:46 +08:00
parent 0b362e5a4b
commit b3e9e3f747
4 changed files with 21 additions and 3 deletions

View file

@ -935,12 +935,16 @@ _init_supported_formats (GstGLContext * context, gboolean output,
} }
if (!context || (gst_gl_format_is_supported (context, GST_GL_R16) && if (!context || (gst_gl_format_is_supported (context, GST_GL_R16) &&
gst_gl_format_is_supported (context, GST_GL_RG16))) gst_gl_format_is_supported (context, GST_GL_RG16))) {
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
_append_value_string_list (supported_formats, "P010_10LE", "P016_LE", NULL); _append_value_string_list (supported_formats, "P010_10LE", "P016_LE", NULL);
#else #else
_append_value_string_list (supported_formats, "P010_10BE", "P016_BE", NULL); _append_value_string_list (supported_formats, "P010_10BE", "P016_BE", NULL);
#endif #endif
}
if (!context || (gst_gl_format_is_supported (context, GST_GL_RG16)))
_append_value_string_list (supported_formats, "Y210", NULL);
} }
/* copies the given caps */ /* copies the given caps */
@ -1530,6 +1534,7 @@ _get_n_textures (GstVideoFormat v_format)
case GST_VIDEO_FORMAT_BGR10A2_LE: case GST_VIDEO_FORMAT_BGR10A2_LE:
case GST_VIDEO_FORMAT_RGB10A2_LE: case GST_VIDEO_FORMAT_RGB10A2_LE:
case GST_VIDEO_FORMAT_Y410: case GST_VIDEO_FORMAT_Y410:
case GST_VIDEO_FORMAT_Y210:
return 1; return 1;
case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21: case GST_VIDEO_FORMAT_NV21:
@ -1681,6 +1686,16 @@ _YUV_to_RGB (GstGLColorConvert * convert)
info->shader_tex_names[0] = "Ytex"; info->shader_tex_names[0] = "Ytex";
break; break;
} }
case GST_VIDEO_FORMAT_Y210:
{
info->templ = &templ_YUY2_UYVY_to_RGB;
info->frag_body =
g_strdup_printf (templ_YUY2_UYVY_to_RGB_BODY, 'r', 'g', 'g',
'g', 'a', pixel_order[0], pixel_order[1], pixel_order[2],
pixel_order[3]);
info->shader_tex_names[0] = "Ytex";
break;
}
case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV16: case GST_VIDEO_FORMAT_NV16:
{ {
@ -1799,6 +1814,7 @@ _RGB_to_YUV (GstGLColorConvert * convert)
} }
break; break;
case GST_VIDEO_FORMAT_YUY2: case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_Y210:
info->templ = &templ_RGB_to_YUY2_UYVY; info->templ = &templ_RGB_to_YUY2_UYVY;
info->frag_body = g_strdup_printf (templ_RGB_to_YUY2_UYVY_BODY, info->frag_body = g_strdup_printf (templ_RGB_to_YUY2_UYVY_BODY,
pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3], pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3],

View file

@ -95,7 +95,7 @@ struct _GstGLColorConvertClass
#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \ #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
"xBGR, ARGB, ABGR, Y444, I420, YV12, Y42B, " \ "xBGR, ARGB, ABGR, Y444, I420, YV12, Y42B, " \
"Y41B, NV12, NV21, NV16, NV61, YUY2, UYVY, AYUV, " \ "Y41B, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, AYUV, " \
"VUYA, Y410, GRAY8, GRAY16_LE, GRAY16_BE, " \ "VUYA, Y410, GRAY8, GRAY16_LE, GRAY16_BE, " \
"RGB16, BGR16, ARGB64 " COLOR_CONVERT_EXT_FORMATS "}" "RGB16, BGR16, ARGB64 " COLOR_CONVERT_EXT_FORMATS "}"

View file

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

View file

@ -58,7 +58,7 @@ GType gst_gl_memory_allocator_get_type(void);
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \ #define GST_GL_MEMORY_VIDEO_FORMATS_STR \
"{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \ "{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \
"AYUV, VUYA, Y410, I420, YV12, NV12, NV21, NV16, NV61, YUY2, UYVY, Y41B, " \ "AYUV, VUYA, Y410, I420, YV12, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, Y41B, " \
"Y42B, Y444, GRAY8, GRAY16_LE, GRAY16_BE, ARGB64" MEMORY_VIDEO_EXT_FORMATS "}" "Y42B, Y444, GRAY8, GRAY16_LE, GRAY16_BE, ARGB64" MEMORY_VIDEO_EXT_FORMATS "}"
/** /**