
Код: Выделить всё
// Permute bytes: 1<->4, 2<->3 (i.e. little-endian<->big-endian for DWORD)
//
inline DWORD invert(DWORD x)
{
return x<<24|x>>24|(x<<8 & 0xFF0000)|(x>>8 & 0xFF00);
}
// Read bits (cnt <= 16) from an array
//
inline short readbits(unsigned char *p, short from, short cnt)
{
return invert(*(DWORD*)(p+(from/8))) << from%8 >> (32-cnt);
}