Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qv4l2formats_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
QV4L2FORMATS_P_H
5
#
define
QV4L2FORMATS_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
/
qvideoframeformat
.
h
>
19
#
include
<
QtMultimedia
/
private
/
qmultimedia_ranges_p
.
h
>
20
21
#
include
<
linux
/
videodev2
.
h
>
22
23
#
include
<
cstdint
>
24
#
include
<
iterator
>
25
#
include
<
optional
>
26
27
QT_BEGIN_NAMESPACE
28
29
namespace
QtV4L2
{
30
31
struct
V4L2FormatMapEntry
32
{
33
QVideoFrameFormat
::
PixelFormat
format
;
34
uint32_t
v4l2Format
;
35
};
36
37
inline
constexpr
V4L2FormatMapEntry
formatMap
[] = {
38
{
QVideoFrameFormat
::
Format_YUV420P
, V4L2_PIX_FMT_YUV420 },
39
{
QVideoFrameFormat
::
Format_YUV422P
, V4L2_PIX_FMT_YUV422P },
40
{
QVideoFrameFormat
::
Format_YUYV
, V4L2_PIX_FMT_YUYV },
41
{
QVideoFrameFormat
::
Format_UYVY
, V4L2_PIX_FMT_UYVY },
42
{
QVideoFrameFormat
::
Format_XBGR8888
, V4L2_PIX_FMT_XBGR32 },
43
{
QVideoFrameFormat
::
Format_XRGB8888
, V4L2_PIX_FMT_XRGB32 },
44
{
QVideoFrameFormat
::
Format_ABGR8888
, V4L2_PIX_FMT_ABGR32 },
45
{
QVideoFrameFormat
::
Format_ARGB8888
, V4L2_PIX_FMT_ARGB32 },
46
{
QVideoFrameFormat
::
Format_BGRX8888
, V4L2_PIX_FMT_BGR32 },
47
{
QVideoFrameFormat
::
Format_RGBX8888
, V4L2_PIX_FMT_RGB32 },
48
{
QVideoFrameFormat
::
Format_BGRA8888
, V4L2_PIX_FMT_BGRA32 },
49
{
QVideoFrameFormat
::
Format_RGBA8888
, V4L2_PIX_FMT_RGBA32 },
50
{
QVideoFrameFormat
::
Format_Y8
, V4L2_PIX_FMT_GREY },
51
{
QVideoFrameFormat
::
Format_Y16
, V4L2_PIX_FMT_Y16 },
52
{
QVideoFrameFormat
::
Format_NV12
, V4L2_PIX_FMT_NV12 },
53
{
QVideoFrameFormat
::
Format_NV21
, V4L2_PIX_FMT_NV21 },
54
55
// FIXME: V4L2_PIX_FMT_MJPEG and V4L2_PIX_FMT_JPEG both map to QVideoFrameFormat::Format_Jpeg
56
{
QVideoFrameFormat
::
Format_Jpeg
, V4L2_PIX_FMT_MJPEG },
57
{
QVideoFrameFormat
::
Format_Jpeg
, V4L2_PIX_FMT_JPEG },
58
};
59
60
inline
QVideoFrameFormat
::
PixelFormat
formatForV4L2Format
(uint32_t v4l2Format)
61
{
62
namespace
ranges = QtMultimediaPrivate::ranges;
63
const
auto
found = ranges::find_if(formatMap, [&](
const
V4L2FormatMapEntry &entry) {
64
return
entry.v4l2Format == v4l2Format;
65
});
66
if
(found == std::end(formatMap))
67
return
QVideoFrameFormat::Format_Invalid;
68
return
found->format;
69
}
70
71
inline
std
::optional<uint32_t>
v4l2FormatForPixelFormat
(QVideoFrameFormat::PixelFormat format)
72
{
73
namespace
ranges = QtMultimediaPrivate::ranges;
74
const
auto
found = ranges::find_if(formatMap, [&](
const
V4L2FormatMapEntry &entry) {
75
return
entry.format == format;
76
});
77
if
(found ==
std
::end(
formatMap
))
78
return
std
::nullopt;
79
return
found->v4l2Format;
80
}
81
82
inline
QVideoFrameFormat
::
ColorSpace
colorSpaceForV4L2Colorspace
(v4l2_colorspace colorspace)
83
{
84
switch
(colorspace) {
85
case
V4L2_COLORSPACE_REC709:
86
return
QVideoFrameFormat::ColorSpace_BT709;
87
case
V4L2_COLORSPACE_JPEG:
88
return
QVideoFrameFormat::ColorSpace_AdobeRgb;
89
case
V4L2_COLORSPACE_SRGB:
90
// ##### is this correct???
91
return
QVideoFrameFormat::ColorSpace_BT601;
92
case
V4L2_COLORSPACE_BT2020:
93
return
QVideoFrameFormat::ColorSpace_BT2020;
94
default
:
95
case
V4L2_COLORSPACE_DCI_P3:
96
return
QVideoFrameFormat::ColorSpace_Undefined;
97
}
98
}
99
100
inline
std
::optional<v4l2_colorspace>
101
v4l2ColorspaceForColorSpace
(QVideoFrameFormat::ColorSpace colorSpace)
102
{
103
switch
(colorSpace) {
104
case
QVideoFrameFormat::ColorSpace_BT601:
105
return
V4L2_COLORSPACE_SMPTE170M;
106
case
QVideoFrameFormat::ColorSpace_BT709:
107
return
V4L2_COLORSPACE_REC709;
108
case
QVideoFrameFormat::ColorSpace_AdobeRgb:
109
return
V4L2_COLORSPACE_OPRGB;
110
case
QVideoFrameFormat::ColorSpace_BT2020:
111
return
V4L2_COLORSPACE_BT2020;
112
case
QVideoFrameFormat::ColorSpace_Undefined:
113
return
std
::nullopt;
114
}
115
return
std
::nullopt;
116
}
117
118
inline
QSize
sizeForV4L2Format
(
const
v4l2_pix_format &pixFormat)
119
{
120
return
QSize{
121
int
(pixFormat.width),
122
int
(pixFormat.height),
123
};
124
}
125
126
}
// namespace QtV4L2
127
128
QT_END_NAMESPACE
129
130
#
endif
// QV4L2FORMATS_P_H
QtV4L2
Definition
qv4l2camera.cpp:22
QtV4L2::formatMap
constexpr V4L2FormatMapEntry formatMap[]
Definition
qv4l2formats_p.h:37
QtV4L2::v4l2ColorspaceForColorSpace
std::optional< v4l2_colorspace > v4l2ColorspaceForColorSpace(QVideoFrameFormat::ColorSpace colorSpace)
Definition
qv4l2formats_p.h:101
QtV4L2::sizeForV4L2Format
QSize sizeForV4L2Format(const v4l2_pix_format &pixFormat)
Definition
qv4l2formats_p.h:118
QtV4L2::formatForV4L2Format
QVideoFrameFormat::PixelFormat formatForV4L2Format(uint32_t v4l2Format)
Definition
qv4l2formats_p.h:60
QtV4L2::colorSpaceForV4L2Colorspace
QVideoFrameFormat::ColorSpace colorSpaceForV4L2Colorspace(v4l2_colorspace colorspace)
Definition
qv4l2formats_p.h:82
QtV4L2::v4l2FormatForPixelFormat
std::optional< uint32_t > v4l2FormatForPixelFormat(QVideoFrameFormat::PixelFormat format)
Definition
qv4l2formats_p.h:71
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QtV4L2::V4L2FormatMapEntry
Definition
qv4l2formats_p.h:32
QtV4L2::V4L2FormatMapEntry::format
QVideoFrameFormat::PixelFormat format
Definition
qv4l2formats_p.h:33
QtV4L2::V4L2FormatMapEntry::v4l2Format
uint32_t v4l2Format
Definition
qv4l2formats_p.h:34
qtmultimedia
src
multimedia
v4l2
qv4l2formats_p.h
Generated on
for Qt by
1.18.0