Skip to main content

Crate gamut_dsp

Crate gamut_dsp 

Source
Expand description

Shared digital signal processing routines for the gamut codecs.

Provides the AV1 1-D transform kernels:

The 2-D assembly that selects per PlaneTxType and applies the per-pass normalization shifts (AV1 §7.13.3) is tracked in gamut-avif/STATUS.md.

Alongside the transforms, [mod@math] exposes the small AV1 §4.7 integer arithmetic primitives (round2, round2_signed, clip3) and the shared forward-quantize rounding (round_div_nearest) that the codec crates build on, and [mod@mulaw] adds µ-law companding/quantization (mu_compress / mu_expand / mu_quantize / mu_dequantize).

Functions§

clip3
Clip3(low, high, x) (AV1 §4.7): clamp x to the inclusive range [low, high].
flip_in_place
Reverse the first len elements of t in place — the FLIPADST sample-order flip (AV1 §7.13.3 applies this around the shared inverse ADST for the FLIPADST transform variants).
forward_adst
In-place 1-D forward ADST of the length-2^n array t (n ∈ {2, 3, 4}) — the transpose of the inverse ADST matrix, built from the inverse’s impulse responses (see module docs).
forward_dct
In-place 1-D forward DCT-II of the length-2^n array t (2 ≤ n ≤ 6).
forward_identity
In-place 1-D forward identity transform of the length-2^n array t (2 ≤ n ≤ 5): the reciprocal per-element scaling that pairs with inverse_identity.
fwht4x4
Forward 4×4 Walsh–Hadamard transform: maps a row-major residual block to the lossless AV1 coefficients to be entropy-coded.
inverse_adst
In-place 1-D inverse ADST of the length-2^n array t (n ∈ {2, 3, 4}), per AV1 §7.13.2.9.
inverse_dct
In-place 1-D inverse DCT of the length-2^n array t (2 ≤ n ≤ 6), per AV1 §7.13.2.3.
inverse_identity
In-place 1-D inverse identity transform of the length-2^n array t (2 ≤ n ≤ 5), per AV1 §7.13.2.15.
iwht4x4
Lossless 4×4 reconstruct: dequantizes (* 4), applies the AV1 row (shift 2) and column (shift 0) inverse WHT, and returns the residual. Bit-exact with the AV1 decoder for an 8-bit base_q_idx == 0 block (AV1 §7.12.3, §7.13.3, §7.13.2.10).
mu_compress
µ-law compress a value in [-1, 1] to a companded value in [-1, 1]. value is clamped to [-1, 1]. Precondition: mu > 0.
mu_dequantize
Dequantize an integer index back to a value in [-1, 1] through µ-law — the inverse of mu_quantize. The never-written top code clamps down to 2^bits−2 for robustness.
mu_expand
µ-law expand a companded value in [-1, 1] back to [-1, 1] — the inverse of mu_compress. Precondition: mu > 0.
mu_quantize
Quantize a value in [-1, 1] through µ-law to an integer index in 0..=2^bits−2 (odd level count; the center index is exactly 0.0).
round2
Round2(x, n) (AV1 §4.7): rounding right shift, x for n == 0 (arithmetic >>, ties up).
round2_signed
Round2Signed(x, n) (AV1 §4.7): symmetric rounding right shift — rounds the magnitude and keeps the sign (ties away from zero), unlike round2 which ties toward +∞.
round_div_nearest
Rounds num / den to the nearest integer, ties away from zero — the encoder forward-quantize step shared by AV1 and VP8 (level ≈ coeff / q). Requires den > 0.