# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

# dirac::FrameBuffer Class Reference

Holds frames both for reference and to overcome reordering delay. More...

`#include <frame_buffer.h>`

Collaboration diagram for dirac::FrameBuffer:

[legend]
List of all members.

## Public Member Functions

- FrameBuffer ()
    Default Constructor.
- FrameBuffer (ChromaFormat cf, int xlen, int ylen, int c_xlen, int c_ylen, unsigned int vd)
    Constructor.
- FrameBuffer (ChromaFormat cf, int numL1, int L1sep, int xlen, int ylen, int c_xlen, int c_ylen, unsigned int vd)
    Constructor.
- FrameBuffer (const FrameBuffer &cpy)
    Copy constructor.
- FrameBuffer & operator= (const FrameBuffer &rhs)
    Operator=.
- ~FrameBuffer ()
    Destructor.
- Frame & GetFrame (unsigned int fnum)
    Get frame with a given frame number (NOT with a given position in the buffer).
- const Frame & GetFrame (unsigned int fnum) const
    Get frame with a given frame number (NOT with a given position in the buffer).
- PicArray & GetComponent (unsigned int frame_num, CompSort c)
    Get component with a given component sort and frame number (NOT with a given position in the buffer).
- const PicArray & GetComponent (unsigned int frame_num, CompSort c) const
    Get component with a given component sort and frame number (NOT with a given position in the buffer).
- PicArray & GetUpComponent (unsigned int frame_num, CompSort c)
    Get upconverted component with a given component sort and frame number (NOT with a given position in the buffer).
- const PicArray & GetUpComponent (unsigned int frame_num, CompSort c) const
    Get upconverted component with a given component sort and frame number (NOT with a given position in the buffer).
- size_t Size () const
    Return the number of frames in the buffer.
- void PushFrame (unsigned int frame_num)
    Put a new frame into the top of the buffer.
- void PushFrame (const FrameParams &fp)
    Put a new frame into the top of the buffer.
- void PushFrame (const Frame &frame)
    Put a copy of a new frame into the top of the buffer.
- void PushFrame (StreamPicInput *picin, const FrameParams &fp)
    Read a new frame into the buffer.
- void PushFrame (StreamPicInput *picin, unsigned int fnum)
    Read a new frame into the buffer.
- void Clean (int show_fnum, int current_coded_fnum)
    Delete expired frames.
- void Clean (int fnum)
    Delete frame.
- const FrameParams & GetFParams () const
    Return the default frame parameters.

## Private Member Functions

- void SetFrameParams (unsigned int fnum)
    Set the frame parameters based on the frame number in display order and internal GOP parameters.
- void Remove (unsigned int fnum)
    Remove a frame with a given frame number from the buffer.

## Private Attributes

- std::vector< Frame * > m_frame_data
    the buffer storing all the values
- std::vector< bool > m_frame_in_use
    the flags that specifies if the frame is currently in use or not
- std::map< unsigned int, unsigned
  int > m_fnum_map
    the map from frame numbers to position in the buffer
- FrameParams m_fparams
    The frame parameters to use as a default if none are supplied with the frame.
- unsigned int m_num_L1
    The number of L1 frames before next I frame.
- unsigned int m_L1_sep
    The distance, in frames, between L1 frames.
- unsigned int m_gop_len
    The length of the group of pictures (GOP).

## Detailed Description

The buffer holds frames in a stack to overcome both reordering due to bi-directional prediction and use as references for subsequence motion estimation. Frames, and components of frames, can be accessed by their frame numbers. GOP parameters can be included in the constructors so that frames can be given types (I frame, L1 frame or L2 frame) on being pushed onto the stack; alternatively, these parameters can be overridden.

## Constructor & Destructor Documentation

dirac::FrameBuffer::FrameBuffer | ( |  | ) |

dirac::FrameBuffer::FrameBuffer | ( | ChromaFormat | cf,
|  | int | xlen,
|  | int | ylen,
|  | int | c_xlen,
|  | int | c_ylen,
|  | unsigned int | vd |
| ) |  |  |

Creates a FrameBuffer using the chroma format. Suitable for compressing when there are no L2 frames, or when the temporal prediction structure is to be determined on the fly.

Parameters:

  | cf | the Chroma format of frames in the buffer
  | xlen | the luma width of frames in the buffer
  | ylen | the luma height of frames in the buffer
  | c_xlen | the chroma width of frames in the buffer
  | c_ylen | the chroma height of frames in the buffer
  | vd | the video depth of the data in the buffer

dirac::FrameBuffer::FrameBuffer | ( | ChromaFormat | cf,
|  | int | numL1,
|  | int | L1sep,
|  | int | xlen,
|  | int | ylen,
|  | int | c_xlen,
|  | int | c_ylen,
|  | unsigned int | vd |
| ) |  |  |

Creates a FrameBuffer using the chroma format, the number of L1 frames between I frames and the separation in frames between L1 frames. Suitable for compressing when there is a full GOP structure or when the temporal prediction structure is to be determined on the fly.

Parameters:

  | cf | the Chroma format of frames in the buffer
  | numL1 | the number of Layer 1 frames before the next I frame. 0 means that there is only one I frame.
  | L1sep | the number of Layer 2 frames between Layer 1 frames
  | xlen | the luma width of frames in the buffer
  | ylen | the luma height of frames in the buffer
  | c_xlen | the chroma width of frames in the buffer
  | c_ylen | the chroma height of frames in the buffer
  | vd | the video depth of the data in the buffer

dirac::FrameBuffer::FrameBuffer | ( | const FrameBuffer & | cpy | ) |

Copy constructor. Removes the current contents of the frame buffer and copies in the contents of the initialising buffer.

dirac::FrameBuffer::~FrameBuffer | ( |  | ) |

## Member Function Documentation

void dirac::FrameBuffer::Clean | ( | int | fnum | ) |

Delete frame.

Parameters:

  | fnum | frame number in display order to be deleted from frame buffer

void dirac::FrameBuffer::Clean | ( | int | show_fnum,
|  | int | current_coded_fnum |
| ) |  |  |

Delete frames which have been output and which are no longer required for reference. Expiry times are set in each frame's frame parameters.

Parameters:

  | show_fnum | frame number in display order that can be output
  | current_coded_fnum | frame number in display order of frame currently being coded

const PicArray& dirac::FrameBuffer::GetComponent | ( | unsigned int | frame_num,
|  | CompSort | c |
| ) |  |  | const

PicArray& dirac::FrameBuffer::GetComponent | ( | unsigned int | frame_num,
|  | CompSort | c |
| ) |  |  |

const FrameParams& dirac::FrameBuffer::GetFParams | ( |  | ) | const`[inline]`

const Frame& dirac::FrameBuffer::GetFrame | ( | unsigned int | fnum | ) | const

Frame& dirac::FrameBuffer::GetFrame | ( | unsigned int | fnum | ) |

const PicArray& dirac::FrameBuffer::GetUpComponent | ( | unsigned int | frame_num,
|  | CompSort | c |
| ) |  |  | const

PicArray& dirac::FrameBuffer::GetUpComponent | ( | unsigned int | frame_num,
|  | CompSort | c |
| ) |  |  |

FrameBuffer& dirac::FrameBuffer::operator= | ( | const FrameBuffer & | rhs | ) |

Operator=. Assigns all elements of the rhs to the lhs.

void dirac::FrameBuffer::PushFrame | ( | StreamPicInput * | picin,
|  | unsigned int | fnum |
| ) |  |  |

Read a new frame into the buffer. Frame parameters associated with the frame will be derived from the frame number and the internal GOP parameters in the frame buffer.

Parameters:

  | picin | the picture input
  | fnum | the frame number

void dirac::FrameBuffer::PushFrame | ( | StreamPicInput * | picin,
|  | const FrameParams & | fp |
| ) |  |  |

Read a new frame into the buffer. Frame parameters associated with the frame will be as given by the frame parameter object.

Parameters:

  | picin | the picture input
  | fp | the frame parameters to apply to the frame

void dirac::FrameBuffer::PushFrame | ( | const Frame & | frame | ) |

Put a copy of a new frame into the top of the buffer.

void dirac::FrameBuffer::PushFrame | ( | const FrameParams & | fp | ) |

Put a new frame into the top of the buffer. Frame parameters associated with the frame will be as given by the frame parameter object.

void dirac::FrameBuffer::PushFrame | ( | unsigned int | frame_num | ) |

Put a new frame into the top of the buffer. Frame parameters associated with the frame will be the built-in parameters for the buffer.

Parameters:

  | frame_num | the number of the frame being inserted

void dirac::FrameBuffer::Remove | ( | unsigned int | fnum | ) | `[private]`

Remove a frame with a given frame number (in display order) from the buffer. Searches through the buffer and removes frame(s) with that number.

void dirac::FrameBuffer::SetFrameParams | ( | unsigned int | fnum | ) | `[private]`

size_t dirac::FrameBuffer::Size | ( |  | ) | const`[inline]`

## Member Data Documentation

std::map<unsigned int,unsigned int> dirac::FrameBuffer::m_fnum_map`[private]`

FrameParams dirac::FrameBuffer::m_fparams`[private]`

std::vector<Frame*> dirac::FrameBuffer::m_frame_data`[private]`

std::vector<bool> dirac::FrameBuffer::m_frame_in_use`[private]`

unsigned int dirac::FrameBuffer::m_gop_len`[private]`

unsigned int dirac::FrameBuffer::m_L1_sep`[private]`

unsigned int dirac::FrameBuffer::m_num_L1`[private]`

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

- frame_buffer.h

© 2004 British Broadcasting Corporation. Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.