code wiki / _hdl_build / nx_room_simulcast.nx

nx_room_simulcast.nx

buildroot/runtime/_hdl_build/nx_room_simulcast.nx

7172 B138 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic room
docsdependenciesstructsconstsfunctions

about

nx_room_simulcast.nx -- X-ROOM (GEN-ROOM-simulcast-quality-layers): sovereign DETERMINISTIC INTEGER simulcast layer allocator -- the SENDER-side companion to nx_room_abr (the receiver-side ABR controller). ABR decides which quality layer each receiver PULLS; simulcast decides which layers the sender PRODUCES, given a finite uplink budget and the set of layers receivers actually demand. EXCEED axis vs Zoom/LiveKit/WebRTC simulcast (honest): two deterministic, audit- replayable levers a heuristic encoder leaves on the table -- (1) DEMAND-DRIVEN PRUNE: encode ONLY layers some receiver requests; a layer nobody pulls is never encoded = uplink saved (naive simulcast always pushes all spatial layers). (2) BUDGET-BOUNDED SHED: if the demanded layers exceed the uplink budget, shed the highest-bitrate layers FIRST, deterministically, until the encoded set fits -- never over-subscribe the uplink (which a budget-unaware encoder does, causing the very congestion ABR then has to fight). MODEL (bitrates kbps): ladder[] = simulcast layers low->high (DATA, rule 25). demand mask = bit i set iff some receiver requests layer i. allocate: start from the demand mask; while sum(encoded bitrates) > budget, clear the highest set bit (shed) and count it. out[0]=encoded mask, out[1]=encoded kbps, out[2]=shed count. naive baseline = always all layers = sum(ladder). main() is the SELF-VALIDATING GATE. Evidence -> knowledge/status/room_simulcast.log. HONEST SCOPE: this is the produce-set ALLOCATION (prune+shed); per-receiver fallback re-mapping after a shed is a named deeper rung, not claimed here. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_room_simulcast.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sim_demand_mask sim_allocate sim_bitrate sim_top_bit sw sys_write swn sys_mmap ↻ sys_write ↻ sys_openat_append sys_close sys_exit

structs

none

consts

27const SIM_MAGIC_1500: i64 = 1500
28const SIM_MAGIC_2150: i64 = 2150
29const SIM_MAGIC_3000: i64 = 3000
30const SIM_MAGIC_2000: i64 = 2000
31const SIM_MAGIC_999999: i64 = 999999
33const SIM_LOG: *u8 = "knowledge/status/room_simulcast.log"

functions

35func sw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main calls 1: sys_write
36func swn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(fd, bb, k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
39func sim_demand_mask(demands: *i64, nrx: i64) -> i64
called by 1: main
47func sim_bitrate(ladder: *i64, n: i64, mask: i64) -> i64
called by 1: sim_allocate
55func sim_top_bit(n: i64, mask: i64) -> i64
called by 1: sim_allocate
62func sim_allocate(ladder: *i64, n: i64, demand_mask: i64, budget: i64, out: *i64) -> i64
called by 1: main calls 2: sim_bitratesim_top_bit
76func main() -> i64