goat3d

diff libs/openctm/liblzma/LzHash.h @ 14:188c697b3b49

- added a document describing the goat3d file format chunk hierarchy - started an alternative XML-based file format - added the openctm library
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Sep 2013 04:47:05 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/openctm/liblzma/LzHash.h	Thu Sep 26 04:47:05 2013 +0300
     1.3 @@ -0,0 +1,54 @@
     1.4 +/* LzHash.h -- HASH functions for LZ algorithms
     1.5 +2008-10-04 : Igor Pavlov : Public domain */
     1.6 +
     1.7 +#ifndef __LZHASH_H
     1.8 +#define __LZHASH_H
     1.9 +
    1.10 +#define kHash2Size (1 << 10)
    1.11 +#define kHash3Size (1 << 16)
    1.12 +#define kHash4Size (1 << 20)
    1.13 +
    1.14 +#define kFix3HashSize (kHash2Size)
    1.15 +#define kFix4HashSize (kHash2Size + kHash3Size)
    1.16 +#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
    1.17 +
    1.18 +#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
    1.19 +
    1.20 +#define HASH3_CALC { \
    1.21 +  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
    1.22 +  hash2Value = temp & (kHash2Size - 1); \
    1.23 +  hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
    1.24 +
    1.25 +#define HASH4_CALC { \
    1.26 +  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
    1.27 +  hash2Value = temp & (kHash2Size - 1); \
    1.28 +  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
    1.29 +  hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
    1.30 +
    1.31 +#define HASH5_CALC { \
    1.32 +  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
    1.33 +  hash2Value = temp & (kHash2Size - 1); \
    1.34 +  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
    1.35 +  hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)); \
    1.36 +  hashValue = (hash4Value ^ (p->crc[cur[4]] << 3)) & p->hashMask; \
    1.37 +  hash4Value &= (kHash4Size - 1); }
    1.38 +
    1.39 +/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
    1.40 +#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
    1.41 +
    1.42 +
    1.43 +#define MT_HASH2_CALC \
    1.44 +  hash2Value = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
    1.45 +
    1.46 +#define MT_HASH3_CALC { \
    1.47 +  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
    1.48 +  hash2Value = temp & (kHash2Size - 1); \
    1.49 +  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
    1.50 +
    1.51 +#define MT_HASH4_CALC { \
    1.52 +  UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
    1.53 +  hash2Value = temp & (kHash2Size - 1); \
    1.54 +  hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
    1.55 +  hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
    1.56 +
    1.57 +#endif