summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qcam/assets/shader/NV_2_planes_UV_f.glsl32
-rw-r--r--src/qcam/assets/shader/NV_2_planes_VU_f.glsl32
-rw-r--r--src/qcam/assets/shader/NV_3_planes_f.glsl33
-rw-r--r--src/qcam/assets/shader/NV_vertex_shader.glsl16
-rw-r--r--src/qcam/assets/shader/shaders.qrc9
-rw-r--r--src/qcam/meson.build1
6 files changed, 123 insertions, 0 deletions
diff --git a/src/qcam/assets/shader/NV_2_planes_UV_f.glsl b/src/qcam/assets/shader/NV_2_planes_UV_f.glsl
new file mode 100644
index 00000000..67633a11
--- /dev/null
+++ b/src/qcam/assets/shader/NV_2_planes_UV_f.glsl
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Linaro
+ *
+ * NV_2_planes_UV_f.glsl - Fragment shader code for NV12, NV16 and NV24 formats
+ */
+
+#ifdef GL_ES
+precision mediump float;
+#endif
+
+varying vec2 textureOut;
+uniform sampler2D tex_y;
+uniform sampler2D tex_u;
+
+void main(void)
+{
+ vec3 yuv;
+ vec3 rgb;
+ mat3 yuv2rgb_bt601_mat = mat3(
+ vec3(1.164, 1.164, 1.164),
+ vec3(0.000, -0.392, 2.017),
+ vec3(1.596, -0.813, 0.000)
+ );
+
+ yuv.x = texture2D(tex_y, textureOut).r - 0.063;
+ yuv.y = texture2D(tex_u, textureOut).r - 0.500;
+ yuv.z = texture2D(tex_u, textureOut).g - 0.500;
+
+ rgb = yuv2rgb_bt601_mat * yuv;
+ gl_FragColor = vec4(rgb, 1.0);
+}
diff --git a/src/qcam/assets/shader/NV_2_planes_VU_f.glsl b/src/qcam/assets/shader/NV_2_planes_VU_f.glsl
new file mode 100644
index 00000000..086c5b6d
--- /dev/null
+++ b/src/qcam/assets/shader/NV_2_planes_VU_f.glsl
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Linaro
+ *
+ * NV_2_planes_VU_f.glsl - Fragment shader code for NV21, NV61 and NV42 formats
+ */
+
+#ifdef GL_ES
+precision mediump float;
+#endif
+
+varying vec2 textureOut;
+uniform sampler2D tex_y;
+uniform sampler2D tex_u;
+
+void main(void)
+{
+ vec3 yuv;
+ vec3 rgb;
+ mat3 yuv2rgb_bt601_mat = mat3(
+ vec3(1.164, 1.164, 1.164),
+ vec3(0.000, -0.392, 2.017),
+ vec3(1.596, -0.813, 0.000)
+ );
+
+ yuv.x = texture2D(tex_y, textureOut).r - 0.063;
+ yuv.y = texture2D(tex_u, textureOut).g - 0.500;
+ yuv.z = texture2D(tex_u, textureOut).r - 0.500;
+
+ rgb = yuv2rgb_bt601_mat * yuv;
+ gl_FragColor = vec4(rgb, 1.0);
+}
diff --git a/src/qcam/assets/shader/NV_3_planes_f.glsl b/src/qcam/assets/shader/NV_3_planes_f.glsl
new file mode 100644
index 00000000..4bc94184
--- /dev/null
+++ b/src/qcam/assets/shader/NV_3_planes_f.glsl
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Linaro
+ *
+ * NV_3_planes_UV_f.glsl - Fragment shader code for YUV420 format
+ */
+
+#ifdef GL_ES
+precision mediump float;
+#endif
+
+varying vec2 textureOut;
+uniform sampler2D tex_y;
+uniform sampler2D tex_u;
+uniform sampler2D tex_v;
+
+void main(void)
+{
+ vec3 yuv;
+ vec3 rgb;
+ mat3 yuv2rgb_bt601_mat = mat3(
+ vec3(1.164, 1.164, 1.164),
+ vec3(0.000, -0.392, 2.017),
+ vec3(1.596, -0.813, 0.000)
+ );
+
+ yuv.x = texture2D(tex_y, textureOut).r - 0.063;
+ yuv.y = texture2D(tex_u, textureOut).r - 0.500;
+ yuv.z = texture2D(tex_v, textureOut).r - 0.500;
+
+ rgb = yuv2rgb_bt601_mat * yuv;
+ gl_FragColor = vec4(rgb, 1.0);
+}
diff --git a/src/qcam/assets/shader/NV_vertex_shader.glsl b/src/qcam/assets/shader/NV_vertex_shader.glsl
new file mode 100644
index 00000000..12e791e3
--- /dev/null
+++ b/src/qcam/assets/shader/NV_vertex_shader.glsl
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2020, Linaro
+ *
+ * NV_vertex_shader.glsl - Vertex shader code for NV family
+ */
+
+attribute vec4 vertexIn;
+attribute vec2 textureIn;
+varying vec2 textureOut;
+
+void main(void)
+{
+ gl_Position = vertexIn;
+ textureOut = textureIn;
+}
diff --git a/src/qcam/assets/shader/shaders.qrc b/src/qcam/assets/shader/shaders.qrc
new file mode 100644
index 00000000..33eab278
--- /dev/null
+++ b/src/qcam/assets/shader/shaders.qrc
@@ -0,0 +1,9 @@
+<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+<file>./NV_vertex_shader.glsl</file>
+<file>./NV_2_planes_UV_f.glsl</file>
+<file>./NV_2_planes_VU_f.glsl</file>
+<file>./NV_3_planes_f.glsl</file>
+</qresource>
+</RCC>
diff --git a/src/qcam/meson.build b/src/qcam/meson.build
index 6ea886a3..e0c6f26d 100644
--- a/src/qcam/meson.build
+++ b/src/qcam/meson.build
@@ -16,6 +16,7 @@ qcam_moc_headers = files([
qcam_resources = files([
'assets/feathericons/feathericons.qrc',
+ 'assets/shader/shaders.qrc'
])
qt5 = import('qt5')