From 7ef84fb75778b04059d5d9b0224865d34f05038b Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Fri, 11 Oct 2019 22:54:02 +0800 Subject: [PATCH] glimagesink: add support for Y410 format Sample pipeline: gst-launch-1.0 videotestsrc ! video/x-raw,format=Y410 ! glimagesink --- gst-libs/gst/gl/gstglcolorconvert.c | 21 +++++++++++++++++++-- gst-libs/gst/gl/gstglcolorconvert.h | 2 +- gst-libs/gst/gl/gstglformat.c | 1 + gst-libs/gst/gl/gstglmemory.h | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index cc2332e014..895a93cb51 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -924,11 +924,14 @@ _init_supported_formats (GstGLContext * context, gboolean output, if (!context || gst_gl_format_is_supported (context, GST_GL_RGB565)) _append_value_string_list (supported_formats, "RGB16", "BGR16", NULL); + if (!context || gst_gl_format_is_supported (context, GST_GL_RGB10_A2)) { #if G_BYTE_ORDER == G_LITTLE_ENDIAN - if (!context || gst_gl_format_is_supported (context, GST_GL_RGB10_A2)) _append_value_string_list (supported_formats, "BGR10A2_LE", "RGB10A2_LE", - NULL); + "Y410", NULL); +#else + _append_value_string_list (supported_formats, "Y410", NULL); #endif + } if (!context || (gst_gl_format_is_supported (context, GST_GL_R16) && gst_gl_format_is_supported (context, GST_GL_RG16))) @@ -1525,6 +1528,7 @@ _get_n_textures (GstVideoFormat v_format) case GST_VIDEO_FORMAT_ARGB64: case GST_VIDEO_FORMAT_BGR10A2_LE: case GST_VIDEO_FORMAT_RGB10A2_LE: + case GST_VIDEO_FORMAT_Y410: return 1; case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV21: @@ -1625,6 +1629,12 @@ _YUV_to_RGB (GstGLColorConvert * convert) pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]); info->shader_tex_names[0] = "tex"; break; + case GST_VIDEO_FORMAT_Y410: + info->templ = &templ_AYUV_to_RGB; + info->frag_body = g_strdup_printf (templ_AYUV_to_RGB_BODY, "yxz", 'w', + pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]); + info->shader_tex_names[0] = "tex"; + break; case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_Y444: case GST_VIDEO_FORMAT_Y42B: @@ -1754,6 +1764,13 @@ _RGB_to_YUV (GstGLColorConvert * convert) pixel_order[1], pixel_order[2], pixel_order[3], "zyx", 'w', alpha); info->out_n_textures = 1; break; + case GST_VIDEO_FORMAT_Y410: + alpha = _is_RGBx (in_format) ? "1.0" : "texel.a"; + info->templ = &templ_RGB_to_AYUV; + info->frag_body = g_strdup_printf (templ_RGB_to_AYUV_BODY, pixel_order[0], + pixel_order[1], pixel_order[2], pixel_order[3], "yxz", 'w', alpha); + info->out_n_textures = 1; + break; case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_Y444: diff --git a/gst-libs/gst/gl/gstglcolorconvert.h b/gst-libs/gst/gl/gstglcolorconvert.h index 3dd46e9367..59ddfe8e5a 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.h +++ b/gst-libs/gst/gl/gstglcolorconvert.h @@ -95,7 +95,7 @@ struct _GstGLColorConvertClass #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \ "xBGR, ARGB, ABGR, Y444, I420, YV12, Y42B, " \ - "Y41B, NV12, NV21, YUY2, UYVY, AYUV, VUYA, " \ + "Y41B, NV12, NV21, YUY2, UYVY, AYUV, VUYA, Y410, " \ "GRAY8, GRAY16_LE, GRAY16_BE, RGB16, BGR16, ARGB64 " \ COLOR_CONVERT_EXT_FORMATS "}" diff --git a/gst-libs/gst/gl/gstglformat.c b/gst-libs/gst/gl/gstglformat.c index 62ae92b57d..66967086e1 100644 --- a/gst-libs/gst/gl/gstglformat.c +++ b/gst-libs/gst/gl/gstglformat.c @@ -202,6 +202,7 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo, break; case GST_VIDEO_FORMAT_BGR10A2_LE: case GST_VIDEO_FORMAT_RGB10A2_LE: + case GST_VIDEO_FORMAT_Y410: return GST_GL_RGB10_A2; case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10BE: diff --git a/gst-libs/gst/gl/gstglmemory.h b/gst-libs/gst/gl/gstglmemory.h index c1814b8ba3..3c9f42be32 100644 --- a/gst-libs/gst/gl/gstglmemory.h +++ b/gst-libs/gst/gl/gstglmemory.h @@ -58,7 +58,7 @@ GType gst_gl_memory_allocator_get_type(void); #define GST_GL_MEMORY_VIDEO_FORMATS_STR \ "{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \ - "AYUV, VUYA, I420, YV12, NV12, NV21, YUY2, UYVY, Y41B, Y42B, Y444, " \ + "AYUV, VUYA, Y410, I420, YV12, NV12, NV21, YUY2, UYVY, Y41B, Y42B, Y444, " \ "GRAY8, GRAY16_LE, GRAY16_BE, ARGB64" MEMORY_VIDEO_EXT_FORMATS "}" /**