MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__shiftsigned

Function stbi__shiftsigned

include/stb/stb_image.h:5395–5413  ·  view source on GitHub ↗

extract an arbitrarily-aligned N-bit value (N=bits) from v, and then make it 8-bits long and fractionally extend it to full full range.

Source from the content-addressed store, hash-verified

5393// from v, and then make it 8-bits long and fractionally
5394// extend it to full full range.
5395static int stbi__shiftsigned(unsigned int v, int shift, int bits)
5396{
5397 static unsigned int mul_table[9] = {
5398 0,
5399 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/,
5400 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/,
5401 };
5402 static unsigned int shift_table[9] = {
5403 0, 0,0,1,0,2,4,6,0,
5404 };
5405 if (shift < 0)
5406 v <<= -shift;
5407 else
5408 v >>= shift;
5409 STBI_ASSERT(v < 256);
5410 v >>= (8-bits);
5411 STBI_ASSERT(bits >= 0 && bits <= 8);
5412 return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits];
5413}
5414
5415typedef struct
5416{

Callers 1

stbi__bmp_loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected