code wiki / (root) / nx_vcodec_nf.nx

nx_vcodec_nf.nx

buildroot/runtime/nx_vcodec_nf.nx

4339 B92 linesdepth 2pulls 2 transitivereach 78 importersview sourcekind librarytopic vcodec
docsdependenciesstructsconstsfunctions

about

nx_vcodec_nf.nx -- LEARNED decoder-side RESTORATION FILTER (NEURAL track rung 1, task #46; operator 2026-07-07: "achieve true neural sota as we climb ... and these things are all going live"). A data-TRAINED piecewise-linear restorer (RAISR/Wiener-class -- the same family as AV1's loop restoration): every interior pixel of the DEBLOCKED recon is classified by its local gradient (flat + 4 directions x 2 strengths = 9 classes) inside a qp band (3 bands), and restored by that class's TRAINED 3x3+bias filter (Q12 integer weights, trained by nx_vcodec_nf_train on (our-codec-recon -> source) pairs from REAL frames -- no floats anywhere, sovereign end to end). DISPLAY-PATH ONLY by design: the P-reference chain keeps the unfiltered recon (bit-exactness of the codec is untouched; a receiver applies this after decode, before YUV->RGBA). The trained table is caller-provided (vc_nf_load from the GENERATED nx_vcodec_nf_table.nx fills it) -- this module stays allocation-free and wasm-clean. license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_vcodec_nf.nx nx_vcodec_nf_train.nx nx_video_codec_wasm.nx

imports: nx_syscalls.nx

imported by: nx_vcodec_nf_train.nxnx_video_codec_wasm.nx

structs

none

consts

14const VC_NF_CLASSES: i64 = 9 // 0=flat, 1..4 = H/V/D1/D2 moderate, 5..8 = H/V/D1/D2 strong
15const VC_NF_BANDS: i64 = 3 // qp bands: <16, 16..27, >=28 (quant noise scales with qp)
16const VC_NF_TAPS: i64 = 10 // 3x3 raster taps + bias, Q12
17const VC_NF_TBL: i64 = 270 // table length in i64 (bands * classes * taps)

functions

19func vc_nf_band(qp: i64) -> i64
called by 2: vc_nf_applynf_run
27func vc_nf_class(gx: i64, gy: i64) -> i64
called by 2: vc_nf_applynf_run
47func vc_nf_apply(src: *u8, W: i64, H: i64, out: *u8, qp: i64, tbl: *i64) -> i64
86func vc_nf_identity(tbl: *i64) -> i64
called by 1: main