Files
wuffs/test/data/brotli/README.md
T
Claude 4978207531 std/brotli: add a brotli decoder with parity to libbrotlidec v1.2.1
This is the first milestone of a byte-exact rewrite of brotli (reference
implementation tag v1.2.1) in Wuffs. The decoder mirrors c/dec/decode.c
function by function, including its validation checks: the same output for
valid input and the same verdict, with each BROTLI_DECODER_ERROR_FORMAT_*
code mapped to a Wuffs status (see std/brotli/README.md). The C state
machine is replaced by Wuffs coroutines, so decoding works with arbitrarily
small src and dst buffers.

The history window lives in the caller's workbuf. Huffman table groups,
context maps and the static dictionary scratch space live in the decoder
struct. The static dictionary, transforms, context lookup tables and prefix
code tables in common_tables.wuffs are generated from the brotli source by
script/print-brotli-tables.go.

Tests: golden tests on the upstream tests/testdata vectors and on streams
produced by the v1.2.1 CLI at several qualities and window sizes, 1-byte
I/O limits, truncation at every prefix, malformed inputs per error code,
trailing data and workbuf boundaries. With -mimic, every vector and every
malformed input is also compared against libbrotlidec, including the exact
error code. A differential run over about a million mutated inputs found
no divergence.

Not yet supported (left as TODOs): large-window brotli, custom/shared
dictionaries, metadata callbacks and fast paths.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011NoosQNe7DKWnqDCBeqw1p
2026-10-26 22:46:34 +00:00

30 lines
1.3 KiB
Markdown

# Brotli Test Data
Files without a `.br` suffix, and their `.compressed` (and `.compressed.NN`)
counterparts, were copied from the `tests/testdata` directory of the [reference
brotli implementation](https://github.com/google/brotli) at tag v1.2.1. That
repository is licensed under the MIT license: "Copyright (c) 2009, 2010,
2013-2016 by the Brotli Authors".
Some of the upstream files were not copied:
- `lcet10.txt`, `mapsdatazrh`, `plrabn12.txt` and `zerosukkanooa`, because their
decompressed forms are larger than 256 KiB.
- `bb.binast` and `random_chunks`, because they have no `.compressed` form.
The `*.qNwM.br` files were generated by the brotli v1.2.1 command line tool,
from `../romeo.txt`, `../256.bytes` and `alice29.txt`, at quality level N and
with window bits M:
brotli -q N -w M -o romeo.txt.qNwM.br ../romeo.txt
The small window (`w10` and `w16`) `alice29.txt` files exercise the history
ring buffer wrapping around.
The `invalid.*.br` files are malformed. Apart from `invalid.truncated.br` (the
first 20 bytes of `romeo.txt.q11w22.br`), they were found by randomly mutating
the other (valid) files and keeping, for each libbrotlidec v1.2.1 error code,
the smallest mutated file that produced that error code. The file name
mentions that error code, e.g. `invalid.cl-space.br` produces
`BROTLI_DECODER_ERROR_FORMAT_CL_SPACE`.