7#include "../utility/utility.hpp"
8#include "../macros.hpp"
13hi_export_module(hikogui.codec.huffman);
15hi_export
namespace hi {
inline namespace v1 {
17hi_export
template<
typename T>
19 static_assert(std::is_integral_v<T> && std::is_signed_v<T>);
21 using state_t = T
const *;
53 int value = tree[offset];
72 auto const select = code & 1;
75 hi_axiom(tree[offset] == 0);
98 state +=
static_cast<ptrdiff_t
>(
code_bit);
105 state -=
static_cast<ptrdiff_t
>(value);
111 auto state = start();
143 if (a.length == b.length) {
144 return a.symbol < b.symbol;
146 return a.length < b.length;
155 if (
entry.length != 0) {
170 return from_lengths(lengths.
data(), lengths.
size());
@ select
The widget is selectable.
The HikoGUI namespace.
Definition array_generic.hpp:20
bool get_bit(std::span< std::byte const > buffer, std::size_t &index) noexcept
Read a single bit from span of bytes Bits are ordered LSB first.
Definition bits.hpp:27
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition huffman.hpp:18
static huffman_tree from_lengths(uint8_t const *lengths, std::size_t nr_symbols)
Build a canonical-huffman table from a set of lengths.
Definition huffman.hpp:122
void add(int symbol, int code, int code_length) noexcept
Add a symbol to the huffman_tree.
Definition huffman.hpp:44
int get(bool code_bit, state_t &state) const
Get a symbol from the huffman-tree.
Definition huffman.hpp:96
Exception thrown during parsing on an error.
Definition exception_intf.hpp:48