1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#include <QtTest>
#include <video/yuv/PixelFormatYUV.h>
using namespace video::yuv;
class PixelFormatYUVTest : public QObject
{
Q_OBJECT
public:
PixelFormatYUVTest(){};
~PixelFormatYUVTest(){};
private slots:
void testFormatFromToString();
};
std::vector<PixelFormatYUV> getAllFormats()
{
std::vector<PixelFormatYUV> allFormats;
for (auto subsampling : SubsamplingMapper.getEnums())
{
for (auto bitsPerSample : BitDepthList)
{
auto endianList =
(bitsPerSample > 8) ? std::vector<bool>({false, true}) : std::vector<bool>({false});
// Planar
for (auto planeOrder : PlaneOrderMapper.getEnums())
{
for (auto bigEndian : endianList)
{
auto pixelFormat = PixelFormatYUV(subsampling, bitsPerSample, planeOrder, bigEndian);
allFormats.push_back(pixelFormat);
}
}
// Packet
for (auto packingOrder : getSupportedPackingFormats(subsampling))
{
for (auto bytePacking : {false, true})
{
for (auto bigEndian : endianList)
{
auto pixelFormat =
PixelFormatYUV(subsampling, bitsPerSample, packingOrder, bytePacking, bigEndian);
allFormats.push_back(pixelFormat);
}
}
}
}
}
for (auto predefinedFormat : PredefinedPixelFormatMapper.getEnums())
allFormats.push_back(PixelFormatYUV(predefinedFormat));
return allFormats;
}
void PixelFormatYUVTest::testFormatFromToString()
{
for (auto fmt : getAllFormats())
{
QVERIFY(fmt.isValid());
auto name = fmt.getName();
if (name.empty())
{
QFAIL("Name empty");
}
auto fmtNew = PixelFormatYUV(name);
if (fmt != fmtNew)
{
auto errorStr = "Comparison failed. Names: " + name;
QFAIL(errorStr.c_str());
}
if (fmt.getSubsampling() != fmtNew.getSubsampling() ||
fmt.getBitsPerSample() != fmtNew.getBitsPerSample() ||
fmt.isPlanar() != fmtNew.isPlanar() || fmt.getChromaOffset() != fmtNew.getChromaOffset() ||
fmt.getPlaneOrder() != fmtNew.getPlaneOrder() ||
fmt.isUVInterleaved() != fmtNew.isUVInterleaved() ||
fmt.getPackingOrder() != fmtNew.getPackingOrder() ||
fmt.isBytePacking() != fmtNew.isBytePacking())
{
auto errorStr = "Comparison of parameters failed. Names: " + name;
QFAIL(errorStr.c_str());
}
if (fmt.getBitsPerSample() > 8 && fmt.isBigEndian() != fmtNew.isBigEndian())
{
auto errorStr = "Comparison of parameters failed. Endianness wrong. Names: " + name;
QFAIL(errorStr.c_str());
}
}
}
QTEST_MAIN(PixelFormatYUVTest)
#include "PixelFormatYUVTest.moc"
|