diff options
Diffstat (limited to 'src/multimedia/video/qvideoframeformat.cpp')
-rw-r--r-- | src/multimedia/video/qvideoframeformat.cpp | 105 |
1 files changed, 60 insertions, 45 deletions
diff --git a/src/multimedia/video/qvideoframeformat.cpp b/src/multimedia/video/qvideoframeformat.cpp index ead8a4655..b3177234f 100644 --- a/src/multimedia/video/qvideoframeformat.cpp +++ b/src/multimedia/video/qvideoframeformat.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qvideoframeformat.h" #include "qvideotexturehelper_p.h" @@ -48,7 +12,7 @@ #include <qmatrix4x4.h> static void initResource() { - Q_INIT_RESOURCE(shaders); + Q_INIT_RESOURCE(qtmultimedia_shaders); } QT_BEGIN_NAMESPACE @@ -75,7 +39,8 @@ public: && viewport == other.viewport && frameRatesEqual(frameRate, other.frameRate) && colorSpace == other.colorSpace - && mirrored == other.mirrored) + && mirrored == other.mirrored + && rotation == other.rotation) return true; return false; @@ -96,6 +61,7 @@ public: float frameRate = 0.0; float maxLuminance = -1.; bool mirrored = false; + QtVideo::Rotation rotation = QtVideo::Rotation::None; }; QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QVideoFrameFormatPrivate); @@ -112,7 +78,7 @@ QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QVideoFrameFormatPrivate); A video sink presents a stream of video frames. QVideoFrameFormat describes the type of the frames and determines how they should be presented. - The core properties of a video stream required to setup a video sink are the pixel format + The core properties of a video stream required to set up a video sink are the pixel format given by pixelFormat(), and the frame dimensions given by frameSize(). The region of a frame that is actually displayed on a video surface is given by the viewport(). @@ -408,6 +374,12 @@ QVideoFrameFormat::QVideoFrameFormat(const QVideoFrameFormat &other) = default; */ /*! + \fn void QVideoFrameFormat::swap(QVideoFrameFormat &other) noexcept + + Swaps the current video frame format with the \a other. +*/ + +/*! Assigns the values of \a other to this object. */ QVideoFrameFormat &QVideoFrameFormat::operator =(const QVideoFrameFormat &other) = default; @@ -568,12 +540,13 @@ void QVideoFrameFormat::setScanLineDirection(Direction direction) d->scanLineDirection = direction; } +#if QT_DEPRECATED_SINCE(6, 8) /*! Returns the frame rate of a video stream in frames per second. */ qreal QVideoFrameFormat::frameRate() const { - return d->frameRate; + return streamFrameRate(); } /*! @@ -581,10 +554,28 @@ qreal QVideoFrameFormat::frameRate() const */ void QVideoFrameFormat::setFrameRate(qreal rate) { + setStreamFrameRate(rate); +} +#endif + +/*! + Returns the frame rate of a video stream in frames per second. +*/ +qreal QVideoFrameFormat::streamFrameRate() const +{ + return d->frameRate; +} + +/*! + Sets the frame \a rate of a video stream in frames per second. +*/ +void QVideoFrameFormat::setStreamFrameRate(qreal rate) +{ detach(); d->frameRate = rate; } +#if QT_DEPRECATED_SINCE(6, 4) /*! \deprecated Use colorSpace() instead @@ -606,6 +597,7 @@ void QVideoFrameFormat::setYCbCrColorSpace(QVideoFrameFormat::YCbCrColorSpace sp detach(); d->colorSpace = ColorSpace(space); } +#endif // QT_DEPRECATED_SINCE(6, 4) /*! Returns the color space of a video stream. @@ -693,6 +685,23 @@ void QVideoFrameFormat::setMirrored(bool mirrored) } /*! + Returns the rotation angle the matching video frame should be rotated clockwise before displaying. + */ +QtVideo::Rotation QVideoFrameFormat::rotation() const +{ + return d->rotation; +} + +/*! + Sets the \a rotation angle the matching video frame should be rotated clockwise before displaying. + */ +void QVideoFrameFormat::setRotation(QtVideo::Rotation rotation) +{ + detach(); + d->rotation = rotation; +} + +/*! \internal */ QString QVideoFrameFormat::vertexShaderFileName() const @@ -733,7 +742,9 @@ float QVideoFrameFormat::maxLuminance() const } return d->maxLuminance; } - +/*! + Sets the maximum luminance to the given value, \a lum. +*/ void QVideoFrameFormat::setMaxLuminance(float lum) { detach(); @@ -769,7 +780,9 @@ QVideoFrameFormat::PixelFormat QVideoFrameFormat::pixelFormatFromImageFormat(QIm case QImage::Format_RGBA8888: return QVideoFrameFormat::Format_RGBA8888; case QImage::Format_RGBA8888_Premultiplied: - return QVideoFrameFormat::Format_ARGB8888_Premultiplied; + // QVideoFrameFormat::Format_RGBA8888_Premultiplied is to be added in 6.8 + // Format_RGBX8888 suits the best as a workaround + return QVideoFrameFormat::Format_RGBX8888; case QImage::Format_RGBX8888: return QVideoFrameFormat::Format_RGBX8888; case QImage::Format_Grayscale8: @@ -925,6 +938,7 @@ QString QVideoFrameFormat::pixelFormatToString(QVideoFrameFormat::PixelFormat pi } #ifndef QT_NO_DEBUG_STREAM +# if QT_DEPRECATED_SINCE(6, 4) QDebug operator<<(QDebug dbg, QVideoFrameFormat::YCbCrColorSpace cs) { QDebugStateSaver saver(dbg); @@ -954,6 +968,7 @@ QDebug operator<<(QDebug dbg, QVideoFrameFormat::YCbCrColorSpace cs) } return dbg; } +# endif // QT_DEPRECATED_SINCE(6, 4) QDebug operator<<(QDebug dbg, QVideoFrameFormat::ColorSpace cs) { @@ -1006,7 +1021,7 @@ QDebug operator<<(QDebug dbg, const QVideoFrameFormat &f) << "\n frame size=" << f.frameSize() << "\n viewport=" << f.viewport() << "\n colorSpace=" << f.colorSpace() - << "\n frameRate=" << f.frameRate() + << "\n frameRate=" << f.streamFrameRate() << "\n mirrored=" << f.isMirrored(); return dbg; |