code wiki / _hdl_build / nx_bd_calc.nx

nx_bd_calc.nx

buildroot/runtime/_hdl_build/nx_bd_calc.nx

6554 B130 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_bd_calc.nx -- SOVEREIGN Bjontegaard BD-rate (2026-07-29; retires the bd_*.py lane instruments per the sovereign-no-python law -- python remains ONLY as the cubic ORACLE inside this organ's gate). ESTIMATOR (declared): BD-PWL -- piecewise-LINEAR interpolation of log10(rate) over the overlapping PSNR span, trapezoid-integrated. The classic estimator fits a cubic; on the 4-5 point curves this lane sweeps, PWL is monotone, has no ill-conditioned Vandermonde solve, and its delta vs the cubic oracle is MEASURED and bounded in nx_bd_calc_gate (tolerance derived from measurement, never taste). All math is bits-up sovereign binary64 (nx_f64 add/sub/mul/div/log2/exp/cvt). usage: nx_bd_calc <anchor.pts> <test.pts> each line: "<kbps_milli> <psnr_milli>" (integers; kbps_milli = bytes*5 for 48f@30fps CIF sweeps; the milli scaling cancels: log10(1000x)=log10(x)+3 shifts BOTH curves equally, psnr-milli scales numerator and denominator of the average equally) output: "BD_PWL_PERMILLE=<n>" (test-vs-anchor bits at equal quality; negative = test wins) license: ORIGINAL

dependencies 7 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_f64.nx nx_f64_div.nx nx_f64_cvt.nx nx_f64_exp.nx nx_f64_log2.nx nx_bd_calc.nx

imports: nx_syscalls.nxnx_tier.nxnx_f64.nxnx_f64_div.nxnx_f64_cvt.nxnx_f64_exp.nxnx_f64_log2.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gw sys_write sys_mmap bd_parse sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close bd_sort bd_logs nx_f64_mul nx_f64_classify nx_f64_exp_field nx_f64_mant_field nx_f64_sign nx_f64_mant_field ↻ nx_f64_exp_field ↻ _f64_round_pack nx_f64_log2 nx_f64_classify ↻ nx_f64_sign ↻ nx_f64_mant_field ↻ nx_f64_exp_field ↻ nx_f64_sub nx_f64_add nx_f64_classify ↻ nx_f64_sign ↻ nx_f64_mant_field ↻ nx_f64_exp_field ↻ _f64_round_pack ↻ nx_f64_neg nx_f64_add ↻ nx_f64_div nx_f64_classify ↻ nx_f64_sign ↻ nx_f64_mant_field ↻

structs

none

consts

22const BD_MAXPTS: i64 = 64
23const BD_LOG10_2: i64 = 0x3FD34413509F79FF // log10(2) in binary64
24const BD_LN10: i64 = 0x40026BB1BBB55516 // ln(10) in binary64
25const BD_ONE: i64 = 0x3FF0000000000000
26const BD_HALF: i64 = 0x3FE0000000000000
27const BD_KILO: i64 = 0x408F400000000000 // 1000.0

functions

29func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
30func gn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
36func bd_parse(path: *u8, km: *i64, pm: *i64) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
63func bd_sort(km: *i64, pm: *i64, n: i64) -> i64
called by 1: main
74func bd_logs(km: *i64, v: *i64, n: i64) -> i64
81func bd_integ(pm: *i64, v: *i64, n: i64, lo: i64, hi: i64) -> i64
100func main(argc: i64, argv: *i64) -> i64