KASKADE 7 development version
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
RangeCoder< UInt > Class Template Reference

Base class for entropy coding with range encoder and decoder. More...

#include <rangecoder.hh>

Detailed Description

template<class UInt>
class RangeCoder< UInt >

Base class for entropy coding with range encoder and decoder.

The coding works on sequences \( (s_i)_i \) of symbols. The symbols \( s_i \) are elements of an alphabet \( S_i \), which may be a different one for any position \( i \).

Each symbol \( s \) is a pair of values \( (s_{\text{low}},s_{\text{high}}) \) with \( s_{\text{low}} < s_{\text{high}} \). Symbols represent half-open integer ranges. Symbols from the same alphabet are non-overlapping, i.e., \( s,t\in S \Rightarrow s_{\text{high}} \le t_{\text{low}} \vee t_{\text{high}} \le s_{\text{low}} \).

Each alphabet \( S \) is a setof nonoverlapping symbols such that \( s_{\text{high}} \le \text{maxRange} \) for all \( s\in S \).

Note that the range coder is not self-terminating. That means that spurious trailing symbols can be extracted. For a correct termination of the symbol sequence on decoding, you either need to transmit the length of the symbol sequence beforehand or define a special EOF symbol.

The range coder algorithm is derived from the implementation by Dmitry Subbotin. See also https://en.wikipedia.org/wiki/Range_encoding.

Template Parameters
UIntan unsigned integral type with more than 16 bits (usually 32 or 64 bit usigned integer).

Definition at line 62 of file rangecoder.hh.

Inheritance diagram for RangeCoder< UInt >:
RangeDecoder< UInt > RangeEncoder< UInt >

Public Member Functions

size_t size () const
 Number of processed encoded bytes. More...
 

Static Public Attributes

static const UInt maxRange = bottom
 Maximal total range of alphabets. More...
 

Protected Member Functions

 RangeCoder ()
 

Protected Attributes

UInt low
 
UInt range
 
size_t count
 

Static Protected Attributes

static int const digits = std::numeric_limits<UInt>::digits
 
static UInt const top = static_cast<UInt>(1) << (digits-8)
 
static UInt const bottom = static_cast<UInt>(1) << (digits-16)
 

Constructor & Destructor Documentation

◆ RangeCoder()

template<class UInt >
RangeCoder< UInt >::RangeCoder ( )
inlineprotected

Definition at line 105 of file rangecoder.hh.

Member Function Documentation

◆ size()

template<class UInt >
size_t RangeCoder< UInt >::size ( ) const
inline

Number of processed encoded bytes.

When encoding, this is the number of bytes already written to the output stream. When decoding, this is the number of bytes already read from the input stream.

Definition at line 100 of file rangecoder.hh.

Member Data Documentation

◆ bottom

template<class UInt >
UInt const RangeCoder< UInt >::bottom = static_cast<UInt>(1) << (digits-16)
staticprotected

Definition at line 85 of file rangecoder.hh.

◆ count

template<class UInt >
size_t RangeCoder< UInt >::count
protected

◆ digits

template<class UInt >
int const RangeCoder< UInt >::digits = std::numeric_limits<UInt>::digits
staticprotected

Definition at line 66 of file rangecoder.hh.

Referenced by RangeCoder< UInt >::RangeCoder().

◆ low

template<class UInt >
UInt RangeCoder< UInt >::low
protected

◆ maxRange

template<class UInt >
const UInt RangeCoder< UInt >::maxRange = bottom
static

Maximal total range of alphabets.

Definition at line 91 of file rangecoder.hh.

◆ range

template<class UInt >
UInt RangeCoder< UInt >::range
protected

◆ top

template<class UInt >
UInt const RangeCoder< UInt >::top = static_cast<UInt>(1) << (digits-8)
staticprotected

Definition at line 76 of file rangecoder.hh.


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