| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
| 3 * All rights reserved. | 3 * All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 /* | 32 /* |
| 33 * This is an optimized version of the YUV to RGB conversion shader. This | 33 * This is an optimized version of the YUV to RGB conversion shader. This |
| 34 * shader assumes the height of U and V planes is odd, which means the height | 34 * shader assumes the height of U and V planes is odd, which means the height |
| 35 * of the original image is 2 modulo 4. | 35 * of the original image is 2 modulo 4. |
| 36 */ | 36 */ |
| 37 | 37 |
| 38 #define I915_WORKAROUND 1 | |
| 39 | |
| 40 uniform sampler2D textureSampler; | 38 uniform sampler2D textureSampler; |
| 41 uniform sampler2D paritySampler; | 39 uniform sampler2D paritySampler; |
| 42 | 40 |
| 43 varying vec2 lineCounter; | 41 varying vec2 lineCounter; |
| 44 varying vec2 yPlane; | 42 varying vec2 yPlane; |
| 45 varying vec2 uPlane; | 43 varying vec2 uPlane; |
| 46 varying vec2 vPlane; | 44 varying vec2 vPlane; |
| 47 | 45 |
| 48 void main() { | 46 void main() { |
| 49 /* | 47 /* |
| 50 * If the height of the original image is even, offset_odd is not needed. | 48 * If the height of the original image is even, offset_odd is not needed. |
| 51 */ | 49 */ |
| 52 #if I915_WORKAROUND | 50 #if defined(I915_WORKAROUND) |
| 53 vec2 offset_even = vec2(texture2D(paritySampler, gl_TexCoord[0].xy).x * 0.5, | 51 vec2 offset_even = vec2(texture2D(paritySampler, gl_TexCoord[0].xy).x * 0.5, |
| 54 0.0); | 52 0.0); |
| 55 #else | 53 #else |
| 56 vec2 offset_even = vec2(texture2D(paritySampler, lineCounter).x * 0.5, 0.0); | 54 vec2 offset_even = vec2(texture2D(paritySampler, lineCounter).x * 0.5, 0.0); |
| 57 #endif | 55 #endif |
| 58 vec2 offset_odd = vec2(0.5 - offset_even.x, 0.0); | 56 vec2 offset_odd = vec2(0.5 - offset_even.x, 0.0); |
| 59 | 57 |
| 60 #if I915_WORKAROUND | 58 #if defined(I915_WORKAROUND) |
| 61 float yChannel = texture2D(textureSampler, gl_TexCoord[0].zw).x; | 59 float yChannel = texture2D(textureSampler, gl_TexCoord[0].zw).x; |
| 62 float uChannel = texture2D(textureSampler, gl_TexCoord[1].xy + offset_even).x; | 60 float uChannel = texture2D(textureSampler, gl_TexCoord[1].xy + offset_even).x; |
| 63 float vChannel = texture2D(textureSampler, gl_TexCoord[1].zw + offset_odd).x; | 61 float vChannel = texture2D(textureSampler, gl_TexCoord[1].zw + offset_odd).x; |
| 64 #else | 62 #else |
| 65 float yChannel = texture2D(textureSampler, yPlane).x; | 63 float yChannel = texture2D(textureSampler, yPlane).x; |
| 66 float uChannel = texture2D(textureSampler, uPlane + offset_even).x; | 64 float uChannel = texture2D(textureSampler, uPlane + offset_even).x; |
| 67 float vChannel = texture2D(textureSampler, vPlane + offset_odd).x; | 65 float vChannel = texture2D(textureSampler, vPlane + offset_odd).x; |
| 68 #endif | 66 #endif |
| 69 /* | 67 /* |
| 70 * This does the colorspace conversion from Y'UV to RGB as a matrix | 68 * This does the colorspace conversion from Y'UV to RGB as a matrix |
| 71 * multiply. It also does the offset of the U and V channels from | 69 * multiply. It also does the offset of the U and V channels from |
| 72 * [0,1] to [-.5,.5] as part of the transform. | 70 * [0,1] to [-.5,.5] as part of the transform. |
| 73 */ | 71 */ |
| 74 vec4 channels = vec4(yChannel, uChannel, vChannel, 1.0); | 72 vec4 channels = vec4(yChannel, uChannel, vChannel, 1.0); |
| 75 mat4 conversion = mat4( 1.0, 1.0, 1.0, 0.0, | 73 mat4 conversion = mat4( 1.0, 1.0, 1.0, 0.0, |
| 76 0.0, -0.344, 1.772, 0.0, | 74 0.0, -0.344, 1.772, 0.0, |
| 77 1.402, -0.714, 0.0, 0.0, | 75 1.402, -0.714, 0.0, 0.0, |
| 78 -0.701, 0.529, -0.886, 1.0); | 76 -0.701, 0.529, -0.886, 1.0); |
| 79 | 77 |
| 80 gl_FragColor = conversion * channels; | 78 gl_FragColor = conversion * channels; |
| 81 } | 79 } |
| OLD | NEW |