Testing various methods for choosing tANS entropy coding automata
C++
80
35 commits
updated Dec 23, 2023
Testing various methods for choosing tANS entropy coding automata
ANS is new approach to entropy coding, which adds fractional bits into consideration into Huffman-like decoder, combining its speed with accuracy of arithmetic coding, like in implementation of Yann Collet. Another advantage in comparison to Huffman coding is that we choose the size of coding tables (L) here, corresponding to 2^depth of Huffman tree, and that there is no need to sort symbol probabilities (linear initialization).
The choice of such finite L state entropy coding automaton consists of 2-3 parts (which generally can be merged):
This toolkit contains various choices of these functions, allows to test obtained compression rates, compare with Huffman. Currently it allows to choose betwen:
For example for 4 symbol and L=16 states: p=(0.04 0.16 0.16 0.64), q/L=(0.0625 0.1875 0.125 0.625).
| method | symbol spread | dH/H rate loss | comment |
|---|---|---|---|
| - | - | ~0.011 | penalty of quantizer itself |
| Huffman | 0011222233333333 | ~0.080 | would give Huffman decoder |
| spread_range_i() | 0111223333333333 | ~0.059 | analogous to Huffman |
| spread_range_d() | 3333333333221110 | ~0.022 | decreasing order |
| spread_fast() | 0233233133133133 | ~0.020 | fast |
| spread_prec() | 3313233103332133 | ~0.015 | generally close to quantization dH/H |
| spread_tuned() | 3233321333313310 | ~0.0046 | better than quantization dH/H due to using also p |
| spread_tuned_s() | 2333312333313310 | ~0.0040 | L log L complexity (sort) |
| spread_tuned_p() | 2331233330133331 | ~0.0058 | testing 1/(p ln(1+1/i)) ~ i/p approximation |
Tuning shifts symbols right when q[s]/L > p[s] and left otherwise, getting better agreement and so compression rate.
Some sources: article, slides, discussion, list of implementations of ANS.
Feel free to add new probability distributions, better quantizers and spreads.
Jarek Duda, July 2014
Update: paper with tuned spread: https://arxiv.org/pdf/2106.06438
C++
100.0%
Testing various methods for choosing tANS entropy coding automata
C++
80
35 commits
updated Dec 23, 2023
Testing various methods for choosing tANS entropy coding automata
ANS is new approach to entropy coding, which adds fractional bits into consideration into Huffman-like decoder, combining its speed with accuracy of arithmetic coding, like in implementation of Yann Collet. Another advantage in comparison to Huffman coding is that we choose the size of coding tables (L) here, corresponding to 2^depth of Huffman tree, and that there is no need to sort symbol probabilities (linear initialization).
The choice of such finite L state entropy coding automaton consists of 2-3 parts (which generally can be merged):
This toolkit contains various choices of these functions, allows to test obtained compression rates, compare with Huffman. Currently it allows to choose betwen:
For example for 4 symbol and L=16 states: p=(0.04 0.16 0.16 0.64), q/L=(0.0625 0.1875 0.125 0.625).
| method | symbol spread | dH/H rate loss | comment |
|---|---|---|---|
| - | - | ~0.011 | penalty of quantizer itself |
| Huffman | 0011222233333333 | ~0.080 | would give Huffman decoder |
| spread_range_i() | 0111223333333333 | ~0.059 | analogous to Huffman |
| spread_range_d() | 3333333333221110 | ~0.022 | decreasing order |
| spread_fast() | 0233233133133133 | ~0.020 | fast |
| spread_prec() | 3313233103332133 | ~0.015 | generally close to quantization dH/H |
| spread_tuned() | 3233321333313310 | ~0.0046 | better than quantization dH/H due to using also p |
| spread_tuned_s() | 2333312333313310 | ~0.0040 | L log L complexity (sort) |
| spread_tuned_p() | 2331233330133331 | ~0.0058 | testing 1/(p ln(1+1/i)) ~ i/p approximation |
Tuning shifts symbols right when q[s]/L > p[s] and left otherwise, getting better agreement and so compression rate.
Some sources: article, slides, discussion, list of implementations of ANS.
Feel free to add new probability distributions, better quantizers and spreads.
Jarek Duda, July 2014
Update: paper with tuned spread: https://arxiv.org/pdf/2106.06438
C++
100.0%