Qt 6.x
The Qt SDK
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)
 
 ~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 (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 QVideoFrame::MapMode mapMode () const =0
 
virtual MapData map (QVideoFrame::MapMode mode)=0
 Independently maps the planes of a video buffer to memory.
 
virtual void unmap ()=0
 Releases the memory mapped by the map() function.
 
virtual std::unique_ptr< QVideoFrameTexturesmapTextures (QRhi *)
 
virtual quint64 textureHandle (int) const
 Returns a texture handle to the data buffer.
 
virtual QMatrix4x4 externalTextureMatrix () 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()

QT_BEGIN_NAMESPACE QFFmpegVideoBuffer::QFFmpegVideoBuffer ( AVFrameUPtr  frame)

Definition at line 25 of file qffmpegvideobuffer.cpp.

References convertSWFrame(), QFFmpeg::HWAccel::format(), frame, and toQtPixelFormat().

+ Here is the call graph for this function:

◆ ~QFFmpegVideoBuffer()

QFFmpegVideoBuffer::~QFFmpegVideoBuffer ( )
overridedefault

Member Function Documentation

◆ colorRange()

◆ colorSpace()

◆ colorTransfer()

◆ convertSWFrame()

void QFFmpegVideoBuffer::convertSWFrame ( )

Definition at line 42 of file qffmpegvideobuffer.cpp.

References isFrameFlipped(), QFFmpeg::makeAVFrame(), pixelFormat(), Q_ASSERT, toAVPixelFormat(), and toQtPixelFormat().

Referenced by QFFmpegVideoBuffer(), and 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 Q_LOGGING_CATEGORY().

+ 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 166 of file qffmpegvideobuffer.cpp.

References QAbstractVideoBuffer::MapData::bytesPerLine, convertSWFrame(), QAbstractVideoBuffer::MapData::data, desc, i, QFFmpeg::makeAVFrame(), mapData(), QAbstractVideoBuffer::MapData::nPlanes, pixelFormat(), Q_ASSERT, qWarning, ret, QAbstractVideoBuffer::MapData::size, and QVideoTextureHelper::textureDescription().

+ Here is the call graph for this function:

◆ mapMode()

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

Implements QAbstractVideoBuffer.

Definition at line 161 of file qffmpegvideobuffer.cpp.

◆ mapTextures()

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

Reimplemented from QAbstractVideoBuffer.

Definition at line 200 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 145 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 221 of file qffmpegvideobuffer.cpp.

Referenced by convertSWFrame(), map(), and toAVPixelFormat().

+ Here is the caller graph for this function:

◆ setTextureConverter()

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

Definition at line 68 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 226 of file qffmpegvideobuffer.cpp.

◆ textureHandle()

quint64 QFFmpegVideoBuffer::textureHandle ( int  ) const
overridevirtual

Returns a texture handle to the data buffer.

See also
handleType()

Reimplemented from QAbstractVideoBuffer.

Definition at line 216 of file qffmpegvideobuffer.cpp.

◆ toAVPixelFormat()

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

Definition at line 299 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 convertSWFrame(), QAndroidCamera::ffmpegHWPixelFormat(), QAndroidCamera::frameAvailable(), and Q_LOGGING_CATEGORY().

+ 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 195 of file qffmpegvideobuffer.cpp.


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