avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
av::PixelFormat Class Reference

The PixelFormat class is a simple wrapper for AVPixelFormat that allow to acces it it properties. More...

#include <pixelformat.h>

Inheritance diagram for av::PixelFormat:

Public Types

using Parent = PixSampleFmtWrapper<PixelFormat, AVPixelFormat>
 The wrapper this type builds on.

Public Member Functions

 PixelFormat ()=default
 Create an unset format, equivalent to AV_PIX_FMT_NONE.
 PixelFormat (const char *name) noexcept
 Look a pixel format up by name.
 PixelFormat (const std::string &name) noexcept
 Look a pixel format up by name.
const char * name (OptionalErrorCode ec=throws()) const
 Name of the format.
const AVPixFmtDescriptor * descriptor (OptionalErrorCode ec=throws()) const
 FFmpeg description of the format.
int bitsPerPixel (OptionalErrorCode ec=throws()) const
 Bits needed for one pixel.
size_t planesCount (OptionalErrorCode ec=throws()) const
 Number of image planes.
PixelFormat swapEndianness () const noexcept
 The same format with the opposite byte order.
size_t convertionLoss (PixelFormat dstFmt, bool srcHasAlpha=false) const noexcept
 What a conversion to another format would lose.
Public Member Functions inherited from PixSampleFmtWrapper< PixelFormat, AVPixelFormat >
constexpr PixSampleFmtWrapper ()=default
 Create a wrapper holding NoneValue.
constexpr PixSampleFmtWrapper (AVPixelFormat fmt) noexcept
 Wrap a raw enum value.
 operator AVPixelFormat () const noexcept
 Implicit conversion to the FFmpeg enum.
AVPixelFormat get () const noexcept
 The stored enum value.
 operator AVPixelFormat & () noexcept
 Mutable access to the stored value.
PixelFormat & operator= (AVPixelFormat fmt) noexcept
 Assign a raw enum value.
void set (AVPixelFormat fmt) noexcept
 Assign a raw enum value.
 operator AVPixelFormat () const noexcept
 Implicit conversion to the FFmpeg enum.
 operator AVPixelFormat & () noexcept
 Mutable access to the stored value.

Additional Inherited Members

Protected Attributes inherited from PixSampleFmtWrapper< PixelFormat, AVPixelFormat >
AVPixelFormat m_fmt
 The stored enum value.

Detailed Description

It has size same to the AVPixelFormat, but wrap pixel description function too. Pixel format descriptor.

A thin wrapper over AVPixelFormat that can answer the questions a pipeline asks: the name of the format, how many planes it has, how many bits per pixel it needs, and what a conversion to another format would cost.

Examples
api2-hw-decode.cpp, api2-hw-encode.cpp, and api2-hw-probe.cpp.

Constructor & Destructor Documentation

◆ PixelFormat() [1/2]

av::PixelFormat::PixelFormat ( const char * name)
explicitnoexcept
Parameters
namethe name FFmpeg uses, for example "yuv420p"

◆ PixelFormat() [2/2]

av::PixelFormat::PixelFormat ( const std::string & name)
explicitnoexcept
Parameters
namethe name FFmpeg uses, for example "yuv420p"

Member Function Documentation

◆ bitsPerPixel()

int av::PixelFormat::bitsPerPixel ( OptionalErrorCode ec = throws()) const
Parameters
echolder for the error code
Returns
the average bit depth, accounting for chroma subsampling

◆ convertionLoss()

size_t av::PixelFormat::convertionLoss ( PixelFormat dstFmt,
bool srcHasAlpha = false ) const
noexcept
Parameters
dstFmttarget format
srcHasAlphawhether the source actually carries alpha
Returns
a combination of the FF_LOSS_* flags, zero when the conversion is lossless

◆ descriptor()

const AVPixFmtDescriptor * av::PixelFormat::descriptor ( OptionalErrorCode ec = throws()) const
Parameters
echolder for the error code
Returns
the descriptor, which describes planes, chroma subsampling and bit depth

◆ name()

const char * av::PixelFormat::name ( OptionalErrorCode ec = throws()) const
Parameters
echolder for the error code; an unset format reports an error
Returns
a static string owned by FFmpeg
Examples
api2-hw-decode.cpp, and api2-hw-probe.cpp.

◆ planesCount()

size_t av::PixelFormat::planesCount ( OptionalErrorCode ec = throws()) const
Parameters
echolder for the error code
Returns
1 for packed formats, 2 to 4 for planar ones

◆ swapEndianness()

PixelFormat av::PixelFormat::swapEndianness ( ) const
noexcept
Returns
the matching *BE or *LE format, or the same value when the format has no endianness variant

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