压缩器选项
可以在 Brotli 编码器上设置几个选项,影响压缩效率和速度。
键和值都可以作为 zlib.constants 对象的属性访问。
最重要的选项是:
BROTLI_PARAM_MODEBROTLI_MODE_GENERIC(默认)BROTLI_MODE_TEXT,针对 UTF-8 文本进行了调整BROTLI_MODE_FONT,针对 WOFF 2.0 字体进行了调整
BROTLI_PARAM_QUALITY- 范围从
BROTLI_MIN_QUALITY到BROTLI_MAX_QUALITY,默认为BROTLI_DEFAULT_QUALITY。
- 范围从
BROTLI_PARAM_SIZE_HINT- 表示预期输入大小的整数值;对于未知的输入大小,默认为
0。
- 表示预期输入大小的整数值;对于未知的输入大小,默认为
可以设置以下标志以对压缩算法和内存使用调整进行高级控制:
BROTLI_PARAM_LGWIN- 范围从
BROTLI_MIN_WINDOW_BITS到BROTLI_MAX_WINDOW_BITS,默认为BROTLI_DEFAULT_WINDOW,如果设置了BROTLI_PARAM_LARGE_WINDOW标志,则最高可达BROTLI_LARGE_MAX_WINDOW_BITS。
- 范围从
BROTLI_PARAM_LGBLOCK- 范围从
BROTLI_MIN_INPUT_BLOCK_BITS到BROTLI_MAX_INPUT_BLOCK_BITS。
- 范围从
BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING- 降低压缩率以提高解压速度的布尔标志。
BROTLI_PARAM_LARGE_WINDOW- 启用“大窗口 Brotli”模式的布尔标志(与 RFC 7932 中标准化的 Brotli 格式不兼容)。
BROTLI_PARAM_NPOSTFIX- 范围从
0到BROTLI_MAX_NPOSTFIX。
- 范围从
BROTLI_PARAM_NDIRECT- 范围从
0到15 << NPOSTFIX,步长为1 << NPOSTFIX。
- 范围从
There are several options that can be set on Brotli encoders, affecting
compression efficiency and speed. Both the keys and the values can be accessed
as properties of the zlib.constants object.
The most important options are:
BROTLI_PARAM_MODEBROTLI_MODE_GENERIC(default)BROTLI_MODE_TEXT, adjusted for UTF-8 textBROTLI_MODE_FONT, adjusted for WOFF 2.0 fonts
BROTLI_PARAM_QUALITY- Ranges from
BROTLI_MIN_QUALITYtoBROTLI_MAX_QUALITY, with a default ofBROTLI_DEFAULT_QUALITY.
- Ranges from
BROTLI_PARAM_SIZE_HINT- Integer value representing the expected input size;
defaults to
0for an unknown input size.
- Integer value representing the expected input size;
defaults to
The following flags can be set for advanced control over the compression algorithm and memory usage tuning:
BROTLI_PARAM_LGWIN- Ranges from
BROTLI_MIN_WINDOW_BITStoBROTLI_MAX_WINDOW_BITS, with a default ofBROTLI_DEFAULT_WINDOW, or up toBROTLI_LARGE_MAX_WINDOW_BITSif theBROTLI_PARAM_LARGE_WINDOWflag is set.
- Ranges from
BROTLI_PARAM_LGBLOCK- Ranges from
BROTLI_MIN_INPUT_BLOCK_BITStoBROTLI_MAX_INPUT_BLOCK_BITS.
- Ranges from
BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING- Boolean flag that decreases compression ratio in favour of decompression speed.
BROTLI_PARAM_LARGE_WINDOW- Boolean flag enabling “Large Window Brotli” mode (not compatible with the Brotli format as standardized in RFC 7932).
BROTLI_PARAM_NPOSTFIX- Ranges from
0toBROTLI_MAX_NPOSTFIX.
- Ranges from
BROTLI_PARAM_NDIRECT- Ranges from
0to15 << NPOSTFIXin steps of1 << NPOSTFIX.
- Ranges from