mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 13:59:51 +02:00
~20% faster lossless decoding
We use help from small LUTs for Huffman decoding. Change-Id: I58db4ecd37282822094519f2aa14cf544beba975
This commit is contained in:
@ -158,6 +158,14 @@ static WEBP_INLINE int ReadSymbol(const HuffmanTree* tree,
|
||||
const HuffmanTreeNode* node = tree->root_;
|
||||
uint32_t bits = VP8LPrefetchBits(br);
|
||||
int bitpos = br->bit_pos_;
|
||||
// Check if we find the bit combination from the Huffman lookup table.
|
||||
const int lut_ix = bits & (HUFF_LUT - 1);
|
||||
const int lut_bits = tree->lut_bits_[lut_ix];
|
||||
if (lut_bits <= HUFF_LUT_BITS) {
|
||||
VP8LSetBitPos(br, bitpos + lut_bits);
|
||||
return tree->lut_symbol_[lut_ix];
|
||||
}
|
||||
// Decode the value from a binary tree.
|
||||
assert(node != NULL);
|
||||
while (HuffmanTreeNodeIsNotLeaf(node)) {
|
||||
node = HuffmanTreeNextNode(node, bits & 1);
|
||||
|
Reference in New Issue
Block a user