mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 16:47:28 +01:00
Completes the decoder's feature set relative to libbrotlidec v1.2.1: - QUIRK_LARGE_WINDOW mirrors BROTLI_DECODER_PARAM_LARGE_WINDOW: the large-window WBITS escape, window bits up to 30, the 544-symbol distance alphabet and 64-bit distance arithmetic, with workbuf_len growing to (1 << 30) + 542 when the quirk is set. - decoder.add_dictionary! mirrors BrotliDecoderAttachDictionary for raw (LZ77 prefix) and serialized shared dictionaries: compound-dictionary distance mapping, the shared-dictionary parser (custom word lists, transform lists including the SHIFT transforms, context-dependent dictionary selection, prefix dictionaries) and all of its validation. Wuffs structs cannot hold slices, so the dictionary bytes are copied into the front of the caller's workbuf; the layout is documented in the README. Serialized dictionaries are accepted as in a BROTLI_EXPERIMENTAL build of libbrotli. - fuzz/c/std/brotli_fuzzer.c, exercising the quirk, dictionaries and random I/O limits. Tests: new golden vectors for large windows (including a 17 MiB far-distance stream generated in the test), raw and serialized dictionaries, nine more malformed inputs, and mimic comparisons that attach the same dictionaries to libbrotlidec. Differential runs over 2.7 million mutated large-window and dictionary streams found no divergence from libbrotlidec. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011NoosQNe7DKWnqDCBeqw1p
33 lines
1.3 KiB
Plaintext
33 lines
1.3 KiB
Plaintext
// Copyright 2026 The Wuffs Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
|
// option. This file may not be copied, modified, or distributed
|
|
// except according to those terms.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
// --------
|
|
|
|
// Quirks are discussed in (/doc/note/quirks.md).
|
|
//
|
|
// The base38 encoding of "brot" is 0x0A_ADE4. Left shifting by 10 gives
|
|
// 0x2AB7_9000.
|
|
pri const QUIRKS_BASE : base.u32 = 0x2AB7_9000
|
|
|
|
// --------
|
|
|
|
// When this quirk is set, a positive value enables large-window brotli
|
|
// (https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/),
|
|
// with window sizes up to (1 << 30) bytes. Zero means standard (RFC 7932)
|
|
// brotli. It mirrors the C code's BROTLI_DECODER_PARAM_LARGE_WINDOW.
|
|
//
|
|
// It must be set before decoding starts. Setting it also increases the
|
|
// workbuf_len.
|
|
//
|
|
// Without this quirk, a stream that starts with the large-window WBITS escape
|
|
// is rejected with "#unsupported large window". With this quirk, a stream that
|
|
// does not start with that escape is decoded as standard brotli.
|
|
pub const QUIRK_LARGE_WINDOW : base.u32 = 0x2AB7_9000 | 0x00
|