Also-RANS: Asymmetric Numeral Systems for Entropy Coding

原始链接: https://fergusfinn.com/blog/understanding-rans/

相关文章

原文

rANS is one of a family of entropy coding methods that we can use to compress a stream of symbols losslessly. For some set of symbols sSs \in S

Huffman coding can help us cleanly with the first two. But it uses fixed width symbols. The third symbol is going to end up taking 22 bits to decode. The result is that we can’t get perfect lossless compression.

rANS is one of a set of arithmetic coding methods that can achieve perfect compression, by not using fixed width symbols. Instead, the stream of bits is encoded into an integer, by a series of reversible arithmetic operations.

Encoding a sequence into an integer§

The code is a single integer, call it the state xx. Each symbol we encode transforms xx through some arithmetic operation. The operation has to be reversible, because the decoder needs to recover both the symbol and the previous state from the new one.

The specific operation rANS uses is:

x=xfsM+cs+(xmodfs)x' = \left\lfloor \frac{x}{f_s} \right\rfloor \cdot M + c_s + (x \bmod f_s)
联系我们 contact @ memedata.com