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

+4 -2
View File
@@ -1257,7 +1257,7 @@ run_dict_configs(const char* name, const uint8_t* data, size_t len, uint32_t q,
// check_smaller checks that, with the current dictionaries (which should
// hold much of data), libbrotlienc's output (which Wuffs' output matches) is
// smaller than without them.
// smaller than without them (unless that is already tiny).
static void //
check_smaller(const char* name, const uint8_t* data, size_t len, uint32_t q) {
config c = make_config(q, 22);
@@ -1272,7 +1272,9 @@ check_smaller(const char* name, const uint8_t* data, size_t len, uint32_t q) {
}
g_num_dicts = saved;
g_num_smaller_checks++;
if (err || (with_len >= without_len)) {
// Tiny outputs (e.g. for long runs of zeroes) cannot shrink.
if (err || (with_len > without_len) ||
((without_len >= 64) && (with_len >= without_len))) {
g_num_mismatches++;
printf("NOT SMALLER %s: q=%u dicts=%s: %zu bytes with, %zu without: %s\n",
name, q, g_dict_desc, with_len, without_len, err ? err : "");