Capstan.Zstd.Huffman (Capstan v1.2.1)

Copy Markdown View Source

zstd Huffman decoding (RFC 8878 §4.2): the weight description (direct nibble form or FSE-compressed), the weight→prefix-code conversion, and the single-table (X1) decode of 1- and 4-stream literal blocks.

Summary

Functions

Decodes count symbols from one Huffman reverse bitstream using table.

Parses a Huffman tree description from the head of bin. Returns {:ok, table, bytes_consumed} where table maps a tableLog-bit peek value to {symbol, nb_bits}.

Functions

decode_stream(table, count, bin)

@spec decode_stream(map(), non_neg_integer(), binary()) ::
  {:ok, binary()} | {:error, term()}

Decodes count symbols from one Huffman reverse bitstream using table.

read_tree(arg)

@spec read_tree(binary()) :: {:ok, map(), non_neg_integer()} | {:error, term()}

Parses a Huffman tree description from the head of bin. Returns {:ok, table, bytes_consumed} where table maps a tableLog-bit peek value to {symbol, nb_bits}.