1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QVIDEOFRAME_H
41#define QVIDEOFRAME_H
42
43#include <QtCore/qmetatype.h>
44#include <QtCore/qshareddata.h>
45#include <QtGui/qimage.h>
46#include <QtMultimedia/qabstractvideobuffer.h>
47#include <QtCore/qvariant.h>
48
49QT_BEGIN_NAMESPACE
50
51class QSize;
52
53class QVideoFramePrivate;
54
55class Q_MULTIMEDIA_EXPORT QVideoFrame
56{
57public:
58 enum FieldType
59 {
60 ProgressiveFrame,
61 TopField,
62 BottomField,
63 InterlacedFrame
64 };
65
66 enum PixelFormat
67 {
68 Format_Invalid,
69 Format_ARGB32,
70 Format_ARGB32_Premultiplied,
71 Format_RGB32,
72 Format_RGB24,
73 Format_RGB565,
74 Format_RGB555,
75 Format_ARGB8565_Premultiplied,
76 Format_BGRA32,
77 Format_BGRA32_Premultiplied,
78 Format_BGR32,
79 Format_BGR24,
80 Format_BGR565,
81 Format_BGR555,
82 Format_BGRA5658_Premultiplied,
83
84 Format_AYUV444,
85 Format_AYUV444_Premultiplied,
86 Format_YUV444,
87 Format_YUV420P,
88 Format_YV12,
89 Format_UYVY,
90 Format_YUYV,
91 Format_NV12,
92 Format_NV21,
93 Format_IMC1,
94 Format_IMC2,
95 Format_IMC3,
96 Format_IMC4,
97 Format_Y8,
98 Format_Y16,
99
100 Format_Jpeg,
101
102 Format_CameraRaw,
103 Format_AdobeDng,
104 Format_ABGR32, // ### Qt 6: reorder
105 Format_YUV422P,
106
107#ifndef Q_QDOC
108 NPixelFormats,
109#endif
110 Format_User = 1000
111 };
112
113 QVideoFrame();
114 QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format);
115 QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format);
116 QVideoFrame(const QImage &image);
117 QVideoFrame(const QVideoFrame &other);
118 ~QVideoFrame();
119
120 QVideoFrame &operator =(const QVideoFrame &other);
121 bool operator==(const QVideoFrame &other) const;
122 bool operator!=(const QVideoFrame &other) const;
123
124 QAbstractVideoBuffer *buffer() const;
125 bool isValid() const;
126
127 PixelFormat pixelFormat() const;
128
129 QAbstractVideoBuffer::HandleType handleType() const;
130
131 QSize size() const;
132 int width() const;
133 int height() const;
134
135 FieldType fieldType() const;
136 void setFieldType(FieldType);
137
138 bool isMapped() const;
139 bool isReadable() const;
140 bool isWritable() const;
141
142 QAbstractVideoBuffer::MapMode mapMode() const;
143
144 bool map(QAbstractVideoBuffer::MapMode mode);
145 void unmap();
146
147 int bytesPerLine() const;
148 int bytesPerLine(int plane) const;
149
150 uchar *bits();
151 uchar *bits(int plane);
152 const uchar *bits() const;
153 const uchar *bits(int plane) const;
154 int mappedBytes() const;
155 int planeCount() const;
156
157 QVariant handle() const;
158
159 qint64 startTime() const;
160 void setStartTime(qint64 time);
161
162 qint64 endTime() const;
163 void setEndTime(qint64 time);
164
165 QVariantMap availableMetaData() const;
166 QVariant metaData(const QString &key) const;
167 void setMetaData(const QString &key, const QVariant &value);
168
169 QImage image() const;
170
171 static PixelFormat pixelFormatFromImageFormat(QImage::Format format);
172 static QImage::Format imageFormatFromPixelFormat(PixelFormat format);
173
174private:
175 QExplicitlySharedDataPointer<QVideoFramePrivate> d;
176};
177
178#ifndef QT_NO_DEBUG_STREAM
179Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoFrame&);
180Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::FieldType);
181Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::PixelFormat);
182#endif
183
184QT_END_NAMESPACE
185
186Q_DECLARE_METATYPE(QVideoFrame)
187Q_DECLARE_METATYPE(QVideoFrame::FieldType)
188Q_DECLARE_METATYPE(QVideoFrame::PixelFormat)
189
190#endif
191
192

source code of qtmultimedia/src/multimedia/video/qvideoframe.h