diff options
Diffstat (limited to 'src/zopfli/lz77.h')
-rw-r--r-- | src/zopfli/lz77.h | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/src/zopfli/lz77.h b/src/zopfli/lz77.h index 55186a7..dc8597a 100644 --- a/src/zopfli/lz77.h +++ b/src/zopfli/lz77.h @@ -46,13 +46,37 @@ typedef struct ZopfliLZ77Store { unsigned short* dists; /* If 0: indicates literal in corresponding litlens, if > 0: length in corresponding litlens, this is the distance. */ size_t size; + + const unsigned char* data; /* original data */ + size_t* pos; /* position in data where this LZ77 command begins */ + + unsigned short* ll_symbol; + unsigned short* d_symbol; + + /* Cumulative histograms wrapping around per chunk. Each chunk has the amount + of distinct symbols as length, so using 1 value per LZ77 symbol, we have a + precise histogram at every N symbols, and the rest can be calculated by + looping through the actual symbols of this chunk. */ + size_t* ll_counts; + size_t* d_counts; } ZopfliLZ77Store; -void ZopfliInitLZ77Store(ZopfliLZ77Store* store); +void ZopfliInitLZ77Store(const unsigned char* data, ZopfliLZ77Store* store); void ZopfliCleanLZ77Store(ZopfliLZ77Store* store); void ZopfliCopyLZ77Store(const ZopfliLZ77Store* source, ZopfliLZ77Store* dest); void ZopfliStoreLitLenDist(unsigned short length, unsigned short dist, - ZopfliLZ77Store* store); + size_t pos, ZopfliLZ77Store* store); +void ZopfliAppendLZ77Store(const ZopfliLZ77Store* store, + ZopfliLZ77Store* target); +/* Gets the amount of raw bytes that this range of LZ77 symbols spans. */ +size_t ZopfliLZ77GetByteRange(const ZopfliLZ77Store* lz77, + size_t lstart, size_t lend); +/* Gets the histogram of lit/len and dist symbols in the given range, using the +cumulative histograms, so faster than adding one by one for large range. Does +not add the one end symbol of value 256. */ +void ZopfliLZ77GetHistogram(const ZopfliLZ77Store* lz77, + size_t lstart, size_t lend, + size_t* ll_counts, size_t* d_counts); /* Some state information for compressing a block. @@ -72,6 +96,11 @@ typedef struct ZopfliBlockState { size_t blockend; } ZopfliBlockState; +void ZopfliInitBlockState(const ZopfliOptions* options, + size_t blockstart, size_t blockend, int add_lmc, + ZopfliBlockState* s); +void ZopfliCleanBlockState(ZopfliBlockState* s); + /* Finds the longest match (length and corresponding distance) for LZ77 compression. @@ -100,22 +129,6 @@ void ZopfliVerifyLenDist(const unsigned char* data, size_t datasize, size_t pos, unsigned short dist, unsigned short length); /* -Counts the number of literal, length and distance symbols in the given lz77 -arrays. -litlens: lz77 lit/lengths -dists: ll77 distances -start: where to begin counting in litlens and dists -end: where to stop counting in litlens and dists (not inclusive) -ll_count: count of each lit/len symbol, must have size 288 (see deflate - standard) -d_count: count of each dist symbol, must have size 32 (see deflate standard) -*/ -void ZopfliLZ77Counts(const unsigned short* litlens, - const unsigned short* dists, - size_t start, size_t end, - size_t* ll_count, size_t* d_count); - -/* Does LZ77 using an algorithm similar to gzip, with lazy matching, rather than with the slow but better "squeeze" implementation. The result is placed in the ZopfliLZ77Store. @@ -124,6 +137,6 @@ dictionary. */ void ZopfliLZ77Greedy(ZopfliBlockState* s, const unsigned char* in, size_t instart, size_t inend, - ZopfliLZ77Store* store); + ZopfliLZ77Store* store, ZopfliHash* h); #endif /* ZOPFLI_LZ77_H_ */ |