diff options
author | Artem Dyomin <artem.dyomin@qt.io> | 2024-01-23 14:30:04 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-01-23 19:39:41 +0000 |
commit | b4ccc09abb258f57ca8b1d456369067136673a5a (patch) | |
tree | 559f66f35bfc327d91668899c3ebff5bdf033a07 | |
parent | a3a82617bccab94ca180534f0c038c83ef414086 (diff) |
Fix conversion of QImage::Format_RGBA8888_Premultiplied to PixelFormat
QImage::Format_RGBA8888_Premultiplied should be converted to
QVideoFrameFormat::Format_RGBA8888_Premultiplied which is not present
in the list of formats. It should be added in 6.8.
We've got the format on eglfs, when we grab a frame by OpenglCompositor.
The best workaround is conversion to QVideoFrameFormat::Format_RGBX8888.
Pick-to: 6.6 6.5
Change-Id: Ic84d47f62c379e4a476a868b2985b525c0ec7edb
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit bdc9e0a2e30d2a7a7edf0c52630eb8137038cd89)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimedia/video/qvideoframeformat.cpp | 4 | ||||
-rw-r--r-- | tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/multimedia/video/qvideoframeformat.cpp b/src/multimedia/video/qvideoframeformat.cpp index cdb1d3c0a..b2c9dc5f1 100644 --- a/src/multimedia/video/qvideoframeformat.cpp +++ b/src/multimedia/video/qvideoframeformat.cpp @@ -743,7 +743,9 @@ QVideoFrameFormat::PixelFormat QVideoFrameFormat::pixelFormatFromImageFormat(QIm case QImage::Format_RGBA8888: return QVideoFrameFormat::Format_RGBA8888; case QImage::Format_RGBA8888_Premultiplied: - return QVideoFrameFormat::Format_ARGB8888_Premultiplied; + // QVideoFrameFormat::Format_RGBA8888_Premultiplied is to be added in 6.8 + // Format_RGBX8888 suits the best as a workaround + return QVideoFrameFormat::Format_RGBX8888; case QImage::Format_RGBX8888: return QVideoFrameFormat::Format_RGBX8888; case QImage::Format_Grayscale8: diff --git a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp index ba1ad233c..43eb8be9a 100644 --- a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp @@ -788,6 +788,11 @@ void tst_QVideoFrame::formatConversion_data() QTest::newRow("QVideoFrameFormat::Format_Jpeg") << QImage::Format_Invalid << QVideoFrameFormat::Format_Jpeg; + QTest::newRow("QVideoFrameFormat::Format_RGBX8888") + << QImage::Format_RGBX8888 << QVideoFrameFormat::Format_RGBX8888; + QTest::newRow("QImage::Format_RGBA8888_Premultiplied => QVideoFrameFormat::Format_RGBX8888 " + "(workaround)") + << QImage::Format_RGBA8888_Premultiplied << QVideoFrameFormat::Format_RGBX8888; } void tst_QVideoFrame::formatConversion() @@ -798,6 +803,12 @@ void tst_QVideoFrame::formatConversion() if (imageFormat != QImage::Format_Invalid) QCOMPARE(QVideoFrameFormat::pixelFormatFromImageFormat(imageFormat), pixelFormat); + if (imageFormat == QImage::Format_RGBA8888_Premultiplied) { + qWarning() << "Workaround: convert QImage::Format_RGBA8888_Premultiplied to " + "QVideoFrameFormat::Format_RGBX8888; to be removed in 6.8"; + return; + } + if (pixelFormat != QVideoFrameFormat::Format_Invalid) QCOMPARE(QVideoFrameFormat::imageFormatFromPixelFormat(pixelFormat), imageFormat); } |