diff options
author | bobo1on1 <bobo1on1@svn> | 2010-07-10 11:44:25 +0000 |
---|---|---|
committer | bobo1on1 <bobo1on1@svn> | 2010-07-10 11:44:25 +0000 |
commit | aef0b1901d59ccfa172a8069ee1ef38c0b4c0bdf (patch) | |
tree | 61644739e513802badbd3a36b0518f65b6d3fe7a /system/shaders/yuv2rgb_basic.glsl | |
parent | 57ec3a8656a315bb63fec8e50bc2a368f7607426 (diff) |
added: YUY2 to rgb conversion with shaders
removed: double upload for YUY2
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31688 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'system/shaders/yuv2rgb_basic.glsl')
-rw-r--r-- | system/shaders/yuv2rgb_basic.glsl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/system/shaders/yuv2rgb_basic.glsl b/system/shaders/yuv2rgb_basic.glsl index 0cbd1f8c74..31f07ee3db 100644 --- a/system/shaders/yuv2rgb_basic.glsl +++ b/system/shaders/yuv2rgb_basic.glsl @@ -11,6 +11,8 @@ varying vec2 m_cordY; varying vec2 m_cordU; varying vec2 m_cordV; +uniform vec2 m_step; + uniform mat4 m_yuvmat; uniform float m_stretch; @@ -30,6 +32,8 @@ vec2 stretch(vec2 pos) void main() { +#ifndef XBMC_YUY2 + vec4 yuv, rgb; yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r , texture2D(m_sampU, stretch(m_cordU)).g @@ -39,4 +43,39 @@ void main() rgb = m_yuvmat * yuv; rgb.a = gl_Color.a; gl_FragColor = rgb; + +#else + +#if(XBMC_texture_rectangle) + vec2 stepxy = vec2(1.0, 1.0); + vec2 pos = stretch(vec2(m_cordY.x * 0.5 - 0.25, m_cordY.y)); + vec2 f = fract(pos); +#else + vec2 stepxy = vec2(m_step.x * 2.0, m_step.y); + vec2 pos = stretch(vec2(m_cordY.x - stepxy.x * 0.25, m_cordY.y)); + vec2 f = fract(pos / stepxy); +#endif + + //y axis will be correctly interpolated by opengl + //x axis will not, so we grab two pixels at the center of two columns and interpolate ourselves + vec4 c1 = texture2D(m_sampY, vec2(pos.x + (-0.5 - f.x) * stepxy.x, pos.y)); + vec4 c2 = texture2D(m_sampY, vec2(pos.x + ( 0.5 - f.x) * stepxy.x, pos.y)); + + /* each pixel has two Y subpixels and one UV subpixel + YUV Y YUV + check if we're left or right of the middle Y subpixel and interpolate accordingly*/ + float leftY = mix(c1.b, c1.r, f.x * 2.0); + float rightY = mix(c1.r, c2.b, f.x * 2.0 - 1.0); + float outY = mix(leftY, rightY, step(0.5, f.x)); + + //interpolate UV + vec2 outUV = mix(c1.ga, c2.ga, f.x); + + vec4 yuv = vec4(outY, outUV, 1.0); + vec4 rgb = m_yuvmat * yuv; + + gl_FragColor = rgb; + gl_FragColor.a = gl_Color.a; + +#endif } |