# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
dirac::SequenceCompressor Class Referenceabstract

Compresses a sequence of frames/fields from a stream. More...

`#include <seq_compress.h>`

Inheritance diagram for dirac::SequenceCompressor:
[legend]
Collaboration diagram for dirac::SequenceCompressor:
[legend]

## Public Member Functions
| SequenceCompressor (StreamPicInput *pin, EncoderParams &encp, DiracByteStream &dirac_byte_stream)
| Constructor. More...
virtual | ~SequenceCompressor ()
| Destructor. More...
virtual bool | LoadNextFrame ()=0
| Load data. More...
const EncPicture * | CompressNextPicture ()
| Compress the next picture in sequence. More...
virtual void | SetPicTypeAndRefs (PictureParams &pparams)=0
| Set up the appropriate prediction parameters for a picture. More...
const EncPicture * | GetPictureEncoded ()
| Return a pointer to the most recent picture encoded. More...
DiracByteStats | EndSequence ()
bool | Finished ()
| Determine if compression is complete. More...
void | SignalEOS ()
| Signal end of sequence. More...
int | PTSOffset ()
| The delay required for correct timestamps. More...

## Protected Member Functions
void | SetMotionParameters ()
| Set up the motion block parameters. More...
virtual int | CodedToDisplay (const int pnum)=0
| Uses the GOP parameters to convert picture numbers in coded order to display order. More...
void | MakeSequenceReport ()
| Make a report to screen on the coding results for the whole sequence. More...
virtual void | CleanBuffers ()
| Remove unwanted pictures from picture buffers. More...
virtual void | UpdateCBRModel (EncPicture &my_picture, const PictureByteIO *picture_byteio)=0
| Update the CBR model based on the data we've compressed. More...
void | UpdateIntraPicCBRModel (const PictureParams &, const bool is_a_cut)
| Update the parameters to be used in advance of coding an intra frame. More...
bool | CanEncode ()
| Returns true if the encoder can encode a picture. More...

## Protected Attributes
bool | m_all_done
| Completion flag, returned via the Finished method. More...
bool | m_just_finished
| Flag indicating whether we've just finished. More...
OLBParams * | m_basic_olb_params0
| A class to hold the basic block parameters. More...
OLBParams * | m_basic_olb_params1
| A class to hold the basic block parameters. More...
const OLBParams * | m_basic_olb_params2
| A class to hold the basic block parameters. More...
OLBParams * | m_intra_olbp
| A class to hold block parameters to use when there are lots of intra blocks. More...
SourceParams & | m_srcparams
| The parameters of the input source. More...
EncoderParams & | m_encparams
| The parameters used for encoding. More...
PicturePredParams & | m_predparams
| The parameters used for ME/MC. More...
int | m_L1_sep
| The L1 separation currently in use. More...
PictureParams | m_pparams
| Generic picture parameters for initialising pictures. More...
StreamPicInput * | m_pic_in
| Pointer pointing at the picture input. More...
EncQueue | m_enc_pbuffer
| A picture buffer used for local storage of pictures whilst pending re-ordering or being used for reference. More...
int | m_current_display_pnum
| The number of the current picture to be coded, in display order. More...
int | m_current_code_pnum
| The number of the current picture to be coded, in coded order. More...
int | m_show_pnum
| The number of the picture which should be output for concurrent display or storage. More...
int | m_last_picture_read
| The index, in display order, of the last picture read. More...
int | m_gop_start_num
| The picture number of the last GOP start. More...
int | m_delay
| A delay so that we don't display what we haven't coded. More...
QualityMonitor | m_qmonitor
| A class for monitoring the quality of pictures and adjusting parameters appropriately. More...
RateController * | m_ratecontrol
| A class for monitoring and controlling bit rate. More...
PictureCompressor | m_pcoder
| A class to hold the picture compressor object. More...
DiracByteStream & | m_dirac_byte_stream
| Output destination for compressed data in bitstream format. More...
bool | m_eos_signalled
| Flag to check if End of Sequence has been signalled by the end user. More...

## Private Member Functions
| SequenceCompressor (const SequenceCompressor &cpy)
| Copy constructor is private and body-less. More...
SequenceCompressor & | operator= (const SequenceCompressor &rhs)
| Assignment = is private and body-less. More...

## Detailed Description

This class compresses a sequence of frames/fields, frame by frame. or field by field. It currently uses GOP parameters set in the encoder parameters in order to define the temporal prediction structure. A version to incorporate non-GOP structures is TBC.

This is an abstract class.

## Constructor & Destructor Documentation

## ◆ SequenceCompressor() [1/2]

dirac::SequenceCompressor::SequenceCompressor | ( | StreamPicInput * | pin,
|  | EncoderParams & | encp,
|  | DiracByteStream & | dirac_byte_stream
| ) |  |

Creates a sequence compressor, and prepares to begin compressing with the first picture.Sets up picture padding in the picture input if necesary

Parameters

  pin | an input stream containing a sequence of frames
  encp | parameters for the encoding process
  dirac_byte_stream | Output destination for compressed data

## ◆ ~SequenceCompressor()

virtual dirac::SequenceCompressor::~SequenceCompressor | ( |  | ) |
| virtual

Destructor. Must delete IO objects created by constructor.

## ◆ SequenceCompressor() [2/2]

dirac::SequenceCompressor::SequenceCompressor | ( | const SequenceCompressor & | cpy | ) |
| private

Copy constructor is private and body-less. This class should not be copied.

## Member Function Documentation

## ◆ CanEncode()

bool dirac::SequenceCompressor::CanEncode | ( |  | ) |
| protected

## ◆ CleanBuffers()

virtual void dirac::SequenceCompressor::CleanBuffers | ( |  | ) |
| protected virtual

## ◆ CodedToDisplay()

virtual int dirac::SequenceCompressor::CodedToDisplay | ( | const int | pnum | ) |
| protected pure virtual

Uses the GOP parameters to convert picture numbers in coded order to display order. Pure virtual function. The child class will have to define it.

Parameters

  pnum | the picture number in coded order

Implemented in dirac::FrameSequenceCompressor, and dirac::FieldSequenceCompressor.

## ◆ CompressNextPicture()

const EncPicture * dirac::SequenceCompressor::CompressNextPicture | ( |  | ) |

This function codes the next picture in coding order and returns the next picture in display order. In general these will differ, and because of re-ordering there is a delay which needs to be imposed. This creates problems at the start and at the end of the sequence which must be dealt with. At the start we just keep outputting picture 0. At the end you will need to loop for longer to get all the pictures out. It's up to the calling function to do something with the decoded pictures as they come out – write them to screen or to file, for example. . If coding is fast enough the compressed version could be watched real-time (with suitable buffering in the calling function to account for encode-time variations).

NOTE: LoadNextFrame must be called atleast once before invoking this method.

Returns
  pointer to the next locally decoded picture available for display

## ◆ EndSequence()

DiracByteStats dirac::SequenceCompressor::EndSequence | ( |  | ) |

## ◆ Finished()

bool dirac::SequenceCompressor::Finished | ( |  | ) |
| inline

Indicates whether or not the last picture in the sequence has been compressed.

Returns
  true if last picture has been compressed; false if not

References m_all_done.

## ◆ GetPictureEncoded()

const EncPicture * dirac::SequenceCompressor::GetPictureEncoded | ( |  | ) |

## ◆ LoadNextFrame()

virtual bool dirac::SequenceCompressor::LoadNextFrame | ( |  | ) |
| pure virtual

Load one picture of data into the Sequence Compressor. Sets m_all_done to true if no more data is available to be loaded. Input can be frame or field. So the child class will have to implement this function.

Returns
  true - if frame load succeeded. false - otherwise

Implemented in dirac::FrameSequenceCompressor, and dirac::FieldSequenceCompressor.

## ◆ MakeSequenceReport()

void dirac::SequenceCompressor::MakeSequenceReport | ( |  | ) |
| protected

## ◆ operator=()

SequenceCompressor & dirac::SequenceCompressor::operator= | ( | const SequenceCompressor & | rhs | ) |
| private

Assignment = is private and body-less. This class should not be assigned..

## ◆ PTSOffset()

int dirac::SequenceCompressor::PTSOffset | ( |  | ) |
| inline

References m_delay.

## ◆ SetMotionParameters()

void dirac::SequenceCompressor::SetMotionParameters | ( |  | ) |
| protected

## ◆ SetPicTypeAndRefs()

virtual void dirac::SequenceCompressor::SetPicTypeAndRefs | ( | PictureParams & | pparams | ) |
| pure virtual

Implemented in dirac::FrameSequenceCompressor, and dirac::FieldSequenceCompressor.

## ◆ SignalEOS()

void dirac::SequenceCompressor::SignalEOS | ( |  | ) |
| inline

References m_eos_signalled.

## ◆ UpdateCBRModel()

virtual void dirac::SequenceCompressor::UpdateCBRModel | ( | EncPicture & | my_picture,
|  | const PictureByteIO * | picture_byteio
| ) |  |
| protected pure virtual

Implemented in dirac::FrameSequenceCompressor, and dirac::FieldSequenceCompressor.

## ◆ UpdateIntraPicCBRModel()

void dirac::SequenceCompressor::UpdateIntraPicCBRModel | ( | const PictureParams & | ,
|  | const bool | is_a_cut
| ) |  |
| protected

## Member Data Documentation

## ◆ m_all_done

bool dirac::SequenceCompressor::m_all_done
| protected

Referenced by Finished().

## ◆ m_basic_olb_params0

OLBParams* dirac::SequenceCompressor::m_basic_olb_params0
| protected

## ◆ m_basic_olb_params1

OLBParams* dirac::SequenceCompressor::m_basic_olb_params1
| protected

## ◆ m_basic_olb_params2

const OLBParams* dirac::SequenceCompressor::m_basic_olb_params2
| protected

## ◆ m_current_code_pnum

int dirac::SequenceCompressor::m_current_code_pnum
| protected

## ◆ m_current_display_pnum

int dirac::SequenceCompressor::m_current_display_pnum
| protected

## ◆ m_delay

int dirac::SequenceCompressor::m_delay
| protected

Referenced by PTSOffset().

## ◆ m_dirac_byte_stream

DiracByteStream& dirac::SequenceCompressor::m_dirac_byte_stream
| protected

## ◆ m_enc_pbuffer

EncQueue dirac::SequenceCompressor::m_enc_pbuffer
| protected

## ◆ m_encparams

EncoderParams& dirac::SequenceCompressor::m_encparams
| protected

## ◆ m_eos_signalled

bool dirac::SequenceCompressor::m_eos_signalled
| protected

Referenced by SignalEOS().

## ◆ m_gop_start_num

int dirac::SequenceCompressor::m_gop_start_num
| protected

## ◆ m_intra_olbp

OLBParams* dirac::SequenceCompressor::m_intra_olbp
| protected

## ◆ m_just_finished

bool dirac::SequenceCompressor::m_just_finished
| protected

Flag which is false if we've been all-done for more than one picture, true otherwise (so that we can take actions on finishing once only).

## ◆ m_L1_sep

int dirac::SequenceCompressor::m_L1_sep
| protected

## ◆ m_last_picture_read

int dirac::SequenceCompressor::m_last_picture_read
| protected

## ◆ m_pcoder

PictureCompressor dirac::SequenceCompressor::m_pcoder
| protected

## ◆ m_pic_in

StreamPicInput* dirac::SequenceCompressor::m_pic_in
| protected

## ◆ m_pparams

PictureParams dirac::SequenceCompressor::m_pparams
| protected

## ◆ m_predparams

PicturePredParams& dirac::SequenceCompressor::m_predparams
| protected

## ◆ m_qmonitor

QualityMonitor dirac::SequenceCompressor::m_qmonitor
| protected

## ◆ m_ratecontrol

RateController* dirac::SequenceCompressor::m_ratecontrol
| protected

## ◆ m_show_pnum

int dirac::SequenceCompressor::m_show_pnum
| protected

## ◆ m_srcparams

SourceParams& dirac::SequenceCompressor::m_srcparams
| protected

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

- seq_compress.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.