QAbstractVideoBuffer 類

QAbstractVideoBuffer 類是視頻數據的抽象。 更多...

頭: #include <QAbstractVideoBuffer>
qmake: QT += multimedia
繼承者:

QAbstractPlanarVideoBuffer

公共類型

enum HandleType { NoHandle, GLTextureHandle, XvShmImageHandle, CoreImageHandle, QPixmapHandle, …, GLTextureRectangleHandle }
enum MapMode { NotMapped, ReadOnly, WriteOnly, ReadWrite }

公共函數

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

詳細描述

The QVideoFrame 類利用 QAbstractVideoBuffer 在內部引用視頻數據緩衝。通常,視頻數據緩衝可能駐留在視頻內存而不是係統內存中,而這個類提供瞭位置抽象。

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 用戶定義句柄類型的起始值。
QAbstractVideoBuffer::GLTextureRectangleHandle 6 The handle of the buffer is an OpenGL texture ID of target type GL_TEXTURE_RECTANGLE .

另請參閱 handleType ().

enum QAbstractVideoBuffer:: MapMode

枚舉如何把視頻緩衝數據映射到係統內存。

常量 描述
QAbstractVideoBuffer::NotMapped 0x00 不把視頻緩衝映射到內存。
QAbstractVideoBuffer::ReadOnly 0x01 采用來自視頻緩衝的數據填充映射內存當映射時,但可能丟棄所映射內存的內容當取消映射時。
QAbstractVideoBuffer::WriteOnly 0x02 映射內存未初始化當映射時,但可能修改的內容將用於填充視頻緩衝當取消映射時。
QAbstractVideoBuffer::ReadWrite ReadOnly | WriteOnly 采用來自視頻緩衝的數據填充映射內存,並采用映射內存的內容重新填充視頻緩衝當取消映射時。

另請參閱 mapMode () 和 map ().

成員函數文檔編製

QAbstractVideoBuffer:: QAbstractVideoBuffer ( QAbstractVideoBuffer::HandleType type )

構造抽象視頻緩衝為給定 type .

[虛擬] QAbstractVideoBuffer:: ~QAbstractVideoBuffer ()

銷毀抽象視頻緩衝。

[虛擬] QVariant QAbstractVideoBuffer:: handle () const

返迴數據緩衝的特定句柄類型。

句柄類型的給齣,通過 handleType () 函數。

另請參閱 handleType ().

QAbstractVideoBuffer::HandleType QAbstractVideoBuffer:: handleType () const

返迴視頻緩衝的句柄類型。

另請參閱 handle ().

[pure virtual] uchar *QAbstractVideoBuffer:: map ( QAbstractVideoBuffer::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] QAbstractVideoBuffer::MapMode QAbstractVideoBuffer:: mapMode () const

返迴視頻緩衝映射模式。

另請參閱 map ().

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

單獨把視頻緩衝平麵映射到內存。

映射 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.

要實現此函數,創建衍生的 QAbstractPlanarVideoBuffer 並實現其 map 函數實例取而代之。

該函數在 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.

默認實現刪除緩衝實例。

[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 ().