64,678
社区成员
发帖
与我相关
我的任务
分享
/*
00480 ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
00481 int level,
00482 int method,
00483 int windowBits,
00484 int memLevel,
00485 int strategy));
00486
00487 This is another version of deflateInit with more compression options. The
00488 fields next_in, zalloc, zfree and opaque must be initialized before by
00489 the caller.
00490
00491 The method parameter is the compression method. It must be Z_DEFLATED in
00492 this version of the library.
00493
00494 The windowBits parameter is the base two logarithm of the window size
00495 (the size of the history buffer). It should be in the range 8..15 for this
00496 version of the library. Larger values of this parameter result in better
00497 compression at the expense of memory usage. The default value is 15 if
00498 deflateInit is used instead.
00499
00500 windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
00501 determines the window size. deflate() will then generate raw deflate data
00502 with no zlib header or trailer, and will not compute an adler32 check value.
00503
00504 windowBits can also be greater than 15 for optional gzip encoding. Add
00505 16 to windowBits to write a simple gzip header and trailer around the
00506 compressed data instead of a zlib wrapper. The gzip header will have no
00507 file name, no extra data, no comment, no modification time (set to zero),
00508 no header crc, and the operating system will be set to 255 (unknown). If a
00509 gzip stream is being written, strm->adler is a crc32 instead of an adler32.
00510
00511 The memLevel parameter specifies how much memory should be allocated
00512 for the internal compression state. memLevel=1 uses minimum memory but
00513 is slow and reduces compression ratio; memLevel=9 uses maximum memory
00514 for optimal speed. The default value is 8. See zconf.h for total memory
00515 usage as a function of windowBits and memLevel.
00516
00517 The strategy parameter is used to tune the compression algorithm. Use the
00518 value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
00519 filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
00520 string match), or Z_RLE to limit match distances to one (run-length
00521 encoding). Filtered data consists mostly of small values with a somewhat
00522 random distribution. In this case, the compression algorithm is tuned to
00523 compress them better. The effect of Z_FILTERED is to force more Huffman
00524 coding and less string matching; it is somewhat intermediate between
00525 Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
00526 Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
00527 parameter only affects the compression ratio but not the correctness of the
00528 compressed output even if it is not set appropriately. Z_FIXED prevents the
00529 use of dynamic Huffman codes, allowing for a simpler decoder for special
00530 applications.
00531
00532 deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
00533 memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
00534 method). msg is set to null if there is no error message. deflateInit2 does
00535 not perform any compression: this will be done by deflate().
00536 */