summaryrefslogtreecommitdiffstats
path: root/src/multimedia/video/qvideotexturehelper.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2021-04-04 17:49:48 +0200
committerLars Knoll <lars.knoll@qt.io>2021-04-08 12:19:11 +0000
commitebb4b2cd47dde5b343c1e53104e8cd5aa426a09c (patch)
treeb93d12ae3a009868d3eb985392301849ad94a1b9 /src/multimedia/video/qvideotexturehelper.cpp
parenteef8a2079639e5c35dc74fafe656b0d0ef504f9a (diff)
Add a colorMatrix to the rgb shaders
This unifies the uniform layout for all pixel formats, and has the advantage that we can now use the color matrix to do brightness adjustments if required by the sink. Fix the rgb pixel shaders and add a missing one for ABGR. Change-Id: I545b4e0f0c067501903ee5f7af1f0f1f80b2b0bb Reviewed-by: Doris Verria <doris.verria@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/multimedia/video/qvideotexturehelper.cpp')
-rw-r--r--src/multimedia/video/qvideotexturehelper.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/multimedia/video/qvideotexturehelper.cpp b/src/multimedia/video/qvideotexturehelper.cpp
index e57e2f615..b9db64c5f 100644
--- a/src/multimedia/video/qvideotexturehelper.cpp
+++ b/src/multimedia/video/qvideotexturehelper.cpp
@@ -234,7 +234,7 @@ QString vertexShaderFileName(QVideoSurfaceFormat::PixelFormat format)
case QVideoSurfaceFormat::Format_BGRA32_Premultiplied:
case QVideoSurfaceFormat::Format_ABGR32:
case QVideoSurfaceFormat::Format_BGR32:
- return QStringLiteral(":/qt-project.org/multimedia/shaders/rgba.vert.qsb");
+ return QStringLiteral(":/qt-project.org/multimedia/shaders/rgb.vert.qsb");
case QVideoSurfaceFormat::Format_YUV420P:
case QVideoSurfaceFormat::Format_YUV422P:
case QVideoSurfaceFormat::Format_YV12:
@@ -273,11 +273,13 @@ QString fragmentShaderFileName(QVideoSurfaceFormat::PixelFormat format)
case QVideoSurfaceFormat::Format_ARGB32:
case QVideoSurfaceFormat::Format_ARGB32_Premultiplied:
case QVideoSurfaceFormat::Format_RGB32:
+ return QStringLiteral(":/qt-project.org/multimedia/shaders/argb.frag.qsb");
case QVideoSurfaceFormat::Format_BGRA32:
case QVideoSurfaceFormat::Format_BGRA32_Premultiplied:
+ return QStringLiteral(":/qt-project.org/multimedia/shaders/bgra.frag.qsb");
case QVideoSurfaceFormat::Format_ABGR32:
case QVideoSurfaceFormat::Format_BGR32:
- return QStringLiteral(":/qt-project.org/multimedia/shaders/rgba.frag.qsb");
+ return QStringLiteral(":/qt-project.org/multimedia/shaders/abgr.frag.qsb");
case QVideoSurfaceFormat::Format_YUV420P:
case QVideoSurfaceFormat::Format_YUV422P:
case QVideoSurfaceFormat::Format_YV12:
@@ -324,6 +326,7 @@ static QMatrix4x4 colorMatrix(QVideoSurfaceFormat::YCbCrColorSpace colorSpace)
QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &transform, float opacity)
{
+ QMatrix4x4 cmat;
switch (format.pixelFormat()) {
case QVideoSurfaceFormat::Format_Invalid:
case QVideoSurfaceFormat::Format_Jpeg:
@@ -347,14 +350,8 @@ QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &tran
case QVideoSurfaceFormat::Format_BGRA32:
case QVideoSurfaceFormat::Format_BGRA32_Premultiplied:
case QVideoSurfaceFormat::Format_ABGR32:
- case QVideoSurfaceFormat::Format_BGR32: {
- // { matrix4x4, opacity }
- QByteArray buf(16*4 + 4, Qt::Uninitialized);
- char *data = buf.data();
- memcpy(data, transform.constData(), 64);
- memcpy(data + 64, &opacity, 4);
- return buf;
- }
+ case QVideoSurfaceFormat::Format_BGR32:
+ break;
case QVideoSurfaceFormat::Format_AYUV444:
case QVideoSurfaceFormat::Format_AYUV444_Premultiplied:
case QVideoSurfaceFormat::Format_YUV420P:
@@ -366,13 +363,14 @@ QByteArray uniformData(const QVideoSurfaceFormat &format, const QMatrix4x4 &tran
case QVideoSurfaceFormat::Format_NV21:
case QVideoSurfaceFormat::Format_P010:
case QVideoSurfaceFormat::Format_P016:
+ cmat = colorMatrix(format.yCbCrColorSpace());
break;
}
// { matrix4x4, colorMatrix, opacity, planeWidth[3] }
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, cmat.constData(), 64);
memcpy(data + 64 + 64, &opacity, 4);
return buf;
}