diff options
author | André de la Rocha <andre.rocha@qt.io> | 2022-08-22 16:00:04 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-08-24 21:03:41 +0000 |
commit | a66c1538ee3fc198746e4d0476ffd75d41a105e1 (patch) | |
tree | 156bdc910103b4156e4866977c5ba6b4d24813ae | |
parent | 9371afd63934995e35a528be6eca12d030057245 (diff) |
Revert "Fix for QImage format issue in the qImageFromVideoFrame function"
The patch was incorrect, as the shader-based conversion always
generates RGBA images, while the CPU-based conversion can generate
other formats. It caused, for instance, images to be captured from
the camera with the wrong colors. Also adjusting
tst_QVideoFrame::image() accordingly.
This reverts commit 80871c952a009be6b35a912d946d63b78d5d06b4.
Change-Id: Iadfb9a391bb7a3290e604a8ac13803cb4f0d2e87
Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit c173807a7da112451cf459c70e6aac1686ee09f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/multimedia/video/qvideoframeconverter.cpp | 10 | ||||
-rw-r--r-- | tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp | 42 |
2 files changed, 14 insertions, 38 deletions
diff --git a/src/multimedia/video/qvideoframeconverter.cpp b/src/multimedia/video/qvideoframeconverter.cpp index ddf2e491d..a1a3c8c76 100644 --- a/src/multimedia/video/qvideoframeconverter.cpp +++ b/src/multimedia/video/qvideoframeconverter.cpp @@ -409,19 +409,11 @@ QImage qImageFromVideoFrame(const QVideoFrame &frame, QVideoFrame::RotationAngle return convertCPU(frame, rotation, mirrorX, mirrorY); } - if (!qConverterForFormat(frame.pixelFormat())) { - qCDebug(qLcVideoFrameConverter) << "Unsupported pixel format" << frame.pixelFormat(); - return {}; - } - - QImage::Format format = pixelFormatHasAlpha(frame.pixelFormat()) ? - QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32; - QByteArray *imageData = new QByteArray(readResult.data); return QImage(reinterpret_cast<const uchar *>(imageData->constData()), readResult.pixelSize.width(), readResult.pixelSize.height(), - format, imageCleanupHandler, imageData); + QImage::Format_RGBA8888_Premultiplied, imageCleanupHandler, imageData); } QT_END_NAMESPACE diff --git a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp index 5d3f35844..7685e0cb4 100644 --- a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp @@ -891,85 +891,69 @@ void tst_QVideoFrame::image_data() { QTest::addColumn<QSize>("size"); QTest::addColumn<QVideoFrameFormat::PixelFormat>("pixelFormat"); - QTest::addColumn<QImage::Format>("imageFormat"); QTest::newRow("64x64 ARGB32") << QSize(64, 64) - << QVideoFrameFormat::Format_ARGB8888 - << QImage::Format_ARGB32_Premultiplied; + << QVideoFrameFormat::Format_ARGB8888; QTest::newRow("64x64 ARGB32_Premultiplied") << QSize(64, 64) - << QVideoFrameFormat::Format_ARGB8888_Premultiplied - << QImage::Format_ARGB32_Premultiplied; + << QVideoFrameFormat::Format_ARGB8888_Premultiplied; QTest::newRow("64x64 RGB32") << QSize(64, 64) - << QVideoFrameFormat::Format_XRGB8888 - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_XRGB8888; QTest::newRow("64x64 BGRA32") << QSize(64, 64) - << QVideoFrameFormat::Format_BGRA8888 - << QImage::Format_ARGB32_Premultiplied; + << QVideoFrameFormat::Format_BGRA8888; QTest::newRow("64x64 BGRA32_Premultiplied") << QSize(64, 64) - << QVideoFrameFormat::Format_BGRA8888_Premultiplied - << QImage::Format_ARGB32_Premultiplied; + << QVideoFrameFormat::Format_BGRA8888_Premultiplied; QTest::newRow("64x64 BGR32") << QSize(64, 64) - << QVideoFrameFormat::Format_XBGR8888 - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_XBGR8888; QTest::newRow("64x64 AYUV") << QSize(64, 64) - << QVideoFrameFormat::Format_AYUV - << QImage::Format_ARGB32_Premultiplied; + << QVideoFrameFormat::Format_AYUV; QTest::newRow("64x64 YUV420P") << QSize(64, 64) - << QVideoFrameFormat::Format_YUV420P - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_YUV420P; QTest::newRow("64x64 YV12") << QSize(64, 64) - << QVideoFrameFormat::Format_YV12 - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_YV12; QTest::newRow("64x64 UYVY") << QSize(64, 64) - << QVideoFrameFormat::Format_UYVY - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_UYVY; QTest::newRow("64x64 YUYV") << QSize(64, 64) - << QVideoFrameFormat::Format_YUYV - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_YUYV; QTest::newRow("64x64 NV12") << QSize(64, 64) - << QVideoFrameFormat::Format_NV12 - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_NV12; QTest::newRow("64x64 NV21") << QSize(64, 64) - << QVideoFrameFormat::Format_NV21 - << QImage::Format_RGB32; + << QVideoFrameFormat::Format_NV21; } void tst_QVideoFrame::image() { QFETCH(QSize, size); QFETCH(QVideoFrameFormat::PixelFormat, pixelFormat); - QFETCH(QImage::Format, imageFormat); QVideoFrame frame(QVideoFrameFormat(size, pixelFormat)); QImage img = frame.toImage(); QVERIFY(!img.isNull()); - QCOMPARE(img.format(), imageFormat); QCOMPARE(img.size(), size); } |