Dirac - A Video Codec

Created by the British Broadcasting Corporation.


dirac::ArithCodec< T > Class Template Referenceabstract

Abstract binary arithmetic coding class. More...

#include <arith_codec.h>

Inheritance diagram for dirac::ArithCodec< T >:
Collaboration diagram for dirac::ArithCodec< T >:

Public Member Functions

 ArithCodec (ByteIO *p_byteio, size_t number_of_contexts)
 Constructor for encoding.
virtual ~ArithCodec ()
 Destructor.
int Compress (T &in_data)
 Compresses the input and returns the number of bits written.
void Decompress (T &out_data, const int num_bytes)
 Decompresses the bitstream and writes into the output.
Public Member Functions inherited from dirac::ArithCodecBase
 ArithCodecBase (ByteIO *p_byteio, size_t number_of_contexts)
 Constructor.
virtual ~ArithCodecBase ()
 Destructor.

Protected Member Functions

virtual void DoWorkCode (T &in_data)=0
 Does the work of actually coding the data.
virtual void DoWorkDecode (T &out_data)=0
 virtual decode-only functions
Protected Member Functions inherited from dirac::ArithCodecBase
void InitEncoder ()
 Initialises the Encoder.
void EncodeSymbol (const bool symbol, const int context_num)
 encodes a symbol and writes to output
void EncodeUInt (const unsigned int value, const int bin1, const int max_bin)
void EncodeSInt (const int value, const int bin1, const int max_bin)
void FlushEncoder ()
 flushes the output of the encoder.
int ByteCount () const
void InitDecoder (int num_bytes)
 Initialise the Decoder.
bool DecodeSymbol (int context_num)
 Decodes a symbol given a context number.
unsigned int DecodeUInt (const int bin1, const int max_bin)
int DecodeSInt (const int bin1, const int max_bin)

Additional Inherited Members

Protected Attributes inherited from dirac::ArithCodecBase
std::vector< Contextm_context_list
 List of contexts.

Detailed Description

template<class T>
class dirac::ArithCodec< T >

This is an abtract binary arithmetic encoding class, used as the base for concrete classes that encode motion vectors and subband residues.

Parameters
Ta container (most probably, or array) type

Constructor & Destructor Documentation

◆ ArithCodec()

template<class T>
dirac::ArithCodec< T >::ArithCodec ( ByteIO * p_byteio,
size_t number_of_contexts )

Creates an ArithCodec object to decode input based on a set of parameters.

Parameters
p_byteioinput/output for encoded bits
number_of_contextsthe number of contexts used

References dirac::ArithCodecBase::ArithCodecBase().

◆ ~ArithCodec()

template<class T>
virtual dirac::ArithCodec< T >::~ArithCodec ( )
inlinevirtual

Destructor is virtual as this class is abstract.

Member Function Documentation

◆ Compress()

template<class T>
int dirac::ArithCodec< T >::Compress ( T & in_data)

Compress takes a type T object (a container or array) and compresses it using the abstract function DoWorkCode() which is overridden in subclasses. It returns the number of bits written.

Parameters
in_datathe input to be compressed. Non-const, since the compression may be lossy.

References dirac::ArithCodecBase::ByteCount(), DoWorkCode(), dirac::ArithCodecBase::FlushEncoder(), and dirac::ArithCodecBase::InitEncoder().

◆ Decompress()

template<class T>
void dirac::ArithCodec< T >::Decompress ( T & out_data,
const int num_bytes )

Decompresses the bitstream, up to the number of bytes specified and writes into the output subclasses.

Parameters
out_datathe output into which the decompressed data is written.
num_bytesthe number of bytes to be read from the bitstream.

References DoWorkDecode(), and dirac::ArithCodecBase::InitDecoder().

◆ DoWorkCode()

template<class T>
virtual void dirac::ArithCodec< T >::DoWorkCode ( T & in_data)
protectedpure virtual

◆ DoWorkDecode()

template<class T>
virtual void dirac::ArithCodec< T >::DoWorkDecode ( T & out_data)
protectedpure virtual

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

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