KASKADE 7 development version
Loading...
Searching...
No Matches
PrefixEncoder< Symbol, OIter, Output, State > Class Template Reference

An encoder for arbitrary prefix codes. More...

#include <prefixcoder.hh>

Public Member Functions

 PrefixEncoder (OIter out_)
 ~PrefixEncoder ()
 Flushes the remaining state, i.e. writes the rest of the encoded message to the output.
void push_back (Symbol s, PrefixCode< Symbol, State > const &code)
 Appends a symbol to the encoded message.
void push_back (State c, int n)
 Appends a given codeword directly.

Detailed Description

template<class Symbol, class OIter, class Output, class State = uint64_t>
class PrefixEncoder< Symbol, OIter, Output, State >

An encoder for arbitrary prefix codes.

The encoder supports encoding each symbol with an individual prefix code (i.e. it's context adaptive), but the context (i.e. the actual code) needs to be communicated as side information, it is not stored in the message.

The encoder maintains the tail of the encoded message as internal state, which is written to the output only on deconstruction (or if more symbols are pushed). Thus, the encoded message is only complete after the encoder deconstruction.

The encoded message can be decoded with the PrefixDecoder parametrized with the same types and provided with the same prefix codes.

Template Parameters
Symbolan unsigned integral type for representing symbols.
OIteran output iterator type for storing the encoded message. Output needs to be convertible to OIter's value type without any information loss.
Outputan unsigned integral type used for storing the encoded message. Note that 8*sizeof(Output)+maxLength <= 8*sizeof(State) hast to hold.
Statean unsigned integral type used for representing part of the message and for assembling the message. It has to be large enough to hold 8*sizeof(Output)+maxLength bits

Definition at line 260 of file prefixcoder.hh.

Constructor & Destructor Documentation

◆ PrefixEncoder()

template<class Symbol, class OIter, class Output, class State = uint64_t>
PrefixEncoder< Symbol, OIter, Output, State >::PrefixEncoder ( OIter out_)
inline

Definition at line 267 of file prefixcoder.hh.

◆ ~PrefixEncoder()

template<class Symbol, class OIter, class Output, class State = uint64_t>
PrefixEncoder< Symbol, OIter, Output, State >::~PrefixEncoder ( )
inline

Flushes the remaining state, i.e. writes the rest of the encoded message to the output.

Definition at line 275 of file prefixcoder.hh.

Member Function Documentation

◆ push_back() [1/2]

template<class Symbol, class OIter, class Output, class State = uint64_t>
void PrefixEncoder< Symbol, OIter, Output, State >::push_back ( State c,
int n )
inline

Appends a given codeword directly.

This can be used to interleave the encoded bit stream with additional data. Note that on decoding, these explicit code words need to be extracted with the same length at the same position in the stream - this information is not encoded in the message itself.

Parameters
cthe code word to append (right-aligned, i.e. in the n least significant bits)
nthe length of the code word in bits. This can be at most 8*(sizeof(State)-sizeof(Output)).

Definition at line 313 of file prefixcoder.hh.

◆ push_back() [2/2]

template<class Symbol, class OIter, class Output, class State = uint64_t>
void PrefixEncoder< Symbol, OIter, Output, State >::push_back ( Symbol s,
PrefixCode< Symbol, State > const & code )
inline

Appends a symbol to the encoded message.

Parameters
codethe prefix code to use for selecting the code word

Definition at line 291 of file prefixcoder.hh.

Referenced by push_back().


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