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

Converts video frames between sizes and pixel formats. More...

#include <videorescaler.h>

Inheritance diagram for av::VideoRescaler:

Public Member Functions

 VideoRescaler ()
 Create an uninitialised scaler.
 VideoRescaler (int dstWidth, int dstHeight, PixelFormat dstPixelFormat, int srcWidth, int srcHeight, PixelFormat srcPixelFormat, int32_t flags=SwsFlagAuto)
 Create a scaler with explicit source and destination.
 VideoRescaler (int m_dstWidth, int m_dstHeight, PixelFormat m_dstPixelFormat, int32_t flags=SwsFlagAuto)
 Create a scaler that keeps the input geometry and only converts formats.
 VideoRescaler (const VideoRescaler &other)
 Copy the scaler configuration.
 VideoRescaler (VideoRescaler &&other)
 Move the scaler.
VideoRescaler & operator= (const VideoRescaler &rhs)
 Copy assignment: replaces the configuration and the libswscale context.
VideoRescaler & operator= (VideoRescaler &&rhs)
 Move assignment.
int dstWidth () const
 Output width.
int dstHeight () const
 Output height.
PixelFormat dstPixelFormat ()
 Output pixel format.
int srcWidth () const
 Input width.
int srcHeight () const
 Input height.
PixelFormat srcPixelFormat ()
 Input pixel format.
int32_t flags () const
 Scaling options in use.
void rescale (VideoFrame &dst, const VideoFrame &src, OptionalErrorCode ec=throws())
 Scale into an existing frame.
VideoFrame rescale (const VideoFrame &src, OptionalErrorCode ec=throws())
 Scale into a newly allocated frame.
bool isValid () const
 Whether the scaler has a libswscale context.
Public Member Functions inherited from FFWrapperPtr< SwsContext >
 FFWrapperPtr ()=default
 Create an empty wrapper; isNull() is true.
const SwsContext * raw () const
 Read access to the wrapped object.
void reset (SwsContext *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.

Additional Inherited Members

Protected Member Functions inherited from av::noncopyable
 noncopyable (const noncopyable &)=delete
void operator= (const noncopyable &)=delete
Protected Attributes inherited from FFWrapperPtr< SwsContext >
SwsContext * m_raw
 The wrapped pointer; owned by the derived class, not by this template.

Detailed Description

The scaler works on system memory only: a hardware frame must be transferred with VideoFrame::toSystemMemory() first and uploaded back afterwards. Both the source and the destination geometry are fixed at construction, because libswscale allocates its tables for one conversion.

Examples
api2-scale-video.cpp.

Constructor & Destructor Documentation

◆ VideoRescaler() [1/5]

av::VideoRescaler::VideoRescaler ( )

Configure it with rescale() by passing frames of the target geometry, or construct it with explicit sizes.

◆ VideoRescaler() [2/5]

av::VideoRescaler::VideoRescaler ( int dstWidth,
int dstHeight,
PixelFormat dstPixelFormat,
int srcWidth,
int srcHeight,
PixelFormat srcPixelFormat,
int32_t flags = SwsFlagAuto )
Parameters
dstWidthoutput width in pixels
dstHeightoutput height in pixels
dstPixelFormatoutput pixel format
srcWidthinput width in pixels
srcHeightinput height in pixels
srcPixelFormatinput pixel format
flagsa combination of SwsFlags

◆ VideoRescaler() [3/5]

av::VideoRescaler::VideoRescaler ( int m_dstWidth,
int m_dstHeight,
PixelFormat m_dstPixelFormat,
int32_t flags = SwsFlagAuto )
Parameters
m_dstWidthoutput width in pixels
m_dstHeightoutput height in pixels
m_dstPixelFormatoutput pixel format
flagsa combination of SwsFlags

◆ VideoRescaler() [4/5]

av::VideoRescaler::VideoRescaler ( const VideoRescaler & other)
Parameters
otherthe scaler to copy

◆ VideoRescaler() [5/5]

av::VideoRescaler::VideoRescaler ( VideoRescaler && other)
Parameters
otherthe scaler to move from; left uninitialised

Member Function Documentation

◆ dstHeight()

int av::VideoRescaler::dstHeight ( ) const
inline
Returns
the height in pixels, or -1 when it is not configured

◆ dstPixelFormat()

PixelFormat av::VideoRescaler::dstPixelFormat ( )
inline
Returns
the format, or AV_PIX_FMT_NONE when it is not configured

◆ dstWidth()

int av::VideoRescaler::dstWidth ( ) const
inline
Returns
the width in pixels, or -1 when it is not configured

◆ flags()

int32_t av::VideoRescaler::flags ( ) const
inline
Returns
a combination of SwsFlags

◆ isValid()

bool av::VideoRescaler::isValid ( ) const
Returns
true when rescale() can be called

◆ operator=() [1/2]

VideoRescaler & av::VideoRescaler::operator= ( const VideoRescaler & rhs)
Parameters
rhsthe scaler to copy from
Returns
this scaler

◆ operator=() [2/2]

VideoRescaler & av::VideoRescaler::operator= ( VideoRescaler && rhs)
Parameters
rhsthe scaler to move from; left uninitialised
Returns
this scaler

◆ rescale() [1/2]

VideoFrame av::VideoRescaler::rescale ( const VideoFrame & src,
OptionalErrorCode ec = throws() )
Parameters
srcsource frame in system memory
echolder for the error code
Returns
the scaled frame, or an invalid frame on failure

◆ rescale() [2/2]

void av::VideoRescaler::rescale ( VideoFrame & dst,
const VideoFrame & src,
OptionalErrorCode ec = throws() )
Parameters
dstdestination frame; it must be allocated with the output geometry and format
srcsource frame in system memory
echolder for the error code
Examples
api2-scale-video.cpp.

◆ srcHeight()

int av::VideoRescaler::srcHeight ( ) const
inline
Returns
the height in pixels, or -1 when it is not configured

◆ srcPixelFormat()

PixelFormat av::VideoRescaler::srcPixelFormat ( )
inline
Returns
the format, or AV_PIX_FMT_NONE when it is not configured

◆ srcWidth()

int av::VideoRescaler::srcWidth ( ) const
inline
Returns
the width in pixels, or -1 when it is not configured

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