Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmultimedia_drm_support_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QMULTIMEDIA_DRM_SUPPORT_P_H
5#define QMULTIMEDIA_DRM_SUPPORT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtMultimedia/private/qtmultimediaglobal_p.h>
19#include <QtMultimedia/qvideoframeformat.h>
20#include <QtCore/qspan.h>
21#include <QtCore/qstring.h>
22
23#include <cstdint>
24
25QT_BEGIN_NAMESPACE
26
27class QDebug;
28
29namespace QtMultimediaPrivate {
30
31// see DRM_FORMAT_MOD_VENDOR_* in drm_fourcc.h
32enum class DRMModifier : std::uint64_t { };
33
34static constexpr DRMModifier DmaBufFormatModifierInvalid = DRMModifier{ (1ULL << 56) - 1 };
36
37Q_MULTIMEDIA_EXPORT QString toString(DRMModifier modifier);
38Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug debug, DRMModifier modifier);
39
40constexpr uint32_t fourcc_code(char a, char b, char c, char d)
41{
42 return ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24));
43}
44
45// clang-format off
46enum class DRMFormat : std::uint32_t {
47 RGBA8888 = fourcc_code('R', 'A', '2', '4'), /* [31:0] R:G:B:A 8:8:8:8 little endian */
48 RGB888 = fourcc_code('R', 'G', '2', '4'), /* [23:0] R:G:B little endian */
49 RG88 = fourcc_code('R', 'G', '8', '8'), /* [15:0] R:G 8:8 little endian */
50 ARGB8888 = fourcc_code('A', 'R', '2', '4'), /* [31:0] A:R:G:B 8:8:8:8 little endian */
51 ABGR8888 = fourcc_code('A', 'B', '2', '4'), /* [31:0] A:B:G:R 8:8:8:8 little endian */
52 BGRA8888 = fourcc_code('B', 'A', '2', '4'), /* [31:0] B:G:R:A 8:8:8:8 little endian */
53 BGR888 = fourcc_code('B', 'G', '2', '4'), /* [23:0] B:G:R little endian */
54 GR88 = fourcc_code('G', 'R', '8', '8'), /* [15:0] G:R 8:8 little endian */
55 R8 = fourcc_code('R', '8', ' ', ' '), /* [7:0] R */
56 R16 = fourcc_code('R', '1', '6', ' '), /* [15:0] R little endian */
57 RGB565 = fourcc_code('R', 'G', '1', '6'), /* [15:0] R:G:B 5:6:5 little endian */
58 RG1616 = fourcc_code('R', 'G', '3', '2'), /* [31:0] R:G 16:16 little endian */
59 GR1616 = fourcc_code('G', 'R', '3', '2'), /* [31:0] G:R 16:16 little endian */
60 BGRA1010102 = fourcc_code('B', 'A', '3', '0'), /* [31:0] B:G:R:A 10:10:10:2 little endian */
61 YUYV = fourcc_code('Y', 'U', 'Y', 'V'), /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */
62 UYVY = fourcc_code('U', 'Y', 'V', 'Y'), /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */
63 AYUV = fourcc_code('A', 'Y', 'U', 'V'), /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
64 NV12 = fourcc_code('N', 'V', '1', '2'), /* 2x2 subsampled Cr:Cb plane */
65 NV21 = fourcc_code('N', 'V', '2', '1'), /* 2x2 subsampled Cb:Cr plane */
66 P010 = fourcc_code('P', '0', '1', '0'), /* 2x2 subsampled Cr:Cb plane, 10 bits per channel */
67 YUV411 = fourcc_code('Y', 'U', '1', '1'), /* 4x1 subsampled Cb (1) and Cr (2) planes */
68 YUV420 = fourcc_code('Y', 'U', '1', '2'), /* 2x2 subsampled Cb (1) and Cr (2) planes */
69 YVU420 = fourcc_code('Y', 'V', '1', '2'), /* 2x2 subsampled Cr (1) and Cb (2) planes */
70 YUV422 = fourcc_code('Y', 'U', '1', '6'), /* 2x1 subsampled Cb (1) and Cr (2) planes */
71 YUV444 = fourcc_code('Y', 'U', '2', '4'), /* non-subsampled Cb (1) and Cr (2) planes */
72};
73// clang-format on
74
75Q_MULTIMEDIA_EXPORT QString toString(DRMFormat format);
76Q_MULTIMEDIA_EXPORT QDebug operator<<(QDebug debug, DRMFormat format);
77
78inline QSpan<const DRMFormat>
79dmaBufFourccFromPixelFormat(const QVideoFrameFormat::PixelFormat format)
80{
81#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
82 constexpr DRMFormat rgba_fourcc = DRMFormat::ABGR8888;
83 constexpr DRMFormat rg_fourcc = DRMFormat::GR88;
84 constexpr DRMFormat rg16_fourcc = DRMFormat::GR1616;
85#else
86 constexpr DRMFormat rgba_fourcc = DRMFormat::RGBA8888;
87 constexpr DRMFormat rg_fourcc = DRMFormat::RG88;
88 constexpr DRMFormat rg16_fourcc = DRMFormat::RG1616;
89#endif
90
91 switch (format) {
92 case QVideoFrameFormat::Format_Invalid:
93 case QVideoFrameFormat::Format_IMC1:
94 case QVideoFrameFormat::Format_IMC2:
95 case QVideoFrameFormat::Format_IMC3:
96 case QVideoFrameFormat::Format_IMC4:
97 case QVideoFrameFormat::Format_SamplerExternalOES:
98 case QVideoFrameFormat::Format_Jpeg:
99 case QVideoFrameFormat::Format_SamplerRect:
100 return {};
101
102 case QVideoFrameFormat::Format_ARGB8888:
103 case QVideoFrameFormat::Format_ARGB8888_Premultiplied:
104 case QVideoFrameFormat::Format_XRGB8888:
105 case QVideoFrameFormat::Format_BGRA8888:
106 case QVideoFrameFormat::Format_BGRA8888_Premultiplied:
107 case QVideoFrameFormat::Format_BGRX8888:
108 case QVideoFrameFormat::Format_ABGR8888:
109 case QVideoFrameFormat::Format_XBGR8888:
110 case QVideoFrameFormat::Format_RGBA8888:
111 case QVideoFrameFormat::Format_RGBX8888:
112 case QVideoFrameFormat::Format_AYUV:
113 case QVideoFrameFormat::Format_AYUV_Premultiplied:
114 case QVideoFrameFormat::Format_UYVY:
115 case QVideoFrameFormat::Format_YUYV: {
116 static constexpr DRMFormat format[] = { rgba_fourcc };
117 return format;
118 }
119
120 case QVideoFrameFormat::Format_Y8: {
121 static constexpr DRMFormat format[] = { DRMFormat::R8 };
122 return format;
123 }
124 case QVideoFrameFormat::Format_Y16: {
125 static constexpr DRMFormat format[] = { DRMFormat::R16 };
126 return format;
127 }
128
129 case QVideoFrameFormat::Format_YUV420P:
130 case QVideoFrameFormat::Format_YUV422P:
131 case QVideoFrameFormat::Format_YV12: {
132 static constexpr DRMFormat format[] = { DRMFormat::R8, DRMFormat::R8, DRMFormat::R8 };
133 return format;
134 }
135 case QVideoFrameFormat::Format_YUV420P10: {
136 static constexpr DRMFormat format[] = { DRMFormat::R16, DRMFormat::R16, DRMFormat::R16 };
137 return format;
138 }
139
140 case QVideoFrameFormat::Format_NV12:
141 case QVideoFrameFormat::Format_NV21: {
142 static constexpr DRMFormat format[] = { DRMFormat::R8, rg_fourcc };
143 return format;
144 }
145
146 case QVideoFrameFormat::Format_P010:
147 case QVideoFrameFormat::Format_P016: {
148 static constexpr DRMFormat format[] = { DRMFormat::R16, rg16_fourcc };
149 return format;
150 }
151 }
152 return {};
153}
154
163
164} // namespace QtMultimediaPrivate
165
166QT_END_NAMESPACE
167
168#endif
Combined button and popup list for selecting options.
constexpr uint32_t fourcc_code(char a, char b, char c, char d)
QString toString(DRMModifier modifier)
static constexpr DRMModifier DrmFormatModifierLinear
static constexpr DRMModifier DmaBufFormatModifierInvalid
QSpan< const DRMFormat > dmaBufFourccFromPixelFormat(const QVideoFrameFormat::PixelFormat format)
QString toString(DRMFormat format)