~20% faster lossless decoding

We use help from small LUTs for Huffman decoding.

Change-Id: I58db4ecd37282822094519f2aa14cf544beba975
This commit is contained in:
skal
2013-06-20 09:41:29 +02:00
parent 313d853fa9
commit 24cc307ae3
3 changed files with 36 additions and 0 deletions

View File

@ -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);