returns 0..31 for the highest set bit
| 5365 | |
| 5366 | // returns 0..31 for the highest set bit |
| 5367 | static int stbi__high_bit(unsigned int z) |
| 5368 | { |
| 5369 | int n=0; |
| 5370 | if (z == 0) return -1; |
| 5371 | if (z >= 0x10000) { n += 16; z >>= 16; } |
| 5372 | if (z >= 0x00100) { n += 8; z >>= 8; } |
| 5373 | if (z >= 0x00010) { n += 4; z >>= 4; } |
| 5374 | if (z >= 0x00004) { n += 2; z >>= 2; } |
| 5375 | if (z >= 0x00002) { n += 1;/* >>= 1;*/ } |
| 5376 | return n; |
| 5377 | } |
| 5378 | |
| 5379 | static int stbi__bitcount(unsigned int a) |
| 5380 | { |