summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <reynaldo@collabora.com>2012-10-10 02:04:18 -0300
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-18 14:35:18 +0200
commita95834a4911c3507b864c0478771d2d7106c7031 (patch)
tree21d468536e2528ed9ae09ec3d764e885533bc631 /ext
parenta7a2dcc433aa11f2a7101c82f4f2bf01d0b9c7df (diff)
downloadgstreamer-plugins-bad-a95834a4911c3507b864c0478771d2d7106c7031.tar.gz
eglglessink: GLSL: Optimize frag_AYUV_prog
- Avoid repeatedly performing the texture lookup - Use consts for the transform's offset and cofficients values - Use the dot product instead of the explicit mult and add
Diffstat (limited to 'ext')
-rw-r--r--ext/eglgles/gsteglglessink.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/ext/eglgles/gsteglglessink.c b/ext/eglgles/gsteglglessink.c
index b03de8226..b70e92772 100644
--- a/ext/eglgles/gsteglglessink.c
+++ b/ext/eglgles/gsteglglessink.c
@@ -213,23 +213,24 @@ static const char *frag_REORDER_prog = {
/* Packed YUV converters */
-/** From gst-plugins-gl: AYUV to RGB conversion */
+/** AYUV to RGB conversion */
static const char *frag_AYUV_prog = {
"precision mediump float;"
"varying vec2 opos;"
"uniform sampler2D tex;"
+ "const vec3 offset = vec3(-0.0625, -0.5, -0.5);"
+ "const vec3 rcoeff = vec3(1.164, 0.000, 1.596);"
+ "const vec3 gcoeff = vec3(1.164,-0.391,-0.813);"
+ "const vec3 bcoeff = vec3(1.164, 2.018, 0.000);"
"void main(void) {"
- " float r,g,b,y,u,v;"
+ " float r,g,b;"
+ " vec3 yuv;
" vec2 nxy = opos.xy;"
- " y=texture2D(tex,nxy).g;"
- " u=texture2D(tex,nxy).b;"
- " v=texture2D(tex,nxy).a;"
- " y=1.1643*(y-0.0625);"
- " u=u-0.5;"
- " v=v-0.5;"
- " r=y+1.5958*v;"
- " g=y-0.39173*u-0.81290*v;"
- " b=y+2.017*u;"
+ " yuv = texture2D(tex,nxy).gba;"
+ " yuv += offset;"
+ " r = dot(yuv, rcoeff);"
+ " g = dot(yuv, gcoeff);"
+ " b = dot(yuv, bcoeff);"
" gl_FragColor=vec4(r,g,b,1.0);"
"}"
};