21 #import "OFInvalidFormatException.h"
23 OF_ASSUME_NONNULL_BEGIN
25 struct of_huffman_tree {
26 struct of_huffman_tree *_Nullable leaves[2];
31 of_huffman_tree_walk(
id _Nullable stream,
32 bool (*bitReader)(
id _Nullable, uint16_t *_Nonnull, uint8_t),
33 struct of_huffman_tree *_Nonnull *_Nonnull tree, uint16_t *_Nonnull value)
35 struct of_huffman_tree *iter = *tree;
38 while (iter->value == 0xFFFF) {
39 if OF_UNLIKELY (!bitReader(stream, &bits, 1)) {
44 if OF_UNLIKELY (iter->leaves[bits] == NULL)
47 iter = iter->leaves[bits];
57 extern struct of_huffman_tree *_Nonnull of_huffman_tree_construct(
58 uint8_t lengths[_Nonnull], uint16_t count);
59 extern struct of_huffman_tree *_Nonnull of_huffman_tree_construct_single(
61 extern void of_huffman_tree_release(
struct of_huffman_tree *_Nonnull tree);