params(p1, p2)
public
Changes the parameters of the deflate stream. See zlib.h for
details. The output from the stream by changing the params is preserved in output buffer.
level |
An Integer compression level between BEST_SPEED
and BEST_COMPRESSION
|
strategy |
A parameter to tune the compression algorithm. Use the DEFAULT_STRATEGY for
normal data, FILTERED for data produced by a filter (or predictor),
HUFFMAN_ONLY to force Huffman encoding only (no string match).
|
Show source
static VALUE
rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
{
struct zstream *z = get_zstream(obj);
int level, strategy;
int err;
uInt n;
level = ARG_LEVEL(v_level);
strategy = ARG_STRATEGY(v_strategy);
n = z->stream.avail_out;
err = deflateParams(&z->stream, level, strategy);
z->buf_filled += n - z->stream.avail_out;
while (err == Z_BUF_ERROR) {
rb_warning("deflateParams() returned Z_BUF_ERROR");
zstream_expand_buffer(z);
n = z->stream.avail_out;
err = deflateParams(&z->stream, level, strategy);
z->buf_filled += n - z->stream.avail_out;
}
if (err != Z_OK) {
raise_zlib_error(err, z->stream.msg);
}
return Qnil;
}