mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 15:32:53 +01:00
ARM: speed up bitreader by avoiding tables
(and using BitsLog2Floor() from utils.h instead) 9-10% speed-up, apparently Change-Id: I9acae4a4dceb1ddcc99306f99b722079bb06f6f8
This commit is contained in:
parent
1dc82a6bba
commit
a345068aba
@ -116,31 +116,19 @@ static WEBP_INLINE int VP8GetBit(VP8BitReader* const br, int prob) {
|
||||
const int pos = br->bits_;
|
||||
const range_t split = (range * prob) >> 8;
|
||||
const range_t value = (range_t)(br->value_ >> pos);
|
||||
#if defined(__arm__) || defined(_M_ARM) // ARM-specific
|
||||
const int bit = ((int)(split - value) >> 31) & 1;
|
||||
if (value > split) {
|
||||
range -= split + 1;
|
||||
const int bit = (value > split);
|
||||
if (bit) {
|
||||
range -= split;
|
||||
br->value_ -= (bit_t)(split + 1) << pos;
|
||||
} else {
|
||||
range = split;
|
||||
range = split + 1;
|
||||
}
|
||||
#else // faster version on x86
|
||||
int bit; // Don't use 'const int bit = (value > split);", it's slower.
|
||||
if (value > split) {
|
||||
range -= split + 1;
|
||||
br->value_ -= (bit_t)(split + 1) << pos;
|
||||
bit = 1;
|
||||
} else {
|
||||
range = split;
|
||||
bit = 0;
|
||||
}
|
||||
#endif
|
||||
if (range <= (range_t)0x7e) {
|
||||
const int shift = kVP8Log2Range[range];
|
||||
range = kVP8NewRange[range];
|
||||
{
|
||||
const int shift = 7 ^ BitsLog2Floor(range);
|
||||
range <<= shift;
|
||||
br->bits_ -= shift;
|
||||
}
|
||||
br->range_ = range;
|
||||
br->range_ = range - 1;
|
||||
return bit;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user