summaryrefslogtreecommitdiffstats
path: root/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
diff options
context:
space:
mode:
authorVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-10-11 11:51:14 +0200
committerVaL Doroshchuk <valentyn.doroshchuk@qt.io>2019-10-31 09:49:49 +0100
commit59d0683c999bec5612f6ba91867bde4d02185204 (patch)
treea8bcd49d8044d2b9a76699137ad763a11a5464bb /tests/auto/unit/qvideoframe/tst_qvideoframe.cpp
parent71e2096c2b704420cbb0ee836c16565b658b3d0f (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/auto/unit/qvideoframe/tst_qvideoframe.cpp')
-rw-r--r--tests/auto/unit/qvideoframe/tst_qvideoframe.cpp169
1 files changed, 169 insertions, 0 deletions
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"