![]() |
KASKADE 7 development version
|
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. | |
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.
| Symbol | an unsigned integral type for representing symbols. |
| OIter | an output iterator type for storing the encoded message. Output needs to be convertible to OIter's value type without any information loss. |
| Output | an unsigned integral type used for storing the encoded message. Note that 8*sizeof(Output)+maxLength <= 8*sizeof(State) hast to hold. |
| State | an 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.
|
inline |
Definition at line 267 of file prefixcoder.hh.
|
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.
|
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.
| c | the code word to append (right-aligned, i.e. in the n least significant bits) |
| n | the 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.
|
inline |
Appends a symbol to the encoded message.
| code | the prefix code to use for selecting the code word |
Definition at line 291 of file prefixcoder.hh.
Referenced by push_back().