[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    gst-plugins-bad: glmemory: add checking the read implementation format/ type on gles2 platforms
From:       ystreet () kemper ! freedesktop ! org (Matthew Waters)
Date:       2016-03-31 10:17:07
Message-ID: 20160331101707.0B5D4761E0 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-bad
Branch: master
Commit: 9ea15579ec5402c52e995aaed85347358d859a68
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=9ea15579ec5402c52e995aaed85347358d859a68


Author: Matthew Waters <matthew@centricular.com>
Date:   Thu Mar 31 19:38:12 2016 +1100

glmemory: add checking the read implementation format/type on gles2 platforms

By default, reading GL_RED or GL_RG us unsupported by glReadPixels unless
exposed through GL_COLOR_READ_IMPLEMENTATION_FORMAT/TYPE.  This allows
downloading multiple-planar video frames where possible.

---

 gst-libs/gst/gl/gstglmemory.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c
index 402fd4d..f75a842 100644
--- a/gst-libs/gst/gl/gstglmemory.c
+++ b/gst-libs/gst/gl/gstglmemory.c
@@ -367,6 +367,26 @@ gst_gl_memory_read_pixels (GstGLMemory * gl_mem, gpointer \
read_pointer)  return FALSE;
   }
 
+  if (USING_GLES2 (context) || USING_GLES3 (context)) {
+    if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+      /* explicitly supported */
+    } else {
+      gint supported_format, supported_type;
+
+      gl->GetIntegerv (GL_IMPLEMENTATION_COLOR_READ_FORMAT, &supported_format);
+      gl->GetIntegerv (GL_IMPLEMENTATION_COLOR_READ_TYPE, &supported_type);
+
+      if (supported_format != format || supported_type != type) {
+        GST_CAT_ERROR (GST_CAT_GL_MEMORY, "cannot read pixels with "
+            "unsupported format and type.  Supported format 0x%x type 0x%x",
+            supported_format, supported_type);
+        gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
+        gl->DeleteFramebuffers (1, &fbo);
+        return FALSE;
+      }
+    }
+  }
+
   gst_gl_query_start_log (GST_GL_BASE_MEMORY_CAST (gl_mem)->query,
       GST_CAT_GL_MEMORY, GST_LEVEL_LOG, NULL, "%s", "glReadPixels took");
   gl->ReadPixels (0, 0, gl_mem->tex_width, GL_MEM_HEIGHT (gl_mem), format,
@@ -374,7 +394,6 @@ gst_gl_memory_read_pixels (GstGLMemory * gl_mem, gpointer \
read_pointer)  gst_gl_query_end (GST_GL_BASE_MEMORY_CAST (gl_mem)->query);
 
   gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
-
   gl->DeleteFramebuffers (1, &fbo);
 
   return TRUE;

_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic