Skip to content

feat(transfer): add exact 16-bit decode tables - #1

Merged
oddharsh merged 1 commit into
mainfrom
codex/u16-transfer-tables
Sep 16, 2026
Merged

oddharsh merged 1 commit into
mainfrom
codex/u16-transfer-tables

Conversation

@oddharsh

@oddharsh oddharsh commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Add srgb_lut16() and g22_lut16() so Rust callers can decode unsigned 16-bit samples to linear f32 without an 8-bit intermediate or a power function per sample. This moves the tested implementation from site #854 into the crate that already owns resampling and 8-bit transfer functions.

Each curve lazily allocates a 256 KiB table directly on the heap. Both bit depths share the normalized curve implementation; existing public APIs and the JavaScript surface retain their behavior. No dependencies or MSRV changes.

Validation:

  • Exhaustive bit equality for all 65,536 values under both curves, against the original site formulas, in debug and release builds.
  • The integration test initializes both tables on a cold 128 KiB thread stack, guarding against the temporary-array stack overflow found during the site experiment.
  • Existing 8-bit tests, both doctests, five conformance tests, workspace Clippy and formatting pass.
  • Rust 1.75 check passes. WebAssembly build and all three JavaScript tests pass; wasm is 13,613 bytes gzip, below the 40,000-byte gate.
  • Site #854 now consumes this exact commit. Comparing its previous binary with the new dependency produced identical bytes for all 312 outputs across 52 full-resolution originals (46 JPEGs and six HIFs): 208 thumbnail tier files, 52 width-capped PNGs and 52 q84 JPEG encodes. All 258 site histograms also match. The site's 38 Rust tests, including exhaustive checks through its four 16-bit loader formats, pass in the consumer build.

Local wasm-pack printed prebuilt-binary/update and package-metadata notices; the build completed successfully using the available tooling.

@oddharsh
oddharsh merged commit 60225de into main Sep 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant