1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QVIDEOSURFACEFORMAT_H
5#define QVIDEOSURFACEFORMAT_H
6
7#include <QtMultimedia/qtmultimediaglobal.h>
8#include <QtMultimedia/qtvideo.h>
9
10#include <QtCore/qlist.h>
11#include <QtCore/qmetatype.h>
12#include <QtCore/qshareddata.h>
13#include <QtCore/qsize.h>
14#include <QtGui/qimage.h>
15
16QT_BEGIN_NAMESPACE
17
18
19class QDebug;
20
21class QVideoFrameFormatPrivate;
22class QVideoFrame;
23class QMatrix4x4;
24
25QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QVideoFrameFormatPrivate, Q_MULTIMEDIA_EXPORT)
26
27class Q_MULTIMEDIA_EXPORT QVideoFrameFormat
28{
29 Q_GADGET
30public:
31 enum PixelFormat
32 {
33 Format_Invalid,
34 Format_ARGB8888,
35 Format_ARGB8888_Premultiplied,
36 Format_XRGB8888,
37 Format_BGRA8888,
38 Format_BGRA8888_Premultiplied,
39 Format_BGRX8888,
40 Format_ABGR8888,
41 Format_XBGR8888,
42 Format_RGBA8888,
43 Format_RGBX8888,
44
45 Format_AYUV,
46 Format_AYUV_Premultiplied,
47 Format_YUV420P,
48 Format_YUV422P,
49 Format_YV12,
50 Format_UYVY,
51 Format_YUYV,
52 Format_NV12,
53 Format_NV21,
54 Format_IMC1,
55 Format_IMC2,
56 Format_IMC3,
57 Format_IMC4,
58 Format_Y8,
59 Format_Y16,
60
61 Format_P010,
62 Format_P016,
63
64 Format_SamplerExternalOES,
65 Format_Jpeg,
66 Format_SamplerRect,
67
68 Format_YUV420P10
69 };
70 Q_ENUM(PixelFormat)
71#ifndef Q_QDOC
72 static constexpr int NPixelFormats = Format_YUV420P10 + 1;
73#endif
74
75 enum Direction
76 {
77 TopToBottom,
78 BottomToTop
79 };
80
81#if QT_DEPRECATED_SINCE(6, 4)
82 enum YCbCrColorSpace
83 {
84 YCbCr_Undefined = 0,
85 YCbCr_BT601 = 1,
86 YCbCr_BT709 = 2,
87 YCbCr_xvYCC601 = 3,
88 YCbCr_xvYCC709 = 4,
89 YCbCr_JPEG = 5,
90 YCbCr_BT2020 = 6
91 };
92#endif
93
94 // Keep values compatible with YCbCrColorSpace
95 enum ColorSpace
96 {
97 ColorSpace_Undefined = 0,
98 ColorSpace_BT601 = 1,
99 ColorSpace_BT709 = 2,
100 ColorSpace_AdobeRgb = 5,
101 ColorSpace_BT2020 = 6
102 };
103
104 enum ColorTransfer
105 {
106 ColorTransfer_Unknown,
107 ColorTransfer_BT709,
108 ColorTransfer_BT601,
109 ColorTransfer_Linear,
110 ColorTransfer_Gamma22,
111 ColorTransfer_Gamma28,
112 ColorTransfer_ST2084,
113 ColorTransfer_STD_B67,
114 };
115
116 enum ColorRange
117 {
118 ColorRange_Unknown,
119 ColorRange_Video,
120 ColorRange_Full
121 };
122
123 QVideoFrameFormat();
124 QVideoFrameFormat(const QSize &size, PixelFormat pixelFormat);
125 QVideoFrameFormat(const QVideoFrameFormat &format);
126 ~QVideoFrameFormat();
127
128 QVideoFrameFormat(QVideoFrameFormat &&other) noexcept = default;
129 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QVideoFrameFormat);
130 void swap(QVideoFrameFormat &other) noexcept
131 { d.swap(other&: other.d); }
132
133 void detach();
134
135 QVideoFrameFormat &operator=(const QVideoFrameFormat &format);
136
137 bool operator==(const QVideoFrameFormat &format) const;
138 bool operator!=(const QVideoFrameFormat &format) const;
139
140 bool isValid() const;
141
142 QVideoFrameFormat::PixelFormat pixelFormat() const;
143
144 QSize frameSize() const;
145 void setFrameSize(const QSize &size);
146 void setFrameSize(int width, int height);
147
148 int frameWidth() const;
149 int frameHeight() const;
150
151 int planeCount() const;
152
153 QRect viewport() const;
154 void setViewport(const QRect &viewport);
155
156 Direction scanLineDirection() const;
157 void setScanLineDirection(Direction direction);
158
159#if QT_DEPRECATED_SINCE(6, 8)
160 QT_DEPRECATED_VERSION_X_6_8("Use streamFrameRate()")
161 qreal frameRate() const;
162 QT_DEPRECATED_VERSION_X_6_8("Use setStreamFrameRate()")
163 void setFrameRate(qreal rate);
164#endif
165
166 qreal streamFrameRate() const;
167 void setStreamFrameRate(qreal rate);
168
169#if QT_DEPRECATED_SINCE(6, 4)
170 QT_DEPRECATED_VERSION_X_6_4("Use colorSpace()")
171 YCbCrColorSpace yCbCrColorSpace() const;
172 QT_DEPRECATED_VERSION_X_6_4("Use setColorSpace()")
173 void setYCbCrColorSpace(YCbCrColorSpace colorSpace);
174#endif
175
176 ColorSpace colorSpace() const;
177 void setColorSpace(ColorSpace colorSpace);
178
179 ColorTransfer colorTransfer() const;
180 void setColorTransfer(ColorTransfer colorTransfer);
181
182 ColorRange colorRange() const;
183 void setColorRange(ColorRange range);
184
185 bool isMirrored() const;
186 void setMirrored(bool mirrored);
187
188 QtVideo::Rotation rotation() const;
189 void setRotation(QtVideo::Rotation rotation);
190
191 QString vertexShaderFileName() const;
192 QString fragmentShaderFileName() const;
193 void updateUniformData(QByteArray *dst, const QVideoFrame &frame, const QMatrix4x4 &transform, float opacity) const;
194
195 float maxLuminance() const;
196 void setMaxLuminance(float lum);
197
198 static PixelFormat pixelFormatFromImageFormat(QImage::Format format);
199 static QImage::Format imageFormatFromPixelFormat(PixelFormat format);
200
201 static QString pixelFormatToString(QVideoFrameFormat::PixelFormat pixelFormat);
202
203private:
204 QExplicitlySharedDataPointer<QVideoFrameFormatPrivate> d;
205};
206
207Q_DECLARE_SHARED(QVideoFrameFormat)
208
209#ifndef QT_NO_DEBUG_STREAM
210Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, const QVideoFrameFormat &);
211Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrameFormat::Direction);
212#if QT_DEPRECATED_SINCE(6, 4)
213QT_DEPRECATED_VERSION_X_6_4("Use QVideoFrameFormat::ColorSpace")
214Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrameFormat::YCbCrColorSpace);
215#endif
216Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrameFormat::ColorSpace);
217Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug, QVideoFrameFormat::PixelFormat);
218#endif
219
220QT_END_NAMESPACE
221
222Q_DECLARE_METATYPE(QVideoFrameFormat)
223
224#endif
225
226

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

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