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_ABGR32,
79 Format_BGR32,
80 Format_BGR24,
81 Format_BGR565,
82 Format_BGR555,
83 Format_BGRA5658_Premultiplied,
84
85 Format_AYUV444,
86 Format_AYUV444_Premultiplied,
87 Format_YUV444,
88 Format_YUV420P,
89 Format_YUV422P,
90 Format_YV12,
91 Format_UYVY,
92 Format_YUYV,
93 Format_NV12,
94 Format_NV21,
95 Format_IMC1,
96 Format_IMC2,
97 Format_IMC3,
98 Format_IMC4,
99 Format_Y8,
100 Format_Y16,
101
102 Format_Jpeg,
103
104 Format_CameraRaw,
105 Format_AdobeDng,
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 static PixelFormat pixelFormatFromImageFormat(QImage::Format format);
170 static QImage::Format imageFormatFromPixelFormat(PixelFormat format);
171
172private:
173 QExplicitlySharedDataPointer<QVideoFramePrivate> d;
174};
175
176#ifndef QT_NO_DEBUG_STREAM
177Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoFrame&);
178Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::FieldType);
179Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrame::PixelFormat);
180#endif
181
182QT_END_NAMESPACE
183
184Q_DECLARE_METATYPE(QVideoFrame)
185Q_DECLARE_METATYPE(QVideoFrame::FieldType)
186Q_DECLARE_METATYPE(QVideoFrame::PixelFormat)
187
188#endif
189
190