Recycles CPU-backed QVideoFrame storage keyed by (size, pixelFormat) to avoid per-frame malloc churn. More...
#include <CpuVideoFramePool.h>
Classes | |
| struct | PlaneLayout |
| class | FrameMapping |
Public Types | |
| using | PinnedFrameCounter = std::shared_ptr<std::atomic<int>> |
| Live zero-copy frames of one sink; shared so frames Qt still holds after the sink is gone can release it. | |
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. | |
| 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 CpuVideoFramePool & | instance () |
| static std::unique_ptr< QAbstractVideoBuffer > | wrapZeroCopy (GstBuffer *buffer, const GstVideoInfo &info, const QVideoFrameFormat &format, const PinnedFrameCounter &pinned) |
| static PlaneLayout | computeLayout (const GstVideoInfo &info) |
Destination plane layout mirroring info (strides/offsets from the decoder). planeCount==0 means unsupported. | |
| static QAbstractVideoBuffer::MapData | mapDataFor (const GstVideoFrame &frame) |
| Qt map data for a frame mapped with gst_video_frame_map, each plane sized by its own row count. | |
| static QVideoFrame | copyFromBuffer (GstBuffer *buffer, const GstVideoInfo &videoInfo, const QVideoFrameFormat &format) |
Static Public Attributes | |
| static constexpr int | kMaxPinnedFrames = 4 |
Recycles CPU-backed QVideoFrame storage keyed by (size, pixelFormat) to avoid per-frame malloc churn.
Definition at line 18 of file CpuVideoFramePool.h.
| using CpuVideoFramePool::PinnedFrameCounter = std::shared_ptr<std::atomic<int>> |
Live zero-copy frames of one sink; shared so frames Qt still holds after the sink is gone can release it.
Definition at line 33 of file CpuVideoFramePool.h.
| 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 227 of file CpuVideoFramePool.cc.
References CpuVideoFramePool::PlaneLayout::byteSize, computeLayout(), and CpuVideoFramePool::PlaneLayout::planeCount.
Referenced by copyFromBuffer().
|
static |
Destination plane layout mirroring info (strides/offsets from the decoder). planeCount==0 means unsupported.
Definition at line 119 of file CpuVideoFramePool.cc.
References CpuVideoFramePool::PlaneLayout::byteSize, CpuVideoFramePool::PlaneLayout::bytesPerLine, CpuVideoFramePool::PlaneLayout::height, CpuVideoFramePool::PlaneLayout::planeCount, GstHw::planeHeight(), and CpuVideoFramePool::PlaneLayout::planeOffset.
Referenced by acquireFrame().
|
static |
Copy buffer's planes into a pool-allocated QVideoFrame of format's frame size, laid out as gst-video lays out videoInfo's format: the top-left part of a buffer whose GstVideoMeta is larger. Invalid on stride overflow, an unsupported format or a buffer smaller than the frame.
Definition at line 260 of file CpuVideoFramePool.cc.
References acquireFrame(), CpuVideoFramePool::FrameMapping::frame(), instance(), CpuVideoFramePool::FrameMapping::mapFrame(), GstHw::planeHeight(), GstHw::planeRowBytes(), and GstHw::setFrameSize().
Referenced by mapSampleToFrame().
|
static |
Definition at line 113 of file CpuVideoFramePool.cc.
Referenced by copyFromBuffer().
|
static |
Qt map data for a frame mapped with gst_video_frame_map, each plane sized by its own row count.
Definition at line 136 of file CpuVideoFramePool.cc.
References CpuVideoFramePool::PlaneLayout::planeCount, and GstHw::planeHeight().
Referenced by CpuVideoFramePool::FrameMapping::map().
| 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 195 of file CpuVideoFramePool.cc.
|
static |
Zero-copy CPU frame: wraps buffer and maps its system memory through to Qt. nullptr if not CPU-mappable or pinned already counts kMaxPinnedFrames (caller copies instead). Pins the decoder buffer for the frame's lifetime.
Definition at line 238 of file CpuVideoFramePool.cc.
Referenced by mapSampleToFrame().
|
staticconstexpr |
Upper bound on decoder buffers one sink holds downstream at once, zero-copy CPU and GPU frames alike: the frame being mapped in show_frame, one pending GUI delivery (latest-frame-only), the frame Qt displays, and the previous frame, whose texture bundle keeps its sample until Qt reuses that in-flight slot (QRhi FramesInFlight is 2 on the common backends).
Definition at line 30 of file CpuVideoFramePool.h.