code wiki / (root) / nx_video_client_wasm.nx

nx_video_client_wasm.nx

buildroot/runtime/nx_video_client_wasm.nx

42741 B984 linesdepth 6pulls 19 transitivereach 14 importersview sourcekind librarytopic video
docsdependenciesstructsconstsfunctions

about

nx_video_client_wasm.nx -- the Nishi Video BROWSER CLIENT CORE, for the WAT/WASM target. Operator 2026-06-10: "we dont want to use javascript or anything except as a last mile translation for 3rd party browsers." ALL format/protocol/sample logic the video client needs lives HERE, in NishiLang, shipped to the browser as nx_video_client.wasm. The JS that remains in app.js is a named LAST-MILE SHIM: mount this module + bridge the platform primitives the browser gates behind JS APIs (getUserMedia, canvas pixels, AudioContext buffers, WebSocket send/recv). No format byte and no sample arithmetic is computed in JavaScript. Like nx_sha256_wasm.nx: imports NOTHING, works in caller-supplied linear memory regions, no syscalls. Team-side authority for the NV1 container is nx_nv1.nx -- nx_vc_gate cross-checks this module against it natively. Exports (pointers are i64 offsets into the module's linear memory): NV1 container (NLC1 -- see knowledge/specs/2026-06-10-nishilossless-...) vc_nv1_header(out, rate) -> 24 vc_nv1_chunk(out, w, kind, t_ms, payload, n) -> new w vc_nv1_end(out, w, dur_ms) -> new w vc_nv1_validate(buf, n, info) -> 0 | negative defect code vc_nv1_next(buf, n, off, info) -> next off | 0 at end | negative info[0]=kind info[1]=len info[2]=t_ms info[3]=payload_off Room wire frames (13-byte kind/id/seq header, relay broadcast) vc_wire_pack(out, kind, id, seq, payload, n) -> total len vc_wire_parse(buf, n, info) -> 0 | -1 info[0]=kind info[1]=seq info[2]=payload_off info[3]=payload_len Sample plane (IEEE 754 decoded with INTEGER math -- bit-exact, no float unit on the trust path; matches the JS path it replaces: clamp [-1,1] then TRUNCATE toward zero; NaN->0, +/-Inf->clamp) vc_f32_to_i16(inb, n_samples, outb) -> n_samples (LE f32 bits -> LE i16) vc_i16_to_f32(inb, n_samples, outb) -> n_samples (LE i16 -> LE f32 bits, EXACT) Send-rate governor (the fps/quality ladder decision) vc_ladder_step(idx, n_rungs, rtt_ms, degrade_ms, recover_ms, good) -> idx license_tier: ORIGINAL

dependencies 4 imports · 14 importers

nx_media_budget.nx nx_video_ui_core.nx nx_video_codec_wasm.nx nx_vcodec_nf_table.nx nx_video_client_wasm.nx nx_audio_lossless_gate.nx nx_lpc_speed_bench.nx nx_room_stream_gate.nx nx_vc_fec_gate.nx nx_vc_fecrx_fuzz_gate.nx nx_vc_fecwire_gate.nx nx_vc_gate.nx nx_vcore_a64_kat.nx nx_video_client_live_verify.nx nx_video_client_wasm_vm_gate.nx

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

imports: nx_media_budget.nxnx_video_ui_core.nxnx_video_codec_wasm.nxnx_vcodec_nf_table.nx

imported by: nx_audio_lossless_gate.nxnx_lpc_speed_bench.nxnx_room_stream_gate.nxnx_vc_fec_gate.nxnx_vc_fecrx_fuzz_gate.nxnx_vc_fecwire_gate.nxnx_vc_gate.nxnx_vcore_a64_kat.nxnx_video_client_live_verify.nxnx_video_client_wasm_vm_gate.nxnx_video_native_client_gate.nxnx_video_native_video_gate.nxnx_video_qoe_live.nxnx_video_swarm_probe.nx

structs

none

consts

56const VC_MAGIC_65536: i64 = 65536
57const VC_MAGIC_16777216: i64 = 16777216
58const VC_MAGIC_2147483648: i64 = 2147483648
59const VC_MAGIC_8388608: i64 = 8388608
60const VC_MAGIC_8388607: i64 = 8388607
61const VC_MAGIC_32768: i64 = 32768
62const VC_MAGIC_32767: i64 = 32767
63const VC_MAGIC_2048: i64 = 2048
64const VC_MAGIC_2764: i64 = 2764
66const VC_NV1_HDR: i64 = 24
67const VC_NV1_CHDR: i64 = 9
497const VC_LADDER_RUNGS: i64 = 10
542const VC_RECOVER_DELTA: i64 = 100
551const VC_DEGRADE_DELTA: i64 = 250
600const VV_CTX_EST: i64 = 0x80
601const VV_CTX_PROBS: i64 = 0x180
602const VV_CTX_T8C: i64 = 0x280
603const VV_CTX_RCSCR: i64 = 0x1800
606const VV_CTX_MVPLANE: i64 = 0x32000
691const VC_FEC_K: i64 = 8
692const VC_FEC_M: i64 = 2
693const VC_GF_POLY: i64 = 0x11d
929const VC_NREACTS: i64 = 6

functions

69func vc_rd_u32(b: *u8, off: i64) -> i64
77func vc_wr_u32(b: *u8, off: i64, v: i64) -> i64
87func vc_nv1_header(out: *u8, rate: i64) -> i64
called by 1: main calls 1: vc_wr_u32
97func vc_nv1_chunk(out: *u8, w: i64, kind: i64, t_ms: i64, payload: *u8, n: i64) -> i64
called by 1: main calls 1: vc_wr_u32
106func vc_nv1_end(out: *u8, w: i64, dur_ms: i64) -> i64
called by 1: main calls 1: vc_wr_u32
114func vc_nv1_validate(buf: *u8, n: i64, info: *i64) -> i64
called by 1: main calls 1: vc_rd_u32
158func vc_nv1_next(buf: *u8, n: i64, off: i64, info: *i64) -> i64
called by 1: main calls 1: vc_rd_u32
173func vc_wire_pack(out: *u8, kind: i64, id: *u8, seq: i64, payload: *u8, n: i64) -> i64
183func vc_wire_parse(buf: *u8, n: i64, info: *i64) -> i64
199func vc_f32_bits_to_i16(bits: i64) -> i64
228func vc_i16_to_f32_bits(v: i64) -> i64
248func vc_f32_to_i16(inb: *u8, n_samples: i64, outb: *u8) -> i64
called by 1: main calls 2: vc_rd_u32vc_f32_bits_to_i16
261func vc_i16_to_f32(inb: *u8, n_samples: i64, outb: *u8) -> i64
called by 1: main calls 2: vc_wr_u32vc_i16_to_f32_bits
281func vc_lpc_rd_i16(b: *u8, off: i64) -> i64
288func vc_lpc_wr_i16(b: *u8, idx: i64, v: i64) -> i64
called by 1: vc_lpc_decode
296func vc_lpc_bit_put(b: *u8, pos: i64, bit: i64) -> i64
called by 1: vc_lpc_rice_put
304func vc_lpc_bit_get(b: *u8, cur: *i64, lim: i64) -> i64
called by 1: vc_lpc_rice_get
311func vc_lpc_rice_put(b: *u8, pos: i64, u: i64, k: i64) -> i64
called by 1: vc_lpc_encode calls 1: vc_lpc_bit_put
324func vc_lpc_rice_get(b: *u8, cur: *i64, lim: i64, k: i64) -> i64
called by 1: vc_lpc_decode calls 1: vc_lpc_bit_get
343func vc_lpc_residuals(x: *i64, n: i64, o: i64, u: *i64) -> i64
called by 1: vc_lpc_encode
365func vc_lpc_cost_bits(u: *i64, m: i64, k: i64) -> i64
called by 1: vc_lpc_encode
377func vc_lpc_encode(pcm: *u8, nsamples: i64, out: *u8, outcap: i64, scratch: *i64) -> i64
434func vc_lpc_decode(pl: *u8, plen: i64, out: *u8, outcap: i64, scratch: *i64) -> i64
498func vc_ladder_rungs() -> i64 { return VC_LADDER_RUNGS }
499func vc_ladder_fps(idx: i64) -> i64
511func vc_ladder_q_permille(idx: i64) -> i64
531func vc_ladder_floor(n_peers: i64) -> i64
called by 3: mainmainmain
562func vc_ladder_step(idx: i64, n_rungs: i64, rtt_ms: i64,
called by 1: main
608func vv_init_ctx(base: i64) -> i64 { vc_t8_init((base + VV_CTX_T8C) as *i64); return 0 }
calls 1: vc_t8_init
623func vv_seed_rctx(base: i64, rc: i64, nf: i64, sig: i64, part: i64, deblock: i64, heatp: i64, nftbl: i64, nfscr: i64) -> i64
658func vc_res_tier(cls: i64, flex_all: i64, all818: i64) -> i64
695func vc_gf_mul(tbl: *i64, a: i64, b: i64) -> i64
700func vc_gf_inv(tbl: *i64, a: i64) -> i64 { return tbl[255 - tbl[512 + a]] }
703func vc_fec_init(tbl: *i64) -> i64
called by 3: mainmainmain calls 1: vc_gf_inv
737func vc_fec_encode(tbl: *i64, data: *u8, shards: *u8, S: i64) -> i64
called by 2: mainvc_fecs_pack calls 1: vc_gf_mul
757func vc_fec_decode(tbl: *i64, shards: *u8, erased: *i64, out: *u8, S: i64, scratchA: *i64) -> i64
called by 2: mainvc_fecrx_add calls 2: vc_gf_invvc_gf_mul
819func vc_fecs_shard_size(flen: i64) -> i64 { return (flen + 7) / 8 }
called by 2: mainmain
823func vc_fecs_pack(tbl: *i64, frame: *u8, flen: i64, block_id: i64, scratch_data: *u8, scratch_shards: *u8, out: *u8) -> i64
called by 2: mainmain calls 1: vc_fec_encode
853func vc_fecrx_reset(st: *i64) -> i64
called by 2: mainmain
865func vc_fecrx_add(st: *i64, tbl: *i64, payload: *u8, plen: i64, scratchA: *i64, scratchSh: *u8, out: *u8, outcap: i64) -> i64
called by 2: mainmain calls 1: vc_fec_decode
930func vc_react_pack(out: *u8, idx: i64) -> i64
937func vc_react_parse(pay: *u8, plen: i64) -> i64
943func vc_react_emoji(idx: i64, out: *u8) -> i64
954func vc_chat_pack(out: *u8, name: *u8, nlen: i64, text: *u8, tlen: i64) -> i64
called by 2: mainmain
969func vc_chat_parse(pay: *u8, plen: i64, info: *i64) -> i64
called by 1: main