After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 764873 - gldeinterlace: enable this plugin on OpenGL ES using a simple deinterlace fragment shader
gldeinterlace: enable this plugin on OpenGL ES using a simple deinterlace fra...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.8.0
Other Windows
: Normal normal
: 1.9.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 747232 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-04-11 05:11 UTC by Haihua Hu
Modified: 2016-09-27 06:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gldeinterlace: enable this plugin on OpenGL ES using a simple deinterlace fragment shader (6.90 KB, patch)
2016-04-11 05:13 UTC, Haihua Hu
needs-work Details | Review
refine the patch (11.13 KB, patch)
2016-04-11 08:53 UTC, Haihua Hu
reviewed Details | Review
Add method property to gldeinterlace and add blur vertical method (21.19 KB, patch)
2016-04-13 04:54 UTC, Haihua Hu
needs-work Details | Review
correct patch coding error (21.67 KB, patch)
2016-04-27 09:16 UTC, Haihua Hu
none Details | Review

Description Haihua Hu 2016-04-11 05:11:07 UTC
Can we enable gldeinterlace on OpenGL ES. For better performance, we can use a simple fragment shader. I have tested this shader, it can meet requirement.
Comment 1 Haihua Hu 2016-04-11 05:13:03 UTC
Created attachment 325696 [details] [review]
gldeinterlace: enable this plugin on OpenGL ES using a simple deinterlace fragment shader
Comment 2 Matthew Waters (ystreet00) 2016-04-11 07:32:22 UTC
Review of attachment 325696 [details] [review]:

A couple of things.

It's possible to build against both the OpenGL desktop and GLES API's.  As such the GST_GL_HAVE OPENGL define is not the correct way to conditionally check for the GL API.  Use gst_gl_context_get_gl_api() instead.

Also, the current deinterlace shader is trivial to port to GLES2.  Any reason you did not do that?

::: ext/gl/gstgldeinterlace.c
@@ +69,2 @@
 /* *INDENT-OFF* */
+const gchar *vertex_default =

You should use the default vertex string, gst_gl_shader_string_vertex_default instead of duplicating it here.

@@ +157,3 @@
+
+const gchar *deinterlace_fragment_source_gles2 =
+  "precision mediump float;\n"

Should add #ifdef GL_ES, #endif around the precision qualifier.

@@ +269,2 @@
   //blocking call, wait the opengl thread has compiled the shader
+#if GST_GL_HAVE_OPENGL

This won't always do what you want.  Use gst_gl_context_get_gl_api() instead.

@@ +326,3 @@
+  gst_gl_shader_use (deinterlace_filter->shader);
+
+#if GST_GL_HAVE_OPENGL

ditto
Comment 3 Haihua Hu 2016-04-11 08:51:46 UTC
(In reply to Matthew Waters (ystreet00) from comment #2)
> Review of attachment 325696 [details] [review] [review]:
> 
> A couple of things.
> 
> It's possible to build against both the OpenGL desktop and GLES API's.  As
> such the GST_GL_HAVE OPENGL define is not the correct way to conditionally
> check for the GL API.  Use gst_gl_context_get_gl_api() instead.
> 
> Also, the current deinterlace shader is trivial to port to GLES2.  Any
> reason you did not do that?

We have tried the greedyh_fragment_source and it can run on GLES2, but the performance is not good on i.Mx6QP. 
We need this plugin to do deinterlace by GPU and create the simple one. It got good results. I wonder if we can enable this plugin on GLES2 just like gleffects, let user to choose the deinterlace shader. In this way, we can add more deinterlace shader.

> 
> ::: ext/gl/gstgldeinterlace.c
> @@ +69,2 @@
>  /* *INDENT-OFF* */
> +const gchar *vertex_default =
> 
> You should use the default vertex string,
> gst_gl_shader_string_vertex_default instead of duplicating it here.
> 
> @@ +157,3 @@
> +
> +const gchar *deinterlace_fragment_source_gles2 =
> +  "precision mediump float;\n"
> 
> Should add #ifdef GL_ES, #endif around the precision qualifier.
> 
> @@ +269,2 @@
>    //blocking call, wait the opengl thread has compiled the shader
> +#if GST_GL_HAVE_OPENGL
> 
> This won't always do what you want.  Use gst_gl_context_get_gl_api() instead.
> 
> @@ +326,3 @@
> +  gst_gl_shader_use (deinterlace_filter->shader);
> +
> +#if GST_GL_HAVE_OPENGL
> 
> ditto
Comment 4 Haihua Hu 2016-04-11 08:53:17 UTC
Created attachment 325707 [details] [review]
refine the patch
Comment 5 Matthew Waters (ystreet00) 2016-04-11 12:32:49 UTC
Review of attachment 325707 [details] [review]:

I think this should be behind a property, say method, like the deinterlace element in -good.  There's nothing technically prohibiting enabling this (vertical blur) shader (and the existing greedyh one everywhere).  In fact, all that's required is to add a property and merge the two _callback() implementations.

::: ext/gl/gstgldeinterlace.c
@@ +200,3 @@
 
+  GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api =
+      GST_GL_API_OPENGL | GST_GL_API_GLES2;

gles2 shaders are also supported for OpenGL3.
Comment 6 Haihua Hu 2016-04-12 01:34:19 UTC
(In reply to Matthew Waters (ystreet00) from comment #5)
> Review of attachment 325707 [details] [review] [review]:
> 
> I think this should be behind a property, say method, like the deinterlace
> element in -good.  There's nothing technically prohibiting enabling this
> (vertical blur) shader (and the existing greedyh one everywhere).  In fact,
> all that's required is to add a property and merge the two _callback()
> implementations.
> 
> ::: ext/gl/gstgldeinterlace.c
> @@ +200,3 @@
>  
> +  GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api =
> +      GST_GL_API_OPENGL | GST_GL_API_GLES2;
> 
> gles2 shaders are also supported for OpenGL3.

Yes, you are right. That's what I mean, let me refine this patch just like what we discuss above.
Comment 7 Haihua Hu 2016-04-13 04:54:45 UTC
Created attachment 325838 [details] [review]
Add method property to gldeinterlace and add blur vertical method
Comment 8 Haihua Hu 2016-04-13 04:57:10 UTC
(In reply to Matthew Waters (ystreet00) from comment #5)
> Review of attachment 325707 [details] [review] [review]:
> 
> I think this should be behind a property, say method, like the deinterlace
> element in -good.  There's nothing technically prohibiting enabling this
> (vertical blur) shader (and the existing greedyh one everywhere).  In fact,
> all that's required is to add a property and merge the two _callback()
> implementations.
> 
> ::: ext/gl/gstgldeinterlace.c
> @@ +200,3 @@
>  
> +  GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api =
> +      GST_GL_API_OPENGL | GST_GL_API_GLES2;
> 
> gles2 shaders are also supported for OpenGL3.

Hi Matthew,
I have refine the gldeinterlace, help me review the code. Thanks a lot.
Comment 9 Haihua Hu 2016-04-19 01:28:46 UTC
(In reply to Matthew Waters (ystreet00) from comment #5)
> Review of attachment 325707 [details] [review] [review]:
> 
> I think this should be behind a property, say method, like the deinterlace
> element in -good.  There's nothing technically prohibiting enabling this
> (vertical blur) shader (and the existing greedyh one everywhere).  In fact,
> all that's required is to add a property and merge the two _callback()
> implementations.
> 
> ::: ext/gl/gstgldeinterlace.c
> @@ +200,3 @@
>  
> +  GST_GL_BASE_FILTER_CLASS (klass)->supported_gl_api =
> +      GST_GL_API_OPENGL | GST_GL_API_GLES2;
> 
> gles2 shaders are also supported for OpenGL3.

Hi Matthew,
Any update for this patch?
Comment 10 Matthew Waters (ystreet00) 2016-04-27 08:07:25 UTC
Review of attachment 325838 [details] [review]:

This doesn't seem to apply cleanly to latest master.

After modifying the patch to apply, it also doesn't compile with opengl enabled and -Werror enabled.

gstgldeinterlace.c: In function ‘gst_gl_deinterlace_vfir_callback’:
gstgldeinterlace.c:437:52: error: passing argument 1 of ‘gst_gl_deinterlace_get_fragment_shader’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   shader = gst_gl_deinterlace_get_fragment_shader (deinterlace_filter, "vfir",
                                                    ^
gstgldeinterlace.c:393:1: note: expected ‘GstGLFilter * {aka struct _GstGLFilter *}’ but argument is of type ‘GstGLDeinterlace * {aka struct _GstGLDeinterlace *}’
 gst_gl_deinterlace_get_fragment_shader (GstGLFilter * filter,
 ^
gstgldeinterlace.c:444:7: error: implicit declaration of function ‘USING_OPENGL’ [-Werror=implicit-function-declaration]
   if (USING_OPENGL (context)) {
       ^
gstgldeinterlace.c:444:3: error: nested extern declaration of ‘USING_OPENGL’ [-Werror=nested-externs]
   if (USING_OPENGL (context)) {
   ^
gstgldeinterlace.c: In function ‘gst_gl_deinterlace_greedyh_callback’:
gstgldeinterlace.c:476:47: error: passing argument 1 of ‘gst_gl_deinterlace_get_fragment_shader’ from incompatible pointer type [-Werror=incompatible-pointer-types]
       gst_gl_deinterlace_get_fragment_shader (deinterlace_filter, "greedhy",
                                               ^
gstgldeinterlace.c:393:1: note: expected ‘GstGLFilter * {aka struct _GstGLFilter *}’ but argument is of type ‘GstGLDeinterlace * {aka struct _GstGLDeinterlace *}’
 gst_gl_deinterlace_get_fragment_shader (GstGLFilter * filter,
 ^

::: ext/gl/gstgldeinterlace.h
@@ +41,3 @@
+
+  GLCB	       deinterlacefunc; 
+  GHashTable   *shaderstable;

Why are you using a hash table?
Comment 11 Haihua Hu 2016-04-27 08:29:59 UTC
(In reply to Matthew Waters (ystreet00) from comment #10)
> Review of attachment 325838 [details] [review] [review]:
> 
> This doesn't seem to apply cleanly to latest master.
> 
> After modifying the patch to apply, it also doesn't compile with opengl
> enabled and -Werror enabled.
> 
> gstgldeinterlace.c: In function ‘gst_gl_deinterlace_vfir_callback’:
> gstgldeinterlace.c:437:52: error: passing argument 1 of
> ‘gst_gl_deinterlace_get_fragment_shader’ from incompatible pointer type
> [-Werror=incompatible-pointer-types]
>    shader = gst_gl_deinterlace_get_fragment_shader (deinterlace_filter,
> "vfir",
>                                                     ^
> gstgldeinterlace.c:393:1: note: expected ‘GstGLFilter * {aka struct
> _GstGLFilter *}’ but argument is of type ‘GstGLDeinterlace * {aka struct
> _GstGLDeinterlace *}’
>  gst_gl_deinterlace_get_fragment_shader (GstGLFilter * filter,
>  ^
> gstgldeinterlace.c:444:7: error: implicit declaration of function
> ‘USING_OPENGL’ [-Werror=implicit-function-declaration]
>    if (USING_OPENGL (context)) {
>        ^
> gstgldeinterlace.c:444:3: error: nested extern declaration of ‘USING_OPENGL’
> [-Werror=nested-externs]
>    if (USING_OPENGL (context)) {
>    ^
> gstgldeinterlace.c: In function ‘gst_gl_deinterlace_greedyh_callback’:
> gstgldeinterlace.c:476:47: error: passing argument 1 of
> ‘gst_gl_deinterlace_get_fragment_shader’ from incompatible pointer type
> [-Werror=incompatible-pointer-types]
>        gst_gl_deinterlace_get_fragment_shader (deinterlace_filter, "greedhy",
>                                                ^
> gstgldeinterlace.c:393:1: note: expected ‘GstGLFilter * {aka struct
> _GstGLFilter *}’ but argument is of type ‘GstGLDeinterlace * {aka struct
> _GstGLDeinterlace *}’
>  gst_gl_deinterlace_get_fragment_shader (GstGLFilter * filter,
>  ^
> 
> ::: ext/gl/gstgldeinterlace.h
> @@ +41,3 @@
> +
> +  GLCB	       deinterlacefunc; 
> +  GHashTable   *shaderstable;
> 
> Why are you using a hash table?

Sorry for my mistake:

I forgot to declare USING_OPENGL in gstgldeinterlace.h and the function first argument of gst_gl_deinterlace_get_fragment_shader is wrong, I will update this patch immediately.

Use a hash table to store shader we create. We only need to create the shader when first time to run, it will allow us to switch deinterlace  shader at run time without create it again
Comment 12 Haihua Hu 2016-04-27 09:16:37 UTC
Created attachment 326848 [details] [review]
correct patch coding error
Comment 13 Matthew Waters (ystreet00) 2016-04-29 11:36:49 UTC
Thanks!

commit 0cfb0890ce9a20f096a0a9c9f23b656f436794c6
Author: Haihua Hu <jared.hu@nxp.com>
Date:   Fri Apr 8 16:47:15 2016 +0800

    gl: enable gldeinterlace on OpenGL ES
    
    1.Porting the exist deinterlace shader and OpenGL callback
      to be compatible with OpenGL ES.
    2.Add a our blur vertical shader to gldeinterlace.
    3.Add a property named “method” to let user choose which
      deinterlace function to use. Default to choose blur vertical
      method for better performance.
    
    [Matthew Waters]: fix name of greedyh in method property (was greedhy) and port
    to git master.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764873
Comment 14 Matthew Waters (ystreet00) 2016-09-27 06:11:24 UTC
*** Bug 747232 has been marked as a duplicate of this bug. ***