Dirac - A Video Codec

Created by the British Broadcasting Corporation.


dirac::ArithCodec< T >::Context Class Reference

A class for binary contexts. More...

#include <arith_codec.h>

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

Private Attributes

Static Private Attributes


Detailed Description

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

A class for binary contexts. Stores probabilities for 0 and 1 in terms of counts of numbers of occurrences, and also as Triples partitioning the interval [0,1) into two parts [0,p) and [p,1).


Constructor & Destructor Documentation

template<class T>
dirac::ArithCodec< T >::Context::Context  )  [inline]
 

Default constructor initialises counts to 1 each of 0 and 1.

template<class T>
dirac::ArithCodec< T >::Context::Context int  cnt0,
int  cnt1
[inline]
 

Constructor initialises the counts to those set.

template<class T>
dirac::ArithCodec< T >::Context::Context const Context cpy  )  [inline]
 

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


Member Function Documentation

template<class T>
calc_t dirac::ArithCodec< T >::Context::GetCount0  )  const [inline]
 

template<class T>
calc_t dirac::ArithCodec< T >::Context::GetCount1  )  const [inline]
 

template<class T>
const ProbInterval& dirac::ArithCodec< T >::Context::GetProbInterval const bool  symbol  )  const [inline]
 

template<class T>
bool dirac::ArithCodec< T >::Context::GetSymbol const calc_t  num,
const calc_t  factor,
ProbInterval prob_val
const [inline]
 

Given a number, return the corresponding symbol and triple.

template<class T>
void dirac::ArithCodec< T >::Context::HalveCounts  )  [inline]
 

template<class T>
void dirac::ArithCodec< T >::Context::IncrCount const bool  symbol  )  [inline]
 

Increment the count of symbol by 1.

Parameters:
symbol the symbol whose count is to be incremented (false=0, true=1)

template<class T>
Context& dirac::ArithCodec< T >::Context::operator= const Context rhs  )  [inline]
 

template<class T>
void dirac::ArithCodec< T >::Context::SetCounts const int  cnt0,
const int  cnt1
[inline]
 

Sets the counts, and then the triples to reflect the counts.

template<class T>
void dirac::ArithCodec< T >::Context::SetRanges  )  [inline]
 

template<class T>
calc_t dirac::ArithCodec< T >::Context::Weight  )  const [inline]
 


Member Data Documentation

template<class T>
const unsigned int dirac::ArithCodec< T >::Context::m_lookup [static, private]
 

Counts m_num0 and m_num1 are scaled to 1024 before being used to make probability intervals for use in the arithmetic codec. This means calculating (m_num0*1024)/m_weight. m_lookup is a lookup table for avoiding doing this division directly. It's defined by

m_lookup[k]=(1<<31)/m_weight

So the calculation instead becomes

(m_num0*m_lookup[m_weight-1])>>21

The 21 comes from 1024/(1<<31).

In principle we're multiplying two ints here so the result should be a long int to retain overflow before the bit shift. But it turns out that since m_num0<m_weight the overflow bits will always be zero so everything can be done with ints.

template<class T>
calc_t dirac::ArithCodec< T >::Context::m_num0 [private]
 

template<class T>
calc_t dirac::ArithCodec< T >::Context::m_num1 [private]
 

template<class T>
ProbInterval dirac::ArithCodec< T >::Context::m_r0 [private]
 

template<class T>
ProbInterval dirac::ArithCodec< T >::Context::m_r1 [private]
 

template<class T>
calc_t dirac::ArithCodec< T >::Context::m_weight [private]
 


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.