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
qcvimagevideobuffer.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 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
<
QtFFmpegMediaPluginImpl
/
private
/
qcvimagevideobuffer_p
.
h
>
5
6
QT_BEGIN_NAMESPACE
7
8
QFFmpeg::CVImageVideoBuffer::CVImageVideoBuffer(QAVFHelpers::QSharedCVPixelBuffer &&pixelBuffer)
9
: m_buffer(std::move(pixelBuffer))
10
{
11
Q_ASSERT(m_buffer);
12
}
13
14
QFFmpeg::CVImageVideoBuffer::~CVImageVideoBuffer()
15
{
16
Q_ASSERT(m_mode == QVideoFrame::NotMapped);
17
}
18
19
QAbstractVideoBuffer::MapData QFFmpeg::CVImageVideoBuffer::map(QVideoFrame::MapMode mode)
20
{
21
Q_ASSERT(m_buffer);
22
23
MapData mapData;
24
25
if
(m_mode == QVideoFrame::NotMapped) {
26
CVPixelBufferLockBaseAddress(
27
m_buffer.get(),
28
mode == QVideoFrame::ReadOnly ? kCVPixelBufferLock_ReadOnly : 0);
29
m_mode = mode;
30
}
31
32
mapData.planeCount = CVPixelBufferGetPlaneCount(m_buffer.get());
33
Q_ASSERT(mapData.planeCount <= 3);
34
35
if
(!mapData.planeCount) {
36
// single plane
37
mapData.bytesPerLine[0] = CVPixelBufferGetBytesPerRow(m_buffer.get());
38
mapData.data[0] =
static_cast
<uchar *>(CVPixelBufferGetBaseAddress(m_buffer.get()));
39
mapData.dataSize[0] = CVPixelBufferGetDataSize(m_buffer.get());
40
mapData.planeCount = mapData.data[0] ? 1 : 0;
41
return
mapData;
42
}
43
44
// For a bi-planar or tri-planar format we have to set the parameters correctly:
45
for
(
int
i = 0; i < mapData.planeCount; ++i) {
46
mapData.bytesPerLine[i] = CVPixelBufferGetBytesPerRowOfPlane(m_buffer.get(), i);
47
mapData.dataSize[i] =
48
mapData.bytesPerLine[i] * CVPixelBufferGetHeightOfPlane(m_buffer.get(), i);
49
mapData.data[i] =
50
static_cast
<uchar *>(CVPixelBufferGetBaseAddressOfPlane(m_buffer.get(), i));
51
}
52
53
return
mapData;
54
}
55
56
void
QFFmpeg::CVImageVideoBuffer::unmap()
57
{
58
Q_ASSERT(m_buffer);
59
if
(m_mode != QVideoFrame::NotMapped) {
60
CVPixelBufferUnlockBaseAddress(
61
m_buffer.get(),
62
m_mode == QVideoFrame::ReadOnly ? kCVPixelBufferLock_ReadOnly : 0);
63
m_mode = QVideoFrame::NotMapped;
64
}
65
}
66
67
QT_END_NAMESPACE
qtmultimedia
src
plugins
multimedia
ffmpeg
darwin
qcvimagevideobuffer.cpp
Generated on
for Qt by
1.18.0