/system/shaders/yuv2rgb_bob_gles.glsl

http://github.com/xbmc/xbmc · GLSL · 74 lines · 42 code · 12 blank · 20 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. precision highp float;
  21. uniform sampler2D m_sampY;
  22. uniform sampler2D m_sampU;
  23. uniform sampler2D m_sampV;
  24. varying vec2 m_cordY;
  25. varying vec2 m_cordU;
  26. varying vec2 m_cordV;
  27. uniform float m_alpha;
  28. uniform mat4 m_yuvmat;
  29. uniform float m_stepX;
  30. uniform float m_stepY;
  31. uniform int m_field;
  32. void main()
  33. {
  34. vec4 yuv, rgb;
  35. vec2 offsetY;
  36. vec2 offsetU;
  37. vec2 offsetV;
  38. float temp1 = mod(m_cordY.y, 2.0*m_stepY);
  39. offsetY = m_cordY;
  40. offsetU = m_cordU;
  41. offsetV = m_cordV;
  42. offsetY.y -= (temp1 - m_stepY/2.0 + float(m_field)*m_stepY);
  43. offsetU.y -= (temp1 - m_stepY/2.0 + float(m_field)*m_stepY)/2.0;
  44. offsetV.y -= (temp1 - m_stepY/2.0 + float(m_field)*m_stepY)/2.0;
  45. float bstep = step(m_stepY, temp1);
  46. // Blend missing line
  47. vec2 belowY, belowU, belowV;
  48. belowY.x = offsetY.x;
  49. belowY.y = offsetY.y + (2.0*m_stepY*bstep);
  50. belowU.x = offsetU.x;
  51. belowU.y = offsetU.y + (m_stepY*bstep);
  52. belowV.x = offsetV.x;
  53. belowV.y = offsetV.y + (m_stepY*bstep);
  54. vec4 yuvBelow, rgbBelow;
  55. yuv.rgba = vec4(texture2D(m_sampY, offsetY).r, texture2D(m_sampU, offsetU).g, texture2D(m_sampV, offsetV).a, 1.0);
  56. rgb = m_yuvmat * yuv;
  57. rgb.a = m_alpha;
  58. yuvBelow.rgba = vec4(texture2D(m_sampY, belowY).r, texture2D(m_sampU, belowU).g, texture2D(m_sampV, belowV).a, 1.0);
  59. rgbBelow = m_yuvmat * yuvBelow;
  60. rgbBelow.a = m_alpha;
  61. gl_FragColor.rgba = mix(rgb, rgbBelow, 0.5);
  62. }