avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::Frame< T > Class Template Reference

CRTP base that gives a frame type its copy and move assignment. More...

#include <frame.h>

Inheritance diagram for av::Frame< T >:

Public Member Functions

T clone (size_t align=1) const
 Deep copy of the frame.
 FrameCommon ()
 Create an invalid frame.
 FrameCommon (const AVFrame *frame)
 Copy the frame metadata into a new wrapper.
 FrameCommon (const FrameCommon &other)
 Copy constructor: references the same buffer.
 FrameCommon (FrameCommon &&other)
 Move constructor.
Public Member Functions inherited from av::FrameCommon
 FrameCommon ()
 Create an invalid frame.
 FrameCommon (const AVFrame *frame)
 Copy the frame metadata into a new wrapper.
 FrameCommon (const FrameCommon &other)
 Copy constructor: references the same buffer.
 FrameCommon (FrameCommon &&other)
 Move constructor.
bool isReferenced () const
 Whether the frame data is reference counted.
int refCount () const
 Number of references to the frame buffer.
AVFrame * makeRef () const
 Create an independent reference to the frame.
Timestamp pts () const
 Presentation timestamp.
attribute_deprecated void setPts (int64_t pts, Rational ptsTimeBase)
 Set the timestamp and its time base at once.
void setPts (const Timestamp &ts)
 Set the timestamp.
const Rational & timeBase () const
 Time base of the frame.
void setTimeBase (const Rational &value)
 Set the time base.
int streamIndex () const
 Index of the stream the frame belongs to.
void setStreamIndex (int streamIndex)
 Set the stream index.
void setComplete (bool isComplete)
 Mark the frame as complete or incomplete.
bool isComplete () const
 Whether the frame is marked complete.
bool isValid () const
 Whether the wrapper holds a frame.
 operator bool () const
 Whether the wrapper holds a frame.
bool isHwFrame () const
 Whether the frame lives in device memory.
uint8_t * data (size_t plane=0)
 Pointer to one image or audio plane.
const uint8_t * data (size_t plane=0) const
 Pointer to one plane, read-only.
size_t size (size_t plane) const
 Size of one plane.
size_t size () const
 Total size of all planes.
void dump () const
 Print the frame layout through the FFmpeg log system.
void operator= (const FrameCommon &)=delete
 Assignment is deleted: derived classes implement it to avoid slicing.
void swap (FrameCommon &other)
 Exchange the contents of two frames.
const FrameSideData sideData (AVFrameSideDataType type) const
 Get packet side data of the given type.
FrameSideData sideData (AVFrameSideDataType type)
 Mutable access to the side data of the given type.
std::size_t sideDataCount () const noexcept
 Return count of the side data elements.
FrameSideData sideDataIndex (std::size_t index) noexcept
 Get side data element by index.
ArrayView< AVFrameSideData *, FrameSideData, std::size_t > sideData () noexcept
 Observe all packet side data via iterators.
ArrayView< const AVFrameSideData *, FrameSideData, std::size_t > sideData () const noexcept
 Read-only iteration over all side data entries.
void sideDataRemove (AVFrameSideDataType type) noexcept
 Remove and free all side data instances of the given type.
FrameSideData addSideData (AVFrameSideDataType type, std::span< const uint8_t > data, OptionalErrorCode ec=throws())
 Add side data of the given type into packet.
FrameSideData addSideData (AVFrameSideDataType type, std::span< uint8_t > data, wrap_data, OptionalErrorCode ec=throws())
 Add side data of the given type into packet.
FrameSideData addSideData (AVFrameSideDataType type, std::span< uint8_t > data, wrap_data_static, OptionalErrorCode ec=throws())
 Add side data of the given type into packet.
FrameSideData addSideData (AVFrameSideDataType type, BufferRef buf, OptionalErrorCode ec=throws())
 Add side data of the given type into packet.
FrameSideData allocateSideData (AVFrameSideDataType type, std::size_t size, OptionalErrorCode ec=throws())
 Allocate storage for the packet side data of the given type and return reference to it.
Public Member Functions inherited from FFWrapperPtr< AVFrame >
 FFWrapperPtr ()=default
 Create an empty wrapper; isNull() is true.
const AVFrame * raw () const
 Read access to the wrapped object.
void reset (AVFrame *raw=nullptr)
 Replace the stored pointer.
bool isNull () const
 Whether the wrapper is empty.
void _log (int level, const char *fmt) const
 Log through the FFmpeg log system, using this wrapper as the context.

Static Public Member Functions

static T null ()
 An invalid frame of this type.

Protected Member Functions

T & assignOperator (const T &rhs)
 Copy the other frame into this one.
T & moveOperator (T &&rhs)
 Move the other frame into this one.
Protected Member Functions inherited from av::FrameCommon
void copyInfoFrom (const FrameCommon &other)
 Copy the avcpp bookkeeping (time base, stream index, completeness).
void clone (FrameCommon &dst, size_t align=1) const
 Make a deep copy of the frame data into another frame object.

Additional Inherited Members

Protected Attributes inherited from av::FrameCommon
Rational m_timeBase {}
 Time base of the timestamps in this frame.
int m_streamIndex {-1}
 Index of the stream the frame belongs to; -1 when unset.
bool m_isComplete {false}
 Completeness flag, set through setComplete().
Protected Attributes inherited from FFWrapperPtr< AVFrame >
AVFrame * m_raw
 The wrapped pointer; owned by the derived class, not by this template.

Detailed Description

template<typename T>
class av::Frame< T >

The derived class passes itself as T; the base supplies the operations that must not be inherited from FrameCommon directly.

Template Parameters
Tthe derived frame type

Member Function Documentation

◆ assignOperator()

template<typename T>
T & av::Frame< T >::assignOperator ( const T & rhs)
inlineprotected
Parameters
rhsthe frame to copy
Returns
this frame

◆ clone()

template<typename T>
T av::Frame< T >::clone ( size_t align = 1) const
inline
Parameters
alignalignment in bytes for the allocated planes
Returns
an independent frame; invalid when this one is invalid

◆ FrameCommon() [1/3]

template<typename T>
av::FrameCommon::FrameCommon ( const AVFrame< T > * frame)

The data itself is referenced, not copied.

Parameters
framethe frame to reference

◆ FrameCommon() [2/3]

template<typename T>
av::FrameCommon::FrameCommon ( const FrameCommon & other)
Parameters
otherthe wrapper to copy

◆ FrameCommon() [3/3]

template<typename T>
av::FrameCommon::FrameCommon ( FrameCommon && other)
Parameters
otherthe wrapper to move from; left invalid

◆ moveOperator()

template<typename T>
T & av::Frame< T >::moveOperator ( T && rhs)
inlineprotected
Parameters
rhsthe frame to move from
Returns
this frame

◆ null()

template<typename T>
T av::Frame< T >::null ( )
inlinestatic
Returns
a frame wrapper that holds no AVFrame

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