Expand description
SZ3-style multilevel interpolation codec for pointwise (max-abs) bounds,
and for RMSE / PSNR targets through rate control of the bound
(encode_rmse_f32).
Aimed at loose bounds on smooth fields, where the wavelet codec’s fixed overheads (centroids, band predictors, outlier map) dominate a tiny stream.
- Prediction. The grid is refined coarse to fine: at stride
s(a power of two, largest first) and for each axiskin turn, the points whosekcoordinate is an odd multiple ofsare predicted from already reconstructed points at±s, ±3salongk— cubic(−1, 9, 9, −1)/16inside, one-sided quadratics near an edge, linear or copy at the boundary. Each level picks linear or cubic by a trial cost (one header bit per level). - Quantization.
q = round((x − x̃)/2b_ℓ)with a level boundb_ℓ = b / min(α^(ℓ−1), β) ≤ b(finer prediction anchors, as in QoZ); the reconstructionx̃ + 2b_ℓqis cast to f32 and checked againstbexactly as the decoder will compute it, and any point that fails (or overflows the code range) is escaped and stored raw.(α, β)is picked from a small preset list by actual stream size. - Coding. Adaptive binary range coding (
crate::abac): a zero flag with contexts (level,log₂of the local neighbour difference in quanta, previous symbol class), a sign bit per level and an adaptive Elias-gamma magnitude.
Prediction is f64 arithmetic on f32 reconstructions in a fixed order, so encoder and decoder agree bit for bit.
Constants§
- FAST_
TUNE - Fast-mode preset index into the
(α, β)table (the one most often kept byencode_f32on the seen fields). - MAGIC
- Stream magic of the interpolation codec.
Functions§
- decode
- Decode an interpolation stream.
- encode_
f32 - Encode
x(row-major, shapedims) with|x − x̂| ≤ beverywhere, trying each(α, β)preset and keeping the smallest stream. - encode_
fast_ f32 encode_f32with a single(α, β)preset (FAST_TUNE).- encode_
psnr_ f32 encode_rmse_f32atPSNR = 20 log₁₀(range / RMSE)dB.- encode_
rmse_ f32 - Encode for an RMSE target (
rmseabsolute): the boundbis rate controlled per(α, β)preset — the largestbwhose reconstruction meets the squared-error budget, by secant steps onlog SSE(log b)inside a bisection bracket — and the smallest stream wins. The stream is an ordinary max-abs stream at thatb; the target is checked on the exact reconstruction the decoder computes.