diff options
author | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-10-11 11:51:14 +0200 |
---|---|---|
committer | VaL Doroshchuk <valentyn.doroshchuk@qt.io> | 2019-10-31 09:49:49 +0100 |
commit | 59d0683c999bec5612f6ba91867bde4d02185204 (patch) | |
tree | a8bcd49d8044d2b9a76699137ad763a11a5464bb /src/multimedia | |
parent | 71e2096c2b704420cbb0ee836c16565b658b3d0f (diff) |
Introduce QVideoFrame::image()
Since QVideoFrame::pixelFormat's do not 100% match QImage::Format's,
introducing converstion function.
Returns an image based on current frame.
Converts data if needed to supported QImage format.
Change-Id: I3331578c01cf9c999a380efc4a83bf9eddb07901
(cherry picked from commit 93f966335e1ed8ed47b7e8b32452d43c2f8a7bb1)
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/multimedia')
-rw-r--r-- | src/multimedia/video/qvideoframe.cpp | 8 | ||||
-rw-r--r-- | src/multimedia/video/qvideoframe.h | 2 | ||||
-rw-r--r-- | src/multimedia/video/qvideoframe_p.h | 63 | ||||
-rw-r--r-- | src/multimedia/video/video.pri | 1 |
4 files changed, 6 insertions, 68 deletions
diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index 5e2d6df39..fd7b74075 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -39,7 +39,6 @@ #include "qvideoframe.h" -#include "qvideoframe_p.h" #include "qimagevideobuffer_p.h" #include "qmemoryvideobuffer_p.h" #include "qvideoframeconversionhelper_p.h" @@ -1112,11 +1111,12 @@ static void qInitConvertFuncsAsm() } /*! - \internal + Based on the pixel format converts current video frame to image. + \since 5.15 */ -QImage qt_imageFromVideoFrame(const QVideoFrame &f) +QImage QVideoFrame::image() const { - QVideoFrame &frame = const_cast<QVideoFrame&>(f); + QVideoFrame frame = *this; QImage result; if (!frame.isValid() || !frame.map(QAbstractVideoBuffer::ReadOnly)) diff --git a/src/multimedia/video/qvideoframe.h b/src/multimedia/video/qvideoframe.h index 8fcf47fc4..d043442a3 100644 --- a/src/multimedia/video/qvideoframe.h +++ b/src/multimedia/video/qvideoframe.h @@ -166,6 +166,8 @@ public: QVariant metaData(const QString &key) const; void setMetaData(const QString &key, const QVariant &value); + QImage image() const; + static PixelFormat pixelFormatFromImageFormat(QImage::Format format); static QImage::Format imageFormatFromPixelFormat(PixelFormat format); diff --git a/src/multimedia/video/qvideoframe_p.h b/src/multimedia/video/qvideoframe_p.h deleted file mode 100644 index d7b9dd348..000000000 --- a/src/multimedia/video/qvideoframe_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QVIDEOFRAME_P_H -#define QVIDEOFRAME_P_H - -#include <QtMultimedia/qvideoframe.h> - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -QT_BEGIN_NAMESPACE - -Q_MULTIMEDIA_EXPORT QImage qt_imageFromVideoFrame(const QVideoFrame &frame); - -QT_END_NAMESPACE - -#endif // QVIDEOFRAME_P_H - diff --git a/src/multimedia/video/video.pri b/src/multimedia/video/video.pri index e5fa697ce..3a73c5045 100644 --- a/src/multimedia/video/video.pri +++ b/src/multimedia/video/video.pri @@ -15,7 +15,6 @@ PRIVATE_HEADERS += \ video/qmemoryvideobuffer_p.h \ video/qvideooutputorientationhandler_p.h \ video/qvideosurfaceoutput_p.h \ - video/qvideoframe_p.h \ video/qvideoframeconversionhelper_p.h SOURCES += \ |