MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__bitcount

Function stbi__bitcount

Source/Utils/stb_image.h:5379–5387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5377}
5378
5379static int stbi__bitcount(unsigned int a)
5380{
5381 a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2
5382 a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4
5383 a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits
5384 a = (a + (a >> 8)); // max 16 per 8 bits
5385 a = (a + (a >> 16)); // max 32 per 8 bits
5386 return a & 0xff;
5387}
5388
5389// extract an arbitrarily-aligned N-bit value (N=bits)
5390// from v, and then make it 8-bits long and fractionally

Callers 1

stbi__bmp_loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected