The QVideoFrame class represents a frame of video data. 更多...
| 头: | #include <QVideoFrame> |
| qmake: | QT += multimedia |
| enum | FieldType { ProgressiveFrame, TopField, BottomField, InterlacedFrame } |
| enum | PixelFormat { Format_Invalid, Format_ARGB32, Format_ARGB32_Premultiplied, Format_RGB32, ..., Format_User } |
| QVideoFrame () | |
| QVideoFrame (QAbstractVideoBuffer * buffer , const QSize & size , PixelFormat format ) | |
| QVideoFrame (int bytes , const QSize & size , int bytesPerLine , PixelFormat format ) | |
| QVideoFrame (const QImage & image ) | |
| QVideoFrame (const QVideoFrame & other ) | |
| ~QVideoFrame () | |
| QVariantMap | availableMetaData () const |
| uchar * | bits () |
| uchar * | bits (int plane ) |
| const uchar * | bits () const |
| const uchar * | bits (int plane ) const |
| int | bytesPerLine () const |
| int | bytesPerLine (int plane ) const |
| qint64 | endTime () const |
| FieldType | fieldType () const |
| QVariant | handle () const |
| QAbstractVideoBuffer::HandleType | handleType () const |
| int | height () const |
| bool | isMapped () const |
| bool | isReadable () const |
| bool | isValid () const |
| bool | isWritable () const |
| bool | map (QAbstractVideoBuffer::MapMode mode ) |
| QAbstractVideoBuffer::MapMode | mapMode () const |
| int | mappedBytes () const |
| QVariant | metaData (const QString & key ) const |
| PixelFormat | pixelFormat () const |
| int | planeCount () const |
| void | setEndTime (qint64 time ) |
| void | setFieldType (FieldType field ) |
| void | setMetaData (const QString & key , const QVariant & value ) |
| void | setStartTime (qint64 time ) |
| QSize | size () const |
| qint64 | startTime () const |
| void | unmap () |
| int | width () const |
| bool | operator!= (const QVideoFrame & other ) const |
| QVideoFrame & | operator= (const QVideoFrame & other ) |
| bool | operator== (const QVideoFrame & other ) const |
| QImage::Format | imageFormatFromPixelFormat (PixelFormat format ) |
| PixelFormat | pixelFormatFromImageFormat (QImage::Format format ) |
The QVideoFrame class represents a frame of video data.
A QVideoFrame encapsulates the pixel data of a video frame, and information about the frame.
视频帧可以来自几个地方 - 解码的 media , camera ,或以编程方式生成。在这些帧中描述像素的方式可能有很大不同,且一些像素格式以易用性为代价提供更大压缩机会。
视频帧的像素内容映射到内存可以使用 map () 函数。当映射时,视频数据的访问可以使用 bits () 函数,返回缓冲指针。此缓冲总大小的给定是通过 mappedBytes () 函数,和每行大小的给定是通过 bytesPerLine ()。返回值对于 handle () 函数也可以使用内部缓冲的本地 API 来访问帧数据 (例如:OpenGL 纹理句柄)。
视频帧也可以拥有关联它的时间戳信息。这些时间戳可以用于实现的 QAbstractVideoSurface 以确定何时开始和停止显示帧,但并非所有表面都可能遵守此设置。
The video pixel data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer 。 QVideoFrame may be constructed from any buffer type by subclassing the QAbstractVideoBuffer 类。
注意: Since video frames can be expensive to copy, QVideoFrame is explicitly shared, so any change made to a video frame will also apply to any copies.
指定隔行扫描视频帧所属的字段。
| 常量 | 值 | 描述 |
|---|---|---|
QVideoFrame::ProgressiveFrame
|
0
|
帧非隔行扫描。 |
QVideoFrame::TopField
|
1
|
帧包含 top 字段。 |
QVideoFrame::BottomField
|
2
|
框架包含 bottom 字段。 |
QVideoFrame::InterlacedFrame
|
3
|
帧包含合并的 top 和 bottom 字段。 |
枚举视频数据类型。
| 常量 | 值 | 描述 |
|---|---|---|
QVideoFrame::Format_Invalid
|
0
|
帧无效。 |
QVideoFrame::Format_ARGB32
|
1
|
使用 32 位 ARGB 格式 (0xAARRGGBB) 存储帧。这相当于 QImage::Format_ARGB32 . |
QVideoFrame::Format_ARGB32_Premultiplied
|
2
|
使用预乘 32 位 ARGB 格式 (0xAARRGGBB) 存储帧。这相当于 QImage::Format_ARGB32_Premultiplied . |
QVideoFrame::Format_RGB32
|
3
|
使用 32 位 RGB 格式 (0xffRRGGBB) 存储帧。这相当于 QImage::Format_RGB32 |
QVideoFrame::Format_RGB24
|
4
|
The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent to QImage::Format_RGB888 |
QVideoFrame::Format_RGB565
|
5
|
The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent to QImage::Format_RGB16 . |
QVideoFrame::Format_RGB555
|
6
|
The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent to QImage::Format_RGB555 . |
QVideoFrame::Format_ARGB8565_Premultiplied
|
7
|
The frame is stored using a 24-bit premultiplied ARGB format (8-5-6-5). |
QVideoFrame::Format_BGRA32
|
8
|
The frame is stored using a 32-bit BGRA format (0xBBGGRRAA). |
QVideoFrame::Format_BGRA32_Premultiplied
|
9
|
The frame is stored using a premultiplied 32bit BGRA format. |
QVideoFrame::Format_BGR32
|
10
|
The frame is stored using a 32-bit BGR format (0xBBGGRRff). |
QVideoFrame::Format_BGR24
|
11
|
The frame is stored using a 24-bit BGR format (0xBBGGRR). |
QVideoFrame::Format_BGR565
|
12
|
帧使用 16 位 BGR 格式 (5-6-5) 存储。 |
QVideoFrame::Format_BGR555
|
13
|
帧使用 16 位 BGR 格式 (5-5-5) 存储。 |
QVideoFrame::Format_BGRA5658_Premultiplied
|
14
|
The frame is stored using a 24-bit premultiplied BGRA format (5-6-5-8). |
QVideoFrame::Format_AYUV444
|
15
|
The frame is stored using a packed 32-bit AYUV format (0xAAYYUUVV). |
QVideoFrame::Format_AYUV444_Premultiplied
|
16
|
The frame is stored using a packed premultiplied 32-bit AYUV format (0xAAYYUUVV). |
QVideoFrame::Format_YUV444
|
17
|
The frame is stored using a 24-bit packed YUV format (8-8-8). |
QVideoFrame::Format_YUV420P
|
18
|
The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are half that of the Y plane. |
QVideoFrame::Format_YV12
|
19
|
The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are half that of the Y plane. |
QVideoFrame::Format_UYVY
|
20
|
The frame is stored using an 8-bit per component packed YUV format with the U and V planes horizontally sub-sampled (U-Y-V-Y), i.e. two horizontally adjacent pixels are stored as a 32-bit macropixel which has a Y value for each pixel and common U and V values. |
QVideoFrame::Format_YUYV
|
21
|
The frame is stored using an 8-bit per component packed YUV format with the U and V planes horizontally sub-sampled (Y-U-Y-V), i.e. two horizontally adjacent pixels are stored as a 32-bit macropixel which has a Y value for each pixel and common U and V values. |
QVideoFrame::Format_NV12
|
22
|
The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) followed by a horizontally and vertically sub-sampled, packed UV plane (U-V). |
QVideoFrame::Format_NV21
|
23
|
The frame is stored using an 8-bit per component semi-planar YUV format with a Y plane (Y) followed by a horizontally and vertically sub-sampled, packed VU plane (V-U). |
QVideoFrame::Format_IMC1
|
24
|
The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except that the bytes per line of the U and V planes are padded out to the same stride as the Y plane. |
QVideoFrame::Format_IMC2
|
25
|
The frame is stored using an 8-bit per component planar YUV format with the U and V planes horizontally and vertically sub-sampled. This is similar to the Format_YUV420P type, except that the lines of the U and V planes are interleaved, i.e. each line of U data is followed by a line of V data creating a single line of the same stride as the Y data. |
QVideoFrame::Format_IMC3
|
26
|
The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that the bytes per line of the V and U planes are padded out to the same stride as the Y plane. |
QVideoFrame::Format_IMC4
|
27
|
The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled. This is similar to the Format_YV12 type, except that the lines of the V and U planes are interleaved, i.e. each line of V data is followed by a line of U data creating a single line of the same stride as the Y data. |
QVideoFrame::Format_Y8
|
28
|
使用 8 位灰度格式存储帧。 |
QVideoFrame::Format_Y16
|
29
|
使用 16 位线性灰度格式存储帧。小端在前。 |
QVideoFrame::Format_Jpeg
|
30
|
以压缩的 JPEG 格式存储帧。 |
QVideoFrame::Format_CameraRaw
|
31
|
使用特定设备摄像头原生格式存储帧。 |
QVideoFrame::Format_AdobeDng
|
32
|
使用原生 Adobe DNG (数字负片) 格式存储帧。 |
QVideoFrame::Format_User
|
1000
|
用户定义像素格式的起始值。 |
构造 null 视频帧。
构造视频帧从 buffer 采用给定像素 format and size (以像素为单位)。
注意: 这不会递增视频缓冲的引用计数。
构造视频帧采用给定像素 format and size (以像素为单位)。
The bytesPerLine (步幅) 是每扫描行的长度 (以字节为单位),和 bytes 是必须为帧分配的总字节数。
构造视频帧从 image .
注意: 这会构造无效视频帧,若不存在等价图像格式的帧类型。
另请参阅 pixelFormatFromImageFormat ().
构造浅拷贝为 other 。由于 QVideoFrame 是明确共享的,这 2 实例将反射相同帧。
销毁视频帧。
返回关联此帧的任何额外元数据。
返回指向帧数据缓冲起始的指针。
此值才有效当帧数据为 mapped .
凭借此指针访问数据做出的改变 (当采用写入访问映射时) 只保证有持久化当 unmap () 被调用和当缓冲已被映射以供写入。
另请参阅 map (), mappedBytes (),和 bytesPerLine ().
返回指针指向帧数据缓冲的开始为 plane .
此值才有效当帧数据为 mapped .
凭借此指针访问数据做出的改变 (当采用写入访问映射时) 只保证有持久化当 unmap () 被调用和当缓冲已被映射以供写入。
该函数在 Qt 5.4 引入。
另请参阅 map (), mappedBytes (), bytesPerLine (),和 planeCount ().
返回指向帧数据缓冲起始的指针。
此值才有效当帧数据为 mapped .
若缓冲未采用读取访问被映射,此缓冲的内容将被初始为未被初始化。
另请参阅 map (), mappedBytes (),和 bytesPerLine ().
返回指针指向帧数据缓冲的开始为 plane .
此值才有效当帧数据为 mapped .
若缓冲未采用读取访问被映射,此缓冲的内容将被初始为未被初始化。
该函数在 Qt 5.4 引入。
另请参阅 map (), mappedBytes (), bytesPerLine (),和 planeCount ().
返回扫描行字节数。
注意: For planar formats this is the bytes per line of the first plane only. The bytes per line of subsequent planes should be calculated as per the frame 像素格式 .
此值才有效当帧数据为 mapped .
另请参阅 bits (), map (),和 mappedBytes ().
Returns the number of bytes in a scan line of a plane .
此值才有效当帧数据为 mapped .
该函数在 Qt 5.4 引入。
另请参阅 bits (), map (), mappedBytes (),和 planeCount ().
返回要显示的呈现时间 (以微秒为单位),当帧应停止时。
无效时间表示为 -1。
另请参阅 setEndTime ().
返回隔行扫描视频帧所属的字段。
若不是隔行扫描视频,这会返回 WholeFrame。
另请参阅 setFieldType ().
返回视频帧缓冲的特定类型句柄。
对于 OpenGL 纹理,这将是纹理 ID。
另请参阅 QAbstractVideoBuffer::handle ().
返回视频帧的句柄类型。
返回视频帧的高度。
[static]
QImage::Format
QVideoFrame::
imageFormatFromPixelFormat
(
PixelFormat
format
)
返回图像格式等效视频帧像素 format 。若没有等效格式 QImage::Format_Invalid 被返回取而代之。
注意: 一般而言 QImage 没有 YUV 格式。
标识目前是否把视频帧内容,映射到系统内存。
This is a convenience function which checks that the MapMode of the frame is not equal to QAbstractVideoBuffer::NotMapped .
Returns true if the contents of the video frame are mapped to system memory, and false otherwise.
另请参阅 mapMode () 和 QAbstractVideoBuffer::MapMode .
标识视频帧映射内容,是否是从帧读取当映射时。
这是方便校验函数若 MapMode 包含 QAbstractVideoBuffer::WriteOnly 标志。
返回 true 若从视频帧读取映射内存内容,和 false 否则。
另请参阅 mapMode () 和 QAbstractVideoBuffer::MapMode .
标识视频帧是否有效。
无效帧没有关联它的视频缓冲。
返回 true 若帧有效,和 false 若帧无效。
标识视频帧的映射内容是否会持久化,当取消帧映射时。
这是方便校验函数若 MapMode 包含 QAbstractVideoBuffer::WriteOnly 标志。
返回 true 若将更新视频帧当取消映射时,否则返回 false。
注意: 更改以只读方式映射帧数据的结果未定义。从属缓冲实现,改变可能持久化,或更糟更改共享缓冲。
另请参阅 mapMode () 和 QAbstractVideoBuffer::MapMode .
把视频帧的内容映射到系统 (CPU 可寻址) 内存。
在某些情况下,视频帧数据可能存储在视频内存 (或其它不可访问内存) 中,因此有必要映射帧在访问像素数据前。这可能涉及围绕内容的拷贝,所以,应避免映射和取消映射 (除非要求)。
映射
mode
指示映射内存内容是否应读取自和/或写入帧。若映射模式包括
QAbstractVideoBuffer::ReadOnly
标志将采用视频帧内容填充映射内存当初始映射时。若映射模式包括
QAbstractVideoBuffer::WriteOnly
标志可能将修改映射内存内容写回到帧当取消映射时。
当映射时,可以直接访问视频帧内容透过指针返回通过 bits () 函数。
当访问数据不再需要时,确保调用 unmap () 函数以释放映射内存且可能更新视频帧内容。
若已以只读方式映射视频帧,则以只读方式多次映射 (且取消映射它相应次数) 是准许的。在所有其它情况下,有必要先取消帧映射,在第 2 次映射前。
注意: 由于只读写入映射内存未定义,且可能导致共享数据改变 (或崩溃)。
返回 true 若映射帧到内存按给定 mode 和 false 否则。
另请参阅 unmap (), mapMode (),和 bits ().
返回将视频帧映射到系统内存中的模式。
另请参阅 map () 和 QAbstractVideoBuffer::MapMode .
返回由映射帧数据所占据的字节数。
此值才有效当帧数据为 mapped .
另请参阅 map ().
返回此帧的任何元数据为给定 key .
这可能包括来自摄像头的帧特定信息,或来自解码视频流的字幕。
见相关视频帧生产者文档编制,进一步了解可用元数据的有关信息。
另请参阅 setMetaData ().
返回视频帧的颜色格式。
[static]
PixelFormat
QVideoFrame::
pixelFormatFromImageFormat
(
QImage::Format
format
)
返回视频像素格式相当于图像 format 。若不存在等价格式,返回 QVideoFrame::InvalidType 代替。
注意: 一般而言 QImage 没有 YUV 格式。
返回视频帧中的平面数。
此值才有效当帧数据为 mapped .
该函数在 Qt 5.4 引入。
另请参阅 map ().
设置呈现 time (以微秒为单位) 当帧应停止显示时。
无效时间表示为 -1。
另请参阅 endTime ().
设置 field 属于隔行扫描视频帧。
另请参阅 fieldType ().
设置元数据为给定 key to value .
若 value 是 null 变体,将移除此键的任何元数据。
视频帧生产者可能使用这将某些数据与此帧关联,或让中间处理器为此帧的消费者添加信息。
另请参阅 metaData ().
设置呈现 time (以微秒为单位) 当帧应该被初始显示时。
无效时间表示为 -1。
另请参阅 startTime ().
返回视频帧尺度。
返回呈现时间 (以微秒为单位) 当帧应该被显示时。
无效时间表示为 -1。
另请参阅 setStartTime ().
释放内存映射通过 map () 函数。
若 MapMode 包括 QAbstractVideoBuffer::WriteOnly 标志,则这会把映射内存当前内容坚持到视频帧。
unmap() 不应被调用,若 map () 函数失败。
另请参阅 map ().
返回视频帧的宽度。
返回
true
若此
QVideoFrame
and
other
不反射相同帧。
赋值内容对于 other 到此视频帧。由于 QVideoFrame 是明确共享的,这 2 实例将反射相同帧。
返回
true
若此
QVideoFrame
and
other
反射相同帧。