diff --git a/gst-libs/gst/gl/egl/gsteglimage.c b/gst-libs/gst/gl/egl/gsteglimage.c index 21eb9da4dc..12f0eaa167 100644 --- a/gst-libs/gst/gl/egl/gsteglimage.c +++ b/gst-libs/gst/gl/egl/gsteglimage.c @@ -78,6 +78,18 @@ #define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') #endif +#ifndef DRM_FORMAT_R16 +#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') +#endif + +#ifndef DRM_FORMAT_GR1616 +#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') +#endif + +#ifndef DRM_FORMAT_RG1616 +#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') +#endif + #ifndef EGL_LINUX_DMA_BUF_EXT #define EGL_LINUX_DMA_BUF_EXT 0x3270 #endif @@ -517,6 +529,14 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane, *out_format = GST_GL_RGB10_A2; return DRM_FORMAT_RGBA1010102; + case GST_VIDEO_FORMAT_P010_10LE: + *out_format = plane == 0 ? GST_GL_R16 : GST_GL_RG16; + return plane == 0 ? DRM_FORMAT_R16 : DRM_FORMAT_GR1616; + + case GST_VIDEO_FORMAT_P010_10BE: + *out_format = plane == 0 ? GST_GL_R16 : GST_GL_RG16; + return plane == 0 ? DRM_FORMAT_R16 : DRM_FORMAT_RG1616; + default: GST_ERROR ("Unsupported format for DMABuf."); return -1; diff --git a/gst-libs/gst/gl/gstglcolorconvert.c b/gst-libs/gst/gl/gstglcolorconvert.c index ee27887852..13c7fdcb81 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.c +++ b/gst-libs/gst/gl/gstglcolorconvert.c @@ -956,6 +956,14 @@ _init_supported_formats (GstGLContext * context, gboolean output, _append_value_string_list (supported_formats, "BGR10A2_LE", "RGB10A2_LE", NULL); #endif + + if (!context || (gst_gl_format_is_supported (context, GST_GL_R16) && + gst_gl_format_is_supported (context, GST_GL_RG16))) +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + _append_value_string_list (supported_formats, "P010_10LE", NULL); +#else + _append_value_string_list (supported_formats, "P010_10BE", NULL); +#endif } /* copies the given caps */ @@ -1547,6 +1555,8 @@ _get_n_textures (GstVideoFormat v_format) return 1; case GST_VIDEO_FORMAT_NV12: case GST_VIDEO_FORMAT_NV21: + case GST_VIDEO_FORMAT_P010_10LE: + case GST_VIDEO_FORMAT_P010_10BE: return 2; case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_Y444: @@ -1705,6 +1715,17 @@ _YUV_to_RGB (GstGLColorConvert * convert) info->shader_tex_names[1] = "UVtex"; break; } + case GST_VIDEO_FORMAT_P010_10LE: + case GST_VIDEO_FORMAT_P010_10BE: + { + info->templ = &templ_SEMI_PLANAR_to_RGB; + info->frag_body = + g_strdup_printf (templ_SEMI_PLANAR_to_RGB_BODY, 'r', 'g', + pixel_order[0], pixel_order[1], pixel_order[2], pixel_order[3]); + info->shader_tex_names[0] = "Ytex"; + info->shader_tex_names[1] = "UVtex"; + break; + } default: break; } diff --git a/gst-libs/gst/gl/gstglcolorconvert.h b/gst-libs/gst/gl/gstglcolorconvert.h index e39ecbbace..608bc9cf88 100644 --- a/gst-libs/gst/gl/gstglcolorconvert.h +++ b/gst-libs/gst/gl/gstglcolorconvert.h @@ -88,9 +88,9 @@ 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" +#define COLOR_CONVERT_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE" #else -#define COLOR_CONVERT_EXT_FORMATS "" +#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE" #endif #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \ diff --git a/gst-libs/gst/gl/gstglformat.c b/gst-libs/gst/gl/gstglformat.c index 73b13e9ed0..91286fb3ea 100644 --- a/gst-libs/gst/gl/gstglformat.c +++ b/gst-libs/gst/gl/gstglformat.c @@ -75,6 +75,7 @@ _gl_format_n_components (guint format) case GST_GL_LUMINANCE_ALPHA: case GST_GL_RG: case GST_GL_RG8: + case GST_GL_RG16: return 2; case GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE: case GST_VIDEO_GL_TEXTURE_TYPE_R: @@ -82,6 +83,7 @@ _gl_format_n_components (guint format) case GST_GL_ALPHA: case GST_GL_RED: case GST_GL_R8: + case GST_GL_R16: return 1; default: return 0; @@ -201,6 +203,9 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo, case GST_VIDEO_FORMAT_BGR10A2_LE: case GST_VIDEO_FORMAT_RGB10A2_LE: return GST_GL_RGB10_A2; + case GST_VIDEO_FORMAT_P010_10LE: + case GST_VIDEO_FORMAT_P010_10BE: + return plane == 0 ? GST_GL_R16 : GST_GL_RG16; default: n_plane_components = 4; g_assert_not_reached (); @@ -269,6 +274,8 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context, if (!USING_GLES3 (context) && USING_GLES2 (context) && ext_texture_rg) return GST_GL_RG; return GST_GL_RG8; + case GL_UNSIGNED_SHORT: + return GST_GL_RG16; } break; case GST_GL_RED: @@ -277,6 +284,8 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context, if (!USING_GLES3 (context) && USING_GLES2 (context) && ext_texture_rg) return GST_GL_RED; return GST_GL_R8; + case GL_UNSIGNED_SHORT: + return GST_GL_R16; } break; case GST_GL_RGBA8: @@ -292,6 +301,8 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context, case GST_GL_DEPTH_COMPONENT16: case GST_GL_DEPTH24_STENCIL8: case GST_GL_RGB10_A2: + case GST_GL_R16: + case GST_GL_RG16: return format; default: g_critical ("Unknown GL format 0x%x type 0x%x provided", format, type); @@ -363,6 +374,14 @@ gst_gl_format_type_from_sized_gl_format (GstGLFormat format, *unsized_format = GST_GL_RGBA; *gl_type = GL_UNSIGNED_INT_2_10_10_10_REV; break; + case GST_GL_R16: + *unsized_format = GST_GL_RED; + *gl_type = GL_UNSIGNED_SHORT; + break; + case GST_GL_RG16: + *unsized_format = GST_GL_RG; + *gl_type = GL_UNSIGNED_SHORT; + break; default: g_critical ("Unknown GL format 0x%x provided", format); *unsized_format = format; @@ -435,6 +454,12 @@ gst_gl_format_is_supported (GstGLContext * context, GstGLFormat format) || USING_GLES3 (context) || gst_gl_context_check_feature (context, "GL_OES_required_internalformat"); + case GST_GL_R16: + case GST_GL_RG16: + return gst_gl_context_check_gl_version (context, + GST_GL_API_OPENGL | GST_GL_API_OPENGL3, 3, 0) + || (gst_gl_context_check_gl_version (context, GST_GL_API_GLES2, 3, 1) + && gst_gl_context_check_feature (context, "GL_EXT_texture_norm16")); default: g_assert_not_reached (); return FALSE; diff --git a/gst-libs/gst/gl/gstglformat.h b/gst-libs/gst/gl/gstglformat.h index 8705d4586f..1e95cebdcf 100644 --- a/gst-libs/gst/gl/gstglformat.h +++ b/gst-libs/gst/gl/gstglformat.h @@ -98,6 +98,8 @@ G_BEGIN_DECLS * a 8-bit component for stencil informat. * @GST_GL_RGBA10_A2: Four components of bit depth 10, 10, 10 and 2 stored in the * R, G, B and A texture components respectively. + * @GST_GL_R16: Single 16-bit component stored in the R texture component + * @GST_GL_RG16: Two 16-bit components stored in the R and G texture components */ typedef enum { @@ -128,6 +130,9 @@ typedef enum GST_GL_DEPTH24_STENCIL8 = 0x88F0, GST_GL_RGB10_A2 = 0x8059, + + GST_GL_R16 = 0x822A, + GST_GL_RG16 = 0x822C, } GstGLFormat; GST_GL_API diff --git a/gst-libs/gst/gl/gstglmemory.h b/gst-libs/gst/gl/gstglmemory.h index b18bbf3107..3c5610b409 100644 --- a/gst-libs/gst/gl/gstglmemory.h +++ b/gst-libs/gst/gl/gstglmemory.h @@ -51,9 +51,9 @@ 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" +#define MEMORY_VIDEO_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE" #else -#define MEMORY_VIDEO_EXT_FORMATS "" +#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE" #endif #define GST_GL_MEMORY_VIDEO_FORMATS_STR \