
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQVideoFrame class provides a representation of a frame of video data.More...
| Header: | #include <QVideoFrame> |
| Since: | Qt 4.6 |
| 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() | |
| uchar * | bits() |
| const uchar * | bits() const |
| int | bytesPerLine() 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 |
| PixelFormat | pixelFormat() const |
| void | setEndTime(qint64 time) |
| void | setFieldType(FieldType field) |
| void | setStartTime(qint64 time) |
| QSize | size() const |
| qint64 | startTime() const |
| void | unmap() |
| int | width() const |
| QVideoFrame & | operator=(const QVideoFrame & other) |
| QImage::Format | imageFormatFromPixelFormat(PixelFormat format) |
| PixelFormat | pixelFormatFromImageFormat(QImage::Format format) |
TheQVideoFrame class provides a representation of a frame of video data.
AQVideoFrame encapsulates the data of a video frame, and information about the frame.
The contents of a video frame can be mapped to memory using themap() function. While mapped the video data can accessed using thebits() function which returns a pointer to a buffer, the total size of which is given by themappedBytes(), and the size of each line is given bybytesPerLine(). The return value of thehandle() function may be used to access frame data using the internal buffer's native APIs.
The video data in aQVideoFrame is encapsulated in aQAbstractVideoBuffer. AQVideoFrame may be constructed from any buffer type by subclassing theQAbstractVideoBuffer class.
Note:QVideoFrame is explicitly shared, any change made to video frame will also apply to any copies.
Specifies the field an interlaced video frame belongs to.
| Constant | Value | Description |
|---|---|---|
QVideoFrame::ProgressiveFrame | 0 | The frame is not interlaced. |
QVideoFrame::TopField | 1 | The frame contains a top field. |
QVideoFrame::BottomField | 2 | The frame contains a bottom field. |
QVideoFrame::InterlacedFrame | 3 | The frame contains a merged top and bottom field. |
Enumerates video data types.
| Constant | Value | Description |
|---|---|---|
QVideoFrame::Format_Invalid | 0 | The frame is invalid. |
QVideoFrame::Format_ARGB32 | 1 | The frame is stored using a 32-bit ARGB format (0xAARRGGBB). This is equivalent toQImage::Format_ARGB32. |
QVideoFrame::Format_ARGB32_Premultiplied | 2 | The frame stored using a premultiplied 32-bit ARGB format (0xAARRGGBB). This is equivalent toQImage::Format_ARGB32_Premultiplied. |
QVideoFrame::Format_RGB32 | 3 | The frame stored using a 32-bit RGB format (0xffRRGGBB). This is equivalent toQImage::Format_RGB32 |
QVideoFrame::Format_RGB24 | 4 | The frame is stored using a 24-bit RGB format (8-8-8). This is equivalent toQImage::Format_RGB888 |
QVideoFrame::Format_RGB565 | 5 | The frame is stored using a 16-bit RGB format (5-6-5). This is equivalent toQImage::Format_RGB16. |
QVideoFrame::Format_RGB555 | 6 | The frame is stored using a 16-bit RGB format (5-5-5). This is equivalent toQImage::Format_RGB555. |
QVideoFrame::Format_ARGB8565_Premultiplied | 7 | The frame is stored using a 24-bit premultiplied ARGB format (8-6-6-5). |
QVideoFrame::Format_BGRA32 | 8 | The frame is stored using a 32-bit ARGB 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 | The frame is stored using a 16-bit BGR format (5-6-5). |
QVideoFrame::Format_BGR555 | 13 | The frame is stored using a 16-bit BGR format (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 | The frame is stored using an 8-bit greyscale format. |
QVideoFrame::Format_Y16 | 29 | The frame is stored using a 16-bit linear greyscale format. Little endian. |
QVideoFrame::Format_User | 1000 | Start value for user defined pixel formats. |
Constructs a null video frame.
Constructs a video frame from abuffer of the given pixelformat andsize in pixels.
Note:This doesn't increment the reference count of the video buffer.
Constructs a video frame of the given pixelformat andsize in pixels.
ThebytesPerLine (stride) is the length of each scan line in bytes, andbytes is the total number of bytes that must be allocated for the frame.
Constructs a video frame from animage.
Note:This will construct an invalid video frame if there is no frame type equivalent to the image format.
See alsopixelFormatFromImageFormat().
Constructs a copy ofother.
Destroys a video frame.
Returns a pointer to the start of the frame data buffer.
This value is only valid while the frame data ismapped.
See alsomap(),mappedBytes(), andbytesPerLine().
Returns a pointer to the start of the frame data buffer.
This value is only valid while the frame data ismapped.
See alsomap(),mappedBytes(), andbytesPerLine().
Returns the number of bytes in a scan line.
Note: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 type.
This value is only valid while the frame data ismapped.
See alsobits(),map(), andmappedBytes().
Returns the presentation time when a frame should stop being displayed.
See alsosetEndTime().
Returns the field an interlaced video frame belongs to.
If the video is not interlaced this will return WholeFrame.
See alsosetFieldType().
Returns a type specific handle to a video frame's buffer.
For anOpenGL texture this would be the texture ID.
See alsoQAbstractVideoBuffer::handle().
Returns the type of a video frame's handle.
Returns the height of a video frame.
[static]QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format)Returns an image format equivalent to a video frame pixelformat. If there is no equivalent formatQImage::Format_Invalid is returned instead.
Identifies if a video frame's contents are currently mapped to system memory.
This is a convenience function which checks that theMapMode of the frame is not equal toQAbstractVideoBuffer::NotMapped.
Returns true if the contents of the video frame are mapped to system memory, and false otherwise.
See alsomapMode() andQAbstractVideoBuffer::MapMode.
Identifies if the mapped contents of a video frame were read from the frame when it was mapped.
This is a convenience function which checks if theMapMode contains theQAbstractVideoBuffer::WriteOnly flag.
Returns true if the contents of the mapped memory were read from the video frame, and false otherwise.
See alsomapMode() andQAbstractVideoBuffer::MapMode.
Identifies whether a video frame is valid.
An invalid frame has no video buffer associated with it.
Returns true if the frame is valid, and false if it is not.
Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped.
This is a convenience function which checks if theMapMode contains theQAbstractVideoBuffer::WriteOnly flag.
Returns true if the video frame will be updated when unmapped, and false otherwise.
Note:The result of altering the data of a frame that is mapped in read-only mode is undefined. Depending on the buffer implementation the changes may be persisted, or worse alter a shared buffer.
See alsomapMode() andQAbstractVideoBuffer::MapMode.
Maps the contents of a video frame to memory.
The mapmode indicates whether the contents of the mapped memory should be read from and/or written to the frame. If the map mode includes theQAbstractVideoBuffer::ReadOnly flag the mapped memory will be populated with the content of the video frame when mapped. If the map mode inclues theQAbstractVideoBuffer::WriteOnly flag the content of the mapped memory will be persisted in the frame when unmapped.
While mapped the contents of a video frame can be accessed directly through the pointer returned by thebits() function.
When access to the data is no longer needed be sure to call theunmap() function to release the mapped memory.
Returns true if the buffer was mapped to memory in the givenmode and false otherwise.
See alsounmap(),mapMode(), andbits().
Returns the mode a video frame was mapped to system memory in.
See alsomap() andQAbstractVideoBuffer::MapMode.
Returns the number of bytes occupied by the mapped frame data.
This value is only valid while the frame data ismapped.
See alsomap().
Returns the color format of a video frame.
[static]PixelFormat QVideoFrame::pixelFormatFromImageFormat(QImage::Format format)Returns an video pixel format equivalent to an imageformat. If there is no equivalent format QVideoFrame::InvalidType is returned instead.
Sets the presentationtime when a frame should stop being displayed.
See alsoendTime().
Sets thefield an interlaced video frame belongs to.
See alsofieldType().
Sets the presentationtime when the frame should be displayed.
See alsostartTime().
Returns the size of a video frame.
Returns the presentation time when the frame should be displayed.
See alsosetStartTime().
Releases the memory mapped by themap() function.
If theMapMode included theQAbstractVideoBuffer::WriteOnly flag this will persist the current content of the mapped memory to the video frame.
See alsomap().
Returns the width of a video frame.
Assigns the contents ofother to a video frame.
© 2016 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 theGNU 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.