Range encoding

Range encoding

Range encoding is a data compression method defined by G N N Martin in his 1979 paper on "Range encoding: an algorithm for removing redundancy from a digitized message" [http://www.compressconsult.com/rangecoder/#download Range Encoder ] ] . Range encoding is mathematically equivalent to arithmetic coding, a patent encumbered technique. Range "encoders" often use a particular kind of implementation based on Martin's paper. Such implementations are known to be free from arithmetic coding related patents, on the basis of the age of Martin's paper. This clear lack of patent encumbrance has driven interest in range encoding, particularly in the open source community.

How range encoding works

Range encoding conceptually encodes all the symbols of the message into one number, unlike Huffman coding which assigns each symbol a bit-pattern and concatenates all the bit-patterns together. Thus range encoding can achieve greater compression ratios than the one-bit-per-symbol upper bound on Huffman encoding and it does not suffer the inefficiencies that Huffman does when dealing with probabilities that are not exact powers of two.

The central concept behind range encoding is this: given a large-enough range of integers, and a probability estimation for the symbols, the initial range can easily be divided into sub-ranges whose sizes are proportional to the probability of the symbol they represent. Each symbol of the message can then be encoded in turn, by reducing the current range down to just that sub-range which corresponds to the next symbol to be encoded. The decoder must have the same probability estimation the encoder used, which can either be sent in advance, derived from already transferred data or be part of the compressor and decompressor.

When all symbols have been encoded, merely identifying the sub-range is enough to communicate the entire message (presuming of course that the decoder is somehow notified when it has extracted the entire message). A single integer is actually sufficient to identify the sub-range, and it may not even be necessary to transmit the entire integer; if there is a sequence of digits such that every integer beginning with that prefix falls within the sub-range, then the prefix alone is all that's needed to identify the sub-range and thus transmit the message.

Example

Suppose we want to encode the message "AABA", where is the end-of-message symbol. For this example it is assumed that the decoder knows that we intend to use base 10 number system, an initial range of [0, 100000) and the frequency algorithm {A: .60; B: .20; : .20}. The first symbol breaks down the range [0, 100000) into three subranges:

A: [ 0, 60000) B: [ 60000, 80000) : [ 80000, 100000)

Since our first symbol is an A, it reduces our initial range down to [0, 60000). The second symbol choice leaves us with three sub-ranges of this range, we show them following the already-encoded 'A':

AA: [ 0, 36000) AB: [ 36000, 48000) A: [ 48000, 60000)

With two symbols encoded, our range is now [0, 36000) and our third symbols leads to the following choices:

AAA: [ 0, 21600) AAB: [ 21600, 28800) AA: [ 28800, 36000)

This time it is the second of our three choices that represent the message we want to encode, and our range becomes [21600, 28800). It may look harder to determine our sub-ranges in this case, but it is actually not: we can merely subtract the lower bound from the upper bound to determine that there are 7200 numbers in our range; that the first 4320 of them represent .60 of the total, the next 1440 represent the next .20, and the remaining 1440 represent the remaining .20 of the total. Adding back the lower bound gives us our ranges:

AABA: [21600, 25920) AABB: [25920, 27360) AAB: [27360, 28800)

Finally, with our range narrowed down to [21600, 25920), we have just one more symbol to encode. Using the same technique as before for dividing up the range between the lower and upper bound, we find the three sub-ranges are:

AABAA: [21600, 24192) AABAB: [24192, 25056) AABA: [25056, 25920)

And since is our final symbol, our final range is [25056, 25920). Because all five-digit integers starting with "251" fall within our final range, it is one of the three-digit prefixes we could transmit that would unambiguously convey our original message. (The fact that there are actually eight such prefixes in all implies we still have inefficiencies. They have been introduced by our use of base 10 rather than base 2.)

The central problem may appear to be selecting an initial range large enough that no matter how many symbols we have to encode, we will always have a current range large enough to divide into non-zero sub-ranges. In practice, however, this is not a problem, because instead of starting with a very large range and gradually narrowing it down, the encoder works with a smaller range of numbers at any given time. After some number of digits have been encoded, the leftmost digits will not change. In the example after encoding just three symbols, we already knew that our final result would start with "2". More digits are shifted in on the right as digits on the left are sent off.

Relationship with arithmetic coding

Arithmetic coding is the same as range encoding, but with the integers taken as being the numerators of fractions. These fractions have an implicit, common denominator, such that all the fractions fall in the range [0,1). Accordingly, the resulting arithmetic code is interpreted as beginning with an implicit "0.". As these are just different interpretations of the same coding methods, and as the resulting arithmetic and range codes are identical, each arithmetic coder is its corresponding range encoder, and vice-versa. In other words, arithmetic coding and range encoding are just two, slightly different ways of understanding the same thing.

In practice, though, so-called range "encoders" tend to be implemented pretty much as described in Martin's paper, while arithmetic coders more generally tend not to be called range encoders. An often noted feature of such range encoders is the tendency to perform renormalization a byte at a time, rather than one bit at a time (as is usually the case). In other words, range encoders tend to use bytes as encoding digits, rather than bits. While this does reduce the amount of compression that can be achieved by a very small amount, it is faster than when performing renormalization for each bit.

See also

*Shannon-Fano coding

References

External links

* [http://web.archive.org/web/20041014083730/www.compressconsult.com/rangecoder/ Range Encoder]
* [http://www.arturocampos.com/ac_range.html "Range coder" by Arturo Campos]

* [http://www.ezcodesample.com/reanatomy.html "Anatomy of Range Encoder" by Andrew Polar]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Range-encoding — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range encoding — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range-Code — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range-Coder — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range-Kodierer — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range-Kodierung — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range Coder — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Range code — Die Bereichskodierung (engl. Range encoding) ist ein Datenkompressionsverfahren zur Entropiekodierung, das eine Art des arithmetischen Kodierens realisiert. Die Bereichskodierung wird oft als alternative Beschreibung des Arithmetischen Kodierens… …   Deutsch Wikipedia

  • Variable-width encoding — This article is about the storage of text in computers. For the transmission of data across noisy channels, see variable length code. A variable width encoding is a type of character encoding scheme in which codes of differing lengths are used to …   Wikipedia

  • Character encoding — Special characters redirects here. For the Wikipedia editor s handbook page, see Help:Special characters. A character encoding system consists of a code that pairs each character from a given repertoire with something else, such as a sequence of… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”