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
qvivantevideobuffer.cpp
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
#
include
"qvivantevideobuffer_p.h"
5
6
#
include
<
QtMultimedia
/
private
/
qrhivaluemapper_p
.
h
>
7
#
include
<
QtMultimedia
/
private
/
qvideotexturehelper_p
.
h
>
8
#
include
<
QtMultimedia
/
private
/
qvivantetextureimporter_p
.
h
>
9
#
include
<
QtGui
/
rhi
/
qrhi
.
h
>
10
#
include
<
QtCore
/
qloggingcategory
.
h
>
11
12
static_assert
(QT_CONFIG(gpu_vivante));
13
14
QT_BEGIN_NAMESPACE
15
16
Q_STATIC_LOGGING_CATEGORY
(qLcVivanteVideoBuffer,
"qt.multimedia.vivantevideobuffer"
);
17
18
namespace
QtMultimediaPrivate
{
19
20
static
QRhiValueMapper
<
VivanteContext
>
g_vivanteContexts
;
21
VivanteContext
&
vivanteContextForRhi
(QRhi &rhi)
22
{
23
return
g_vivanteContexts.getOrCreate(rhi, [&] {
24
return
VivanteContext(&rhi);
25
});
26
}
27
28
QVivanteVideoBuffer
::
QVivanteVideoBuffer
(
QVideoFrameFormat
::
PixelFormat
format
,
QSize
size
,
29
quint32
physicalAddress
,
void
*
logicalAddr
,
30
GLenum
vivFormatToken
,
std
::
shared_ptr
<
void
>
keepAlive
,
31
VivanteCpuView
cpuView
)
32
:
m_format
(
format
),
33
m_size
(
size
),
34
m_physicalAddress
(
physicalAddress
),
35
m_logicalAddr
(
logicalAddr
),
36
m_vivFormatToken
(
vivFormatToken
),
37
m_cpuView
(
cpuView
),
38
m_keepAlive
(
std
::
move
(
keepAlive
))
39
{
40
}
41
42
QVivanteVideoBuffer
::~
QVivanteVideoBuffer
()
43
{
44
Q_ASSERT
(
m_mapMode
==
QVideoFrame
::
NotMapped
);
45
}
46
47
QVideoFrameTexturesUPtr
QVivanteVideoBuffer
::
mapTextures
(
QRhi
&
rhi
)
48
{
49
Q_ASSERT
(
rhi
.
thread
()->
isCurrentThread
());
50
51
if
(
rhi
.
backend
() !=
QRhi
::
OpenGLES2
)
52
return
{};
53
54
VivanteContext
&
context
=
vivanteContextForRhi
(
rhi
);
55
56
if
(!
context
.
isValid
()) {
57
qCDebug
(
qLcVivanteVideoBuffer
) <<
"VivanteContext is not valid, falling back to CPU path"
;
58
return
{};
59
}
60
61
auto
handles
=
importVivanteTexture
(
rhi
,
context
,
m_physicalAddress
,
m_logicalAddr
,
m_size
,
62
m_vivFormatToken
,
m_keepAlive
);
63
if
(!
handles
) {
64
qCWarning
(
qLcVivanteVideoBuffer
) <<
"Vivante direct-texture import failed"
;
65
return
{};
66
}
67
68
return
QVideoTextureHelper
::
createTexturesFromHandles
(
std
::
move
(*
handles
),
rhi
,
m_format
,
69
m_size
);
70
}
71
72
QAbstractVideoBuffer
::
MapData
QVivanteVideoBuffer
::
map
(
QVideoFrame
::
MapMode
mode
)
73
{
74
MapData
mapData
;
75
76
// The producer (VPU/driver) owns write access to the phys-mem buffer.
77
if
(
mode
!=
QVideoFrame
::
ReadOnly
||
m_mapMode
!=
QVideoFrame
::
NotMapped
)
78
return
mapData
;
79
80
if
(!
m_cpuView
.
data
) {
81
qCDebug
(
qLcVivanteVideoBuffer
) <<
"No CPU-mapped view available for this buffer"
;
82
return
mapData
;
83
}
84
85
// The caller must have already CPU-mapped the phys-mem buffer (e.g. via gst_buffer_map())
86
// and passed the pointer in as VivanteCpuView; just hand that view back out.
87
mapData
.
planeCount
= 1;
88
mapData
.
data
[0] =
m_cpuView
.
data
;
89
mapData
.
bytesPerLine
[0] =
m_cpuView
.
bytesPerLine
;
90
mapData
.
dataSize
[0] =
m_cpuView
.
dataSize
;
91
92
m_mapMode
=
mode
;
93
return
mapData
;
94
}
95
96
void
QVivanteVideoBuffer
::
unmap
()
97
{
98
// Nothing to release: the CPU-mapped view is owned by the caller (see
99
// VivanteCpuView / m_keepAlive), not by this object.
100
m_mapMode
=
QVideoFrame
::
NotMapped
;
101
}
102
103
}
// namespace QtMultimediaPrivate
104
105
QT_END_NAMESPACE
QtMultimediaPrivate::impl
Definition
qaudiosystem_p.h:257
QtMultimediaPrivate::g_vivanteContexts
static QRhiValueMapper< VivanteContext > g_vivanteContexts
Definition
qvivantevideobuffer.cpp:20
QtMultimediaPrivate::vivanteContextForRhi
VivanteContext & vivanteContextForRhi(QRhi &rhi)
Definition
qvivantevideobuffer.cpp:21
Q_STATIC_LOGGING_CATEGORY
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
qtmultimedia
src
multimedia
video
qvivantevideobuffer.cpp
Generated on
for Qt by
1.18.0