code wiki / (root) / nx_av1_txfm.nx

nx_av1_txfm.nx

buildroot/runtime/nx_av1_txfm.nx

6501 B205 linesdepth 2pulls 2 transitivereach 7 importersview sourcekind librarytopic av1
docsdependenciesstructsconstsfunctions

about

nx_av1_txfm.nx -- AV1/AV2 transform primitives. Layer six, the last one before actual residual reconstruction. Everything here is integer and bit-exact by mandate: an inverse transform that is off by one anywhere drifts the reference frames apart from the encoder's, and the picture degrades over a GOP rather than failing. Round2 AND Round2Signed BOTH EXIST AND DIFFER. Round2 adds half and arithmetic-shifts, so it rounds negatives toward positive infinity: Round2(-3, 1) is -1. Round2Signed rounds AWAY from zero by construction: Round2Signed(-3, 1) is -2. The spec uses each in specific places and they are not interchangeable -- substituting one for the other produces a transform that is correct on non-negative input and half-wrong on real signal, which is exactly the kind of defect that survives a smoke test. THE COSINE TABLE IS 12-BIT AND QUARTER-PERIOD. Cos128_Lookup holds only angles 0..64; the other three quadrants are reflections with sign flips. Getting a quadrant sign wrong inverts half the basis functions, which decodes to a recognisable but wrong image -- it does not look like noise, so it is easy to ship. THE WHT IS EXACTLY INVERTIBLE. The lossless path's Walsh-Hadamard pair is integer-exact in both directions, which makes it the one transform provable by pure round-trip rather than against reference vectors. genealogy_id: av1_spec_7_13_inverse_transform lineage_id: nx_av1_txfm_v1 license_tier: ORIGINAL

dependencies 1 imports · 7 importers

nx_syscalls.nx nx_av1_txfm.nx nx_av1_adst.nx nx_av1_adst_gate.nx nx_av1_dct.nx nx_av1_dct_gate.nx nx_av1_txfm2d.nx nx_av1_txfm2d_gate.nx nx_av1_txfm_gate.nx

imports: nx_syscalls.nx

imported by: nx_av1_adst.nxnx_av1_adst_gate.nxnx_av1_dct.nxnx_av1_dct_gate.nxnx_av1_txfm2d.nxnx_av1_txfm2d_gate.nxnx_av1_txfm_gate.nx

structs

none

consts

32const NX_TX_COS_BITS: i64 = 12
33const NX_TX_COS_ONE: i64 = 4096

functions

37func nx_av1_round2(x: i64, n: i64) -> i64
42func nx_av1_round2_signed(x: i64, n: i64) -> i64
called by 1: main calls 1: nx_av1_round2
51func nx_av1_brev(num_bits: i64, x: i64) -> i64
65func nx_av1_clamp(v: i64, lo: i64, hi: i64) -> i64
called by 1: main
76func nx_av1_cos_table(t: *i64) -> i64
called by 4: mainmainmainmain
98func nx_av1_cos128(t: *i64, angle: i64) -> i64
106func nx_av1_sin128(t: *i64, angle: i64) -> i64
115func nx_av1_fwht4(inp: *i64, out: *i64) -> i64
called by 1: main
134func nx_av1_iwht4(inp: *i64, out: *i64, shift: i64) -> i64
called by 1: main
159func nx_av1_identity4(v: i64) -> i64
called by 1: main calls 1: nx_av1_round2
163func nx_av1_identity8(v: i64) -> i64
called by 1: main
167func nx_av1_identity16(v: i64) -> i64
called by 1: main calls 1: nx_av1_round2
171func nx_av1_identity32(v: i64) -> i64
called by 1: main
181func nx_av1_butterfly_b(t: *i64, arr: *i64, a: i64, b: i64, angle: i64, flip: i64) -> i64
196func nx_av1_butterfly_h(arr: *i64, a: i64, b: i64, flip: i64) -> i64
called by 1: main