压缩器选项


¥Compressor options

可以在 Brotli 编码器上设置几个选项,影响压缩效率和速度。键和值都可以作为 zlib.constants 对象的属性访问。

¥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(默认)

      ¥BROTLI_MODE_GENERIC (default)

    • BROTLI_MODE_TEXT,针对 UTF-8 文本进行了调整

      ¥BROTLI_MODE_TEXT, adjusted for UTF-8 text

    • BROTLI_MODE_FONT,针对 WOFF 2.0 字体进行了调整

      ¥BROTLI_MODE_FONT, adjusted for WOFF 2.0 fonts

  • BROTLI_PARAM_QUALITY

    • 范围从 BROTLI_MIN_QUALITYBROTLI_MAX_QUALITY,默认为 BROTLI_DEFAULT_QUALITY

      ¥Ranges from BROTLI_MIN_QUALITY to BROTLI_MAX_QUALITY, with a default of BROTLI_DEFAULT_QUALITY.

  • BROTLI_PARAM_SIZE_HINT

    • 表示预期输入大小的整数值;对于未知的输入大小,默认为 0

      ¥Integer value representing the expected input size; defaults to 0 for an unknown input size.

可以设置以下标志以对压缩算法和内存使用调整进行高级控制:

¥The following flags can be set for advanced control over the compression algorithm and memory usage tuning:

  • BROTLI_PARAM_LGWIN

    • 范围从 BROTLI_MIN_WINDOW_BITSBROTLI_MAX_WINDOW_BITS,默认为 BROTLI_DEFAULT_WINDOW,如果设置了 BROTLI_PARAM_LARGE_WINDOW 标志,则最高可达 BROTLI_LARGE_MAX_WINDOW_BITS

      ¥Ranges from BROTLI_MIN_WINDOW_BITS to BROTLI_MAX_WINDOW_BITS, with a default of BROTLI_DEFAULT_WINDOW, or up to BROTLI_LARGE_MAX_WINDOW_BITS if the BROTLI_PARAM_LARGE_WINDOW flag is set.

  • BROTLI_PARAM_LGBLOCK

    • 范围从 BROTLI_MIN_INPUT_BLOCK_BITSBROTLI_MAX_INPUT_BLOCK_BITS

      ¥Ranges from BROTLI_MIN_INPUT_BLOCK_BITS to BROTLI_MAX_INPUT_BLOCK_BITS.

  • BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING

    • 降低压缩率以提高解压速度的布尔标志。

      ¥Boolean flag that decreases compression ratio in favour of decompression speed.

  • BROTLI_PARAM_LARGE_WINDOW

    • 启用“大窗口 Brotli”模式的布尔标志(与 RFC 7932 中标准化的 Brotli 格式不兼容)。

      ¥Boolean flag enabling “Large Window Brotli” mode (not compatible with the Brotli format as standardized in RFC 7932).

  • BROTLI_PARAM_NPOSTFIX

    • 范围从 0BROTLI_MAX_NPOSTFIX

      ¥Ranges from 0 to BROTLI_MAX_NPOSTFIX.

  • BROTLI_PARAM_NDIRECT

    • 范围从 015 << NPOSTFIX,步长为 1 << NPOSTFIX

      ¥Ranges from 0 to 15 << NPOSTFIX in steps of 1 << NPOSTFIX.