flate

deflate implementation
git clone git://git.suckless.org/flate
Log | Files | Refs | README

commit 0415ad28bd842b0ed4e5f081d73669ceb5e254dd
parent 2dd25d387a3157e6e09d56db17ddc2a27b6d757e
Author: nsz <nszabolcs@gmail.com>
Date:   Sun, 26 Jul 2009 19:28:58 +0200

deflate_simple update
Diffstat:
Makefile | 4++--
README | 10++++++----
deflate_simple.c | 10++--------
3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ -#CFLAGS=-g -Wall -ansi -pedantic -CFLAGS=-O3 -Wall -ansi -pedantic +CFLAGS=-g -Wall -ansi -pedantic +#CFLAGS=-O3 -Wall -ansi -pedantic LDFLAGS= SRC=inflate.c inflate_simple.c inflate_callback.c deflate.c deflate_simple.c OBJ=${SRC:.c=.o} diff --git a/README b/README @@ -2,15 +2,17 @@ minimal deflate implementation based on: rfc1951 from ietf - tinf from ibsensoftware - libflate from plan 9 zlib puff from zlib gzip - halibut/deflate from putty + tinf from ibsensoftware + libflate from plan 9 + deflate from halibut + sshzlib from putty build: make features: - decode raw deflate compressed data + inflate: decode raw deflate compressed data + deflate: raw deflate compression diff --git a/deflate_simple.c b/deflate_simple.c @@ -8,7 +8,7 @@ enum { MinMatch = 3, MaxMatch = 258, BigDist = 1 << 12, - MaxChainStep = 64, + MaxChainStep = 128, HashBits = 13, HashSize = 1 << HashBits, WinSize = 1 << 15, @@ -309,7 +309,6 @@ static void deflate_block(State *s, int blocklen) { int dynsize, fixsize, uncsize; int *pn; uchar *pc; -/*int dyntree;*/ /* calc dynamic codes */ hufflens(llen, s->lfreq, Nlitlen, CodeBits-1); @@ -340,7 +339,6 @@ static void deflate_block(State *s, int blocklen) { if (c == 18) dynsize += 7; } -/*dyntree = dynsize - 3;*/ for (pn = s->rbuf, pc = s->src; pn != s->rend;) { n = *pn++; if (n & RunlenFlag) { @@ -401,10 +399,6 @@ static void deflate_block(State *s, int blocklen) { memcpy(s->dst, s->src, blocklen); s->dst += blocklen; } -/* -fprintf(stderr, "blocklen: %d lzlen: %d dynsize: %d (tree: %d, rate: %.3f) fixsize: %d (rate: %.3f) uncsize: %d (rate: %.3f)\n", blocklen, s->rend - s->rbuf, - dynsize, dyntree, dynsize/(float)blocklen, fixsize, fixsize/(float)blocklen, uncsize, uncsize/(float)blocklen); -*/ } static int bisect(ushort *base, int len, int n) { @@ -442,7 +436,7 @@ static void recordlit(State *s, int c) { s->lfreq[c]++; } -/* 32 bit multiplicative hash */ +/* multiplicative hash */ static uint gethash(uchar *p) { return 0x9e3779b1 * ((p[0]<<16) + (p[1]<<8) + p[2]) >> (32 - HashBits); }