summaryrefslogtreecommitdiff
path: root/src/qtmultimediaquicktools/shaders/yuyvvideo.frag
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-01-18 18:01:58 +0100
committerLiang Qi <liang.qi@qt.io>2018-01-18 18:01:58 +0100
commit2e9d1fa5ef1367e5d2ace88bc47f93b8fe8a039b (patch)
treee34abd8ef99ae1abb2730a3772debe3fc9b26144 /src/qtmultimediaquicktools/shaders/yuyvvideo.frag
parentb8609cd3ffeddd02a514c6b5f9170c8017966e41 (diff)
parent7638848d2486e2fac9764b60a99de08f50adc8eb (diff)
downloadqtmultimedia-2e9d1fa5ef1367e5d2ace88bc47f93b8fe8a039b.tar.gz
Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: I7566f543ce11ff6cddc4d17e2c258a582f365b65
Diffstat (limited to 'src/qtmultimediaquicktools/shaders/yuyvvideo.frag')
-rw-r--r--src/qtmultimediaquicktools/shaders/yuyvvideo.frag18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/qtmultimediaquicktools/shaders/yuyvvideo.frag b/src/qtmultimediaquicktools/shaders/yuyvvideo.frag
index 72732cd66..5ce8b7366 100644
--- a/src/qtmultimediaquicktools/shaders/yuyvvideo.frag
+++ b/src/qtmultimediaquicktools/shaders/yuyvvideo.frag
@@ -1,22 +1,12 @@
-uniform sampler2D yuvTexture; // YUYV macropixel texture passed as RGBA format
-uniform mediump float imageWidth; // The YUYV texture appears to the shader with 1/2 the image width since we use the RGBA format to pass YUYV
+uniform sampler2D yTexture; // Y component passed as GL_LUMINANCE_ALPHA, in yuyv Y = r
+uniform sampler2D uvTexture; // UV component passed as RGBA macropixel, in uyvy U = g, V = a
uniform mediump mat4 colorMatrix;
uniform lowp float opacity;
-
varying highp vec2 qt_TexCoord;
void main()
{
- // For Y0 U0 Y1 V0 macropixel, lookup Y0 or Y1 based on whether
- // the original texture x coord is even or odd.
- mediump float Y;
- if (fract(floor(qt_TexCoord.x * imageWidth + 0.5) / 2.0) > 0.0)
- Y = texture2D(yuvTexture, qt_TexCoord).b; // odd so choose Y1
- else
- Y = texture2D(yuvTexture, qt_TexCoord).r; // even so choose Y0
- mediump float Cb = texture2D(yuvTexture, qt_TexCoord).g;
- mediump float Cr = texture2D(yuvTexture, qt_TexCoord).a;
+ mediump vec3 YUV = vec3(texture2D(yTexture, qt_TexCoord).r, texture2D(uvTexture, qt_TexCoord).ga);
- mediump vec4 color = vec4(Y, Cb, Cr, 1.0);
- gl_FragColor = colorMatrix * color * opacity;
+ gl_FragColor = colorMatrix * vec4(YUV, 1.0) * opacity;
}