Expand description
The wavelet codec: CDF 9/7 pyramid → deadzone quantizer → context model → adaptive binary range coding, with a SPERR-style outlier stream for pointwise bounds and an integer 5/3 lossless mode.
§Lossy path
- Forward multi-level CDF 9/7 (
crate::wavelet); every coefficient is multiplied by its band’s synthesis-basis norm, so one uniform stepΔis equal-slope (MSE-matched) across bands. - Deadzone uniform quantizer
q = sgn(c)·⌊|c|/Δ + ρ⌋(ρ < ½widens the zero bin); reconstruction at the per-(class, |q|∈{1,2,≥3}) centroid|ĉ| = (|q| − δ)Δ, the 30δs transmitted in 1/512 units. - Coefficients coded by
crate::coefcode(hand contexts) or a learned model (crate::learned). - Rate control: for a PSNR/RMSE target
Δis bisected on the measured error of the actual decoder output.
§Max-abs mode
For a bound b the wavelet layer is coded at Δ = f·b for several f;
the encoder decodes its own output and every cell with |x − x̂| > b gets a
correction k = round((x − x̂)/2b) (then |x − (x̂ + 2bk)| ≤ b), coded as a
context-modelled significance map plus |k|; cells a float cast still
pushes over b are stored raw. The f with the smallest total wins and
the bound is re-verified on the exact decoder output before returning.
Structs§
- Coeffs
- Forward-transformed, band-weighted coefficients.
- WavConfig
- Wavelet-codec options.
- WavStats
- What the encoder did.
Enums§
- Model
Choice - Which coefficient model codes the stream.
Constants§
- FAST_
K_ MAXABS - See
FAST_K_RMSE. - FAST_
K_ RMSE - Fast-mode step ratios
Δ / target: RMSE targets (Δ = k·rmse) and max-abs bounds (Δ = k·b). Calibrated on the 19 seen fields. - MAGIC
- Stream magic of the wavelet codec.
Functions§
- decode
- Decode a lossy wavelet stream.
- decode_
i32_ lossless - Decode a lossless stream from
encode_i32_lossless. - encode_
f32 - Encode f32 samples (row-major,
dims1D–3D). - encode_
f64 - Encode f64 samples.
- encode_
i32_ lossless - Lossless coding of integer samples via the reversible 5/3 transform.
- fast_
step - Step for an RMSE target: start from the formula
Δ = k·t, then take log–log secant steps on the measured error (rmse ∝ Δ^γ), aiming 1% under the target, for at mostcheckstrials. Returns the largest tried step that met the target (or the last one, halved, when none did) and the number of trials. - quantize
- Deadzone quantization with centroid offsets.
- reconstruct
- Dequantize + inverse transform → reconstruction (f64, row-major).