Improve video test coverage and debugging output.
Added a few debug operators for some useful enums, and added tests for them. One or two other features not really tested. Change-Id: Idffec6ade1d4e05dbf72f3dc47dfc0d01ddddf8b Reviewed-on: http://codereview.qt-project.org/6201 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
03f22bcdaf
commit
adca03adfd
@@ -43,6 +43,9 @@
|
|||||||
|
|
||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -198,5 +201,24 @@ QVariant QAbstractVideoBuffer::handle() const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
QDebug operator<<(QDebug dbg, QAbstractVideoBuffer::HandleType type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case QAbstractVideoBuffer::NoHandle:
|
||||||
|
return dbg.nospace() << "NoHandle";
|
||||||
|
case QAbstractVideoBuffer::GLTextureHandle:
|
||||||
|
return dbg.nospace() << "GLTextureHandle";
|
||||||
|
case QAbstractVideoBuffer::XvShmImageHandle:
|
||||||
|
return dbg.nospace() << "XvShmImageHandle";
|
||||||
|
case QAbstractVideoBuffer::CoreImageHandle:
|
||||||
|
return dbg.nospace() << "CoreImageHandle";
|
||||||
|
case QAbstractVideoBuffer::QPixmapHandle:
|
||||||
|
return dbg.nospace() << "QPixmapHandle";
|
||||||
|
default:
|
||||||
|
return dbg.nospace() << QString(QLatin1String("UserHandle(%1)")).arg(int(type)).toAscii().constData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ private:
|
|||||||
Q_DISABLE_COPY(QAbstractVideoBuffer)
|
Q_DISABLE_COPY(QAbstractVideoBuffer)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QAbstractVideoBuffer::HandleType);
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QAbstractVideoBuffer::HandleType)
|
Q_DECLARE_METATYPE(QAbstractVideoBuffer::HandleType)
|
||||||
|
|||||||
@@ -50,6 +50,8 @@
|
|||||||
#include <qvariant.h>
|
#include <qvariant.h>
|
||||||
#include <qvector.h>
|
#include <qvector.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -682,11 +684,6 @@ void QVideoFrame::setEndTime(qint64 time)
|
|||||||
QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format)
|
QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case QImage::Format_Invalid:
|
|
||||||
case QImage::Format_Mono:
|
|
||||||
case QImage::Format_MonoLSB:
|
|
||||||
case QImage::Format_Indexed8:
|
|
||||||
return Format_Invalid;
|
|
||||||
case QImage::Format_RGB32:
|
case QImage::Format_RGB32:
|
||||||
return Format_RGB32;
|
return Format_RGB32;
|
||||||
case QImage::Format_ARGB32:
|
case QImage::Format_ARGB32:
|
||||||
@@ -697,22 +694,13 @@ QVideoFrame::PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format
|
|||||||
return Format_RGB565;
|
return Format_RGB565;
|
||||||
case QImage::Format_ARGB8565_Premultiplied:
|
case QImage::Format_ARGB8565_Premultiplied:
|
||||||
return Format_ARGB8565_Premultiplied;
|
return Format_ARGB8565_Premultiplied;
|
||||||
case QImage::Format_RGB666:
|
|
||||||
case QImage::Format_ARGB6666_Premultiplied:
|
|
||||||
return Format_Invalid;
|
|
||||||
case QImage::Format_RGB555:
|
case QImage::Format_RGB555:
|
||||||
return Format_RGB555;
|
return Format_RGB555;
|
||||||
case QImage::Format_ARGB8555_Premultiplied:
|
|
||||||
return Format_Invalid;
|
|
||||||
case QImage::Format_RGB888:
|
case QImage::Format_RGB888:
|
||||||
return Format_RGB24;
|
return Format_RGB24;
|
||||||
case QImage::Format_RGB444:
|
default:
|
||||||
case QImage::Format_ARGB4444_Premultiplied:
|
|
||||||
return Format_Invalid;
|
|
||||||
case QImage::NImageFormats:
|
|
||||||
return Format_Invalid;
|
return Format_Invalid;
|
||||||
}
|
}
|
||||||
return Format_Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -772,5 +760,84 @@ QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format)
|
|||||||
return QImage::Format_Invalid;
|
return QImage::Format_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, QVideoFrame::PixelFormat pf)
|
||||||
|
{
|
||||||
|
switch (pf) {
|
||||||
|
case QVideoFrame::Format_Invalid:
|
||||||
|
return dbg.nospace() << "Format_Invalid";
|
||||||
|
case QVideoFrame::Format_ARGB32:
|
||||||
|
return dbg.nospace() << "Format_ARGB32";
|
||||||
|
case QVideoFrame::Format_ARGB32_Premultiplied:
|
||||||
|
return dbg.nospace() << "Format_ARGB32_Premultiplied";
|
||||||
|
case QVideoFrame::Format_RGB32:
|
||||||
|
return dbg.nospace() << "Format_RGB32";
|
||||||
|
case QVideoFrame::Format_RGB24:
|
||||||
|
return dbg.nospace() << "Format_RGB24";
|
||||||
|
case QVideoFrame::Format_RGB565:
|
||||||
|
return dbg.nospace() << "Format_RGB565";
|
||||||
|
case QVideoFrame::Format_RGB555:
|
||||||
|
return dbg.nospace() << "Format_RGB555";
|
||||||
|
case QVideoFrame::Format_ARGB8565_Premultiplied:
|
||||||
|
return dbg.nospace() << "Format_ARGB8565_Premultiplied";
|
||||||
|
case QVideoFrame::Format_BGRA32:
|
||||||
|
return dbg.nospace() << "Format_BGRA32";
|
||||||
|
case QVideoFrame::Format_BGRA32_Premultiplied:
|
||||||
|
return dbg.nospace() << "Format_BGRA32_Premultiplied";
|
||||||
|
case QVideoFrame::Format_BGR32:
|
||||||
|
return dbg.nospace() << "Format_BGR32";
|
||||||
|
case QVideoFrame::Format_BGR24:
|
||||||
|
return dbg.nospace() << "Format_BGR24";
|
||||||
|
case QVideoFrame::Format_BGR565:
|
||||||
|
return dbg.nospace() << "Format_BGR565";
|
||||||
|
case QVideoFrame::Format_BGR555:
|
||||||
|
return dbg.nospace() << "Format_BGR555";
|
||||||
|
case QVideoFrame::Format_BGRA5658_Premultiplied:
|
||||||
|
return dbg.nospace() << "Format_BGRA5658_Premultiplied";
|
||||||
|
case QVideoFrame::Format_AYUV444:
|
||||||
|
return dbg.nospace() << "Format_AYUV444";
|
||||||
|
case QVideoFrame::Format_AYUV444_Premultiplied:
|
||||||
|
return dbg.nospace() << "Format_AYUV444_Premultiplied";
|
||||||
|
case QVideoFrame::Format_YUV444:
|
||||||
|
return dbg.nospace() << "Format_YUV444";
|
||||||
|
case QVideoFrame::Format_YUV420P:
|
||||||
|
return dbg.nospace() << "Format_YUV420P";
|
||||||
|
case QVideoFrame::Format_YV12:
|
||||||
|
return dbg.nospace() << "Format_YV12";
|
||||||
|
case QVideoFrame::Format_UYVY:
|
||||||
|
return dbg.nospace() << "Format_UYVY";
|
||||||
|
case QVideoFrame::Format_YUYV:
|
||||||
|
return dbg.nospace() << "Format_YUYV";
|
||||||
|
case QVideoFrame::Format_NV12:
|
||||||
|
return dbg.nospace() << "Format_NV12";
|
||||||
|
case QVideoFrame::Format_NV21:
|
||||||
|
return dbg.nospace() << "Format_NV21";
|
||||||
|
case QVideoFrame::Format_IMC1:
|
||||||
|
return dbg.nospace() << "Format_IMC1";
|
||||||
|
case QVideoFrame::Format_IMC2:
|
||||||
|
return dbg.nospace() << "Format_IMC2";
|
||||||
|
case QVideoFrame::Format_IMC3:
|
||||||
|
return dbg.nospace() << "Format_IMC3";
|
||||||
|
case QVideoFrame::Format_IMC4:
|
||||||
|
return dbg.nospace() << "Format_IMC4";
|
||||||
|
case QVideoFrame::Format_Y8:
|
||||||
|
return dbg.nospace() << "Format_Y8";
|
||||||
|
case QVideoFrame::Format_Y16:
|
||||||
|
return dbg.nospace() << "Format_Y16";
|
||||||
|
case QVideoFrame::Format_Jpeg:
|
||||||
|
return dbg.nospace() << "Format_Jpeg";
|
||||||
|
case QVideoFrame::Format_AdobeDng:
|
||||||
|
return dbg.nospace() << "Format_AdobeDng";
|
||||||
|
case QVideoFrame::Format_CameraRaw:
|
||||||
|
return dbg.nospace() << "Format_CameraRaw";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return dbg.nospace() << QString(QLatin1String("UserType(%1)" )).arg(int(pf)).toAscii().constData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ private:
|
|||||||
QExplicitlySharedDataPointer<QVideoFramePrivate> d;
|
QExplicitlySharedDataPointer<QVideoFramePrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::PixelFormat );
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QVideoFrame::FieldType)
|
Q_DECLARE_METATYPE(QVideoFrame::FieldType)
|
||||||
|
|||||||
@@ -504,8 +504,6 @@ QVariant QVideoSurfaceFormat::property(const char *name) const
|
|||||||
return qVariantFromValue(d->handleType);
|
return qVariantFromValue(d->handleType);
|
||||||
} else if (qstrcmp(name, "pixelFormat") == 0) {
|
} else if (qstrcmp(name, "pixelFormat") == 0) {
|
||||||
return qVariantFromValue(d->pixelFormat);
|
return qVariantFromValue(d->pixelFormat);
|
||||||
} else if (qstrcmp(name, "handleType") == 0) {
|
|
||||||
return qVariantFromValue(d->handleType);
|
|
||||||
} else if (qstrcmp(name, "frameSize") == 0) {
|
} else if (qstrcmp(name, "frameSize") == 0) {
|
||||||
return d->frameSize;
|
return d->frameSize;
|
||||||
} else if (qstrcmp(name, "frameWidth") == 0) {
|
} else if (qstrcmp(name, "frameWidth") == 0) {
|
||||||
@@ -593,108 +591,35 @@ void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value)
|
|||||||
|
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, QVideoSurfaceFormat::YCbCrColorSpace cs)
|
||||||
|
{
|
||||||
|
switch (cs) {
|
||||||
|
case QVideoSurfaceFormat::YCbCr_BT601:
|
||||||
|
return dbg.nospace() << "YCbCr_BT601";
|
||||||
|
case QVideoSurfaceFormat::YCbCr_BT709:
|
||||||
|
return dbg.nospace() << "YCbCr_BT709";
|
||||||
|
case QVideoSurfaceFormat::YCbCr_JPEG:
|
||||||
|
return dbg.nospace() << "YCbCr_JPEG";
|
||||||
|
case QVideoSurfaceFormat::YCbCr_xvYCC601:
|
||||||
|
return dbg.nospace() << "YCbCr_xvYCC601";
|
||||||
|
case QVideoSurfaceFormat::YCbCr_xvYCC709:
|
||||||
|
return dbg.nospace() << "YCbCr_xvYCC709";
|
||||||
|
case QVideoSurfaceFormat::YCbCr_CustomMatrix:
|
||||||
|
return dbg.nospace() << "YCbCr_CustomMatrix";
|
||||||
|
default:
|
||||||
|
return dbg.nospace() << "YCbCr_Undefined";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f)
|
QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f)
|
||||||
{
|
{
|
||||||
QString typeName;
|
dbg.nospace() << "QVideoSurfaceFormat(" << f.pixelFormat();
|
||||||
switch (f.pixelFormat()) {
|
|
||||||
case QVideoFrame::Format_Invalid:
|
|
||||||
typeName = QLatin1String("Format_Invalid");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_ARGB32:
|
|
||||||
typeName = QLatin1String("Format_ARGB32");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_ARGB32_Premultiplied:
|
|
||||||
typeName = QLatin1String("Format_ARGB32_Premultiplied");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_RGB32:
|
|
||||||
typeName = QLatin1String("Format_RGB32");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_RGB24:
|
|
||||||
typeName = QLatin1String("Format_RGB24");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_RGB565:
|
|
||||||
typeName = QLatin1String("Format_RGB565");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_RGB555:
|
|
||||||
typeName = QLatin1String("Format_RGB555");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_ARGB8565_Premultiplied:
|
|
||||||
typeName = QLatin1String("Format_ARGB8565_Premultiplied");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGRA32:
|
|
||||||
typeName = QLatin1String("Format_BGRA32");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGRA32_Premultiplied:
|
|
||||||
typeName = QLatin1String("Format_BGRA32_Premultiplied");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGR32:
|
|
||||||
typeName = QLatin1String("Format_BGR32");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGR24:
|
|
||||||
typeName = QLatin1String("Format_BGR24");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGR565:
|
|
||||||
typeName = QLatin1String("Format_BGR565");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGR555:
|
|
||||||
typeName = QLatin1String("Format_BGR555");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_BGRA5658_Premultiplied:
|
|
||||||
typeName = QLatin1String("Format_BGRA5658_Premultiplied");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_AYUV444:
|
|
||||||
typeName = QLatin1String("Format_AYUV444");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_AYUV444_Premultiplied:
|
|
||||||
typeName = QLatin1String("Format_AYUV444_Premultiplied");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_YUV444:
|
|
||||||
typeName = QLatin1String("Format_YUV444");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_YUV420P:
|
|
||||||
typeName = QLatin1String("Format_YUV420P");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_YV12:
|
|
||||||
typeName = QLatin1String("Format_YV12");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_UYVY:
|
|
||||||
typeName = QLatin1String("Format_UYVY");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_YUYV:
|
|
||||||
typeName = QLatin1String("Format_YUYV");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_NV12:
|
|
||||||
typeName = QLatin1String("Format_NV12");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_NV21:
|
|
||||||
typeName = QLatin1String("Format_NV21");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_IMC1:
|
|
||||||
typeName = QLatin1String("Format_IMC1");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_IMC2:
|
|
||||||
typeName = QLatin1String("Format_IMC2");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_IMC3:
|
|
||||||
typeName = QLatin1String("Format_IMC3");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_IMC4:
|
|
||||||
typeName = QLatin1String("Format_IMC4");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_Y8:
|
|
||||||
typeName = QLatin1String("Format_Y8");
|
|
||||||
break;
|
|
||||||
case QVideoFrame::Format_Y16:
|
|
||||||
typeName = QLatin1String("Format_Y16");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
typeName = QString(QLatin1String("UserType(%1)" )).arg(int(f.pixelFormat()));
|
|
||||||
}
|
|
||||||
|
|
||||||
dbg.nospace() << "QVideoSurfaceFormat(" << typeName;
|
|
||||||
dbg.nospace() << ", " << f.frameSize();
|
dbg.nospace() << ", " << f.frameSize();
|
||||||
dbg.nospace() << ", viewport=" << f.viewport();
|
dbg.nospace() << ", viewport=" << f.viewport();
|
||||||
dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio();
|
dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio();
|
||||||
|
dbg.nospace() << ", handleType=" << f.handleType();
|
||||||
|
dbg.nospace() << ", yCbCrColorSpace=" << f.yCbCrColorSpace();
|
||||||
dbg.nospace() << ")";
|
dbg.nospace() << ")";
|
||||||
|
|
||||||
foreach(const QByteArray& propertyName, f.propertyNames())
|
foreach(const QByteArray& propertyName, f.propertyNames())
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ private:
|
|||||||
|
|
||||||
#ifndef QT_NO_DEBUG_STREAM
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &);
|
Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &);
|
||||||
|
Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoSurfaceFormat::YCbCrColorSpace);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -100,33 +100,41 @@ void tst_QAbstractVideoBuffer::cleanup()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ADD_HANDLE_TEST(x) \
|
||||||
|
QTest::newRow(#x) \
|
||||||
|
<< QAbstractVideoBuffer::x \
|
||||||
|
<< QString(QLatin1String(#x));
|
||||||
|
|
||||||
void tst_QAbstractVideoBuffer::handleType_data()
|
void tst_QAbstractVideoBuffer::handleType_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QAbstractVideoBuffer::HandleType>("type");
|
QTest::addColumn<QAbstractVideoBuffer::HandleType>("type");
|
||||||
|
QTest::addColumn<QString>("stringized");
|
||||||
|
|
||||||
|
ADD_HANDLE_TEST(NoHandle);
|
||||||
|
ADD_HANDLE_TEST(GLTextureHandle);
|
||||||
|
ADD_HANDLE_TEST(XvShmImageHandle);
|
||||||
|
ADD_HANDLE_TEST(QPixmapHandle);
|
||||||
|
ADD_HANDLE_TEST(CoreImageHandle);
|
||||||
|
|
||||||
|
// User handles are different
|
||||||
|
|
||||||
QTest::newRow("none")
|
|
||||||
<< QAbstractVideoBuffer::NoHandle;
|
|
||||||
QTest::newRow("opengl")
|
|
||||||
<< QAbstractVideoBuffer::GLTextureHandle;
|
|
||||||
QTest::newRow("XvShmImageHandle")
|
|
||||||
<< QAbstractVideoBuffer::XvShmImageHandle;
|
|
||||||
QTest::newRow("CoreImageHandle")
|
|
||||||
<< QAbstractVideoBuffer::CoreImageHandle;
|
|
||||||
QTest::newRow("QPixmapHandle")
|
|
||||||
<< QAbstractVideoBuffer::QPixmapHandle;
|
|
||||||
QTest::newRow("user1")
|
QTest::newRow("user1")
|
||||||
<< QAbstractVideoBuffer::UserHandle;
|
<< QAbstractVideoBuffer::UserHandle << QString::fromAscii("UserHandle(1000)");
|
||||||
QTest::newRow("user2")
|
QTest::newRow("user2")
|
||||||
<< QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle + 1);
|
<< QAbstractVideoBuffer::HandleType(QAbstractVideoBuffer::UserHandle + 1) << QString::fromAscii("UserHandle(1001)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAbstractVideoBuffer::handleType()
|
void tst_QAbstractVideoBuffer::handleType()
|
||||||
{
|
{
|
||||||
QFETCH(QAbstractVideoBuffer::HandleType, type);
|
QFETCH(QAbstractVideoBuffer::HandleType, type);
|
||||||
|
QFETCH(QString, stringized);
|
||||||
|
|
||||||
QtTestVideoBuffer buffer(type);
|
QtTestVideoBuffer buffer(type);
|
||||||
|
|
||||||
QCOMPARE(buffer.handleType(), type);
|
QCOMPARE(buffer.handleType(), type);
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||||
|
qDebug() << type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAbstractVideoBuffer::handle()
|
void tst_QAbstractVideoBuffer::handle()
|
||||||
|
|||||||
@@ -314,6 +314,12 @@ void tst_QAbstractVideoSurface::start()
|
|||||||
QCOMPARE(activeSpy.count(), 1);
|
QCOMPARE(activeSpy.count(), 1);
|
||||||
QCOMPARE(activeSpy.last().at(0).toBool(), true);
|
QCOMPARE(activeSpy.last().at(0).toBool(), true);
|
||||||
|
|
||||||
|
// Starting twice won't change active
|
||||||
|
// XXX should this also not emit surfaceFormatChanged?
|
||||||
|
QVERIFY(surface.start(format));
|
||||||
|
QCOMPARE(activeSpy.count(), 1);
|
||||||
|
QVERIFY(surface.isActive());
|
||||||
|
|
||||||
// error() is reset on a successful start.
|
// error() is reset on a successful start.
|
||||||
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
QCOMPARE(surface.error(), QAbstractVideoSurface::NoError);
|
||||||
|
|
||||||
@@ -322,7 +328,19 @@ void tst_QAbstractVideoSurface::start()
|
|||||||
QVERIFY(!surface.isActive());
|
QVERIFY(!surface.isActive());
|
||||||
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||||
|
|
||||||
QCOMPARE(formatSpy.count(), 2);
|
QCOMPARE(formatSpy.count(), 3);
|
||||||
|
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
|
||||||
|
|
||||||
|
QCOMPARE(activeSpy.count(), 2);
|
||||||
|
QCOMPARE(activeSpy.last().at(0).toBool(), false);
|
||||||
|
|
||||||
|
// Stopping a stopped surface shouldn't hurt
|
||||||
|
surface.stop();
|
||||||
|
|
||||||
|
QVERIFY(!surface.isActive());
|
||||||
|
QCOMPARE(surface.surfaceFormat(), QVideoSurfaceFormat());
|
||||||
|
|
||||||
|
QCOMPARE(formatSpy.count(), 3);
|
||||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
|
QCOMPARE(qvariant_cast<QVideoSurfaceFormat>(formatSpy.last().at(0)), QVideoSurfaceFormat());
|
||||||
|
|
||||||
QCOMPARE(activeSpy.count(), 2);
|
QCOMPARE(activeSpy.count(), 2);
|
||||||
@@ -346,6 +364,15 @@ void tst_QAbstractVideoSurface::nativeResolution()
|
|||||||
QSize size2 = qvariant_cast<QSize>(spy.at(0).at(0));
|
QSize size2 = qvariant_cast<QSize>(spy.at(0).at(0));
|
||||||
QVERIFY(size2.width() == 100);
|
QVERIFY(size2.width() == 100);
|
||||||
QVERIFY(size2.height() == 150);
|
QVERIFY(size2.height() == 150);
|
||||||
|
|
||||||
|
// Setting again should not emit
|
||||||
|
surface.setNativeResolution(res);
|
||||||
|
QVERIFY(spy.count() == 1);
|
||||||
|
|
||||||
|
size2 = qvariant_cast<QSize>(spy.at(0).at(0));
|
||||||
|
QVERIFY(size2.width() == 100);
|
||||||
|
QVERIFY(size2.height() == 150);
|
||||||
|
|
||||||
spy.clear();
|
spy.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ void tst_QVideoFrame::create()
|
|||||||
|
|
||||||
QVERIFY(frame.isValid());
|
QVERIFY(frame.isValid());
|
||||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||||
|
QCOMPARE(frame.handle(), QVariant());
|
||||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||||
QCOMPARE(frame.size(), size);
|
QCOMPARE(frame.size(), size);
|
||||||
QCOMPARE(frame.width(), size.width());
|
QCOMPARE(frame.width(), size.width());
|
||||||
@@ -200,6 +201,7 @@ void tst_QVideoFrame::createInvalid()
|
|||||||
|
|
||||||
QVERIFY(!frame.isValid());
|
QVERIFY(!frame.isValid());
|
||||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||||
|
QCOMPARE(frame.handle(), QVariant());
|
||||||
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
QCOMPARE(frame.pixelFormat(), pixelFormat);
|
||||||
QCOMPARE(frame.size(), size);
|
QCOMPARE(frame.size(), size);
|
||||||
QCOMPARE(frame.width(), size.width());
|
QCOMPARE(frame.width(), size.width());
|
||||||
@@ -308,17 +310,50 @@ void tst_QVideoFrame::createFromIncompatibleImage()
|
|||||||
|
|
||||||
void tst_QVideoFrame::createNull()
|
void tst_QVideoFrame::createNull()
|
||||||
{
|
{
|
||||||
QVideoFrame frame;
|
// Default ctor
|
||||||
|
{
|
||||||
|
QVideoFrame frame;
|
||||||
|
|
||||||
QVERIFY(!frame.isValid());
|
QVERIFY(!frame.isValid());
|
||||||
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||||
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
|
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_Invalid);
|
||||||
QCOMPARE(frame.size(), QSize());
|
QCOMPARE(frame.size(), QSize());
|
||||||
QCOMPARE(frame.width(), -1);
|
QCOMPARE(frame.width(), -1);
|
||||||
QCOMPARE(frame.height(), -1);
|
QCOMPARE(frame.height(), -1);
|
||||||
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||||
QCOMPARE(frame.startTime(), qint64(-1));
|
QCOMPARE(frame.startTime(), qint64(-1));
|
||||||
QCOMPARE(frame.endTime(), qint64(-1));
|
QCOMPARE(frame.endTime(), qint64(-1));
|
||||||
|
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
|
||||||
|
QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly));
|
||||||
|
QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||||
|
QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly));
|
||||||
|
QCOMPARE(frame.isMapped(), false);
|
||||||
|
frame.unmap(); // Shouldn't crash
|
||||||
|
QCOMPARE(frame.isReadable(), false);
|
||||||
|
QCOMPARE(frame.isWritable(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Null buffer (shouldn't crash)
|
||||||
|
{
|
||||||
|
QVideoFrame frame(0, QSize(1024,768), QVideoFrame::Format_ARGB32);
|
||||||
|
QVERIFY(!frame.isValid());
|
||||||
|
QCOMPARE(frame.handleType(), QAbstractVideoBuffer::NoHandle);
|
||||||
|
QCOMPARE(frame.pixelFormat(), QVideoFrame::Format_ARGB32);
|
||||||
|
QCOMPARE(frame.size(), QSize(1024, 768));
|
||||||
|
QCOMPARE(frame.width(), 1024);
|
||||||
|
QCOMPARE(frame.height(), 768);
|
||||||
|
QCOMPARE(frame.fieldType(), QVideoFrame::ProgressiveFrame);
|
||||||
|
QCOMPARE(frame.startTime(), qint64(-1));
|
||||||
|
QCOMPARE(frame.endTime(), qint64(-1));
|
||||||
|
QCOMPARE(frame.mapMode(), QAbstractVideoBuffer::NotMapped);
|
||||||
|
QVERIFY(!frame.map(QAbstractVideoBuffer::ReadOnly));
|
||||||
|
QVERIFY(!frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||||
|
QVERIFY(!frame.map(QAbstractVideoBuffer::WriteOnly));
|
||||||
|
QCOMPARE(frame.isMapped(), false);
|
||||||
|
frame.unmap(); // Shouldn't crash
|
||||||
|
QCOMPARE(frame.isReadable(), false);
|
||||||
|
QCOMPARE(frame.isWritable(), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QVideoFrame::destructor()
|
void tst_QVideoFrame::destructor()
|
||||||
@@ -597,6 +632,9 @@ void tst_QVideoFrame::map()
|
|||||||
|
|
||||||
QVERIFY(frame.map(mode));
|
QVERIFY(frame.map(mode));
|
||||||
|
|
||||||
|
// Mapping twice should fail, but leave it mapped (and the mode is ignored)
|
||||||
|
QVERIFY(!frame.map(mode));
|
||||||
|
|
||||||
QVERIFY(frame.bits());
|
QVERIFY(frame.bits());
|
||||||
QCOMPARE(frame.mappedBytes(), mappedBytes);
|
QCOMPARE(frame.mappedBytes(), mappedBytes);
|
||||||
QCOMPARE(frame.bytesPerLine(), bytesPerLine);
|
QCOMPARE(frame.bytesPerLine(), bytesPerLine);
|
||||||
@@ -764,6 +802,9 @@ void tst_QVideoFrame::formatConversion_data()
|
|||||||
<< QImage::Format_Invalid
|
<< QImage::Format_Invalid
|
||||||
<< QVideoFrame::Format_AYUV444_Premultiplied;
|
<< QVideoFrame::Format_AYUV444_Premultiplied;
|
||||||
QTest::newRow("QVideoFrame::Format_YUV444")
|
QTest::newRow("QVideoFrame::Format_YUV444")
|
||||||
|
<< QImage::Format_Invalid
|
||||||
|
<< QVideoFrame::Format_YUV444;
|
||||||
|
QTest::newRow("QVideoFrame::Format_YUV420P")
|
||||||
<< QImage::Format_Invalid
|
<< QImage::Format_Invalid
|
||||||
<< QVideoFrame::Format_YUV420P;
|
<< QVideoFrame::Format_YUV420P;
|
||||||
QTest::newRow("QVideoFrame::Format_YV12")
|
QTest::newRow("QVideoFrame::Format_YV12")
|
||||||
@@ -799,6 +840,21 @@ void tst_QVideoFrame::formatConversion_data()
|
|||||||
QTest::newRow("QVideoFrame::Format_Y16")
|
QTest::newRow("QVideoFrame::Format_Y16")
|
||||||
<< QImage::Format_Invalid
|
<< QImage::Format_Invalid
|
||||||
<< QVideoFrame::Format_Y16;
|
<< QVideoFrame::Format_Y16;
|
||||||
|
QTest::newRow("QVideoFrame::Format_Jpeg")
|
||||||
|
<< QImage::Format_Invalid
|
||||||
|
<< QVideoFrame::Format_Jpeg;
|
||||||
|
QTest::newRow("QVideoFrame::Format_CameraRaw")
|
||||||
|
<< QImage::Format_Invalid
|
||||||
|
<< QVideoFrame::Format_CameraRaw;
|
||||||
|
QTest::newRow("QVideoFrame::Format_AdobeDng")
|
||||||
|
<< QImage::Format_Invalid
|
||||||
|
<< QVideoFrame::Format_AdobeDng;
|
||||||
|
QTest::newRow("QVideoFrame::Format_User")
|
||||||
|
<< QImage::Format_Invalid
|
||||||
|
<< QVideoFrame::Format_User;
|
||||||
|
QTest::newRow("QVideoFrame::Format_User + 1")
|
||||||
|
<< QImage::Format_Invalid
|
||||||
|
<< QVideoFrame::PixelFormat(QVideoFrame::Format_User + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QVideoFrame::formatConversion()
|
void tst_QVideoFrame::formatConversion()
|
||||||
@@ -834,22 +890,31 @@ do { \
|
|||||||
void tst_QVideoFrame::isMapped()
|
void tst_QVideoFrame::isMapped()
|
||||||
{
|
{
|
||||||
QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
|
QVideoFrame frame(16384, QSize(64, 64), 256, QVideoFrame::Format_ARGB32);
|
||||||
|
const QVideoFrame& constFrame(frame);
|
||||||
|
|
||||||
TEST_UNMAPPED(frame);
|
TEST_UNMAPPED(frame);
|
||||||
|
TEST_UNMAPPED(constFrame);
|
||||||
|
|
||||||
QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadOnly));
|
||||||
TEST_MAPPED(frame, QAbstractVideoBuffer::ReadOnly);
|
TEST_MAPPED(frame, QAbstractVideoBuffer::ReadOnly);
|
||||||
|
TEST_MAPPED(constFrame, QAbstractVideoBuffer::ReadOnly);
|
||||||
frame.unmap();
|
frame.unmap();
|
||||||
TEST_UNMAPPED(frame);
|
TEST_UNMAPPED(frame);
|
||||||
|
TEST_UNMAPPED(constFrame);
|
||||||
|
|
||||||
QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
|
QVERIFY(frame.map(QAbstractVideoBuffer::WriteOnly));
|
||||||
TEST_MAPPED(frame, QAbstractVideoBuffer::WriteOnly);
|
TEST_MAPPED(frame, QAbstractVideoBuffer::WriteOnly);
|
||||||
|
TEST_MAPPED(constFrame, QAbstractVideoBuffer::WriteOnly);
|
||||||
frame.unmap();
|
frame.unmap();
|
||||||
TEST_UNMAPPED(frame);
|
TEST_UNMAPPED(frame);
|
||||||
|
TEST_UNMAPPED(constFrame);
|
||||||
|
|
||||||
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
|
QVERIFY(frame.map(QAbstractVideoBuffer::ReadWrite));
|
||||||
TEST_MAPPED(frame, QAbstractVideoBuffer::ReadWrite);
|
TEST_MAPPED(frame, QAbstractVideoBuffer::ReadWrite);
|
||||||
|
TEST_MAPPED(constFrame, QAbstractVideoBuffer::ReadWrite);
|
||||||
frame.unmap();
|
frame.unmap();
|
||||||
TEST_UNMAPPED(frame);
|
TEST_UNMAPPED(frame);
|
||||||
|
TEST_UNMAPPED(constFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QVideoFrame::isReadable()
|
void tst_QVideoFrame::isReadable()
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ private slots:
|
|||||||
void yCbCrColorSpaceEnum ();
|
void yCbCrColorSpaceEnum ();
|
||||||
void copyAllParameters ();
|
void copyAllParameters ();
|
||||||
void assignAllParameters ();
|
void assignAllParameters ();
|
||||||
|
|
||||||
|
void propertyEdgeCases();
|
||||||
|
void debugOperator();
|
||||||
|
void debugOperator_data();
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
|
tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat()
|
||||||
@@ -180,10 +184,14 @@ void tst_QVideoSurfaceFormat::construct()
|
|||||||
QVideoSurfaceFormat format(frameSize, pixelFormat, handleType);
|
QVideoSurfaceFormat format(frameSize, pixelFormat, handleType);
|
||||||
|
|
||||||
QCOMPARE(format.handleType(), handleType);
|
QCOMPARE(format.handleType(), handleType);
|
||||||
|
QCOMPARE(format.property("handleType").value<QAbstractVideoBuffer::HandleType>(), handleType);
|
||||||
QCOMPARE(format.pixelFormat(), pixelFormat);
|
QCOMPARE(format.pixelFormat(), pixelFormat);
|
||||||
|
QCOMPARE(format.property("pixelFormat").value<QVideoFrame::PixelFormat>(), pixelFormat);
|
||||||
QCOMPARE(format.frameSize(), frameSize);
|
QCOMPARE(format.frameSize(), frameSize);
|
||||||
QCOMPARE(format.frameWidth(), frameSize.width());
|
QCOMPARE(format.frameWidth(), frameSize.width());
|
||||||
|
QCOMPARE(format.property("frameWidth").toInt(), frameSize.width());
|
||||||
QCOMPARE(format.frameHeight(), frameSize.height());
|
QCOMPARE(format.frameHeight(), frameSize.height());
|
||||||
|
QCOMPARE(format.property("frameHeight").toInt(), frameSize.height());
|
||||||
QCOMPARE(format.isValid(), valid);
|
QCOMPARE(format.isValid(), valid);
|
||||||
QCOMPARE(format.viewport(), viewport);
|
QCOMPARE(format.viewport(), viewport);
|
||||||
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
|
QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
|
||||||
@@ -213,16 +221,32 @@ void tst_QVideoSurfaceFormat::frameSize()
|
|||||||
QFETCH(QSize, initialSize);
|
QFETCH(QSize, initialSize);
|
||||||
QFETCH(QSize, newSize);
|
QFETCH(QSize, newSize);
|
||||||
|
|
||||||
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
|
{
|
||||||
|
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
|
||||||
|
|
||||||
format.setFrameSize(newSize);
|
format.setFrameSize(newSize);
|
||||||
|
|
||||||
|
QCOMPARE(format.frameSize(), newSize);
|
||||||
|
QCOMPARE(format.property("frameSize").toSize(), newSize);
|
||||||
|
QCOMPARE(format.frameWidth(), newSize.width());
|
||||||
|
QCOMPARE(format.property("frameWidth").toInt(), newSize.width());
|
||||||
|
QCOMPARE(format.frameHeight(), newSize.height());
|
||||||
|
QCOMPARE(format.property("frameHeight").toInt(), newSize.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32);
|
||||||
|
|
||||||
|
format.setProperty("frameSize", newSize);
|
||||||
|
|
||||||
|
QCOMPARE(format.frameSize(), newSize);
|
||||||
|
QCOMPARE(format.property("frameSize").toSize(), newSize);
|
||||||
|
QCOMPARE(format.frameWidth(), newSize.width());
|
||||||
|
QCOMPARE(format.property("frameWidth").toInt(), newSize.width());
|
||||||
|
QCOMPARE(format.frameHeight(), newSize.height());
|
||||||
|
QCOMPARE(format.property("frameHeight").toInt(), newSize.height());
|
||||||
|
}
|
||||||
|
|
||||||
QCOMPARE(format.frameSize(), newSize);
|
|
||||||
QCOMPARE(format.property("frameSize").toSize(), newSize);
|
|
||||||
QCOMPARE(format.frameWidth(), newSize.width());
|
|
||||||
QCOMPARE(format.property("frameWidth").toInt(), newSize.width());
|
|
||||||
QCOMPARE(format.frameHeight(), newSize.height());
|
|
||||||
QCOMPARE(format.property("frameHeight").toInt(), newSize.height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QVideoSurfaceFormat::viewport_data()
|
void tst_QVideoSurfaceFormat::viewport_data()
|
||||||
@@ -457,6 +481,11 @@ void tst_QVideoSurfaceFormat::sizeHint_data()
|
|||||||
<< QRect(168, 84, 800, 600)
|
<< QRect(168, 84, 800, 600)
|
||||||
<< QSize(4, 3)
|
<< QSize(4, 3)
|
||||||
<< QSize(1066, 600);
|
<< QSize(1066, 600);
|
||||||
|
QTest::newRow("(168, 84, 800x600), 4:0")
|
||||||
|
<< QSize(1024, 768)
|
||||||
|
<< QRect(168, 84, 800, 600)
|
||||||
|
<< QSize(4, 0)
|
||||||
|
<< QSize(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QVideoSurfaceFormat::sizeHint()
|
void tst_QVideoSurfaceFormat::sizeHint()
|
||||||
@@ -740,20 +769,31 @@ void tst_QVideoSurfaceFormat::assign()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
|
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
|
||||||
|
|
||||||
|
#define ADD_YCBCR_TEST(x) \
|
||||||
|
QTest::newRow(#x) \
|
||||||
|
<< QVideoSurfaceFormat::x \
|
||||||
|
<< QString(QLatin1String(#x));
|
||||||
|
|
||||||
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data()
|
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
|
QTest::addColumn<QVideoSurfaceFormat::YCbCrColorSpace>("colorspace");
|
||||||
|
QTest::addColumn<QString>("stringized");
|
||||||
|
|
||||||
QTest::newRow("YCbCr_BT601")
|
ADD_YCBCR_TEST(YCbCr_BT601);
|
||||||
<< QVideoSurfaceFormat::YCbCr_BT601;
|
ADD_YCBCR_TEST(YCbCr_BT709);
|
||||||
QTest::newRow("YCbCr_xvYCC709")
|
ADD_YCBCR_TEST(YCbCr_xvYCC601);
|
||||||
<< QVideoSurfaceFormat::YCbCr_xvYCC709;
|
ADD_YCBCR_TEST(YCbCr_xvYCC709);
|
||||||
|
ADD_YCBCR_TEST(YCbCr_JPEG);
|
||||||
|
ADD_YCBCR_TEST(YCbCr_CustomMatrix);
|
||||||
|
ADD_YCBCR_TEST(YCbCr_Undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
|
/* Test case for Enum YCbCr_BT601, YCbCr_xvYCC709 */
|
||||||
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum()
|
void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum()
|
||||||
{
|
{
|
||||||
QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace);
|
QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace);
|
||||||
|
QFETCH(QString, stringized);
|
||||||
|
|
||||||
{
|
{
|
||||||
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32);
|
||||||
@@ -771,6 +811,9 @@ void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum()
|
|||||||
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
|
QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")),
|
||||||
colorspace);
|
colorspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData());
|
||||||
|
qDebug() << colorspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test case for api isValid */
|
/* Test case for api isValid */
|
||||||
@@ -866,6 +909,155 @@ void tst_QVideoSurfaceFormat::assignAllParameters()
|
|||||||
QCOMPARE(original != copy, false);
|
QCOMPARE(original != copy, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QVideoSurfaceFormat::propertyEdgeCases()
|
||||||
|
{
|
||||||
|
// Test setting read only properties doesn't change anything
|
||||||
|
QVideoSurfaceFormat original(
|
||||||
|
QSize(1024, 768), QVideoFrame::Format_ARGB32, QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
|
||||||
|
original.setProperty("handleType", QAbstractVideoBuffer::UserHandle);
|
||||||
|
QCOMPARE(original.handleType(), QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
|
||||||
|
original.setProperty("pixelFormat", QVideoFrame::Format_AYUV444);
|
||||||
|
QCOMPARE(original.pixelFormat(), QVideoFrame::Format_ARGB32);
|
||||||
|
|
||||||
|
original.setProperty("frameWidth", 512);
|
||||||
|
QCOMPARE(original.frameWidth(), 1024);
|
||||||
|
|
||||||
|
original.setProperty("frameHeight", 77);
|
||||||
|
QCOMPARE(original.frameHeight(), 768);
|
||||||
|
|
||||||
|
original.setProperty("sizeHint", QSize(512, 384));
|
||||||
|
QCOMPARE(original.sizeHint(), QSize(1024,768));
|
||||||
|
|
||||||
|
// Now test setting some r/w properties with the wrong data type
|
||||||
|
original.setProperty("frameSize", Qt::red);
|
||||||
|
QCOMPARE(original.frameSize(), QSize(1024, 768));
|
||||||
|
|
||||||
|
original.setProperty("viewport", Qt::red);
|
||||||
|
QCOMPARE(original.viewport(), QRect(0, 0, 1024, 768));
|
||||||
|
|
||||||
|
original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop);
|
||||||
|
original.setProperty("scanLineDirection", Qt::red);
|
||||||
|
QCOMPARE(original.scanLineDirection(), QVideoSurfaceFormat::BottomToTop);
|
||||||
|
|
||||||
|
original.setFrameRate(32);
|
||||||
|
original.setProperty("frameRate", QSize(32, 43));
|
||||||
|
QCOMPARE(original.frameRate(), qreal(32));
|
||||||
|
|
||||||
|
original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
original.setProperty("yCbCrColorSpace", QSize(43,43));
|
||||||
|
QCOMPARE(original.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
|
||||||
|
original.setPixelAspectRatio(53, 45);
|
||||||
|
original.setProperty("pixelAspectRatio", Qt::red);
|
||||||
|
QCOMPARE(original.pixelAspectRatio(), QSize(53, 45));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ADDDEBUGTEST(format, w, h, r) \
|
||||||
|
QTest::newRow(#format "-" #w "x" #h "@" #r) \
|
||||||
|
<< QVideoFrame::Format_ ##format \
|
||||||
|
<< "Format_" #format \
|
||||||
|
<< QSize(w, h) \
|
||||||
|
<< r;
|
||||||
|
|
||||||
|
void tst_QVideoSurfaceFormat::debugOperator_data()
|
||||||
|
{
|
||||||
|
// This is not too exhaustive
|
||||||
|
QTest::addColumn<QVideoFrame::PixelFormat>("format");
|
||||||
|
QTest::addColumn<QString>("formatString");
|
||||||
|
QTest::addColumn<QSize>("frameSize");
|
||||||
|
QTest::addColumn<int>("frameRate"); // could be double, but formatting is unstable
|
||||||
|
|
||||||
|
ADDDEBUGTEST(Invalid, 100, 200, 3);
|
||||||
|
ADDDEBUGTEST(ARGB32,101, 201, 4);
|
||||||
|
ADDDEBUGTEST(ARGB32_Premultiplied, 100, 202, 5);
|
||||||
|
ADDDEBUGTEST(RGB32, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(RGB24, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(RGB565, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(RGB555, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(ARGB8565_Premultiplied, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGRA32, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGRA32_Premultiplied, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGR32, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGR24, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGR565, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGR555, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(BGRA5658_Premultiplied, 8, 16, 30);
|
||||||
|
|
||||||
|
ADDDEBUGTEST(AYUV444, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(AYUV444, 8, 16, 31);
|
||||||
|
ADDDEBUGTEST(AYUV444_Premultiplied, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(YUV444, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(YUV420P, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(YV12, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(UYVY, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(YUYV, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(NV12, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(NV12, 80, 16, 30);
|
||||||
|
ADDDEBUGTEST(NV21, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(IMC1, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(IMC2, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(IMC3, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(IMC3, 8, 160, 30);
|
||||||
|
ADDDEBUGTEST(IMC4, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(Y8, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(Y16, 8, 16, 30);
|
||||||
|
|
||||||
|
ADDDEBUGTEST(Jpeg, 8, 16, 30);
|
||||||
|
|
||||||
|
ADDDEBUGTEST(CameraRaw, 8, 16, 30);
|
||||||
|
ADDDEBUGTEST(AdobeDng, 8, 16, 30);
|
||||||
|
|
||||||
|
// User is special
|
||||||
|
QTest::newRow("User-0x0@0)")
|
||||||
|
<< QVideoFrame::Format_User
|
||||||
|
<< "UserType(1000)"
|
||||||
|
<< QSize()
|
||||||
|
<< 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QVideoSurfaceFormat::debugOperator()
|
||||||
|
{
|
||||||
|
QFETCH(QVideoFrame::PixelFormat, format);
|
||||||
|
QFETCH(QString, formatString);
|
||||||
|
QFETCH(QSize, frameSize);
|
||||||
|
QFETCH(int, frameRate);
|
||||||
|
|
||||||
|
QString templateOutput = QString("QVideoSurfaceFormat(%1, QSize(%2, %3) , viewport=QRect(0,1 800x600) , pixelAspectRatio=QSize(320, 200) "
|
||||||
|
", handleType=GLTextureHandle, yCbCrColorSpace=YCbCr_BT709)\n"
|
||||||
|
" handleType = QVariant(QAbstractVideoBuffer::HandleType, ) \n"
|
||||||
|
" pixelFormat = QVariant(QVideoFrame::PixelFormat, ) \n"
|
||||||
|
" frameSize = QVariant(QSize, QSize(%4, %5) ) \n"
|
||||||
|
" frameWidth = QVariant(int, %6) \n"
|
||||||
|
" viewport = QVariant(QRect, QRect(0,1 800x600) ) \n"
|
||||||
|
" scanLineDirection = QVariant(QVideoSurfaceFormat::Direction, ) \n"
|
||||||
|
" frameRate = QVariant(double, %7) \n"
|
||||||
|
" pixelAspectRatio = QVariant(QSize, QSize(320, 200) ) \n"
|
||||||
|
" sizeHint = QVariant(QSize, QSize(1280, 600) ) \n"
|
||||||
|
" yCbCrColorSpace = QVariant(QVideoSurfaceFormat::YCbCrColorSpace, ) ")
|
||||||
|
.arg(formatString)
|
||||||
|
.arg(frameSize.width())
|
||||||
|
.arg(frameSize.height())
|
||||||
|
.arg(frameSize.width())
|
||||||
|
.arg(frameSize.height())
|
||||||
|
.arg(frameSize.width())
|
||||||
|
.arg(frameRate);
|
||||||
|
|
||||||
|
QVideoSurfaceFormat vsf(frameSize, format, QAbstractVideoBuffer::GLTextureHandle);
|
||||||
|
vsf.setViewport(QRect(0,1, 800, 600));
|
||||||
|
vsf.setPixelAspectRatio(QSize(320, 200));
|
||||||
|
vsf.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709);
|
||||||
|
vsf.setFrameRate(frameRate);
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtDebugMsg, templateOutput.toLatin1().constData());
|
||||||
|
qDebug() << vsf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN(tst_QVideoSurfaceFormat)
|
QTEST_MAIN(tst_QVideoSurfaceFormat)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "tst_qvideosurfaceformat.moc"
|
#include "tst_qvideosurfaceformat.moc"
|
||||||
|
|||||||
Reference in New Issue
Block a user