36template <
typename CodeTag>
49 template <
typename BIT_STREAM>
57 const auto* top = &(
tree.root->getAsBranch());
59 auto walkBinaryTree = [&partial, &top](
bool bit)
60 ->
Optional<std::pair<typename Base::CodeSymbol, int /*codeValue*/>> {
66 const auto& newNode = top->buds[bit];
70 ThrowRDE(
"bad Huffman code: %u (len: %u)", partial.code,
74 if (
static_cast<typename decltype(
tree)::Node::Type
>(*newNode) ==
75 decltype(
tree)::Node::Type::Leaf) {
77 return {{partial, newNode->getAsLeaf().value}};
81 top = &(newNode->getAsBranch());
86 for (
unsigned bit : initialPartial.getBitsMSB()) {
87 if (
auto sym = walkBinaryTree(bit))
93 invariant(partial.code_len <= Traits::MaxCodeLenghtBits);
96 const bool bit = bs.getBitsNoFill(1);
98 if (
auto sym = walkBinaryTree(bit))
103 __builtin_unreachable();
106 template <
typename BIT_STREAM>
111 "This BitStreamer specialization is not marked as usable here");
115 partial.code_len = 0;
122 void setup(
bool fullDecode_,
bool fixDNGBug16_) {
126 for (
unsigned codeIndex = 0; codeIndex !=
Base::code.symbols.size();
131 template <
typename BIT_STREAM>
135 "This BitStreamer specialization is not marked as usable here");
143 "This BitStreamer specialization is not marked as usable here");
152 template <
typename BIT_STREAM,
bool FULL_DECODE>
156 "This BitStreamer specialization is not marked as usable here");
162 typename Traits::CodeValueTy codeValue;
assert(dim.area() >=area)
int processSymbol(BIT_STREAM &bs, CodeSymbol symbol, typename Traits::CodeValueTy codeValue) const
typename Base::Traits Traits
AbstractPrefixCodeTranscoder< CodeTag > Base
typename Base::CodeSymbol CodeSymbol
bool RAWSPEED_READONLY isFullDecode() const
PrefixCode< CodeTag > code
void setup(bool fullDecode_, bool fixDNGBug16_)
Traits::CodeValueTy decodeCodeValue(BIT_STREAM &bs) const
int decodeDifference(BIT_STREAM &bs) const
BinaryPrefixTree< CodeTag > tree
void setup(bool fullDecode_, bool fixDNGBug16_)
std::pair< typename Base::CodeSymbol, int > readSymbol(BIT_STREAM &bs) const
int decode(BIT_STREAM &bs) const
typename Base::Traits Traits
AbstractPrefixCodeDecoder< CodeTag > Base
std::pair< typename Base::CodeSymbol, int > finishReadingPartialSymbol(BIT_STREAM &bs, typename Base::CodeSymbol initialPartial) const