|
avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
|
Common interface of video frames and audio samples. More...
#include <frame.h>
Classes | |
| struct | wrap_data |
| Wrap data and take owning. More... | |
| struct | wrap_data_static |
| Wrap static data, do not owning and free. More... | |
Public Member Functions | |
| 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. | |
Protected Member Functions | |
| 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. | |
Protected Attributes | |
| 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. | |
Owns an AVFrame and adds the avcpp bookkeeping that FFmpeg keeps outside it: the time base, the stream index and a completeness flag. Derived classes are expected to implement assignment through assignOperator()/moveOperator(); direct assignment is deleted here to make slicing impossible.
Reference counting follows AVPacket/AVFrame semantics: a copy of the wrapper references the same frame buffer, and clone() is the way to get an independent copy.
| av::FrameCommon::FrameCommon | ( | const AVFrame * | frame | ) |
The data itself is referenced, not copied.
| frame | the frame to reference |
| av::FrameCommon::FrameCommon | ( | const FrameCommon & | other | ) |
| other | the wrapper to copy |
| av::FrameCommon::FrameCommon | ( | FrameCommon && | other | ) |
| other | the wrapper to move from; left invalid |
| FrameSideData av::FrameCommon::addSideData | ( | AVFrameSideDataType | type, |
| BufferRef | buf, | ||
| OptionalErrorCode | ec = throws() ) |
Setup via buffer reference view. Nested API does not reference buffer so it must be done with the caller code.
| type | |
| buf | |
| ec |
| FrameSideData av::FrameCommon::addSideData | ( | AVFrameSideDataType | type, |
| std::span< const uint8_t > | data, | ||
| OptionalErrorCode | ec = throws() ) |
Data will be cloned.
| type | |
| data | |
| ec |
| FrameSideData av::FrameCommon::addSideData | ( | AVFrameSideDataType | type, |
| std::span< uint8_t > | data, | ||
| wrap_data | , | ||
| OptionalErrorCode | ec = throws() ) |
Data will be wrapped and owner-shipping taken. Data must be allocated via av_malloc()/av::malloc() family functions.
| type | |
| data | |
| ec |
| FrameSideData av::FrameCommon::addSideData | ( | AVFrameSideDataType | type, |
| std::span< uint8_t > | data, | ||
| wrap_data_static | , | ||
| OptionalErrorCode | ec = throws() ) |
Data will be wrapped without copying and null deleter will be provided. So data maybe any static data.
| type | |
| data | |
| ec |
| FrameSideData av::FrameCommon::allocateSideData | ( | AVFrameSideDataType | type, |
| std::size_t | size, | ||
| OptionalErrorCode | ec = throws() ) |
Data owned by the packet.
| type | |
| size | |
| ec |
|
protected |
| dst | the frame that receives the copy |
| align | alignment in bytes for the allocated planes |
|
protected |
| other | the frame to copy from |
| uint8_t * av::FrameCommon::data | ( | size_t | plane = 0 | ) |
| plane | zero-based plane index; audio uses one plane per channel for planar formats |
| const uint8_t * av::FrameCommon::data | ( | size_t | plane = 0 | ) | const |
| plane | zero-based plane index |
| bool av::FrameCommon::isComplete | ( | ) | const |
| bool av::FrameCommon::isHwFrame | ( | ) | const |
| bool av::FrameCommon::isReferenced | ( | ) | const |
| bool av::FrameCommon::isValid | ( | ) | const |
| AVFrame * av::FrameCommon::makeRef | ( | ) | const |
| av::FrameCommon::operator bool | ( | ) | const |
| Timestamp av::FrameCommon::pts | ( | ) | const |
| int av::FrameCommon::refCount | ( | ) | const |
| void av::FrameCommon::setComplete | ( | bool | isComplete | ) |
| isComplete | true when the frame holds all the data it should |
| void av::FrameCommon::setPts | ( | const Timestamp & | ts | ) |
| ts | the timestamp; its time base is stored with the frame |
| attribute_deprecated void av::FrameCommon::setPts | ( | int64_t | pts, |
| Rational | ptsTimeBase ) |
| pts | timestamp in ptsTimeBase units |
| ptsTimeBase | time base of the timestamp |
| void av::FrameCommon::setStreamIndex | ( | int | streamIndex | ) |
| streamIndex | index of the stream in the container |
| void av::FrameCommon::setTimeBase | ( | const Rational & | value | ) |
| value | timestamp units per second; set it before the frame is passed to another component |
|
noexcept |
|
noexcept |
Applicable for range-based for and std::range:xxx algos.
| FrameSideData av::FrameCommon::sideData | ( | AVFrameSideDataType | type | ) |
| type | the AV_FRAME_DATA_* value to look for |
| const FrameSideData av::FrameCommon::sideData | ( | AVFrameSideDataType | type | ) | const |
Empty buffer means no data.
| type |
|
noexcept |
|
noexcept |
| index |
|
noexcept |
| type |
| size_t av::FrameCommon::size | ( | ) | const |
| size_t av::FrameCommon::size | ( | size_t | plane | ) | const |
| plane | zero-based plane index |
| int av::FrameCommon::streamIndex | ( | ) | const |
| void av::FrameCommon::swap | ( | FrameCommon & | other | ) |
| other | the frame to swap with |
| const Rational & av::FrameCommon::timeBase | ( | ) | const |