| Index: src/utils.h
|
| diff --git a/src/utils.h b/src/utils.h
|
| index b16730b8c46d750c1e264ad07713868c2b32d804..5680384196d2c870cd519f420d34bb84337fb881 100644
|
| --- a/src/utils.h
|
| +++ b/src/utils.h
|
| @@ -86,6 +86,25 @@ inline int WhichPowerOf2(uint32_t x) {
|
| }
|
|
|
|
|
| +inline int MostSignificantBit(uint32_t x) {
|
| + static const int msb4[] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4};
|
| + int nibble = 0;
|
| + if (x & 0xffff0000) {
|
| + nibble += 16;
|
| + x >>= 16;
|
| + }
|
| + if (x & 0xff00) {
|
| + nibble += 8;
|
| + x >>= 8;
|
| + }
|
| + if (x & 0xf0) {
|
| + nibble += 4;
|
| + x >>= 4;
|
| + }
|
| + return nibble + msb4[x];
|
| +}
|
| +
|
| +
|
| // Magic numbers for integer division.
|
| // These are kind of 2's complement reciprocal of the divisors.
|
| // Details and proofs can be found in:
|
|
|