Table of Contents
Fetching ...

Encoding and Decoding Algorithms of ANS Variants and Evaluation of Their Average Code Lengths

Hirosuke Yamamoto, Ken-ichi Iwata

TL;DR

This work provides a detailed, accessible treatment of Asymmetric Numeral Systems (ANS) and its variants—ABS, rANS, and tANS—alongside rigorous information-theoretic bounds on their average code lengths. By presenting explicit encoding/decoding procedures, finite-digit stream implementations, and table-based variants, the authors quantify how closely ANS can approach fundamental limits such as $H(p)$ and $H(p) + D(p\|q)$ under various practical constraints. They analyze the impact of finite arithmetic, streaming, and tiling on efficiency, showing that overhead can be bounded (e.g., $O(1/N)$) and will vanish asymptotically with sequence length. The results offer practical guidance for deploying ANS in real-world compressors (e.g., ZSTD, LZFSE) and inform design choices for achieving near-optimal compression with low computational cost.

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.

Encoding and Decoding Algorithms of ANS Variants and Evaluation of Their Average Code Lengths

TL;DR

This work provides a detailed, accessible treatment of Asymmetric Numeral Systems (ANS) and its variants—ABS, rANS, and tANS—alongside rigorous information-theoretic bounds on their average code lengths. By presenting explicit encoding/decoding procedures, finite-digit stream implementations, and table-based variants, the authors quantify how closely ANS can approach fundamental limits such as and under various practical constraints. They analyze the impact of finite arithmetic, streaming, and tiling on efficiency, showing that overhead can be bounded (e.g., ) and will vanish asymptotically with sequence length. The results offer practical guidance for deploying ANS in real-world compressors (e.g., ZSTD, LZFSE) and inform design choices for achieving near-optimal compression with low computational cost.

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.
Paper Structure (14 sections, 48 equations, 2 figures)

This paper contains 14 sections, 48 equations, 2 figures.

Figures (2)

  • Figure 1: Relations used in rANS encoding and decoding.
  • Figure 2: Relation between Push and Pop used in stream encoding and decoding of rANS.

Theorems & Definitions (6)

  • Remark 1
  • Remark 2
  • Remark 3
  • Remark 4
  • Remark 5
  • Remark 6