From ea6bed111bab9b394d787f7760c6a3b953630d3a Mon Sep 17 00:00:00 2001 From: Haihua Hu Date: Thu, 25 May 2017 11:05:47 +0800 Subject: [PATCH] glformat: fix the usage of GST_GL_RGB565 GL_RGB565 is sized internal glformat, the corresponding glformat should be GL_RGB and type is GL_UNSIGNED_SHORT_565. Otherwise will return GL_INVALID_ENUM when creating texture. https://bugzilla.gnome.org/show_bug.cgi?id=783066 --- gst-libs/gst/gl/gstglformat.c | 2 +- gst-libs/gst/gl/gstglmemory.c | 8 ++++++-- gst-libs/gst/gl/gstglmemorypbo.c | 4 +++- gst-libs/gst/gl/gstglrenderbuffer.c | 4 +++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/gl/gstglformat.c b/gst-libs/gst/gl/gstglformat.c index e449688462..1aeb09db39 100644 --- a/gst-libs/gst/gl/gstglformat.c +++ b/gst-libs/gst/gl/gstglformat.c @@ -234,7 +234,7 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context, && !USING_GLES3 (context) ? GST_GL_RGB : GST_GL_RGB8; break; case GL_UNSIGNED_SHORT_5_6_5: - return GST_GL_RGB; + return GST_GL_RGB565; break; } break; diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c index 0a06086c62..c762a9fb31 100644 --- a/gst-libs/gst/gl/gstglmemory.c +++ b/gst-libs/gst/gl/gstglmemory.c @@ -245,8 +245,10 @@ _gl_tex_create (GstGLMemory * gl_mem, GError ** error) tex_format = gl_mem->tex_format; tex_type = GL_UNSIGNED_BYTE; - if (gl_mem->tex_format == GST_GL_RGB565) + if (gl_mem->tex_format == GST_GL_RGB565) { + tex_format = GST_GL_RGB; tex_type = GL_UNSIGNED_SHORT_5_6_5; + } internal_format = gst_gl_sized_gl_format_from_gl_format_type (context, tex_format, @@ -779,8 +781,10 @@ _gl_tex_copy_thread (GstGLContext * context, gpointer data) out_tex_target = gst_gl_texture_target_to_gl (copy_params->tex_target); out_gl_format = copy_params->src->tex_format; out_gl_type = GL_UNSIGNED_BYTE; - if (copy_params->out_format == GST_GL_RGB565) + if (copy_params->out_format == GST_GL_RGB565) { + out_gl_format = GST_GL_RGB; out_gl_type = GL_UNSIGNED_SHORT_5_6_5; + } internal_format = gst_gl_sized_gl_format_from_gl_format_type (context, out_gl_format, diff --git a/gst-libs/gst/gl/gstglmemorypbo.c b/gst-libs/gst/gl/gstglmemorypbo.c index a7cf042f2c..89091c80b1 100644 --- a/gst-libs/gst/gl/gstglmemorypbo.c +++ b/gst-libs/gst/gl/gstglmemorypbo.c @@ -419,8 +419,10 @@ _gl_mem_copy_thread (GstGLContext * context, gpointer data) gl = context->gl_vtable; out_gl_format = copy_params->out_format; out_gl_type = GL_UNSIGNED_BYTE; - if (copy_params->out_format == GST_GL_RGB565) + if (copy_params->out_format == GST_GL_RGB565) { + out_gl_format = GST_GL_RGB; out_gl_type = GL_UNSIGNED_SHORT_5_6_5; + } in_gl_format = src->mem.tex_format; in_gl_type = GL_UNSIGNED_BYTE; if (src->mem.tex_format == GST_GL_RGB565) diff --git a/gst-libs/gst/gl/gstglrenderbuffer.c b/gst-libs/gst/gl/gstglrenderbuffer.c index c3e36f6b54..9a3c0c69e8 100644 --- a/gst-libs/gst/gl/gstglrenderbuffer.c +++ b/gst-libs/gst/gl/gstglrenderbuffer.c @@ -86,8 +86,10 @@ _gl_rbo_create (GstGLRenderbuffer * gl_mem, GError ** error) tex_format = gl_mem->renderbuffer_format; renderbuffer_type = GL_UNSIGNED_BYTE; - if (gl_mem->renderbuffer_format == GST_GL_RGB565) + if (gl_mem->renderbuffer_format == GST_GL_RGB565) { + tex_format = GST_GL_RGB; renderbuffer_type = GL_UNSIGNED_SHORT_5_6_5; + } internal_format = gst_gl_sized_gl_format_from_gl_format_type (context, tex_format,