提交 cbbd2030 编写于 作者: M Mark Adler

Permit immediate deflateParams changes before any deflate input.

This permits deflateParams to change the strategy and level right
after deflateInit, without having to wait until a header has been
written. The parameters can be changed immediately up until the
first deflate call that consumes any input data.
上级 7d9c9d41
...@@ -586,7 +586,8 @@ int ZEXPORT deflateParams(strm, level, strategy) ...@@ -586,7 +586,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
} }
func = configuration_table[s->level].func; func = configuration_table[s->level].func;
if ((strategy != s->strategy || func != configuration_table[level].func)) { if ((strategy != s->strategy || func != configuration_table[level].func) &&
s->high_water) {
/* Flush the last buffer: */ /* Flush the last buffer: */
int err = deflate(strm, Z_BLOCK); int err = deflate(strm, Z_BLOCK);
if (err == Z_STREAM_ERROR) if (err == Z_STREAM_ERROR)
......
...@@ -712,10 +712,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, ...@@ -712,10 +712,11 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
used to switch between compression and straight copy of the input data, or used to switch between compression and straight copy of the input data, or
to switch to a different kind of input data requiring a different strategy. to switch to a different kind of input data requiring a different strategy.
If the compression approach (which is a function of the level) or the If the compression approach (which is a function of the level) or the
strategy is changed, then the input available so far is compressed with the strategy is changed, and if any input has been consumed in a previous
old level and strategy using deflate(strm, Z_BLOCK). There are three deflate() call, then the input available so far is compressed with the old
approaches for the compression levels 0, 1..3, and 4..9 respectively. The level and strategy using deflate(strm, Z_BLOCK). There are three approaches
new level and strategy will take effect at the next call of deflate(). for the compression levels 0, 1..3, and 4..9 respectively. The new level
and strategy will take effect at the next call of deflate().
If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
not have enough output space to complete, then the parameter change will not not have enough output space to complete, then the parameter change will not
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册