diff options
| -rw-r--r-- | deflate.c | 3 | ||||
| -rw-r--r-- | zlib.h | 38 |
2 files changed, 27 insertions, 14 deletions
| @@ -509,8 +509,7 @@ int ZEXPORT deflateParams(strm, level, strategy) | |||
| 509 | } | 509 | } |
| 510 | func = configuration_table[s->level].func; | 510 | func = configuration_table[s->level].func; |
| 511 | 511 | ||
| 512 | if ((strategy != s->strategy || func != configuration_table[level].func) && | 512 | if ((strategy != s->strategy || func != configuration_table[level].func)) { |
| 513 | strm->total_in != 0) { | ||
| 514 | /* Flush the last buffer: */ | 513 | /* Flush the last buffer: */ |
| 515 | err = deflate(strm, Z_BLOCK); | 514 | err = deflate(strm, Z_BLOCK); |
| 516 | if (err == Z_BUF_ERROR && s->pending == 0) | 515 | if (err == Z_BUF_ERROR && s->pending == 0) |
| @@ -670,20 +670,34 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, | |||
| 670 | int strategy)); | 670 | int strategy)); |
| 671 | /* | 671 | /* |
| 672 | Dynamically update the compression level and compression strategy. The | 672 | Dynamically update the compression level and compression strategy. The |
| 673 | interpretation of level and strategy is as in deflateInit2. This can be | 673 | interpretation of level and strategy is as in deflateInit2(). This can be |
| 674 | used to switch between compression and straight copy of the input data, or | 674 | used to switch between compression and straight copy of the input data, or |
| 675 | to switch to a different kind of input data requiring a different strategy. | 675 | to switch to a different kind of input data requiring a different strategy. |
| 676 | If the compression level is changed, the input available so far is | 676 | If the compression approach (which is a function of the level) or the |
| 677 | compressed with the old level (and may be flushed); the new level will take | 677 | strategy is changed, then the input available so far is compressed with the |
| 678 | effect only at the next call of deflate(). | 678 | old level and strategy using deflate(strm, Z_BLOCK). There are three |
| 679 | 679 | approaches for the compression levels 0, 1..3, and 4..9 respectively. The | |
| 680 | Before the call of deflateParams, the stream state must be set as for | 680 | new level and strategy will take effect at the next call of deflate(). |
| 681 | a call of deflate(), since the currently available input may have to be | 681 | |
| 682 | compressed and flushed. In particular, strm->avail_out must be non-zero. | 682 | If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does |
| 683 | 683 | not have enough output space to complete, then the parameter change will | |
| 684 | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source | 684 | take effect at an undetermined location in the uncompressed data provided so |
| 685 | stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if | 685 | far. In order to assure a change in the parameters at a specific location |
| 686 | strm->avail_out was zero. | 686 | in the uncompressed data, the deflate stream should first be flushed with |
| 687 | Z_BLOCK or another flush parameter, and deflate() called until | ||
| 688 | strm.avail_out is not zero, before the call of deflateParams(). Then no | ||
| 689 | more input data should be provided before the deflateParams() call. If this | ||
| 690 | is done, the old level and strategy will be applied to the data compressed | ||
| 691 | before deflateParams(), and the new level and strategy will be applied to | ||
| 692 | the the data compressed after deflateParams(). | ||
| 693 | |||
| 694 | deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source stream | ||
| 695 | state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if | ||
| 696 | there was not enough output space to complete the compression before the | ||
| 697 | parameters were changed. Note that in the case of a Z_BUF_ERROR, the | ||
| 698 | parameters are changed nevertheless, and will take effect at an undetermined | ||
| 699 | location in the previously supplied uncompressed data. Compression may | ||
| 700 | proceed after a Z_BUF_ERROR. | ||
| 687 | */ | 701 | */ |
| 688 | 702 | ||
| 689 | ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, | 703 | ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, |
