uint8 bitinverse(uint8 x)
{
x = (x >> 4) | (x << 4);
x = (x >> 2 & 0x33) | (x << 2 & 0xcc);
x = (x >> 1 & 0x55) | (x << 1 & 0xaa);
return x;
}
uint16 bit16inverse(uint16 x)
{
x = (x >> 8) | (x << 8);
x = (x >> 4 & 0x0F0F) | (x << 4 & 0xF0F0);
x = (x >> 2 & 0x3333) | (x << 2 & 0xCCCC);
x = (x >> 1 & 0x5555) | (x << 1 & 0xAAAA);
return x;
}
uint32 bit32inverse(uint32 x)
{
x = (x >> 16) | (x << 16);
x = ((x >> 8) & 0x00FF00FF) | ((x << 8) & 0xFF00FF00);
x = ((x >> 4) & 0x0F0F0F0F) | ((x << 4) & 0xF0F0F0F0);
x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xCCCCCCCC);
x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xAAAAAAAA);
return x;
}
|