wai-rs: jpegai_pipeline::sigma_index — close the scale path (byte-exact, both planes) #5
Loading…
Reference in a new issue
No description provided.
Delete branch "jpegai-sigma-index"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Derives the per-position mANS distribution index from the hyper-scale decoder output, connecting decode_hyper_scale to the sgm entropy decode:
The
+64 >>7is a round-to-nearest-128 done as an arithmetic right shift (floor) — the same reference semantics as the hyper_scale division.Recovered from the reference decoder fixtures: sigma is NOT a pure function of i_s (the ranges overlap), but becomes an exact one once the per-channel gain and per-position residual-variance scale are added — at which point the boundaries snap to clean multiples of 128.
Byte-exact vs the reference entropy fixtures on real test256.bin, both planes: luma (SORP) 40960/40960, chroma (SORS) 24576/24576 — matching the
indexesthe reference entropy coder actually consumed. Plus a unit test pinning the 128-boundaries, floor-on-negatives, and the [0,31] clamp.This completes the entropy+scale chain byte-exact end to end: z → hyper_scale → i_s → sigma_index → mANS sgm → y_q → dequant → resi.
dcharlot referenced this pull request2026-11-06 13:54:17 -05:00