summaryrefslogtreecommitdiffstats
path: root/src/multimedia
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-04-04 17:29:27 +0200
committerLars Knoll <lars.knoll@qt.io>2021-04-08 12:19:04 +0000
commiteef8a2079639e5c35dc74fafe656b0d0ef504f9a (patch)
treeb0fb8cdba389cf242880c48564bbbe094ffb893b /src/multimedia
parent74c7dc45ed4b79843260e4e16d808987de1aacc8 (diff)
Remove the plane width code from the shaders
This wasn't used at all. We always assume plane texture coords are correct. If anything else should be required, it can be fixed in a special shader. Change-Id: Idfdd428fc5a267f6ad68683b369fb95f5e42d918 Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r--src/multimedia/shaders/ayuv.frag9
-rw-r--r--src/multimedia/shaders/nv12.frag10
-rw-r--r--src/multimedia/shaders/nv21.frag10
-rw-r--r--src/multimedia/shaders/p010.frag10
-rw-r--r--src/multimedia/shaders/uyvy.frag8
-rw-r--r--src/multimedia/shaders/yuv.vert11
-rw-r--r--src/multimedia/shaders/yuv_yv.frag13
-rw-r--r--src/multimedia/shaders/yuyv.frag8
-rw-r--r--src/multimedia/video/qvideotexturehelper.cpp29
9 files changed, 26 insertions, 82 deletions
diff --git a/src/multimedia/shaders/ayuv.frag b/src/multimedia/shaders/ayuv.frag
index 100c6512c..6ae19b166 100644
--- a/src/multimedia/shaders/ayuv.frag
+++ b/src/multimedia/shaders/ayuv.frag
@@ -1,23 +1,18 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
-layout(binding = 2) uniform sampler2D plane2Texture;
void main()
{
- vec3 YUV = texture(plane1Texture, plane1TexCoord).gra;
+ vec3 YUV = texture(plane1Texture, texCoord).gra;
fragColor = ubuf.colorMatrix * vec4(YUV, 1.0) * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/nv12.frag b/src/multimedia/shaders/nv12.frag
index 9ef6bd648..49c333c98 100644
--- a/src/multimedia/shaders/nv12.frag
+++ b/src/multimedia/shaders/nv12.frag
@@ -1,16 +1,12 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
@@ -18,8 +14,8 @@ layout(binding = 2) uniform sampler2D plane2Texture;
void main()
{
- float Y = texture(plane1Texture, plane1TexCoord).r;
- vec2 UV = texture(plane2Texture, plane2TexCoord).rg;
+ float Y = texture(plane1Texture, texCoord).r;
+ vec2 UV = texture(plane2Texture, texCoord).rg;
vec4 color = vec4(Y, UV.x, UV.y, 1.);
fragColor = ubuf.colorMatrix * color * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/nv21.frag b/src/multimedia/shaders/nv21.frag
index 636294048..5876c504a 100644
--- a/src/multimedia/shaders/nv21.frag
+++ b/src/multimedia/shaders/nv21.frag
@@ -1,16 +1,12 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
@@ -18,8 +14,8 @@ layout(binding = 2) uniform sampler2D plane2Texture;
void main()
{
- float Y = texture(plane1Texture, plane1TexCoord).r;
- vec2 UV = texture(plane2Texture, plane2TexCoord).gr;
+ float Y = texture(plane1Texture, texCoord).r;
+ vec2 UV = texture(plane2Texture, texCoord).gr;
vec4 color = vec4(Y, UV.x, UV.y, 1.);
fragColor = ubuf.colorMatrix * color * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/p010.frag b/src/multimedia/shaders/p010.frag
index 9ef6bd648..49c333c98 100644
--- a/src/multimedia/shaders/p010.frag
+++ b/src/multimedia/shaders/p010.frag
@@ -1,16 +1,12 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
@@ -18,8 +14,8 @@ layout(binding = 2) uniform sampler2D plane2Texture;
void main()
{
- float Y = texture(plane1Texture, plane1TexCoord).r;
- vec2 UV = texture(plane2Texture, plane2TexCoord).rg;
+ float Y = texture(plane1Texture, texCoord).r;
+ vec2 UV = texture(plane2Texture, texCoord).rg;
vec4 color = vec4(Y, UV.x, UV.y, 1.);
fragColor = ubuf.colorMatrix * color * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/uyvy.frag b/src/multimedia/shaders/uyvy.frag
index f1c7c1aec..d48e9a5b5 100644
--- a/src/multimedia/shaders/uyvy.frag
+++ b/src/multimedia/shaders/uyvy.frag
@@ -1,16 +1,12 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
@@ -18,6 +14,6 @@ layout(binding = 2) uniform sampler2D plane2Texture;
void main()
{
- vec3 YUV = vec3(texture(plane1Texture, plane1TexCoord).g, texture(plane2Texture, plane2TexCoord).rb);
+ vec3 YUV = vec3(texture(plane1Texture, texCoord).g, texture(plane2Texture, texCoord).rb);
fragColor = ubuf.colorMatrix * vec4(YUV, 1.0) * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/yuv.vert b/src/multimedia/shaders/yuv.vert
index 6f103372f..cc73b37bf 100644
--- a/src/multimedia/shaders/yuv.vert
+++ b/src/multimedia/shaders/yuv.vert
@@ -3,24 +3,17 @@
layout(location = 0) in vec4 qt_VertexPosition;
layout(location = 1) in vec2 qt_VertexTexCoord;
-layout(location = 0) out vec2 plane1TexCoord;
-layout(location = 1) out vec2 plane2TexCoord;
-layout(location = 2) out vec2 plane3TexCoord;
+layout(location = 0) out vec2 texCoord;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
out gl_PerVertex { vec4 gl_Position; };
void main() {
- plane1TexCoord = qt_VertexTexCoord * vec2(ubuf.plane1Width, 1);
- plane2TexCoord = qt_VertexTexCoord * vec2(ubuf.plane2Width, 1);
- plane3TexCoord = qt_VertexTexCoord * vec2(ubuf.plane3Width, 1);
+ texCoord = qt_VertexTexCoord;
gl_Position = ubuf.matrix * qt_VertexPosition;
}
diff --git a/src/multimedia/shaders/yuv_yv.frag b/src/multimedia/shaders/yuv_yv.frag
index 07ea52aab..26fa202f5 100644
--- a/src/multimedia/shaders/yuv_yv.frag
+++ b/src/multimedia/shaders/yuv_yv.frag
@@ -1,17 +1,12 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
-layout(location = 2) in vec2 plane3TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
@@ -20,9 +15,9 @@ layout(binding = 3) uniform sampler2D plane3Texture;
void main()
{
- float Y = texture(plane1Texture, plane1TexCoord).r;
- float U = texture(plane2Texture, plane2TexCoord).r;
- float V = texture(plane3Texture, plane3TexCoord).r;
+ float Y = texture(plane1Texture, texCoord).r;
+ float U = texture(plane2Texture, texCoord).r;
+ float V = texture(plane3Texture, texCoord).r;
vec4 color = vec4(Y, U, V, 1.);
fragColor = ubuf.colorMatrix * color * ubuf.opacity;
}
diff --git a/src/multimedia/shaders/yuyv.frag b/src/multimedia/shaders/yuyv.frag
index 454fdc21e..6838596e8 100644
--- a/src/multimedia/shaders/yuyv.frag
+++ b/src/multimedia/shaders/yuyv.frag
@@ -1,16 +1,12 @@
#version 440
-layout(location = 0) in vec2 plane1TexCoord;
-layout(location = 1) in vec2 plane2TexCoord;
+layout(location = 0) in vec2 texCoord;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 matrix;
mat4 colorMatrix;
float opacity;
- float plane1Width;
- float plane2Width;
- float plane3Width;
} ubuf;
layout(binding = 1) uniform sampler2D plane1Texture;
@@ -18,6 +14,6 @@ layout(binding = 2) uniform sampler2D plane2Texture;
void main()
{
- vec3 YUV = vec3(texture(plane1Texture, plane1TexCoord).r, texture(plane2Texture, plane2TexCoord).ga);
+ vec3 YUV = vec3(texture(plane1Texture, texCoord).r, texture(plane2Texture, texCoord).ga);
fragColor = ubuf.colorMatrix * vec4(YUV, 1.0) * ubuf.opacity;
}
diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp
index ed3742b47..e57e2f615 100644
--- a/src/multimedia/video/qvideotexturehelper.cpp
+++ b/src/multimedia/video/qvideotexturehelper.cpp
@@ -324,9 +324,6 @@ static QMatrix4x4 colorMatrix(QVideoSurfaceFormat::YCbCrColorSpace colorSpace)
QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &transform, float opacity)
{
- static constexpr float pw[3] = {};
- const float *planeWidth = pw;
-
switch (format.pixelFormat()) {
case QVideoSurfaceFormat::Format_Invalid:
case QVideoSurfaceFormat::Format_Jpeg:
@@ -359,40 +356,24 @@ QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &tran
return buf;
}
case QVideoSurfaceFormat::Format_AYUV444:
- case QVideoSurfaceFormat::Format_AYUV444_Premultiplied: {
- static constexpr float pw[] = { 1, 0, 0 };
- planeWidth = pw;
- break;
- }
+ case QVideoSurfaceFormat::Format_AYUV444_Premultiplied:
case QVideoSurfaceFormat::Format_YUV420P:
case QVideoSurfaceFormat::Format_YUV422P:
- case QVideoSurfaceFormat::Format_YV12: {
- static constexpr float pw[] = { 1, 1, 1 };
- planeWidth = pw;
- break;
- }
+ case QVideoSurfaceFormat::Format_YV12:
case QVideoSurfaceFormat::Format_UYVY:
- case QVideoSurfaceFormat::Format_YUYV: {
- static constexpr float pw[] = { 1, 1, 0 };
- planeWidth = pw;
- break;
- }
+ case QVideoSurfaceFormat::Format_YUYV:
case QVideoSurfaceFormat::Format_NV12:
case QVideoSurfaceFormat::Format_NV21:
case QVideoSurfaceFormat::Format_P010:
- case QVideoSurfaceFormat::Format_P016: {
- static constexpr float pw[] = { 1, 1, 0 };
- planeWidth = pw;
+ case QVideoSurfaceFormat::Format_P016:
break;
}
- }
// { matrix4x4, colorMatrix, opacity, planeWidth[3] }
- QByteArray buf(64*2 + 4 + 3*4, Qt::Uninitialized);
+ QByteArray buf(64*2 + 4, Qt::Uninitialized);
char *data = buf.data();
memcpy(data, transform.constData(), 64);
memcpy(data + 64, colorMatrix(format.yCbCrColorSpace()).constData(), 64);
memcpy(data + 64 + 64, &opacity, 4);
- memcpy(data + 64 + 64 + 4, planeWidth, 3*4);
return buf;
}