Qt 4.8
|
The QVideoFrame class provides a representation of a frame of video data. More...
#include <qvideoframe.h>
Public Types | |
enum | FieldType { ProgressiveFrame, TopField, BottomField, InterlacedFrame } |
Specifies the field an interlaced video frame belongs to. More... | |
enum | PixelFormat { Format_Invalid, Format_ARGB32, Format_ARGB32_Premultiplied, Format_RGB32, Format_RGB24, Format_RGB565, Format_RGB555, Format_ARGB8565_Premultiplied, Format_BGRA32, Format_BGRA32_Premultiplied, Format_BGR32, Format_BGR24, Format_BGR565, Format_BGR555, Format_BGRA5658_Premultiplied, Format_AYUV444, Format_AYUV444_Premultiplied, Format_YUV444, Format_YUV420P, Format_YV12, Format_UYVY, Format_YUYV, Format_NV12, Format_NV21, Format_IMC1, Format_IMC2, Format_IMC3, Format_IMC4, Format_Y8, Format_Y16, Format_User = 1000 } |
Enumerates video data types. More... | |
Public Functions | |
uchar * | bits () |
Returns a pointer to the start of the frame data buffer. More... | |
const uchar * | bits () const |
Returns a pointer to the start of the frame data buffer. More... | |
int | bytesPerLine () const |
Returns the number of bytes in a scan line. More... | |
qint64 | endTime () const |
Returns the presentation time when a frame should stop being displayed. More... | |
FieldType | fieldType () const |
Returns the field an interlaced video frame belongs to. More... | |
QVariant | handle () const |
Returns a type specific handle to a video frame's buffer. More... | |
QAbstractVideoBuffer::HandleType | handleType () const |
Returns the type of a video frame's handle. More... | |
int | height () const |
Returns the height of a video frame. More... | |
bool | isMapped () const |
Identifies if a video frame's contents are currently mapped to system memory. More... | |
bool | isReadable () const |
Identifies if the mapped contents of a video frame were read from the frame when it was mapped. More... | |
bool | isValid () const |
Identifies whether a video frame is valid. More... | |
bool | isWritable () const |
Identifies if the mapped contents of a video frame will be persisted when the frame is unmapped. More... | |
bool | map (QAbstractVideoBuffer::MapMode mode) |
Maps the contents of a video frame to memory. More... | |
QAbstractVideoBuffer::MapMode | mapMode () const |
Returns the mode a video frame was mapped to system memory in. More... | |
int | mappedBytes () const |
Returns the number of bytes occupied by the mapped frame data. More... | |
QVideoFrame & | operator= (const QVideoFrame &other) |
Assigns the contents of other to a video frame. More... | |
PixelFormat | pixelFormat () const |
Returns the color format of a video frame. More... | |
QVideoFrame () | |
Constructs a null video frame. More... | |
QVideoFrame (QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format) | |
Constructs a video frame from a buffer of the given pixel format and size in pixels. More... | |
QVideoFrame (int bytes, const QSize &size, int bytesPerLine, PixelFormat format) | |
Constructs a video frame of the given pixel format and size in pixels. More... | |
QVideoFrame (const QImage &image) | |
Constructs a video frame from an image. More... | |
QVideoFrame (const QVideoFrame &other) | |
Constructs a copy of other. More... | |
void | setEndTime (qint64 time) |
Sets the presentation time when a frame should stop being displayed. More... | |
void | setFieldType (FieldType) |
Sets the field an interlaced video frame belongs to. More... | |
void | setStartTime (qint64 time) |
Sets the presentation time when the frame should be displayed. More... | |
QSize | size () const |
Returns the size of a video frame. More... | |
qint64 | startTime () const |
Returns the presentation time when the frame should be displayed. More... | |
void | unmap () |
Releases the memory mapped by the map() function. More... | |
int | width () const |
Returns the width of a video frame. More... | |
~QVideoFrame () | |
Destroys a video frame. More... | |
Static Public Functions | |
static QImage::Format | imageFormatFromPixelFormat (PixelFormat format) |
Returns an image format equivalent to a video frame pixel format. More... | |
static PixelFormat | pixelFormatFromImageFormat (QImage::Format format) |
Returns an video pixel format equivalent to an image format. More... | |
Properties | |
QExplicitlySharedDataPointer< QVideoFramePrivate > | d |
The QVideoFrame class provides a representation of a frame of video data.
A QVideoFrame encapsulates the data of a video frame, and information about the frame.
The contents of a video frame can be mapped to memory using the map() function. While mapped the video data can accessed using the bits() function which returns a pointer to a buffer, the total size of which is given by the mappedBytes(), and the size of each line is given by bytesPerLine(). The return value of the handle() function may be used to access frame data using the internal buffer's native APIs.
The video data in a QVideoFrame is encapsulated in a QAbstractVideoBuffer. A QVideoFrame may be constructed from any buffer type by subclassing the QAbstractVideoBuffer class.
Definition at line 61 of file qvideoframe.h.
Specifies the field an interlaced video frame belongs to.
Enumerator | |
---|---|
ProgressiveFrame | |
TopField | |
BottomField | |
InterlacedFrame |
Definition at line 64 of file qvideoframe.h.
Enumerates video data types.
Definition at line 72 of file qvideoframe.h.
QVideoFrame::QVideoFrame | ( | ) |
Constructs a null video frame.
Definition at line 271 of file qvideoframe.cpp.
QVideoFrame::QVideoFrame | ( | QAbstractVideoBuffer * | buffer, |
const QSize & | size, | ||
PixelFormat | format | ||
) |
Constructs a video frame from a buffer of the given pixel format and size in pixels.
Definition at line 282 of file qvideoframe.cpp.
QVideoFrame::QVideoFrame | ( | int | bytes, |
const QSize & | size, | ||
int | bytesPerLine, | ||
PixelFormat | format | ||
) |
Constructs a video frame of the given pixel format and size in pixels.
The bytesPerLine (stride) is the length of each scan line in bytes, and bytes is the total number of bytes that must be allocated for the frame.
Definition at line 296 of file qvideoframe.cpp.
QVideoFrame::QVideoFrame | ( | const QImage & | image | ) |
Constructs a video frame from an image.
Definition at line 318 of file qvideoframe.cpp.
QVideoFrame::QVideoFrame | ( | const QVideoFrame & | other | ) |
QVideoFrame::~QVideoFrame | ( | ) |
uchar * QVideoFrame::bits | ( | ) |
Returns a pointer to the start of the frame data buffer.
This value is only valid while the frame data is map(){mapped}.
Definition at line 575 of file qvideoframe.cpp.
const uchar * QVideoFrame::bits | ( | ) | const |
Returns a pointer to the start of the frame data buffer.
This value is only valid while the frame data is map(){mapped}.
Definition at line 588 of file qvideoframe.cpp.
int QVideoFrame::bytesPerLine | ( | ) | const |
Returns the number of bytes in a scan line.
This value is only valid while the frame data is map(){mapped}.
Definition at line 562 of file qvideoframe.cpp.
qint64 QVideoFrame::endTime | ( | ) | const |
Returns the presentation time when a frame should stop being displayed.
Definition at line 641 of file qvideoframe.cpp.
QVideoFrame::FieldType QVideoFrame::fieldType | ( | ) | const |
Returns the field an interlaced video frame belongs to.
If the video is not interlaced this will return WholeFrame.
Definition at line 418 of file qvideoframe.cpp.
QVariant QVideoFrame::handle | ( | ) | const |
Returns a type specific handle to a video frame's buffer.
For an OpenGL texture this would be the texture ID.
Definition at line 614 of file qvideoframe.cpp.
QAbstractVideoBuffer::HandleType QVideoFrame::handleType | ( | ) | const |
Returns the type of a video frame's handle.
Definition at line 380 of file qvideoframe.cpp.
int QVideoFrame::height | ( | ) | const |
|
static |
Returns an image format equivalent to a video frame pixel format.
If there is no equivalent format QImage::Format_Invalid is returned instead.
Definition at line 701 of file qvideoframe.cpp.
bool QVideoFrame::isMapped | ( | ) | const |
Identifies if a video frame's contents are currently mapped to system memory.
This is a convenience function which checks that the QAbstractVideoBuffer::MapMode{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.
Definition at line 444 of file qvideoframe.cpp.
bool QVideoFrame::isReadable | ( | ) | const |
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 the QAbstractVideoBuffer::MapMode{MapMode} contains the QAbstractVideoBuffer::WriteOnly flag.
Returns true if the contents of the mapped memory were read from the video frame, and false otherwise.
Definition at line 481 of file qvideoframe.cpp.
bool QVideoFrame::isValid | ( | ) | const |
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.
Definition at line 362 of file qvideoframe.cpp.
bool QVideoFrame::isWritable | ( | ) | const |
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 the QAbstractVideoBuffer::MapMode{MapMode} contains the QAbstractVideoBuffer::WriteOnly flag.
Returns true if the video frame will be updated when unmapped, and false otherwise.
Definition at line 464 of file qvideoframe.cpp.
bool QVideoFrame::map | ( | QAbstractVideoBuffer::MapMode | mode | ) |
Maps the contents of a video frame to memory.
The map mode indicates whether the contents of the mapped memory should be read from and/or written to the frame. If the map mode includes the QAbstractVideoBuffer::ReadOnly flag the mapped memory will be populated with the content of the video frame when mapped. If the map mode inclues the QAbstractVideoBuffer::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 the bits() function.
When access to the data is no longer needed be sure to call the unmap() function to release the mapped memory.
Returns true if the buffer was mapped to memory in the given mode and false otherwise.
Definition at line 517 of file qvideoframe.cpp.
QAbstractVideoBuffer::MapMode QVideoFrame::mapMode | ( | ) | const |
Returns the mode a video frame was mapped to system memory in.
Definition at line 492 of file qvideoframe.cpp.
int QVideoFrame::mappedBytes | ( | ) | const |
Returns the number of bytes occupied by the mapped frame data.
This value is only valid while the frame data is map(){mapped}.
Definition at line 601 of file qvideoframe.cpp.
QVideoFrame & QVideoFrame::operator= | ( | const QVideoFrame & | other | ) |
QVideoFrame::PixelFormat QVideoFrame::pixelFormat | ( | ) | const |
|
static |
Returns an video pixel format equivalent to an image format.
If there is no equivalent format QVideoFrame::InvalidType is returned instead.
Definition at line 660 of file qvideoframe.cpp.
void QVideoFrame::setEndTime | ( | qint64 | time | ) |
Sets the presentation time when a frame should stop being displayed.
Definition at line 650 of file qvideoframe.cpp.
void QVideoFrame::setFieldType | ( | QVideoFrame::FieldType | field | ) |
Sets the field an interlaced video frame belongs to.
Definition at line 427 of file qvideoframe.cpp.
void QVideoFrame::setStartTime | ( | qint64 | time | ) |
Sets the presentation time when the frame should be displayed.
Definition at line 632 of file qvideoframe.cpp.
QSize QVideoFrame::size | ( | ) | const |
qint64 QVideoFrame::startTime | ( | ) | const |
Returns the presentation time when the frame should be displayed.
Definition at line 623 of file qvideoframe.cpp.
void QVideoFrame::unmap | ( | ) |
Releases the memory mapped by the map() function.
If the QAbstractVideoBuffer::MapMode{MapMode} included the QAbstractVideoBuffer::WriteOnly flag this will persist the current content of the mapped memory to the video frame.
Definition at line 540 of file qvideoframe.cpp.
int QVideoFrame::width | ( | ) | const |
|
private |
Definition at line 158 of file qvideoframe.h.
Referenced by bits(), bytesPerLine(), endTime(), fieldType(), handle(), handleType(), height(), isMapped(), isReadable(), isValid(), isWritable(), map(), mapMode(), mappedBytes(), operator=(), pixelFormat(), QVideoFrame(), setEndTime(), setFieldType(), setStartTime(), size(), startTime(), unmap(), and width().