25#import "OFInvalidFormatException.h"
27OF_ASSUME_NONNULL_BEGIN
29typedef struct _OFHuffmanTree {
30 struct _OFHuffmanTree *_Nullable leaves[2];
36_OFHuffmanTreeWalk(
id _Nullable stream,
37 bool (*bitReader)(
id _Nullable, uint16_t *_Nonnull, uint8_t),
38 OFHuffmanTree _Nonnull *_Nonnull tree, uint16_t *_Nonnull value)
40 OFHuffmanTree iter = *tree;
43 while (iter->value == 0xFFFF) {
44 if OF_UNLIKELY (!bitReader(stream, &bits, 1)) {
49 if OF_UNLIKELY (iter->leaves[bits] == NULL)
52 iter = iter->leaves[bits];
62extern OFHuffmanTree _Nonnull _OFHuffmanTreeNew(uint8_t lengths[_Nonnull],
63 uint16_t count) OF_VISIBILITY_HIDDEN;
64extern OFHuffmanTree _Nonnull _OFHuffmanTreeNewSingle(uint16_t value)
66extern void _OFHuffmanTreeFree(OFHuffmanTree _Nonnull tree)