goat3d
annotate libs/openctm/liblzma/LzHash.h @ 54:dad392c710df
added copyright headers and license files + readme
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 17 Apr 2014 08:50:36 +0300 |
parents | |
children |
rev | line source |
---|---|
nuclear@14 | 1 /* LzHash.h -- HASH functions for LZ algorithms |
nuclear@14 | 2 2008-10-04 : Igor Pavlov : Public domain */ |
nuclear@14 | 3 |
nuclear@14 | 4 #ifndef __LZHASH_H |
nuclear@14 | 5 #define __LZHASH_H |
nuclear@14 | 6 |
nuclear@14 | 7 #define kHash2Size (1 << 10) |
nuclear@14 | 8 #define kHash3Size (1 << 16) |
nuclear@14 | 9 #define kHash4Size (1 << 20) |
nuclear@14 | 10 |
nuclear@14 | 11 #define kFix3HashSize (kHash2Size) |
nuclear@14 | 12 #define kFix4HashSize (kHash2Size + kHash3Size) |
nuclear@14 | 13 #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size) |
nuclear@14 | 14 |
nuclear@14 | 15 #define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8); |
nuclear@14 | 16 |
nuclear@14 | 17 #define HASH3_CALC { \ |
nuclear@14 | 18 UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ |
nuclear@14 | 19 hash2Value = temp & (kHash2Size - 1); \ |
nuclear@14 | 20 hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; } |
nuclear@14 | 21 |
nuclear@14 | 22 #define HASH4_CALC { \ |
nuclear@14 | 23 UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ |
nuclear@14 | 24 hash2Value = temp & (kHash2Size - 1); \ |
nuclear@14 | 25 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ |
nuclear@14 | 26 hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; } |
nuclear@14 | 27 |
nuclear@14 | 28 #define HASH5_CALC { \ |
nuclear@14 | 29 UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ |
nuclear@14 | 30 hash2Value = temp & (kHash2Size - 1); \ |
nuclear@14 | 31 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ |
nuclear@14 | 32 hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \ |
nuclear@14 | 33 hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \ |
nuclear@14 | 34 hash4Value &= (kHash4Size - 1); } |
nuclear@14 | 35 |
nuclear@14 | 36 /* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */ |
nuclear@14 | 37 #define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF; |
nuclear@14 | 38 |
nuclear@14 | 39 |
nuclear@14 | 40 #define MT_HASH2_CALC \ |
nuclear@14 | 41 hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1); |
nuclear@14 | 42 |
nuclear@14 | 43 #define MT_HASH3_CALC { \ |
nuclear@14 | 44 UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ |
nuclear@14 | 45 hash2Value = temp & (kHash2Size - 1); \ |
nuclear@14 | 46 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); } |
nuclear@14 | 47 |
nuclear@14 | 48 #define MT_HASH4_CALC { \ |
nuclear@14 | 49 UInt32 temp = p->crc[cur[0]] ^ cur[1]; \ |
nuclear@14 | 50 hash2Value = temp & (kHash2Size - 1); \ |
nuclear@14 | 51 hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \ |
nuclear@14 | 52 hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); } |
nuclear@14 | 53 |
nuclear@14 | 54 #endif |