… | |
… | |
44 | * don't play with this unless you benchmark! |
44 | * don't play with this unless you benchmark! |
45 | * decompression is not dependent on the hash function |
45 | * decompression is not dependent on the hash function |
46 | * the hashing function might seem strange, just believe me |
46 | * the hashing function might seem strange, just believe me |
47 | * it works ;) |
47 | * it works ;) |
48 | */ |
48 | */ |
|
|
49 | #ifndef FRST |
49 | #define FRST(p) (((p[0]) << 8) | p[1]) |
50 | # define FRST(p) (((p[0]) << 8) | p[1]) |
50 | #define NEXT(v,p) (((v) << 8) | p[2]) |
51 | # define NEXT(v,p) (((v) << 8) | p[2]) |
51 | #define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) |
52 | # define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1)) |
|
|
53 | #endif |
52 | /* |
54 | /* |
53 | * IDX works because it is very similar to a multiplicative hash, e.g. |
55 | * IDX works because it is very similar to a multiplicative hash, e.g. |
54 | * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1)) |
56 | * ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1)) |
55 | * the latter is also quite fast on newer CPUs, and sligthly better |
57 | * the latter is also quite fast on newer CPUs, and sligthly better |
56 | * |
58 | * |
… | |
… | |
71 | |
73 | |
72 | /* |
74 | /* |
73 | * compressed format |
75 | * compressed format |
74 | * |
76 | * |
75 | * 000LLLLL <L+1> ; literal |
77 | * 000LLLLL <L+1> ; literal |
76 | * LLLOOOOO oooooooo ; backref L |
78 | * LLLooooo oooooooo ; backref L |
77 | * 111OOOOO LLLLLLLL oooooooo ; backref L+7 |
79 | * 111ooooo LLLLLLLL oooooooo ; backref L+7 |
78 | * |
80 | * |
79 | */ |
81 | */ |
80 | |
82 | |
81 | unsigned int |
83 | unsigned int |
82 | lzf_compress (const void *const in_data, unsigned int in_len, |
84 | lzf_compress (const void *const in_data, unsigned int in_len, |