# Dirac - A Video Codec

Created by the British Broadcasting Corporation.

# dirac::SequenceCompressor Class Reference

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

`#include <seq_compress.h>`

Collaboration diagram for dirac::SequenceCompressor:

[legend]
List of all members.

## Public Member Functions

- SequenceCompressor (StreamPicInput *pin, SourceParams &srcp, EncoderParams &encp, DiracByteStream &dirac_byte_stream)
    Constructor.
- ~SequenceCompressor ()
    Destructor.
- bool LoadNextFrame ()
    Load data.
- Frame & CompressNextFrame ()
    Compress the next frame in sequence.
- const Frame * GetFrameEncoded ()
    Return a pointer to the most recent frame encoded.
- const MEData * GetMEData ()
    Return Motion estimation info related to the most recent frame encoded.
- DiracByteStats EndSequence ()
- bool Finished ()
    Determine if compression is complete.

## Private Member Functions

- SequenceCompressor (const SequenceCompressor &cpy)
    Copy constructor is private and body-less.
- SequenceCompressor & operator= (const SequenceCompressor &rhs)
    Assignment = is private and body-less.
- SequenceCompressor & operator<< (AccessUnitByteIO *p_accessunit_byteio)
    Writes sequence data to byte stream.
- int CodedToDisplay (const int fnum)
    Uses the GOP parameters to convert frame numbers in coded order to display order.
- void MakeSequenceReport ()
    Make a report to screen on the coding results for the whole sequence.
- void MakeFrameReport ()
    Make a report to screen on the coding results for a single frame.

## Private Attributes

- bool m_all_done
    Completion flag, returned via the Finished method.
- bool m_just_finished
    Flag indicating whether we've just finished.
- SourceParams & m_srcparams
    The parameters of the input source.
- EncoderParams & m_encparams
    The parameters used for encoding.
- StreamPicInput * m_pic_in
    Pointer pointing at the picture input.
- FrameBuffer * m_fbuffer
    A picture buffer used for local storage of frames whilst pending re-ordering or being used for reference.
- FrameBuffer * m_origbuffer
    A picture buffer of original frames.
- int m_current_display_fnum
    The number of the current frame to be coded, in display order.
- int m_current_code_fnum
    The number of the current frame to be coded, in coded order.
- int m_current_accessunit_fnum
    Current AccessUnit frame-number.
- int m_show_fnum
    The number of the frame which should be output for concurrent display or storage.
- int m_last_frame_read
    The index, in display order, of the last frame read.
- int m_delay
    A delay so that we don't display what we haven't coded.
- QualityMonitor m_qmonitor
    A class for monitoring the quality of pictures and adjusting parameters appropriately.
- FrameCompressor m_fcoder
    A class to hold the frame compressor object.
- DiracByteStream & m_dirac_byte_stream
    Output destination for compressed data in bitstream format.

## Detailed Description

This class compresses a sequence of frames, frame by frame. 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.

## Constructor & Destructor Documentation

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

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

Parameters:

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

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

Destructor. Must delete IO objects created by constructor.

dirac::SequenceCompressor::SequenceCompressor | ( | const SequenceCompressor & | cpy | ) | `[private]`

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

## Member Function Documentation

int dirac::SequenceCompressor::CodedToDisplay | ( | const int | fnum | ) | `[private]`

Uses the GOP parameters to convert frame numbers in coded order to display order

Parameters:

  | fnum | the frame number in coded order

Frame& dirac::SequenceCompressor::CompressNextFrame | ( |  | ) |

This function codes the next frame in coding order and returns the next frame 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 frame 0. At the end you will need to loop for longer to get all the frames out. It's up to the calling function to do something with the decoded frames 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:
  reference to the next locally decoded frame available for display

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

bool dirac::SequenceCompressor::Finished | ( |  | ) | `[inline]`

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

Returns:
  true if last frame has been compressed; false if not

const Frame* dirac::SequenceCompressor::GetFrameEncoded | ( |  | ) |

const MEData* dirac::SequenceCompressor::GetMEData | ( |  | ) |

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

Load one frame of data into the Sequence Compressor. Sets m_all_done to true if no more data is available to be loaded.

Returns:
  true - if frame load succeeded. false - otherwise

void dirac::SequenceCompressor::MakeFrameReport | ( |  | ) | `[private]`

void dirac::SequenceCompressor::MakeSequenceReport | ( |  | ) | `[private]`

SequenceCompressor& dirac::SequenceCompressor::operator<< | ( | AccessUnitByteIO * | p_accessunit_byteio | ) | `[private]`

Parameters:

  | p_accessunit_byteio | Output destination

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

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

## Member Data Documentation

bool dirac::SequenceCompressor::m_all_done`[private]`

int dirac::SequenceCompressor::m_current_accessunit_fnum`[private]`

int dirac::SequenceCompressor::m_current_code_fnum`[private]`

int dirac::SequenceCompressor::m_current_display_fnum`[private]`

int dirac::SequenceCompressor::m_delay`[private]`

DiracByteStream& dirac::SequenceCompressor::m_dirac_byte_stream`[private]`

EncoderParams& dirac::SequenceCompressor::m_encparams`[private]`

FrameBuffer* dirac::SequenceCompressor::m_fbuffer`[private]`

FrameCompressor dirac::SequenceCompressor::m_fcoder`[private]`

bool dirac::SequenceCompressor::m_just_finished`[private]`

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

int dirac::SequenceCompressor::m_last_frame_read`[private]`

FrameBuffer* dirac::SequenceCompressor::m_origbuffer`[private]`

StreamPicInput* dirac::SequenceCompressor::m_pic_in`[private]`

QualityMonitor dirac::SequenceCompressor::m_qmonitor`[private]`

int dirac::SequenceCompressor::m_show_fnum`[private]`

SourceParams& dirac::SequenceCompressor::m_srcparams`[private]`

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.