1 /* LzHash.h */ |
|
2 |
|
3 #ifndef __C_LZHASH_H |
|
4 #define __C_LZHASH_H |
|
5 |
|
6 #define kHash2Size (1 << 10) |
|
7 #define kHash3Size (1 << 16) |
|
8 #define kHash4Size (1 << 20) |
|
9 |
|
10 #define kFix3HashSize (kHash2Size) |
|
11 #define kFix4HashSize (kHash2Size + kHash3Size) |
|
12 #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) |
|
13 |
|
14 #define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); |
|
15 |
|
16 #define HASH3_CALC { \ |
|
17 UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \ |
|
18 hash2Value = temp & (kHash2Size - 1); \ |
|
19 hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } |
|
20 |
|
21 #define HASH4_CALC { \ |
|
22 UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \ |
|
23 hash2Value = temp & (kHash2Size - 1); \ |
|
24 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ |
|
25 hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (g_CrcTable[cur[3]] << 5)) & p->hashMask; } |
|
26 |
|
27 #define HASH5_CALC { \ |
|
28 UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \ |
|
29 hash2Value = temp & (kHash2Size - 1); \ |
|
30 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ |
|
31 hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (g_CrcTable[cur[3]] << 5)); \ |
|
32 hashValue = (hash4Value ^ (g_CrcTable[cur[4]] << 3)) & p->hashMask; \ |
|
33 hash4Value &= (kHash4Size - 1); } |
|
34 |
|
35 /* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ g_CrcTable[cur[2]]) & 0xFFFF; */ |
|
36 #define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ g_CrcTable[cur[1]]) & 0xFFFF; |
|
37 |
|
38 |
|
39 #define MT_HASH2_CALC \ |
|
40 hash2Value = (g_CrcTable[cur[0]] ^ cur[1]) & (kHash2Size - 1); |
|
41 |
|
42 #define MT_HASH3_CALC { \ |
|
43 UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \ |
|
44 hash2Value = temp & (kHash2Size - 1); \ |
|
45 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } |
|
46 |
|
47 #define MT_HASH4_CALC { \ |
|
48 UInt32 temp = g_CrcTable[cur[0]] ^ cur[1]; \ |
|
49 hash2Value = temp & (kHash2Size - 1); \ |
|
50 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ |
|
51 hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (g_CrcTable[cur[3]] << 5)) & (kHash4Size - 1); } |
|
52 |
|
53 #endif |
|