tests/auto/qvideoframe/tst_qvideoframe.cpp
changeset 33 3e2da88830cd
parent 18 2f34d5167611
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    77     void map_data();
    77     void map_data();
    78     void map();
    78     void map();
    79     void mapImage_data();
    79     void mapImage_data();
    80     void mapImage();
    80     void mapImage();
    81     void imageDetach();
    81     void imageDetach();
       
    82     void formatConversion_data();
       
    83     void formatConversion();
    82 };
    84 };
    83 
    85 
    84 Q_DECLARE_METATYPE(QImage::Format)
    86 Q_DECLARE_METATYPE(QImage::Format)
    85 Q_DECLARE_METATYPE(QVideoFrame)
    87 Q_DECLARE_METATYPE(QVideoFrame)
    86 
    88 
   656 
   658 
   657     // Original image has detached and is therefore unchanged.
   659     // Original image has detached and is therefore unchanged.
   658     QCOMPARE(image.pixel(4, 4), red);
   660     QCOMPARE(image.pixel(4, 4), red);
   659 }
   661 }
   660 
   662 
       
   663 void tst_QVideoFrame::formatConversion_data()
       
   664 {
       
   665     QTest::addColumn<QImage::Format>("imageFormat");
       
   666     QTest::addColumn<QVideoFrame::PixelFormat>("pixelFormat");
       
   667 
       
   668     QTest::newRow("QImage::Format_RGB32 | QVideoFrame::Format_RGB32")
       
   669             << QImage::Format_RGB32
       
   670             << QVideoFrame::Format_RGB32;
       
   671     QTest::newRow("QImage::Format_ARGB32 | QVideoFrame::Format_ARGB32")
       
   672             << QImage::Format_ARGB32
       
   673             << QVideoFrame::Format_ARGB32;
       
   674     QTest::newRow("QImage::Format_ARGB32_Premultiplied | QVideoFrame::Format_ARGB32_Premultiplied")
       
   675             << QImage::Format_ARGB32_Premultiplied
       
   676             << QVideoFrame::Format_ARGB32_Premultiplied;
       
   677     QTest::newRow("QImage::Format_RGB16 | QVideoFrame::Format_RGB565")
       
   678             << QImage::Format_RGB16
       
   679             << QVideoFrame::Format_RGB565;
       
   680     QTest::newRow("QImage::Format_ARGB8565_Premultiplied | QVideoFrame::Format_ARGB8565_Premultiplied")
       
   681             << QImage::Format_ARGB8565_Premultiplied
       
   682             << QVideoFrame::Format_ARGB8565_Premultiplied;
       
   683     QTest::newRow("QImage::Format_RGB555 | QVideoFrame::Format_RGB555")
       
   684             << QImage::Format_RGB555
       
   685             << QVideoFrame::Format_RGB555;
       
   686     QTest::newRow("QImage::Format_RGB888 | QVideoFrame::Format_RGB24")
       
   687             << QImage::Format_RGB888
       
   688             << QVideoFrame::Format_RGB24;
       
   689 
       
   690     QTest::newRow("QImage::Format_MonoLSB")
       
   691             << QImage::Format_MonoLSB
       
   692             << QVideoFrame::Format_Invalid;
       
   693     QTest::newRow("QImage::Format_Indexed8")
       
   694             << QImage::Format_Indexed8
       
   695             << QVideoFrame::Format_Invalid;
       
   696     QTest::newRow("QImage::Format_ARGB6666_Premultiplied")
       
   697             << QImage::Format_ARGB6666_Premultiplied
       
   698             << QVideoFrame::Format_Invalid;
       
   699     QTest::newRow("QImage::Format_ARGB8555_Premultiplied")
       
   700             << QImage::Format_ARGB8555_Premultiplied
       
   701             << QVideoFrame::Format_Invalid;
       
   702     QTest::newRow("QImage::Format_RGB666")
       
   703             << QImage::Format_RGB666
       
   704             << QVideoFrame::Format_Invalid;
       
   705     QTest::newRow("QImage::Format_RGB444")
       
   706             << QImage::Format_RGB444
       
   707             << QVideoFrame::Format_Invalid;
       
   708     QTest::newRow("QImage::Format_ARGB4444_Premultiplied")
       
   709             << QImage::Format_ARGB4444_Premultiplied
       
   710             << QVideoFrame::Format_Invalid;
       
   711 
       
   712     QTest::newRow("QVideoFrame::Format_BGRA32")
       
   713             << QImage::Format_Invalid
       
   714             << QVideoFrame::Format_BGRA32;
       
   715     QTest::newRow("QVideoFrame::Format_BGRA32_Premultiplied")
       
   716             << QImage::Format_Invalid
       
   717             << QVideoFrame::Format_BGRA32_Premultiplied;
       
   718     QTest::newRow("QVideoFrame::Format_BGR32")
       
   719             << QImage::Format_Invalid
       
   720             << QVideoFrame::Format_BGR32;
       
   721     QTest::newRow("QVideoFrame::Format_BGR24")
       
   722             << QImage::Format_Invalid
       
   723             << QVideoFrame::Format_BGR24;
       
   724     QTest::newRow("QVideoFrame::Format_BGR565")
       
   725             << QImage::Format_Invalid
       
   726             << QVideoFrame::Format_BGR565;
       
   727     QTest::newRow("QVideoFrame::Format_BGR555")
       
   728             << QImage::Format_Invalid
       
   729             << QVideoFrame::Format_BGR555;
       
   730     QTest::newRow("QVideoFrame::Format_BGRA5658_Premultiplied")
       
   731             << QImage::Format_Invalid
       
   732             << QVideoFrame::Format_BGRA5658_Premultiplied;
       
   733     QTest::newRow("QVideoFrame::Format_AYUV444")
       
   734             << QImage::Format_Invalid
       
   735             << QVideoFrame::Format_AYUV444;
       
   736     QTest::newRow("QVideoFrame::Format_AYUV444_Premultiplied")
       
   737             << QImage::Format_Invalid
       
   738             << QVideoFrame::Format_AYUV444_Premultiplied;
       
   739     QTest::newRow("QVideoFrame::Format_YUV444")
       
   740             << QImage::Format_Invalid
       
   741             << QVideoFrame::Format_YUV420P;
       
   742     QTest::newRow("QVideoFrame::Format_YV12")
       
   743             << QImage::Format_Invalid
       
   744             << QVideoFrame::Format_YV12;
       
   745     QTest::newRow("QVideoFrame::Format_UYVY")
       
   746             << QImage::Format_Invalid
       
   747             << QVideoFrame::Format_UYVY;
       
   748     QTest::newRow("QVideoFrame::Format_YUYV")
       
   749             << QImage::Format_Invalid
       
   750             << QVideoFrame::Format_YUYV;
       
   751     QTest::newRow("QVideoFrame::Format_NV12")
       
   752             << QImage::Format_Invalid
       
   753             << QVideoFrame::Format_NV12;
       
   754     QTest::newRow("QVideoFrame::Format_NV21")
       
   755             << QImage::Format_Invalid
       
   756             << QVideoFrame::Format_NV21;
       
   757     QTest::newRow("QVideoFrame::Format_IMC1")
       
   758             << QImage::Format_Invalid
       
   759             << QVideoFrame::Format_IMC1;
       
   760     QTest::newRow("QVideoFrame::Format_IMC2")
       
   761             << QImage::Format_Invalid
       
   762             << QVideoFrame::Format_IMC2;
       
   763     QTest::newRow("QVideoFrame::Format_IMC3")
       
   764             << QImage::Format_Invalid
       
   765             << QVideoFrame::Format_IMC3;
       
   766     QTest::newRow("QVideoFrame::Format_IMC4")
       
   767             << QImage::Format_Invalid
       
   768             << QVideoFrame::Format_IMC4;
       
   769     QTest::newRow("QVideoFrame::Format_Y8")
       
   770             << QImage::Format_Invalid
       
   771             << QVideoFrame::Format_Y8;
       
   772     QTest::newRow("QVideoFrame::Format_Y16")
       
   773             << QImage::Format_Invalid
       
   774             << QVideoFrame::Format_Y16;
       
   775 }
       
   776 
       
   777 void tst_QVideoFrame::formatConversion()
       
   778 {
       
   779     QFETCH(QImage::Format, imageFormat);
       
   780     QFETCH(QVideoFrame::PixelFormat, pixelFormat);
       
   781 
       
   782     QCOMPARE(QVideoFrame::pixelFormatFromImageFormat(imageFormat) == pixelFormat,
       
   783               imageFormat != QImage::Format_Invalid);
       
   784 
       
   785     QCOMPARE(QVideoFrame::imageFormatFromPixelFormat(pixelFormat) == imageFormat,
       
   786              pixelFormat != QVideoFrame::Format_Invalid);
       
   787 }
       
   788 
   661 QTEST_MAIN(tst_QVideoFrame)
   789 QTEST_MAIN(tst_QVideoFrame)
   662 
   790 
   663 #include "tst_qvideoframe.moc"
   791 #include "tst_qvideoframe.moc"