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
qimagevideobuffer.cpp
Go to the documentation of this file.
1
// Copyright (C) 2023 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
#
include
"qimagevideobuffer_p.h"
5
#
include
"qvideoframeformat.h"
6
7
QT_BEGIN_NAMESPACE
8
9
namespace
{
10
11
QImage
::
Format
fixImageFormat
(QImage::Format format)
12
{
13
switch
(format) {
14
case
QImage::Format_ARGB32_Premultiplied:
15
case
QImage::Format_ARGB8565_Premultiplied:
16
case
QImage::Format_ARGB6666_Premultiplied:
17
case
QImage::Format_ARGB8555_Premultiplied:
18
case
QImage::Format_ARGB4444_Premultiplied:
19
case
QImage::Format_RGBA8888_Premultiplied:
20
case
QImage::Format_A2BGR30_Premultiplied:
21
case
QImage::Format_A2RGB30_Premultiplied:
22
case
QImage::Format_RGBA64_Premultiplied:
23
case
QImage::Format_RGBA16FPx4_Premultiplied:
24
case
QImage::Format_RGBA32FPx4_Premultiplied:
25
return
QImage::Format_ARGB32_Premultiplied;
26
case
QImage::Format_ARGB32:
27
case
QImage::Format_RGBA8888:
28
case
QImage::Format_Alpha8:
29
case
QImage::Format_RGBA64:
30
case
QImage::Format_RGBA16FPx4:
31
case
QImage::Format_RGBA32FPx4:
32
return
QImage::Format_ARGB32;
33
case
QImage::Format_Invalid:
34
return
QImage::Format_Invalid;
35
default
:
36
return
QImage::Format_RGB32;
37
}
38
}
39
40
QImage
fixImage
(QImage image)
41
{
42
const
auto
imageFormat = image.format();
43
if
(imageFormat == QImage::Format_Invalid)
44
return
image;
45
46
const
auto
frameFormat = QVideoFrameFormat::pixelFormatFromImageFormat(imageFormat);
47
if
(frameFormat != QVideoFrameFormat::Format_Invalid)
48
return
image;
49
50
return
std::move(image).convertToFormat(fixImageFormat(imageFormat));
51
}
52
53
}
// namespace
54
55
QImageVideoBuffer::QImageVideoBuffer(QImage image) : m_image(fixImage(std::move(image))) { }
56
57
QAbstractVideoBuffer::MapData QImageVideoBuffer::map(QVideoFrame::MapMode mode)
58
{
59
MapData mapData;
60
61
if
(!m_image.isNull()) {
62
mapData.planeCount = 1;
63
mapData.bytesPerLine[0] = m_image.bytesPerLine();
64
if
(mode == QVideoFrame::ReadOnly)
65
mapData.data[0] =
const_cast
<uint8_t *>(m_image.constBits());
66
else
67
mapData.data[0] = m_image.bits();
68
mapData.dataSize[0] = m_image.sizeInBytes();
69
}
70
71
return
mapData;
72
}
73
74
QImage QImageVideoBuffer::underlyingImage()
const
75
{
76
return
m_image;
77
}
78
79
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE::fixImage
QImage fixImage(QImage image)
Definition
qimagevideobuffer.cpp:40
QT_BEGIN_NAMESPACE::fixImageFormat
QImage::Format fixImageFormat(QImage::Format format)
Definition
qimagevideobuffer.cpp:11
qtmultimedia
src
multimedia
video
qimagevideobuffer.cpp
Generated on
for Qt by
1.18.0