code wiki / (root) / nx_vcodec.nx

nx_vcodec.nx

buildroot/runtime/nx_vcodec.nx

150261 B2476 linesdepth 4pulls 13 transitivereach 107 importersview sourcekind librarytopic vcodec
docsdependenciesstructsconstsfunctions

about

nx_vcodec.nx -- the reusable sovereign video codec MODULE. The proven end-to-end encoder (intra keyframe with H.264-style DC prediction + inter-frame 16x16 motion compensation + 4x4 WHT transform + deadzone quant + zig-zag/RLE entropy), EXTRACTED from nx_vcodec_gate (V-R5, GREEN: keyframe 459B, inter avg 114B, 7x less than full-JPEG/frame, inter max-err 4/255) so the vroom daemon and the gate share ONE codec instead of duplicating it (DRY). The current nishifamily.com/video 8fps sends a full JPEG every frame; this is the delta-chain encoder that replaces it. Caller owns all scratch: ebuf (per-block bitstream bytes), blk (16 i64), mv (2 i64). The codec allocates nothing. license_tier: ORIGINAL

dependencies 10 imports · 26 importers

nx_vmotion.nx nx_vtransform.nx nx_vtransform_dct.nx nx_vtransform_dct2.nx nx_dct8.nx nx_ventropy.nx nx_rangecoder.nx nx_rangecoder_sig.nx nx_vskip.nx nx_vsubpel.nx nx_vcodec.nx nx_vcodec_color_codec.nx nx_vcodec_color_wasm.nx nx_vcodec_dct2_rd_gate.nx nx_vcodec_entropy_gap.nx nx_vcodec_exceed_census.nx nx_vcodec_ffv1_entropy_gate.nx nx_vcodec_gate.nx nx_vcodec_golomb_gate.nx nx_vcodec_gop_vm_gate.nx nx_vcodec_inloop_gate.nx

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

imports: nx_vmotion.nxnx_vtransform.nxnx_vtransform_dct.nxnx_vtransform_dct2.nxnx_dct8.nxnx_ventropy.nxnx_rangecoder.nxnx_rangecoder_sig.nxnx_vskip.nxnx_vsubpel.nx

imported by: nx_vcodec_color_codec.nxnx_vcodec_color_wasm.nxnx_vcodec_dct2_rd_gate.nxnx_vcodec_entropy_gap.nxnx_vcodec_exceed_census.nxnx_vcodec_ffv1_entropy_gate.nxnx_vcodec_gate.nxnx_vcodec_golomb_gate.nxnx_vcodec_gop_vm_gate.nxnx_vcodec_inloop_gate.nxnx_vcodec_inter_vm_gate.nxnx_vcodec_ltr_gate.nxnx_vcodec_luma32_vm_gate.nxnx_vcodec_mrbits_gate.nxnx_vcodec_neural_entropy_gate.nxnx_vcodec_packed_gate.nxnx_vcodec_quarter_gate.nxnx_vcodec_rdoq2_gate.nxnx_vcodec_realframe_gate.nxnx_vcodec_realseq_gate.nxnx_vcodec_sigcoder_gate.nxnx_vcodec_subpel_gate.nxnx_vcodec_tile_gate.nxnx_vcodec_wasm.nxnx_video_codec_wasm.nxnx_wasm_vm_exec_gate.nx

structs

none

consts

18const VC_MAGIC_2147483647: i64 = 2147483647
19const VC_MAGIC_8192: i64 = 8192
20const VC_MAGIC_4096: i64 = 4096
21const VC_MAGIC_5008: i64 = 5008
22const VC_MAGIC_1152921504606846976: i64 = 1152921504606846976
23const VC_MAGIC_5392: i64 = 5392
24const VC_MAGIC_2048: i64 = 2048
25const VC_MAGIC_5440: i64 = 5440
160const VC_RDOQ_LAM_DIV: i64 = 4
277const VC_T8_M: i64 = 0 // [0..63] DCT8 basis matrix (nx_dct8_init)
278const VC_T8_ZZ: i64 = 64 // [64..127] 8x8 zig-zag scan table
279const VC_T8_WORK: i64 = 128 // [128..191] spatial residual in / recon residual out
280const VC_T8_FREQ: i64 = 192 // [192..255] frequency coeffs / quant indices
281const VC_T8_SCR: i64 = 256 // [256..319] 2D transform scratch (first 16 doubling as the RD 4x4 trial block)
282const VC_T8_TA: i64 = 320 // [320..327] 1D transform tmp in
283const VC_T8_TB: i64 = 328 // [328..335] 1D transform tmp out
284const VC_T8_TE: i64 = 336 // [336..351] intra top edge incl above-right (up to 2n = 16 px)
285const VC_T8_LE: i64 = 352 // [352..359] intra left edge (up to 8 px)
286const VC_T8_MM: i64 = 360 // [360..367] in-MB mode memory (above-mode per sub-block column, MPM)
287const VC_T8_EO: i64 = 368 // [368..369] edge-gather out: [corner, dc] (survives the transform temps)
288const VC_T8_RES: i64 = 370 // [370..625] 16x16 MB residual for the RD transform-size trial
289const VC_T8_SIZE: i64 = 626 // slab length in i64 elements
296const VC_ME_R: i64 = 16
994const VC_MVPACK0: i64 = 33558528 // (0+4096)*8192 + (0+4096)
998const VC_RDSK_LO_DIV: i64 = 4
999const VC_RDSK_HI_MUL: i64 = 8
1004const VC_TE_H16_MV0: i64 = 0 // 16x16 argmin dx (restored around the quadrant trial)
1005const VC_TE_H16_MV1: i64 = 1 // 16x16 argmin dy
1006const VC_TE_H16_SAD: i64 = 4 // 16x16 integer-search SAD
1100const VC_EO_PART: i64 = 30 // skip partition evaluation when refined-16x16-adjacent SAD < qp*30
1101const VC_EO_T8: i64 = 20 // skip the transform trial (default 4x4) when refined 16x16 SAD < qp*20
2091const VC_HEAT_STREAK: i64 = 4
2092const VC_HEAT_DIV: i64 = 2
2093const VC_HEAT_SKIPBITS: i64 = 4
2311const VC_SKIPCTX: i64 = 24

functions

28func vc_vbits(v: i64) -> i64 { return 5 + ve_blen(ve_zze(v)) }
called by 2: vc_enc_blockmain calls 2: ve_blenve_zze
32func vc_enc_sub(blk: *i64, qp: i64, ebuf: *u8) -> i64
42func vc_dc_pred(recon: *u8, W: i64, sx: i64, sy: i64) -> i64
called by 1: vc_enc_block
54func vc_pred_px(mode: i64, xx: i64, yy: i64, t0: i64, t1: i64, t2: i64, t3: i64, l0: i64, l1: i64, l2: i64, l3: i64, corner: i64, dc: i64) -> i64
65func vc_enc_block(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, bx: i64, by: i64, qp: i64, keyframe: i64, sad_thresh: i64, ebuf: *u8, blk: *i64, mv: *i64) -> i64
133func vc_enc_frame(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad_thresh: i64, ebuf: *u8, blk: *i64, mv: *i64) -> i64
called by 1: main calls 1: vc_enc_block
171func vc_enc_sub_at(blk: *i64, qp: i64, buf: *u8, bp: i64) -> i64 { return vc_enc_sub_at_tf(blk, qp, buf, bp, 0) }
176func vc_enc_sub_at_tf(blk: *i64, qp: i64, buf: *u8, bp: i64, tf: i64) -> i64
186func vc_dec_sub_at(buf: *u8, bp: i64, qp: i64, blk: *i64) -> i64 { return vc_dec_sub_at_tf(buf, bp, qp, blk, 0) }
187func vc_dec_sub_at_tf(buf: *u8, bp: i64, qp: i64, blk: *i64, tf: i64) -> i64
195func vc_enc_sub_rc(blk: *i64, qp: i64, est: *i64, rcbuf: *u8, probs: *i64, tf: i64) -> i64
201func vc_dec_sub_rc(est: *i64, rcbuf: *u8, probs: *i64, qp: i64, blk: *i64, tf: i64) -> i64
209func vc_enc_sub_sig(blk: *i64, qp: i64, est: *i64, rcbuf: *u8, probs: *i64, tf: i64, n: i64, wd: i64, sigmap: *i64) -> i64
215func vc_dec_sub_sig(est: *i64, rcbuf: *u8, probs: *i64, qp: i64, blk: *i64, tf: i64, n: i64, wd: i64, sigmap: *i64) -> i64
223func vc_coeff_enc(blk: *i64, qp: i64, buf: *u8, bp: i64, tf: i64, rctx: *i64) -> i64
230func vc_coeff_dec(buf: *u8, bp: i64, qp: i64, blk: *i64, tf: i64, rctx: *i64) -> i64
243func vc_mb_mad(cur: *u8, W: i64, cx: i64, cy: i64) -> i64
252func vc_aq_level(mad: i64) -> i64
257func vc_aq_qp(qp: i64, level: i64) -> i64 { // IDENTICAL on enc + dec
298func vc_t8p(t8c: *i64, off: i64) -> *i64 { return ((t8c as i64) + off * 8) as *i64 }
309func vc_mb_t8_ok(cur: *u8, W: i64, cx: i64, cy: i64) -> i64
338func vc_t8_init(t8c: *i64) -> i64
355func vc_quant8(f: *i64, q: i64) -> i64
369func vc_dequant8(f: *i64, q: i64) -> i64
404func vt2_quant_rdoq(blk: *i64, q: i64) -> i64
436func vc_rdoq8(lev: *i64, c8: *i64, q: i64, zz8: *i64) -> i64
463func vc_enc_sub8_tail(t8c: *i64, qp: i64, buf: *u8, bp0: i64, rctx: *i64, sigscr: *i64) -> i64
483func vc_enc_sub8(t8c: *i64, qp: i64, buf: *u8, bp0: i64, rctx: *i64) -> i64
497func vc_dec_sub8(buf: *u8, bp0: i64, qp: i64, t8c: *i64, rctx: *i64) -> i64
527func vc_pred_rich(mode: i64, xx: i64, yy: i64, n: i64, T: *i64, L: *i64, corner: i64, dc: i64) -> i64
581func vc_gather_edges(recon: *u8, W: i64, sx: i64, sy: i64, n: i64, ytop: i64, ar: i64, T: *i64, L: *i64, out: *i64) -> i64
643func vc_mpm_put(buf: *u8, bp: i64, mode: i64, pred: i64) -> i64
650func vc_mpm_val(buf: *u8, bp: i64, pred: i64) -> i64
656func vc_mpm_len(buf: *u8, bp: i64) -> i64
663func vc_mpm_pred(mm: *i64, si: i64, sj: i64, leftmode: i64) -> i64
674func vc_enc_mb8_intra(cur: *u8, recon: *u8, W: i64, cx: i64, cy: i64, ytop: i64, qp: i64, buf: *u8, bp0: i64, t8c: *i64, rctx: *i64) -> i64
734func vc_dec_mb8_intra(recon: *u8, W: i64, cx: i64, cy: i64, ytop: i64, qp: i64, buf: *u8, bp0: i64, t8c: *i64, rctx: *i64) -> i64
775func vc_enc_mb4r_intra(cur: *u8, recon: *u8, W: i64, cx: i64, cy: i64, ytop: i64, qp: i64, tf: i64, buf: *u8, bp0: i64, blk: *i64, t8c: *i64, rctx: *i64) -> i64
834func vc_dec_mb4r_intra(recon: *u8, W: i64, cx: i64, cy: i64, ytop: i64, qp: i64, tf: i64, buf: *u8, bp0: i64, blk: *i64, t8c: *i64, rctx: *i64) -> i64
880func vc_enc_mb8_inter(cur: *u8, prev: *u8, recon: *u8, W: i64, cx: i64, cy: i64, qp: i64, mvx: i64, mvy: i64, bqx: i64, bqy: i64, buf: *u8, bp0: i64, t8c: *i64, rctx: *i64, pfresh: i64) -> i64
922func vc_dec_mb8_inter(prev: *u8, recon: *u8, W: i64, cx: i64, cy: i64, qp: i64, mvx: i64, mvy: i64, bqx: i64, bqy: i64, buf: *u8, bp0: i64, t8c: *i64, rctx: *i64) -> i64
956func vc_mvcost(v: i64) -> i64 { return 5 + ve_blen(ve_zze(v)) } // bits ve_vput(v) would emit (RD MV cost, no write)
963func vc_gput(buf: *u8, bp0: i64, v: i64) -> i64
974func vc_gget(buf: *u8, bpbox: *i64) -> i64
called by 2: vc_dec_block_packed_emain calls 1: nx_br_get
1007func vc_mvplane_row0(mvp: *i64, BW: i64) -> i64
1012func vc_mvplane_nextrow(mvp: *i64, BW: i64) -> i64
1017func vc_mvmed3(a: i64, b: i64, c: i64) -> i64
called by 1: vc_mvpred
1024func vc_mvpred(mvp: *i64, BW: i64, bx: i64, pxy: *i64) -> i64
1038func vc_mvplane_set(mvp: *i64, BW: i64, bx: i64, mvx: i64, mvy: i64) -> i64
1046func vc_intra_dc_sad(cur: *u8, recon: *u8, W: i64, cx: i64, cy: i64) -> i64
1059func vc_me8(cur: *u8, prev: *u8, W: i64, H: i64, sx: i64, sy: i64, mv: *i64, bq: *i64, qp: i64, scr3: *i64) -> i64
1106func vc_rd_part_inter(cur: *u8, prev: *u8, W: i64, H: i64, cx: i64, cy: i64, qp: i64, scr: *i64) -> i64
1142func vc_enc_mb_part8_inter(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, cx: i64, cy: i64, qp: i64, buf: *u8, bp0: i64, t8c: *i64, rctx: *i64) -> i64
1173func vc_dec_mb_part8_inter(prev: *u8, recon: *u8, W: i64, cx: i64, cy: i64, qp: i64, buf: *u8, bp0: i64, t8c: *i64, rctx: *i64) -> i64
1214func vc_rd_t8_inter(cur: *u8, prev: *u8, recon: *u8, W: i64, cx: i64, cy: i64, qp: i64, mvx: i64, mvy: i64, bqx: i64, bqy: i64, tf: i64, rctx: *i64, jout: *i64) -> i64
1313func vc_rd_part_inter_rc(cur: *u8, prev: *u8, W: i64, H: i64, cx: i64, cy: i64, qp: i64, tf: i64, rctx: *i64) -> i64
1376func vc_satd4_d(d: *i64) -> i64
called by 1: vc_satd16_cand
1414func vc_satd16_cand(cur: *u8, prev: *u8, W: i64, cx: i64, cy: i64, px: i64, py: i64, tqx: i64, tqy: i64, limit: i64, sd: *i64) -> i64
called by 1: vc_enc_block_packed_i calls 1: vc_satd4_d
1450func vc_enc_block_packed(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, bx: i64, by: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, bp0: i64, blk: *i64, mv: *i64, tfy: i64) -> i64
1465func vc_rdskip_len(est: *i64, scr: *i64, rcbuf: *u8) -> i64
1471func vc_enc_block_packed_e(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, bx: i64, by: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, bp0: i64, blk: *i64, mv: *i64, tfy: i64, rctx: *i64) -> i64
1532func vc_enc_block_packed_i(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, bx: i64, by: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, bp0: i64, blk: *i64, mv: *i64, tfy: i64, rctx: *i64) -> i64
1837func vc_dec_block_packed(prev: *u8, recon: *u8, W: i64, H: i64, bx: i64, by: i64, qp: i64, keyframe: i64, buf: *u8, bp0: i64, blk: *i64, mv: *i64, tfy: i64) -> i64
1840func vc_dec_block_packed_e(prev: *u8, recon: *u8, W: i64, H: i64, bx: i64, by: i64, qp: i64, keyframe: i64, buf: *u8, bp0: i64, blk: *i64, mv: *i64, tfy: i64, rctx: *i64) -> i64
1963func vc_enc_frame_packed(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64) -> i64
1966func vc_enc_frame_packed_tf(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64) -> i64
1977func vc_dec_frame_packed(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64) -> i64
1980func vc_dec_frame_packed_tf(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64) -> i64
1993func vc_enc_frame_packed_rc(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2010func vc_dec_frame_packed_rc(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2034func vc_enc_frame_packed_t8(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2063func vc_dec_frame_packed_t8(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2094func vc_enc_frame_packed_rct8(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2154func vc_enc_frame_packed_rct8_region(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2197func vc_dec_frame_packed_rct8_region(prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2218func vc_dec_frame_packed_rct8(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2246func vc_enc_frame_packed_b(cur: *u8, past: *u8, fut: *u8, recon: *u8, W: i64, H: i64, qp: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2279func vc_dec_frame_packed_b(past: *u8, fut: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2312func vc_mbcopy(recon: *u8, prev: *u8, W: i64, cx: i64, cy: i64) -> i64
2317func vc_mbssd(a: *u8, b: *u8, W: i64, cx: i64, cy: i64) -> i64
2323func vc_enc_frame_packed_rct9(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2415func vc_dec_frame_packed_rct9(prev: *u8, recon: *u8, W: i64, H: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64, rctx: *i64) -> i64
2458func vc_enc_frame_packed_region(cur: *u8, prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, keyframe: i64, sad_thresh: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64) -> i64
2467func vc_dec_frame_packed_region(prev: *u8, recon: *u8, W: i64, H: i64, by0: i64, by1: i64, qp: i64, buf: *u8, blk: *i64, mv: *i64, tf: i64) -> i64