Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub

The Frame structure provides storage and manipulation of frames (multiplanar images). More...

#include <SimdFrame.hpp>

Public Types

enum  Format {
  None = 0 ,
  Nv12 ,
  Yuv420p ,
  Bgra32 ,
  Bgr24 ,
  Gray8 ,
  Rgb24 ,
  Rgba32
}
 
typedef A< uint8_t > Allocator
 

Public Member Functions

 Frame ()
 
 Frame (const Frame &frame)
 
 Frame (Frame &&frame) noexcept
 
 Frame (const View< A > &view, bool flipped_=false, double timestamp_=0)
 
 Frame (View< A > &&view, bool flipped_=false, double timestamp_=0)
 
 Frame (size_t width_, size_t height_, Format format_, bool flipped_=false, double timestamp_=0, SimdYuvType yuvType_=SimdYuvUnknown)
 
 Frame (const Point< ptrdiff_t > &size, Format format_, bool flipped_=false, double timestamp_=0, SimdYuvType yuvType_=SimdYuvUnknown)
 
 Frame (size_t width_, size_t height_, Format format_, uint8_t *data0, size_t stride0, uint8_t *data1, size_t stride1, uint8_t *data2, size_t stride2, bool flipped_=false, double timestamp_=0, SimdYuvType yuvType_=SimdYuvUnknown)
 
 ~Frame ()
 
FrameClone () const
 
FrameClone (const Rectangle< ptrdiff_t > &rect) const
 
FrameClone (Frame &buffer) const
 
Frameoperator= (const Frame &frame)
 
Frameoperator= (Frame &&frame)
 
FrameRef ()
 
void Recreate (size_t width_, size_t height_, Format format_, SimdYuvType yuvType_=SimdYuvUnknown)
 
void Recreate (const Point< ptrdiff_t > &size, Format format_, SimdYuvType yuvType_=SimdYuvUnknown)
 
Frame Region (const ptrdiff_t &left, const ptrdiff_t &top, const ptrdiff_t &right, const ptrdiff_t &bottom) const
 
Frame Region (ptrdiff_t &left, ptrdiff_t &top, ptrdiff_t &right, ptrdiff_t &bottom) const
 
Frame Region (const Point< ptrdiff_t > &topLeft, const Point< ptrdiff_t > &bottomRight) const
 
Frame Region (Point< ptrdiff_t > &topLeft, Point< ptrdiff_t > &bottomRight) const
 
Frame Region (const Rectangle< ptrdiff_t > &rect) const
 
Frame Region (Rectangle< ptrdiff_t > &rect) const
 
Frame Flipped () const
 
Point< ptrdiff_t > Size () const
 
size_t DataSize () const
 
size_t Area () const
 
size_t PlaneCount () const
 
void Clear ()
 
void Swap (Frame &other)
 
bool Owner () const
 
void Capture ()
 

Static Public Member Functions

static size_t PlaneCount (Format format)
 

Data Fields

const size_t width
 A width of the frame.
 
const size_t height
 A height of the frame.
 
const Format format
 A pixel format types of the frame.
 
View< A > planes [PLANE_COUNT_MAX]
 Planes of the frame.
 
bool flipped
 A flag of vertically flipped image (false - frame point (0, 0) is placed at top left corner of the frame, true - frame point (0, 0) is placed at bottom left corner of the frame.
 
double timestamp
 A timestamp of the frame.
 
const SimdYuvType yuvType
 A YUV format type.
 

Static Public Attributes

static const size_t PLANE_COUNT_MAX = 4
 

Detailed Description

template<template< class > class A>
struct Simd::Frame< A >

The Frame structure provides storage and manipulation of frames (multiplanar images).

Related Functions.

Member Typedef Documentation

◆ Allocator

typedef A<uint8_t> Allocator

Allocator type definition.

Member Enumeration Documentation

◆ Format

enum Format

Describes pixel format types of a frame.

Enumerator
None 

An undefined pixel format.

Nv12 

Two planes (8-bit full size Y plane, 16-bit interlived half size UV plane) NV12 pixel format.

Yuv420p 

Three planes (8-bit full size Y plane, 8-bit half size U plane, 8-bit half size V plane) YUV420P pixel format.

Bgra32 

One plane 32-bit (4 8-bit channels) BGRA (Blue, Green, Red, Alpha) pixel format.

Bgr24 

One plane 24-bit (3 8-bit channels) BGR (Blue, Green, Red) pixel format.

Gray8 

One plane 8-bit gray pixel format.

Rgb24 

One plane 24-bit (3 8-bit channels) RGB (Red, Green, Blue) pixel format.

Rgba32 

One plane 32-bit (4 8-bit channels) RGBA (Red, Green, Blue, Alpha) pixel format.

Constructor & Destructor Documentation

◆ Frame() [1/8]

SIMD_INLINE Frame

Creates a new empty Frame structure.

◆ Frame() [2/8]

SIMD_INLINE Frame ( const Frame< A > &  frame)

Creates a new Frame structure on the base of the other frame.

Note
This constructor is not create new frame! It only creates a reference to the same frame. If you want to create a copy then must use method Simd::Frame::Clone.
Parameters
[in]frame- an original frame.

◆ Frame() [3/8]

SIMD_INLINE Frame ( Frame< A > &&  frame)
noexcept

Move constructor of Frame structure.

Parameters
[in]frame- a moved Frame.

◆ Frame() [4/8]

SIMD_INLINE Frame ( const View< A > &  view,
bool  flipped_ = false,
double  timestamp_ = 0 
)

Creates a new one plane Frame structure on the base of the image view.

Note
This constructor is not create new image frame! It only creates a reference to the same image. If you want to create a copy then must use method Simd::Frame::Clone.
Parameters
[in]view- an original image view.
[in]flipped_- a flag of vertically flipped image of created frame. It is equal to false by default.
[in]timestamp_- a timestamp of created frame. It is equal to 0 by default.

◆ Frame() [5/8]

SIMD_INLINE Frame ( View< A > &&  view,
bool  flipped_ = false,
double  timestamp_ = 0 
)

Creates a new one plane Frame structure on the base of the temporal image view.

Parameters
[in]view- a temporal image view.
[in]flipped_- a flag of vertically flipped image of created frame. It is equal to false by default.
[in]timestamp_- a timestamp of created frame. It is equal to 0 by default.

◆ Frame() [6/8]

SIMD_INLINE Frame ( size_t  width_,
size_t  height_,
Format  format_,
bool  flipped_ = false,
double  timestamp_ = 0,
SimdYuvType  yuvType_ = SimdYuvUnknown 
)

Creates a new Frame structure with specified width, height and pixel format.

Parameters
[in]width_- a width of created frame.
[in]height_- a height of created frame.
[in]format_- a pixel format of created frame.
[in]flipped_- a flag of vertically flipped image of created frame. It is equal to false by default.
[in]timestamp_- a timestamp of created frame. It is equal to 0 by default.
[in]yuvType_- a YUV format type of created frame. It is equal to SimdYuvUnknown by default.

◆ Frame() [7/8]

SIMD_INLINE Frame ( const Point< ptrdiff_t > &  size,
Format  format_,
bool  flipped_ = false,
double  timestamp_ = 0,
SimdYuvType  yuvType_ = SimdYuvUnknown 
)

Creates a new Frame structure with specified width, height and pixel format.

Parameters
[in]size- a size (width and height) of created frame.
[in]format_- a pixel format of created frame.
[in]flipped_- a flag of vertically flipped image of created frame. It is equal to false by default.
[in]timestamp_- a timestamp of created frame. It is equal to 0 by default.
[in]yuvType_- a YUV format type of created frame. It is equal to SimdYuvUnknown by default.

◆ Frame() [8/8]

SIMD_INLINE Frame ( size_t  width_,
size_t  height_,
Format  format_,
uint8_t *  data0,
size_t  stride0,
uint8_t *  data1,
size_t  stride1,
uint8_t *  data2,
size_t  stride2,
bool  flipped_ = false,
double  timestamp_ = 0,
SimdYuvType  yuvType_ = SimdYuvUnknown 
)

Creates a new Frame structure with specified width, height and pixel format around external buffers.

Parameters
[in]width_- a width of created frame.
[in]height_- a height of created frame.
[in]format_- a pixel format of created frame.
[in]data0- a pointer to the pixel data of first image plane.
[in]stride0- a row size of first image plane.
[in]data1- a pointer to the pixel data of second image plane.
[in]stride1- a row size of second image plane.
[in]data2- a pointer to the pixel data of third image plane.
[in]stride2- a row size of third image plane.
[in]flipped_- a flag of vertically flipped image of created frame. It is equal to false by default.
[in]timestamp_- a timestamp of created frame. It is equal to 0 by default.
[in]yuvType_- a YUV format type of created frame. It is equal to SimdYuvUnknown by default.

◆ ~Frame()

SIMD_INLINE ~Frame

A Frame destructor.

Member Function Documentation

◆ Clone() [1/3]

SIMD_INLINE Frame< A > * Clone

Gets a copy of current frame.

Returns
a pointer to the new Frame structure. The user must free this pointer after usage.

◆ Clone() [2/3]

SIMD_INLINE Frame< A > * Clone ( const Rectangle< ptrdiff_t > &  rect) const

Gets a copy of region of current frame which bounded by the rectangle with specified coordinates.

Parameters
[in]rect- a rectangle which bound the region.
Returns
- a pointer to the new Frame structure. The user must free this pointer after usage.

◆ Clone() [3/3]

Frame * Clone ( Frame< A > &  buffer) const

Gets a copy of current frame using buffer as a storage.

Parameters
[in,out]buffer- an external frame as a buffer.
Returns
a pointer to the new Frame structure (not owner). The user must free this pointer after usage.

◆ operator=() [1/2]

Frame & operator= ( const Frame< A > &  frame)

Creates reference to other Frame structure.

Note
This function is not create copy of the frame! It only create a reference to the same frame.
Parameters
[in]frame- an original frame.
Returns
a reference to itself.

◆ operator=() [2/2]

Frame & operator= ( Frame< A > &&  frame)

Moves Frame structure.

Parameters
[in]frame- a moved frame.
Returns
a reference to itself.

◆ Ref()

SIMD_INLINE Frame< A > & Ref

Creates reference to itself.

Returns
a reference to itself.

◆ Recreate() [1/2]

SIMD_INLINE void Recreate ( size_t  width_,
size_t  height_,
Format  format_,
SimdYuvType  yuvType_ = SimdYuvUnknown 
)

Re-creates a Frame structure with specified width, height and pixel format.

Parameters
[in]width_- a width of re-created frame.
[in]height_- a height of re-created frame.
[in]format_- a pixel format of re-created frame.
[in]yuvType_- a YUV format type of re-created frame. It is equal to SimdYuvUnknown by default.

◆ Recreate() [2/2]

SIMD_INLINE void Recreate ( const Point< ptrdiff_t > &  size,
Format  format_,
SimdYuvType  yuvType_ = SimdYuvUnknown 
)

Re-creates a Frame structure with specified width, height and pixel format.

Parameters
[in]size- a size (width and height) of re-created frame.
[in]format_- a pixel format of re-created frame.
[in]yuvType_- a YUV format type of re-created frame. It is equal to SimdYuvUnknown by default.

◆ Region() [1/6]

SIMD_INLINE Frame< A > Region ( const ptrdiff_t &  left,
const ptrdiff_t &  top,
const ptrdiff_t &  right,
const ptrdiff_t &  bottom 
) const

Creates a new Frame structure which points to the region of current frame bounded by the rectangle with specified coordinates.

Parameters
[in]left- a left side of the region.
[in]top- a top side of the region.
[in]right- a right side of the region.
[in]bottom- a bottom side of the region.
Returns
- a new Frame structure which points to the region of frame.

◆ Region() [2/6]

SIMD_INLINE Frame< A > Region ( ptrdiff_t &  left,
ptrdiff_t &  top,
ptrdiff_t &  right,
ptrdiff_t &  bottom 
) const

Creates a new Frame structure which points to the region of current frame bounded by the rectangle with specified coordinates.

Parameters
[in,out]left- a left side of the required region. Returns the left side of the actual region.
[in,out]top- a top side of the required region. Returns the top side of the actual region.
[in,out]right- a right side of the required region. Returns the right side of the actual region.
[in,out]bottom- a bottom side of the required region. Returns the bottom side of the actual region.
Returns
- a new Frame structure which points to the region of frame.

◆ Region() [3/6]

SIMD_INLINE Frame< A > Region ( const Point< ptrdiff_t > &  topLeft,
const Point< ptrdiff_t > &  bottomRight 
) const

Creates a new Frame structure which points to the region of frame bounded by the rectangle with specified coordinates.

Parameters
[in]topLeft- a top-left corner of the region.
[in]bottomRight- a bottom-right corner of the region.
Returns
- a new Frame structure which points to the region of frame.

◆ Region() [4/6]

SIMD_INLINE Frame< A > Region ( Point< ptrdiff_t > &  topLeft,
Point< ptrdiff_t > &  bottomRight 
) const

Creates a new Frame structure which points to the region of frame bounded by the rectangle with specified coordinates.

Parameters
[in,out]topLeft- a top-left corner of the required region. Returns the top-left corner of the actual region.
[in,out]bottomRight- a bottom-right corner of the required region. Returns the bottom-right corner of the actual region.
Returns
- a new Frame structure which points to the region of frame.

◆ Region() [5/6]

SIMD_INLINE Frame< A > Region ( const Rectangle< ptrdiff_t > &  rect) const

Creates a new Frame structure which points to the region of frame bounded by the rectangle with specified coordinates.

Parameters
[in]rect- a rectangle which bound the region.
Returns
- a new Frame structure which points to the region of frame.

◆ Region() [6/6]

SIMD_INLINE Frame< A > Region ( Rectangle< ptrdiff_t > &  rect) const

Creates a new Frame structure which points to the region of frame bounded by the rectangle with specified coordinates.

Parameters
[in,out]rect- a rectangle which bound the required region. Returns the actual region.
Returns
- a new Frame structure which points to the region of frame.

◆ Flipped()

SIMD_INLINE Frame< A > Flipped

Creates a new Frame structure which points to the vertically flipped frame.

Returns
- a new Frame structure which points to the flipped frame.

◆ Size()

SIMD_INLINE Point< ptrdiff_t > Size

Gets size (width and height) of the frame.

Returns
- a new Point structure with frame width and height.

◆ DataSize()

SIMD_INLINE size_t DataSize

Gets size in bytes required to store pixel data of current Frame structure.

Returns
- a size of data pixels in bytes.

◆ Area()

SIMD_INLINE size_t Area

Gets area in pixels of of current Frame structure.

Returns
- a area of current Frame in pixels.

◆ PlaneCount() [1/2]

SIMD_INLINE size_t PlaneCount ( Format  format)
static

Gets number of planes in the frame for current pixel format.

Parameters
[in]format- a pixel format.
Returns
- a number of planes.

◆ PlaneCount() [2/2]

SIMD_INLINE size_t PlaneCount

Gets number of planes for current frame.

Returns
- a number of planes.

◆ Clear()

SIMD_INLINE void Clear

Clears Frame structure (reset all fields).

◆ Swap()

SIMD_INLINE void Swap ( Frame< A > &  other)

Swaps content of two (this and other) Frame structures.

Parameters
[in]other- an other frame.

◆ Owner()

SIMD_INLINE bool Owner

Gets owner flag: Do its planes own their images?

Returns
- an owner flag.

◆ Capture()

SIMD_INLINE void Capture

Captures image planes (copies to internal buffers) if this Frame is not owner of current image planes.

Field Documentation

◆ PLANE_COUNT_MAX

const size_t PLANE_COUNT_MAX = 4
static

Maximal count of pixel planes in a frame.