PageRenderTime 4ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/system/shaders/yuv2rgb_bob_gles.glsl

http://github.com/xbmc/xbmc
Unknown | 74 lines | 62 code | 12 blank | 0 comment | 0 complexity | 4b9894f8c690c4ee45f34aa5e1e07930 MD5 | raw file
 1/*
 2 *      Copyright (C) 2010-2013 Team XBMC
 3 *      http://xbmc.org
 4 *
 5 *  This Program is free software; you can redistribute it and/or modify
 6 *  it under the terms of the GNU General Public License as published by
 7 *  the Free Software Foundation; either version 2, or (at your option)
 8 *  any later version.
 9 *
10 *  This Program is distributed in the hope that it will be useful,
11 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *  GNU General Public License for more details.
14 *
15 *  You should have received a copy of the GNU General Public License
16 *  along with XBMC; see the file COPYING.  If not, see
17 *  <http://www.gnu.org/licenses/>.
18 *
19 */
20
21precision highp float;
22uniform sampler2D m_sampY;
23uniform sampler2D m_sampU;
24uniform sampler2D m_sampV;
25varying vec2      m_cordY;
26varying vec2      m_cordU;
27varying vec2      m_cordV;
28uniform float     m_alpha;
29uniform mat4      m_yuvmat;
30uniform float     m_stepX;
31uniform float     m_stepY;
32uniform int       m_field;
33
34void main()
35{
36  vec4 yuv, rgb;
37
38  vec2 offsetY;
39  vec2 offsetU;
40  vec2 offsetV;
41  float temp1 = mod(m_cordY.y, 2.0*m_stepY);
42
43  offsetY  = m_cordY;
44  offsetU  = m_cordU;
45  offsetV  = m_cordV;
46
47  offsetY.y -= (temp1 - m_stepY/2.0 + float(m_field)*m_stepY);
48  offsetU.y -= (temp1 - m_stepY/2.0 + float(m_field)*m_stepY)/2.0;
49  offsetV.y -= (temp1 - m_stepY/2.0 + float(m_field)*m_stepY)/2.0;
50
51  float bstep = step(m_stepY, temp1);
52
53  // Blend missing line
54  vec2 belowY, belowU, belowV;
55
56  belowY.x = offsetY.x;
57  belowY.y = offsetY.y + (2.0*m_stepY*bstep);
58  belowU.x = offsetU.x;
59  belowU.y = offsetU.y + (m_stepY*bstep);
60  belowV.x = offsetV.x;
61  belowV.y = offsetV.y + (m_stepY*bstep);
62
63  vec4 yuvBelow, rgbBelow;
64
65  yuv.rgba = vec4(texture2D(m_sampY, offsetY).r, texture2D(m_sampU, offsetU).g, texture2D(m_sampV, offsetV).a, 1.0);
66  rgb   = m_yuvmat * yuv;
67  rgb.a = m_alpha;
68
69  yuvBelow.rgba = vec4(texture2D(m_sampY, belowY).r, texture2D(m_sampU, belowU).g, texture2D(m_sampV, belowV).a, 1.0);
70  rgbBelow   = m_yuvmat * yuvBelow;
71  rgbBelow.a = m_alpha;
72
73  gl_FragColor.rgba = mix(rgb, rgbBelow, 0.5);
74}