3 #define CRC32_POLYNOMIAL 0x04C11DB7
6 unsigned int CRCTable[ 256 * 4];
8 unsigned int CRCTable[ 256 ];
11 u32 Reflect( u32 ref, char ch )
15 // Swap bit 0 for bit 7
16 // bit 1 for bit 6, etc.
17 for (int i = 1; i < (ch + 1); i++)
20 value |= 1 << (ch - i);
30 for (int i = 0; i < 256; i++)
32 crc = Reflect( i, 8 ) << 24;
33 for (int j = 0; j < 8; j++)
34 crc = (crc << 1) ^ (crc & (1 << 31) ? CRC32_POLYNOMIAL : 0);
36 CRCTable[i] = Reflect( crc, 32 );
40 for (int i = 0; i < 256; i++)
42 for(int j = 0; j < 3; j++)
44 CRCTable[256*(j+1) + i] = (CRCTable[256*j + i]>>8) ^ CRCTable[CRCTable[256*j + i]&0xFF];
51 u32 CRC_Calculate( u32 crc, void *buffer, u32 count )
61 crc ^= *(unsigned int*) p; p += 4;
62 crc = CRCTable[3*256 + (crc&0xFF)]
63 ^ CRCTable[2*256 + ((crc>>8)&0xFF)]
64 ^ CRCTable[1*256 + ((crc>>16)&0xFF)]
65 ^ CRCTable[0*256 + ((crc>>24))];
72 crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
77 u32 CRC_CalculatePalette( u32 crc, void *buffer, u32 count )
85 crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
86 crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];