dirac::ArithCodec< T > Class Template Reference

Abstract binary arithmetic coding class. More...

#include <arith_codec.h>

List of all members.

Public Member Functions

 ArithCodec (BasicOutputManager *bits_out, size_t number_of_contexts)
 Constructor for encoding.
 ArithCodec (BitInputManager *bits_in, size_t number_of_contexts)
 Constructor for decoding.
virtual ~ArithCodec ()
 Destructor.
int Compress (T &in_data)
 Compresses the input and returns the number of bits written.
void Decompress (T &out_data, int num_bits)
 Decompresses the bitstream and writes into the output.

Protected Types

typedef uint16_t code_t
typedef uint32_t calc_t

Protected Member Functions

virtual void InitContexts ()=0
 The method by which the contexts are initialised.
virtual void Update (const bool symbol, const int context_num)=0
 The method by which the counts are updated.
virtual void Resize (const int context_num)=0
 The method by which the counts are resized.
virtual void ResetAll ()=0
 The method by which _all_ the counts are resized.
virtual int ChooseContext (const T &data, const int bin_number) const =0
 Choose the context based on previous data.
virtual int ChooseContext (const T &data) const =0
 Choose the context based on previous data.
virtual void DoWorkCode (T &in_data)=0
 Does the work of actually coding the data.
void InitEncoder ()
 Initialises the Encoder.
void EncodeTriple (const Triple &c)
 encodes a triple and writes to output
void EncodeSymbol (const bool symbol, const int context_num)
 encodes a symbol and writes to output
void FlushEncoder ()
 flushes the output of the encoder.
void FlushDecoder ()
 flushes the input of the encoder by reading all the remaining bits
virtual void DoWorkDecode (T &out_data, int num_bits)=0
 virtual decode-only functions
void InitDecoder ()
 Initialise the Decoder.
void RemFromStream (const Triple &c)
 Remove the symbol from the coded input stream.
void SetCurrentCount (const int context_num)
 Rescales the interval midpoint according to the context.
void DecodeSymbol (bool &symbol, int context_num)
 Decodes a symbol given a context number.

Protected Attributes

std::vector< Contextm_context_list
 List of contexts.

Static Protected Attributes

static const code_t CODE_MAX = 0xffff
static const code_t CODE_MSB = ((0xffff + 1) >> 1)
static const code_t CODE_2ND_MSB = ((0xffff + 1) >> 2)

Classes

class  Context
 A class for binary contexts. More...
class  Triple
 A class for encapsulating interval fractions for use in arithmetic coding. More...


Detailed Description

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

Abstract binary arithmetic coding class.

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

Parameters:
T a container (most probably, or array) type

Definition at line 73 of file arith_codec.h.


Constructor & Destructor Documentation

template<class T>
dirac::ArithCodec< T >::ArithCodec BasicOutputManager bits_out,
size_t  number_of_contexts
 

Constructor for encoding.

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

Parameters:
bits_out output for encoded bits
number_of_contexts the number of contexts used

Definition at line 457 of file arith_codec.h.

Referenced by dirac::ArithCodec< T >::Context::GetSymbol().

template<class T>
dirac::ArithCodec< T >::ArithCodec BitInputManager bits_in,
size_t  number_of_contexts
 

Constructor for decoding.

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

Parameters:
bits_in source of bits to be decoded
number_of_contexts the number of contexts used

Definition at line 447 of file arith_codec.h.

template<class T>
dirac::ArithCodec< T >::~ArithCodec  )  [virtual]
 

Destructor.

Destructor is virtual as this class is abstract.

Definition at line 466 of file arith_codec.h.


Member Function Documentation

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

Compresses the input and returns the number of bits written.

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_data the input to be compressed. Non-const, since the compression may be lossy.

Definition at line 472 of file arith_codec.h.

References dirac::ArithCodec< T >::DoWorkCode(), dirac::ArithCodec< T >::FlushEncoder(), and dirac::ArithCodec< T >::InitEncoder().

Referenced by dirac::FrameCompressor::Compress(), and dirac::CompCompressor::Compress().

template<class T>
void dirac::ArithCodec< T >::Decompress T &  out_data,
int  num_bits
 

Decompresses the bitstream and writes into the output.

Decompresses the bitstream, up to the number of bits specified and writes into the output

subclasses.

Parameters:
out_data the output into which the decompressed data is written.
num_bits the number of bits to be read from the bitstream. [May be eliminated in future revisions. TJD 13 April 2004.]

Definition at line 481 of file arith_codec.h.

References dirac::ArithCodec< T >::DoWorkDecode(), dirac::ArithCodec< T >::FlushDecoder(), dirac::BitInputManager::FlushInput(), and dirac::ArithCodec< T >::InitDecoder().

Referenced by dirac::CompDecompressor::Decompress().


The documentation for this class was generated from the following file:
Generated on Tue Dec 13 14:49:18 2005 for guliverkli by  doxygen 1.4.5