diff options
author | bobo1on1 <bobo1on1@svn> | 2010-07-15 23:37:10 +0000 |
---|---|---|
committer | bobo1on1 <bobo1on1@svn> | 2010-07-15 23:37:10 +0000 |
commit | 73db334552b34b36435e887b103d96fc07e21dee (patch) | |
tree | 7f45ffcc5a5a4562c0e8774c13abaed6f2a6132d /system | |
parent | c13bfaa8ca023923cc42d0808fc4f4f83260b2f7 (diff) |
added: UYVY support
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31832 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'system')
-rw-r--r-- | system/shaders/yuv2rgb_basic.glsl | 16 | ||||
-rw-r--r-- | system/shaders/yuv2rgb_basic_2d_UYVY.arb | 47 | ||||
-rw-r--r-- | system/shaders/yuv2rgb_basic_rect_UYVY.arb | 43 |
3 files changed, 100 insertions, 6 deletions
diff --git a/system/shaders/yuv2rgb_basic.glsl b/system/shaders/yuv2rgb_basic.glsl index 4df222b0f6..f6589c9904 100644 --- a/system/shaders/yuv2rgb_basic.glsl +++ b/system/shaders/yuv2rgb_basic.glsl @@ -37,7 +37,7 @@ vec2 stretch(vec2 pos) void main() { -#ifndef XBMC_YUY2 +#if defined(XBMC_YV12) || defined(XBMC_NV12) vec4 yuv, rgb; yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r @@ -49,7 +49,7 @@ void main() rgb.a = gl_Color.a; gl_FragColor = rgb; -#else +#elif defined(XBMC_YUY2) || defined(XBMC_UYVY) #if(XBMC_texture_rectangle) vec2 stepxy = vec2(1.0, 1.0); @@ -63,7 +63,6 @@ void main() 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)); @@ -72,12 +71,17 @@ void main() /* 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*/ +#ifdef XBMC_YUY2 //BGRA = YUYV 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); +#else //BGRA = UYVY + float leftY = mix(c1.g, c1.a, f.x * 2.0); + float rightY = mix(c1.a, c2.g, f.x * 2.0 - 1.0); + vec2 outUV = mix(c1.br, c2.br, f.x); +#endif //XBMC_YUY2 + + float outY = mix(leftY, rightY, step(0.5, f.x)); vec4 yuv = vec4(outY, outUV, 1.0); vec4 rgb = m_yuvmat * yuv; diff --git a/system/shaders/yuv2rgb_basic_2d_UYVY.arb b/system/shaders/yuv2rgb_basic_2d_UYVY.arb new file mode 100644 index 0000000000..ec1c90958f --- /dev/null +++ b/system/shaders/yuv2rgb_basic_2d_UYVY.arb @@ -0,0 +1,47 @@ +!!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 , dims[0].x, -0.25, fragment.texcoord[0].x; +MOV pos.y , fragment.texcoord[0].y; +MUL f.x , dims[0].z, pos.x; +MUL f.y , dims[0].w, pos.y; +FRC f , f; + +TEMP c1pos; +TEMP c2pos; +SUB c1pos.x, 0.5, f.x; +SUB c2pos.x, 1.5, f.x; +MAD c1pos.x, c1pos.x, dims[0].x, pos.x; +MAD c2pos.x, c2pos.x, dims[0].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.a , c1.g; +LRP yuv.b, cint.y, c2.g , c1.a; +LRP yuv.r, cint.z, yuv.b, yuv.g; + +LRP yuv.g, f.x , c2.b , c1.b; +LRP yuv.b, f.x , c2.r , c1.r; + +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_UYVY.arb b/system/shaders/yuv2rgb_basic_rect_UYVY.arb new file mode 100644 index 0000000000..dc635468cf --- /dev/null +++ b/system/shaders/yuv2rgb_basic_rect_UYVY.arb @@ -0,0 +1,43 @@ +!!ARBfp1.0 +PARAM yuvmat[4] = { program.local[0..3] }; +TEMP f; +TEMP pos; +ADD pos.x , fragment.texcoord[0].x, -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, 1.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.a , c1.g; +LRP yuv.b, cint.y, c2.g , c1.a; +LRP yuv.r, cint.z, yuv.b, yuv.g; + +LRP yuv.g, f.x , c2.b , c1.b; +LRP yuv.b, f.x , c2.r , c1.r; + +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 |