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 | |
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')
-rw-r--r-- | system/shaders/yuv2rgb_basic.glsl | 39 | ||||
-rw-r--r-- | system/shaders/yuv2rgb_basic_2d_YUY2.arb | 51 | ||||
-rw-r--r-- | system/shaders/yuv2rgb_basic_rect_YUY2.arb | 45 |
3 files changed, 135 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 } diff --git a/system/shaders/yuv2rgb_basic_2d_YUY2.arb b/system/shaders/yuv2rgb_basic_2d_YUY2.arb new file mode 100644 index 0000000000..65f1a38c03 --- /dev/null +++ b/system/shaders/yuv2rgb_basic_2d_YUY2.arb @@ -0,0 +1,51 @@ +!!ARBfp1.0 +PARAM yuvmat[4] = { program.local[0..3] }; +#stepx, stepy, width, height +PARAM dims[1] = { program.local[4] }; +TEMP stepY; +TEMP f; +TEMP pos; +MUL stepY.x, dims[0].x, 2.0; +MOV stepY.y, dims[0].y; +RCP f.x , stepY.x; +RCP f.y , stepY.y; +MAD pos.x , stepY.x, -0.25, fragment.texcoord[0].x; +MOV pos.y , fragment.texcoord[0].y; +MUL f , pos, f; +FRC f , f; + +TEMP c1pos; +TEMP c2pos; +SUB c1pos.x, -0.5, f.x; +SUB c2pos.x, 0.5, f.x; +MAD c1pos.x, c1pos.x, stepY.x, pos.x; +MAD c2pos.x, c2pos.x, stepY.x, pos.x; +MOV c1pos.y, pos.y; +MOV c2pos.y, pos.y; + +TEMP c1; +TEMP c2; +TEX c1, c1pos, texture[0], 2D; +TEX c2, c2pos, texture[0], 2D; + +TEMP cint; +MUL cint.x, f.x, 2.0; +MAD cint.y, f.x, 2.0, -1.0; +SGE cint.z, f.x, 0.5; + +TEMP yuv; +LRP yuv.g, cint.x, c1.r , c1.b; +LRP yuv.b, cint.y, c2.b , c1.r; +LRP yuv.r, cint.z, yuv.b, yuv.g; + +LRP yuv.g, f.x , c2.g , c1.g; +LRP yuv.b, f.x , c2.a , c1.a; + +TEMP rgb; +DPH rgb.r, yuv, yuvmat[0]; +DPH rgb.g, yuv, yuvmat[1]; +DPH rgb.b, yuv, yuvmat[2]; +MOV rgb.a, fragment.color.a; +MOV result.color, rgb; + +END diff --git a/system/shaders/yuv2rgb_basic_rect_YUY2.arb b/system/shaders/yuv2rgb_basic_rect_YUY2.arb new file mode 100644 index 0000000000..42dd4e89fe --- /dev/null +++ b/system/shaders/yuv2rgb_basic_rect_YUY2.arb @@ -0,0 +1,45 @@ +!!ARBfp1.0 +PARAM yuvmat[4] = { program.local[0..3] }; +#stepx, stepy, width, height +PARAM dims[1] = { program.local[4] }; +TEMP f; +TEMP pos; +MAD pos.x , fragment.texcoord[0].x, 0.5, -0.25; +MOV pos.y , fragment.texcoord[0].y; +FRC f , pos; + +TEMP c1pos; +TEMP c2pos; +SUB c1pos.x, -0.5, f.x; +SUB c2pos.x, 0.5, f.x; +ADD c1pos.x, c1pos.x, pos.x; +ADD c2pos.x, c2pos.x, pos.x; +MOV c1pos.y, pos.y; +MOV c2pos.y, pos.y; + +TEMP c1; +TEMP c2; +TEX c1, c1pos, texture[0], RECT; +TEX c2, c2pos, texture[0], RECT; + +TEMP cint; +MUL cint.x, f.x, 2.0; +MAD cint.y, f.x, 2.0, -1.0; +SGE cint.z, f.x, 0.5; + +TEMP yuv; +LRP yuv.g, cint.x, c1.r , c1.b; +LRP yuv.b, cint.y, c2.b , c1.r; +LRP yuv.r, cint.z, yuv.b, yuv.g; + +LRP yuv.g, f.x , c2.g , c1.g; +LRP yuv.b, f.x , c2.a , c1.a; + +TEMP rgb; +DPH rgb.r, yuv, yuvmat[0]; +DPH rgb.g, yuv, yuvmat[1]; +DPH rgb.b, yuv, yuvmat[2]; +MOV rgb.a, fragment.color.a; +MOV result.color, rgb; + +END |