Capstan.Zstd.BitReader (Capstan v1.2.1)

Copy Markdown View Source

The two bit readers zstd needs (RFC 8878, conventions derived first-hand).

  • Forward — FSE table descriptions: bytes consumed first→last, the first-consumed bit is the LSB of a multi-bit value.
  • Reverse — Huffman-coded streams and sequence bitstreams: bytes walked last→first, bits MSB→LSB within each byte, after skipping the zero padding and the final 1 bit in the stream's last byte; the FIRST bit read is the MSB of a multi-bit value.

Both track remaining usable bits so FSE weight decoding can detect the overflow condition ("extra bits are zero") and stop.