Skip to main content
QUICK REVIEW

[Paper Review] Encoding and Decoding Algorithms of ANS Variants and Evaluation of Their Average Code Lengths

H. Yamamoto, Ken‐ichi Iwata|arXiv (Cornell University)|Aug 14, 2024
Coding theory and cryptographyComputer Science1 citations
TL;DR

This paper provides a comprehensive, accessible explanation of encoding and decoding algorithms for ANS variants—ABS, rANS, and tANS—while deriving tight information-theoretic upper bounds on their average code length. It shows that tANS achieves near-optimal compression with a bounded loss of less than 1 bit per symbol when using optimal probability distributions, making it highly efficient for practical lossless compression systems.

ABSTRACT

Asymmetric Numeral Systems (ANS) proposed by Jarek Duda are high-performance distortionless data compression schemes that can achieve almost the same compression performance as arithmetic codes with less arithmetic operations than arithmetic coding. The ANS is widely used in various practical systems like Facebook, Apple, Google, Dropbox, Microsoft, and Pixar, due to their high performance, but many researchers still lack much knowledge about the ANS. This paper thoroughly explains the encoding and decoding algorithms of the ANS, and theoretically analyzes the average code length achievable by the ANS.

Motivation & Objective

  • To provide a clear, detailed explanation of ANS encoding and decoding algorithms, which are often poorly documented and difficult to understand.
  • To address the lack of theoretical performance evaluation for ANS, especially regarding average code length, despite its widespread use in systems like Zstandard, LZFSE, and Google's compression tools.
  • To derive rigorous information-theoretic upper bounds on the average code length achievable by ANS variants, particularly focusing on tANS and its deviation from ideal performance.
  • To clarify the relationship between ANS and arithmetic coding, emphasizing how ANS achieves similar compression efficiency with fewer arithmetic operations through integer arithmetic and reverse-order processing.

Proposed method

  • Proposes and formalizes encoding and decoding functions for three ANS variants: ABS (Asymmetric Binary Systems), rANS (range variant), and tANS (tabled variant), using integer arithmetic.
  • Introduces a novel information-theoretic analysis to bound the expected average code length per symbol, using entropy H(p) and relative entropy D(p∥q) as key components.
  • Derives a strict upper bound for tANS: L ≤ H(p) + D(p∥q) + α/N, where α is a constant and N is the table size, showing near-optimality.
  • Analyzes the loss in average code length due to quantization in tANS by comparing real-valued ideal codeword lengths to integer-based implementations.
  • Uses Jensen’s inequality and probability distributions to bound the deviation between actual and ideal code lengths, especially in the tANS case.
  • Demonstrates that with optimal construction of the mapping function C̃, the distribution Q(x) can closely approximate the ideal Q*(x) = (lg x + 1)/x, minimizing performance loss.

Experimental results

Research questions

  • RQ1How do the encoding and decoding algorithms of ABS, rANS, and tANS work in practice, and what are their key differences?
  • RQ2What is the theoretical upper bound on the average code length achievable by ANS variants, and how close can they get to the information-theoretic limit?
  • RQ3What is the performance loss in tANS compared to an ideal real-valued codeword system, and how can it be minimized through proper design?
  • RQ4Can the average code length of tANS be bounded in terms of entropy and relative entropy, and what role does the table size N play in this bound?
  • RQ5How does the choice of probability distribution and mapping function affect the compression efficiency of tANS?

Key findings

  • The average code length of tANS is bounded by H(p) + D(p∥q) + α/N, where α is a constant, showing that the performance loss decreases with larger table sizes.
  • The theoretical loss in average code length compared to the ideal case is strictly less than 1 bit per symbol, as shown by the bound L − L* < 1.
  • When the probability distribution q(s) = N/Ns matches the source distribution p(s), the mapping function C̃ can be constructed such that Q(x) = Q*(x) + O(1/N²), achieving near-optimal performance.
  • The ideal stationary distribution for tANS is Q*(x) = (lg x + 1)/x, and achieving this distribution minimizes the average code length.
  • The analysis confirms that tANS can achieve compression performance very close to the entropy limit, with a small, bounded loss due to integer quantization.
  • The paper establishes that even with integer arithmetic, ANS can match the compression efficiency of arithmetic coding while requiring fewer computational operations, making it suitable for high-performance systems.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.