Raytrix Light Field SDK  5.0
Rx::FileIO::CFFmpegEnc_Impl Class Reference

Detailed Description

FFMpeg video encode codec.

Inherits Rx::FileIO::IVideoEncode, and Rx::FileIO::IParameterVideoEncode.

Public Member Functions

 CFFmpegEnc_Impl ()
 Default constructor. Applies all necessary options for the encoder and initializes the FFMpeg libraries. More...
 
 ~CFFmpegEnc_Impl ()
 Destructor. Frees all by the constructor allocated memory and finalizes the FFmpeg libraries. More...
 
virtual void AddImage (const CRxImage &xSrcImg)
 Adds a single picture for encoding to video data. The picture must have the same format as specified in the image format in Open(). More...
 
virtual void Close ()
 Closes the video file. If there some delayed pictures in the encoding pipeline, they will be encoded before the video is closed. More...
 
virtual void Destroy ()
 Destroys this object. More...
 
virtual void GetLevel (char *&xParameters)
 Gets the level enum containing the current level. More...
 
virtual void GetParameters (char *&pcParameter, char *&pcValue)
 Gets the parameter struct containing the current encoding parameters. More...
 
virtual void GetParameters (H264 &xParameters)
 Gets the current parameters and writes them into the given H264 struct. When this function is called the first time without calling SetParameters() before it will fill the struct with the default values for the used video encoder. This function may be called at any state of the object. More...
 
virtual void GetPreset (char *&xParameters)
 Gets the preset enum containing the current preset. More...
 
virtual void GetProfile (char *&xParameters)
 Gets the profile containing the current profile. More...
 
virtual void GetTune (char *&xParameters)
 Gets the tune settings containing the current tune parameters. More...
 
virtual void Open (const CRxString &sxOutputVideopath, const CRxImageFormat &xFormat)
 Opens the video file at the specified path and sets last option based on the provided image format. More...
 
virtual void SetLevel (const char *&xParameters)
 Overwrites the current level with the parameters inside the enum. More...
 
virtual void SetParameters (const char *pcParameter, const char *pcValue)
 Overwrites the current encoding parameters with the parameters inside the struct. More...
 
virtual void SetParameters (const H264 &xParameters)
 Sets the new parameters for the video encoder from the H264 struct. This function must not be called after the first image was added, but it is not necessary to call GetParameters() before this function. More...
 
virtual void SetPreset (const char *&xParameters)
 Overwrites the current preset parameters with the parameters inside the enum. More...
 
virtual void SetProfile (const char *&xParameters)
 Overwrites the current profile parameters with the parameters inside the enum. More...
 
virtual void SetTune (const char *&xParameters)
 Overwrites the tune settings with the parameters inside the enum. More...
 

Protected Member Functions

void GenerateFilterString (CRxString &sxFilterString, bool bCrop, int iTransposeLvl)
 Generates the string containing the commands used for initializing the filter chain. This function is called by SetupAndOpenEncoder() as part of the setup. More...
 
void InitFilters (const CRxString &sxFilterDescription)
 Initializes the filters by the string containing LibavFilter commands. Command list can be found at the FFmpeg documentation or at the Libavfilter documentation. This function is called by SetupAndOpenEncoder() as part of the setup. More...
 
void RxPixelFormatToAVPixelFormat (AVPixelFormat &avFormat, const CRxImageFormat &rxFormat)
 Converts Raytrix pixel format to Libav pixel format. This function is called by Open(). More...
 
void SetupAndOpenEncoder (AVFormatContext *pxAVFormatContext, AVCodec *pxAVCodec, AVStream *pxAVStream)
 Opens the video encoder, setups the filter chain and allocates the image buffer inside the frames. This function is called once when the first image is added via AddImage(). More...
 

Constructor & Destructor Documentation

◆ CFFmpegEnc_Impl()

Rx::FileIO::CFFmpegEnc_Impl::CFFmpegEnc_Impl ( )

Default constructor. Applies all necessary options for the encoder and initializes the FFMpeg libraries.

◆ ~CFFmpegEnc_Impl()

Rx::FileIO::CFFmpegEnc_Impl::~CFFmpegEnc_Impl ( )

Destructor. Frees all by the constructor allocated memory and finalizes the FFmpeg libraries.

Member Function Documentation

◆ AddImage()

virtual void Rx::FileIO::CFFmpegEnc_Impl::AddImage ( const CRxImage xSrcImg)
virtual

Adds a single picture for encoding to video data. The picture must have the same format as specified in the image format in Open().

Parameters
xSrcImg[in] Source image.

Implements Rx::FileIO::IVideoEncode.

◆ Close()

virtual void Rx::FileIO::CFFmpegEnc_Impl::Close ( )
virtual

Closes the video file. If there some delayed pictures in the encoding pipeline, they will be encoded before the video is closed.

Implements Rx::FileIO::IVideoEncode.

◆ Destroy()

virtual void Rx::FileIO::CFFmpegEnc_Impl::Destroy ( )
virtual

Destroys this object.

Implements Rx::FileIO::IVideoEncode.

◆ GenerateFilterString()

void Rx::FileIO::CFFmpegEnc_Impl::GenerateFilterString ( CRxString sxFilterString,
bool  bCrop,
int  iTransposeLvl 
)
protected

Generates the string containing the commands used for initializing the filter chain. This function is called by SetupAndOpenEncoder() as part of the setup.

Parameters
sxFilterString[out] The string containing the generated filter chain.
bCrop[in] True to allow frame cropping.
iTransposeLvl[in] The transpose level.

◆ GetLevel()

virtual void Rx::FileIO::CFFmpegEnc_Impl::GetLevel ( char *&  xParameters)
virtual

Gets the level enum containing the current level.

Parameters
xParameters[out] The parameter struct.

Implements Rx::FileIO::IParameterVideoEncode.

◆ GetParameters() [1/2]

virtual void Rx::FileIO::CFFmpegEnc_Impl::GetParameters ( char *&  pcParameter,
char *&  pcValue 
)
virtual

Gets the parameter struct containing the current encoding parameters.

Parameters
pcParameter[out] The parameter struct.
pcValue[in,out] If non-null, the value.

Implements Rx::FileIO::IParameterVideoEncode.

◆ GetParameters() [2/2]

virtual void Rx::FileIO::CFFmpegEnc_Impl::GetParameters ( H264 xParameters)
virtual

Gets the current parameters and writes them into the given H264 struct. When this function is called the first time without calling SetParameters() before it will fill the struct with the default values for the used video encoder. This function may be called at any state of the object.

Parameters
xParameters[out] The H264 struct which contains the current parameters.

Implements Rx::FileIO::IParameterVideoEncode.

◆ GetPreset()

virtual void Rx::FileIO::CFFmpegEnc_Impl::GetPreset ( char *&  xParameters)
virtual

Gets the preset enum containing the current preset.

Parameters
xParameters[out] The parameter struct.

Implements Rx::FileIO::IParameterVideoEncode.

◆ GetProfile()

virtual void Rx::FileIO::CFFmpegEnc_Impl::GetProfile ( char *&  xParameters)
virtual

Gets the profile containing the current profile.

Parameters
xParameters[out] The parameter struct.

Implements Rx::FileIO::IParameterVideoEncode.

◆ GetTune()

virtual void Rx::FileIO::CFFmpegEnc_Impl::GetTune ( char *&  xParameters)
virtual

Gets the tune settings containing the current tune parameters.

Parameters
xParameters[out] The parameter struct.

Implements Rx::FileIO::IParameterVideoEncode.

◆ InitFilters()

void Rx::FileIO::CFFmpegEnc_Impl::InitFilters ( const CRxString sxFilterDescription)
protected

Initializes the filters by the string containing LibavFilter commands. Command list can be found at the FFmpeg documentation or at the Libavfilter documentation. This function is called by SetupAndOpenEncoder() as part of the setup.

Parameters
sxFilterDescription[in] Information describing the Libav filter.

◆ Open()

virtual void Rx::FileIO::CFFmpegEnc_Impl::Open ( const CRxString sxOutputVideopath,
const CRxImageFormat xFormat 
)
virtual

Opens the video file at the specified path and sets last option based on the provided image format.

Parameters
sxOutputVideopath[in] The path for the output video file.
xFormat[in] Describes the format of the input images.

Implements Rx::FileIO::IVideoEncode.

◆ RxPixelFormatToAVPixelFormat()

void Rx::FileIO::CFFmpegEnc_Impl::RxPixelFormatToAVPixelFormat ( AVPixelFormat &  avFormat,
const CRxImageFormat rxFormat 
)
protected

Converts Raytrix pixel format to Libav pixel format. This function is called by Open().

Parameters
avFormat[out] The av format.
rxFormat[in] The raytrix format.

◆ SetLevel()

virtual void Rx::FileIO::CFFmpegEnc_Impl::SetLevel ( const char *&  xParameters)
virtual

Overwrites the current level with the parameters inside the enum.

Parameters
xParameters[in] Parameter struct with encoder parameters.

Implements Rx::FileIO::IParameterVideoEncode.

◆ SetParameters() [1/2]

virtual void Rx::FileIO::CFFmpegEnc_Impl::SetParameters ( const char *  pcParameter,
const char *  pcValue 
)
virtual

Overwrites the current encoding parameters with the parameters inside the struct.

Parameters
pcParameter[in] Parameter struct with encoder parameters.
pcValueThe value.

Implements Rx::FileIO::IParameterVideoEncode.

◆ SetParameters() [2/2]

virtual void Rx::FileIO::CFFmpegEnc_Impl::SetParameters ( const H264 xParameters)
virtual

Sets the new parameters for the video encoder from the H264 struct. This function must not be called after the first image was added, but it is not necessary to call GetParameters() before this function.

Parameters
xParameters[in] The H264 struct containing the new parameters.

Implements Rx::FileIO::IParameterVideoEncode.

◆ SetPreset()

virtual void Rx::FileIO::CFFmpegEnc_Impl::SetPreset ( const char *&  xParameters)
virtual

Overwrites the current preset parameters with the parameters inside the enum.

Parameters
xParameters[in] Parameter struct with encoder parameters.

Implements Rx::FileIO::IParameterVideoEncode.

◆ SetProfile()

virtual void Rx::FileIO::CFFmpegEnc_Impl::SetProfile ( const char *&  xParameters)
virtual

Overwrites the current profile parameters with the parameters inside the enum.

Parameters
xParameters[in] Parameter struct with encoder parameters.

Implements Rx::FileIO::IParameterVideoEncode.

◆ SetTune()

virtual void Rx::FileIO::CFFmpegEnc_Impl::SetTune ( const char *&  xParameters)
virtual

Overwrites the tune settings with the parameters inside the enum.

Parameters
xParameters[in] Parameter struct with encoder parameters.

Implements Rx::FileIO::IParameterVideoEncode.

◆ SetupAndOpenEncoder()

void Rx::FileIO::CFFmpegEnc_Impl::SetupAndOpenEncoder ( AVFormatContext *  pxAVFormatContext,
AVCodec *  pxAVCodec,
AVStream *  pxAVStream 
)
protected

Opens the video encoder, setups the filter chain and allocates the image buffer inside the frames. This function is called once when the first image is added via AddImage().

Parameters
pxAVFormatContext[in] The AV format context.
pxAVCodec[in] The AV codec.
pxAVStream[in] The AV stream.