std/brotli: test encoder dictionaries and document them

Add mimic_brotli_encode_with_dictionaries to the mimic library and
encoder dictionary tests: the add_dictionary API, its workbuf
accounting and rejection cases (matching libbrotlienc's default build),
a parity grid over qualities 0 to 9 with several dictionary sets, stream
offsets, large window, flushes and metadata, and dictionaries of 2 to
33 MiB, each round tripped through both decoders.

Document the encoder's dictionary API, workbuf layout and differences
from the C code.
This commit is contained in:
Claude committed 2026-10-27 05:28:37 +00:00
1 parent aabdeaf4b0
commit 36a4380062
5 files changed
+941 -27

No files matched your search

+9 -3
View File
@@ -26,8 +26,10 @@ In Wuffs syntax, the `base.io_transformer` methods are:
- `workbuf_len() range_ii_u64`
Encoders may have further, format-specific methods. For example, the brotli
encoder has `request_flush`, `request_emit_metadata` and
`max_compressed_size`.
encoder has `request_flush`, `request_emit_metadata`, `max_compressed_size`
and, for raw (LZ77 prefix) dictionaries, `add_dictionary` and
`add_dictionary_workbuf_len`. Like quirks, dictionaries are added before the
first `transform_io` call.
## Implementations
@@ -36,4 +38,8 @@ encoder has `request_flush`, `request_emit_metadata` and
including large-window brotli, with windows of up to 1 GiB, at qualities 3
to 9). Its `workbuf_len` is the worst case for the parameters (more than
2 GiB for large-window brotli at lgwin 30), but a shorter workbuf works for
short inputs: see the README's "Encoder Workbuf Layout" section.
short inputs: see the README's "Encoder Workbuf Layout" section. Up to 15
raw dictionaries can be attached (like libbrotlienc's
`BrotliEncoderAttachPreparedDictionary`), see the README's "Encoder
Dictionaries" section. They live at the start of the workbuf, with their
prepared hash tables, and `workbuf_len` grows accordingly.