MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__bitcount

Function stbi__bitcount

lite/example/cpp_example/mge/cv/stb_image.h:5932–5939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5930}
5931
5932static 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

Callers 1

stbi__bmp_loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected