summaryrefslogtreecommitdiffstats
path: root/src/qtmultimediaquicktools/shaders
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2016-04-29 15:47:52 +0200
committerYoann Lopes <yoann.lopes@qt.io>2016-04-29 13:51:02 +0000
commitbc8e257718240f92db70b229980fc97e8317997d (patch)
treef9e053ae29416152494504a6eb938c52c41df10c /src/qtmultimediaquicktools/shaders
parent0a73b2e63a5cec80edc89cfefd7d86064d393c46 (diff)
Implement YUV 4:2:2 8bit support for QtQuick
This patch implements support for rendering of UYVY and YUYV sources when using QtQuick for preview. [ChangeLog][QtQuick][Rendering] Support for YUV 4:2:2 8bit has been implemented for the QtQuick viewfinder. Change-Id: I4d98f3c44240ee53f7708bc6bd84e7fb83aac069 Reviewed-by: Yoann Lopes <yoann.lopes@qt.io>
Diffstat (limited to 'src/qtmultimediaquicktools/shaders')
-rw-r--r--src/qtmultimediaquicktools/shaders/monoplanarvideo.vert (renamed from src/qtmultimediaquicktools/shaders/rgbvideo.vert)0
-rw-r--r--src/qtmultimediaquicktools/shaders/uyvyvideo.frag22
-rw-r--r--src/qtmultimediaquicktools/shaders/yuyvvideo.frag22
3 files changed, 44 insertions, 0 deletions
diff --git a/src/qtmultimediaquicktools/shaders/rgbvideo.vert b/src/qtmultimediaquicktools/shaders/monoplanarvideo.vert
index 19915f2ff..19915f2ff 100644
--- a/src/qtmultimediaquicktools/shaders/rgbvideo.vert
+++ b/src/qtmultimediaquicktools/shaders/monoplanarvideo.vert
diff --git a/src/qtmultimediaquicktools/shaders/uyvyvideo.frag b/src/qtmultimediaquicktools/shaders/uyvyvideo.frag
new file mode 100644
index 000000000..8e34f7d33
--- /dev/null
+++ b/src/qtmultimediaquicktools/shaders/uyvyvideo.frag
@@ -0,0 +1,22 @@
+uniform sampler2D yuvTexture; // UYVY macropixel texture passed as RGBA format
+uniform float imageWidth; // The UYVY texture appears to the shader with 1/2 the image width since we use the RGBA format to pass UYVY
+uniform mediump mat4 colorMatrix;
+uniform lowp float opacity;
+
+varying highp vec2 qt_TexCoord;
+
+void main()
+{
+ // For U0 Y0 V0 Y1 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).a; // odd so choose Y1
+ else
+ Y = texture2D(yuvTexture, qt_TexCoord).g; // even so choose Y0
+ mediump float Cb = texture2D(yuvTexture, qt_TexCoord).r;
+ mediump float Cr = texture2D(yuvTexture, qt_TexCoord).b;
+
+ mediump vec4 color = vec4(Y, Cb, Cr, 1.0);
+ gl_FragColor = colorMatrix * color * opacity;
+}
diff --git a/src/qtmultimediaquicktools/shaders/yuyvvideo.frag b/src/qtmultimediaquicktools/shaders/yuyvvideo.frag
new file mode 100644
index 000000000..876771008
--- /dev/null
+++ b/src/qtmultimediaquicktools/shaders/yuyvvideo.frag
@@ -0,0 +1,22 @@
+uniform sampler2D yuvTexture; // YUYV macropixel texture passed as RGBA format
+uniform 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 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 vec4 color = vec4(Y, Cb, Cr, 1.0);
+ gl_FragColor = colorMatrix * color * opacity;
+}