code wiki / _hdl_build / nx_room_simulcast.nx
nx_room_simulcast.nx
buildroot/runtime/_hdl_build/nx_room_simulcast.nx
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
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
structs
| none |
consts
| 27 | const SIM_MAGIC_1500: i64 = 1500 |
| 28 | const SIM_MAGIC_2150: i64 = 2150 |
| 29 | const SIM_MAGIC_3000: i64 = 3000 |
| 30 | const SIM_MAGIC_2000: i64 = 2000 |
| 31 | const SIM_MAGIC_999999: i64 = 999999 |
| 33 | const SIM_LOG: *u8 = "knowledge/status/room_simulcast.log" |
functions
| 35 | func 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 } |
| 36 | func 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 } |
| 39 | func sim_demand_mask(demands: *i64, nrx: i64) -> i64 called by 1: main |
| 47 | func sim_bitrate(ladder: *i64, n: i64, mask: i64) -> i64 called by 1: sim_allocate |
| 55 | func sim_top_bit(n: i64, mask: i64) -> i64 called by 1: sim_allocate |
| 62 | func sim_allocate(ladder: *i64, n: i64, demand_mask: i64, budget: i64, out: *i64) -> i64 |
| 76 | func main() -> i64 |