diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-10-11 11:51:14 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-10-31 09:49:49 +0100 |
commit | 59d0683c999bec5612f6ba91867bde4d02185204 (patch) | |
tree | a8bcd49d8044d2b9a76699137ad763a11a5464bb /tests | |
parent | 71e2096c2b704420cbb0ee836c16565b658b3d0f (diff) |
Introduce QVideoFrame::image()
Since QVideoFrame::pixelFormat's do not 100% match QImage::Format's,
introducing converstion function.
Returns an image based on current frame.
Converts data if needed to supported QImage format.
Change-Id: I3331578c01cf9c999a380efc4a83bf9eddb07901
(cherry picked from commit 93f966335e1ed8ed47b7e8b32452d43c2f8a7bb1)
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp | 5 | ||||
-rw-r--r-- | tests/auto/unit/qvideoframe/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/unit/qvideoframe/tst_qvideoframe.cpp | 169 |
3 files changed, 173 insertions, 3 deletions
diff --git a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp index 894486230..27fc014aa 100644 --- a/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp +++ b/tests/auto/integration/qcamerabackend/tst_qcamerabackend.cpp @@ -49,7 +49,6 @@ #include <qcameraimagecapture.h> #include <qvideorenderercontrol.h> #include <private/qmediaserviceprovider_p.h> -#include <private/qvideoframe_p.h> QT_USE_NAMESPACE @@ -451,7 +450,7 @@ void tst_QCameraBackend::testCaptureToBuffer() QCOMPARE(imageAvailableSignal.first().first().toInt(), id); QVideoFrame frame = imageAvailableSignal.first().last().value<QVideoFrame>(); - QVERIFY(!qt_imageFromVideoFrame(frame).isNull()); + QVERIFY(!frame.image().isNull()); frame = QVideoFrame(); capturedSignal.clear(); @@ -509,7 +508,7 @@ void tst_QCameraBackend::testCaptureToBuffer() QCOMPARE(imageAvailableSignal.first().first().toInt(), id); frame = imageAvailableSignal.first().last().value<QVideoFrame>(); - QVERIFY(!qt_imageFromVideoFrame(frame).isNull()); + QVERIFY(!frame.image().isNull()); QString fileName = savedSignal.first().last().toString(); QVERIFY(QFileInfo(fileName).exists()); diff --git a/tests/auto/unit/qvideoframe/BLACKLIST b/tests/auto/unit/qvideoframe/BLACKLIST new file mode 100644 index 000000000..1fa752da5 --- /dev/null +++ b/tests/auto/unit/qvideoframe/BLACKLIST @@ -0,0 +1,2 @@ +[image:64x64 AYUV444,64x64 YUV444,64x64 YUV420P,64x64 YV12,64x64 UYVY,64x64 YUYV,64x64 NV12,64x64 NV21] +windows-10 ci diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp index 6be039108..de9295c33 100644 --- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp @@ -85,6 +85,9 @@ private slots: void isMapped(); void isReadable(); void isWritable(); + + void image_data(); + void image(); }; Q_DECLARE_METATYPE(QImage::Format) @@ -1128,6 +1131,172 @@ void tst_QVideoFrame::isWritable() frame.unmap(); } +void tst_QVideoFrame::image_data() +{ + QTest::addColumn<QSize>("size"); + QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat"); + QTest::addColumn<int>("bytes"); + QTest::addColumn<int>("bytesPerLine"); + QTest::addColumn<QImage::Format>("imageFormat"); + + QTest::newRow("64x64 ARGB32") + << QSize(64, 64) + << QVideoFrame::Format_ARGB32 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 ARGB32_Premultiplied") + << QSize(64, 64) + << QVideoFrame::Format_ARGB32_Premultiplied + << 16384 + << 256 + << QImage::Format_ARGB32_Premultiplied; + + QTest::newRow("64x64 RGB32") + << QSize(64, 64) + << QVideoFrame::Format_RGB32 + << 16384 + << 256 + << QImage::Format_RGB32; + + QTest::newRow("64x64 RGB24") + << QSize(64, 64) + << QVideoFrame::Format_RGB24 + << 16384 + << 192 + << QImage::Format_RGB888; + + QTest::newRow("64x64 RGB565") + << QSize(64, 64) + << QVideoFrame::Format_RGB565 + << 16384 + << 128 + << QImage::Format_RGB16; + + QTest::newRow("64x64 RGB555") + << QSize(64, 64) + << QVideoFrame::Format_RGB555 + << 16384 + << 128 + << QImage::Format_RGB555; + + QTest::newRow("64x64 BGRA32") + << QSize(64, 64) + << QVideoFrame::Format_BGRA32 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 BGRA32_Premultiplied") + << QSize(64, 64) + << QVideoFrame::Format_BGRA32_Premultiplied + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 BGR32") + << QSize(64, 64) + << QVideoFrame::Format_BGR32 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 BGR24") + << QSize(64, 64) + << QVideoFrame::Format_BGR24 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 BGR565") + << QSize(64, 64) + << QVideoFrame::Format_BGR565 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 BGR555") + << QSize(64, 64) + << QVideoFrame::Format_BGR555 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 AYUV444") + << QSize(64, 64) + << QVideoFrame::Format_AYUV444 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 YUV444") + << QSize(64, 64) + << QVideoFrame::Format_YUV444 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 YUV420P") + << QSize(64, 64) + << QVideoFrame::Format_YUV420P + << 13288 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 YV12") + << QSize(64, 64) + << QVideoFrame::Format_YV12 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 UYVY") + << QSize(64, 64) + << QVideoFrame::Format_UYVY + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 YUYV") + << QSize(64, 64) + << QVideoFrame::Format_YUYV + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 NV12") + << QSize(64, 64) + << QVideoFrame::Format_NV12 + << 16384 + << 256 + << QImage::Format_ARGB32; + + QTest::newRow("64x64 NV21") + << QSize(64, 64) + << QVideoFrame::Format_NV21 + << 16384 + << 256 + << QImage::Format_ARGB32; +} + +void tst_QVideoFrame::image() +{ + QFETCH(QSize, size); + QFETCH(QVideoFrame::PixelFormat, pixelFormat); + QFETCH(int, bytes); + QFETCH(int, bytesPerLine); + QFETCH(QImage::Format, imageFormat); + + QVideoFrame frame(bytes, size, bytesPerLine, pixelFormat); + QImage img = frame.image(); + + QVERIFY(!img.isNull()); + QCOMPARE(img.format(), imageFormat); + QCOMPARE(img.size(), size); + QCOMPARE(img.bytesPerLine(), bytesPerLine); +} + QTEST_MAIN(tst_QVideoFrame) #include "tst_qvideoframe.moc" |