Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Dynamic Markov compression

From Wikipedia, the free encyclopedia
Lossless data compression algorithm

Dynamic Markov compression (DMC) is a losslessdata compressionalgorithm developed byGordon Cormack andNigel Horspool.[1] It uses predictivearithmetic coding similar toprediction by partial matching (PPM), except that the input is predicted one bit at a time (rather than one byte at a time). DMC has a good compression ratio and moderate speed, similar to PPM, but requires somewhat more memory and is not widely implemented. Some recent implementations include the experimental compression programshook by Nania Francesco Antonio,ocamyd by Frank Schwellinger, and as a submodel inpaq8l by Matt Mahoney. These are based on the1993 implementation in C by Gordon Cormack.

Algorithm

[edit]

DMC predicts and codes one bit at a time. It differs fromPPM in that it codes bits rather than bytes, and fromcontext mixing algorithms such asPAQ in that there is only one context per prediction. The predicted bit is then coded usingarithmetic coding.

Arithmetic coding

[edit]

A bitwise arithmetic coder such as DMC has two components, a predictor and an arithmetic coder. The predictor accepts ann-bit input stringx =x1x2...xn and assigns it a probabilityp(x), expressed as a product of a series of predictions,p(x1)p(x2|x1)p(x3|x1x2) ...p(xn|x1x2...xn–1). The arithmetic coder maintains two high precision binary numbers,plow andphigh, representing the possible range for the total probability that the model would assign to all strings lexicographically less thanx, given the bits ofx seen so far. The compressed code forx ispx, the shortest bit string representing a number betweenplow andphigh. It is always possible to find a number in this range no more than one bit longer than theShannon limit, log2 1/p(x). One such number can be obtained fromphigh by dropping all of the trailing bits after the first bit that differs fromplow.

Compression proceeds as follows. The initial range is set toplow = 0,phigh = 1. For each bit, the predictor estimatesp0 =p(xi = 0|x1x2...xi–1) andp1 = 1 − p0, the probability of a 0 or 1, respectively. The arithmetic coder then divides the current range, (plowphigh) into two parts in proportion top0 andp1. Then the subrange corresponding to the next bitxi becomes the new range.

For decompression, the predictor makes an identical series of predictions, given the bits decompressed so far. The arithmetic coder makes an identical series of range splits, then selects the range containingpx and outputs the bitxi corresponding to that subrange.

In practice, it is not necessary to keepplow andphigh in memory to high precision. As the range narrows the leading bits of both numbers will be the same, and can be output immediately.

DMC model

[edit]

The DMC predictor is a table which maps (bitwise) contexts to a pair of counts,n0 andn1, representing the number of zeros and ones previously observed in this context. Thus, it predicts that the next bit will be a 0 with probabilityp0 =n0/n =n0/ (n0 + n1) and 1 with probabilityp1 = 1 − p0 =n1/n. In addition, each table entry has a pair of pointers to the contexts obtained by appending either a 0 or a 1 to the right of the current context (and possibly dropping bits on the left). Thus, it is never necessary to look up the current context in the table; it is sufficient to maintain a pointer to the current context and follow the links.

In the original DMC implementation, the initial table is the set of all contexts of length 8 to 15 bits that begin on a byte boundary. The initial state is any of the 8 bit contexts. The counts are floating point numbers initialized to a small nonzero constant such as 0.2. The counts are not initialized to zero in order to allow values to be coded even if they have not been seen before in the current context.

Modeling is the same for compression and decompression. For each bit,p0 andp1 are computed, bitxi is coded or decoded, the model is updated by adding 1 to the count corresponding toxi, and the next context is found by traversing the link corresponding toxi.

Adding new contexts

[edit]

DMC as described above is equivalent to an order-1 context model. However, it is normal to add longer contexts to improve compression. If the current context is A, and the next context B would drop bits on the left, then DMC may add (clone) a new context C from B. C represents the same context as A after appending one bit on the right as with B, but without dropping any bits on the left. The link from A will thus be moved from B to point to C. B and C will both make the same prediction, and both will point to the same pair of next states. The total count,n =n0 + n1 for C will be equal to the countnx for A (for input bit x), and that count will be subtracted from B.

For example, suppose that state A represents the context 11111. On input bit 0, it transitions to state B representing context 110, obtained by dropping 3 bits on the left. In context A, there have been 4 zero bits and some number of one bits. In context B, there have been 3 zeros and 7 ones (n = 10), which predictsp1 = 0.7.

Staten0n1next0next1
A = 111114B
B = 11037EF

C is cloned from B. It represents context 111110. Both B and C predictp1 = 0.7, and both go to the same next states, E and F. The count for C isn = 4, equal ton0 for A. This leavesn = 6 for B.

Staten0n1next0next1
A = 111114C
B = 1101.84.2EF
C = 1111101.22.8EF

States are cloned just prior to transitioning to them. In the original DMC, the condition for cloning a state is when the transition from A to B is at least 2, and the count for B is at least 2 more than that. (When the second threshold is greater than 0, it guarantees that other states will still transition to B after cloning). Some implementations such as hook allow these thresholds to be set as parameters. In paq8l, these thresholds increase as memory is used up to slow the growth rate of new states. In most implementations, when memory is exhausted the model is discarded and reinitialized back to the original bytewise order 1 model.

References

[edit]
  1. ^Gordon Cormack and Nigel Horspool, "Data Compression using Dynamic Markov Modelling", Computer Journal 30:6 (December 1987)

External links

[edit]


Lossless
type
Entropy
Dictionary
Other
Hybrid
Lossy
type
Transform
Predictive
Audio
Concepts
Codec
parts
Image
Concepts
Methods
Video
Concepts
Codec
parts
Theory
Community
People
Retrieved from "https://en.wikipedia.org/w/index.php?title=Dynamic_Markov_compression&oldid=1305863674"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp