Files
wuffs/std/brotli/decode_quirks.wuffs
T
Claude bc1b5fcd49 std/brotli: add QUIRK_REPORT_METADATA
The decoder can now report metadata blocks, like libbrotlidec's
BrotliDecoderSetMetadataCallbacks: transform_io returns
"@metadata reported", metadata_length gives the block's length and the
block's contents are written to dst. The differential fuzzer compares
the reported metadata with libbrotlidec's callbacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UZ978Fjdsyig4v3wYAZRg5
2026-10-27 17:06:08 +00:00

49 lines
2.1 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
// When this quirk is set, a positive value makes the decoder report metadata
// blocks, like the C code's BrotliDecoderSetMetadataCallbacks. Zero (the
// default) means that metadata blocks are skipped, like the C code without
// callbacks.
//
// When reporting, at each metadata block, after all of the previously decoded
// bytes have been written to dst, transform_io returns
// base."@metadata reported" and metadata_length returns the block's length
// (the C code's start callback's size argument), which can be zero. The next
// metadata_length bytes that transform_io writes to dst (in subsequent calls)
// are the metadata block's contents (the C code's chunk callbacks' data),
// after which decoded bytes follow as usual.
//
// It must be set before decoding starts. This quirk is decoder-only.
pub const QUIRK_REPORT_METADATA : base.u32 = 0x2AB7_9000 | 0x0A