CVB++ 14.1
Frame Class Referencefinal

A video frame for encoding and decoding. More...

#include <cvb/codec_bridge/frame.hpp>

Public Member Functions

int Width () const
 Get the frame width. More...
 
int Height () const
 Get the frame height. More...
 
Size2D< int > Size () const
 Get the frame size. More...
 
int64_t PresentationTimeStamp () const
 Get the frame presentation time stamp. More...
 
void SetPresentationTimeStamp (int64_t value)
 Set the presentation time stamp for this frame. More...
 
CodecBridge::PixelFormat PixelFormat () const
 Get the frame pixel format. More...
 
void UserData (void *buffer, size_t &size) const
 Get the user data if available. More...
 
Rational TimeBase () const
 Get the time base for this frame. More...
 
void SetUserData (void *buffer, size_t size)
 Set the user data for this frame. More...
 
void DeleteUserData ()
 Delete user data. More...
 
std::unique_ptr< ImageAsImage () const
 Get this frame as image. More...
 
int PlanesCount () const noexcept
 Get the number of planes in this frame. More...
 
PlanePtr Plane (int index) const
 Get a plane of this frame at the given index. More...
 

Static Public Member Functions

static std::unique_ptr< FrameCreate (Size2D< int > size, CodecBridge::PixelFormat format, uint8_t *buffer)
 Creates a frame as view on external memory. More...
 
static std::unique_ptr< FrameCreate (Size2D< int > size, CodecBridge::PixelFormat format)
 Creates a frame. More...
 

Detailed Description

A video frame for encoding and decoding.

Member Function Documentation

◆ AsImage()

std::unique_ptr< Image > AsImage ( ) const
inline

Get this frame as image.

Returns
An image as view on the buffer.
Exceptions
Anyexception derived from std::exception including CvbException.

This method does not copy data. The image and the frame will share the ownership of the buffer. An exception will be thrown if the pixel format of the frame cannot be represented ans image.

◆ Create() [1/2]

static std::unique_ptr< Frame > Create ( Size2D< int >  size,
CodecBridge::PixelFormat  format 
)
inlinestatic

Creates a frame.

Parameters
[in]sizeThe size of the frame.
[in]formatThe pixel format (compatible with FFmpeg).
Returns
A pointer to a frame object.
Exceptions
Anyexception derived from std::exception including CvbException.

The buffer for the frame is allocated internally.

◆ Create() [2/2]

static std::unique_ptr< Frame > Create ( Size2D< int >  size,
CodecBridge::PixelFormat  format,
uint8_t *  buffer 
)
inlinestatic

Creates a frame as view on external memory.

Parameters
[in]sizeThe size of the frame
[in]formatThe pixel format (compatible with FFmpeg)
[in]bufferThe buffer with the frame content.
Returns
A pointer to a frame object.
Exceptions
Anyexception derived from std::exception including CvbException.

The buffer must be large enough to match the given size and format.

◆ DeleteUserData()

void DeleteUserData ( )
inline

Delete user data.

Exceptions
Anyexception derived from std::exception including CvbException.

If there is no user data, this method does nothing.

◆ Height()

int Height ( ) const
inline

Get the frame height.

Returns
The frame height.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ PixelFormat()

Get the frame pixel format.

Returns
The pixel format.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Plane()

PlanePtr Plane ( int  index) const
inline

Get a plane of this frame at the given index.

Returns
A pointer to the plane.
Exceptions
Anyexception derived from std::exception including CvbException.

RGB frames will contain only one 3D plane.

◆ PlanesCount()

int PlanesCount ( ) const
inlinenoexcept

Get the number of planes in this frame.

Returns
The number of planes.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ PresentationTimeStamp()

int64_t PresentationTimeStamp ( ) const
inline

Get the frame presentation time stamp.

Returns
The presentation timestamp.
Exceptions
Anyexception derived from std::exception including CvbException.

The presentation time stamp is set by the decoder when decoding.

◆ SetPresentationTimeStamp()

void SetPresentationTimeStamp ( int64_t  value)
inline

Set the presentation time stamp for this frame.

Parameters
[in]valueThe presentation time stamp.
Exceptions
Anyexception derived from std::exception including CvbException.

Before encoding the frame the presentation timestamp must be set.

◆ SetUserData()

void SetUserData ( void *  buffer,
size_t  size 
)
inline

Set the user data for this frame.

Parameters
[in]bufferBuffer with the raw user data.
[in]sizeBuffer size.
Exceptions
Anyexception derived from std::exception including CvbException.

Some encoders support encoding user data alongside the frame. Usually this feature must be enabled manually in the encoder (udu_sei option).

◆ Size()

Size2D< int > Size ( ) const
inline

Get the frame size.

Returns
The frame size.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ TimeBase()

Rational TimeBase ( ) const
inline

Get the time base for this frame.

Returns
The the time base.
Exceptions
Anyexception derived from std::exception including CvbException.

The time base is set by the decoder when decoding. Encoders will ignore the value from the frame and use their own time base.

◆ UserData()

void UserData ( void *  buffer,
size_t &  size 
) const
inline

Get the user data if available.

Parameters
[in,out]bufferBuffer to hold the user data, or null to read the required size.
[in,out]sizeSize of the buffer to hold the user data. Will be filled with the required size if buffer is null.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Width()

int Width ( ) const
inline

Get the frame width.

Returns
The frame width.
Exceptions
Anyexception derived from std::exception including CvbException.