Skip to content

Commit b6767ed

Browse files
committed
review: fix ratio direction in residue_upscale (#231, codex P2)
Columns were labeled /paeth but computed paeth/global, printing 0.70 for a case where grid (3648 B) actually costs MORE than paeth (2565 B) — readable as a 30% saving when it is a 42% loss. Invert to grid/paeth and spiral/paeth (byte-cost ratio, > 1 = the global upscaler loses to local DPCM), relabel the columns (>1=lose), and reword the conclusion: grid 1.42×, spiral 2.64× of paeth on very-smooth (loss); ~0.98× on noise (tie). Conclusion unchanged in substance — the anatomy upscaler loses to local DPCM on dense scalar residuals — now the numbers point the right way. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MLBnPuScZy6w9di2QEjsXM
1 parent 21321d1 commit b6767ed

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

examples/residue_upscale.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ fn main() {
258258
println!(" {W}×{H} field, {A} anchors (grid {NAX}×{NAY} stride {STRIDE} == spiral {A}), K={KIDW} IDW");
259259
println!(" bytes = order-0 Shannon entropy H₀ (what an ideal rANS coder spends)\n");
260260
println!(
261-
" {:<14} {:>9} {:>9} {:>11} {:>11} {:>7} {:>7}",
262-
"field", "dense H₀", "paeth", "grid a+res", "spiral a+res", "grid×", "spiral×"
261+
" {:<14} {:>9} {:>9} {:>11} {:>11} {:>9} {:>9}",
262+
"field", "dense H₀", "paeth", "grid a+res", "spiral a+res", "grid/paeth", "spiral/paeth"
263263
);
264264
println!(
265-
" {:<14} {:>9} {:>9} {:>11} {:>11} {:>7} {:>7}",
266-
"", "(no model)", "(local)", "(global)", "(global)", "/paeth", "/paeth"
265+
" {:<14} {:>9} {:>9} {:>11} {:>11} {:>9} {:>9}",
266+
"", "(no model)", "(local)", "(global)", "(global)", "(>1=lose)", "(>1=lose)"
267267
);
268268

269269
let names = ["very-smooth", "weather-like", "mid-freq", "noise"];
@@ -280,16 +280,18 @@ fn main() {
280280
let sr = residue(&f, &sp);
281281
let spiral_total = entropy_bytes(&sav) + entropy_bytes(&sr);
282282

283-
// the honest comparison is vs the LOCAL predictor (paeth), not the no-model dense.
283+
// the honest comparison is vs the LOCAL predictor (paeth), not the no-model
284+
// dense. Ratio = byte cost RELATIVE to paeth: > 1 means the global upscaler
285+
// costs MORE than local DPCM (a loss), < 1 means it beats paeth.
284286
println!(
285-
" {:<14} {:>9.0} {:>9.0} {:>11.0} {:>11.0} {:>6.2}× {:>6.2}×",
287+
" {:<14} {:>9.0} {:>9.0} {:>11.0} {:>11.0} {:>8.2}× {:>8.2}×",
286288
name,
287289
dense,
288290
paeth,
289291
grid_total,
290292
spiral_total,
291-
paeth / grid_total,
292-
paeth / spiral_total,
293+
grid_total / paeth,
294+
spiral_total / paeth,
293295
);
294296
}
295297

@@ -313,10 +315,11 @@ fn main() {
313315
\x20 predictor, which stores ZERO anchors):\n\
314316
\x20 • Global sparse-anchor upscaling DOES decorrelate — grid a+res (3648) ≪ the\n\
315317
\x20 no-model order-0 dense (14807). The anatomy 2000→4M mechanism is real.\n\
316-
\x20 • BUT for a DENSE SCALAR luma residual it LOSES to local DPCM (grid 0.70×,\n\
317-
\x20 spiral 0.38× of paeth on very-smooth): a cheap causal local predictor\n\
318-
\x20 beats it, because the 256 anchor VALUES cost real bits and a sparse grid\n\
319-
\x20 can't model structure finer than its stride. For scalar-dense residuals\n\
318+
\x20 • BUT for a DENSE SCALAR luma residual it LOSES to local DPCM: grid costs\n\
319+
\x20 1.42×, spiral 2.64× of paeth's bytes on very-smooth (ratio > 1 = a loss).\n\
320+
\x20 A cheap causal local predictor beats it, because the 256 anchor VALUES\n\
321+
\x20 cost real bits and a sparse grid can't model structure finer than its\n\
322+
\x20 stride. For scalar-dense residuals\n\
320323
\x20 the analogy is RHYME, not a winning transfer — use DPCM / transform.\n\
321324
\x20 • grid > spiral here (bilinear is a better scalar interpolant than\n\
322325
\x20 scattered IDW). The golden-spiral's win is NOT scalar fields.\n\

0 commit comments

Comments
 (0)