KASKADE 7 development version
|
Base class for entropy coding with range encoder and decoder. More...
#include <rangecoder.hh>
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.
UInt | an unsigned integral type with more than 16 bits (usually 32 or 64 bit usigned integer). |
Definition at line 62 of file rangecoder.hh.
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) |
|
inlineprotected |
Definition at line 105 of file rangecoder.hh.
|
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.
|
staticprotected |
Definition at line 85 of file rangecoder.hh.
|
protected |
Definition at line 114 of file rangecoder.hh.
Referenced by RangeDecoder< UInt >::pop(), RangeDecoder< UInt >::RangeDecoder(), and RangeCoder< UInt >::size().
|
staticprotected |
Definition at line 66 of file rangecoder.hh.
Referenced by RangeCoder< UInt >::RangeCoder().
|
protected |
Definition at line 113 of file rangecoder.hh.
Referenced by RangeDecoder< UInt >::front(), RangeDecoder< UInt >::pop(), and RangeEncoder< UInt >::push().
|
static |
Maximal total range of alphabets.
Definition at line 91 of file rangecoder.hh.
|
protected |
Definition at line 113 of file rangecoder.hh.
Referenced by RangeDecoder< UInt >::front(), RangeDecoder< UInt >::pop(), and RangeEncoder< UInt >::push().
|
staticprotected |
Definition at line 76 of file rangecoder.hh.