QAbstractVideoBuffer 类

The QAbstractVideoBuffer class is an abstraction for video data. 更多...

头: #include <QAbstractVideoBuffer>
qmake: QT += multimedia
继承者: QAbstractPlanarVideoBuffer

公共类型

enum HandleType { NoHandle, GLTextureHandle, XvShmImageHandle, CoreImageHandle, ..., UserHandle }
enum MapMode { NotMapped, ReadOnly, WriteOnly, ReadWrite }

公共函数

QAbstractVideoBuffer (HandleType type )
virtual ~QAbstractVideoBuffer ()
virtual QVariant handle () const
HandleType handleType () const
virtual uchar * map (MapMode mode , int * numBytes , int * bytesPerLine ) = 0
virtual MapMode mapMode () const = 0
int mapPlanes (MapMode mode , int * numBytes , int[4] bytesPerLine , uchar *[4] data )
virtual void release ()
virtual void unmap () = 0

详细描述

The QAbstractVideoBuffer class is an abstraction for video data.

The QVideoFrame class makes use of a QAbstractVideoBuffer internally to reference a buffer of video data. Quite often video data buffers may reside in video memory rather than system memory, and this class provides an abstraction of the location.

In addition, creating a subclass of QAbstractVideoBuffer will allow you to construct video frames from preallocated or static buffers, in cases where the QVideoFrame constructors taking a QByteArray QImage do not suffice. This may be necessary when implementing a new hardware accelerated video system, for example.

The contents of a buffer can be accessed by mapping the buffer to memory using the map () function, which returns a pointer to memory containing the contents of the video buffer. The memory returned by map () is released by calling the unmap () 函数。

The handle () of a buffer may also be used to manipulate its contents using type specific APIs. The type of a buffer's handle is given by the handleType () 函数。

另请参阅 QVideoFrame .

成员类型文档编制

enum QAbstractVideoBuffer:: HandleType

标识视频缓冲句柄的类型。

常量 描述
QAbstractVideoBuffer::NoHandle 0 缓冲没有句柄,只能通过映射缓冲访问其数据。
QAbstractVideoBuffer::GLTextureHandle 1 缓冲句柄是 OpenGL 纹理 ID。
QAbstractVideoBuffer::XvShmImageHandle 2 句柄包含指向共享内存 XVideo 图像的指针。
QAbstractVideoBuffer::CoreImageHandle 3 句柄包含指向 macOS CIImage 的指针。
QAbstractVideoBuffer::QPixmapHandle 4 缓冲的句柄是 QPixmap .
QAbstractVideoBuffer::EGLImageHandle 5 缓冲的句柄是 EGLImageKHR。
QAbstractVideoBuffer::UserHandle 1000 用户定义句柄类型的起始值。

另请参阅 handleType ().

enum QAbstractVideoBuffer:: MapMode

枚举如何把视频缓冲数据映射到系统内存。

常量 描述
QAbstractVideoBuffer::NotMapped 0x00 不把视频缓冲映射到内存。
QAbstractVideoBuffer::ReadOnly 0x01 The mapped memory is populated with data from the video buffer when mapped, but the content of the mapped memory may be discarded when unmapped.
QAbstractVideoBuffer::WriteOnly 0x02 The mapped memory is uninitialized when mapped, but the possibly modified content will be used to populate the video buffer when unmapped.
QAbstractVideoBuffer::ReadWrite ReadOnly | WriteOnly The mapped memory is populated with data from the video buffer, and the video buffer is repopulated with the content of the mapped memory when it is unmapped.

另请参阅 mapMode () 和 map ().

成员函数文档编制

QAbstractVideoBuffer:: QAbstractVideoBuffer ( HandleType type )

构造抽象视频缓冲为给定 type .

[虚拟] QAbstractVideoBuffer:: ~QAbstractVideoBuffer ()

销毁抽象视频缓冲。

[虚拟] QVariant QAbstractVideoBuffer:: handle () const

返回数据缓冲的特定句柄类型。

句柄类型的给出,通过 handleType () 函数。

另请参阅 handleType ().

HandleType QAbstractVideoBuffer:: handleType () const

返回视频缓冲的句柄类型。

另请参阅 handle ().

[pure virtual] uchar *QAbstractVideoBuffer:: map ( MapMode mode , int * numBytes , int * bytesPerLine )

将视频缓冲内容映射到内存。

In some cases the video buffer might be stored in video memory or otherwise inaccessible memory, so it is necessary to map the buffer before accessing the pixel data. This may involve copying the contents around, so avoid mapping and unmapping unless required.

映射 mode indicates whether the contents of the mapped memory should be read from and/or written to the buffer. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the mapped memory will be populated with the content of the buffer when initially mapped. If the map mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the possibly modified mapped memory will be written back to the buffer when unmapped.

When access to the data is no longer needed be sure to call the unmap () function to release the mapped memory and possibly update the buffer contents.

Returns a pointer to the mapped memory region, or a null pointer if the mapping failed. The size in bytes of the mapped memory region is returned in numBytes , and the line stride in bytesPerLine .

注意: 作为只读的写入映射内存是未定义的,并可能导致共享数据改变或崩溃。

另请参阅 unmap () 和 mapMode ().

[pure virtual] MapMode QAbstractVideoBuffer:: mapMode () const

返回视频缓冲映射模式。

另请参阅 map ().

int QAbstractVideoBuffer:: mapPlanes ( MapMode mode , int * numBytes , int [ 4 ] bytesPerLine , uchar *[ 4 ] data )

Independently maps the planes of a video buffer to memory.

映射 mode indicates whether the contents of the mapped memory should be read from and/or written to the buffer. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the mapped memory will be populated with the content of the buffer when initially mapped. If the map mode includes the QAbstractVideoBuffer::WriteOnly flag the content of the possibly modified mapped memory will be written back to the buffer when unmapped.

When access to the data is no longer needed be sure to call the unmap () function to release the mapped memory and possibly update the buffer contents.

Returns the number of planes in the mapped video data. For each plane the line stride of that plane will be returned in bytesPerLine , and a pointer to the plane data will be returned in data . The accumulative size of the mapped data is returned in numBytes .

Not all buffer implementations will map more than the first plane, if this returns a single plane for a planar format the additional planes will have to be calculated from the line stride of the first plane and the frame height. Mapping a buffer with QVideoFrame will do this for you.

To implement this function create a derivative of QAbstractPlanarVideoBuffer and implement its map function instance instead.

该函数在 Qt 5.4 引入。

[虚拟] void QAbstractVideoBuffer:: release ()

释放视频缓冲。

QVideoFrame calls QAbstractVideoBuffer::release when the buffer is not used any more and can be destroyed or returned to the buffer pool.

The default implementation deletes the buffer instance.

[pure virtual] void QAbstractVideoBuffer:: unmap ()

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

MapMode 包括 QAbstractVideoBuffer::WriteOnly flag this will write the current content of the mapped memory back to the video frame.

另请参阅 map ().