diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-03-02 17:06:14 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-03-16 07:45:53 +0000 |
commit | 4b99f984a014a90f554bc1924ebae11e25af597c (patch) | |
tree | 9bf8a9ba31673b9b64a74f8c246ef1320c69c6fb | |
parent | 4547eabd96ffe5d362397e782eb36bcb8749d939 (diff) | |
download | qtmultimedia-4b99f984a014a90f554bc1924ebae11e25af597c.tar.gz |
Some cleanups in QVideoSurfaceFormat
Remove the pixel aspect ratio property. It's almost always 1/1 or
something very close to it.
Remove the pseudo property API. If we need to bind this to QML as a value
type there are better ways to do it.
Change-Id: I02f2170b0f1672529e298593a668eb418caed964
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
18 files changed, 37 insertions, 619 deletions
diff --git a/src/imports/multimedia/plugins.qmltypes b/src/imports/multimedia/plugins.qmltypes index 63dc4f4e2..92cf6834d 100644 --- a/src/imports/multimedia/plugins.qmltypes +++ b/src/imports/multimedia/plugins.qmltypes @@ -1326,7 +1326,6 @@ Module { Property { name: "coverArtUrlSmall"; type: "QVariant" } Property { name: "coverArtUrlLarge"; type: "QVariant" } Property { name: "resolution"; type: "QVariant" } - Property { name: "pixelAspectRatio"; type: "QVariant" } Property { name: "videoFrameRate"; type: "QVariant" } Property { name: "videoBitRate"; type: "QVariant" } Property { name: "videoCodec"; type: "QVariant" } diff --git a/src/imports/multimedia/qdeclarativeaudio.cpp b/src/imports/multimedia/qdeclarativeaudio.cpp index 2668cd3fd..c52cc3717 100644 --- a/src/imports/multimedia/qdeclarativeaudio.cpp +++ b/src/imports/multimedia/qdeclarativeaudio.cpp @@ -1027,7 +1027,6 @@ void QDeclarativeAudio::_q_mediaChanged(const QUrl &) \qmlproperty variant QtMultimedia::Audio::metaData.coverArtUrlSmall \qmlproperty variant QtMultimedia::Audio::metaData.coverArtUrlLarge \qmlproperty variant QtMultimedia::Audio::metaData.resolution - \qmlproperty variant QtMultimedia::Audio::metaData.pixelAspectRatio \qmlproperty variant QtMultimedia::Audio::metaData.videoFrameRate \qmlproperty variant QtMultimedia::Audio::metaData.videoBitRate \qmlproperty variant QtMultimedia::Audio::metaData.videoCodec @@ -1078,7 +1077,6 @@ void QDeclarativeAudio::_q_mediaChanged(const QUrl &) \li \c metaData.coverArtUrlSmall - the URL of a small cover art image. \li \c metaData.coverArtUrlLarge - the URL of a large cover art image. \li \c metaData.resolution - the dimension of an image or video. - \li \c metaData.pixelAspectRatio - the pixel aspect ratio of an image or video. \li \c metaData.videoFrameRate - the frame rate of the media's video stream. \li \c metaData.videoBitRate - the bit rate of the media's video stream in bits per second. \li \c metaData.videoCodec - the encoding of the media's video stream. @@ -1559,7 +1557,6 @@ void QDeclarativeAudio::_q_mediaChanged(const QUrl &) \qmlproperty variant QtMultimedia::MediaPlayer::metaData.coverArtUrlSmall \qmlproperty variant QtMultimedia::MediaPlayer::metaData.coverArtUrlLarge \qmlproperty variant QtMultimedia::MediaPlayer::metaData.resolution - \qmlproperty variant QtMultimedia::MediaPlayer::metaData.pixelAspectRatio \qmlproperty variant QtMultimedia::MediaPlayer::metaData.videoFrameRate \qmlproperty variant QtMultimedia::MediaPlayer::metaData.videoBitRate \qmlproperty variant QtMultimedia::MediaPlayer::metaData.videoCodec @@ -1610,7 +1607,6 @@ void QDeclarativeAudio::_q_mediaChanged(const QUrl &) \li \c metaData.coverArtUrlSmall - the URL of a small cover art image. \li \c metaData.coverArtUrlLarge - the URL of a large cover art image. \li \c metaData.resolution - the dimension of an image or video. - \li \c metaData.pixelAspectRatio - the pixel aspect ratio of an image or video. \li \c metaData.videoFrameRate - the frame rate of the media's video stream. \li \c metaData.videoBitRate - the bit rate of the media's video stream in bits per second. \li \c metaData.videoCodec - the encoding of the media's video stream. diff --git a/src/imports/multimedia/qdeclarativemediametadata_p.h b/src/imports/multimedia/qdeclarativemediametadata_p.h index f08c14c68..3ed7f49de 100644 --- a/src/imports/multimedia/qdeclarativemediametadata_p.h +++ b/src/imports/multimedia/qdeclarativemediametadata_p.h @@ -97,7 +97,6 @@ class QDeclarativeMediaMetaData : public QObject // Q_PROPERTY(QVariant coverArtUrlSmall READ coverArtUrlSmall WRITE setCoverArtUrlSmall NOTIFY metaDataChanged) // Q_PROPERTY(QVariant coverArtUrlLarge READ coverArtUrlLarge WRITE setCoverArtUrlLarge NOTIFY metaDataChanged) // Q_PROPERTY(QVariant resolution READ resolution WRITE setResolution NOTIFY metaDataChanged) -// Q_PROPERTY(QVariant pixelAspectRatio READ pixelAspectRatio WRITE setPixelAspectRatio NOTIFY metaDataChanged) // Q_PROPERTY(QVariant videoFrameRate READ videoFrameRate WRITE setVideoFrameRate NOTIFY metaDataChanged) // Q_PROPERTY(QVariant videoBitRate READ videoBitRate WRITE setVideoBitRate NOTIFY metaDataChanged) // Q_PROPERTY(QVariant videoCodec READ videoCodec WRITE setVideoCodec NOTIFY metaDataChanged) @@ -255,10 +254,6 @@ public: // QVariant resolution() const { return metaData.value(QMediaMetaData::Resolution); } // void setResolution(const QVariant &resolution) { // setMetaData(QMediaMetaData::Resolution, resolution); } -// QVariant pixelAspectRatio() const { -// return metaData.value(QMediaMetaData::PixelAspectRatio); } -// void setPixelAspectRatio(const QVariant &ratio) { -// setMetaData(QMediaMetaData::PixelAspectRatio, ratio); } // QVariant videoFrameRate() const { return metaData.value(QMediaMetaData::VideoFrameRate); } // void setVideoFrameRate(const QVariant &rate) { // setMetaData(QMediaMetaData::VideoFrameRate, rate); } diff --git a/src/multimedia/platform/gstreamer/common/qgst_p.h b/src/multimedia/platform/gstreamer/common/qgst_p.h index b779960f9..f4cb5684d 100644 --- a/src/multimedia/platform/gstreamer/common/qgst_p.h +++ b/src/multimedia/platform/gstreamer/common/qgst_p.h @@ -154,7 +154,6 @@ public: Q_MULTIMEDIA_EXPORT QSize resolution() const; Q_MULTIMEDIA_EXPORT QVideoFrame::PixelFormat pixelFormat() const; - Q_MULTIMEDIA_EXPORT QSize pixelAspectRatio() const; Q_MULTIMEDIA_EXPORT QGRange<float> frameRateRange() const; QByteArray toString() const { return gst_structure_to_string(structure); } diff --git a/src/multimedia/platform/gstreamer/common/qgstutils.cpp b/src/multimedia/platform/gstreamer/common/qgstutils.cpp index 1fed48717..ae8a625e0 100644 --- a/src/multimedia/platform/gstreamer/common/qgstutils.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstutils.cpp @@ -362,9 +362,6 @@ QVideoSurfaceFormat QGstUtils::formatForCaps( if (infoPtr->fps_d > 0) format.setFrameRate(qreal(infoPtr->fps_n) / infoPtr->fps_d); - if (infoPtr->par_d > 0) - format.setPixelAspectRatio(infoPtr->par_n, infoPtr->par_d); - return format; } } @@ -519,22 +516,6 @@ QVideoFrame::PixelFormat QGstStructure::pixelFormat() const return pixelFormat; } -QSize QGstStructure::pixelAspectRatio() const -{ - QSize ratio(1, 1); - - gint aspectNum = 0; - gint aspectDenum = 0; - if (structure && gst_structure_get_fraction(structure, "pixel-aspect-ratio", &aspectNum, &aspectDenum)) { - if (aspectDenum > 0) { - ratio.rwidth() = aspectNum; - ratio.rheight() = aspectDenum; - } - } - - return ratio; -} - QGRange<float> QGstStructure::frameRateRange() const { float minRate = 0.; diff --git a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp index f0cc0ddbe..4f5eadc64 100644 --- a/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp +++ b/src/multimedia/platform/windows/evr/evrd3dpresentengine.cpp @@ -373,10 +373,6 @@ done: : qt_evr_pixelFormatFromD3DFormat(d3dFormat), m_useTextureRendering ? QVideoFrame::GLTextureHandle : QVideoFrame::NoHandle); - UINT32 horizontal = 1, vertical = 1; - hr = MFGetAttributeRatio(format, MF_MT_PIXEL_ASPECT_RATIO, &horizontal, &vertical); - if (SUCCEEDED(hr)) - m_surfaceFormat.setPixelAspectRatio(horizontal, vertical); } else { releaseResources(); } diff --git a/src/multimedia/platform/windows/player/mfmetadata.cpp b/src/multimedia/platform/windows/player/mfmetadata.cpp index 3800deb67..a6b16e2d4 100644 --- a/src/multimedia/platform/windows/player/mfmetadata.cpp +++ b/src/multimedia/platform/windows/player/mfmetadata.cpp @@ -314,8 +314,6 @@ QMediaMetaData MFMetaData::fromNative(IMFMediaSource* mediaSource) mediaKey = QMediaMetaData::Resolution; } else if (key == PKEY_Video_Orientation) { mediaKey = QMediaMetaData::Orientation; -// } else if (key == PKEY_Video_HorizontalAspectRatio) { -// mediaKey = QMediaMetaData::PixelAspectRatio; // } else if (key == PKEY_Video_FrameRate) { // mediaKey = QMediaMetaData::VideoFrameRate; } else if (key == PKEY_Video_EncodingBitrate) { diff --git a/src/multimedia/platform/windows/player/mftvideo.cpp b/src/multimedia/platform/windows/player/mftvideo.cpp index 8bb2f86be..8d318a6f6 100644 --- a/src/multimedia/platform/windows/player/mftvideo.cpp +++ b/src/multimedia/platform/windows/player/mftvideo.cpp @@ -654,10 +654,6 @@ QVideoSurfaceFormat MFTransform::videoFormatForMFMediaType(IMFMediaType *mediaTy QVideoFrame::PixelFormat pixelFormat = formatFromSubtype(subtype); QVideoSurfaceFormat format(size, pixelFormat); - UINT32 num, den; - if (SUCCEEDED(MFGetAttributeRatio(mediaType, MF_MT_PIXEL_ASPECT_RATIO, &num, &den))) { - format.setPixelAspectRatio(num, den); - } if (SUCCEEDED(MFGetAttributeRatio(mediaType, MF_MT_FRAME_RATE, &num, &den))) { format.setFrameRate(qreal(num)/den); } diff --git a/src/multimedia/qmediametadata.cpp b/src/multimedia/qmediametadata.cpp index 2e4f335ce..7a2ee634f 100644 --- a/src/multimedia/qmediametadata.cpp +++ b/src/multimedia/qmediametadata.cpp @@ -112,7 +112,6 @@ QT_BEGIN_NAMESPACE \header \li {3,1} Image and video attributes \row \li Resolution \li The dimensions of an image or video. \li QSize - \row \li PixelAspectRatio \li The pixel aspect ratio of an image or video. \li QSize \row \li Orientation \li Orientation of an image or video. \li int (degrees) \header \li {3,1} diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index d80389151..05901b679 100644 --- a/src/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -59,7 +59,6 @@ public: : pixelFormat(format) , handleType(type) , frameSize(size) - , pixelAspectRatio(1, 1) , viewport(QPoint(0, 0), size) { } @@ -70,20 +69,11 @@ public: && handleType == other.handleType && scanLineDirection == other.scanLineDirection && frameSize == other.frameSize - && pixelAspectRatio == other.pixelAspectRatio && viewport == other.viewport && frameRatesEqual(frameRate, other.frameRate) && ycbcrColorSpace == other.ycbcrColorSpace - && mirrored == other.mirrored - && propertyNames.count() == other.propertyNames.count()) { - for (int i = 0; i < propertyNames.count(); ++i) { - int j = other.propertyNames.indexOf(propertyNames.at(i)); - - if (j == -1 || propertyValues.at(i) != other.propertyValues.at(j)) - return false; - } + && mirrored == other.mirrored) return true; - } return false; } @@ -97,13 +87,10 @@ public: QVideoFrame::HandleType handleType = QVideoFrame::NoHandle; QVideoSurfaceFormat::Direction scanLineDirection = QVideoSurfaceFormat::TopToBottom; QSize frameSize; - QSize pixelAspectRatio; QVideoSurfaceFormat::YCbCrColorSpace ycbcrColorSpace = QVideoSurfaceFormat::YCbCr_Undefined; QRect viewport; qreal frameRate = 0.0; bool mirrored = false; - QList<QByteArray> propertyNames; - QList<QVariant> propertyValues; }; /*! @@ -129,7 +116,7 @@ public: than the nearest optimal size of a video frame. For example the width of a frame may be extended so that the start of each scan line is eight byte aligned. - Other common properties are the pixelAspectRatio(), scanLineDirection(), and frameRate(). + Other common properties are the scanLineDirection(), and frameRate(). Additionally a stream may have some additional type specific properties which are listed by the dynamicPropertyNames() function and can be accessed using the property(), and setProperty() functions. @@ -358,32 +345,6 @@ void QVideoSurfaceFormat::setFrameRate(qreal rate) } /*! - Returns a video stream's pixel aspect ratio. -*/ -QSize QVideoSurfaceFormat::pixelAspectRatio() const -{ - return d->pixelAspectRatio; -} - -/*! - Sets a video stream's pixel aspect \a ratio. -*/ -void QVideoSurfaceFormat::setPixelAspectRatio(const QSize &ratio) -{ - d->pixelAspectRatio = ratio; -} - -/*! - \overload - - Sets the \a horizontal and \a vertical elements of a video stream's pixel aspect ratio. -*/ -void QVideoSurfaceFormat::setPixelAspectRatio(int horizontal, int vertical) -{ - d->pixelAspectRatio = QSize(horizontal, vertical); -} - -/*! Returns the Y'CbCr color space of a video stream. */ QVideoSurfaceFormat::YCbCrColorSpace QVideoSurfaceFormat::yCbCrColorSpace() const @@ -432,137 +393,13 @@ void QVideoSurfaceFormat::setMirrored(bool mirrored) /*! Returns a suggested size in pixels for the video stream. - This is the size of the viewport scaled according to the pixel aspect ratio. + This is the same as the size of the viewport. */ QSize QVideoSurfaceFormat::sizeHint() const { - QSize size = d->viewport.size(); - - if (d->pixelAspectRatio.height() != 0) - size.setWidth(size.width() * d->pixelAspectRatio.width() / d->pixelAspectRatio.height()); - - return size; + return d->viewport.size(); } -/*! - Returns a list of video format dynamic property names. -*/ -QList<QByteArray> QVideoSurfaceFormat::propertyNames() const -{ - return (QList<QByteArray>() - << "handleType" - << "pixelFormat" - << "frameSize" - << "frameWidth" - << "viewport" - << "scanLineDirection" - << "frameRate" - << "pixelAspectRatio" - << "sizeHint" - << "yCbCrColorSpace" - << "mirrored") - + d->propertyNames; -} - -/*! - Returns the value of the video format's \a name property. -*/ -QVariant QVideoSurfaceFormat::property(const char *name) const -{ - if (qstrcmp(name, "handleType") == 0) { - return QVariant::fromValue(d->handleType); - } else if (qstrcmp(name, "pixelFormat") == 0) { - return QVariant::fromValue(d->pixelFormat); - } else if (qstrcmp(name, "frameSize") == 0) { - return d->frameSize; - } else if (qstrcmp(name, "frameWidth") == 0) { - return d->frameSize.width(); - } else if (qstrcmp(name, "frameHeight") == 0) { - return d->frameSize.height(); - } else if (qstrcmp(name, "viewport") == 0) { - return d->viewport; - } else if (qstrcmp(name, "scanLineDirection") == 0) { - return QVariant::fromValue(d->scanLineDirection); - } else if (qstrcmp(name, "frameRate") == 0) { - return QVariant::fromValue(d->frameRate); - } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - return QVariant::fromValue(d->pixelAspectRatio); - } else if (qstrcmp(name, "sizeHint") == 0) { - return sizeHint(); - } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - return QVariant::fromValue(d->ycbcrColorSpace); - } else if (qstrcmp(name, "mirrored") == 0) { - return d->mirrored; - } else { - int id = 0; - for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} - - return id < d->propertyValues.count() - ? d->propertyValues.at(id) - : QVariant(); - } -} - -/*! - Sets the video format's \a name property to \a value. - - Trying to set a read only property will be ignored. - -*/ -void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) -{ - if (qstrcmp(name, "handleType") == 0) { - // read only. - } else if (qstrcmp(name, "pixelFormat") == 0) { - // read only. - } else if (qstrcmp(name, "frameSize") == 0) { - if (value.canConvert<QSize>()) { - d->frameSize = qvariant_cast<QSize>(value); - d->viewport = QRect(QPoint(0, 0), d->frameSize); - } - } else if (qstrcmp(name, "frameWidth") == 0) { - // read only. - } else if (qstrcmp(name, "frameHeight") == 0) { - // read only. - } else if (qstrcmp(name, "viewport") == 0) { - if (value.canConvert<QRect>()) - d->viewport = qvariant_cast<QRect>(value); - } else if (qstrcmp(name, "scanLineDirection") == 0) { - if (value.canConvert<Direction>()) - d->scanLineDirection = qvariant_cast<Direction>(value); - } else if (qstrcmp(name, "frameRate") == 0) { - if (value.canConvert<qreal>()) - d->frameRate = qvariant_cast<qreal>(value); - } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - if (value.canConvert<QSize>()) - d->pixelAspectRatio = qvariant_cast<QSize>(value); - } else if (qstrcmp(name, "sizeHint") == 0) { - // read only. - } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - if (value.canConvert<YCbCrColorSpace>()) - d->ycbcrColorSpace = qvariant_cast<YCbCrColorSpace>(value); - } else if (qstrcmp(name, "mirrored") == 0) { - if (value.canConvert<bool>()) - d->mirrored = qvariant_cast<bool>(value); - } else { - int id = 0; - for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} - - if (id < d->propertyValues.count()) { - if (value.isNull()) { - d->propertyNames.removeAt(id); - d->propertyValues.removeAt(id); - } else { - d->propertyValues[id] = value; - } - } else if (!value.isNull()) { - d->propertyNames.append(QByteArray(name)); - d->propertyValues.append(value); - } - } -} - - #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, QVideoSurfaceFormat::YCbCrColorSpace cs) { @@ -584,9 +421,6 @@ QDebug operator<<(QDebug dbg, QVideoSurfaceFormat::YCbCrColorSpace cs) case QVideoSurfaceFormat::YCbCr_xvYCC709: dbg << "YCbCr_xvYCC709"; break; - case QVideoSurfaceFormat::YCbCr_CustomMatrix: - dbg << "YCbCr_CustomMatrix"; - break; default: dbg << "YCbCr_Undefined"; break; @@ -614,13 +448,15 @@ QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f) QDebugStateSaver saver(dbg); dbg.nospace(); dbg << "QVideoSurfaceFormat(" << f.pixelFormat() << ", " << f.frameSize() - << ", viewport=" << f.viewport() << ", pixelAspectRatio=" << f.pixelAspectRatio() + << ", viewport=" << f.viewport() << ", handleType=" << f.handleType() << ", yCbCrColorSpace=" << f.yCbCrColorSpace() - << ')'; - - const auto propertyNames = f.propertyNames(); - for (const QByteArray& propertyName : propertyNames) - dbg << "\n " << propertyName.data() << " = " << f.property(propertyName.data()); + << ')' + << "\n pixel format=" << f.pixelFormat() + << "\n frame size=" << f.frameSize() + << "\n viewport=" << f.viewport() + << "\n yCbCrColorSpace=" << f.yCbCrColorSpace() + << "\n frameRate=" << f.frameRate() + << "\n mirrored=" << f.isMirrored(); return dbg; } diff --git a/src/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h index 417b53d8f..dca8c808c 100644 --- a/src/multimedia/video/qvideosurfaceformat.h +++ b/src/multimedia/video/qvideosurfaceformat.h @@ -71,9 +71,6 @@ public: YCbCr_xvYCC601, YCbCr_xvYCC709, YCbCr_JPEG, -#ifndef Q_QDOC - YCbCr_CustomMatrix -#endif }; QVideoSurfaceFormat(); @@ -110,10 +107,6 @@ public: qreal frameRate() const; void setFrameRate(qreal rate); - QSize pixelAspectRatio() const; - void setPixelAspectRatio(const QSize &ratio); - void setPixelAspectRatio(int width, int height); - YCbCrColorSpace yCbCrColorSpace() const; void setYCbCrColorSpace(YCbCrColorSpace colorSpace); @@ -122,10 +115,6 @@ public: QSize sizeHint() const; - QList<QByteArray> propertyNames() const; - QVariant property(const char *name) const; - void setProperty(const char *name, const QVariant &value); - private: QSharedDataPointer<QVideoSurfaceFormatPrivate> d; }; diff --git a/src/multimediawidgets/qpaintervideosurface.cpp b/src/multimediawidgets/qpaintervideosurface.cpp index 785980db8..1a48dd88b 100644 --- a/src/multimediawidgets/qpaintervideosurface.cpp +++ b/src/multimediawidgets/qpaintervideosurface.cpp @@ -146,7 +146,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGenericPainter::start(const QVideoSurf m_imageSize = format.frameSize(); m_scanLineDirection = format.scanLineDirection(); - m_mirrored = format.property("mirrored").toBool(); + m_mirrored = format.isMirrored(); const QVideoFrame::HandleType t = format.handleType(); if (t == QVideoFrame::NoHandle) { @@ -823,7 +823,7 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac } else { m_handleType = format.handleType(); m_scanLineDirection = format.scanLineDirection(); - m_mirrored = format.property("mirrored").toBool(); + m_mirrored = format.isMirrored(); m_frameSize = format.frameSize(); m_colorSpace = format.yCbCrColorSpace(); @@ -1182,7 +1182,7 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface } else { m_handleType = format.handleType(); m_scanLineDirection = format.scanLineDirection(); - m_mirrored = format.property("mirrored").toBool(); + m_mirrored = format.isMirrored(); m_frameSize = format.frameSize(); m_colorSpace = format.yCbCrColorSpace(); diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp index 562831a45..7cea41330 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput.cpp @@ -446,7 +446,6 @@ QRectF QDeclarativeVideoOutput::contentRect() const The orientation setting does not affect this rectangle. - \sa QVideoSurfaceFormat::pixelAspectRatio() \sa QVideoSurfaceFormat::viewport() */ QRectF QDeclarativeVideoOutput::sourceRect() const diff --git a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp index bc5747903..58aa840b3 100644 --- a/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp +++ b/src/qtmultimediaquicktools/qdeclarativevideooutput_render.cpp @@ -224,7 +224,7 @@ void QDeclarativeVideoBackend::updateGeometry() m_sourceTextureRect.setBottom(top); } - if (m_surfaceFormat.property("mirrored").toBool()) { + if (m_surfaceFormat.isMirrored()) { qreal left = m_sourceTextureRect.left(); m_sourceTextureRect.setLeft(m_sourceTextureRect.right()); m_sourceTextureRect.setRight(left); @@ -299,7 +299,6 @@ QSGNode *QDeclarativeVideoBackend::updatePaintNode(QSGNode *oldNode, // QSGVideoItemSurface supports (logically) anything. QVideoSurfaceFormat nodeFormat(m_frame.size(), m_frame.pixelFormat(), m_frame.handleType()); nodeFormat.setYCbCrColorSpace(m_surfaceFormat.yCbCrColorSpace()); - nodeFormat.setPixelAspectRatio(m_surfaceFormat.pixelAspectRatio()); nodeFormat.setScanLineDirection(m_surfaceFormat.scanLineDirection()); nodeFormat.setViewport(m_surfaceFormat.viewport()); nodeFormat.setFrameRate(m_surfaceFormat.frameRate()); @@ -352,18 +351,7 @@ QAbstractVideoSurface *QDeclarativeVideoBackend::videoSurface() const QRectF QDeclarativeVideoBackend::adjustedViewport() const { - const QRectF viewport = m_surfaceFormat.viewport(); - const QSizeF pixelAspectRatio = m_surfaceFormat.pixelAspectRatio(); - - if (pixelAspectRatio.isValid()) { - const qreal ratio = pixelAspectRatio.width() / pixelAspectRatio.height(); - QRectF result = viewport; - result.setX(result.x() * ratio); - result.setWidth(result.width() * ratio); - return result; - } - - return viewport; + return m_surfaceFormat.viewport(); } #if QT_CONFIG(opengl) diff --git a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp index 376e93035..c41be9aad 100644 --- a/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/multimedia/qvideoframe/tst_qvideoframe.cpp @@ -966,12 +966,6 @@ void tst_QVideoFrame::formatConversion_data() 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() diff --git a/tests/auto/unit/multimedia/qvideosurfaceformat/tst_qvideosurfaceformat.cpp b/tests/auto/unit/multimedia/qvideosurfaceformat/tst_qvideosurfaceformat.cpp index 779f8433a..22a630ebb 100644 --- a/tests/auto/unit/multimedia/qvideosurfaceformat/tst_qvideosurfaceformat.cpp +++ b/tests/auto/unit/multimedia/qvideosurfaceformat/tst_qvideosurfaceformat.cpp @@ -63,14 +63,10 @@ private slots: void scanLineDirection(); void frameRate_data(); void frameRate(); - void pixelAspectRatio_data(); - void pixelAspectRatio(); void sizeHint_data(); void sizeHint(); void yCbCrColorSpaceEnum_data(); void yCbCrColorSpaceEnum (); - void staticPropertyNames(); - void dynamicProperty(); void compare(); void copy(); void assign(); @@ -78,8 +74,6 @@ private slots: void isValid(); void copyAllParameters (); void assignAllParameters (); - - void propertyEdgeCases(); }; tst_QVideoSurfaceFormat::tst_QVideoSurfaceFormat() @@ -119,7 +113,6 @@ void tst_QVideoSurfaceFormat::constructNull() QCOMPARE(format.viewport(), QRect()); QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); QCOMPARE(format.frameRate(), 0.0); - QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); } @@ -173,19 +166,14 @@ void tst_QVideoSurfaceFormat::construct() QVideoSurfaceFormat format(frameSize, pixelFormat, handleType); QCOMPARE(format.handleType(), handleType); - QCOMPARE(format.property("handleType").value<QVideoFrame::HandleType>(), handleType); QCOMPARE(format.pixelFormat(), pixelFormat); - QCOMPARE(format.property("pixelFormat").value<QVideoFrame::PixelFormat>(), pixelFormat); QCOMPARE(format.frameSize(), frameSize); QCOMPARE(format.frameWidth(), frameSize.width()); - QCOMPARE(format.property("frameWidth").toInt(), frameSize.width()); QCOMPARE(format.frameHeight(), frameSize.height()); - QCOMPARE(format.property("frameHeight").toInt(), frameSize.height()); QCOMPARE(format.isValid(), valid); QCOMPARE(format.viewport(), viewport); QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom); QCOMPARE(format.frameRate(), 0.0); - QCOMPARE(format.pixelAspectRatio(), QSize(1, 1)); QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined); } @@ -210,32 +198,13 @@ void tst_QVideoSurfaceFormat::frameSize() QFETCH(QSize, initialSize); QFETCH(QSize, newSize); - { - QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); - - 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); + 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()); - } + format.setFrameSize(newSize); + QCOMPARE(format.frameSize(), newSize); + QCOMPARE(format.frameWidth(), newSize.width()); + QCOMPARE(format.frameHeight(), newSize.height()); } void tst_QVideoSurfaceFormat::viewport_data() @@ -269,29 +238,17 @@ void tst_QVideoSurfaceFormat::viewport() QFETCH(QSize, newSize); QFETCH(QRect, expectedViewport); - { - QRect initialViewport(QPoint(0, 0), initialSize); - - QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); - - format.setViewport(viewport); + QRect initialViewport(QPoint(0, 0), initialSize); - QCOMPARE(format.viewport(), viewport); - QCOMPARE(format.property("viewport").toRect(), viewport); + QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); - format.setFrameSize(newSize); + format.setViewport(viewport); - QCOMPARE(format.viewport(), expectedViewport); - QCOMPARE(format.property("viewport").toRect(), expectedViewport); - } - { - QVideoSurfaceFormat format(initialSize, QVideoFrame::Format_RGB32); + QCOMPARE(format.viewport(), viewport); - format.setProperty("viewport", viewport); + format.setFrameSize(newSize); - QCOMPARE(format.viewport(), viewport); - QCOMPARE(format.property("viewport").toRect(), viewport); - } + QCOMPARE(format.viewport(), expectedViewport); } void tst_QVideoSurfaceFormat::scanLineDirection_data() @@ -308,26 +265,11 @@ void tst_QVideoSurfaceFormat::scanLineDirection() QFETCH(QVideoSurfaceFormat::Direction, direction); QFETCH(QString, stringized); - { - QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); - - format.setScanLineDirection(direction); - - QCOMPARE(format.scanLineDirection(), direction); - QCOMPARE( - qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")), - direction); - } - { - QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); + QVideoSurfaceFormat format(QSize(16, 16), QVideoFrame::Format_RGB32); - format.setProperty("scanLineDirection", QVariant::fromValue(direction)); + format.setScanLineDirection(direction); - QCOMPARE(format.scanLineDirection(), direction); - QCOMPARE( - qvariant_cast<QVideoSurfaceFormat::Direction>(format.property("scanLineDirection")), - direction); - } + QCOMPARE(format.scanLineDirection(), direction); QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); qDebug() << direction; @@ -343,7 +285,6 @@ void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum_data() ADD_ENUM_TEST(YCbCr_xvYCC601); ADD_ENUM_TEST(YCbCr_xvYCC709); ADD_ENUM_TEST(YCbCr_JPEG); - ADD_ENUM_TEST(YCbCr_CustomMatrix); ADD_ENUM_TEST(YCbCr_Undefined); } @@ -353,22 +294,10 @@ void tst_QVideoSurfaceFormat::yCbCrColorSpaceEnum() QFETCH(QVideoSurfaceFormat::YCbCrColorSpace, colorspace); QFETCH(QString, stringized); - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - format.setYCbCrColorSpace(colorspace); - - QCOMPARE(format.yCbCrColorSpace(), colorspace); - QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")), - colorspace); - } - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - format.setProperty("yCbCrColorSpace", QVariant::fromValue(colorspace)); + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + format.setYCbCrColorSpace(colorspace); - QCOMPARE(format.yCbCrColorSpace(), colorspace); - QCOMPARE(qvariant_cast<QVideoSurfaceFormat::YCbCrColorSpace>(format.property("yCbCrColorSpace")), - colorspace); - } + QCOMPARE(format.yCbCrColorSpace(), colorspace); QTest::ignoreMessage(QtDebugMsg, stringized.toLatin1().constData()); qDebug() << colorspace; @@ -393,95 +322,26 @@ void tst_QVideoSurfaceFormat::frameRate() { QFETCH(qreal, frameRate); - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - - format.setFrameRate(frameRate); - - QCOMPARE(format.frameRate(), frameRate); - QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate); - } - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); + QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - format.setFrameRate(frameRate); - format.setProperty("frameRate", frameRate); + format.setFrameRate(frameRate); - QCOMPARE(format.frameRate(), frameRate); - QCOMPARE(qvariant_cast<qreal>(format.property("frameRate")), frameRate); - } -} - -void tst_QVideoSurfaceFormat::pixelAspectRatio_data() -{ - QTest::addColumn<QSize>("aspectRatio"); - - QTest::newRow("1:1") - << QSize(1, 1); - QTest::newRow("4:3") - << QSize(4, 3); - QTest::newRow("16:9") - << QSize(16, 9); -} - -void tst_QVideoSurfaceFormat::pixelAspectRatio() -{ - QFETCH(QSize, aspectRatio); - - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - format.setPixelAspectRatio(aspectRatio); - - QCOMPARE(format.pixelAspectRatio(), aspectRatio); - QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); - } - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - format.setPixelAspectRatio(aspectRatio.width(), aspectRatio.height()); - - QCOMPARE(format.pixelAspectRatio(), aspectRatio); - QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); - } - { - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - format.setProperty("pixelAspectRatio", aspectRatio); - - QCOMPARE(format.pixelAspectRatio(), aspectRatio); - QCOMPARE(format.property("pixelAspectRatio").toSize(), aspectRatio); - } + QCOMPARE(format.frameRate(), frameRate); } void tst_QVideoSurfaceFormat::sizeHint_data() { QTest::addColumn<QSize>("frameSize"); QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("aspectRatio"); QTest::addColumn<QSize>("sizeHint"); QTest::newRow("(0, 0, 1024x768), 1:1") << QSize(1024, 768) << QRect(0, 0, 1024, 768) - << QSize(1, 1) << QSize(1024, 768); - QTest::newRow("0, 0, 1024x768), 4:3") - << QSize(1024, 768) - << QRect(0, 0, 1024, 768) - << QSize(4, 3) - << QSize(1365, 768); QTest::newRow("(168, 84, 800x600), 1:1") << QSize(1024, 768) << QRect(168, 84, 800, 600) - << QSize(1, 1) - << QSize(800, 600); - QTest::newRow("(168, 84, 800x600), 4:3") - << QSize(1024, 768) - << QRect(168, 84, 800, 600) - << QSize(4, 3) - << QSize(1066, 600); - QTest::newRow("(168, 84, 800x600), 4:0") - << QSize(1024, 768) - << QRect(168, 84, 800, 600) - << QSize(4, 0) << QSize(800, 600); } @@ -489,95 +349,12 @@ void tst_QVideoSurfaceFormat::sizeHint() { QFETCH(QSize, frameSize); QFETCH(QRect, viewport); - QFETCH(QSize, aspectRatio); QFETCH(QSize, sizeHint); QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_RGB32); format.setViewport(viewport); - format.setPixelAspectRatio(aspectRatio); QCOMPARE(format.sizeHint(), sizeHint); - QCOMPARE(format.property("sizeHint").toSize(), sizeHint); -} - -void tst_QVideoSurfaceFormat::staticPropertyNames() -{ - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - - QList<QByteArray> propertyNames = format.propertyNames(); - - QVERIFY(propertyNames.contains("handleType")); - QVERIFY(propertyNames.contains("pixelFormat")); - QVERIFY(propertyNames.contains("frameSize")); - QVERIFY(propertyNames.contains("frameWidth")); - QVERIFY(propertyNames.contains("viewport")); - QVERIFY(propertyNames.contains("scanLineDirection")); - QVERIFY(propertyNames.contains("frameRate")); - QVERIFY(propertyNames.contains("pixelAspectRatio")); - QVERIFY(propertyNames.contains("yCbCrColorSpace")); - QVERIFY(propertyNames.contains("sizeHint")); - QVERIFY(propertyNames.contains("mirrored")); - QCOMPARE(propertyNames.count(), 11); -} - -void tst_QVideoSurfaceFormat::dynamicProperty() -{ - QVideoSurfaceFormat format(QSize(64, 64), QVideoFrame::Format_RGB32); - - QCOMPARE(format.property("integer"), QVariant()); - QCOMPARE(format.property("size"), QVariant()); - QCOMPARE(format.property("string"), QVariant()); - QCOMPARE(format.property("null"), QVariant()); - - QList<QByteArray> propertyNames = format.propertyNames(); - - QCOMPARE(propertyNames.count(QByteArray("integer")), 0); - QCOMPARE(propertyNames.count(QByteArray("string")), 0); - QCOMPARE(propertyNames.count(QByteArray("size")), 0); - QCOMPARE(propertyNames.count(QByteArray("null")), 0); - - format.setProperty("string", QString::fromLatin1("Hello")); - format.setProperty("integer", 198); - format.setProperty("size", QSize(43, 65)); - - QCOMPARE(format.property("integer").toInt(), 198); - QCOMPARE(format.property("size").toSize(), QSize(43, 65)); - QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello")); - - propertyNames = format.propertyNames(); - - QCOMPARE(propertyNames.count(QByteArray("integer")), 1); - QCOMPARE(propertyNames.count(QByteArray("string")), 1); - QCOMPARE(propertyNames.count(QByteArray("size")), 1); - - format.setProperty("integer", 125423); - format.setProperty("size", QSize(1, 986)); - - QCOMPARE(format.property("integer").toInt(), 125423); - QCOMPARE(format.property("size").toSize(), QSize(1, 986)); - QCOMPARE(format.property("string").toString(), QString::fromLatin1("Hello")); - - propertyNames = format.propertyNames(); - - QCOMPARE(propertyNames.count(QByteArray("integer")), 1); - QCOMPARE(propertyNames.count(QByteArray("string")), 1); - QCOMPARE(propertyNames.count(QByteArray("size")), 1); - - format.setProperty("string", QVariant()); - format.setProperty("size", QVariant()); - format.setProperty("null", QVariant()); - - QCOMPARE(format.property("integer").toInt(), 125423); - QCOMPARE(format.property("size"), QVariant()); - QCOMPARE(format.property("string"), QVariant()); - QCOMPARE(format.property("null"), QVariant()); - - propertyNames = format.propertyNames(); - - QCOMPARE(propertyNames.count(QByteArray("integer")), 1); - QCOMPARE(propertyNames.count(QByteArray("string")), 0); - QCOMPARE(propertyNames.count(QByteArray("size")), 0); - QCOMPARE(propertyNames.count(QByteArray("null")), 0); } void tst_QVideoSurfaceFormat::compare() @@ -647,18 +424,6 @@ void tst_QVideoSurfaceFormat::compare() QCOMPARE(format1 == format2, true); QCOMPARE(format1 != format2, false); - format2.setPixelAspectRatio(4, 3); - - // Not equal pixel aspect ratio differs. - QCOMPARE(format1 == format2, false); - QCOMPARE(format1 != format2, true); - - format1.setPixelAspectRatio(QSize(4, 3)); - - // Equal. - QCOMPARE(format1 == format2, true); - QCOMPARE(format1 != format2, false); - format2.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC601); // Not equal yuv color space differs. @@ -670,44 +435,6 @@ void tst_QVideoSurfaceFormat::compare() // Equal. QCOMPARE(format1 == format2, true); QCOMPARE(format1 != format2, false); - - format1.setProperty("integer", 12); - - // Not equal, property mismatch. - QCOMPARE(format1 == format2, false); - QCOMPARE(format1 != format2, true); - - format2.setProperty("integer", 45); - - // Not equal, integer differs. - QCOMPARE(format1 == format2, false); - QCOMPARE(format1 != format2, true); - - format2.setProperty("integer", 12); - - // Equal. - QCOMPARE(format1 == format2, true); - QCOMPARE(format1 != format2, false); - - format1.setProperty("string", QString::fromLatin1("Hello")); - format2.setProperty("size", QSize(12, 54)); - - // Not equal, property mismatch. - QCOMPARE(format1 == format2, false); - QCOMPARE(format1 != format2, true); - - format2.setProperty("string", QString::fromLatin1("Hello")); - format1.setProperty("size", QSize(12, 54)); - - // Equal. - QCOMPARE(format1 == format2, true); - QCOMPARE(format1 != format2, false); - - format1.setProperty("string", QVariant()); - - // Not equal, property mismatch. - QCOMPARE(format1 == format2, false); - QCOMPARE(format1 != format2, true); } @@ -799,7 +526,6 @@ void tst_QVideoSurfaceFormat::copyAllParameters() original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); original.setViewport(QRect(0, 0, 1024, 1024)); original.setFrameRate(qreal(15.0)); - original.setPixelAspectRatio(QSize(320,480)); original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709); /* Copy the original instance to copy and verify if both the instances @@ -812,7 +538,6 @@ void tst_QVideoSurfaceFormat::copyAllParameters() QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024)); QCOMPARE(copy.frameRate(), qreal(15.0)); - QCOMPARE(copy.pixelAspectRatio(), QSize(320,480)); QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709); /* Verify if both the instances are eqaul */ @@ -829,7 +554,6 @@ void tst_QVideoSurfaceFormat::assignAllParameters() copy.setScanLineDirection(QVideoSurfaceFormat::TopToBottom); copy.setViewport(QRect(0, 0, 640, 320)); copy.setFrameRate(qreal(7.5)); - copy.setPixelAspectRatio(QSize(640,320)); copy.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT601); /* Create the instance and set all the parameters. */ @@ -838,7 +562,6 @@ void tst_QVideoSurfaceFormat::assignAllParameters() original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); original.setViewport(QRect(0, 0, 1024, 1024)); original.setFrameRate(qreal(15.0)); - original.setPixelAspectRatio(QSize(320,480)); original.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_BT709); /* Assign the original instance to copy and verify if both the instancess @@ -851,7 +574,6 @@ void tst_QVideoSurfaceFormat::assignAllParameters() QCOMPARE(copy.scanLineDirection(), QVideoSurfaceFormat::BottomToTop); QCOMPARE(copy.viewport(), QRect(0, 0, 1024, 1024)); QCOMPARE(copy.frameRate(), qreal(15.0)); - QCOMPARE(copy.pixelAspectRatio(), QSize(320,480)); QCOMPARE(copy.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_BT709); /* Verify if both the instances are eqaul */ @@ -859,52 +581,6 @@ void tst_QVideoSurfaceFormat::assignAllParameters() 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, QVideoFrame::GLTextureHandle); - - original.setProperty("handleType", QVideoFrame::NoHandle); - QCOMPARE(original.handleType(), QVideoFrame::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", QColor(Qt::red)); - QCOMPARE(original.frameSize(), QSize(1024, 768)); - - original.setProperty("viewport", QColor(Qt::red)); - QCOMPARE(original.viewport(), QRect(0, 0, 1024, 768)); - - original.setScanLineDirection(QVideoSurfaceFormat::BottomToTop); - original.setProperty("scanLineDirection", QColor(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", QColor(Qt::red)); - QCOMPARE(original.pixelAspectRatio(), QSize(53, 45)); -} - - QTEST_MAIN(tst_QVideoSurfaceFormat) diff --git a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp index f7c5ae6a9..a4699cb0c 100644 --- a/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp +++ b/tests/auto/unit/multimediawidgets/qgraphicsvideoitem/tst_qgraphicsvideoitem.cpp @@ -359,33 +359,23 @@ void tst_QGraphicsVideoItem::nativeSize_data() { QTest::addColumn<QSize>("frameSize"); QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("pixelAspectRatio"); QTest::addColumn<QSizeF>("nativeSize"); QTest::newRow("640x480") << QSize(640, 480) << QRect(0, 0, 640, 480) - << QSize(1, 1) << QSizeF(640, 480); QTest::newRow("800x600, (80,60, 640x480) viewport") << QSize(800, 600) << QRect(80, 60, 640, 480) - << QSize(1, 1) << QSizeF(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSizeF(853, 480); } void tst_QGraphicsVideoItem::nativeSize() { QFETCH(QSize, frameSize); QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); QFETCH(QSizeF, nativeSize); QtTestVideoObject object(new QtTestRendererControl); @@ -398,7 +388,6 @@ void tst_QGraphicsVideoItem::nativeSize() QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); { // Surface setup is deferred until after the first paint. QImage image(320, 240, QImage::Format_RGB32); diff --git a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp index f2d1a249b..5e36dd322 100644 --- a/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp +++ b/tests/auto/unit/multimediawidgets/qvideowidget/tst_qvideowidget.cpp @@ -225,27 +225,17 @@ void tst_QVideoWidget::sizeHintWindowControl_data() QTest::addColumn<QSize>("frameSize"); QTest::addColumn<QRect>("viewport"); - QTest::addColumn<QSize>("pixelAspectRatio"); QTest::addColumn<QSize>("expectedSize"); QTest::newRow("640x480") << QSize(640, 480) << QRect(0, 0, 640, 480) - << QSize(1, 1) << QSize(640, 480); QTest::newRow("800x600, (80,60, 640x480) viewport") << QSize(800, 600) << QRect(80, 60, 640, 480) - << QSize(1, 1) << QSize(640, 480); - - QTest::newRow("800x600, (80,60, 640x480) viewport, 4:3") - << QSize(800, 600) - << QRect(80, 60, 640, 480) - << QSize(4, 3) - << QSize(853, 480); - } void tst_QVideoWidget::sizeHintWindowControl() @@ -256,7 +246,6 @@ void tst_QVideoWidget::sizeHintWindowControl() QFETCH(QSize, frameSize); QFETCH(QRect, viewport); - QFETCH(QSize, pixelAspectRatio); QFETCH(QSize, expectedSize); QtTestVideoObject object(nullptr, new QtTestRendererControl); @@ -268,7 +257,6 @@ void tst_QVideoWidget::sizeHintWindowControl() QVideoSurfaceFormat format(frameSize, QVideoFrame::Format_ARGB32); format.setViewport(viewport); - format.setPixelAspectRatio(pixelAspectRatio); QVERIFY(object.testService->rendererControl->surface()->start(format)); |