| 5930 | } |
| 5931 | |
| 5932 | static int stbi__bitcount(unsigned int a) { |
| 5933 | a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 |
| 5934 | a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 |
| 5935 | a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits |
| 5936 | a = (a + (a >> 8)); // max 16 per 8 bits |
| 5937 | a = (a + (a >> 16)); // max 32 per 8 bits |
| 5938 | return a & 0xff; |
| 5939 | } |
| 5940 | |
| 5941 | // extract an arbitrarily-aligned N-bit value (N=bits) |
| 5942 | // from v, and then make it 8-bits long and fractionally |