QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
CpuVideoFramePool Class Reference

Recycles CPU-backed QVideoFrame storage keyed by (size, pixelFormat) to avoid per-frame malloc churn. More...

#include <CpuVideoFramePool.h>

Classes

struct  PlaneLayout
 

Public Member Functions

QVideoFrame acquireFrame (const QVideoFrameFormat &format, const GstVideoInfo &info)
 Returns a pool-backed frame sized to info, or freshly allocates on a pool miss; invalid if unsupported.
 
quint64 hitCount () const noexcept
 Telemetry: total acquireFrame() calls satisfied from the pool vs. fresh alloc.
 
quint64 missCount () const noexcept
 
void releaseBacking (QSize size, QVideoFrameFormat::PixelFormat format, QByteArray &&backing)
 Return a backing array to the pool; called by PooledCpuVideoBuffer's destructor only.
 

Static Public Member Functions

static CpuVideoFramePoolinstance ()
 
static std::unique_ptr< QAbstractVideoBuffer > wrapZeroCopy (GstBuffer *buffer, const GstVideoInfo &info, const QVideoFrameFormat &format)
 
static PlaneLayout computeLayout (const GstVideoInfo &info)
 Destination plane layout mirroring info (strides/offsets from the decoder). planeCount==0 means unsupported.
 
static QVideoFrame copyFromBuffer (GstBuffer *buffer, const GstVideoInfo &videoInfo, const QVideoFrameFormat &format)
 Copy buffer's planes into a pool-allocated QVideoFrame; invalid on stride overflow or unsupported format.
 

Detailed Description

Recycles CPU-backed QVideoFrame storage keyed by (size, pixelFormat) to avoid per-frame malloc churn.

Definition at line 17 of file CpuVideoFramePool.h.

Member Function Documentation

◆ acquireFrame()

QVideoFrame CpuVideoFramePool::acquireFrame ( const QVideoFrameFormat &  format,
const GstVideoInfo &  info 
)

Returns a pool-backed frame sized to info, or freshly allocates on a pool miss; invalid if unsupported.

Definition at line 230 of file CpuVideoFramePool.cc.

References CpuVideoFramePool::PlaneLayout::byteSize, computeLayout(), and CpuVideoFramePool::PlaneLayout::planeCount.

Referenced by copyFromBuffer().

◆ computeLayout()

CpuVideoFramePool::PlaneLayout CpuVideoFramePool::computeLayout ( const GstVideoInfo &  info)
static

Destination plane layout mirroring info (strides/offsets from the decoder). planeCount==0 means unsupported.

Definition at line 157 of file CpuVideoFramePool.cc.

References CpuVideoFramePool::PlaneLayout::byteSize, CpuVideoFramePool::PlaneLayout::bytesPerLine, CpuVideoFramePool::PlaneLayout::height, CpuVideoFramePool::PlaneLayout::planeCount, and CpuVideoFramePool::PlaneLayout::planeOffset.

Referenced by acquireFrame().

◆ copyFromBuffer()

QVideoFrame CpuVideoFramePool::copyFromBuffer ( GstBuffer *  buffer,
const GstVideoInfo &  videoInfo,
const QVideoFrameFormat &  format 
)
static

Copy buffer's planes into a pool-allocated QVideoFrame; invalid on stride overflow or unsupported format.

Definition at line 260 of file CpuVideoFramePool.cc.

References acquireFrame(), and instance().

Referenced by mapSampleToFrame().

◆ hitCount()

quint64 CpuVideoFramePool::hitCount ( ) const
inlinenoexcept

Telemetry: total acquireFrame() calls satisfied from the pool vs. fresh alloc.

Definition at line 31 of file CpuVideoFramePool.h.

◆ instance()

CpuVideoFramePool & CpuVideoFramePool::instance ( )
static

Definition at line 151 of file CpuVideoFramePool.cc.

Referenced by copyFromBuffer().

◆ missCount()

quint64 CpuVideoFramePool::missCount ( ) const
inlinenoexcept

Definition at line 33 of file CpuVideoFramePool.h.

◆ releaseBacking()

void CpuVideoFramePool::releaseBacking ( QSize  size,
QVideoFrameFormat::PixelFormat  format,
QByteArray &&  backing 
)

Return a backing array to the pool; called by PooledCpuVideoBuffer's destructor only.

Definition at line 198 of file CpuVideoFramePool.cc.

◆ wrapZeroCopy()

std::unique_ptr< QAbstractVideoBuffer > CpuVideoFramePool::wrapZeroCopy ( GstBuffer *  buffer,
const GstVideoInfo &  info,
const QVideoFrameFormat &  format 
)
static

Zero-copy CPU frame: wraps buffer and maps its system memory through to Qt. nullptr if not CPU-mappable (caller copies instead). Pins the decoder buffer for the frame's lifetime.

Definition at line 241 of file CpuVideoFramePool.cc.

Referenced by mapSampleToFrame().


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