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

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