mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 16:47:28 +01:00
Merge branch 'claude/project-thread-0izcgq' into m5a-zopfli
This commit is contained in:
2 files changed
+14
-1
No files matched your search
@@ -455,6 +455,14 @@ static size_t //
|
|||||||
random_distance(block_t* b) {
|
random_distance(block_t* b) {
|
||||||
uint32_t r = rng_below(16);
|
uint32_t r = rng_below(16);
|
||||||
size_t max = b->large_window ? 0x7FFFFFFC : ((1u << 24) - 16);
|
size_t max = b->large_window ? 0x7FFFFFFC : ((1u << 24) - 16);
|
||||||
|
// Keep the distance codes (distance + 15) at most the distance params'
|
||||||
|
// max_distance (which is less than 0x7FFFFFFC for some large-window
|
||||||
|
// params), as the encoder does. Larger distances are invalid for those
|
||||||
|
// params and make the C code's ComputeDistanceCost write past the end of
|
||||||
|
// its distance histogram.
|
||||||
|
if (max > (b->dist.max_distance - 15)) {
|
||||||
|
max = b->dist.max_distance - 15;
|
||||||
|
}
|
||||||
if ((g_dist_style == 1) && (r < 12)) {
|
if ((g_dist_style == 1) && (r < 12)) {
|
||||||
// Distances with a fixed residue modulo (1 << g_dist_shift), which
|
// Distances with a fixed residue modulo (1 << g_dist_shift), which
|
||||||
// favors npostfix > 0.
|
// favors npostfix > 0.
|
||||||
|
|||||||
@@ -531,7 +531,12 @@ The exact signatures are:
|
|||||||
bytes. `literal_context_mode` is a `ContextType` (0 = LSB6, 1 = MSB6, 2 =
|
bytes. `literal_context_mode` is a `ContextType` (0 = LSB6, 1 = MSB6, 2 =
|
||||||
UTF8, 3 = SIGNED). Like the C code, it rewrites the commands'
|
UTF8, 3 = SIGNED). Like the C code, it rewrites the commands'
|
||||||
`dist_prefix_` and `dist_extra_` fields for the chosen distance params and
|
`dist_prefix_` and `dist_extra_` fields for the chosen distance params and
|
||||||
leaves those params in the `dist_etc` fields. It returns
|
leaves those params in the `dist_etc` fields. Like the encoder's commands,
|
||||||
|
every command's distance code must be at most the given params'
|
||||||
|
`max_distance` (with larger, invalid distance codes, the C code's
|
||||||
|
`ComputeDistanceCost` writes past the end of its distance histogram, which
|
||||||
|
the Wuffs code cannot mirror: it ignores out-of-range histogram symbols
|
||||||
|
instead). It returns
|
||||||
`"#bad workbuf length"` if `wb` is too short (the results are then invalid
|
`"#bad workbuf length"` if `wb` is too short (the results are then invalid
|
||||||
but `cmds` may already be rewritten, so retrying needs the original
|
but `cmds` may already be rewritten, so retrying needs the original
|
||||||
commands).
|
commands).
|
||||||
|
|||||||
Reference in new issue
Block a user