[310/906] Global reindent
authorDavid Schleef <ds@schleef.org>
Wed, 11 Feb 2009 06:39:14 +0000 (22:39 -0800)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:21 +0000 (19:31 +0000)
Indent parameters:
INDENT_PARAMETERS="--braces-on-if-line \
        --case-brace-indentation0 \
        --case-indentation2 \
        --braces-after-struct-decl-line \
        --line-length80 \
        --no-tabs \
        --cuddle-else \
        --dont-line-up-parentheses \
        --honour-newlines \
        --continuation-indentation4 \
        --tab-size8 \
        --indent-level2"

gst-libs/gst/gl/gstglbuffer.c
gst-libs/gst/gl/gstgldisplay.c
gst-libs/gst/gl/gstglfilter.c
gst-libs/gst/gl/gstglshader.c
gst-libs/gst/gl/gstglwindow_win32.c
gst-libs/gst/gl/gstglwindow_x11.c

index 31e1456..8df84bb 100644 (file)
 
 #include "gstglbuffer.h"
 
-static GObjectClassgst_gl_buffer_parent_class;
+static GObjectClass *gst_gl_buffer_parent_class;
 
 static void
-gst_gl_buffer_finalize (GstGLBuffer* buffer)
+gst_gl_buffer_finalize (GstGLBuffer * buffer)
 {
-    //blocking call, put the texture in the pool
-    gst_gl_display_del_texture (buffer->display, buffer->texture,
+  //blocking call, put the texture in the pool
+  gst_gl_display_del_texture (buffer->display, buffer->texture,
       buffer->width, buffer->height);
 
-    g_object_unref (buffer->display);
+  g_object_unref (buffer->display);
 
-    GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->
-           finalize (GST_MINI_OBJECT (buffer));
+  GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->finalize (GST_MINI_OBJECT
+      (buffer));
 }
 
 static void
-gst_gl_buffer_init (GstGLBuffer* buffer, gpointer g_class)
+gst_gl_buffer_init (GstGLBuffer * buffer, gpointer g_class)
 {
-    buffer->display = NULL;
+  buffer->display = NULL;
 
-    buffer->width = 0;
-    buffer->height = 0;
-    buffer->texture = 0;
+  buffer->width = 0;
+  buffer->height = 0;
+  buffer->texture = 0;
 }
 
 static void
 gst_gl_buffer_class_init (gpointer g_class, gpointer class_data)
 {
-    GstMiniObjectClass* mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
+  GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
 
-    gst_gl_buffer_parent_class = g_type_class_peek_parent (g_class);
+  gst_gl_buffer_parent_class = g_type_class_peek_parent (g_class);
 
-    mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
-        gst_gl_buffer_finalize;
+  mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
+      gst_gl_buffer_finalize;
 }
 
 
@@ -87,47 +87,48 @@ gst_gl_buffer_get_type (void)
 }
 
 
-GstGLBuffer*
-gst_gl_buffer_new (GstGLDisplay* display,
-    gint gl_width, gint gl_height)
+GstGLBuffer *
+gst_gl_buffer_new (GstGLDisplay * display, gint gl_width, gint gl_height)
 {
-    GstGLBuffer* gl_buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
+  GstGLBuffer *gl_buffer =
+      (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
 
-    gl_buffer->display = g_object_ref (display);
-    gl_buffer->width = gl_width;
-    gl_buffer->height = gl_height;
+  gl_buffer->display = g_object_ref (display);
+  gl_buffer->width = gl_width;
+  gl_buffer->height = gl_height;
 
-    //it does not depends on the video format because gl buffer has always one texture.
-    //the one attached to the upload FBO
-    GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height);
+  //it does not depends on the video format because gl buffer has always one texture.
+  //the one attached to the upload FBO
+  GST_BUFFER_SIZE (gl_buffer) = gst_gl_buffer_get_size (gl_width, gl_height);
 
-    //blocking call, generate a texture using the pool
-    gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width, gl_height) ;
+  //blocking call, generate a texture using the pool
+  gst_gl_display_gen_texture (gl_buffer->display, &gl_buffer->texture, gl_width,
+      gl_height);
 
-    return gl_buffer;
+  return gl_buffer;
 }
 
 
 gint
 gst_gl_buffer_get_size (gint width, gint height)
 {
-    //this is not strictly true, but it's used for compatibility with
-    //queue and BaseTransform
-    return width * height * 4;
+  //this is not strictly true, but it's used for compatibility with
+  //queue and BaseTransform
+  return width * height * 4;
 }
 
 
 gboolean
-gst_gl_buffer_parse_caps (GstCaps* caps, gint* width, gint* height)
+gst_gl_buffer_parse_caps (GstCaps * caps, gint * width, gint * height)
 {
-    GstStructure* structure = gst_caps_get_structure (caps, 0);
-    gboolean ret = gst_structure_has_name (structure, "video/x-raw-gl");
+  GstStructure *structure = gst_caps_get_structure (caps, 0);
+  gboolean ret = gst_structure_has_name (structure, "video/x-raw-gl");
 
-    if (!ret)
-        return ret;
+  if (!ret)
+    return ret;
 
-    ret = gst_structure_get_int (structure, "width", width);
-    ret &= gst_structure_get_int (structure, "height", height);
+  ret = gst_structure_get_int (structure, "width", width);
+  ret &= gst_structure_get_int (structure, "height", height);
 
-    return ret;
+  return ret;
 }
index a848e24..e250117 100644 (file)
@@ -41,44 +41,48 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
 #define DEBUG_INIT(bla) \
   GST_DEBUG_CATEGORY_INIT (gst_gl_display_debug, "gldisplay", 0, "opengl display");
 
-GST_BOILERPLATE_FULL (GstGLDisplay, gst_gl_display, GObject, G_TYPE_OBJECT, DEBUG_INIT);
-static void gst_gl_display_finalize (GObject* object);
+GST_BOILERPLATE_FULL (GstGLDisplay, gst_gl_display, GObject, G_TYPE_OBJECT,
+    DEBUG_INIT);
+static void gst_gl_display_finalize (GObject * object);
 
 /* Called in the gl thread, protected by lock and unlock */
-gpointer gst_gl_display_thread_create_context (GstGLDisplay* display);
-void gst_gl_display_thread_destroy_context (GstGLDisplay* display);
-void gst_gl_display_thread_run_generic (GstGLDisplay *display);
-void gst_gl_display_thread_gen_texture (GstGLDisplay* display);
-void gst_gl_display_thread_del_texture (GstGLDisplay* display);
-void gst_gl_display_thread_init_upload (GstGLDisplay* display);
-void gst_gl_display_thread_do_upload (GstGLDisplay* display);
-void gst_gl_display_thread_init_download (GstGLDisplay *display);
-void gst_gl_display_thread_do_download (GstGLDisplay* display);
-void gst_gl_display_thread_gen_fbo (GstGLDisplay *display);
-void gst_gl_display_thread_use_fbo (GstGLDisplay *display);
-void gst_gl_display_thread_del_fbo (GstGLDisplay *display);
-void gst_gl_display_thread_gen_shader (GstGLDisplay *display);
-void gst_gl_display_thread_del_shader (GstGLDisplay *display);
+gpointer gst_gl_display_thread_create_context (GstGLDisplay * display);
+void gst_gl_display_thread_destroy_context (GstGLDisplay * display);
+void gst_gl_display_thread_run_generic (GstGLDisplay * display);
+void gst_gl_display_thread_gen_texture (GstGLDisplay * display);
+void gst_gl_display_thread_del_texture (GstGLDisplay * display);
+void gst_gl_display_thread_init_upload (GstGLDisplay * display);
+void gst_gl_display_thread_do_upload (GstGLDisplay * display);
+void gst_gl_display_thread_init_download (GstGLDisplay * display);
+void gst_gl_display_thread_do_download (GstGLDisplay * display);
+void gst_gl_display_thread_gen_fbo (GstGLDisplay * display);
+void gst_gl_display_thread_use_fbo (GstGLDisplay * display);
+void gst_gl_display_thread_del_fbo (GstGLDisplay * display);
+void gst_gl_display_thread_gen_shader (GstGLDisplay * display);
+void gst_gl_display_thread_del_shader (GstGLDisplay * display);
 
 /* private methods */
-void gst_gl_display_lock (GstGLDisplay* display);
-void gst_gl_display_unlock (GstGLDisplay* display);
-void gst_gl_display_on_resize(GstGLDisplay* display, gint width, gint height);
-void gst_gl_display_on_draw (GstGLDisplay* display);
-void gst_gl_display_on_close (GstGLDisplay* display);
-void gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture, GLint width, GLint height);
-void gst_gl_display_gldel_texture (GstGLDisplay* display, GLuint* pTexture, GLint width, GLint height);
-gboolean gst_gl_display_texture_pool_func_clean (gpointer key, gpointer value, gpointer data);
+void gst_gl_display_lock (GstGLDisplay * display);
+void gst_gl_display_unlock (GstGLDisplay * display);
+void gst_gl_display_on_resize (GstGLDisplay * display, gint width, gint height);
+void gst_gl_display_on_draw (GstGLDisplay * display);
+void gst_gl_display_on_close (GstGLDisplay * display);
+void gst_gl_display_glgen_texture (GstGLDisplay * display, GLuint * pTexture,
+    GLint width, GLint height);
+void gst_gl_display_gldel_texture (GstGLDisplay * display, GLuint * pTexture,
+    GLint width, GLint height);
+gboolean gst_gl_display_texture_pool_func_clean (gpointer key, gpointer value,
+    gpointer data);
 void gst_gl_display_check_framebuffer_status (void);
 
 /* To not make gst_gl_display_thread_do_upload
  * and gst_gl_display_thread_do_download too big */
-void gst_gl_display_thread_init_upload_fbo (GstGLDisplay *display);
-void gst_gl_display_thread_do_upload_make (GstGLDisplay *display);
-void gst_gl_display_thread_do_upload_fill (GstGLDisplay *display);
-void gst_gl_display_thread_do_upload_draw (GstGLDisplay *display);
-void gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay *display);
-void gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay *display);
+void gst_gl_display_thread_init_upload_fbo (GstGLDisplay * display);
+void gst_gl_display_thread_do_upload_make (GstGLDisplay * display);
+void gst_gl_display_thread_do_upload_fill (GstGLDisplay * display);
+void gst_gl_display_thread_do_upload_draw (GstGLDisplay * display);
+void gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display);
+void gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display);
 
 
 //------------------------------------------------------------
@@ -98,7 +102,7 @@ gst_gl_display_class_init (GstGLDisplayClass * klass)
 
 
 static void
-gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
+gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
 {
   //thread safe
   display->mutex = g_mutex_new ();
@@ -208,139 +212,126 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
   //YUY2:r,g,a
   //UYVY:a,b,r
   display->text_shader_upload_YUY2_UYVY =
-    "#extension GL_ARB_texture_rectangle : enable\n"
-    "uniform sampler2DRect Ytex, UVtex;\n"
-    "void main(void) {\n"
-    "  float fx, fy, y, u, v, r, g, b;\n"
-    "  fx   = gl_TexCoord[0].x;\n"
-    "  fy   = gl_TexCoord[0].y;\n"
-    "  y = texture2DRect(Ytex,vec2(fx,fy)).%c;\n"
-    "  u = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
-    "  v = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
-    "  y=1.164*(y-0.0627);\n"
-    "  u=u-0.5;\n"
-    "  v=v-0.5;\n"
-    "  r = y+1.5958*v;\n"
-    "  g = y-0.39173*u-0.81290*v;\n"
-    "  b = y+2.017*u;\n"
-    "  gl_FragColor = vec4(r, g, b, 1.0);\n"
-    "}\n";
+      "#extension GL_ARB_texture_rectangle : enable\n"
+      "uniform sampler2DRect Ytex, UVtex;\n"
+      "void main(void) {\n"
+      "  float fx, fy, y, u, v, r, g, b;\n"
+      "  fx   = gl_TexCoord[0].x;\n"
+      "  fy   = gl_TexCoord[0].y;\n"
+      "  y = texture2DRect(Ytex,vec2(fx,fy)).%c;\n"
+      "  u = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
+      "  v = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
+      "  y=1.164*(y-0.0627);\n"
+      "  u=u-0.5;\n"
+      "  v=v-0.5;\n"
+      "  r = y+1.5958*v;\n"
+      "  g = y-0.39173*u-0.81290*v;\n"
+      "  b = y+2.017*u;\n" "  gl_FragColor = vec4(r, g, b, 1.0);\n" "}\n";
 
   //ATI: "*0.5", ""
   //normal: "", "*0.5"
   display->text_shader_upload_I420_YV12 =
-    "#extension GL_ARB_texture_rectangle : enable\n"
-    "uniform sampler2DRect Ytex,Utex,Vtex;\n"
-    "void main(void) {\n"
-    "  float r,g,b,y,u,v;\n"
-    "  vec2 nxy=gl_TexCoord[0].xy;\n"
-    "  y=texture2DRect(Ytex,nxy%s).r;\n"
-    "  u=texture2DRect(Utex,nxy%s).r;\n"
-    "  v=texture2DRect(Vtex,nxy*0.5).r;\n"
-    "  y=1.1643*(y-0.0625);\n"
-    "  u=u-0.5;\n"
-    "  v=v-0.5;\n"
-    "  r=y+1.5958*v;\n"
-    "  g=y-0.39173*u-0.81290*v;\n"
-    "  b=y+2.017*u;\n"
-    "  gl_FragColor=vec4(r,g,b,1.0);\n"
-    "}\n";
+      "#extension GL_ARB_texture_rectangle : enable\n"
+      "uniform sampler2DRect Ytex,Utex,Vtex;\n"
+      "void main(void) {\n"
+      "  float r,g,b,y,u,v;\n"
+      "  vec2 nxy=gl_TexCoord[0].xy;\n"
+      "  y=texture2DRect(Ytex,nxy%s).r;\n"
+      "  u=texture2DRect(Utex,nxy%s).r;\n"
+      "  v=texture2DRect(Vtex,nxy*0.5).r;\n"
+      "  y=1.1643*(y-0.0625);\n"
+      "  u=u-0.5;\n"
+      "  v=v-0.5;\n"
+      "  r=y+1.5958*v;\n"
+      "  g=y-0.39173*u-0.81290*v;\n"
+      "  b=y+2.017*u;\n" "  gl_FragColor=vec4(r,g,b,1.0);\n" "}\n";
 
   display->text_shader_upload_AYUV =
-    "#extension GL_ARB_texture_rectangle : enable\n"
-    "uniform sampler2DRect tex;\n"
-    "void main(void) {\n"
-    "  float r,g,b,y,u,v;\n"
-    "  vec2 nxy=gl_TexCoord[0].xy;\n"
-    "  y=texture2DRect(tex,nxy).r;\n"
-    "  u=texture2DRect(tex,nxy).g;\n"
-    "  v=texture2DRect(tex,nxy).b;\n"
-    "  y=1.1643*(y-0.0625);\n"
-    "  u=u-0.5;\n"
-    "  v=v-0.5;\n"
-    "  r=clamp(y+1.5958*v, 0, 1);\n"
-    "  g=clamp(y-0.39173*u-0.81290*v, 0, 1);\n"
-    "  b=clamp(y+2.017*u, 0, 1);\n"
-    "  gl_FragColor=vec4(r,g,b,1.0);\n"
-    "}\n";
+      "#extension GL_ARB_texture_rectangle : enable\n"
+      "uniform sampler2DRect tex;\n"
+      "void main(void) {\n"
+      "  float r,g,b,y,u,v;\n"
+      "  vec2 nxy=gl_TexCoord[0].xy;\n"
+      "  y=texture2DRect(tex,nxy).r;\n"
+      "  u=texture2DRect(tex,nxy).g;\n"
+      "  v=texture2DRect(tex,nxy).b;\n"
+      "  y=1.1643*(y-0.0625);\n"
+      "  u=u-0.5;\n"
+      "  v=v-0.5;\n"
+      "  r=clamp(y+1.5958*v, 0, 1);\n"
+      "  g=clamp(y-0.39173*u-0.81290*v, 0, 1);\n"
+      "  b=clamp(y+2.017*u, 0, 1);\n" "  gl_FragColor=vec4(r,g,b,1.0);\n" "}\n";
 
   //YUY2:y2,u,y1,v
   //UYVY:v,y1,u,y2
   display->text_shader_download_YUY2_UYVY =
-    "#extension GL_ARB_texture_rectangle : enable\n"
-    "uniform sampler2DRect tex;\n"
-    "void main(void) {\n"
-    "  float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;\n"
-    "  fx = gl_TexCoord[0].x;\n"
-    "  fy = gl_TexCoord[0].y;\n"
-    "  r=texture2DRect(tex,vec2(fx*2.0,fy)).r;\n"
-    "  g=texture2DRect(tex,vec2(fx*2.0,fy)).g;\n"
-    "  b=texture2DRect(tex,vec2(fx*2.0,fy)).b;\n"
-    "  r2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).r;\n"
-    "  g2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).g;\n"
-    "  b2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).b;\n"
-    "  y1=0.299011*r + 0.586987*g + 0.114001*b;\n"
-    "  y2=0.299011*r2 + 0.586987*g2 + 0.114001*b2;\n"
-    "  u=-0.148246*r -0.29102*g + 0.439266*b;\n"
-    "  v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
-    "  y1=0.858885*y1 + 0.0625;\n"
-    "  y2=0.858885*y2 + 0.0625;\n"
-    "  u=u + 0.5;\n"
-    "  v=v + 0.5;\n"
-    "  gl_FragColor=vec4(%s);\n"
-    "}\n";
+      "#extension GL_ARB_texture_rectangle : enable\n"
+      "uniform sampler2DRect tex;\n"
+      "void main(void) {\n"
+      "  float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;\n"
+      "  fx = gl_TexCoord[0].x;\n"
+      "  fy = gl_TexCoord[0].y;\n"
+      "  r=texture2DRect(tex,vec2(fx*2.0,fy)).r;\n"
+      "  g=texture2DRect(tex,vec2(fx*2.0,fy)).g;\n"
+      "  b=texture2DRect(tex,vec2(fx*2.0,fy)).b;\n"
+      "  r2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).r;\n"
+      "  g2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).g;\n"
+      "  b2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).b;\n"
+      "  y1=0.299011*r + 0.586987*g + 0.114001*b;\n"
+      "  y2=0.299011*r2 + 0.586987*g2 + 0.114001*b2;\n"
+      "  u=-0.148246*r -0.29102*g + 0.439266*b;\n"
+      "  v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
+      "  y1=0.858885*y1 + 0.0625;\n"
+      "  y2=0.858885*y2 + 0.0625;\n"
+      "  u=u + 0.5;\n" "  v=v + 0.5;\n" "  gl_FragColor=vec4(%s);\n" "}\n";
 
   display->text_shader_download_I420_YV12 =
-    "#extension GL_ARB_texture_rectangle : enable\n"
-    "uniform sampler2DRect tex;\n"
-    "uniform float w, h;\n"
-    "void main(void) {\n"
-    "  float r,g,b,r2,b2,g2,y,u,v;\n"
-    "  vec2 nxy=gl_TexCoord[0].xy;\n"
-    "  vec2 nxy2=mod(2.0*nxy, vec2(w, h));\n"
-    "  r=texture2DRect(tex,nxy).r;\n"
-    "  g=texture2DRect(tex,nxy).g;\n"
-    "  b=texture2DRect(tex,nxy).b;\n"
-    "  r2=texture2DRect(tex,nxy2).r;\n"
-    "  g2=texture2DRect(tex,nxy2).g;\n"
-    "  b2=texture2DRect(tex,nxy2).b;\n"
-    "  y=0.299011*r + 0.586987*g + 0.114001*b;\n"
-    "  u=-0.148246*r2 -0.29102*g2 + 0.439266*b2;\n"
-    "  v=0.439271*r2 - 0.367833*g2 - 0.071438*b2 ;\n"
-    "  y=0.858885*y + 0.0625;\n"
-    "  u=u + 0.5;\n"
-    "  v=v + 0.5;\n"
-    "  gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);\n"
-    "  gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);\n"
-    "  gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);\n"
-    "}\n";
+      "#extension GL_ARB_texture_rectangle : enable\n"
+      "uniform sampler2DRect tex;\n"
+      "uniform float w, h;\n"
+      "void main(void) {\n"
+      "  float r,g,b,r2,b2,g2,y,u,v;\n"
+      "  vec2 nxy=gl_TexCoord[0].xy;\n"
+      "  vec2 nxy2=mod(2.0*nxy, vec2(w, h));\n"
+      "  r=texture2DRect(tex,nxy).r;\n"
+      "  g=texture2DRect(tex,nxy).g;\n"
+      "  b=texture2DRect(tex,nxy).b;\n"
+      "  r2=texture2DRect(tex,nxy2).r;\n"
+      "  g2=texture2DRect(tex,nxy2).g;\n"
+      "  b2=texture2DRect(tex,nxy2).b;\n"
+      "  y=0.299011*r + 0.586987*g + 0.114001*b;\n"
+      "  u=-0.148246*r2 -0.29102*g2 + 0.439266*b2;\n"
+      "  v=0.439271*r2 - 0.367833*g2 - 0.071438*b2 ;\n"
+      "  y=0.858885*y + 0.0625;\n"
+      "  u=u + 0.5;\n"
+      "  v=v + 0.5;\n"
+      "  gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);\n"
+      "  gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);\n"
+      "  gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);\n" "}\n";
 
   display->text_shader_download_AYUV =
-    "#extension GL_ARB_texture_rectangle : enable\n"
-    "uniform sampler2DRect tex;\n"
-    "void main(void) {\n"
-    "  float r,g,b,y,u,v;\n"
-    "  vec2 nxy=gl_TexCoord[0].xy;\n"
-    "  r=texture2DRect(tex,nxy).r;\n"
-    "  g=texture2DRect(tex,nxy).g;\n"
-    "  b=texture2DRect(tex,nxy).b;\n"
-    "  y=0.299011*r + 0.586987*g + 0.114001*b;\n"
-    "  u=-0.148246*r -0.29102*g + 0.439266*b;\n"
-    "  v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
-    "  y=0.858885*y + 0.0625;\n"
-    "  u=u + 0.5;\n"
-    "  v=v + 0.5;\n"
-    "  gl_FragColor=vec4(y,u,v,1.0);\n"
-    "}\n";
+      "#extension GL_ARB_texture_rectangle : enable\n"
+      "uniform sampler2DRect tex;\n"
+      "void main(void) {\n"
+      "  float r,g,b,y,u,v;\n"
+      "  vec2 nxy=gl_TexCoord[0].xy;\n"
+      "  r=texture2DRect(tex,nxy).r;\n"
+      "  g=texture2DRect(tex,nxy).g;\n"
+      "  b=texture2DRect(tex,nxy).b;\n"
+      "  y=0.299011*r + 0.586987*g + 0.114001*b;\n"
+      "  u=-0.148246*r -0.29102*g + 0.439266*b;\n"
+      "  v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
+      "  y=0.858885*y + 0.0625;\n"
+      "  u=u + 0.5;\n"
+      "  v=v + 0.5;\n" "  gl_FragColor=vec4(y,u,v,1.0);\n" "}\n";
 }
 
 static void
-gst_gl_display_finalize (GObject* object)
+gst_gl_display_finalize (GObject * object)
 {
-  GstGLDisplaydisplay = GST_GL_DISPLAY (object);
+  GstGLDisplay *display = GST_GL_DISPLAY (object);
 
-  if (display->mutex && display->gl_window)
-  {
+  if (display->mutex && display->gl_window) {
 
     gst_gl_display_lock (display);
 
@@ -350,7 +341,8 @@ gst_gl_display_finalize (GObject* object)
 
     GST_INFO ("send quit gl window loop");
 
-    gst_gl_window_quit_loop (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_destroy_context), display);
+    gst_gl_window_quit_loop (display->gl_window,
+        GST_GL_WINDOW_CB (gst_gl_display_thread_destroy_context), display);
 
     GST_INFO ("quit sent to gl window loop");
 
@@ -359,8 +351,7 @@ gst_gl_display_finalize (GObject* object)
     gst_gl_display_unlock (display);
   }
 
-  if (display->gl_thread)
-  {
+  if (display->gl_thread) {
     gpointer ret = g_thread_join (display->gl_thread);
     GST_INFO ("gl thread joined");
     if (ret != NULL)
@@ -404,14 +395,14 @@ gst_gl_display_finalize (GObject* object)
 
 /* Called in the gl thread */
 gpointer
-gst_gl_display_thread_create_context (GstGLDisplay *display)
+gst_gl_display_thread_create_context (GstGLDisplay * display)
 {
   GLenum err = 0;
 
-  display->gl_window = gst_gl_window_new (display->upload_width, display->upload_height);
+  display->gl_window =
+      gst_gl_window_new (display->upload_width, display->upload_height);
 
-  if (!display->gl_window)
-  {
+  if (!display->gl_window) {
     display->isAlive = FALSE;
     GST_ERROR_OBJECT (display, "Failed to create gl window");
     g_cond_signal (display->cond_create_context);
@@ -421,26 +412,27 @@ gst_gl_display_thread_create_context (GstGLDisplay *display)
   GST_INFO ("gl window created");
 
   //Init glew
-  err = glewInit();
-  if (err != GLEW_OK)
-  {
+  err = glewInit ();
+  if (err != GLEW_OK) {
     GST_ERROR_OBJECT (display, "Failed to init GLEW: %s",
-      glewGetErrorString (err));
+        glewGetErrorString (err));
     display->isAlive = FALSE;
-  }
-  else
-  {
+  } else {
     //OpenGL > 1.2.0 and Glew > 1.4.0
-    GString* opengl_version = g_string_truncate (g_string_new ((gchar*) glGetString (GL_VERSION)), 3);
+    GString *opengl_version =
+        g_string_truncate (g_string_new ((gchar *) glGetString (GL_VERSION)),
+        3);
     gint opengl_version_major = 0;
     gint opengl_version_minor = 0;
 
-    sscanf(opengl_version->str, "%d.%d", &opengl_version_major, &opengl_version_minor);
+    sscanf (opengl_version->str, "%d.%d", &opengl_version_major,
+        &opengl_version_minor);
 
     GST_INFO ("GL_VERSION: %s", glGetString (GL_VERSION));
     GST_INFO ("GLEW_VERSION: %s", glewGetString (GLEW_VERSION));
     if (glGetString (GL_SHADING_LANGUAGE_VERSION))
-      GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s", glGetString (GL_SHADING_LANGUAGE_VERSION));
+      GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s",
+          glGetString (GL_SHADING_LANGUAGE_VERSION));
     else
       GST_INFO ("Your driver does not support GLSL (OpenGL Shading Language)");
 
@@ -450,10 +442,10 @@ gst_gl_display_thread_create_context (GstGLDisplay *display)
     g_string_free (opengl_version, TRUE);
 
     if ((opengl_version_major < 1) ||
-        (GLEW_VERSION_MAJOR   < 1) ||
-        (opengl_version_major < 2 && opengl_version_major >= 1 && opengl_version_minor < 2) ||
-        (GLEW_VERSION_MAJOR   < 2 && GLEW_VERSION_MAJOR   >= 1 && GLEW_VERSION_MINOR   < 4) )
-    {
+        (GLEW_VERSION_MAJOR < 1) ||
+        (opengl_version_major < 2 && opengl_version_major >= 1
+            && opengl_version_minor < 2) || (GLEW_VERSION_MAJOR < 2
+            && GLEW_VERSION_MAJOR >= 1 && GLEW_VERSION_MINOR < 4)) {
       //turn off the pipeline, the old drivers are not yet supported
       GST_WARNING ("Required OpenGL >= 1.2.0 and Glew >= 1.4.0");
       display->isAlive = FALSE;
@@ -461,9 +453,12 @@ gst_gl_display_thread_create_context (GstGLDisplay *display)
   }
 
   //setup callbacks
-  gst_gl_window_set_resize_callback (display->gl_window, GST_GL_WINDOW_CB2 (gst_gl_display_on_resize), display);
-  gst_gl_window_set_draw_callback (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_on_draw), display);
-  gst_gl_window_set_close_callback (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_on_close), display);
+  gst_gl_window_set_resize_callback (display->gl_window,
+      GST_GL_WINDOW_CB2 (gst_gl_display_on_resize), display);
+  gst_gl_window_set_draw_callback (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_on_draw), display);
+  gst_gl_window_set_close_callback (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_on_close), display);
 
   g_cond_signal (display->cond_create_context);
 
@@ -489,110 +484,91 @@ gst_gl_display_thread_create_context (GstGLDisplay *display)
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_destroy_context (GstGLDisplay *display)
+gst_gl_display_thread_destroy_context (GstGLDisplay * display)
 {
   //colorspace_conversion specific
-  switch (display->upload_colorspace_conversion)
-  {
-  case GST_GL_DISPLAY_CONVERSION_MESA:
-  case GST_GL_DISPLAY_CONVERSION_MATRIX:
-    break;
-  case GST_GL_DISPLAY_CONVERSION_GLSL:
-  {
-    glUseProgramObjectARB (0);
-    if (display->shader_upload_YUY2)
-    {
-      g_object_unref (G_OBJECT (display->shader_upload_YUY2));
-      display->shader_upload_YUY2 = NULL;
-    }
-    if (display->shader_upload_UYVY)
-    {
-      g_object_unref (G_OBJECT (display->shader_upload_UYVY));
-      display->shader_upload_UYVY = NULL;
-    }
-    if (display->shader_upload_I420_YV12)
-    {
-      g_object_unref (G_OBJECT (display->shader_upload_I420_YV12));
-      display->shader_upload_I420_YV12 = NULL;
-    }
-    if (display->shader_upload_AYUV)
-    {
-      g_object_unref (G_OBJECT (display->shader_upload_AYUV));
-      display->shader_upload_AYUV = NULL;
-    }
-    if (display->shader_download_YUY2)
-    {
-      g_object_unref (G_OBJECT (display->shader_download_YUY2));
-      display->shader_download_YUY2 = NULL;
-    }
-    if (display->shader_download_UYVY)
-    {
-      g_object_unref (G_OBJECT (display->shader_download_UYVY));
-      display->shader_download_UYVY = NULL;
-    }
-    if (display->shader_download_I420_YV12)
-    {
-      g_object_unref (G_OBJECT (display->shader_download_I420_YV12));
-      display->shader_download_I420_YV12 = NULL;
-    }
-    if (display->shader_download_AYUV)
+  switch (display->upload_colorspace_conversion) {
+    case GST_GL_DISPLAY_CONVERSION_MESA:
+    case GST_GL_DISPLAY_CONVERSION_MATRIX:
+      break;
+    case GST_GL_DISPLAY_CONVERSION_GLSL:
     {
-      g_object_unref (G_OBJECT (display->shader_download_AYUV));
-      display->shader_download_AYUV = NULL;
+      glUseProgramObjectARB (0);
+      if (display->shader_upload_YUY2) {
+        g_object_unref (G_OBJECT (display->shader_upload_YUY2));
+        display->shader_upload_YUY2 = NULL;
+      }
+      if (display->shader_upload_UYVY) {
+        g_object_unref (G_OBJECT (display->shader_upload_UYVY));
+        display->shader_upload_UYVY = NULL;
+      }
+      if (display->shader_upload_I420_YV12) {
+        g_object_unref (G_OBJECT (display->shader_upload_I420_YV12));
+        display->shader_upload_I420_YV12 = NULL;
+      }
+      if (display->shader_upload_AYUV) {
+        g_object_unref (G_OBJECT (display->shader_upload_AYUV));
+        display->shader_upload_AYUV = NULL;
+      }
+      if (display->shader_download_YUY2) {
+        g_object_unref (G_OBJECT (display->shader_download_YUY2));
+        display->shader_download_YUY2 = NULL;
+      }
+      if (display->shader_download_UYVY) {
+        g_object_unref (G_OBJECT (display->shader_download_UYVY));
+        display->shader_download_UYVY = NULL;
+      }
+      if (display->shader_download_I420_YV12) {
+        g_object_unref (G_OBJECT (display->shader_download_I420_YV12));
+        display->shader_download_I420_YV12 = NULL;
+      }
+      if (display->shader_download_AYUV) {
+        g_object_unref (G_OBJECT (display->shader_download_AYUV));
+        display->shader_download_AYUV = NULL;
+      }
     }
-  }
-  break;
-  default:
-    g_assert_not_reached ();
+      break;
+    default:
+      g_assert_not_reached ();
   }
 
-  if (display->upload_fbo)
-  {
+  if (display->upload_fbo) {
     glDeleteFramebuffersEXT (1, &display->upload_fbo);
     display->upload_fbo = 0;
   }
-  if (display->upload_depth_buffer)
-  {
-    glDeleteRenderbuffersEXT(1, &display->upload_depth_buffer);
+  if (display->upload_depth_buffer) {
+    glDeleteRenderbuffersEXT (1, &display->upload_depth_buffer);
     display->upload_depth_buffer = 0;
   }
-  if (display->download_fbo)
-  {
+  if (display->download_fbo) {
     glDeleteFramebuffersEXT (1, &display->download_fbo);
     display->download_fbo = 0;
   }
-  if (display->download_depth_buffer)
-  {
-    glDeleteRenderbuffersEXT(1, &display->download_depth_buffer);
+  if (display->download_depth_buffer) {
+    glDeleteRenderbuffersEXT (1, &display->download_depth_buffer);
     display->download_depth_buffer = 0;
   }
-  if (display->download_texture)
-  {
+  if (display->download_texture) {
     glDeleteTextures (1, &display->download_texture);
     display->download_texture = 0;
   }
-  if (display->download_texture_u)
-  {
+  if (display->download_texture_u) {
     glDeleteTextures (1, &display->download_texture_u);
     display->download_texture_u = 0;
   }
-  if (display->download_texture_v)
-  {
+  if (display->download_texture_v) {
     glDeleteTextures (1, &display->download_texture_v);
     display->download_texture_v = 0;
   }
-  if (display->upload_intex != 0)
-  {
+  if (display->upload_intex != 0) {
     glDeleteTextures (1, &display->upload_intex);
     display->upload_intex = 0;
   }
-  if (display->upload_intex_u != 0)
-  {
+  if (display->upload_intex_u != 0) {
     glDeleteTextures (1, &display->upload_intex_u);
     display->upload_intex_u = 0;
   }
-  if (display->upload_intex_v != 0)
-  {
+  if (display->upload_intex_v != 0) {
     glDeleteTextures (1, &display->upload_intex_v);
     display->upload_intex_v = 0;
   }
@@ -600,15 +576,15 @@ gst_gl_display_thread_destroy_context (GstGLDisplay *display)
   GST_INFO ("Cleaning texture pool");
 
   //clean up the texture pool
-  g_hash_table_foreach_remove (display->texture_pool, gst_gl_display_texture_pool_func_clean,
-    NULL);
+  g_hash_table_foreach_remove (display->texture_pool,
+      gst_gl_display_texture_pool_func_clean, NULL);
 
   GST_INFO ("Context destroyed");
 }
 
 
 void
-gst_gl_display_thread_run_generic (GstGLDisplay *display)
+gst_gl_display_thread_run_generic (GstGLDisplay * display)
 {
   display->generic_callback (display, display->data);
 }
@@ -620,468 +596,476 @@ gst_gl_display_thread_gen_texture (GstGLDisplay * display)
 {
   //setup a texture to render to (this one will be in a gl buffer)
   gst_gl_display_glgen_texture (display, &display->gen_texture,
-    display->gen_texture_width, display->gen_texture_height);
+      display->gen_texture_width, display->gen_texture_height);
 }
 
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_del_texture (GstGLDisplay* display)
+gst_gl_display_thread_del_texture (GstGLDisplay * display)
 {
   gst_gl_display_gldel_texture (display, &display->del_texture,
-    display->del_texture_width, display->del_texture_height);
+      display->del_texture_width, display->del_texture_height);
 }
 
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_init_upload (GstGLDisplay *display)
+gst_gl_display_thread_init_upload (GstGLDisplay * display)
 {
-  switch (display->upload_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-    //color space conversion is not needed
-    //but if the size is different we need to redraw it
-    //using fbo
-    if (display->upload_width != display->upload_data_width ||
-        display->upload_height != display->upload_data_height)
-      gst_gl_display_thread_init_upload_fbo (display);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  case GST_VIDEO_FORMAT_AYUV:
-    //color space conversion is needed
-  {
-         //check if fragment shader is available, then load them
-    /* shouldn't we require ARB_shading_language_100? --Filippo */
-    if (GLEW_ARB_fragment_shader)
+  switch (display->upload_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      //color space conversion is not needed
+      //but if the size is different we need to redraw it
+      //using fbo
+      if (display->upload_width != display->upload_data_width ||
+          display->upload_height != display->upload_data_height)
+        gst_gl_display_thread_init_upload_fbo (display);
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    case GST_VIDEO_FORMAT_AYUV:
+      //color space conversion is needed
     {
-      GST_INFO ("Context, ARB_fragment_shader supported: yes");
+      //check if fragment shader is available, then load them
+      /* shouldn't we require ARB_shading_language_100? --Filippo */
+      if (GLEW_ARB_fragment_shader) {
+        GST_INFO ("Context, ARB_fragment_shader supported: yes");
 
-      display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_GLSL;
+        display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_GLSL;
 
-      gst_gl_display_thread_init_upload_fbo (display);
-      if (!display->isAlive)
-        break;
-
-      switch (display->upload_video_format)
-      {
-      case GST_VIDEO_FORMAT_YUY2:
-        {
-          gchar text_shader_upload_YUY2[2048];
-          sprintf (text_shader_upload_YUY2, display->text_shader_upload_YUY2_UYVY, 'r', 'g', 'a');
+        gst_gl_display_thread_init_upload_fbo (display);
+        if (!display->isAlive)
+          break;
 
-          display->shader_upload_YUY2 = gst_gl_shader_new ();
-          if(!gst_gl_shader_compile_and_check (display->shader_upload_YUY2,
-                       text_shader_upload_YUY2, GST_GL_SHADER_FRAGMENT_SOURCE))
+        switch (display->upload_video_format) {
+          case GST_VIDEO_FORMAT_YUY2:
           {
-            display->isAlive = FALSE;
-            g_object_unref (G_OBJECT (display->shader_upload_YUY2));
-            display->shader_upload_YUY2 = NULL;
+            gchar text_shader_upload_YUY2[2048];
+            sprintf (text_shader_upload_YUY2,
+                display->text_shader_upload_YUY2_UYVY, 'r', 'g', 'a');
+
+            display->shader_upload_YUY2 = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check (display->shader_upload_YUY2,
+                    text_shader_upload_YUY2, GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_upload_YUY2));
+              display->shader_upload_YUY2 = NULL;
+            }
           }
-        }
-      break;
-      case GST_VIDEO_FORMAT_UYVY:
-        {
-          gchar text_shader_upload_UYVY[2048];
-          sprintf (text_shader_upload_UYVY, display->text_shader_upload_YUY2_UYVY, 'a', 'b', 'r');
-
-          display->shader_upload_UYVY = gst_gl_shader_new ();
-          if(!gst_gl_shader_compile_and_check (display->shader_upload_UYVY,
-                       text_shader_upload_UYVY, GST_GL_SHADER_FRAGMENT_SOURCE))
+            break;
+          case GST_VIDEO_FORMAT_UYVY:
           {
-            display->isAlive = FALSE;
-            g_object_unref (G_OBJECT (display->shader_upload_UYVY));
-            display->shader_upload_UYVY = NULL;
+            gchar text_shader_upload_UYVY[2048];
+            sprintf (text_shader_upload_UYVY,
+                display->text_shader_upload_YUY2_UYVY, 'a', 'b', 'r');
+
+            display->shader_upload_UYVY = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check (display->shader_upload_UYVY,
+                    text_shader_upload_UYVY, GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_upload_UYVY));
+              display->shader_upload_UYVY = NULL;
+            }
           }
-        }
-        break;
-      case GST_VIDEO_FORMAT_I420:
-      case GST_VIDEO_FORMAT_YV12:
-        {
-          gchar text_shader_upload_I420_YV12[2048];
-          if (g_ascii_strncasecmp ("ATI", (gchar *) glGetString (GL_VENDOR), 3) == 0)
-              sprintf (text_shader_upload_I420_YV12, display->text_shader_upload_I420_YV12, "*0.5", "");
-          else
-              sprintf (text_shader_upload_I420_YV12, display->text_shader_upload_I420_YV12, "", "*0.5");
-
-          display->shader_upload_I420_YV12 = gst_gl_shader_new ();
-          if(!gst_gl_shader_compile_and_check (display->shader_upload_I420_YV12,
-                       text_shader_upload_I420_YV12, GST_GL_SHADER_FRAGMENT_SOURCE))
+            break;
+          case GST_VIDEO_FORMAT_I420:
+          case GST_VIDEO_FORMAT_YV12:
           {
-            display->isAlive = FALSE;
-            g_object_unref (G_OBJECT (display->shader_upload_I420_YV12));
-            display->shader_upload_I420_YV12 = NULL;
+            gchar text_shader_upload_I420_YV12[2048];
+            if (g_ascii_strncasecmp ("ATI", (gchar *) glGetString (GL_VENDOR),
+                    3) == 0)
+              sprintf (text_shader_upload_I420_YV12,
+                  display->text_shader_upload_I420_YV12, "*0.5", "");
+            else
+              sprintf (text_shader_upload_I420_YV12,
+                  display->text_shader_upload_I420_YV12, "", "*0.5");
+
+            display->shader_upload_I420_YV12 = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check
+                (display->shader_upload_I420_YV12, text_shader_upload_I420_YV12,
+                    GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_upload_I420_YV12));
+              display->shader_upload_I420_YV12 = NULL;
+            }
           }
+            break;
+          case GST_VIDEO_FORMAT_AYUV:
+            display->shader_upload_AYUV = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check (display->shader_upload_AYUV,
+                    display->text_shader_upload_AYUV,
+                    GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_upload_AYUV));
+              display->shader_upload_AYUV = NULL;
+            }
+            break;
+          default:
+            g_assert_not_reached ();
         }
-        break;
-      case GST_VIDEO_FORMAT_AYUV:
-        display->shader_upload_AYUV = gst_gl_shader_new ();
-        if(!gst_gl_shader_compile_and_check (display->shader_upload_AYUV,
-                     display->text_shader_upload_AYUV, GST_GL_SHADER_FRAGMENT_SOURCE))
-        {
-          display->isAlive = FALSE;
-          g_object_unref (G_OBJECT (display->shader_upload_AYUV));
-          display->shader_upload_AYUV = NULL;
+      }
+      //check if YCBCR MESA is available
+      else if (GLEW_MESA_ycbcr_texture) {
+        //GLSL and Color Matrix are not available on your drivers, switch to YCBCR MESA
+        GST_INFO ("Context, ARB_fragment_shader supported: no");
+        GST_INFO ("Context, GLEW_MESA_ycbcr_texture supported: yes");
+
+        display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_MESA;
+
+        switch (display->upload_video_format) {
+          case GST_VIDEO_FORMAT_YUY2:
+          case GST_VIDEO_FORMAT_UYVY:
+            //color space conversion is not needed
+            //but if the size is different we need to redraw it
+            //using fbo
+            if (display->upload_width != display->upload_data_width ||
+                display->upload_height != display->upload_data_height)
+              gst_gl_display_thread_init_upload_fbo (display);
+            break;
+          case GST_VIDEO_FORMAT_I420:
+          case GST_VIDEO_FORMAT_YV12:
+          case GST_VIDEO_FORMAT_AYUV:
+            //turn off the pipeline because
+            //MESA only support YUY2 and UYVY
+            GST_WARNING
+                ("Your MESA version only supports YUY2 and UYVY (GLSL is required for others yuv formats");
+            display->isAlive = FALSE;
+            break;
+          default:
+            g_assert_not_reached ();
         }
-        break;
-      default:
-        g_assert_not_reached ();
       }
-    }
-    //check if YCBCR MESA is available
-    else if (GLEW_MESA_ycbcr_texture)
-    {
-      //GLSL and Color Matrix are not available on your drivers, switch to YCBCR MESA
-      GST_INFO ("Context, ARB_fragment_shader supported: no");
-      GST_INFO ("Context, GLEW_MESA_ycbcr_texture supported: yes");
-
-      display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_MESA;
-
-      switch (display->upload_video_format)
-      {
-      case GST_VIDEO_FORMAT_YUY2:
-      case GST_VIDEO_FORMAT_UYVY:
-        //color space conversion is not needed
-        //but if the size is different we need to redraw it
-        //using fbo
-        if (display->upload_width != display->upload_data_width ||
-            display->upload_height != display->upload_data_height)
-          gst_gl_display_thread_init_upload_fbo (display);
-        break;
-      case GST_VIDEO_FORMAT_I420:
-      case GST_VIDEO_FORMAT_YV12:
-      case GST_VIDEO_FORMAT_AYUV:
-        //turn off the pipeline because
-        //MESA only support YUY2 and UYVY
-        GST_WARNING ("Your MESA version only supports YUY2 and UYVY (GLSL is required for others yuv formats");
+      //check if color matrix is available
+      else if (GLEW_ARB_imaging) {
+        //GLSL is not available on your drivers, switch to Color Matrix
+        GST_INFO ("Context, ARB_fragment_shader supported: no");
+        GST_INFO ("Context, GLEW_MESA_ycbcr_texture supported: no");
+        GST_INFO ("Context, GLEW_ARB_imaging supported: yes");
+
+        display->upload_colorspace_conversion =
+            GST_GL_DISPLAY_CONVERSION_MATRIX;
+
+        //turn off the pipeline because we do not support it yet
+        GST_WARNING
+            ("Colorspace conversion using Color Matrix is not yet supported");
         display->isAlive = FALSE;
-        break;
-            default:
-        g_assert_not_reached ();
-      }
-    }
-    //check if color matrix is available
-    else if (GLEW_ARB_imaging)
-    {
-      //GLSL is not available on your drivers, switch to Color Matrix
-      GST_INFO ("Context, ARB_fragment_shader supported: no");
-      GST_INFO ("Context, GLEW_MESA_ycbcr_texture supported: no");
-      GST_INFO ("Context, GLEW_ARB_imaging supported: yes");
-
-      display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_MATRIX;
+      } else {
+        GST_WARNING ("Context, ARB_fragment_shader supported: no");
+        GST_WARNING ("Context, GLEW_ARB_imaging supported: no");
+        GST_WARNING ("Context, GLEW_MESA_ycbcr_texture supported: no");
 
-      //turn off the pipeline because we do not support it yet
-      GST_WARNING ("Colorspace conversion using Color Matrix is not yet supported");
-      display->isAlive = FALSE;
-    }
-    else
-    {
-      GST_WARNING ("Context, ARB_fragment_shader supported: no");
-      GST_WARNING ("Context, GLEW_ARB_imaging supported: no");
-      GST_WARNING ("Context, GLEW_MESA_ycbcr_texture supported: no");
-
-      //turn off the pipeline because colorspace conversion is not possible
-      display->isAlive = FALSE;
+        //turn off the pipeline because colorspace conversion is not possible
+        display->isAlive = FALSE;
+      }
     }
-  }
-  break;
-  default:
-    g_assert_not_reached ();
+      break;
+    default:
+      g_assert_not_reached ();
   }
 }
 
 
 /* Called by the idle function */
 void
-gst_gl_display_thread_do_upload (GstGLDisplay *display)
+gst_gl_display_thread_do_upload (GstGLDisplay * display)
 {
   gst_gl_display_thread_do_upload_fill (display);
 
-  switch (display->upload_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-    //color space conversion is not needed
-    //but if the size is different we need to redraw it
-    //using fbo
-    if (display->upload_width != display->upload_data_width ||
-        display->upload_height != display->upload_data_height)
-      gst_gl_display_thread_do_upload_draw (display);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  case GST_VIDEO_FORMAT_AYUV:
-    {
-      switch (display->upload_colorspace_conversion)
-      {
-      case GST_GL_DISPLAY_CONVERSION_GLSL:
-        //color space conversion is needed
+  switch (display->upload_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      //color space conversion is not needed
+      //but if the size is different we need to redraw it
+      //using fbo
+      if (display->upload_width != display->upload_data_width ||
+          display->upload_height != display->upload_data_height)
         gst_gl_display_thread_do_upload_draw (display);
-        break;
-      case GST_GL_DISPLAY_CONVERSION_MATRIX:
-        //color space conversion is needed
-        //not yet supported
-        break;
-      case GST_GL_DISPLAY_CONVERSION_MESA:
-        //color space conversion is not needed
-        //but if the size is different we need to redraw it
-        //using fbo
-        if (display->upload_width != display->upload_data_width ||
-            display->upload_height != display->upload_data_height)
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    case GST_VIDEO_FORMAT_AYUV:
+    {
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+          //color space conversion is needed
           gst_gl_display_thread_do_upload_draw (display);
-        break;
-      default:
-             g_assert_not_reached ();
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+          //color space conversion is needed
+          //not yet supported
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+          //color space conversion is not needed
+          //but if the size is different we need to redraw it
+          //using fbo
+          if (display->upload_width != display->upload_data_width ||
+              display->upload_height != display->upload_data_height)
+            gst_gl_display_thread_do_upload_draw (display);
+          break;
+        default:
+          g_assert_not_reached ();
       }
     }
-    break;
-  default:
-         g_assert_not_reached ();
+      break;
+    default:
+      g_assert_not_reached ();
   }
 }
 
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_init_download (GstGLDisplay *display)
+gst_gl_display_thread_init_download (GstGLDisplay * display)
 {
-  switch (display->download_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-    //color space conversion is not needed
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  case GST_VIDEO_FORMAT_AYUV:
-    //color space conversion is needed
-  {
-
-    if (GLEW_EXT_framebuffer_object)
+  switch (display->download_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      //color space conversion is not needed
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    case GST_VIDEO_FORMAT_AYUV:
+      //color space conversion is needed
     {
-      GST_INFO ("Context, EXT_framebuffer_object supported: yes");
-
-      //-- init output frame buffer object (GL -> video)
-
-      //setup FBO
-      glGenFramebuffersEXT (1, &display->download_fbo);
-      glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->download_fbo);
-
-      //setup the render buffer for depth
-      glGenRenderbuffersEXT(1, &display->download_depth_buffer);
-      glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->download_depth_buffer);
-      glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
-                              display->download_width, display->download_height);
-
-      //setup a first texture to render to
-      glGenTextures (1, &display->download_texture);
-      glBindTexture(GL_TEXTURE_RECTANGLE_ARB, display->download_texture);
-      glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-                  display->download_width, display->download_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-      //attach the first texture to the FBO to renderer to
-      glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                               GL_TEXTURE_RECTANGLE_ARB, display->download_texture, 0);
-
-      switch (display->download_video_format)
-      {
-      case GST_VIDEO_FORMAT_YUY2:
-      case GST_VIDEO_FORMAT_UYVY:
-      case GST_VIDEO_FORMAT_AYUV:
-        //only one attached texture is needed
-        break;
-
-      case GST_VIDEO_FORMAT_I420:
-      case GST_VIDEO_FORMAT_YV12:
-        //setup a second texture to render to
-        glGenTextures (1, &display->download_texture_u);
-        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, display->download_texture_u);
-        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-                    display->download_width, display->download_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-        //attach the second texture to the FBO to renderer to
-        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
-                                 GL_TEXTURE_RECTANGLE_ARB, display->download_texture_u, 0);
-
-        //setup a third texture to render to
-        glGenTextures (1, &display->download_texture_v);
-        glBindTexture(GL_TEXTURE_RECTANGLE_ARB, display->download_texture_v);
-        glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-                    display->download_width, display->download_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-        //attach the third texture to the FBO to renderer to
-        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT,
-                                 GL_TEXTURE_RECTANGLE_ARB, display->download_texture_v, 0);
-
-        display->multipleRT[0] = GL_COLOR_ATTACHMENT0_EXT;
-        display->multipleRT[1] = GL_COLOR_ATTACHMENT1_EXT;
-        display->multipleRT[2] = GL_COLOR_ATTACHMENT2_EXT;
-        break;
-      default:
-        g_assert_not_reached ();
-      }
 
-      //attach the depth render buffer to the FBO
-      glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
-                                  GL_RENDERBUFFER_EXT, display->download_depth_buffer);
+      if (GLEW_EXT_framebuffer_object) {
+        GST_INFO ("Context, EXT_framebuffer_object supported: yes");
 
-      gst_gl_display_check_framebuffer_status();
+        //-- init output frame buffer object (GL -> video)
 
-      g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
-               GL_FRAMEBUFFER_COMPLETE_EXT);
+        //setup FBO
+        glGenFramebuffersEXT (1, &display->download_fbo);
+        glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->download_fbo);
 
-      //unbind the FBO
-      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-      }
-      else
-      {
+        //setup the render buffer for depth
+        glGenRenderbuffersEXT (1, &display->download_depth_buffer);
+        glBindRenderbufferEXT (GL_RENDERBUFFER_EXT,
+            display->download_depth_buffer);
+        glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+            display->download_width, display->download_height);
+
+        //setup a first texture to render to
+        glGenTextures (1, &display->download_texture);
+        glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->download_texture);
+        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+            display->download_width, display->download_height, 0, GL_RGBA,
+            GL_UNSIGNED_BYTE, NULL);
+        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+            GL_LINEAR);
+        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+            GL_LINEAR);
+        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+            GL_CLAMP_TO_EDGE);
+        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+            GL_CLAMP_TO_EDGE);
+
+        //attach the first texture to the FBO to renderer to
+        glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+            GL_TEXTURE_RECTANGLE_ARB, display->download_texture, 0);
+
+        switch (display->download_video_format) {
+          case GST_VIDEO_FORMAT_YUY2:
+          case GST_VIDEO_FORMAT_UYVY:
+          case GST_VIDEO_FORMAT_AYUV:
+            //only one attached texture is needed
+            break;
+
+          case GST_VIDEO_FORMAT_I420:
+          case GST_VIDEO_FORMAT_YV12:
+            //setup a second texture to render to
+            glGenTextures (1, &display->download_texture_u);
+            glBindTexture (GL_TEXTURE_RECTANGLE_ARB,
+                display->download_texture_u);
+            glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+                display->download_width, display->download_height, 0, GL_RGBA,
+                GL_UNSIGNED_BYTE, NULL);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+                GL_LINEAR);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+                GL_LINEAR);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+                GL_CLAMP_TO_EDGE);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+                GL_CLAMP_TO_EDGE);
+
+            //attach the second texture to the FBO to renderer to
+            glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
+                GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB,
+                display->download_texture_u, 0);
+
+            //setup a third texture to render to
+            glGenTextures (1, &display->download_texture_v);
+            glBindTexture (GL_TEXTURE_RECTANGLE_ARB,
+                display->download_texture_v);
+            glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+                display->download_width, display->download_height, 0, GL_RGBA,
+                GL_UNSIGNED_BYTE, NULL);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+                GL_LINEAR);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+                GL_LINEAR);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+                GL_CLAMP_TO_EDGE);
+            glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+                GL_CLAMP_TO_EDGE);
+
+            //attach the third texture to the FBO to renderer to
+            glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
+                GL_COLOR_ATTACHMENT2_EXT, GL_TEXTURE_RECTANGLE_ARB,
+                display->download_texture_v, 0);
+
+            display->multipleRT[0] = GL_COLOR_ATTACHMENT0_EXT;
+            display->multipleRT[1] = GL_COLOR_ATTACHMENT1_EXT;
+            display->multipleRT[2] = GL_COLOR_ATTACHMENT2_EXT;
+            break;
+          default:
+            g_assert_not_reached ();
+        }
+
+        //attach the depth render buffer to the FBO
+        glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT,
+            GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT,
+            display->download_depth_buffer);
+
+        gst_gl_display_check_framebuffer_status ();
+
+        g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
+            GL_FRAMEBUFFER_COMPLETE_EXT);
+
+        //unbind the FBO
+        glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
+      } else {
         //turn off the pipeline because Frame buffer object is a requirement when using filters
         //or when using GLSL colorspace conversion
         GST_WARNING ("Context, EXT_framebuffer_object supported: no");
         display->isAlive = FALSE;
       }
     }
-    break;
-  default:
-    g_assert_not_reached ();
+      break;
+    default:
+      g_assert_not_reached ();
   }
 
-  switch (display->download_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-    //color space conversion is not needed
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  case GST_VIDEO_FORMAT_AYUV:
-    //color space conversion is needed
-  {
-    //check if fragment shader is available, then load them
-    //GLSL is a requirement for donwload
-    if (GLEW_ARB_fragment_shader)
-    {
-      switch (display->download_video_format)
-      {
-      case GST_VIDEO_FORMAT_YUY2:
-      {
-       gchar text_shader_download_YUY2[2048];
-       sprintf (text_shader_download_YUY2, display->text_shader_download_YUY2_UYVY, "y2,u,y1,v");
-
-       display->shader_download_YUY2 = gst_gl_shader_new ();
-       if(!gst_gl_shader_compile_and_check (display->shader_download_YUY2,
-                                            text_shader_download_YUY2, GST_GL_SHADER_FRAGMENT_SOURCE))
-       {
-         display->isAlive = FALSE;
-         g_object_unref (G_OBJECT (display->shader_download_YUY2));
-         display->shader_download_YUY2 = NULL;
-       }
-      }
+  switch (display->download_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      //color space conversion is not needed
       break;
-      case GST_VIDEO_FORMAT_UYVY:
-      {
-       gchar text_shader_download_UYVY[2048];
-       sprintf (text_shader_download_UYVY, display->text_shader_download_YUY2_UYVY, "v,y1,u,y2");
-
-       display->shader_download_UYVY = gst_gl_shader_new ();
-       if(!gst_gl_shader_compile_and_check (display->shader_download_UYVY,
-                                            text_shader_download_UYVY, GST_GL_SHADER_FRAGMENT_SOURCE))
-       {
-         display->isAlive = FALSE;
-         g_object_unref (G_OBJECT (display->shader_download_UYVY));
-         display->shader_download_UYVY = NULL;
-       }
-      }
-      break;
-      case GST_VIDEO_FORMAT_I420:
-      case GST_VIDEO_FORMAT_YV12:
-       display->shader_download_I420_YV12 = gst_gl_shader_new ();
-       if(!gst_gl_shader_compile_and_check (display->shader_download_I420_YV12,
-                                            display->text_shader_download_I420_YV12, GST_GL_SHADER_FRAGMENT_SOURCE))
-       {
-         display->isAlive = FALSE;
-         g_object_unref (G_OBJECT (display->shader_download_I420_YV12));
-         display->shader_download_I420_YV12 = NULL;
-       }
-       break;
-      case GST_VIDEO_FORMAT_AYUV:
-       display->shader_download_AYUV = gst_gl_shader_new ();
-       if(!gst_gl_shader_compile_and_check (display->shader_download_AYUV,
-                                            display->text_shader_download_AYUV, GST_GL_SHADER_FRAGMENT_SOURCE))
-       {
-         display->isAlive = FALSE;
-         g_object_unref (G_OBJECT (display->shader_download_AYUV));
-         display->shader_download_AYUV = NULL;
-       }
-       break;
-      default:
-       g_assert_not_reached ();
-      }
-    }
-    else
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    case GST_VIDEO_FORMAT_AYUV:
+      //color space conversion is needed
     {
-      //turn off the pipeline because colorspace conversion is not possible
-      GST_WARNING ("Context, ARB_fragment_shader supported: no");
-      display->isAlive = FALSE;
+      //check if fragment shader is available, then load them
+      //GLSL is a requirement for donwload
+      if (GLEW_ARB_fragment_shader) {
+        switch (display->download_video_format) {
+          case GST_VIDEO_FORMAT_YUY2:
+          {
+            gchar text_shader_download_YUY2[2048];
+            sprintf (text_shader_download_YUY2,
+                display->text_shader_download_YUY2_UYVY, "y2,u,y1,v");
+
+            display->shader_download_YUY2 = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check (display->shader_download_YUY2,
+                    text_shader_download_YUY2, GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_download_YUY2));
+              display->shader_download_YUY2 = NULL;
+            }
+          }
+            break;
+          case GST_VIDEO_FORMAT_UYVY:
+          {
+            gchar text_shader_download_UYVY[2048];
+            sprintf (text_shader_download_UYVY,
+                display->text_shader_download_YUY2_UYVY, "v,y1,u,y2");
+
+            display->shader_download_UYVY = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check (display->shader_download_UYVY,
+                    text_shader_download_UYVY, GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_download_UYVY));
+              display->shader_download_UYVY = NULL;
+            }
+          }
+            break;
+          case GST_VIDEO_FORMAT_I420:
+          case GST_VIDEO_FORMAT_YV12:
+            display->shader_download_I420_YV12 = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check
+                (display->shader_download_I420_YV12,
+                    display->text_shader_download_I420_YV12,
+                    GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_download_I420_YV12));
+              display->shader_download_I420_YV12 = NULL;
+            }
+            break;
+          case GST_VIDEO_FORMAT_AYUV:
+            display->shader_download_AYUV = gst_gl_shader_new ();
+            if (!gst_gl_shader_compile_and_check (display->shader_download_AYUV,
+                    display->text_shader_download_AYUV,
+                    GST_GL_SHADER_FRAGMENT_SOURCE)) {
+              display->isAlive = FALSE;
+              g_object_unref (G_OBJECT (display->shader_download_AYUV));
+              display->shader_download_AYUV = NULL;
+            }
+            break;
+          default:
+            g_assert_not_reached ();
+        }
+      } else {
+        //turn off the pipeline because colorspace conversion is not possible
+        GST_WARNING ("Context, ARB_fragment_shader supported: no");
+        display->isAlive = FALSE;
+      }
     }
-  }
-  break;
-  default:
-    g_assert_not_reached ();
+      break;
+    default:
+      g_assert_not_reached ();
   }
 }
 
@@ -1090,38 +1074,37 @@ gst_gl_display_thread_init_download (GstGLDisplay *display)
 void
 gst_gl_display_thread_do_download (GstGLDisplay * display)
 {
-  switch (display->download_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-    //color space conversion is not needed
-    gst_gl_display_thread_do_download_draw_rgb (display);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  case GST_VIDEO_FORMAT_AYUV:
-    //color space conversion is needed
-    gst_gl_display_thread_do_download_draw_yuv (display);
-    break;
-  default:
-    g_assert_not_reached ();
+  switch (display->download_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      //color space conversion is not needed
+      gst_gl_display_thread_do_download_draw_rgb (display);
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    case GST_VIDEO_FORMAT_AYUV:
+      //color space conversion is needed
+      gst_gl_display_thread_do_download_draw_yuv (display);
+      break;
+    default:
+      g_assert_not_reached ();
   }
 }
 
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_gen_fbo (GstGLDisplay *display)
+gst_gl_display_thread_gen_fbo (GstGLDisplay * display)
 {
   //a texture must be attached to the FBO
   GLuint fake_texture = 0;
@@ -1134,36 +1117,36 @@ gst_gl_display_thread_gen_fbo (GstGLDisplay *display)
     display->isAlive = FALSE;
     return;
   }
-
   //setup FBO
   glGenFramebuffersEXT (1, &display->generated_fbo);
   glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->generated_fbo);
 
   //setup the render buffer for depth
-  glGenRenderbuffersEXT(1, &display->generated_depth_buffer);
-  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
-  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
-                          display->gen_fbo_width, display->gen_fbo_height);
+  glGenRenderbuffersEXT (1, &display->generated_depth_buffer);
+  glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
+  glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+      display->gen_fbo_width, display->gen_fbo_height);
 
   //setup a texture to render to
   glGenTextures (1, &fake_texture);
-  glBindTexture(GL_TEXTURE_RECTANGLE_ARB, fake_texture);
-  glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-              display->gen_fbo_width, display->gen_fbo_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+  glBindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
+  glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+      display->gen_fbo_width, display->gen_fbo_height, 0, GL_RGBA,
+      GL_UNSIGNED_BYTE, NULL);
 
   //attach the texture to the FBO to renderer to
-  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                           GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
+  glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+      GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
 
   //attach the depth render buffer to the FBO
-  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
-                              GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
+  glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+      GL_RENDERBUFFER_EXT, display->generated_depth_buffer);
 
   g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
-           GL_FRAMEBUFFER_COMPLETE_EXT);
+      GL_FRAMEBUFFER_COMPLETE_EXT);
 
   //unbind the FBO
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
 
   glDeleteTextures (1, &fake_texture);
 }
@@ -1171,79 +1154,78 @@ gst_gl_display_thread_gen_fbo (GstGLDisplay *display)
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_use_fbo (GstGLDisplay *display)
+gst_gl_display_thread_use_fbo (GstGLDisplay * display)
 {
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, display->use_fbo);
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->use_fbo);
 
   //setup a texture to render to
-  glBindTexture(GL_TEXTURE_RECTANGLE_ARB, display->use_fbo_texture);
+  glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->use_fbo_texture);
 
   //attach the texture to the FBO to renderer to
-  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                           GL_TEXTURE_RECTANGLE_ARB, display->use_fbo_texture, 0);
+  glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+      GL_TEXTURE_RECTANGLE_ARB, display->use_fbo_texture, 0);
 
   if (GLEW_ARB_fragment_shader)
     gst_gl_shader_use (NULL);
 
 
-  glPushAttrib(GL_VIEWPORT_BIT);
-
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-
-  switch (display->use_fbo_projection)
-  {
-  case GST_GL_DISPLAY_PROJECTION_ORTHO2D:
-    gluOrtho2D(display->use_fbo_proj_param1, display->use_fbo_proj_param2,
-              display->use_fbo_proj_param3, display->use_fbo_proj_param4);
-    break;
-  case GST_GL_DISPLAY_PROJECTION_PERSPECIVE:
-    gluPerspective(display->use_fbo_proj_param1, display->use_fbo_proj_param2,
-                  display->use_fbo_proj_param3, display->use_fbo_proj_param4);
-    break;
-  default:
-    g_assert_not_reached ();
+  glPushAttrib (GL_VIEWPORT_BIT);
+
+  glMatrixMode (GL_PROJECTION);
+  glPushMatrix ();
+  glLoadIdentity ();
+
+  switch (display->use_fbo_projection) {
+    case GST_GL_DISPLAY_PROJECTION_ORTHO2D:
+      gluOrtho2D (display->use_fbo_proj_param1, display->use_fbo_proj_param2,
+          display->use_fbo_proj_param3, display->use_fbo_proj_param4);
+      break;
+    case GST_GL_DISPLAY_PROJECTION_PERSPECIVE:
+      gluPerspective (display->use_fbo_proj_param1,
+          display->use_fbo_proj_param2, display->use_fbo_proj_param3,
+          display->use_fbo_proj_param4);
+      break;
+    default:
+      g_assert_not_reached ();
   }
 
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
+  glMatrixMode (GL_MODELVIEW);
+  glPushMatrix ();
+  glLoadIdentity ();
 
-  glViewport(0, 0, display->use_fbo_width, display->use_fbo_height);
+  glViewport (0, 0, display->use_fbo_width, display->use_fbo_height);
 
-  glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
-  glClearColor(0.0, 0.0, 0.0, 0.0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
+  glClearColor (0.0, 0.0, 0.0, 0.0);
+  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
   //the opengl scene
-  display->use_fbo_scene_cb (display->input_texture_width, display->input_texture_height,
-                            display->input_texture, display->use_fbo_stuff);
+  display->use_fbo_scene_cb (display->input_texture_width,
+      display->input_texture_height, display->input_texture,
+      display->use_fbo_stuff);
 
-  glDrawBuffer(GL_NONE);
+  glDrawBuffer (GL_NONE);
 
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-  glPopAttrib();
+  glMatrixMode (GL_PROJECTION);
+  glPopMatrix ();
+  glMatrixMode (GL_MODELVIEW);
+  glPopMatrix ();
+  glPopAttrib ();
 
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
 }
 
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_del_fbo (GstGLDisplay* display)
+gst_gl_display_thread_del_fbo (GstGLDisplay * display)
 {
-  if (display->del_fbo)
-  {
+  if (display->del_fbo) {
     glDeleteFramebuffersEXT (1, &display->del_fbo);
     display->del_fbo = 0;
   }
-  if (display->del_depth_buffer)
-  {
-    glDeleteRenderbuffersEXT(1, &display->del_depth_buffer);
+  if (display->del_depth_buffer) {
+    glDeleteRenderbuffersEXT (1, &display->del_depth_buffer);
     display->del_depth_buffer = 0;
   }
 }
@@ -1251,27 +1233,26 @@ gst_gl_display_thread_del_fbo (GstGLDisplay* display)
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_gen_shader (GstGLDisplay* display)
+gst_gl_display_thread_gen_shader (GstGLDisplay * display)
 {
-  if (GLEW_ARB_fragment_shader)
-  {
+  if (GLEW_ARB_fragment_shader) {
     if (display->gen_shader_vertex_source ||
-         display->gen_shader_fragment_source)
-    {
+        display->gen_shader_fragment_source) {
       gboolean isAlive = TRUE;
       GError *error = NULL;
 
       display->gen_shader = gst_gl_shader_new ();
 
       if (display->gen_shader_vertex_source)
-        gst_gl_shader_set_vertex_source(display->gen_shader, display->gen_shader_vertex_source);
+        gst_gl_shader_set_vertex_source (display->gen_shader,
+            display->gen_shader_vertex_source);
 
       if (display->gen_shader_fragment_source)
-        gst_gl_shader_set_fragment_source(display->gen_shader, display->gen_shader_fragment_source);
+        gst_gl_shader_set_fragment_source (display->gen_shader,
+            display->gen_shader_fragment_source);
 
       gst_gl_shader_compile (display->gen_shader, &error);
-      if (error)
-      {
+      if (error) {
         GST_ERROR ("%s", error->message);
         g_error_free (error);
         error = NULL;
@@ -1279,16 +1260,13 @@ gst_gl_display_thread_gen_shader (GstGLDisplay* display)
         isAlive = FALSE;
       }
 
-      if (!isAlive)
-      {
+      if (!isAlive) {
         display->isAlive = FALSE;
         g_object_unref (G_OBJECT (display->gen_shader));
         display->gen_shader = NULL;
       }
     }
-  }
-  else
-  {
+  } else {
     GST_WARNING ("One of the filter required ARB_fragment_shader");
     display->isAlive = FALSE;
     display->gen_shader = NULL;
@@ -1298,10 +1276,9 @@ gst_gl_display_thread_gen_shader (GstGLDisplay* display)
 
 /* Called in the gl thread */
 void
-gst_gl_display_thread_del_shader (GstGLDisplay* display)
+gst_gl_display_thread_del_shader (GstGLDisplay * display)
 {
-  if (display->del_shader)
-  {
+  if (display->del_shader) {
     g_object_unref (G_OBJECT (display->del_shader));
     display->del_shader = NULL;
   }
@@ -1333,25 +1310,25 @@ gst_gl_display_unlock (GstGLDisplay * display)
 
 
 void
-gst_gl_display_on_resize (GstGLDisplay* display, gint width, gint height)
+gst_gl_display_on_resize (GstGLDisplay * display, gint width, gint height)
 {
   //check if a client reshape callback is registered
   if (display->clientReshapeCallback)
-    display->clientReshapeCallback(width, height);
+    display->clientReshapeCallback (width, height);
 
   //default reshape
-  else
-  {
-    glViewport(0, 0, width, height);
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-    gluOrtho2D(0, width, 0, height);
-    glMatrixMode(GL_MODELVIEW);
+  else {
+    glViewport (0, 0, width, height);
+    glMatrixMode (GL_PROJECTION);
+    glLoadIdentity ();
+    gluOrtho2D (0, width, 0, height);
+    glMatrixMode (GL_MODELVIEW);
   }
 }
 
 
-void gst_gl_display_on_draw(GstGLDisplay* display)
+void
+gst_gl_display_on_draw (GstGLDisplay * display)
 {
   //check if tecture is ready for being drawn
   if (!display->redisplay_texture)
@@ -1367,20 +1344,18 @@ void gst_gl_display_on_draw(GstGLDisplay* display)
   glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
 
   //check if a client draw callback is registered
-  if (display->clientDrawCallback)
-  {
+  if (display->clientDrawCallback) {
     gboolean doRedisplay =
-      display->clientDrawCallback (display->redisplay_texture,
-                                 display->redisplay_texture_width, display->redisplay_texture_height);
+        display->clientDrawCallback (display->redisplay_texture,
+        display->redisplay_texture_width, display->redisplay_texture_height);
 
     if (doRedisplay && display->gl_window)
       gst_gl_window_draw_unlocked (display->gl_window);
   }
   //default opengl scene
-  else
-  {
+  else {
 
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
     glMatrixMode (GL_PROJECTION);
     glLoadIdentity ();
@@ -1395,16 +1370,18 @@ void gst_gl_display_on_draw(GstGLDisplay* display)
     glVertex2f (-1.0f, 1.0f);
     glTexCoord2i (0, display->redisplay_texture_height);
     glVertex2f (-1.0f, -1.0f);
-    glTexCoord2i (display->redisplay_texture_width, display->redisplay_texture_height);
+    glTexCoord2i (display->redisplay_texture_width,
+        display->redisplay_texture_height);
     glVertex2f (1.0f, -1.0f);
     glEnd ();
 
-    glDisable(GL_TEXTURE_RECTANGLE_ARB);
-  }//end default opengl scene
+    glDisable (GL_TEXTURE_RECTANGLE_ARB);
+  }                             //end default opengl scene
 }
 
 
-void gst_gl_display_on_close (GstGLDisplay* display)
+void
+gst_gl_display_on_close (GstGLDisplay * display)
 {
   GST_INFO ("on close");
 
@@ -1415,37 +1392,34 @@ void gst_gl_display_on_close (GstGLDisplay* display)
 /* Generate a texture if no one is available in the pool
  * Called in the gl thread */
 void
-gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture, GLint width, GLint height)
+gst_gl_display_glgen_texture (GstGLDisplay * display, GLuint * pTexture,
+    GLint width, GLint height)
 {
-  if (display->isAlive)
-  {
-    GQueue* sub_texture_pool = NULL;
+  if (display->isAlive) {
+    GQueue *sub_texture_pool = NULL;
 
     //make a unique key from w and h
     //the key cannot be w*h because (4*6 = 6*4 = 2*12 = 12*2)
-    guint key = (gint)width;
+    guint key = (gint) width;
     key <<= 16;
-    key |= (gint)height;
-    sub_texture_pool = g_hash_table_lookup (display->texture_pool, GUINT_TO_POINTER (key));
+    key |= (gint) height;
+    sub_texture_pool =
+        g_hash_table_lookup (display->texture_pool, GUINT_TO_POINTER (key));
 
     //if there is a sub texture pool associated to th given key
-    if (sub_texture_pool && g_queue_get_length(sub_texture_pool) > 0)
-    {
+    if (sub_texture_pool && g_queue_get_length (sub_texture_pool) > 0) {
       //a texture is available in the pool
-      GstGLDisplayTextex = g_queue_pop_head (sub_texture_pool);
+      GstGLDisplayTex *tex = g_queue_pop_head (sub_texture_pool);
       *pTexture = tex->texture;
       g_free (tex);
       GST_LOG ("get texture id:%d from the sub texture pool: %d",
-        *pTexture, key);
-    }
-    else
-    {
+          *pTexture, key);
+    } else {
       //sub texture pool does not exist yet or empty
       glGenTextures (1, pTexture);
       glBindTexture (GL_TEXTURE_RECTANGLE_ARB, *pTexture);
 
-      switch (display->upload_video_format)
-      {
+      switch (display->upload_video_format) {
         case GST_VIDEO_FORMAT_RGB:
         case GST_VIDEO_FORMAT_BGR:
         case GST_VIDEO_FORMAT_RGBx:
@@ -1456,51 +1430,53 @@ gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture, GLint wid
         case GST_VIDEO_FORMAT_BGRA:
         case GST_VIDEO_FORMAT_ARGB:
         case GST_VIDEO_FORMAT_ABGR:
-          glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-            width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+              width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
           break;
         case GST_VIDEO_FORMAT_YUY2:
         case GST_VIDEO_FORMAT_UYVY:
-          switch (display->upload_colorspace_conversion)
-          {
-          case GST_GL_DISPLAY_CONVERSION_GLSL:
-          case GST_GL_DISPLAY_CONVERSION_MATRIX:
-            glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-              width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-            break;
-          case GST_GL_DISPLAY_CONVERSION_MESA:
-            if (display->upload_width != display->upload_data_width ||
-                display->upload_height != display->upload_data_height)
-              glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-                width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-            else
-              glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA,width, height,
-                0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
-            break;
-          default:
-            g_assert_not_reached ();
+          switch (display->upload_colorspace_conversion) {
+            case GST_GL_DISPLAY_CONVERSION_GLSL:
+            case GST_GL_DISPLAY_CONVERSION_MATRIX:
+              glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+                  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+              break;
+            case GST_GL_DISPLAY_CONVERSION_MESA:
+              if (display->upload_width != display->upload_data_width ||
+                  display->upload_height != display->upload_data_height)
+                glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+                    width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+              else
+                glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width,
+                    height, 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
+              break;
+            default:
+              g_assert_not_reached ();
           }
           break;
         case GST_VIDEO_FORMAT_I420:
         case GST_VIDEO_FORMAT_YV12:
         case GST_VIDEO_FORMAT_AYUV:
-          glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-            width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+              width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
           break;
         default:
-            g_assert_not_reached ();
+          g_assert_not_reached ();
       }
 
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+          GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+          GL_CLAMP_TO_EDGE);
 
       GST_LOG ("generate texture id:%d", *pTexture);
     }
 
-  }
-  else
+  } else
     *pTexture = 0;
 }
 
@@ -1508,31 +1484,33 @@ gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture, GLint wid
 /* Delete a texture, actually the texture is just added to the pool
  * Called in the gl thread */
 void
-gst_gl_display_gldel_texture (GstGLDisplay* display, GLuint* pTexture, GLint width, GLint height)
+gst_gl_display_gldel_texture (GstGLDisplay * display, GLuint * pTexture,
+    GLint width, GLint height)
 {
   //Each existing texture is destroyed only when the pool is destroyed
   //The pool of textures is deleted in the GstGLDisplay destructor
 
-  GQueuesub_texture_pool = NULL;
-  GstGLDisplayTextex = NULL;
+  GQueue *sub_texture_pool = NULL;
+  GstGLDisplayTex *tex = NULL;
 
   //make a unique key from w and h
   //the key cannot be w*h because (4*6 = 6*4 = 2*12 = 12*2)
-  guint key = (gint)width;
+  guint key = (gint) width;
   key <<= 16;
-  key |= (gint)height;
-  sub_texture_pool = g_hash_table_lookup (display->texture_pool, GUINT_TO_POINTER (key));
+  key |= (gint) height;
+  sub_texture_pool =
+      g_hash_table_lookup (display->texture_pool, GUINT_TO_POINTER (key));
 
   //if the size is known
-  if (!sub_texture_pool)
-  {
+  if (!sub_texture_pool) {
     sub_texture_pool = g_queue_new ();
-    g_hash_table_insert (display->texture_pool, GUINT_TO_POINTER (key), sub_texture_pool);
+    g_hash_table_insert (display->texture_pool, GUINT_TO_POINTER (key),
+        sub_texture_pool);
 
     GST_INFO ("one more sub texture pool inserted: %d ", key);
-    GST_INFO ("nb sub texture pools: %d", g_hash_table_size (display->texture_pool));
+    GST_INFO ("nb sub texture pools: %d",
+        g_hash_table_size (display->texture_pool));
   }
-
   //contruct a sub texture pool element
   tex = g_new0 (GstGLDisplayTex, 1);
   tex->texture = *pTexture;
@@ -1541,20 +1519,21 @@ gst_gl_display_gldel_texture (GstGLDisplay* display, GLuint* pTexture, GLint wid
   //add tex to the pool, it makes texture allocation reusable
   g_queue_push_tail (sub_texture_pool, tex);
   GST_LOG ("texture id:%d added to the sub texture pool: %d",
-    tex->texture, key);
+      tex->texture, key);
   GST_LOG ("%d texture(s) in the sub texture pool: %d",
-    g_queue_get_length (sub_texture_pool), key);
+      g_queue_get_length (sub_texture_pool), key);
 }
 
 
 /* call when a sub texture pool is removed from the texture pool (ghash table) */
-gboolean gst_gl_display_texture_pool_func_clean (gpointer key, gpointer value, gpointer data)
+gboolean
+gst_gl_display_texture_pool_func_clean (gpointer key, gpointer value,
+    gpointer data)
 {
-  GQueue* sub_texture_pool = (GQueue*) value;
+  GQueue *sub_texture_pool = (GQueue *) value;
 
-  while (g_queue_get_length (sub_texture_pool) > 0)
-  {
-    GstGLDisplayTex* tex = g_queue_pop_head (sub_texture_pool);
+  while (g_queue_get_length (sub_texture_pool) > 0) {
+    GstGLDisplayTex *tex = g_queue_pop_head (sub_texture_pool);
     GST_INFO ("trying to delete texture id: %d deleted", tex->texture);
     glDeleteTextures (1, &tex->texture);
     GST_INFO ("texture id: %d deleted", tex->texture);
@@ -1569,21 +1548,20 @@ gboolean gst_gl_display_texture_pool_func_clean (gpointer key, gpointer value, g
 
 /* called in the gl thread */
 void
-gst_gl_display_check_framebuffer_status(void)
+gst_gl_display_check_framebuffer_status (void)
 {
-  GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+  GLenum status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
 
-  switch(status)
-  {
-  case GL_FRAMEBUFFER_COMPLETE_EXT:
-    break;
+  switch (status) {
+    case GL_FRAMEBUFFER_COMPLETE_EXT:
+      break;
 
-  case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
-    GST_ERROR ("GL_FRAMEBUFFER_UNSUPPORTED_EXT");
-    break;
+    case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
+      GST_ERROR ("GL_FRAMEBUFFER_UNSUPPORTED_EXT");
+      break;
 
-  default:
-    GST_ERROR ("General FBO error");
+    default:
+      GST_ERROR ("General FBO error");
   }
 }
 
@@ -1599,7 +1577,7 @@ gst_gl_display_check_framebuffer_status(void)
 
 
 /* Called by the first gl element of a video/x-raw-gl flow */
-GstGLDisplay*
+GstGLDisplay *
 gst_gl_display_new (void)
 {
   return g_object_new (GST_TYPE_GL_DISPLAY, NULL);
@@ -1609,8 +1587,8 @@ gst_gl_display_new (void)
 /* Create an opengl context (one context for one GstGLDisplay)
  * Called by the first gl element of a video/x-raw-gl flow */
 void
-gst_gl_display_create_context (GstGLDisplay *display,
-                               GLint width, GLint height)
+gst_gl_display_create_context (GstGLDisplay * display,
+    GLint width, GLint height)
 {
   gst_gl_display_lock (display);
 
@@ -1618,7 +1596,7 @@ gst_gl_display_create_context (GstGLDisplay *display,
   display->upload_height = height;
 
   display->gl_thread = g_thread_create (
-    (GThreadFunc) gst_gl_display_thread_create_context, display, TRUE, NULL);
+      (GThreadFunc) gst_gl_display_thread_create_context, display, TRUE, NULL);
 
   g_cond_wait (display->cond_create_context, display->mutex);
 
@@ -1630,16 +1608,15 @@ gst_gl_display_create_context (GstGLDisplay *display,
 
 /* Called by the glimagesink element */
 gboolean
-gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gint height)
+gst_gl_display_redisplay (GstGLDisplay * display, GLuint texture, gint width,
+    gint height)
 {
   gboolean isAlive = TRUE;
 
   gst_gl_display_lock (display);
   isAlive = display->isAlive;
-  if (isAlive)
-  {
-    if (texture)
-    {
+  if (isAlive) {
+    if (texture) {
       display->redisplay_texture = texture;
       display->redisplay_texture_width = width;
       display->redisplay_texture_height = height;
@@ -1653,24 +1630,27 @@ gst_gl_display_redisplay (GstGLDisplay* display, GLuint texture, gint width, gin
 }
 
 void
-gst_gl_display_thread_add (GstGLDisplay *display,
-                          GstGLDisplayThreadFunc func, gpointer data)
+gst_gl_display_thread_add (GstGLDisplay * display,
+    GstGLDisplayThreadFunc func, gpointer data)
 {
   gst_gl_display_lock (display);
   display->data = data;
   display->generic_callback = func;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_run_generic), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_run_generic), display);
   gst_gl_display_unlock (display);
 }
 
 /* Called by gst_gl_buffer_new */
 void
-gst_gl_display_gen_texture (GstGLDisplay* display, GLuint* pTexture, GLint width, GLint height)
+gst_gl_display_gen_texture (GstGLDisplay * display, GLuint * pTexture,
+    GLint width, GLint height)
 {
   gst_gl_display_lock (display);
   display->gen_texture_width = width;
   display->gen_texture_height = height;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_gen_texture), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_gen_texture), display);
   *pTexture = display->gen_texture;
   gst_gl_display_unlock (display);
 }
@@ -1678,15 +1658,16 @@ gst_gl_display_gen_texture (GstGLDisplay* display, GLuint* pTexture, GLint width
 
 /* Called by gst_gl_buffer_finalize */
 void
-gst_gl_display_del_texture (GstGLDisplay* display, GLuint texture, GLint width, GLint height)
+gst_gl_display_del_texture (GstGLDisplay * display, GLuint texture, GLint width,
+    GLint height)
 {
   gst_gl_display_lock (display);
-  if (texture)
-  {
+  if (texture) {
     display->del_texture = texture;
     display->del_texture_width = width;
     display->del_texture_height = height;
-    gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_del_texture), display);
+    gst_gl_window_send_message (display->gl_window,
+        GST_GL_WINDOW_CB (gst_gl_display_thread_del_texture), display);
   }
   gst_gl_display_unlock (display);
 }
@@ -1694,9 +1675,8 @@ gst_gl_display_del_texture (GstGLDisplay* display, GLuint texture, GLint width,
 
 /* Called by the first gl element of a video/x-raw-gl flow */
 void
-gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
-                            guint gl_width, guint gl_height,
-                            gint video_width, gint video_height)
+gst_gl_display_init_upload (GstGLDisplay * display, GstVideoFormat video_format,
+    guint gl_width, guint gl_height, gint video_width, gint video_height)
 {
   gst_gl_display_lock (display);
   display->upload_video_format = video_format;
@@ -1704,28 +1684,28 @@ gst_gl_display_init_upload (GstGLDisplay* display, GstVideoFormat video_format,
   display->upload_height = gl_height;
   display->upload_data_width = video_width;
   display->upload_data_height = video_height;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_init_upload), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_init_upload), display);
   gst_gl_display_unlock (display);
 }
 
 
 /* Called by the first gl element of a video/x-raw-gl flow */
 gboolean
-gst_gl_display_do_upload (GstGLDisplay *display, GLuint texture,
-                          gint data_width, gint data_height,
-                          gpointer data)
+gst_gl_display_do_upload (GstGLDisplay * display, GLuint texture,
+    gint data_width, gint data_height, gpointer data)
 {
   gboolean isAlive = TRUE;
 
   gst_gl_display_lock (display);
   isAlive = display->isAlive;
-  if (isAlive)
-  {
+  if (isAlive) {
     display->upload_outtex = texture;
     display->upload_data_width = data_width;
     display->upload_data_height = data_height;
     display->upload_data = data;
-    gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_do_upload), display);
+    gst_gl_window_send_message (display->gl_window,
+        GST_GL_WINDOW_CB (gst_gl_display_thread_do_upload), display);
   }
   gst_gl_display_unlock (display);
 
@@ -1735,36 +1715,36 @@ gst_gl_display_do_upload (GstGLDisplay *display, GLuint texture,
 
 /* Called by the gldownload and glcolorscale element */
 void
-gst_gl_display_init_download (GstGLDisplay* display, GstVideoFormat video_format,
-                              gint width, gint height)
+gst_gl_display_init_download (GstGLDisplay * display,
+    GstVideoFormat video_format, gint width, gint height)
 {
   gst_gl_display_lock (display);
   display->download_video_format = video_format;
   display->download_width = width;
   display->download_height = height;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_init_download), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_init_download), display);
   gst_gl_display_unlock (display);
 }
 
 
 /* Called by the gldownload and glcolorscale element */
 gboolean
-gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
-                            gint width, gint height,
-                            gpointer data)
+gst_gl_display_do_download (GstGLDisplay * display, GLuint texture,
+    gint width, gint height, gpointer data)
 {
   gboolean isAlive = TRUE;
 
   gst_gl_display_lock (display);
   isAlive = display->isAlive;
-  if (isAlive)
-  {
+  if (isAlive) {
     //data size is aocciated to the glcontext size
     display->download_data = data;
     display->ouput_texture = texture;
     display->ouput_texture_width = width;
     display->ouput_texture_height = height;
-    gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_do_download), display);
+    gst_gl_window_send_message (display->gl_window,
+        GST_GL_WINDOW_CB (gst_gl_display_thread_do_download), display);
   }
   gst_gl_display_unlock (display);
 
@@ -1774,15 +1754,15 @@ gst_gl_display_do_download (GstGLDisplay* display, GLuint texture,
 
 /* Called by gltestsrc and glfilter */
 void
-gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
-                        GLuint* fbo, GLuint* depthbuffer)
+gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
+    GLuint * fbo, GLuint * depthbuffer)
 {
   gst_gl_display_lock (display);
-  if (display->isAlive)
-  {
+  if (display->isAlive) {
     display->gen_fbo_width = width;
     display->gen_fbo_height = height;
-    gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_gen_fbo), display);
+    gst_gl_window_send_message (display->gl_window,
+        GST_GL_WINDOW_CB (gst_gl_display_thread_gen_fbo), display);
     *fbo = display->generated_fbo;
     *depthbuffer = display->generated_depth_buffer;
   }
@@ -1799,19 +1779,18 @@ gst_gl_display_gen_fbo (GstGLDisplay* display, gint width, gint height,
  * GstGLDisplay *display and gpointer data, or just gpointer data */
 /* ..everything here has to be simplified! */
 gboolean
-gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint texture_fbo_height,
-                        GLuint fbo, GLuint depth_buffer, GLuint texture_fbo, GLCB cb,
-                        gint input_texture_width, gint input_texture_height, GLuint input_texture,
-                        gdouble proj_param1, gdouble proj_param2,
-                        gdouble proj_param3, gdouble proj_param4,
-                        GstGLDisplayProjection projection, gpointer* stuff)
+gst_gl_display_use_fbo (GstGLDisplay * display, gint texture_fbo_width,
+    gint texture_fbo_height, GLuint fbo, GLuint depth_buffer,
+    GLuint texture_fbo, GLCB cb, gint input_texture_width,
+    gint input_texture_height, GLuint input_texture, gdouble proj_param1,
+    gdouble proj_param2, gdouble proj_param3, gdouble proj_param4,
+    GstGLDisplayProjection projection, gpointer * stuff)
 {
   gboolean isAlive = TRUE;
 
   gst_gl_display_lock (display);
   isAlive = display->isAlive;
-  if (isAlive)
-  {
+  if (isAlive) {
     display->use_fbo = fbo;
     display->use_depth_buffer = depth_buffer;
     display->use_fbo_texture = texture_fbo;
@@ -1827,7 +1806,8 @@ gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint text
     display->input_texture_width = input_texture_width;
     display->input_texture_height = input_texture_height;
     display->input_texture = input_texture;
-    gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_use_fbo), display);
+    gst_gl_window_send_message (display->gl_window,
+        GST_GL_WINDOW_CB (gst_gl_display_thread_use_fbo), display);
   }
   gst_gl_display_unlock (display);
 
@@ -1837,28 +1817,28 @@ gst_gl_display_use_fbo (GstGLDisplay* display, gint texture_fbo_width, gint text
 
 /* Called by gltestsrc and glfilter */
 void
-gst_gl_display_del_fbo (GstGLDisplay* display, GLuint fbo,
-                        GLuint depth_buffer)
+gst_gl_display_del_fbo (GstGLDisplay * display, GLuint fbo, GLuint depth_buffer)
 {
   gst_gl_display_lock (display);
   display->del_fbo = fbo;
   display->del_depth_buffer = depth_buffer;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_del_fbo), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_del_fbo), display);
   gst_gl_display_unlock (display);
 }
 
 
 /* Called by glfilter */
 void
-gst_gl_display_gen_shader (GstGLDisplay* display,
-                           const gchar* shader_vertex_source,
-                           const gchar* shader_fragment_source,
-                           GstGLShader** shader)
+gst_gl_display_gen_shader (GstGLDisplay * display,
+    const gchar * shader_vertex_source,
+    const gchar * shader_fragment_source, GstGLShader ** shader)
 {
   gst_gl_display_lock (display);
   display->gen_shader_vertex_source = shader_vertex_source;
   display->gen_shader_fragment_source = shader_fragment_source;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_gen_shader), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_gen_shader), display);
   if (shader)
     *shader = display->gen_shader;
   display->gen_shader = NULL;
@@ -1870,18 +1850,19 @@ gst_gl_display_gen_shader (GstGLDisplay* display,
 
 /* Called by glfilter */
 void
-gst_gl_display_del_shader (GstGLDisplay* display, GstGLShader* shader)
+gst_gl_display_del_shader (GstGLDisplay * display, GstGLShader * shader)
 {
   gst_gl_display_lock (display);
   display->del_shader = shader;
-  gst_gl_window_send_message (display->gl_window, GST_GL_WINDOW_CB (gst_gl_display_thread_del_shader), display);
+  gst_gl_window_send_message (display->gl_window,
+      GST_GL_WINDOW_CB (gst_gl_display_thread_del_shader), display);
   gst_gl_display_unlock (display);
 }
 
 
 /* Called by the glimagesink */
 void
-gst_gl_display_set_window_id (GstGLDisplay* display, gulong window_id)
+gst_gl_display_set_window_id (GstGLDisplay * display, gulong window_id)
 {
   gst_gl_display_lock (display);
   gst_gl_window_set_external_window_id (display->gl_window, window_id);
@@ -1914,11 +1895,11 @@ gst_gl_display_set_client_draw_callback (GstGLDisplay * display, CDCB cb)
 //------------------------------------------------------------
 
 /* called by gst_gl_display_thread_init_upload (in the gl thread) */
-void gst_gl_display_thread_init_upload_fbo (GstGLDisplay *display)
+void
+gst_gl_display_thread_init_upload_fbo (GstGLDisplay * display)
 {
   //Frame buffer object is a requirement for every cases
-  if (GLEW_EXT_framebuffer_object)
-  {
+  if (GLEW_EXT_framebuffer_object) {
     //a texture must be attached to the FBO
     GLuint fake_texture = 0;
 
@@ -1931,40 +1912,39 @@ void gst_gl_display_thread_init_upload_fbo (GstGLDisplay *display)
     glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->upload_fbo);
 
     //setup the render buffer for depth
-    glGenRenderbuffersEXT(1, &display->upload_depth_buffer);
-    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
-    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
-                      display->upload_width, display->upload_height);
+    glGenRenderbuffersEXT (1, &display->upload_depth_buffer);
+    glBindRenderbufferEXT (GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
+    glRenderbufferStorageEXT (GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
+        display->upload_width, display->upload_height);
 
     //a fake texture is attached to the upload FBO (cannot init without it)
     glGenTextures (1, &fake_texture);
-    glBindTexture(GL_TEXTURE_RECTANGLE_ARB, fake_texture);
-    glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-       display->upload_width, display->upload_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, fake_texture);
+    glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+        display->upload_width, display->upload_height, 0, GL_RGBA,
+        GL_UNSIGNED_BYTE, NULL);
 
     //attach the texture to the FBO to renderer to
-    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                       GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
+    glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+        GL_TEXTURE_RECTANGLE_ARB, fake_texture, 0);
 
     //attach the depth render buffer to the FBO
-    glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
-                      GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
+    glFramebufferRenderbufferEXT (GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+        GL_RENDERBUFFER_EXT, display->upload_depth_buffer);
 
-    gst_gl_display_check_framebuffer_status();
+    gst_gl_display_check_framebuffer_status ();
 
     g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
         GL_FRAMEBUFFER_COMPLETE_EXT);
 
     //unbind the FBO
-    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+    glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
 
     glDeleteTextures (1, &fake_texture);
 
     //alloc texture (related to upload) memory only on time
     gst_gl_display_thread_do_upload_make (display);
-  }
-  else
-  {
+  } else {
     //turn off the pipeline because Frame buffer object is a not present
     GST_WARNING ("Context, EXT_framebuffer_object supported: no");
     display->isAlive = FALSE;
@@ -1972,7 +1952,8 @@ void gst_gl_display_thread_init_upload_fbo (GstGLDisplay *display)
 }
 
 /* called by gst_gl_display_thread_do_upload (in the gl thread) */
-void gst_gl_display_thread_do_upload_make (GstGLDisplay *display)
+void
+gst_gl_display_thread_do_upload_make (GstGLDisplay * display)
 {
   gint width = display->upload_data_width;
   gint height = display->upload_data_height;
@@ -1980,430 +1961,450 @@ void gst_gl_display_thread_do_upload_make (GstGLDisplay *display)
   glGenTextures (1, &display->upload_intex);
 
   glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-  switch (display->upload_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-    glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
-           width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-    break;
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-    glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
-           width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
-    break;
-  case GST_VIDEO_FORMAT_AYUV:
-               glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
-           width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-    switch (display->upload_colorspace_conversion)
-      {
-      case GST_GL_DISPLAY_CONVERSION_GLSL:
-      case GST_GL_DISPLAY_CONVERSION_MATRIX:
-        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
-          width, height,
-          0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
-        glGenTextures (1, &display->upload_intex_u);
-        glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-          width, height,
-          0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
-        break;
-      case GST_GL_DISPLAY_CONVERSION_MESA:
-        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
-          0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
-        break;
-      default:
-        g_assert_not_reached ();
+  switch (display->upload_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+      glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
+          width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+      break;
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
+          width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
+      break;
+    case GST_VIDEO_FORMAT_AYUV:
+      glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
+          width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL);
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
+              width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+          glGenTextures (1, &display->upload_intex_u);
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+              width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width,
+              height, 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
+          break;
+        default:
+          g_assert_not_reached ();
       }
-    break;
-  case GST_VIDEO_FORMAT_UYVY:
-    switch (display->upload_colorspace_conversion)
-      {
-      case GST_GL_DISPLAY_CONVERSION_GLSL:
-      case GST_GL_DISPLAY_CONVERSION_MATRIX:
-        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
-          width, height,
-          0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
-        glGenTextures (1, &display->upload_intex_u);
-        glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
-          width, height,
-          0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
-        break;
-      case GST_GL_DISPLAY_CONVERSION_MESA:
-        glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
-          0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
-        break;
-      default:
-        g_assert_not_reached ();
+      break;
+    case GST_VIDEO_FORMAT_UYVY:
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
+              width, height, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
+          glGenTextures (1, &display->upload_intex_u);
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
+              width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+          glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width,
+              height, 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
+          break;
+        default:
+          g_assert_not_reached ();
       }
-    break;
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-    glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
-      width, height,
-      0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
-
-    glGenTextures (1, &display->upload_intex_u);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-    glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
-      GST_ROUND_UP_2 (width) / 2,
-      GST_ROUND_UP_2 (height) / 2,
-      0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
-
-    glGenTextures (1, &display->upload_intex_v);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
-    glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
-      GST_ROUND_UP_2 (width) / 2,
-      GST_ROUND_UP_2 (height) / 2,
-      0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
-    break;
-
-  default:
-    g_assert_not_reached ();
+      break;
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+      glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
+          width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
+
+      glGenTextures (1, &display->upload_intex_u);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+      glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
+          GST_ROUND_UP_2 (width) / 2,
+          GST_ROUND_UP_2 (height) / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
+
+      glGenTextures (1, &display->upload_intex_v);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
+      glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
+          GST_ROUND_UP_2 (width) / 2,
+          GST_ROUND_UP_2 (height) / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
+      break;
+
+    default:
+      g_assert_not_reached ();
   }
 }
 
 
 /* called by gst_gl_display_thread_do_upload (in the gl thread) */
 void
-gst_gl_display_thread_do_upload_fill (GstGLDisplay *display)
+gst_gl_display_thread_do_upload_fill (GstGLDisplay * display)
 {
   gint width = display->upload_data_width;
   gint height = display->upload_data_height;
   gpointer data = display->upload_data;
 
-  switch (display->upload_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-    //color space conversion is not needed
-    if (display->upload_width != display->upload_data_width ||
-        display->upload_height != display->upload_data_height)
-      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-    else
-      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  case GST_VIDEO_FORMAT_AYUV:
-    switch (display->upload_colorspace_conversion)
-    {
-    case GST_GL_DISPLAY_CONVERSION_GLSL:
-    case GST_GL_DISPLAY_CONVERSION_MATRIX:
-      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-      break;
-    case GST_GL_DISPLAY_CONVERSION_MESA:
+  switch (display->upload_video_format) {
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+      //color space conversion is not needed
       if (display->upload_width != display->upload_data_width ||
           display->upload_height != display->upload_data_height)
         glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
       else
         glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex);
       break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    case GST_VIDEO_FORMAT_AYUV:
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+          if (display->upload_width != display->upload_data_width ||
+              display->upload_height != display->upload_data_height)
+            glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+          else
+            glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex);
+          break;
+        default:
+          g_assert_not_reached ();
+      }
+      break;
     default:
-      g_assert_not_reached();
-    }
-    break;
-  default:
-         g_assert_not_reached ();
+      g_assert_not_reached ();
   }
 
   switch (display->upload_video_format) {
-  case GST_VIDEO_FORMAT_RGB:
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_RGB, GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_BGR:
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_BGR, GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_RGBA:
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_RGBA, GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_BGRA:
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_BGRA, GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_AYUV:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_ARGB:
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
-    break;
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_ABGR:
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-    switch (display->upload_colorspace_conversion)
-    {
-    case GST_GL_DISPLAY_CONVERSION_GLSL:
-    case GST_GL_DISPLAY_CONVERSION_MATRIX:
+    case GST_VIDEO_FORMAT_RGB:
       glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                      GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
-
-      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
-                      GST_ROUND_UP_2 (width) / 2, height,
-                      GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+          GL_RGB, GL_UNSIGNED_BYTE, data);
       break;
-    case GST_GL_DISPLAY_CONVERSION_MESA:
+    case GST_VIDEO_FORMAT_BGR:
       glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                      GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
+          GL_BGR, GL_UNSIGNED_BYTE, data);
       break;
-    default:
-      g_assert_not_reached ();
-    }
-    break;
-  case GST_VIDEO_FORMAT_UYVY:
-    switch (display->upload_colorspace_conversion)
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_RGBA:
+      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+          GL_RGBA, GL_UNSIGNED_BYTE, data);
+      break;
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_BGRA:
+      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+          GL_BGRA, GL_UNSIGNED_BYTE, data);
+      break;
+    case GST_VIDEO_FORMAT_AYUV:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_ARGB:
+      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+          GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
+      break;
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_ABGR:
+      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+          GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+          glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+              GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
+
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+          glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+              GST_ROUND_UP_2 (width) / 2, height,
+              GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+          glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+              GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
+          break;
+        default:
+          g_assert_not_reached ();
+      }
+      break;
+    case GST_VIDEO_FORMAT_UYVY:
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+          glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+              GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
+
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+          glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+              GST_ROUND_UP_2 (width) / 2, height,
+              GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+          glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
+              GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
+          break;
+        default:
+          g_assert_not_reached ();
+      }
+      break;
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
     {
-    case GST_GL_DISPLAY_CONVERSION_GLSL:
-    case GST_GL_DISPLAY_CONVERSION_MATRIX:
       glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                      GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data);
+          GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
 
       glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
       glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
-                      GST_ROUND_UP_2 (width) / 2, height,
-                      GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
-      break;
-    case GST_GL_DISPLAY_CONVERSION_MESA:
-      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                      GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
+          GST_ROUND_UP_2 (width) / 2, GST_ROUND_UP_2 (height) / 2,
+          GL_LUMINANCE, GL_UNSIGNED_BYTE,
+          (guint8 *) data +
+          gst_video_format_get_component_offset (display->upload_video_format,
+              1, width, height));
+
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
+      glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
+          GST_ROUND_UP_2 (width) / 2, GST_ROUND_UP_2 (height) / 2,
+          GL_LUMINANCE, GL_UNSIGNED_BYTE,
+          (guint8 *) data +
+          gst_video_format_get_component_offset (display->upload_video_format,
+              2, width, height));
+    }
       break;
     default:
       g_assert_not_reached ();
-    }
-    break;
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  {
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
-                    GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
-
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
-                    GST_ROUND_UP_2 (width) / 2, GST_ROUND_UP_2 (height) / 2,
-                    GL_LUMINANCE, GL_UNSIGNED_BYTE,
-                    (guint8 *) data +
-                    gst_video_format_get_component_offset (display->upload_video_format, 1, width, height));
-
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
-    glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
-                    GST_ROUND_UP_2 (width) / 2, GST_ROUND_UP_2 (height) / 2,
-                    GL_LUMINANCE, GL_UNSIGNED_BYTE,
-                    (guint8 *) data +
-                    gst_video_format_get_component_offset (display->upload_video_format, 2, width, height));
-  }
-  break;
-  default:
-    g_assert_not_reached ();
   }
 }
 
 
 /* called by gst_gl_display_thread_do_upload (in the gl thread) */
 void
-gst_gl_display_thread_do_upload_draw (GstGLDisplay *display)
+gst_gl_display_thread_do_upload_draw (GstGLDisplay * display)
 {
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, display->upload_fbo);
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->upload_fbo);
 
   //setup a texture to render to
   glEnable (GL_TEXTURE_RECTANGLE_ARB);
-  glBindTexture(GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex);
+  glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex);
 
   //attach the texture to the FBO to renderer to
-  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-                           GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex, 0);
+  glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+      GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex, 0);
 
   if (GLEW_ARB_fragment_shader)
     gst_gl_shader_use (NULL);
 
-  glPushAttrib(GL_VIEWPORT_BIT);
-
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  gluOrtho2D(0.0, display->upload_width, 0.0, display->upload_height);
-
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
-
-  glViewport(0, 0, display->upload_width, display->upload_height);
-
-  glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
-  glClearColor(0.0, 0.0, 0.0, 0.0);
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  switch (display->upload_video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_ARGB:
-  case GST_VIDEO_FORMAT_ABGR:
-  case GST_VIDEO_FORMAT_RGB:
-  case GST_VIDEO_FORMAT_BGR:
-       {
-               glMatrixMode (GL_PROJECTION);
-               glLoadIdentity ();
-
-               glEnable(GL_TEXTURE_RECTANGLE_ARB);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-               glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-               glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-               glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-               glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-               glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-       }
-       break;
-
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  {
-    switch (display->upload_colorspace_conversion)
-    {
-    case GST_GL_DISPLAY_CONVERSION_GLSL:
-    case GST_GL_DISPLAY_CONVERSION_MATRIX:
-    {
-        GstGLShader* shader_upload_YUY2_UYVY = NULL;
+  glPushAttrib (GL_VIEWPORT_BIT);
 
-        switch (display->upload_video_format)
-        {
-        case GST_VIDEO_FORMAT_YUY2:
-          shader_upload_YUY2_UYVY = display->shader_upload_YUY2;
-          break;
-        case GST_VIDEO_FORMAT_UYVY:
-          shader_upload_YUY2_UYVY = display->shader_upload_UYVY;
-          break;
-        default:
-          g_assert_not_reached ();
-        }
+  glMatrixMode (GL_PROJECTION);
+  glPushMatrix ();
+  glLoadIdentity ();
+  gluOrtho2D (0.0, display->upload_width, 0.0, display->upload_height);
 
-        gst_gl_shader_use (shader_upload_YUY2_UYVY);
+  glMatrixMode (GL_MODELVIEW);
+  glPushMatrix ();
+  glLoadIdentity ();
 
-        glMatrixMode (GL_PROJECTION);
-        glLoadIdentity ();
+  glViewport (0, 0, display->upload_width, display->upload_height);
 
-        glActiveTextureARB(GL_TEXTURE1_ARB);
-        gst_gl_shader_set_uniform_1i (shader_upload_YUY2_UYVY, "UVtex", 1);
-        glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+  glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
+  glClearColor (0.0, 0.0, 0.0, 0.0);
+  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-        glActiveTextureARB(GL_TEXTURE0_ARB);
-        gst_gl_shader_set_uniform_1i (shader_upload_YUY2_UYVY, "Ytex", 0);
-        glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-      }
+  switch (display->upload_video_format) {
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+    {
+      glMatrixMode (GL_PROJECTION);
+      glLoadIdentity ();
+
+      glEnable (GL_TEXTURE_RECTANGLE_ARB);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+          GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+          GL_CLAMP_TO_EDGE);
+      glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+    }
       break;
-    case GST_GL_DISPLAY_CONVERSION_MESA:
-      {
-        glMatrixMode (GL_PROJECTION);
-        glLoadIdentity ();
 
-        glEnable(GL_TEXTURE_RECTANGLE_ARB);
-        glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-        glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+    {
+      switch (display->upload_colorspace_conversion) {
+        case GST_GL_DISPLAY_CONVERSION_GLSL:
+        case GST_GL_DISPLAY_CONVERSION_MATRIX:
+        {
+          GstGLShader *shader_upload_YUY2_UYVY = NULL;
+
+          switch (display->upload_video_format) {
+            case GST_VIDEO_FORMAT_YUY2:
+              shader_upload_YUY2_UYVY = display->shader_upload_YUY2;
+              break;
+            case GST_VIDEO_FORMAT_UYVY:
+              shader_upload_YUY2_UYVY = display->shader_upload_UYVY;
+              break;
+            default:
+              g_assert_not_reached ();
+          }
+
+          gst_gl_shader_use (shader_upload_YUY2_UYVY);
+
+          glMatrixMode (GL_PROJECTION);
+          glLoadIdentity ();
+
+          glActiveTextureARB (GL_TEXTURE1_ARB);
+          gst_gl_shader_set_uniform_1i (shader_upload_YUY2_UYVY, "UVtex", 1);
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+              GL_LINEAR);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+              GL_LINEAR);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+              GL_CLAMP_TO_EDGE);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+              GL_CLAMP_TO_EDGE);
+
+          glActiveTextureARB (GL_TEXTURE0_ARB);
+          gst_gl_shader_set_uniform_1i (shader_upload_YUY2_UYVY, "Ytex", 0);
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+              GL_LINEAR);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+              GL_LINEAR);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+              GL_CLAMP_TO_EDGE);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+              GL_CLAMP_TO_EDGE);
+        }
+          break;
+        case GST_GL_DISPLAY_CONVERSION_MESA:
+        {
+          glMatrixMode (GL_PROJECTION);
+          glLoadIdentity ();
+
+          glEnable (GL_TEXTURE_RECTANGLE_ARB);
+          glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+              GL_LINEAR);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+              GL_LINEAR);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+              GL_CLAMP_TO_EDGE);
+          glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+              GL_CLAMP_TO_EDGE);
+          glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+        }
+          break;
+        default:
+          g_assert_not_reached ();
       }
-      break;
-    default:
-      g_assert_not_reached ();
     }
-  }
-  break;
+      break;
 
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  {
-    gst_gl_shader_use (display->shader_upload_I420_YV12);
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    {
+      gst_gl_shader_use (display->shader_upload_I420_YV12);
 
-    glMatrixMode (GL_PROJECTION);
-    glLoadIdentity ();
+      glMatrixMode (GL_PROJECTION);
+      glLoadIdentity ();
 
-    glActiveTextureARB(GL_TEXTURE1_ARB);
-    gst_gl_shader_set_uniform_1i (display->shader_upload_I420_YV12, "Utex", 1);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-    glActiveTextureARB(GL_TEXTURE2_ARB);
-    gst_gl_shader_set_uniform_1i (display->shader_upload_I420_YV12, "Vtex", 2);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
-    glActiveTextureARB(GL_TEXTURE0_ARB);
-    gst_gl_shader_set_uniform_1i (display->shader_upload_I420_YV12, "Ytex", 0);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-  }
-  break;
+      glActiveTextureARB (GL_TEXTURE1_ARB);
+      gst_gl_shader_set_uniform_1i (display->shader_upload_I420_YV12, "Utex",
+          1);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+          GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+          GL_CLAMP_TO_EDGE);
+
+      glActiveTextureARB (GL_TEXTURE2_ARB);
+      gst_gl_shader_set_uniform_1i (display->shader_upload_I420_YV12, "Vtex",
+          2);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+          GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+          GL_CLAMP_TO_EDGE);
+
+      glActiveTextureARB (GL_TEXTURE0_ARB);
+      gst_gl_shader_set_uniform_1i (display->shader_upload_I420_YV12, "Ytex",
+          0);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+          GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+          GL_CLAMP_TO_EDGE);
+    }
+      break;
 
-  case GST_VIDEO_FORMAT_AYUV:
-  {
-    gst_gl_shader_use (display->shader_upload_AYUV);
+    case GST_VIDEO_FORMAT_AYUV:
+    {
+      gst_gl_shader_use (display->shader_upload_AYUV);
 
-    glMatrixMode (GL_PROJECTION);
-    glLoadIdentity ();
+      glMatrixMode (GL_PROJECTION);
+      glLoadIdentity ();
 
-    glActiveTextureARB(GL_TEXTURE0_ARB);
-    gst_gl_shader_set_uniform_1i (display->shader_upload_AYUV, "tex", 0);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-  }
-  break;
+      glActiveTextureARB (GL_TEXTURE0_ARB);
+      gst_gl_shader_set_uniform_1i (display->shader_upload_AYUV, "tex", 0);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
+          GL_LINEAR);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S,
+          GL_CLAMP_TO_EDGE);
+      glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T,
+          GL_CLAMP_TO_EDGE);
+    }
+      break;
 
-  default:
-    g_assert_not_reached ();
+    default:
+      g_assert_not_reached ();
 
-  }//end switch display->currentVideo_format
+  }                             //end switch display->currentVideo_format
 
   glBegin (GL_QUADS);
   glTexCoord2i (display->upload_data_width, 0);
@@ -2416,29 +2417,29 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay *display)
   glVertex2f (1.0f, 1.0f);
   glEnd ();
 
-  glDrawBuffer(GL_NONE);
+  glDrawBuffer (GL_NONE);
 
   //we are done with the shader
   if (display->upload_colorspace_conversion == GST_GL_DISPLAY_CONVERSION_GLSL)
     glUseProgramObjectARB (0);
 
-  glDisable(GL_TEXTURE_RECTANGLE_ARB);
+  glDisable (GL_TEXTURE_RECTANGLE_ARB);
 
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-  glPopAttrib();
+  glMatrixMode (GL_PROJECTION);
+  glPopMatrix ();
+  glMatrixMode (GL_MODELVIEW);
+  glPopMatrix ();
+  glPopAttrib ();
 
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
 
-  gst_gl_display_check_framebuffer_status();
+  gst_gl_display_check_framebuffer_status ();
 }
 
 
 /* called by gst_gl_display_thread_do_download (in the gl thread) */
 void
-gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay *display)
+gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
 {
   GstVideoFormat video_format = display->download_video_format;
   gpointer data = display->download_data;
@@ -2446,140 +2447,138 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay *display)
   glEnable (GL_TEXTURE_RECTANGLE_ARB);
   glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
 
-  switch (video_format)
-  {
-  case GST_VIDEO_FORMAT_RGBA:
-  case GST_VIDEO_FORMAT_RGBx:
-  case GST_VIDEO_FORMAT_xRGB:
-  case GST_VIDEO_FORMAT_ARGB:
-    glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
-                 GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_BGRx:
-  case GST_VIDEO_FORMAT_BGRA:
-  case GST_VIDEO_FORMAT_xBGR:
-  case GST_VIDEO_FORMAT_ABGR:
-    glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
-                 GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_RGB:
-    glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
-                 GL_UNSIGNED_BYTE, data);
-    break;
-  case GST_VIDEO_FORMAT_BGR:
-    glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR,
-                 GL_UNSIGNED_BYTE, data);
-    break;
-  default:
+  switch (video_format) {
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_ARGB:
+      glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
+          GL_UNSIGNED_BYTE, data);
+      break;
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_ABGR:
+      glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
+          GL_UNSIGNED_BYTE, data);
+      break;
+    case GST_VIDEO_FORMAT_RGB:
+      glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
+          GL_UNSIGNED_BYTE, data);
+      break;
+    case GST_VIDEO_FORMAT_BGR:
+      glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR,
+          GL_UNSIGNED_BYTE, data);
+      break;
+    default:
       g_assert_not_reached ();
-    }
+  }
 }
 
 
 /* called by gst_gl_display_thread_do_download (in the gl thread) */
 void
-gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay *display)
+gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
 {
   gint width = display->download_width;
   gint height = display->download_height;
   GstVideoFormat video_format = display->download_video_format;
   gpointer data = display->download_data;
 
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, display->download_fbo);
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->download_fbo);
 
-  glPushAttrib(GL_VIEWPORT_BIT);
+  glPushAttrib (GL_VIEWPORT_BIT);
 
-  glMatrixMode(GL_PROJECTION);
-  glPushMatrix();
-  glLoadIdentity();
-  gluOrtho2D(0.0, width, 0.0, height);
+  glMatrixMode (GL_PROJECTION);
+  glPushMatrix ();
+  glLoadIdentity ();
+  gluOrtho2D (0.0, width, 0.0, height);
 
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-  glLoadIdentity();
+  glMatrixMode (GL_MODELVIEW);
+  glPushMatrix ();
+  glLoadIdentity ();
 
-  glViewport(0, 0, width, height);
+  glViewport (0, 0, width, height);
 
-  switch (video_format)
-  {
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-  {
-    GstGLShader* shader_download_YUY2_UYVY = NULL;
-
-    switch (video_format)
-    {
+  switch (video_format) {
     case GST_VIDEO_FORMAT_YUY2:
-      shader_download_YUY2_UYVY = display->shader_download_YUY2;
-      break;
     case GST_VIDEO_FORMAT_UYVY:
-      shader_download_YUY2_UYVY = display->shader_download_UYVY;
-      break;
-    default:
-      g_assert_not_reached ();
-    }
+    {
+      GstGLShader *shader_download_YUY2_UYVY = NULL;
 
-    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+      switch (video_format) {
+        case GST_VIDEO_FORMAT_YUY2:
+          shader_download_YUY2_UYVY = display->shader_download_YUY2;
+          break;
+        case GST_VIDEO_FORMAT_UYVY:
+          shader_download_YUY2_UYVY = display->shader_download_UYVY;
+          break;
+        default:
+          g_assert_not_reached ();
+      }
 
-    glClearColor(0.0, 0.0, 0.0, 0.0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+      glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
 
-    gst_gl_shader_use (shader_download_YUY2_UYVY);
+      glClearColor (0.0, 0.0, 0.0, 0.0);
+      glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-    glMatrixMode (GL_PROJECTION);
-    glLoadIdentity ();
+      gst_gl_shader_use (shader_download_YUY2_UYVY);
 
-    glActiveTextureARB(GL_TEXTURE0_ARB);
-    gst_gl_shader_set_uniform_1i (shader_download_YUY2_UYVY, "tex", 0);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
-  }
-  break;
+      glMatrixMode (GL_PROJECTION);
+      glLoadIdentity ();
 
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  {
-    glDrawBuffers(3, display->multipleRT);
+      glActiveTextureARB (GL_TEXTURE0_ARB);
+      gst_gl_shader_set_uniform_1i (shader_download_YUY2_UYVY, "tex", 0);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
+    }
+      break;
 
-    glClearColor(0.0, 0.0, 0.0, 0.0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    {
+      glDrawBuffers (3, display->multipleRT);
 
-    gst_gl_shader_use (display->shader_download_I420_YV12);
+      glClearColor (0.0, 0.0, 0.0, 0.0);
+      glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-    glMatrixMode (GL_PROJECTION);
-    glLoadIdentity ();
+      gst_gl_shader_use (display->shader_download_I420_YV12);
 
-    glActiveTextureARB(GL_TEXTURE0_ARB);
-    gst_gl_shader_set_uniform_1i (display->shader_download_I420_YV12, "tex", 0);
-    gst_gl_shader_set_uniform_1f (display->shader_download_I420_YV12, "w",
-                                 (gfloat)display->ouput_texture_width);
-    gst_gl_shader_set_uniform_1f (display->shader_download_I420_YV12, "h",
-                                 (gfloat)display->ouput_texture_height);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
-  }
-  break;
+      glMatrixMode (GL_PROJECTION);
+      glLoadIdentity ();
 
-  case GST_VIDEO_FORMAT_AYUV:
-  {
-    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+      glActiveTextureARB (GL_TEXTURE0_ARB);
+      gst_gl_shader_set_uniform_1i (display->shader_download_I420_YV12, "tex",
+          0);
+      gst_gl_shader_set_uniform_1f (display->shader_download_I420_YV12, "w",
+          (gfloat) display->ouput_texture_width);
+      gst_gl_shader_set_uniform_1f (display->shader_download_I420_YV12, "h",
+          (gfloat) display->ouput_texture_height);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
+    }
+      break;
 
-    glClearColor(0.0, 0.0, 0.0, 0.0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+    case GST_VIDEO_FORMAT_AYUV:
+    {
+      glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
 
-    gst_gl_shader_use (display->shader_download_AYUV);
+      glClearColor (0.0, 0.0, 0.0, 0.0);
+      glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
-    glMatrixMode (GL_PROJECTION);
-    glLoadIdentity ();
+      gst_gl_shader_use (display->shader_download_AYUV);
 
-    glActiveTextureARB(GL_TEXTURE0_ARB);
-    gst_gl_shader_set_uniform_1i (display->shader_download_AYUV, "tex", 0);
-    glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
-  }
-  break;
+      glMatrixMode (GL_PROJECTION);
+      glLoadIdentity ();
 
-  default:
-    g_assert_not_reached ();
+      glActiveTextureARB (GL_TEXTURE0_ARB);
+      gst_gl_shader_set_uniform_1i (display->shader_download_AYUV, "tex", 0);
+      glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
+    }
+      break;
+
+    default:
+      g_assert_not_reached ();
 
-  }//end switch display->currentVideo_format
+  }                             //end switch display->currentVideo_format
 
   glBegin (GL_QUADS);
   glTexCoord2i (0, 0);
@@ -2592,63 +2591,61 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay *display)
   glVertex2f (-1.0f, 1.0f);
   glEnd ();
 
-  glDrawBuffer(GL_NONE);
+  glDrawBuffer (GL_NONE);
 
   //dot not check if GLSL is available
   //because for now download is not available
   //without GLSL
   glUseProgramObjectARB (0);
 
-  glDisable(GL_TEXTURE_RECTANGLE_ARB);
+  glDisable (GL_TEXTURE_RECTANGLE_ARB);
 
-  glMatrixMode(GL_PROJECTION);
-  glPopMatrix();
-  glMatrixMode(GL_MODELVIEW);
-  glPopMatrix();
-  glPopAttrib();
+  glMatrixMode (GL_PROJECTION);
+  glPopMatrix ();
+  glMatrixMode (GL_MODELVIEW);
+  glPopMatrix ();
+  glPopAttrib ();
 
   glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
 
-  gst_gl_display_check_framebuffer_status();
-
-  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, display->download_fbo);
-  glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
-
-  switch (video_format)
-  {
-  case GST_VIDEO_FORMAT_AYUV:
-  case GST_VIDEO_FORMAT_xRGB:
-    glReadPixels (0, 0, width, height, GL_BGRA,
-                 GL_UNSIGNED_INT_8_8_8_8, data);
-    break;
-  case GST_VIDEO_FORMAT_YUY2:
-  case GST_VIDEO_FORMAT_UYVY:
-    glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, height, GL_BGRA,
-                 GL_UNSIGNED_INT_8_8_8_8_REV, data);
-    break;
-  case GST_VIDEO_FORMAT_I420:
-  case GST_VIDEO_FORMAT_YV12:
-  {
-    glReadPixels (0, 0, width, height, GL_LUMINANCE,
-                 GL_UNSIGNED_BYTE, data);
-
-    glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
-    glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, GST_ROUND_UP_2 (height) / 2,
-                 GL_LUMINANCE, GL_UNSIGNED_BYTE,
-                 (guint8 *) data +
-                 gst_video_format_get_component_offset (video_format, 1, width, height));
-
-    glReadBuffer(GL_COLOR_ATTACHMENT2_EXT);
-    glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, GST_ROUND_UP_2 (height) / 2,
-                 GL_LUMINANCE, GL_UNSIGNED_BYTE,
-                 (guint8 *) data +
-                 gst_video_format_get_component_offset (video_format, 2, width, height));
-  }
-  break;
-  default:
-    g_assert_not_reached ();
+  gst_gl_display_check_framebuffer_status ();
+
+  glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, display->download_fbo);
+  glReadBuffer (GL_COLOR_ATTACHMENT0_EXT);
+
+  switch (video_format) {
+    case GST_VIDEO_FORMAT_AYUV:
+    case GST_VIDEO_FORMAT_xRGB:
+      glReadPixels (0, 0, width, height, GL_BGRA,
+          GL_UNSIGNED_INT_8_8_8_8, data);
+      break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+      glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, height, GL_BGRA,
+          GL_UNSIGNED_INT_8_8_8_8_REV, data);
+      break;
+    case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_YV12:
+    {
+      glReadPixels (0, 0, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
+
+      glReadBuffer (GL_COLOR_ATTACHMENT1_EXT);
+      glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2,
+          GST_ROUND_UP_2 (height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
+          (guint8 *) data + gst_video_format_get_component_offset (video_format,
+              1, width, height));
+
+      glReadBuffer (GL_COLOR_ATTACHMENT2_EXT);
+      glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2,
+          GST_ROUND_UP_2 (height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
+          (guint8 *) data + gst_video_format_get_component_offset (video_format,
+              2, width, height));
+    }
+      break;
+    default:
+      g_assert_not_reached ();
   }
 
   glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0);
-  gst_gl_display_check_framebuffer_status();
+  gst_gl_display_check_framebuffer_status ();
 }
index cfe002e..234f0e1 100644 (file)
@@ -31,48 +31,48 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
 
 
 static GstStaticPadTemplate gst_gl_filter_src_pad_template =
-  GST_STATIC_PAD_TEMPLATE ("src",
-                          GST_PAD_SRC,
-                          GST_PAD_ALWAYS,
-                          GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
+GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
     );
 
 static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
-  GST_STATIC_PAD_TEMPLATE ("sink",
-                          GST_PAD_SINK,
-                          GST_PAD_ALWAYS,
-                          GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
+GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
     );
 
 #define DEBUG_INIT(bla)                                                        \
   GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0, "glfilter element");
 
 GST_BOILERPLATE_FULL (GstGLFilter, gst_gl_filter, GstBaseTransform,
-                     GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
+    GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
 
 static void gst_gl_filter_set_property (GObject * object, guint prop_id,
-                                       const GValue * value, GParamSpec * pspec);
+    const GValue * value, GParamSpec * pspec);
 static void gst_gl_filter_get_property (GObject * object, guint prop_id,
-                                       GValue * value, GParamSpec * pspec);
+    GValue * value, GParamSpec * pspec);
 
-static GstCaps* gst_gl_filter_transform_caps (GstBaseTransform* bt,
-                                             GstPadDirection direction, GstCaps* caps);
+static GstCaps *gst_gl_filter_transform_caps (GstBaseTransform * bt,
+    GstPadDirection direction, GstCaps * caps);
 static void gst_gl_filter_reset (GstGLFilter * filter);
 static gboolean gst_gl_filter_start (GstBaseTransform * bt);
 static gboolean gst_gl_filter_stop (GstBaseTransform * bt);
 static gboolean gst_gl_filter_get_unit_size (GstBaseTransform * trans,
-                                            GstCaps * caps, guint * size);
+    GstCaps * caps, guint * size);
 static GstFlowReturn gst_gl_filter_transform (GstBaseTransform * bt,
-                                             GstBuffer * inbuf, GstBuffer * outbuf);
+    GstBuffer * inbuf, GstBuffer * outbuf);
 static GstFlowReturn gst_gl_filter_prepare_output_buffer (GstBaseTransform *
-                                                         trans, GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
+    trans, GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
 static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
-                                       GstCaps * outcaps);
+    GstCaps * outcaps);
 static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
-                                           GstGLBuffer * inbuf, GstGLBuffer * outbuf);
+    GstGLBuffer * inbuf, GstGLBuffer * outbuf);
 /* GstGLDisplayThreadFunc */
-static void gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data);
-static void gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data);
+static void gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data);
+static void gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data);
 
 
 static void
@@ -81,9 +81,9 @@ gst_gl_filter_base_init (gpointer klass)
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
 
   gst_element_class_add_pad_template (element_class,
-                                     gst_static_pad_template_get (&gst_gl_filter_src_pad_template));
+      gst_static_pad_template_get (&gst_gl_filter_src_pad_template));
   gst_element_class_add_pad_template (element_class,
-                                     gst_static_pad_template_get (&gst_gl_filter_sink_pad_template));
+      gst_static_pad_template_get (&gst_gl_filter_sink_pad_template));
 }
 
 static void
@@ -96,14 +96,14 @@ gst_gl_filter_class_init (GstGLFilterClass * klass)
   gobject_class->get_property = gst_gl_filter_get_property;
 
   GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
-    gst_gl_filter_transform_caps;
+      gst_gl_filter_transform_caps;
   GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_filter_transform;
   GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_filter_start;
   GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_stop;
   GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_filter_set_caps;
   GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size = gst_gl_filter_get_unit_size;
   GST_BASE_TRANSFORM_CLASS (klass)->prepare_output_buffer =
-    gst_gl_filter_prepare_output_buffer;
+      gst_gl_filter_prepare_output_buffer;
 
   klass->set_caps = NULL;
   klass->filter = NULL;
@@ -128,48 +128,45 @@ gst_gl_filter_init (GstGLFilter * filter, GstGLFilterClass * klass)
 
 static void
 gst_gl_filter_set_property (GObject * object, guint prop_id,
-                           const GValue * value, GParamSpec * pspec)
+    const GValue * value, GParamSpec * pspec)
 {
   //GstGLFilter *filter = GST_GL_FILTER (object);
 
-  switch (prop_id)
-  {
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-    break;
+  switch (prop_id) {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
   }
 }
 
 static void
 gst_gl_filter_get_property (GObject * object, guint prop_id,
-                           GValue * value, GParamSpec * pspec)
+    GValue * value, GParamSpec * pspec)
 {
   //GstGLFilter *filter = GST_GL_FILTER (object);
 
-  switch (prop_id)
-  {
-  default:
-    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-    break;
+  switch (prop_id) {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
   }
 }
 
 static void
-gst_gl_filter_reset (GstGLFilter* filter)
+gst_gl_filter_reset (GstGLFilter * filter)
 {
-  GstGLFilterClassfilter_class = GST_GL_FILTER_GET_CLASS (filter);
+  GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
 
-  if (filter->display)
-  {
+  if (filter->display) {
     if (filter_class->onReset)
       filter_class->onReset (filter);
 
     if (filter_class->display_reset_cb != NULL) {
-      gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl, filter);
+      gst_gl_display_thread_add (filter->display, gst_gl_filter_stop_gl,
+          filter);
     }
     //blocking call, delete the FBO
-    gst_gl_display_del_fbo (filter->display, filter->fbo,
-                           filter->depthbuffer);
+    gst_gl_display_del_fbo (filter->display, filter->fbo, filter->depthbuffer);
     g_object_unref (filter->display);
     filter->display = NULL;
   }
@@ -180,19 +177,19 @@ gst_gl_filter_reset (GstGLFilter* filter)
 }
 
 static gboolean
-gst_gl_filter_start (GstBaseTransform* bt)
+gst_gl_filter_start (GstBaseTransform * bt)
 {
   GstGLFilter *filter = GST_GL_FILTER (bt);
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
 
   if (filter_class->onStart)
     filter_class->onStart (filter);
-  
+
   return TRUE;
 }
 
 static gboolean
-gst_gl_filter_stop (GstBaseTransform* bt)
+gst_gl_filter_stop (GstBaseTransform * bt)
 {
   GstGLFilter *filter = GST_GL_FILTER (bt);
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@@ -206,7 +203,7 @@ gst_gl_filter_stop (GstBaseTransform* bt)
 }
 
 static void
-gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data)
+gst_gl_filter_start_gl (GstGLDisplay * display, gpointer data)
 {
   GstGLFilter *filter = GST_GL_FILTER (data);
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@@ -215,7 +212,7 @@ gst_gl_filter_start_gl (GstGLDisplay *display, gpointer data)
 }
 
 static void
-gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data)
+gst_gl_filter_stop_gl (GstGLDisplay * display, gpointer data)
 {
   GstGLFilter *filter = GST_GL_FILTER (data);
   GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
@@ -223,30 +220,28 @@ gst_gl_filter_stop_gl (GstGLDisplay *display, gpointer data)
   filter_class->display_reset_cb (filter);
 }
 
-static GstCaps*
-gst_gl_filter_transform_caps (GstBaseTransform* bt,
-                             GstPadDirection direction, GstCaps* caps)
+static GstCaps *
+gst_gl_filter_transform_caps (GstBaseTransform * bt,
+    GstPadDirection direction, GstCaps * caps)
 {
   //GstGLFilter* filter = GST_GL_FILTER (bt);
-  GstStructurestructure = gst_caps_get_structure (caps, 0);
-  GstCapsret = gst_caps_copy (caps);
-  const GValuepar = NULL;
+  GstStructure *structure = gst_caps_get_structure (caps, 0);
+  GstCaps *ret = gst_caps_copy (caps);
+  const GValue *par = NULL;
 
   structure = gst_structure_copy (gst_caps_get_structure (ret, 0));
 
   gst_structure_set (structure,
-                    "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
-                    "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
+      "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
+      "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
 
   gst_caps_merge_structure (ret, gst_structure_copy (structure));
 
-  if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio")))
-  {
+  if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
     gst_structure_set (structure,
-                      "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
+        "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
     gst_caps_merge_structure (ret, structure);
-  }
-  else
+  } else
     gst_structure_free (structure);
 
   GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, ret);
@@ -256,8 +251,8 @@ gst_gl_filter_transform_caps (GstBaseTransform* bt,
 
 
 static gboolean
-gst_gl_filter_get_unit_size (GstBaseTransform* trans, GstCaps* caps,
-                            guint* size)
+gst_gl_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
+    guint * size)
 {
   gboolean ret = FALSE;
   gint width = 0;
@@ -271,27 +266,27 @@ gst_gl_filter_get_unit_size (GstBaseTransform* trans, GstCaps* caps,
 }
 
 static GstFlowReturn
-gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
-                                    GstBuffer* inbuf, gint size, GstCaps* caps, GstBuffer** buf)
+gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
+    GstBuffer * inbuf, gint size, GstCaps * caps, GstBuffer ** buf)
 {
-  GstGLFilterfilter = NULL;
-  GstGLBuffergl_inbuf = GST_GL_BUFFER (inbuf);
-  GstGLBuffergl_outbuf = NULL;
+  GstGLFilter *filter = NULL;
+  GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
+  GstGLBuffer *gl_outbuf = NULL;
 
   filter = GST_GL_FILTER (trans);
 
-  if (filter->display == NULL)
-  {
-    GstGLFilterClass* filter_class = GST_GL_FILTER_GET_CLASS (filter);
+  if (filter->display == NULL) {
+    GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
 
     filter->display = g_object_ref (gl_inbuf->display);
 
     //blocking call, generate a FBO
     gst_gl_display_gen_fbo (filter->display, filter->width, filter->height,
-                           &filter->fbo, &filter->depthbuffer);
+        &filter->fbo, &filter->depthbuffer);
 
     if (filter_class->display_init_cb != NULL) {
-      gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl, filter);
+      gst_gl_display_thread_add (filter->display, gst_gl_filter_start_gl,
+          filter);
     }
 
     if (filter_class->onInitFBO)
@@ -299,7 +294,7 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
   }
 
   gl_outbuf = gst_gl_buffer_new (filter->display,
-                                filter->width, filter->height);
+      filter->width, filter->height);
 
   *buf = GST_BUFFER (gl_outbuf);
   gst_buffer_set_caps (*buf, caps);
@@ -311,20 +306,19 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans,
 }
 
 static gboolean
-gst_gl_filter_set_caps (GstBaseTransform* bt, GstCaps* incaps,
-                       GstCaps* outcaps)
+gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
+    GstCaps * outcaps)
 {
-  GstGLFilterfilter = GST_GL_FILTER (bt);
+  GstGLFilter *filter = GST_GL_FILTER (bt);
   gboolean ret = FALSE;
-  GstGLFilterClassfilter_class = GST_GL_FILTER_GET_CLASS (filter);
+  GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
 
   ret = gst_gl_buffer_parse_caps (outcaps, &filter->width, &filter->height);
 
   if (filter_class->set_caps)
     filter_class->set_caps (filter, incaps, outcaps);
 
-  if (!ret)
-  {
+  if (!ret) {
     GST_DEBUG ("bad caps");
     return FALSE;
   }
@@ -335,12 +329,12 @@ gst_gl_filter_set_caps (GstBaseTransform* bt, GstCaps* incaps,
 }
 
 static GstFlowReturn
-gst_gl_filter_transform (GstBaseTransform* bt, GstBuffer* inbuf,
-                        GstBuffer* outbuf)
+gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
+    GstBuffer * outbuf)
 {
-  GstGLFilterfilter;
-  GstGLBuffergl_inbuf = GST_GL_BUFFER (inbuf);
-  GstGLBuffergl_outbuf = GST_GL_BUFFER (outbuf);
+  GstGLFilter *filter;
+  GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
+  GstGLBuffer *gl_outbuf = GST_GL_BUFFER (outbuf);
 
   filter = GST_GL_FILTER (bt);
 
@@ -350,10 +344,10 @@ gst_gl_filter_transform (GstBaseTransform* bt, GstBuffer* inbuf,
 }
 
 static gboolean
-gst_gl_filter_do_transform (GstGLFilter* filter,
-                           GstGLBuffer* inbuf, GstGLBuffer* outbuf)
+gst_gl_filter_do_transform (GstGLFilter * filter,
+    GstGLBuffer * inbuf, GstGLBuffer * outbuf)
 {
-  GstGLFilterClassfilter_class = GST_GL_FILTER_GET_CLASS (filter);
+  GstGLFilterClass *filter_class = GST_GL_FILTER_GET_CLASS (filter);
 
   filter_class->filter (filter, inbuf, outbuf);
 
@@ -363,15 +357,13 @@ gst_gl_filter_do_transform (GstGLFilter* filter,
 /* convenience functions to simplify filter development */
 
 void
-gst_gl_filter_render_to_target (GstGLFilter *filter,
-                               GLuint input, GLuint target,
-                               GLCB func, gpointer data)
+gst_gl_filter_render_to_target (GstGLFilter * filter,
+    GLuint input, GLuint target, GLCB func, gpointer data)
 {
   gst_gl_display_use_fbo (filter->display, filter->width, filter->height,
-                         filter->fbo, filter->depthbuffer, target,
-                         func,
-                         filter->width, filter->height, input,
-                         0, filter->width, 0, filter->height,
-                         GST_GL_DISPLAY_PROJECTION_ORTHO2D,
-                         data);
+      filter->fbo, filter->depthbuffer, target,
+      func,
+      filter->width, filter->height, input,
+      0, filter->width, 0, filter->height,
+      GST_GL_DISPLAY_PROJECTION_ORTHO2D, data);
 }
index ec63dfa..04cbbf4 100644 (file)
@@ -132,8 +132,8 @@ gst_gl_shader_get_property (GObject * object,
 }
 
 static void
-gst_gl_shader_log_handler (const gchar *domain, GLogLevelFlags flags,
-                           const gchar *message, gpointer user_data)
+gst_gl_shader_log_handler (const gchar * domain, GLogLevelFlags flags,
+    const gchar * message, gpointer user_data)
 {
   if (_gst_gl_shader_debug) {
     g_log_default_handler (domain, flags, message, user_data);
@@ -249,7 +249,7 @@ gst_gl_shader_init (GstGLShader * self)
     _gst_gl_shader_debug = TRUE;
 
   g_log_set_handler ("GstGLShader", G_LOG_LEVEL_DEBUG,
-                     gst_gl_shader_log_handler, NULL);
+      gst_gl_shader_log_handler, NULL);
 }
 
 GstGLShader *
@@ -511,7 +511,7 @@ gst_gl_shader_set_uniform_1i (GstGLShader * shader, const gchar * name,
 }
 
 GLint
-gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar *name)
+gst_gl_shader_get_attribute_location (GstGLShader * shader, const gchar * name)
 {
   GstGLShaderPrivate *priv;
 
index a37901b..33dbccf 100644 (file)
 #define WM_GST_GL_WINDOW_CUSTOM (WM_APP+1)
 #define WM_GST_GL_WINDOW_QUIT (WM_APP+2)
 
-void gst_gl_window_set_pixel_format (GstGLWindow *window);
-LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+void gst_gl_window_set_pixel_format (GstGLWindow * window);
+LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
+    LPARAM lParam);
+LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam,
+    LPARAM lParam);
 
 #define GST_GL_WINDOW_GET_PRIVATE(o)  \
   (G_TYPE_INSTANCE_GET_PRIVATE((o), GST_GL_TYPE_WINDOW, GstGLWindowPrivate))
@@ -79,8 +81,8 @@ gst_gl_window_finalize (GObject * object)
 }
 
 static void
-gst_gl_window_log_handler (const gchar *domain, GLogLevelFlags flags,
-                           const gchar *message, gpointer user_data)
+gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
+    const gchar * message, gpointer user_data)
 {
   if (_gst_gl_window_debug) {
     g_log_default_handler (domain, flags, message, user_data);
@@ -106,9 +108,8 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
 
   atom = GetClassInfo (hinstance, "GSTGL", &wc);
 
-  if (atom == 0)
-  {
-    ZeroMemory (&wc, sizeof(WNDCLASS));
+  if (atom == 0) {
+    ZeroMemory (&wc, sizeof (WNDCLASS));
 
     wc.lpfnWndProc = window_proc;
     wc.cbClsExtra = 0;
@@ -124,12 +125,12 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
     atom = RegisterClass (&wc);
 
     if (atom == 0)
-      g_error ("Failed to register window class %x\r\n", GetLastError());
+      g_error ("Failed to register window class %x\r\n", GetLastError ());
   }
 }
 
 static void
-gst_gl_window_init (GstGLWindow *window)
+gst_gl_window_init (GstGLWindow * window)
 {
   window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
 
@@ -137,7 +138,7 @@ gst_gl_window_init (GstGLWindow *window)
     _gst_gl_window_debug = TRUE;
 
   g_log_set_handler ("GstGLWindow", G_LOG_LEVEL_DEBUG,
-    gst_gl_window_log_handler, NULL);
+      gst_gl_window_log_handler, NULL);
 }
 
 /* Must be called in the gl thread */
@@ -146,7 +147,7 @@ gst_gl_window_new (gint width, gint height)
 {
   GstGLWindow *window = g_object_new (GST_GL_TYPE_WINDOW, NULL);
   GstGLWindowPrivate *priv = window->priv;
-  GstGLWindowClassklass = GST_GL_WINDOW_GET_CLASS (window);
+  GstGLWindowClass *klass = GST_GL_WINDOW_GET_CLASS (window);
 
   HINSTANCE hinstance = GetModuleHandle (NULL);
 
@@ -169,22 +170,16 @@ gst_gl_window_new (gint width, gint height)
   priv->visible = FALSE;
 
   width += 2 * GetSystemMetrics (SM_CXSIZEFRAME);
-  height += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
-
-  priv->internal_win_id = CreateWindowEx (
-    0,
-    "GSTGL",
-    "OpenGL renderer",
-    WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
-    x, y, width, height,
-    (HWND) NULL,
-    (HMENU) NULL,
-    hinstance,
-    window
-  );
-
-  if (!priv->internal_win_id)
-  {
+  height +=
+      2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION);
+
+  priv->internal_win_id = CreateWindowEx (0,
+      "GSTGL",
+      "OpenGL renderer",
+      WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW,
+      x, y, width, height, (HWND) NULL, (HMENU) NULL, hinstance, window);
+
+  if (!priv->internal_win_id) {
     g_debug ("failed to create gl window: %d\n", priv->internal_win_id);
     return NULL;
   }
@@ -206,36 +201,41 @@ gst_gl_window_error_quark (void)
 }
 
 void
-gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
+gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 id)
 {
   GstGLWindowPrivate *priv = window->priv;
-  WNDPROC window_parent_proc = (WNDPROC) (guint64) GetWindowLongPtr((HWND)id, GWL_WNDPROC);
+  WNDPROC window_parent_proc =
+      (WNDPROC) (guint64) GetWindowLongPtr ((HWND) id, GWL_WNDPROC);
   RECT rect;
 
-  SetProp (priv->internal_win_id, "gl_window_parent_id", (HWND)id);
-  SetProp ((HWND)id, "gl_window_id", priv->internal_win_id);
-  SetProp ((HWND)id, "gl_window_parent_proc", (WNDPROC) window_parent_proc);
-  SetWindowLongPtr ((HWND)id, GWL_WNDPROC, (DWORD) (guint64) sub_class_proc);
+  SetProp (priv->internal_win_id, "gl_window_parent_id", (HWND) id);
+  SetProp ((HWND) id, "gl_window_id", priv->internal_win_id);
+  SetProp ((HWND) id, "gl_window_parent_proc", (WNDPROC) window_parent_proc);
+  SetWindowLongPtr ((HWND) id, GWL_WNDPROC, (DWORD) (guint64) sub_class_proc);
 
   SetWindowLongPtr (priv->internal_win_id, GWL_STYLE, WS_CHILD | WS_MAXIMIZE);
-  SetParent (priv->internal_win_id, (HWND)id);
+  SetParent (priv->internal_win_id, (HWND) id);
 
   //take changes into account: SWP_FRAMECHANGED
-  GetClientRect ((HWND)id, &rect);
-  SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top, rect.right, rect.bottom,
-    SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE);
-  MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right, rect.bottom, FALSE);
+  GetClientRect ((HWND) id, &rect);
+  SetWindowPos (priv->internal_win_id, HWND_TOP, rect.left, rect.top,
+      rect.right, rect.bottom,
+      SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
+      SWP_FRAMECHANGED | SWP_NOACTIVATE);
+  MoveWindow (priv->internal_win_id, rect.left, rect.top, rect.right,
+      rect.bottom, FALSE);
 }
 
 void
-gst_gl_window_set_external_gl_context (GstGLWindow *window, guint64 context)
+gst_gl_window_set_external_gl_context (GstGLWindow * window, guint64 context)
 {
   g_warning ("gst_gl_window_set_external_gl_context: not implemented\n");
 }
 
 /* Must be called in the gl thread */
 void
-gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -245,7 +245,8 @@ gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gp
 
 /* Must be called in the gl thread */
 void
-gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback , gpointer data)
+gst_gl_window_set_resize_callback (GstGLWindow * window,
+    GstGLWindowCB2 callback, gpointer data)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -255,7 +256,8 @@ gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback
 
 /* Must be called in the gl thread */
 void
-gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -264,29 +266,28 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g
 }
 
 void
-gst_gl_window_draw_unlocked (GstGLWindow *window)
+gst_gl_window_draw_unlocked (GstGLWindow * window)
 {
   gst_gl_window_draw (window);
 }
 
 /* Thread safe */
 void
-gst_gl_window_draw (GstGLWindow *window)
+gst_gl_window_draw (GstGLWindow * window)
 {
   GstGLWindowPrivate *priv = window->priv;
 
-  if (!priv->visible)
-  {
+  if (!priv->visible) {
     ShowWindowAsync (priv->internal_win_id, SW_SHOW);
     priv->visible = TRUE;
   }
 
   RedrawWindow (priv->internal_win_id, NULL, NULL,
-    RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
+      RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE);
 }
 
 void
-gst_gl_window_run_loop (GstGLWindow *window)
+gst_gl_window_run_loop (GstGLWindow * window)
 {
   GstGLWindowPrivate *priv = window->priv;
   gboolean running = TRUE;
@@ -295,18 +296,14 @@ gst_gl_window_run_loop (GstGLWindow *window)
 
   g_debug ("begin loop\n");
 
-  while (running && (bRet = GetMessage (&msg, NULL, 0, 0)) != 0)
-  {
-      if (bRet == -1)
-      {
-          g_error ("Failed to get message %x\r\n", GetLastError());
-          running = FALSE;
-      }
-      else
-      {
-          TranslateMessage (&msg);
-          DispatchMessage (&msg);
-      }
+  while (running && (bRet = GetMessage (&msg, NULL, 0, 0)) != 0) {
+    if (bRet == -1) {
+      g_error ("Failed to get message %x\r\n", GetLastError ());
+      running = FALSE;
+    } else {
+      TranslateMessage (&msg);
+      DispatchMessage (&msg);
+    }
   }
 
   g_debug ("end loop\n");
@@ -314,12 +311,13 @@ gst_gl_window_run_loop (GstGLWindow *window)
 
 /* Thread safe */
 void
-gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
-  if (window)
-  {
+  if (window) {
     GstGLWindowPrivate *priv = window->priv;
-    LRESULT res = PostMessage(priv->internal_win_id, WM_GST_GL_WINDOW_QUIT, (WPARAM) data, (LPARAM) callback);
+    LRESULT res = PostMessage (priv->internal_win_id, WM_GST_GL_WINDOW_QUIT,
+        (WPARAM) data, (LPARAM) callback);
     g_assert (SUCCEEDED (res));
     g_debug ("end loop requested\n");
   }
@@ -327,12 +325,13 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
 
 /* Thread safe */
 void
-gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
-  if (window)
-  {
+  if (window) {
     GstGLWindowPrivate *priv = window->priv;
-    LRESULT res = SendMessage (priv->internal_win_id, WM_GST_GL_WINDOW_CUSTOM, (WPARAM) data, (LPARAM) callback);
+    LRESULT res = SendMessage (priv->internal_win_id, WM_GST_GL_WINDOW_CUSTOM,
+        (WPARAM) data, (LPARAM) callback);
     g_assert (SUCCEEDED (res));
   }
 }
@@ -340,56 +339,58 @@ gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointe
 /* PRIVATE */
 
 void
-gst_gl_window_set_pixel_format (GstGLWindow *window)
+gst_gl_window_set_pixel_format (GstGLWindow * window)
 {
-    GstGLWindowPrivate *priv = window->priv;
-    PIXELFORMATDESCRIPTOR pfd;
-    gint pixelformat = 0;
-    gboolean res = FALSE;
-
-    pfd.nSize           = sizeof(PIXELFORMATDESCRIPTOR);
-    pfd.nVersion        = 1;
-    pfd.dwFlags         = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
-    pfd.iPixelType      = PFD_TYPE_RGBA;
-    pfd.cColorBits      = 24;
-    pfd.cRedBits        = 0;
-    pfd.cRedShift       = 0;
-    pfd.cGreenBits      = 0;
-    pfd.cGreenShift     = 0;
-    pfd.cBlueBits       = 0;
-    pfd.cBlueShift      = 0;
-    pfd.cAlphaBits      = 0;
-    pfd.cAlphaShift     = 0;
-    pfd.cAccumBits      = 0;
-    pfd.cAccumRedBits   = 0;
-    pfd.cAccumGreenBits = 0;
-    pfd.cAccumBlueBits  = 0;
-    pfd.cAccumAlphaBits = 0;
-    pfd.cDepthBits      = 32;
-    pfd.cStencilBits    = 8;
-    pfd.cAuxBuffers     = 0;
-    pfd.iLayerType      = PFD_MAIN_PLANE;
-    pfd.bReserved       = 0;
-    pfd.dwLayerMask     = 0;
-    pfd.dwVisibleMask   = 0;
-    pfd.dwDamageMask    = 0;
-
-    pfd.cColorBits = (BYTE) GetDeviceCaps (priv->device, BITSPIXEL);
-
-    pixelformat = ChoosePixelFormat (priv->device, &pfd );
-
-    g_assert (pixelformat);
-
-    res = SetPixelFormat (priv->device, pixelformat, &pfd);
-
-    g_assert (res);
+  GstGLWindowPrivate *priv = window->priv;
+  PIXELFORMATDESCRIPTOR pfd;
+  gint pixelformat = 0;
+  gboolean res = FALSE;
+
+  pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR);
+  pfd.nVersion = 1;
+  pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+  pfd.iPixelType = PFD_TYPE_RGBA;
+  pfd.cColorBits = 24;
+  pfd.cRedBits = 0;
+  pfd.cRedShift = 0;
+  pfd.cGreenBits = 0;
+  pfd.cGreenShift = 0;
+  pfd.cBlueBits = 0;
+  pfd.cBlueShift = 0;
+  pfd.cAlphaBits = 0;
+  pfd.cAlphaShift = 0;
+  pfd.cAccumBits = 0;
+  pfd.cAccumRedBits = 0;
+  pfd.cAccumGreenBits = 0;
+  pfd.cAccumBlueBits = 0;
+  pfd.cAccumAlphaBits = 0;
+  pfd.cDepthBits = 32;
+  pfd.cStencilBits = 8;
+  pfd.cAuxBuffers = 0;
+  pfd.iLayerType = PFD_MAIN_PLANE;
+  pfd.bReserved = 0;
+  pfd.dwLayerMask = 0;
+  pfd.dwVisibleMask = 0;
+  pfd.dwDamageMask = 0;
+
+  pfd.cColorBits = (BYTE) GetDeviceCaps (priv->device, BITSPIXEL);
+
+  pixelformat = ChoosePixelFormat (priv->device, &pfd);
+
+  g_assert (pixelformat);
+
+  res = SetPixelFormat (priv->device, pixelformat, &pfd);
+
+  g_assert (res);
 }
 
-LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK
+window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
   if (uMsg == WM_CREATE) {
 
-    GstGLWindow *window = (GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
+    GstGLWindow *window =
+        (GstGLWindow *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
 
     g_debug ("WM_CREATE\n");
 
@@ -403,20 +404,21 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
       if (priv->gl_context)
         g_debug ("gl context created: %d\n", priv->gl_context);
       else
-        g_debug ("failed to create glcontext %d, %x\r\n", hWnd, GetLastError());
+        g_debug ("failed to create glcontext %d, %x\r\n", hWnd,
+            GetLastError ());
       g_assert (priv->gl_context);
       ReleaseDC (hWnd, priv->device);
       if (!wglMakeCurrent (priv->device, priv->gl_context))
-        g_debug ("failed to make opengl context current %d, %x\r\n", hWnd, GetLastError());
+        g_debug ("failed to make opengl context current %d, %x\r\n", hWnd,
+            GetLastError ());
     }
 
     SetProp (hWnd, "gl_window", window);
 
     return 0;
-  }
-  else if (GetProp(hWnd, "gl_window")) {
+  } else if (GetProp (hWnd, "gl_window")) {
 
-    GstGLWindow *window = GetProp(hWnd, "gl_window");
+    GstGLWindow *window = GetProp (hWnd, "gl_window");
     GstGLWindowPrivate *priv = NULL;
 
     g_assert (window);
@@ -427,21 +429,20 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
 
     g_assert (priv->internal_win_id == hWnd);
 
-    g_assert (priv->gl_context == wglGetCurrentContext());
+    g_assert (priv->gl_context == wglGetCurrentContext ());
 
-    switch ( uMsg ) {
+    switch (uMsg) {
 
       case WM_SIZE:
       {
         if (priv->resize_cb)
-          priv->resize_cb (priv->resize_data, LOWORD(lParam), HIWORD(lParam));
+          priv->resize_cb (priv->resize_data, LOWORD (lParam), HIWORD (lParam));
         break;
       }
 
       case WM_PAINT:
       {
-        if (priv->draw_cb)
-        {
+        if (priv->draw_cb) {
           PAINTSTRUCT ps;
           BeginPaint (hWnd, &ps);
           priv->draw_cb (priv->draw_data);
@@ -456,14 +457,14 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
         ShowWindowAsync (priv->internal_win_id, SW_HIDE);
 
         if (priv->close_cb)
-            priv->close_cb (priv->close_data);
-
-          priv->draw_cb = NULL;
-          priv->draw_data = NULL;
-          priv->resize_cb = NULL;
-          priv->resize_data = NULL;
-          priv->close_cb = NULL;
-          priv->close_data = NULL;
+          priv->close_cb (priv->close_data);
+
+        priv->draw_cb = NULL;
+        priv->draw_data = NULL;
+        priv->resize_cb = NULL;
+        priv->resize_data = NULL;
+        priv->close_cb = NULL;
+        priv->close_data = NULL;
         break;
       }
 
@@ -477,13 +478,13 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
         destroy_cb ((gpointer) wParam);
 
         parent_id = GetProp (hWnd, "gl_window_parent_id");
-        if (parent_id)
-        {
+        if (parent_id) {
           WNDPROC parent_proc = GetProp (parent_id, "gl_window_parent_proc");
 
           g_assert (parent_proc);
 
-          SetWindowLongPtr (parent_id, GWL_WNDPROC, (LONG) (guint64) parent_proc);
+          SetWindowLongPtr (parent_id, GWL_WNDPROC,
+              (LONG) (guint64) parent_proc);
           SetParent (hWnd, NULL);
 
           RemoveProp (parent_id, "gl_window_parent_proc");
@@ -494,19 +495,19 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
         RemoveProp (hWnd, "gl_window");
 
         if (!wglMakeCurrent (NULL, NULL))
-          g_debug ("failed to make current %d, %x\r\n", hWnd, GetLastError());
+          g_debug ("failed to make current %d, %x\r\n", hWnd, GetLastError ());
 
-        if (priv->gl_context)
-        {
+        if (priv->gl_context) {
           if (!wglDeleteContext (priv->gl_context))
-            g_debug ("failed to destroy context %d, %x\r\n", priv->gl_context, GetLastError());
+            g_debug ("failed to destroy context %d, %x\r\n", priv->gl_context,
+                GetLastError ());
         }
 
-        if (priv->internal_win_id)
-        {
+        if (priv->internal_win_id) {
           g_debug ("BEFORE\n");
-          if (!DestroyWindow(priv->internal_win_id))
-            g_debug ("failed to destroy window %d, %x\r\n", hWnd, GetLastError());
+          if (!DestroyWindow (priv->internal_win_id))
+            g_debug ("failed to destroy window %d, %x\r\n", hWnd,
+                GetLastError ());
           g_debug ("AFTER\n");
         }
 
@@ -524,8 +525,7 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
 
       case WM_GST_GL_WINDOW_CUSTOM:
       {
-        if (!priv->is_closed)
-        {
+        if (!priv->is_closed) {
           GstGLWindowCB custom_cb = (GstGLWindowCB) lParam;
           custom_cb ((gpointer) wParam);
         }
@@ -536,25 +536,23 @@ LRESULT CALLBACK window_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
         return TRUE;
 
       default:
-        return DefWindowProc( hWnd, uMsg, wParam, lParam );
+        return DefWindowProc (hWnd, uMsg, wParam, lParam);
     }
 
     return 0;
-  }
-  else
-    return DefWindowProc( hWnd, uMsg, wParam, lParam );
+  } else
+    return DefWindowProc (hWnd, uMsg, wParam, lParam);
 }
 
-LRESULT FAR PASCAL sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+LRESULT FAR PASCAL
+sub_class_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
   WNDPROC window_parent_proc = GetProp (hWnd, "gl_window_parent_proc");
 
-  if (uMsg == WM_SIZE)
-  {
+  if (uMsg == WM_SIZE) {
     HWND gl_window_id = GetProp (hWnd, "gl_window_id");
-    MoveWindow (gl_window_id, 0, 0, LOWORD(lParam), HIWORD(lParam), FALSE);
+    MoveWindow (gl_window_id, 0, 0, LOWORD (lParam), HIWORD (lParam), FALSE);
   }
 
   return CallWindowProc (window_parent_proc, hWnd, uMsg, wParam, lParam);
 }
-
index 57634b5..14dc124 100644 (file)
@@ -119,14 +119,14 @@ gst_gl_window_finalize (GObject * object)
 
   XSync (priv->device, FALSE);
 
-  while(XPending (priv->device))
+  while (XPending (priv->device))
     XNextEvent (priv->device, &event);
 
   XSetCloseDownMode (priv->device, DestroyAll);
 
   /*XAddToSaveSet (display, w)
-  Display *display;
-  Window w;*/
+     Display *display;
+     Window w; */
 
   //FIXME: it seems it causes destroy all created windows, even by other display connection:
   //This is case in: gst-launch-0.10 videotestsrc ! tee name=t t. ! queue ! glimagesink t. ! queue ! glimagesink
@@ -142,16 +142,14 @@ gst_gl_window_finalize (GObject * object)
 
   g_debug ("display sender closed\n");
 
-  if (priv->cond_send_message)
-  {
+  if (priv->cond_send_message) {
     g_cond_free (priv->cond_send_message);
     priv->cond_send_message = NULL;
   }
 
   g_mutex_unlock (priv->x_lock);
 
-  if (priv->x_lock)
-  {
+  if (priv->x_lock) {
     g_mutex_free (priv->x_lock);
     priv->x_lock = NULL;
   }
@@ -206,8 +204,8 @@ gst_gl_window_get_property (GObject * object, guint prop_id,
 }
 
 static void
-gst_gl_window_log_handler (const gchar *domain, GLogLevelFlags flags,
-                           const gchar *message, gpointer user_data)
+gst_gl_window_log_handler (const gchar * domain, GLogLevelFlags flags,
+    const gchar * message, gpointer user_data)
 {
   if (_gst_gl_window_debug) {
     g_log_default_handler (domain, flags, message, user_data);
@@ -231,7 +229,7 @@ gst_gl_window_class_init (GstGLWindowClass * klass)
 }
 
 static void
-gst_gl_window_init (GstGLWindow *window)
+gst_gl_window_init (GstGLWindow * window)
 {
   window->priv = GST_GL_WINDOW_GET_PRIVATE (window);
 
@@ -239,7 +237,7 @@ gst_gl_window_init (GstGLWindow *window)
     _gst_gl_window_debug = TRUE;
 
   g_log_set_handler ("GstGLWindow", G_LOG_LEVEL_DEBUG,
-    gst_gl_window_log_handler, NULL);
+      gst_gl_window_log_handler, NULL);
 }
 
 /* Must be called in the gl thread */
@@ -270,7 +268,7 @@ gst_gl_window_new (gint width, gint height)
   static gint x = 0;
   static gint y = 0;
 
-  setlocale(LC_NUMERIC, "C");
+  setlocale (LC_NUMERIC, "C");
 
   priv->x_lock = g_mutex_new ();
   priv->cond_send_message = g_cond_new ();
@@ -314,8 +312,7 @@ gst_gl_window_new (gint width, gint height)
 
   priv->visual_info = glXChooseVisual (priv->device, priv->screen_num, attrib);
 
-  if (!priv->visual_info)
-  {
+  if (!priv->visual_info) {
     g_warning ("glx visual is null (bad attributes)\n");
     return NULL;
   }
@@ -326,7 +323,8 @@ gst_gl_window_new (gint width, gint height)
   if (priv->visual_info->class == TrueColor)
     g_debug ("visual is using TrueColor\n");
 
-  g_debug ("visual ID: %d\n", (gint)XVisualIDFromVisual(priv->visual_info->visual));
+  g_debug ("visual ID: %d\n",
+      (gint) XVisualIDFromVisual (priv->visual_info->visual));
   g_debug ("visual info screen: %d\n", priv->visual_info->screen);
   g_debug ("visual info visualid: %d\n", (gint) priv->visual_info->visualid);
   g_debug ("visual info depth: %d\n", priv->visual_info->depth);
@@ -336,20 +334,23 @@ gst_gl_window_new (gint width, gint height)
   g_debug ("visual info blue_mask: %ld\n", priv->visual_info->blue_mask);
   g_debug ("visual info bits_per_rgb: %d\n", priv->visual_info->bits_per_rgb);
 
-  win_attr.event_mask = StructureNotifyMask | ExposureMask | VisibilityChangeMask;
+  win_attr.event_mask =
+      StructureNotifyMask | ExposureMask | VisibilityChangeMask;
   win_attr.do_not_propagate_mask = NoEventMask;
 
   win_attr.background_pixmap = None;
   win_attr.background_pixel = 0;
   win_attr.border_pixel = 0;
 
-  win_attr.colormap = XCreateColormap(priv->device, priv->root, priv->visual_info->visual, AllocNone);
+  win_attr.colormap =
+      XCreateColormap (priv->device, priv->root, priv->visual_info->visual,
+      AllocNone);
 
   mask = CWBackPixmap | CWBorderPixel | CWColormap | CWEventMask;
 
   priv->internal_win_id = XCreateWindow (priv->device, priv->root, x, y,
-    width, height, 0, priv->visual_info->depth, InputOutput,
-    priv->visual_info->visual, mask, &win_attr);
+      width, height, 0, priv->visual_info->depth, InputOutput,
+      priv->visual_info->visual, mask, &win_attr);
 
   x += 20;
   y += 20;
@@ -358,7 +359,8 @@ gst_gl_window_new (gint width, gint height)
 
   XSetWindowBackgroundPixmap (priv->device, priv->internal_win_id, None);
 
-  g_debug ("gl window id: %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
+  g_debug ("gl window id: %" G_GUINT64_FORMAT "\n",
+      (guint64) priv->internal_win_id);
 
   g_debug ("gl window props: x:%d y:%d w:%d h:%d\n", x, y, width, height);
 
@@ -376,21 +378,22 @@ gst_gl_window_new (gint width, gint height)
 
   XSetWMProtocols (priv->device, priv->internal_win_id, wm_atoms, 2);
 
-  priv->gl_context = glXCreateContext (priv->device, priv->visual_info, NULL, TRUE);
+  priv->gl_context =
+      glXCreateContext (priv->device, priv->visual_info, NULL, TRUE);
 
   g_debug ("gl context id: %ld\n", (gulong) priv->gl_context);
 
-  if (!glXIsDirect(priv->device, priv->gl_context))
+  if (!glXIsDirect (priv->device, priv->gl_context))
     g_debug ("direct rendering failed\n");
 
   wm_hints.flags = StateHint;
   wm_hints.initial_state = NormalState;
   wm_hints.input = False;
 
-  XStringListToTextProperty ((char**)&title, 1, &text_property);
+  XStringListToTextProperty ((char **) &title, 1, &text_property);
 
-  XSetWMProperties (priv->device, priv->internal_win_id, &text_property, &text_property, 0, 0,
-    NULL, &wm_hints, NULL);
+  XSetWMProperties (priv->device, priv->internal_win_id, &text_property,
+      &text_property, 0, 0, NULL, &wm_hints, NULL);
 
   XFree (text_property.value);
 
@@ -417,10 +420,9 @@ gst_gl_window_error_quark (void)
 
 /* Not called by the gl thread */
 void
-gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
+gst_gl_window_set_external_window_id (GstGLWindow * window, guint64 id)
 {
-  if (window)
-  {
+  if (window) {
     GstGLWindowPrivate *priv = window->priv;
     XWindowAttributes attr;
 
@@ -432,9 +434,11 @@ gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
 
     XGetWindowAttributes (priv->disp_send, priv->parent, &attr);
 
-    XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width, attr.height);
+    XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width,
+        attr.height);
 
-    XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent, attr.x, attr.y);
+    XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent,
+        attr.x, attr.y);
 
     XSync (priv->disp_send, FALSE);
 
@@ -443,13 +447,14 @@ gst_gl_window_set_external_window_id (GstGLWindow *window, guint64 id)
 }
 
 void
-gst_gl_window_set_external_gl_context (GstGLWindow *window, guint64 context)
+gst_gl_window_set_external_gl_context (GstGLWindow * window, guint64 context)
 {
   g_warning ("gst_gl_window_set_external_gl_context: not implemented\n");
 }
 
 void
-gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_set_draw_callback (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -462,7 +467,8 @@ gst_gl_window_set_draw_callback (GstGLWindow *window, GstGLWindowCB callback, gp
 }
 
 void
-gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback , gpointer data)
+gst_gl_window_set_resize_callback (GstGLWindow * window,
+    GstGLWindowCB2 callback, gpointer data)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -475,7 +481,8 @@ gst_gl_window_set_resize_callback (GstGLWindow *window, GstGLWindowCB2 callback
 }
 
 void
-gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_set_close_callback (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -489,12 +496,11 @@ gst_gl_window_set_close_callback (GstGLWindow *window, GstGLWindowCB callback, g
 
 /* Called in the gl thread */
 void
-gst_gl_window_draw_unlocked (GstGLWindow *window)
+gst_gl_window_draw_unlocked (GstGLWindow * window)
 {
   GstGLWindowPrivate *priv = window->priv;
 
-  if (priv->running && priv->allow_extra_expose_events)
-  {
+  if (priv->running && priv->allow_extra_expose_events) {
     XEvent event;
     XWindowAttributes attr;
 
@@ -510,44 +516,42 @@ gst_gl_window_draw_unlocked (GstGLWindow *window)
     event.xexpose.height = attr.height;
     event.xexpose.count = 0;
 
-    XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask, &event);
+    XSendEvent (priv->device, priv->internal_win_id, FALSE, ExposureMask,
+        &event);
     XSync (priv->disp_send, FALSE);
   }
 }
 
 /* Not called by the gl thread */
 void
-gst_gl_window_draw (GstGLWindow *window)
+gst_gl_window_draw (GstGLWindow * window)
 {
-  if (window)
-  {
+  if (window) {
     GstGLWindowPrivate *priv = window->priv;
 
     g_mutex_lock (priv->x_lock);
 
-    if (priv->running)
-    {
+    if (priv->running) {
       XEvent event;
       XWindowAttributes attr;
 
-      if (!priv->visible)
-      {
+      if (!priv->visible) {
         XMapWindow (priv->disp_send, priv->internal_win_id);
         priv->visible = TRUE;
       }
 
       XGetWindowAttributes (priv->disp_send, priv->internal_win_id, &attr);
 
-      if (priv->parent)
-      {
+      if (priv->parent) {
         XWindowAttributes attr_parent;
         XGetWindowAttributes (priv->disp_send, priv->parent, &attr_parent);
 
         if (attr.x != attr_parent.x || attr.y != attr_parent.y ||
-            attr.width != attr_parent.width || attr.height != attr_parent.height)
-        {
-          XMoveResizeWindow (priv->disp_send, priv->internal_win_id, attr_parent.x, attr_parent.y,
-            attr_parent.width, attr_parent.height);
+            attr.width != attr_parent.width
+            || attr.height != attr_parent.height) {
+          XMoveResizeWindow (priv->disp_send, priv->internal_win_id,
+              attr_parent.x, attr_parent.y, attr_parent.width,
+              attr_parent.height);
           XSync (priv->disp_send, FALSE);
 
           attr.x = attr_parent.x;
@@ -556,8 +560,8 @@ gst_gl_window_draw (GstGLWindow *window)
           attr.width = attr_parent.width;
           attr.height = attr_parent.height;
 
-          g_debug ("parent resize:  %d, %d, %d, %d\n", attr_parent.x, attr_parent.y,
-            attr_parent.width, attr_parent.height);
+          g_debug ("parent resize:  %d, %d, %d, %d\n", attr_parent.x,
+              attr_parent.y, attr_parent.width, attr_parent.height);
         }
       }
 
@@ -571,7 +575,8 @@ gst_gl_window_draw (GstGLWindow *window)
       event.xexpose.height = attr.height;
       event.xexpose.count = 0;
 
-      XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, ExposureMask, &event);
+      XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, ExposureMask,
+          &event);
       XSync (priv->disp_send, FALSE);
     }
 
@@ -581,7 +586,7 @@ gst_gl_window_draw (GstGLWindow *window)
 
 /* Called in the gl thread */
 void
-gst_gl_window_run_loop (GstGLWindow *window)
+gst_gl_window_run_loop (GstGLWindow * window)
 {
   GstGLWindowPrivate *priv = window->priv;
 
@@ -589,23 +594,21 @@ gst_gl_window_run_loop (GstGLWindow *window)
 
   g_mutex_lock (priv->x_lock);
 
-  while (priv->running)
-  {
+  while (priv->running) {
     XEvent event;
     XEvent pending_event;
 
     g_mutex_unlock (priv->x_lock);
 
     /* XSendEvent (which are called in other threads) are done from another display structure */
-    XNextEvent(priv->device, &event);
+    XNextEvent (priv->device, &event);
 
     g_mutex_lock (priv->x_lock);
 
     // use in generic/cube and other related uses
     priv->allow_extra_expose_events = XPending (priv->device) <= 2;
 
-    switch (event.type)
-    {
+    switch (event.type) {
       case ClientMessage:
       {
 
@@ -647,9 +650,10 @@ gst_gl_window_run_loop (GstGLWindow *window)
         }
 
         /* User clicked on the cross */
-        else if (wm_delete != None && (Atom) event.xclient.data.l[0] == wm_delete)
-        {
-          g_debug ("Close %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
+        else if (wm_delete != None
+            && (Atom) event.xclient.data.l[0] == wm_delete) {
+          g_debug ("Close %" G_GUINT64_FORMAT "\n",
+              (guint64) priv->internal_win_id);
 
           if (priv->close_cb)
             priv->close_cb (priv->close_data);
@@ -679,7 +683,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
           gpointer destroy_data = (gpointer) event.xclient.data.l[1];
 #endif
 
-          g_debug ("Quit loop message %" G_GUINT64_FORMAT "\n", (guint64) priv->internal_win_id);
+          g_debug ("Quit loop message %" G_GUINT64_FORMAT "\n",
+              (guint64) priv->internal_win_id);
 
           /* exit loop */
           priv->running = FALSE;
@@ -716,9 +721,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
 
           destroy_cb (destroy_data);
 
-        }
-        else
-          g_debug("client message not reconized \n");
+        } else
+          g_debug ("client message not reconized \n");
         break;
       }
 
@@ -726,7 +730,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
       case ConfigureNotify:
       {
         if (priv->resize_cb)
-          priv->resize_cb (priv->resize_data, event.xconfigure.width, event.xconfigure.height);
+          priv->resize_cb (priv->resize_data, event.xconfigure.width,
+              event.xconfigure.height);
         break;
       }
 
@@ -735,18 +740,16 @@ gst_gl_window_run_loop (GstGLWindow *window)
         break;
 
       case Expose:
-        if (priv->draw_cb)
-        {
+        if (priv->draw_cb) {
           priv->draw_cb (priv->draw_data);
-          glFlush();
+          glFlush ();
           glXSwapBuffers (priv->device, priv->internal_win_id);
         }
         break;
 
       case VisibilityNotify:
       {
-        switch (event.xvisibility.state)
-        {
+        switch (event.xvisibility.state) {
           case VisibilityUnobscured:
             if (priv->draw_cb)
               priv->draw_cb (priv->draw_data);
@@ -761,7 +764,8 @@ gst_gl_window_run_loop (GstGLWindow *window)
             break;
 
           default:
-            g_debug("unknown xvisibility event: %d\n", event.xvisibility.state);
+            g_debug ("unknown xvisibility event: %d\n",
+                event.xvisibility.state);
             break;
         }
         break;
@@ -771,9 +775,9 @@ gst_gl_window_run_loop (GstGLWindow *window)
         g_debug ("unknow\n");
         break;
 
-    }// switch
+    }                           // switch
 
-  }// while running
+  }                             // while running
 
   g_mutex_unlock (priv->x_lock);
 
@@ -782,23 +786,23 @@ gst_gl_window_run_loop (GstGLWindow *window)
 
 /* Not called by the gl thread */
 void
-gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_quit_loop (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
-  if (window)
-  {
+  if (window) {
     GstGLWindowPrivate *priv = window->priv;
 
     g_mutex_lock (priv->x_lock);
 
-    if (priv->running)
-    {
+    if (priv->running) {
       XEvent event;
 
       event.xclient.type = ClientMessage;
       event.xclient.send_event = TRUE;
       event.xclient.display = priv->disp_send;
       event.xclient.window = priv->internal_win_id;
-      event.xclient.message_type = XInternAtom (priv->disp_send, "WM_QUIT_LOOP", True);;
+      event.xclient.message_type =
+          XInternAtom (priv->disp_send, "WM_QUIT_LOOP", True);;
       event.xclient.format = 32;
 #if SIZEOF_VOID_P == 8
       event.xclient.data.l[0] = (((long) callback) >> 32) & 0xffffffff;
@@ -810,7 +814,8 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
       event.xclient.data.l[1] = (long) data;
 #endif
 
-      XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, &event);
+      XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask,
+          &event);
       XSync (priv->disp_send, FALSE);
     }
 
@@ -820,23 +825,23 @@ gst_gl_window_quit_loop (GstGLWindow *window, GstGLWindowCB callback, gpointer d
 
 /* Not called by the gl thread */
 void
-gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointer data)
+gst_gl_window_send_message (GstGLWindow * window, GstGLWindowCB callback,
+    gpointer data)
 {
-  if (window)
-  {
+  if (window) {
     GstGLWindowPrivate *priv = window->priv;
 
     g_mutex_lock (priv->x_lock);
 
-    if (priv->running)
-    {
+    if (priv->running) {
       XEvent event;
 
       event.xclient.type = ClientMessage;
       event.xclient.send_event = TRUE;
       event.xclient.display = priv->disp_send;
       event.xclient.window = priv->internal_win_id;
-      event.xclient.message_type = XInternAtom (priv->disp_send, "WM_GL_WINDOW", True);
+      event.xclient.message_type =
+          XInternAtom (priv->disp_send, "WM_GL_WINDOW", True);
       event.xclient.format = 32;
 #if SIZEOF_VOID_P == 8
       event.xclient.data.l[0] = (((long) callback) >> 32) & 0xffffffff;
@@ -848,7 +853,8 @@ gst_gl_window_send_message (GstGLWindow *window, GstGLWindowCB callback, gpointe
       event.xclient.data.l[1] = (long) data;
 #endif
 
-      XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask, &event);
+      XSendEvent (priv->disp_send, priv->internal_win_id, FALSE, NoEventMask,
+          &event);
       XSync (priv->disp_send, FALSE);
 
       /* block until opengl calls have been executed in the gl thread */