eglglessink: Documentation: GLSL Shaders
authorReynaldo H. Verdejo Pinochet <reynaldo@collabora.com>
Tue, 9 Oct 2012 14:48:09 +0000 (11:48 -0300)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 18 Oct 2012 12:35:17 +0000 (14:35 +0200)
Brief explanatory comments plus some rerdering
to group packed/planar converters.

ext/eglgles/gsteglglessink.c

index ab63905..c0e8600 100644 (file)
@@ -168,6 +168,15 @@ static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC my_glEGLImageTargetTexture2DOES;
 #endif
 
 /* *INDENT-OFF* */
+
+/* GLESv2 GLSL Shaders
+ *
+ * OpenGL ES Standard does not mandate YUV support. This is
+ * why most of these shaders deal with Packed/Planar YUV->RGB
+ * conversion.
+ */
+
+/* Direct vertex copy */
 static const char *vert_COPY_prog = {
       "attribute vec3 position;"
       "attribute vec2 texpos;"
@@ -179,6 +188,7 @@ static const char *vert_COPY_prog = {
       "}"
 };
 
+/* Direct fragments copy */
 static const char *frag_COPY_prog = {
   "precision mediump float;"
       "varying vec2 opos;"
@@ -190,6 +200,7 @@ static const char *frag_COPY_prog = {
       "}"
 };
 
+/* Channel reordering for XYZ <-> ZYX conversion */
 static const char *frag_REORDER_prog = {
   "precision mediump float;"
       "varying vec2 opos;"
@@ -201,7 +212,9 @@ static const char *frag_REORDER_prog = {
       "}"
 };
 
-/* From gst-plugins-gl */
+/* Packed YUV converters */
+
+/** From gst-plugins-gl: AYUV to RGB conversion */
 static const char *frag_AYUV_prog = {
       "precision mediump float;"
       "varying vec2 opos;"
@@ -222,16 +235,18 @@ static const char *frag_AYUV_prog = {
       "}"
 };
 
-static const char *frag_PLANAR_YUV_prog = {
+/** YUY2/UYVY to RGB conversion */
+static const char *frag_YUY2_UYVY_prog = {
       "precision mediump float;"
       "varying vec2 opos;"
-      "uniform sampler2D Ytex,Utex,Vtex;"
+      "uniform sampler2D Ytex, UVtex;"
       "void main(void) {"
-      "  float r,g,b,y,u,v;"
-      "  vec2 nxy = opos.xy;"
-      "  y=texture2D(Ytex,nxy).r;"
-      "  u=texture2D(Utex,nxy).r;"
-      "  v=texture2D(Vtex,nxy).r;"
+      "  float fx, fy, y, u, v, r, g, b;"
+      "  fx = opos.x;"
+      "  fy = opos.y;"
+      "  y = texture2D(Ytex,vec2(fx,fy)).%c;"
+      "  u = texture2D(UVtex,vec2(fx,fy)).%c;"
+      "  v = texture2D(UVtex,vec2(fx,fy)).%c;"
       "  y=1.1643*(y-0.0625);"
       "  u=u-0.5;"
       "  v=v-0.5;"
@@ -242,16 +257,19 @@ static const char *frag_PLANAR_YUV_prog = {
       "}"
 };
 
-static const char *frag_NV12_NV21_prog = {
+/* Planar YUV converters */
+
+/** YUV to RGB conversion */
+static const char *frag_PLANAR_YUV_prog = {
       "precision mediump float;"
       "varying vec2 opos;"
-      "uniform sampler2D Ytex,UVtex;"
+      "uniform sampler2D Ytex,Utex,Vtex;"
       "void main(void) {"
       "  float r,g,b,y,u,v;"
       "  vec2 nxy = opos.xy;"
       "  y=texture2D(Ytex,nxy).r;"
-      "  u=texture2D(UVtex,nxy).%c;"
-      "  v=texture2D(UVtex,nxy).%c;"
+      "  u=texture2D(Utex,nxy).r;"
+      "  v=texture2D(Vtex,nxy).r;"
       "  y=1.1643*(y-0.0625);"
       "  u=u-0.5;"
       "  v=v-0.5;"
@@ -262,17 +280,17 @@ static const char *frag_NV12_NV21_prog = {
       "}"
 };
 
-static const char *frag_YUY2_UYVY_prog = {
+/** NV12/NV21 to RGB conversion */
+static const char *frag_NV12_NV21_prog = {
       "precision mediump float;"
       "varying vec2 opos;"
-      "uniform sampler2D Ytex, UVtex;"
+      "uniform sampler2D Ytex,UVtex;"
       "void main(void) {"
-      "  float fx, fy, y, u, v, r, g, b;"
-      "  fx = opos.x;"
-      "  fy = opos.y;"
-      "  y = texture2D(Ytex,vec2(fx,fy)).%c;"
-      "  u = texture2D(UVtex,vec2(fx,fy)).%c;"
-      "  v = texture2D(UVtex,vec2(fx,fy)).%c;"
+      "  float r,g,b,y,u,v;"
+      "  vec2 nxy = opos.xy;"
+      "  y=texture2D(Ytex,nxy).r;"
+      "  u=texture2D(UVtex,nxy).%c;"
+      "  v=texture2D(UVtex,nxy).%c;"
       "  y=1.1643*(y-0.0625);"
       "  u=u-0.5;"
       "  v=v-0.5;"
@@ -282,14 +300,9 @@ static const char *frag_YUY2_UYVY_prog = {
       "  gl_FragColor=vec4(r,g,b,1.0);"
       "}"
 };
-
-
 /* *INDENT-ON* */
 
-/* Input capabilities.
- *
- * Note: OpenGL ES Standard does not mandate YUV support.
- */
+/* Input capabilities. */
 static GstStaticPadTemplate gst_eglglessink_sink_template_factory =
     GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,