From 119fd4bb736c163c83da628f48f5937f1de34acb Mon Sep 17 00:00:00 2001 From: raster Date: Fri, 23 Mar 2012 06:49:42 +0000 Subject: [PATCH] go back to the "old fashioned way" of doing yuv->rgb without matrix. the matrix seems to screw up on too many gl drivers/implementations. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@69579 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/modules/engines/gl_common/shader/yuv_frag.h | 18 +++++++++++------- src/modules/engines/gl_common/shader/yuv_frag.shd | 18 +++++++++++------- src/modules/engines/gl_common/shader/yuv_nomul_frag.h | 18 +++++++++++------- .../engines/gl_common/shader/yuv_nomul_frag.shd | 18 +++++++++++------- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/src/modules/engines/gl_common/shader/yuv_frag.h b/src/modules/engines/gl_common/shader/yuv_frag.h index de9acf8..87f4095 100644 --- a/src/modules/engines/gl_common/shader/yuv_frag.h +++ b/src/modules/engines/gl_common/shader/yuv_frag.h @@ -10,11 +10,15 @@ "varying vec2 tex_c, tex_c2, tex_c3;\n" "void main()\n" "{\n" -" const mat4 yuv2rgb = mat4( 1.16400, 1.16400, 1.16400, 0.00000,\n" -" 0.00000, -0.34410, 1.77200, 0.00000,\n" -" 1.40200, -0.71410, 0.00000, 0.00000,\n" -" -0.77380, 0.45630, -0.95880, 1.00000);\n" -" gl_FragColor = (yuv2rgb * vec4(texture2D(tex, tex_c.xy).r,\n" -" texture2D(texu, tex_c2.xy).r,\n" -" texture2D(texv, tex_c3.xy).r, 1.0)) * col;\n" +" float r, g, b, y, u, v;\n" +" y = texture2D(tex, tex_c.xy).r;\n" +" u = texture2D(texu, tex_c2.xy).r;\n" +" v = texture2D(texv, tex_c3.xy).r;\n" +" y = (y - 0.0625) * 1.164;\n" +" u = u - 0.5;\n" +" v = v - 0.5;\n" +" r = y + (1.402 * v);\n" +" g = y - (0.34414 * u) - (0.71414 * v);\n" +" b = y + (1.772 * u);\n" +" gl_FragColor = vec4(r, g, b, 1.0) * col;\n" "}\n" diff --git a/src/modules/engines/gl_common/shader/yuv_frag.shd b/src/modules/engines/gl_common/shader/yuv_frag.shd index 8e55d14..367fb55 100644 --- a/src/modules/engines/gl_common/shader/yuv_frag.shd +++ b/src/modules/engines/gl_common/shader/yuv_frag.shd @@ -10,11 +10,15 @@ varying vec4 col; varying vec2 tex_c, tex_c2, tex_c3; void main() { - const mat4 yuv2rgb = mat4( 1.16400, 1.16400, 1.16400, 0.00000, - 0.00000, -0.34410, 1.77200, 0.00000, - 1.40200, -0.71410, 0.00000, 0.00000, - -0.77380, 0.45630, -0.95880, 1.00000); - gl_FragColor = (yuv2rgb * vec4(texture2D(tex, tex_c.xy).r, - texture2D(texu, tex_c2.xy).r, - texture2D(texv, tex_c3.xy).r, 1.0)) * col; + float r, g, b, y, u, v; + y = texture2D(tex, tex_c.xy).r; + u = texture2D(texu, tex_c2.xy).r; + v = texture2D(texv, tex_c3.xy).r; + y = (y - 0.0625) * 1.164; + u = u - 0.5; + v = v - 0.5; + r = y + (1.402 * v); + g = y - (0.34414 * u) - (0.71414 * v); + b = y + (1.772 * u); + gl_FragColor = vec4(r, g, b, 1.0) * col; } diff --git a/src/modules/engines/gl_common/shader/yuv_nomul_frag.h b/src/modules/engines/gl_common/shader/yuv_nomul_frag.h index ee5855c..0df4b97 100644 --- a/src/modules/engines/gl_common/shader/yuv_nomul_frag.h +++ b/src/modules/engines/gl_common/shader/yuv_nomul_frag.h @@ -9,11 +9,15 @@ "varying vec2 tex_c, tex_c2, tex_c3;\n" "void main()\n" "{\n" -" const mat4 yuv2rgb = mat4( 1.16400, 1.16400, 1.16400, 0.00000,\n" -" 0.00000, -0.34410, 1.77200, 0.00000,\n" -" 1.40200, -0.71410, 0.00000, 0.00000,\n" -" -0.77380, 0.45630, -0.95880, 1.00000);\n" -" gl_FragColor = yuv2rgb * vec4(texture2D(tex, tex_c.xy).r,\n" -" texture2D(texu, tex_c2.xy).r,\n" -" texture2D(texv, tex_c3.xy).r, 1.0);\n" +" float r, g, b, y, u, v;\n" +" y = texture2D(tex, tex_c.xy).r;\n" +" u = texture2D(texu, tex_c2.xy).r;\n" +" v = texture2D(texv, tex_c3.xy).r;\n" +" y = (y - 0.0625) * 1.164;\n" +" u = u - 0.5;\n" +" v = v - 0.5;\n" +" r = y + (1.402 * v);\n" +" g = y - (0.34414 * u) - (0.71414 * v);\n" +" b = y + (1.772 * u);\n" +" gl_FragColor = vec4(r, g, b, 1.0);\n" "}\n" diff --git a/src/modules/engines/gl_common/shader/yuv_nomul_frag.shd b/src/modules/engines/gl_common/shader/yuv_nomul_frag.shd index 3ec4311..ce24622 100644 --- a/src/modules/engines/gl_common/shader/yuv_nomul_frag.shd +++ b/src/modules/engines/gl_common/shader/yuv_nomul_frag.shd @@ -9,11 +9,15 @@ uniform sampler2D tex, texu, texv; varying vec2 tex_c, tex_c2, tex_c3; void main() { - const mat4 yuv2rgb = mat4( 1.16400, 1.16400, 1.16400, 0.00000, - 0.00000, -0.34410, 1.77200, 0.00000, - 1.40200, -0.71410, 0.00000, 0.00000, - -0.77380, 0.45630, -0.95880, 1.00000); - gl_FragColor = yuv2rgb * vec4(texture2D(tex, tex_c.xy).r, - texture2D(texu, tex_c2.xy).r, - texture2D(texv, tex_c3.xy).r, 1.0); + float r, g, b, y, u, v; + y = texture2D(tex, tex_c.xy).r; + u = texture2D(texu, tex_c2.xy).r; + v = texture2D(texv, tex_c3.xy).r; + y = (y - 0.0625) * 1.164; + u = u - 0.5; + v = v - 0.5; + r = y + (1.402 * v); + g = y - (0.34414 * u) - (0.71414 * v); + b = y + (1.772 * u); + gl_FragColor = vec4(r, g, b, 1.0); } -- 2.7.4