code wiki / _hdl_build / nx_rans.nx

nx_rans.nx

buildroot/runtime/_hdl_build/nx_rans.nx

5345 B132 linesdepth 2pulls 2 transitivereach 12 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_rans.nx -- SOVEREIGN, PATENT-FREE static-frequency rANS entropy coder. The keystone of the patent-free video-codec arc (project-sovereign-patent-free-codec-2026-06-20). rANS = the range variant of Asymmetric Numeral Systems (J. Duda, dedicated to the PUBLIC DOMAIN; the USPTO rejected Google's attempt to patent ANS use, 2018). This is PLAIN static-frequency rANS -- explicitly NOT the Petagene Markov+escape-code variant (US9847791B2) and NOT the Microsoft two-phase / switchable-width / fragment-flush hardware variant (US11234023B2) -- so it reads on no active claim (deep-research verified 2026-06-20). Byte-oriented, 32-bit state in the ryg style (RANS_L = 1<<23, 8-bit renormalization), SCALE_BITS supplied by the caller (12 = a 4096-entry table). LOSSLESS: rans_decode(rans_encode(x)) == x, bit-exact -- the COMPLETE correctness criterion for an entropy stage whose encoder AND decoder we both own (no external interop, so round-trip self-proof is sufficient and total). license_tier: ORIGINAL

dependencies 1 imports · 12 importers

nx_syscalls.nx nx_rans.nx nx_codec_rd2_gate.nx nx_codec_rd_gate.nx nx_codec_real_rd.nx nx_codec_real_rd2.nx nx_codec_real_rd2f.nx nx_codec_real_rd2g.nx nx_codec_real_rd3.nx nx_intra_block_gate.nx nx_intra_image_gate.nx nx_lossless_codec_gate.nx

diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: nx_codec_rd2_gate.nxnx_codec_rd_gate.nxnx_codec_real_rd.nxnx_codec_real_rd2.nxnx_codec_real_rd2f.nxnx_codec_real_rd2g.nxnx_codec_real_rd3.nxnx_intra_block_gate.nxnx_intra_image_gate.nxnx_lossless_codec_gate.nxnx_lossless_ctx_gate.nxnx_rans_gate.nx

structs

none

consts

none

functions

15func rans_count(data: *u8, n: i64, counts: *i64) -> i64
called by 12: mainmainmainmainmainmain+6
25func rans_normalize(counts: *i64, freqs: *i64, scale_bits: i64) -> i64
called by 12: mainmainmainmainmainmain+6
52func rans_cum(freqs: *i64, cum: *i64) -> i64
called by 12: mainmainmainmainmainmain+6
61func rans_build_slot2sym(freqs: *i64, cum: *i64, slot2sym: *i64) -> i64
called by 12: mainmainmainmainmainmain+6
77func rans_encode(data: *u8, n: i64, freqs: *i64, cum: *i64, scale_bits: i64, out: *u8, outcap: i64) -> i64
called by 12: mainmainmainmainmainmain+6 calls 1: sys_mmap
110func rans_decode(enc: *u8, enclen: i64, n: i64, freqs: *i64, cum: *i64, scale_bits: i64, slot2sym: *i64, out: *u8) -> i64
called by 12: mainmainmainmainmainmain+6