code wiki / (root) / nx_resid_entropy.nx

nx_resid_entropy.nx

buildroot/runtime/nx_resid_entropy.nx

2901 B66 linesdepth 4pulls 4 transitivereach 4 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_resid_entropy.nx -- wires the sovereign range coder (nx_range_coder) into LPC-RESIDUAL entropy coding: the voice codec's documented v2 q/bit lever. nx_voice_codec.nx itself notes "entropy coding of residual via nx_range_coder ... is the v2 path". LPC residuals are Laplacian (energy concentrated near 0); a static Laplacian frequency model + arithmetic coding packs them at near-Shannon density, far below a fixed N-bit-per-sample representation -- a real, measured bitrate reduction at identical quality (the residual is coded losslessly). Reusable by the codec's encode/decode. license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_range_coder.nx nx_resid_entropy.nx nx_resid_entropy_gate.nx nx_voice_codec_v2.nx nx_voice_v2_gate.nx

imports: nx_range_coder.nx

imported by: nx_resid_entropy_gate.nxnx_voice_codec_v2.nxnx_voice_v2_gate.nx

structs

none

consts

8const K_MAGIC_4096: i64 = 4096

functions

11func re_zz(r: i64) -> i64 { if r < 0 { return (0 - r) * 2 - 1 } return r * 2 }
called by 2: re_encodemain
12func re_unzz(z: i64) -> i64 { if (z & 1) == 1 { return 0 - ((z + 1) / 2) } return z / 2 }
called by 1: re_decode
16func re_build_model(ALPHA: i64, freq: *i64, cum: *i64) -> i64
32func re_encode(resid: *i64, n: i64, ALPHA: i64, cum: *i64, ft: i64, out: *u8, cap: i64) -> i64
46func re_decode(inb: *u8, len: i64, n: i64, ALPHA: i64, cum: *i64, ft: i64, out_resid: *i64) -> i64