mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.dev
git-svn-id: svn://ultimatepp.org/upp/trunk@7818 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b4ba7da728
commit
ee020ca24f
10 changed files with 615 additions and 14 deletions
52
uppdev/NibblePtr/lzf.cpp
Normal file
52
uppdev/NibblePtr/lzf.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#include "Entropy.h"
|
||||
|
||||
// Test/Test FooFoo
|
||||
|
||||
String LZFCompress(const char *s, int length)
|
||||
{
|
||||
String result;
|
||||
|
||||
const char *end = s + length;
|
||||
|
||||
const char *hash_table[8192];
|
||||
|
||||
for(int i = 0; i < 8192; i++)
|
||||
hash_table[i] = s;
|
||||
|
||||
char *lit = s;
|
||||
int litlen = min(length, 4);
|
||||
s += 4;
|
||||
|
||||
for(;;) {
|
||||
char *hptr;
|
||||
for(;;) {
|
||||
hash = (2654435761U * Peek32le(s)) & 8191;
|
||||
|
||||
hptr = hash_table[hash];
|
||||
|
||||
if(s - hptr < 65536 && Peek32le(hash_table[hash]) == Peek32le(s))
|
||||
break;
|
||||
litlen++;
|
||||
hash_table[(2654435761U * Peek32le(s - 3)) & 8191] = s - 3;
|
||||
s++;
|
||||
if(s >= end)
|
||||
return;
|
||||
}
|
||||
|
||||
int matchlen = 4;
|
||||
while(hptr + matchlen < s && s[matchlen] == hptr[matchlen])
|
||||
matchlen++;
|
||||
|
||||
LOGHEXDUMP(lit, litlen);
|
||||
LOGHEXDUMP(hptr, matchlen);
|
||||
|
||||
const char *e = s + matchlen;
|
||||
while(s < e) {
|
||||
hash_table[(2654435761U * Peek32le(s - 3)) & 8191] = s - 3;
|
||||
s++;
|
||||
}
|
||||
|
||||
lit = s;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue