31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.1 Adaptive Arithmetic Coder ( A0Coder )<br />

1. Definition<br />

An instance C of A0Coder is an adaptive arithmetic coder of order zero (which explains<br />

the “0” in the class name). When the coder encodes a stream it counts the frequencies<br />

of the characters that have occured so far in order to obtain a model of the probabilities<br />

for the future characters. <strong>The</strong> model is called order zero because it does not take into<br />

account that the probability of a character c may depend on the characters that precede<br />

it. (E.g., in an English text the probability that the next character is a “u” is very high if<br />

the current character is a “q”. <strong>The</strong> PPMIICoder in Section 9.3 takes this into account.)<br />

<strong>The</strong> advantage of arithmetic coding [92] is that a character in the source stream can be<br />

encoded by a fractional number of bits in the target stream, which leads to good results<br />

in practice.<br />

<strong>The</strong> coder is called adaptive because the model evolves gradually while the coder scans<br />

its input. In contrast to that a static coder reads the whole input once before it generates<br />

a model. During the actual encoding (in a second scan) the model remains fixed. <strong>The</strong><br />

adaptive coder resets and/or scales its model when the number of characters read since<br />

the last reset/scaling exceeds a certain threshold. Both thresholds can be controlled by<br />

the user.<br />

#include < <strong>LEDA</strong>/coding/arithmetic coding.h ><br />

2. Creation<br />

A0Coder C(streambuf ∗ src stream = 0, streambuf ∗ tgt stream = 0,<br />

bool own streams = false);<br />

creates an instance C which uses the given source and target<br />

streams. If own streams is set, then C is responsible for the destruction<br />

of the streams, otherwise the pointers src stream and tgt stream<br />

must be valid during the life-time of C.<br />

A0Coder<br />

C(const char ∗ src file name, const char ∗ tgt file name);<br />

creates an instance C which uses file-streams for input and output.<br />

3. Operations<br />

Standard Operations<br />

void C.encode( ) encodes the source stream and writes the output to<br />

the target stream.<br />

void C.decode( ) decodes the source stream and writes the output to<br />

the target stream.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!