aboutsummaryrefslogtreecommitdiff
path: root/system/shaders/yuv2rgb_basic.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'system/shaders/yuv2rgb_basic.glsl')
-rw-r--r--system/shaders/yuv2rgb_basic.glsl16
1 files changed, 10 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;