RPNX::Compress
Self-contained C++20 compression and ZIP library
 
Loading...
Searching...
No Matches
rpnx::compression::deflate_codec::huffman_decoder Class Reference

Canonical Huffman decoder for the bit-reversed codes used by DEFLATE. More...

#include <deflate.hpp>

Public Member Functions

void build (std::span< std::uint8_t const > lengths, format stream_format, bool allow_empty=false)
 Builds and validates a decoder from per-symbol code lengths.
 
template<typename reader_type>
std::uint16_t decode (reader_type &reader, format stream_format) const
 Decodes one symbol from a bit reader.
 

Detailed Description

Canonical Huffman decoder for the bit-reversed codes used by DEFLATE.

Definition at line 28 of file deflate.hpp.

Member Function Documentation

◆ build()

void rpnx::compression::deflate_codec::huffman_decoder::build ( std::span< std::uint8_t const > lengths,
format stream_format,
bool allow_empty = false )
inline

Builds and validates a decoder from per-symbol code lengths.

Parameters
lengthsCode length for each symbol in symbol order.
stream_formatFormat used to classify validation errors.
allow_emptyWhether an all-zero length set is accepted.
Exceptions
compression_errorIf lengths exceed 15 bits or oversubscribe the tree.

Definition at line 38 of file deflate.hpp.

References rpnx::compression::invalid_data.

Referenced by rpnx::compression::deflate_codec::decompress().

◆ decode()

template<typename reader_type>
std::uint16_t rpnx::compression::deflate_codec::huffman_decoder::decode ( reader_type & reader,
format stream_format ) const
inlinenodiscard

Decodes one symbol from a bit reader.

Template Parameters
reader_typeLSB-first reader providing read_bits().
Parameters
readerSource bit reader.
stream_formatFormat used to classify validation errors.
Returns
Decoded symbol index.
Exceptions
compression_errorIf no code matches the next input bits.

Definition at line 116 of file deflate.hpp.

References rpnx::compression::invalid_data.

Referenced by rpnx::compression::deflate_codec::decompress().


The documentation for this class was generated from the following file: