code wiki / (root) / nx_video_codec_wasm.nx

nx_video_codec_wasm.nx

buildroot/runtime/nx_video_codec_wasm.nx

43008 B690 linesdepth 5pulls 15 transitivereach 77 importersview sourcekind librarytopic video
docsdependenciesstructsconstsfunctions

about

nx_video_codec_wasm.nx -- the SOVEREIGN video codec on the WIRE (task #27): YUV420 color wrapper over the gated nx_vcodec (key + P-frames, motion comp, WHT/DCT, deadzone quant -- realseq gate 42.89dB bit-exact). This replaces the browser's JPEG encoder (the last third-party in the media path and the 2026-07-05 field-call bitrate killer: JPEG ~8-15x the vcodec at the same fps -> phone uplink saturation -> 4fps chop). Pure integer, allocates nothing, flat args -> compiles UNCHANGED to wasm (3rd-party browsers, via nx_compile_wat) AND native (NishiOS client) -- one codec, every target, no host encoder. WIRE STREAM (one frame): [ybytes:u32 LE][ubytes:u32 LE][vbytes:u32 LE][Y stream][U stream][V stream] Planes are independently packed nx_vcodec streams (self-describing key/P per block); U/V are quarter-res (W/2 x H/2). qp rides the room wire header (kind 0x57), NOT this stream. license_tier: ORIGINAL

dependencies 2 imports · 62 importers

nx_vcodec.nx nx_vcodec_nf.nx nx_video_codec_wasm.nx nx_faithdiff_probe.nx nx_v128_share_probe.nx nx_vcodec_832_twin.nx nx_vcodec_band_gate.nx nx_vcodec_bandwire_gate.nx nx_vcodec_bgop_bench.nx nx_vcodec_bitalloc_gate.nx nx_vcodec_bitsplit_gate.nx nx_vcodec_cdef_gate.nx nx_vcodec_compound_ceil.nx

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

imports: nx_vcodec.nxnx_vcodec_nf.nx

imported by: nx_faithdiff_probe.nxnx_v128_share_probe.nxnx_vcodec_832_twin.nxnx_vcodec_band_gate.nxnx_vcodec_bandwire_gate.nxnx_vcodec_bgop_bench.nxnx_vcodec_bitalloc_gate.nxnx_vcodec_bitsplit_gate.nxnx_vcodec_cdef_gate.nxnx_vcodec_compound_ceil.nxnx_vcodec_coverage_gate.nxnx_vcodec_deblock8_gate.nxnx_vcodec_deblock_gate.nxnx_vcodec_drift_bench.nxnx_vcodec_drift_diag.nxnx_vcodec_drift_gate.nxnx_vcodec_emode_gate.nxnx_vcodec_entcost_probe.nxnx_vcodec_handoff_bench.nxnx_vcodec_heataq.nxnx_vcodec_hpel6_probe.nxnx_vcodec_i16ceil_gate.nxnx_vcodec_intra9_gate.nxnx_vcodec_intrap_gate.nxnx_vcodec_layout_gate.nxnx_vcodec_live_noise_probe.nxnx_vcodec_look_dump.nxnx_vcodec_msu_hp.nxnx_vcodec_msu_hp2.nxnx_vcodec_msu_ours.nxnx_vcodec_msu_ours11.nxnx_vcodec_msu_ours12.nxnx_vcodec_msu_ours13.nxnx_vcodec_msu_ours8.nxnx_vcodec_mvbits_probe.nxnx_vcodec_nf_gate.nxnx_vcodec_nf_train.nxnx_vcodec_part8_gate.nxnx_vcodec_predceiling_gate.nxnx_vcodec_pskip_probe.nxnx_vcodec_pt8_gate.nxnx_vcodec_quality_probe.nxnx_vcodec_rc_frame_gate.nxnx_vcodec_rd_bench.nxnx_vcodec_rdskip_gate.nxnx_vcodec_satd16_gate.nxnx_vcodec_seqdiag_gate.nxnx_vcodec_sigwire_gate.nxnx_vcodec_skiprate_gate.nxnx_vcodec_stdemit.nxnx_vcodec_stdseq_gate.nxnx_vcodec_subpel_ceil.nxnx_vcodec_t8_gate.nxnx_vcodec_t8blk_gate.nxnx_vcodec_t8feat_gate.nxnx_vcodec_t8noise_gate.nxnx_vcodec_t8rd_gate.nxnx_vcodec_tf_speed.nxnx_vcodec_timing_probe.nxnx_video_client_wasm.nxnx_video_codec_wasm_gate.nxnx_video_native_gate.nx

structs

none

consts

121const VC_DRIFT_RING: i64 = 16

functions

15func vv_clamp255(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v }
19func vv_rgba_to_yuv420(rgba: *u8, W: i64, H: i64, yuv: *u8) -> i64 {
called by 1: main calls 1: vv_clamp255
57func vv_yuv420_to_rgba(yuv: *u8, W: i64, H: i64, rgba: *u8) -> i64 {
called by 1: main calls 1: vv_clamp255
82func vv_wr_u32(p: *u8, off: i64, v: i64) -> i64 {
89func vv_rd_u32b(p: *u8, off: i64) -> i64 {
96func vv_iabs(x: i64) -> i64 { if x < 0 { return 0 - x } return x }
102func vc_recon_hash(recon: *u8, W: i64, H: i64) -> i64 {
called by 1: main
122func vc_drift_reset(st: *i64) -> i64 {
called by 2: mainmain
127func vc_drift_push(st: *i64, hash: i64, n: i64, qp: i64, fl: i64, w: i64, h: i64) -> i64 {
called by 2: mainmain
136func vc_drift_verify(st: *i64, myhash: i64, n: i64, qp: i64, fl: i64, w: i64, h: i64) -> i64 {
called by 2: mainmain
153func vc_drift_count(st: *i64) -> i64 { return st[2] }
called by 1: main
160func vv_deblock_plane(p: *u8, W: i64, H: i64, qp: i64, gentle: i64) -> i64 {
called by 2: nf_runvv_deblock calls 2: vv_iabsvv_clamp255
197func vv_deblock(recon: *u8, W: i64, H: i64, qp: i64, gentle: i64) -> i64 {
206func vv_enc(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad: i64,
228func vv_dec(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64) -> i64 {
249func vv_enc_rc(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
264func vv_dec_rc(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
297func vv_nf_enc(cur: *u8, recon: *u8, W: i64, H: i64, qp: i64, ybuf: *u8, nfbit: i64, tr: *u8, rctx: *i64) -> i64 {
343func vv_nf_dec(recon: *u8, W: i64, H: i64, qp: i64, ybuf: *u8, nfbit: i64, tr: *u8, rctx: *i64) -> i64 {
367func vv_nf_trlen(H: i64, ybuf: *u8, nfbit: i64) -> i64 {
called by 2: vv_dec_t8vv_dec_rct8 calls 1: nx_br_get
377func vv_enc_t8(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
400func vv_dec_t8(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
422func vv_enc_rct8(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
446func vv_dec_rct8(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
474func vv_enc_b(cur: *u8, past: *u8, fut: *u8, recon: *u8, W: i64, H: i64, qp: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
494func vv_dec_b(past: *u8, fut: *u8, recon: *u8, W: i64, H: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
517func vv_enc_rct9(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
537func vv_dec_rct9(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
565func vv_deblock_plane_band(p: *u8, W: i64, H: i64, y0: i64, y1: i64, qp: i64) -> i64 {
called by 1: vv_deblock_band calls 2: vv_iabsvv_clamp255
589func vv_deblock_band(recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64) -> i64 {
595func vv_enc_band(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, keyframe: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64) -> i64 {
606func vv_dec_band(prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64) -> i64 {
629func vv_deblock_plane_band_g(p: *u8, W: i64, H: i64, y0: i64, y1: i64, qp: i64, gentle: i64) -> i64 {
called by 1: vv_deblock_band2 calls 2: vv_iabsvv_clamp255
654func vv_deblock_band2(recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, gentle: i64) -> i64 {
660func vv_enc_rct8_band(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, keyframe: i64, sad: i64, out: *u8, out_cap: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {
676func vv_dec_rct8_band(prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, in_: *u8, in_len: i64, blk: *i64, mv: *i64, rctx: *i64) -> i64 {