压缩器选项
可以在 Brotli 编码器上设置几个选项,影响压缩效率和速度。
键和值都可以作为 zlib.constants
对象的属性访问。
最重要的选项是:
BROTLI_PARAM_MODE
BROTLI_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_MODE
BROTLI_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_QUALITY
toBROTLI_MAX_QUALITY
, with a default ofBROTLI_DEFAULT_QUALITY
.
- Ranges from
BROTLI_PARAM_SIZE_HINT
- Integer value representing the expected input size;
defaults to
0
for 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_BITS
toBROTLI_MAX_WINDOW_BITS
, with a default ofBROTLI_DEFAULT_WINDOW
, or up toBROTLI_LARGE_MAX_WINDOW_BITS
if theBROTLI_PARAM_LARGE_WINDOW
flag is set.
- Ranges from
BROTLI_PARAM_LGBLOCK
- Ranges from
BROTLI_MIN_INPUT_BLOCK_BITS
toBROTLI_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
0
toBROTLI_MAX_NPOSTFIX
.
- Ranges from
BROTLI_PARAM_NDIRECT
- Ranges from
0
to15 << NPOSTFIX
in steps of1 << NPOSTFIX
.
- Ranges from