QAbstractVideoBuffer Class

QAbstractVideoBuffer 类是视频数据的抽象概念。更多

头文件: #include <QAbstractVideoBuffer>
CMake.QAbstractVideoBuffer 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().

© 2025 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.