Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QFFmpegVideoBuffer Class Reference

#include <qffmpegvideobuffer_p.h>

+ Inheritance diagram for QFFmpegVideoBuffer:
+ Collaboration diagram for QFFmpegVideoBuffer:

Public Types

using AVFrameUPtr = QFFmpeg::AVFrameUPtr
 

Public Member Functions

 QFFmpegVideoBuffer (AVFrameUPtr frame, AVRational pixelAspectRatio={ 1, 1 })
 
 ~QFFmpegVideoBuffer () override
 
QVideoFrame::MapMode mapMode () const override
 
MapData map (QVideoFrame::MapMode mode) override
 Independently maps the planes of a video buffer to memory.
 
void unmap () override
 Releases the memory mapped by the map() function.
 
virtual std::unique_ptr< QVideoFrameTexturesmapTextures (QRhi *) override
 
virtual quint64 textureHandle (QRhi *rhi, int plane) const override
 Returns a texture handle to the data buffer.
 
QVideoFrameFormat::PixelFormat pixelFormat () const
 
QSize size () const
 
void convertSWFrame ()
 
AVFrame * getHWFrame () const
 
void setTextureConverter (const QFFmpeg::TextureConverter &converter)
 
QVideoFrameFormat::ColorSpace colorSpace () const
 
QVideoFrameFormat::ColorTransfer colorTransfer () const
 
QVideoFrameFormat::ColorRange colorRange () const
 
float maxNits ()
 
- Public Member Functions inherited from QAbstractVideoBuffer
 QAbstractVideoBuffer (QVideoFrame::HandleType type, QRhi *rhi=nullptr)
 Constructs an abstract video buffer of the given type.
 
virtual ~QAbstractVideoBuffer ()
 Destroys an abstract video buffer.
 
QVideoFrame::HandleType handleType () const
 Returns the type of a video buffer's handle.
 
QRhirhi () const
 Returns the QRhi instance.
 
virtual QMatrix4x4 externalTextureMatrix () const
 
virtual QByteArray underlyingByteArray (int) const
 

Static Public Member Functions

static QVideoFrameFormat::PixelFormat toQtPixelFormat (AVPixelFormat avPixelFormat, bool *needsConversion=nullptr)
 
static AVPixelFormat toAVPixelFormat (QVideoFrameFormat::PixelFormat pixelFormat)
 

Additional Inherited Members

- Protected Attributes inherited from QAbstractVideoBuffer
QVideoFrame::HandleType m_type
 
QRhim_rhi = nullptr
 

Detailed Description

Definition at line 28 of file qffmpegvideobuffer_p.h.

Member Typedef Documentation

◆ AVFrameUPtr

Constructor & Destructor Documentation

◆ QFFmpegVideoBuffer()

QFFmpegVideoBuffer::QFFmpegVideoBuffer ( AVFrameUPtr frame,
AVRational pixelAspectRatio = { 1, 1 } )

Definition at line 29 of file qffmpegvideobuffer.cpp.

References frame, QWidget::height, and QWidget::width.

◆ ~QFFmpegVideoBuffer()

QFFmpegVideoBuffer::~QFFmpegVideoBuffer ( )
overridedefault

Member Function Documentation

◆ colorRange()

◆ colorSpace()

◆ colorTransfer()

◆ convertSWFrame()

void QFFmpegVideoBuffer::convertSWFrame ( )

Definition at line 49 of file qffmpegvideobuffer.cpp.

References QSize::height(), isFrameFlipped(), QFFmpeg::makeAVFrame(), Q_ASSERT, toAVPixelFormat(), toQtPixelFormat(), and QSize::width().

Referenced by map().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHWFrame()

AVFrame * QFFmpegVideoBuffer::getHWFrame ( ) const
inline

Definition at line 51 of file qffmpegvideobuffer_p.h.

Referenced by QFFmpeg::VideoEncoder::processOne().

+ Here is the caller graph for this function:

◆ map()

QAbstractVideoBuffer::MapData QFFmpegVideoBuffer::map ( QVideoFrame::MapMode mode)
overridevirtual

Independently maps the planes of a video buffer to memory.

The map 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 QVideoFrame::ReadOnly flag the mapped memory will be populated with the content of the buffer when initially mapped. If the map mode includes the QVideoFrame::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.

Since
5.4

Implements QAbstractVideoBuffer.

Definition at line 176 of file qffmpegvideobuffer.cpp.

References convertSWFrame(), i, QAbstractVideoBuffer::m_type, QFFmpeg::makeAVFrame(), mapData(), QVideoFrame::NoHandle, pixelFormat(), Q_ASSERT, qCDebug, qWarning, ret, QVideoTextureHelper::textureDescription(), and QVideoFrame::WriteOnly.

+ Here is the call graph for this function:

◆ mapMode()

QVideoFrame::MapMode QFFmpegVideoBuffer::mapMode ( ) const
overridevirtual

Implements QAbstractVideoBuffer.

Definition at line 171 of file qffmpegvideobuffer.cpp.

◆ mapTextures()

std::unique_ptr< QVideoFrameTextures > QFFmpegVideoBuffer::mapTextures ( QRhi * )
overridevirtual

Reimplemented from QAbstractVideoBuffer.

Definition at line 225 of file qffmpegvideobuffer.cpp.

References QFFmpeg::TextureConverter::getTextures(), QFFmpeg::TextureConverter::isNull(), and qWarning.

+ Here is the call graph for this function:

◆ maxNits()

float QFFmpegVideoBuffer::maxNits ( )

Definition at line 155 of file qffmpegvideobuffer.cpp.

References i, maxNits(), and QFFmpeg::mul().

Referenced by maxNits().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pixelFormat()

QVideoFrameFormat::PixelFormat QFFmpegVideoBuffer::pixelFormat ( ) const

Definition at line 250 of file qffmpegvideobuffer.cpp.

Referenced by map(), and toAVPixelFormat().

+ Here is the caller graph for this function:

◆ setTextureConverter()

void QFFmpegVideoBuffer::setTextureConverter ( const QFFmpeg::TextureConverter & converter)

Definition at line 78 of file qffmpegvideobuffer.cpp.

References QFFmpeg::TextureConverter::init(), QFFmpeg::TextureConverter::isNull(), QAbstractVideoBuffer::m_type, QVideoFrame::NoHandle, and QVideoFrame::RhiTextureHandle.

Referenced by QFFmpegVideoSink::setVideoFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

QSize QFFmpegVideoBuffer::size ( ) const

Definition at line 255 of file qffmpegvideobuffer.cpp.

◆ textureHandle()

quint64 QFFmpegVideoBuffer::textureHandle ( QRhi * rhi,
int plane ) const
overridevirtual

Returns a texture handle to the data buffer.

See also
handleType()

Reimplemented from QAbstractVideoBuffer.

Definition at line 245 of file qffmpegvideobuffer.cpp.

References QAbstractVideoBuffer::rhi().

+ Here is the call graph for this function:

◆ toAVPixelFormat()

AVPixelFormat QFFmpegVideoBuffer::toAVPixelFormat ( QVideoFrameFormat::PixelFormat pixelFormat)
static

Definition at line 328 of file qffmpegvideobuffer.cpp.

References QVideoFrameFormat::Format_ABGR8888, QVideoFrameFormat::Format_ARGB8888, QVideoFrameFormat::Format_ARGB8888_Premultiplied, QVideoFrameFormat::Format_AYUV, QVideoFrameFormat::Format_AYUV_Premultiplied, QVideoFrameFormat::Format_BGRA8888, QVideoFrameFormat::Format_BGRA8888_Premultiplied, QVideoFrameFormat::Format_BGRX8888, QVideoFrameFormat::Format_IMC1, QVideoFrameFormat::Format_IMC2, QVideoFrameFormat::Format_IMC3, QVideoFrameFormat::Format_IMC4, QVideoFrameFormat::Format_Invalid, QVideoFrameFormat::Format_Jpeg, QVideoFrameFormat::Format_NV12, QVideoFrameFormat::Format_NV21, QVideoFrameFormat::Format_P010, QVideoFrameFormat::Format_P016, QVideoFrameFormat::Format_RGBA8888, QVideoFrameFormat::Format_RGBX8888, QVideoFrameFormat::Format_SamplerExternalOES, QVideoFrameFormat::Format_UYVY, QVideoFrameFormat::Format_XBGR8888, QVideoFrameFormat::Format_XRGB8888, QVideoFrameFormat::Format_Y16, QVideoFrameFormat::Format_Y8, QVideoFrameFormat::Format_YUV420P, QVideoFrameFormat::Format_YUV420P10, QVideoFrameFormat::Format_YUV422P, QVideoFrameFormat::Format_YUYV, QVideoFrameFormat::Format_YV12, and pixelFormat().

Referenced by QFFmpeg::VideoEncoder::VideoEncoder(), convertSWFrame(), QAndroidCamera::ffmpegHWPixelFormat(), and QAndroidCamera::frameAvailable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toQtPixelFormat()

◆ unmap()

void QFFmpegVideoBuffer::unmap ( )
overridevirtual

Releases the memory mapped by the map() function.

If the \l {QVideoFrame::MapMode}{MapMode} included the QVideoFrame::WriteOnly flag this will write the current content of the mapped memory back to the video frame.

See also
map()

Implements QAbstractVideoBuffer.

Definition at line 218 of file qffmpegvideobuffer.cpp.

References QVideoFrame::NotMapped.


The documentation for this class was generated from the following files: