本页内容

QAbstractVideoBuffer Class

QAbstractVideoBuffer 类是对视频数据的抽象表示。更多内容...

头文件: #include <QAbstractVideoBuffer>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
自: Qt 6.8

公共类型

struct MapData

公共函数

virtual ~QAbstractVideoBuffer()
virtual QVideoFrameFormat format() const = 0
virtual QAbstractVideoBuffer::MapData map(QVideoFrame::MapMode mode) = 0
virtual void unmap()

详细说明

QVideoFrame 类在内部使用QAbstractVideoBuffer来引用视频数据缓冲区。通过创建QAbstractVideoBuffer的子类,您可以从预分配或静态缓冲区中构建视频帧。该子类可以包含硬件缓冲区,并通过将缓冲区映射到CPU内存来实现对数据的访问。

可以通过使用map() 函数将缓冲区映射到内存来访问缓冲区的内容,该函数返回一个包含当前视频数据平面布局信息的结构体。

另请参阅 QVideoFrame 、QVideoFrameFormat 和QVideoFrame::MapMode 。

成员函数文档

[virtual noexcept] QAbstractVideoBuffer::~QAbstractVideoBuffer()

销毁一个视频缓冲区。

[pure virtual] QVideoFrameFormat QAbstractVideoBuffer::format() const

获取底层视频缓冲区的QVideoFrameFormat 。

在创建 `QVideoFrame` 时,该格式必须已存在。`QVideoFrame ` 将包含该格式的实例,该实例可以被分离并进行修改。

[pure virtual] QAbstractVideoBuffer::MapData QAbstractVideoBuffer::map(QVideoFrame::MapMode mode)

将视频缓冲区的各平面映射到内存中。

返回一个 `MapData ` 结构体,其中包含关于已映射的当前视频数据平面布局的信息。如果映射失败,该方法将返回默认结构体。对于 CPU 内存缓冲区,其数据被视为已映射,因此该函数仅返回预分配底层数据的平面布局。

mode 映射模式指示应从映射内存中读取和/或向缓冲区写入数据。如果映射模式包含QVideoFrame::ReadOnly 标志,则在初始映射时,映射内存将被填充为缓冲区的内容。如果映射模式包含QVideoFrame::WriteOnly 标志,则在解除映射时,可能已被修改的映射内存内容将被写回缓冲区。

当不再需要访问数据时,调用unmap 函数以释放映射的内存,并可能更新缓冲区内容。

如果视频数据的格式为多平面,该方法可能会将整个像素数据映射为单个平面。在这种情况下,使用 `QVideoFrame ` 映射缓冲区时,系统会根据第一个平面的指定行步长、帧高和数据大小来计算额外的平面。

[virtual] void QAbstractVideoBuffer::unmap()

释放由map()函数映射的内存。

如果MapMode 函数中包含QVideoFrame::WriteOnly 标志,则会将映射内存的当前内容写回视频帧。

对于 CPU 视频缓冲区,该函数不得被重写。unmap 的默认实现不执行任何操作。

另请参阅 map()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.