mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-15 21:39:59 +02:00
Remove ReadOneBit() and ReadSymbolUnsafe()
Simplify and re-organize the VP8L bit-reader functions (e.g.: the 40-bit look-ahead code was helping much) Speed-up with LBITS=64, on arm7-a: => before: ./dwebp_justify_24_neon -v bryce_ll.webp Time to decode picture: 11.393s File bryce_ll.webp can be decoded (dimensions: 11158 x 2156). ... => after (LBITS=64): Time to decode picture: 9.953s making the VP8L bit-reader in 32 bit mode is going to be harder (because we need to be able to read two symbols at a time, each with max length 15 bits) Change-Id: I89746fb103b87b5e2fd40a3208a6fbc584b88297
This commit is contained in:
@ -149,29 +149,21 @@ static WEBP_INLINE int PlaneCodeToDistance(int xsize, int plane_code) {
|
||||
//------------------------------------------------------------------------------
|
||||
// Decodes the next Huffman code from bit-stream.
|
||||
// FillBitWindow(br) needs to be called at minimum every second call
|
||||
// to ReadSymbolUnsafe.
|
||||
static int ReadSymbolUnsafe(const HuffmanTree* tree, VP8LBitReader* const br) {
|
||||
const HuffmanTreeNode* node = tree->root_;
|
||||
assert(node != NULL);
|
||||
while (!HuffmanTreeNodeIsLeaf(node)) {
|
||||
node = HuffmanTreeNextNode(node, VP8LReadOneBitUnsafe(br));
|
||||
}
|
||||
return node->symbol_;
|
||||
}
|
||||
|
||||
// to ReadSymbol, in order to pre-fetch enough bits.
|
||||
static WEBP_INLINE int ReadSymbol(const HuffmanTree* tree,
|
||||
VP8LBitReader* const br) {
|
||||
const int read_safe = (br->pos_ + 8 > br->len_);
|
||||
if (!read_safe) {
|
||||
return ReadSymbolUnsafe(tree, br);
|
||||
} else {
|
||||
const HuffmanTreeNode* node = tree->root_;
|
||||
assert(node != NULL);
|
||||
while (!HuffmanTreeNodeIsLeaf(node)) {
|
||||
node = HuffmanTreeNextNode(node, VP8LReadOneBit(br));
|
||||
}
|
||||
return node->symbol_;
|
||||
const HuffmanTreeNode* node = tree->root_;
|
||||
int num_bits = 0;
|
||||
uint32_t bits;
|
||||
bits = VP8LPrefetchBits(br);
|
||||
assert(node != NULL);
|
||||
while (!HuffmanTreeNodeIsLeaf(node)) {
|
||||
node = HuffmanTreeNextNode(node, bits & 1);
|
||||
bits >>= 1;
|
||||
++num_bits;
|
||||
}
|
||||
VP8LDiscardBits(br, num_bits);
|
||||
return node->symbol_;
|
||||
}
|
||||
|
||||
static int ReadHuffmanCodeLengths(
|
||||
|
Reference in New Issue
Block a user