diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2009-10-15 02:26:03 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2009-10-15 03:34:17 (GMT) |
commit | 162dd5b9360a362a78e77387ed92c49934201a32 (patch) | |
tree | ee940b68481e8b15f3692709b924758358817d9a /src | |
parent | 03c587f510f2a5f9126b53a0c3913ac06bb86c79 (diff) | |
download | Qt-162dd5b9360a362a78e77387ed92c49934201a32.zip Qt-162dd5b9360a362a78e77387ed92c49934201a32.tar.gz Qt-162dd5b9360a362a78e77387ed92c49934201a32.tar.bz2 |
Change the frame rate property to a qreal from a QPair<int,int> rational
While a rational number is a common way to represent a frame rate,
QPair<int, int> isn't a proper numeric type meaning it can't be used as
anything more than an identifer for an exact frame rate without being
converted to a real, or extending it to a proper rational type.
Rev by: Justin McPherson
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/video/qvideosurfaceformat.cpp | 51 | ||||
-rw-r--r-- | src/multimedia/video/qvideosurfaceformat.h | 8 |
2 files changed, 17 insertions, 42 deletions
diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index 2b0de96..e6ef8f3 100644 --- a/src/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -58,7 +58,7 @@ public: , scanLineDirection(QVideoSurfaceFormat::TopToBottom) , pixelAspectRatio(1, 1) , yuvColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) - , frameRate(0, 0) + , frameRate(0.0) { } @@ -73,7 +73,7 @@ public: , pixelAspectRatio(1, 1) , yuvColorSpace(QVideoSurfaceFormat::YCbCr_Undefined) , viewport(QPoint(0, 0), size) - , frameRate(0, 0) + , frameRate(0.0) { } @@ -100,7 +100,7 @@ public: && frameSize == other.frameSize && pixelAspectRatio == other.pixelAspectRatio && viewport == other.viewport - && frameRate == other.frameRate + && frameRatesEqual(frameRate, other.frameRate) && yuvColorSpace == other.yuvColorSpace && propertyNames.count() == other.propertyNames.count()) { for (int i = 0; i < propertyNames.count(); ++i) { @@ -115,6 +115,11 @@ public: } } + inline static bool frameRatesEqual(qreal r1, qreal r2) + { + return qAbs(r1 - r2) <= 0.00001 * qMin(qAbs(r1), qAbs(r2)); + } + QVideoFrame::PixelFormat pixelFormat; QAbstractVideoBuffer::HandleType handleType; QVideoSurfaceFormat::Direction scanLineDirection; @@ -122,7 +127,7 @@ public: QSize pixelAspectRatio; QVideoSurfaceFormat::YuvColorSpace yuvColorSpace; QRect viewport; - QVideoSurfaceFormat::FrameRate frameRate; + qreal frameRate; QList<QByteArray> propertyNames; QList<QVariant> propertyValues; }; @@ -201,15 +206,6 @@ public: The full range Y'CbCr color space used in JPEG files. */ - -/*! - \typedef QVideoSurfaceFormat::FrameRate - - A pair of integers representing the frame rate of a video stream. - - The first number is the numerator and the second the denominator. -*/ - /*! Constructs a null video stream format. */ @@ -415,41 +411,24 @@ void QVideoSurfaceFormat::setScanLineDirection(Direction direction) } /*! - Returns the frame rate of a video stream. - - The frame rate is a rational number represented by a pair of integers. - The first integer is the numerator and the second the denominator. + Returns the frame rate of a video stream in frames per second. */ -QVideoSurfaceFormat::FrameRate QVideoSurfaceFormat::frameRate() const +qreal QVideoSurfaceFormat::frameRate() const { return d->frameRate; } /*! - Sets the frame \a rate of a video stream. - - The frame rate is a rational number represented by a pair of integers. - The first integer is the numerator and the second the denominator. + Sets the frame \a rate of a video stream in frames per second. */ -void QVideoSurfaceFormat::setFrameRate(const FrameRate &rate) +void QVideoSurfaceFormat::setFrameRate(qreal rate) { d->frameRate = rate; } /*! - \overload - - Sets the \a numerator and \a denominator of the frame rate of a video stream. -*/ - -void QVideoSurfaceFormat::setFrameRate(int numerator, int denominator) -{ - d->frameRate = qMakePair(numerator, denominator); -} - -/*! Returns a video stream's pixel aspect ratio. */ @@ -599,8 +578,8 @@ void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) if (qVariantCanConvert<Direction>(value)) d->scanLineDirection = qvariant_cast<Direction>(value); } else if (qstrcmp(name, "frameRate") == 0) { - if (qVariantCanConvert<FrameRate>(value)) - d->frameRate = qvariant_cast<FrameRate>(value); + if (qVariantCanConvert<qreal>(value)) + d->frameRate = qvariant_cast<qreal>(value); } else if (qstrcmp(name, "pixelAspectRatio") == 0) { if (qVariantCanConvert<QSize>(value)) d->pixelAspectRatio = qvariant_cast<QSize>(value); diff --git a/src/multimedia/video/qvideosurfaceformat.h b/src/multimedia/video/qvideosurfaceformat.h index b3005bd..1f4a5cb 100644 --- a/src/multimedia/video/qvideosurfaceformat.h +++ b/src/multimedia/video/qvideosurfaceformat.h @@ -87,8 +87,6 @@ public: #endif }; - typedef QPair<int, int> FrameRate; - QVideoSurfaceFormat(); QVideoSurfaceFormat( const QSize &size, @@ -120,9 +118,8 @@ public: Direction scanLineDirection() const; void setScanLineDirection(Direction direction); - FrameRate frameRate() const; - void setFrameRate(const FrameRate &rate); - void setFrameRate(int numerator, int denominator = 1); + qreal frameRate() const; + void setFrameRate(qreal rate); QSize pixelAspectRatio() const; void setPixelAspectRatio(const QSize &ratio); @@ -147,7 +144,6 @@ Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoSurfaceFormat &); QT_END_NAMESPACE -Q_DECLARE_METATYPE(QVideoSurfaceFormat::FrameRate) Q_DECLARE_METATYPE(QVideoSurfaceFormat::Direction) Q_DECLARE_METATYPE(QVideoSurfaceFormat::YuvColorSpace) |