aboutsummaryrefslogtreecommitdiff
path: root/zlib.h
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-12-07 23:57:37 -0800
committerMark Adler <madler@alumni.caltech.edu>2011-12-08 00:13:52 -0800
commitafe7cf78d51b819dcdc5b0f4cb85a25a52a9fcd0 (patch)
tree24c9db96071504cd7beb1d1800dbb265c736070f /zlib.h
parentfbac04f666339eef3678e4eb81b25ae69bfcbd81 (diff)
downloadzlib-afe7cf78d51b819dcdc5b0f4cb85a25a52a9fcd0.tar.gz
zlib-afe7cf78d51b819dcdc5b0f4cb85a25a52a9fcd0.tar.bz2
zlib-afe7cf78d51b819dcdc5b0f4cb85a25a52a9fcd0.zip
Enable dictionary setting in middle of stream, and keeping the dictionary.
This patch adds the deflateResetKeep() function to retain the sliding window for the next deflate operation, and fixes an inflateResetKeep() problem that came from inflate() not updating the window when the stream completed. This enables constructing and decompressing a series of concatenated deflate streams where each can depend on the history of uncompressed data that precedes it. This generalizes deflateSetDictionary() and inflateSetDictionary() to permit setting the dictionary in the middle of a stream for raw deflate and inflate. This in combination with the Keep functions enables a scheme for updating files block by block with the transmission of compressed data, where blocks are sent with deflateResetKeep() to retain history for better compression, and deflateSetDictionary() is used for blocks already present at the receiver to skip compression but insert that data in the history, again for better compression. The corresponding inflate calls are done on the receiver side.
Diffstat (limited to 'zlib.h')
-rw-r--r--zlib.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/zlib.h b/zlib.h
index 3121b0a..3669f2e 100644
--- a/zlib.h
+++ b/zlib.h
@@ -581,10 +581,15 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
581 uInt dictLength)); 581 uInt dictLength));
582/* 582/*
583 Initializes the compression dictionary from the given byte sequence 583 Initializes the compression dictionary from the given byte sequence
584 without producing any compressed output. This function must be called 584 without producing any compressed output. When using the zlib format, this
585 immediately after deflateInit, deflateInit2 or deflateReset, before any call 585 function must be called immediately after deflateInit, deflateInit2 or
586 of deflate. The compressor and decompressor must use exactly the same 586 deflateReset, and before any call of deflate. When doing raw deflate, this
587 dictionary (see inflateSetDictionary). 587 function must be called either before any call of deflate, or immediately
588 after the completion of a deflate block, i.e. after all input has been
589 consumed and all output has been delivered when using any of the flush
590 options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
591 compressor and decompressor must use exactly the same dictionary (see
592 inflateSetDictionary).
588 593
589 The dictionary should consist of strings (byte sequences) that are likely 594 The dictionary should consist of strings (byte sequences) that are likely
590 to be encountered later in the data to be compressed, with the most commonly 595 to be encountered later in the data to be compressed, with the most commonly
@@ -611,8 +616,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
611 deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a 616 deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
612 parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is 617 parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
613 inconsistent (for example if deflate has already been called for this stream 618 inconsistent (for example if deflate has already been called for this stream
614 or if the compression method is bsort). deflateSetDictionary does not 619 or if not at a block boundary for raw deflate). deflateSetDictionary does
615 perform any compression: this will be done by deflate(). 620 not perform any compression: this will be done by deflate().
616*/ 621*/
617 622
618ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, 623ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
@@ -810,10 +815,11 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
810 if that call returned Z_NEED_DICT. The dictionary chosen by the compressor 815 if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
811 can be determined from the adler32 value returned by that call of inflate. 816 can be determined from the adler32 value returned by that call of inflate.
812 The compressor and decompressor must use exactly the same dictionary (see 817 The compressor and decompressor must use exactly the same dictionary (see
813 deflateSetDictionary). For raw inflate, this function can be called 818 deflateSetDictionary). For raw inflate, this function can be called at any
814 immediately after inflateInit2() or inflateReset() and before any call of 819 time to set the dictionary. If the provided dictionary is smaller than the
815 inflate() to set the dictionary. The application must insure that the 820 window and there is already data in the window, then the provided dictionary
816 dictionary that was used for compression is provided. 821 will amend what's there. The application must insure that the dictionary
822 that was used for compression is provided.
817 823
818 inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a 824 inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
819 parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is 825 parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
@@ -1694,6 +1700,7 @@ ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
1694ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); 1700ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
1695ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); 1701ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
1696ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); 1702ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
1703ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
1697#ifndef Z_SOLO 1704#ifndef Z_SOLO
1698 ZEXTERN unsigned long ZEXPORT gzflags OF((void)); 1705 ZEXTERN unsigned long ZEXPORT gzflags OF((void));
1699#endif 1706#endif