code wiki / (root) / nx_vcodec_stage_bench_recovery_20260912.nx

nx_vcodec_stage_bench_recovery_20260912.nx

buildroot/runtime/nx_vcodec_stage_bench_recovery_20260912.nx

24580 B384 linesdepth 6pulls 19 transitivereach 0 importersview sourcekind benchtopic vcodec
docsdependenciesstructsconstsfunctions

about

nx_vcodec_stage_bench.nx -- WHERE DOES THE ENCODE TIME GO. Stage attribution of the LIVE rct8 RTC encoder, per macroblock, on the REAL head-to-head test card (the akiyo index-strip card nx_video_h2h judged 2026-09-02). WHY IT EXISTS: the same-instrument head-to-head measured ours at 9.9-18.2 of 30 fps against Jitsi's 29, and the probes' own arming dump showed the cause is encode COST (93 ms single-thread, 48 ms banded at 640x480), not the ladder (30/45/60 rungs exist) and not wasm (native 74 us per MB == browser 77 us per MB). Nothing in the estate attributed that cost to a stage (nx_capsearch 2026-09-02: no encoder stage profiler), so every fix would have been a guess. This organ MEASURES: (A) the whole production frame encode, (B) the integer motion search kernel called once per MB exactly as the block coder calls it, (C) the quarter-pel refine kernel on the CODED MBs (and on all MBs, the ceiling), and derives REST = A - B - C (transform, quant, RDOQ, entropy, recon, deblock). Kernel costs are the cost of ONE call per MB, which is an UPPER BOUND on their share if the encoder early-outs before them. Historical baseline: emode 2593 = range coder + sig-map + gentle deblock + RD-skip. Build 865 additionally enables quiet-quadrant skip (emode 18977); both arms remain in this benchmark. The live skip threshold is qp*30; qp*188 is the separate RD-benchmark control. Two qp points bracket the ladder. Prints one line per stage per qp; last line is the verdict for gv_last_line readers. Card: 352x288, first 120 frames of the h2h card (banked in _ops/video_h2h/testcard120.y4m). license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_video_codec_wasm.nx nx_quality_metric.nx nx_vcodec_stage_bench_recovery

imports: nx_syscalls.nxnx_video_codec_wasm.nxnx_quality_metric.nx

imported by: nobody (leaf or entry point)

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

main sb_is_bd sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close sw sys_write ↻ sb_parse_y4m sb_atoi sys_openat_wr vc_t8_init nx_dct8_init vc_t8p sb_bd sys_mmap ↻ sys_now_us sys_mmap ↻ sys_clock_gettime_mono seedctx vv_enc_rct8 vc_enc_frame_packed_rct8

structs

none

consts

20const SB_W: i64 = 352
21const SB_H: i64 = 288
22const SB_NF: i64 = 120
23const SB_T: i64 = 16
24const SB_QP_A: i64 = 24
25const SB_QP_B: i64 = 32
26const SB_THRESH_LIVE: i64 = 30 // the LIVE worker's skip threshold: app.v2.js passes B(m.qp * 30) to vv_enc_rct8
27const SB_THRESH_RDBENCH: i64 = 188 // the rd bench's value (qp*188 = the measured real-translation band) -- the OTHER convention
28const SB_NOISE_MAX: i64 = 2 // sensor / colour-conversion noise emulation: +-0, +-1, +-2 LSB per luma pixel
29const SB_LCG_A: i64 = 1103515245
30const SB_LCG_C: i64 = 12345
31const SB_LCG_MASK: i64 = 2147483647
32const SB_EMODE_RTC: i64 = 2593 // 1 | 32 | 512 | 2048 -- rc + sig + deblock + rdskip (vv_seed_rctx, RTC room)
33const SB_WIRE_CAP: i64 = 4194304
34const SB_RCBUF: i64 = 2097152
35const SB_T8C_BYTES: i64 = 5120
36const SB_MAXFRAMES: i64 = 1024
37const SB_NS_PER_US: i64 = 1000
44const SB_EMODE_NORDSKIP: i64 = 545 // 2593 - 2048: the RD-skip band trial OFF (rc + sig + deblock)
45const SB_EMODE_NOSIG: i64 = 513 // 545 - 32: sig-map coefficient coder OFF (rc + deblock)
46const SB_EMODE_RCONLY: i64 = 1 // range coder only: no sig-map, no deblock, no RD-skip
47const SB_EMODE_QQ: i64 = 18977 // 2593 | 16384: the live RTC mode plus the quiet-quadrant early skip (VC_EMODE_QQSKIP)
48const SB_EMODE_QQ_HEX: i64 = 51745 // 18977 | 32768: plus the hexagon motion search (VC_EMODE_HEXME)
53const SB_RC_P_HALF: i64 = 2048
121const SB_BD_NF: i64 = 48 // the sweep clock: 48 frames at 30 fps -> kbps_milli = total_bytes*5 (nx_bd_calc contract)
122const SB_BD_KBPS_MUL: i64 = 5
123const SB_BD_NQ: i64 = 5

functions

39func sw(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 3: sb_bdsb_runmain calls 1: sys_write
40func sn(v: i64) -> i64
called by 3: sb_bdsb_runmain calls 2: sys_mmapsys_write
49func seedctx(rctx: *i64, est: *i64, probs: *i64, rcbuf: *u8, t8c: *i64, emode: i64) -> i64
called by 2: sb_bdsb_run
52func cpb(d: *u8, s: *u8, n: i64) -> i64 { var i: i64 = 0; while i < n { d[i] = s[i]; i = i + 1 } return 0 }
called by 3: sb_noisysb_bdsb_run
55func sb_fill_res(blk: *i64, cur: *u8, prev: *u8, W: i64, sx: i64, sy: i64) -> i64
called by 1: sb_run
63func sb_noisy(dst: *u8, src: *u8, sz: i64, n_luma: i64, amp: i64, seed: i64) -> i64
called by 1: sb_run calls 1: cpb
81func sb_wnfd(fd: i64, v: i64, sep: i64) -> i64
called by 1: sb_bd calls 2: sys_mmapsys_write
93func sb_psnr_cdb_sse(s: i64, n: i64) -> i64
called by 1: sb_bd calls 1: qm_log2_q16
100func sb_sse(a: *u8, b: *u8, n: i64) -> i64
called by 1: sb_bd
105func sb_parse_y4m(raw: *u8, total: i64, fp: *i64, maxf: i64) -> i64
called by 1: main
127func sb_bd(fp: *i64, nf: i64, emode: i64, bufs: *i64, ptsfd: i64) -> i64
166func sb_run(fp: *i64, nf: i64, qp: i64, tmult: i64, amp: i64, emode: i64, bufs: *i64) -> i64
293func sb_atoi(a: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while a[i] != (0 as u8) { v = v * 10 + ((a[i] as i64 & 0xff) - 48); i = i + 1 } return v }
called by 1: main
294func sb_is_bd(a: *u8) -> i64 { if a[0] != (98 as u8) { return 0 } if a[1] != (100 as u8) { return 0 } if a[2] != (0 as u8) { return 0 } return 1 }
295func main(argc: i64, argv: *i64) -> i64