code wiki / (root) / nx_dct8.nx

nx_dct8.nx

buildroot/runtime/nx_dct8.nx

6576 B195 linesdepth 2pulls 2 transitivereach 142 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_dct8.nx -- 8x8 integer DCT-II in pure NishiLang. The universal frequency-domain transform that underlies every modern video codec (JPEG, MPEG-1/2/4, H.261/263/264/265, AV1's DCT mode). We re-derive from the public math (Ahmed, Natarajan, Rao 1974; Chen, Smith, Fralick 1977; Loeffler, Ligtenberg, Moschytz 1989) -- not from any patented codec's reference code. Math: 1D DCT-II of size 8: X_k = (1/2) c_k * sum_{n=0..7} x_n * cos((2n+1) k pi / 16) c_0 = 1/sqrt(2); c_k = 1 (k > 0) 2D 8x8 DCT: apply 1D DCT row-by-row, then column-by-column on transposed result. Equivalent to multiplying by the DCT matrix on both sides: Y = D X D^T. Fixed-point: every cosine entry is precomputed as Q10 (scale-by-1024) and stored in a caller-supplied 64-entry matrix buffer M. After each row/column pass we shift right by 10 to renormalise. Error budget is bounded by a few units in i64 at full scale; the smoke verifies round-trip reconstruction within 8 units. genealogy_id: ahmed_natarajan_rao_1974_dct + chen_smith_fralick_1977 + loeffler_ligtenberg_moschytz_1989_fast_dct + jpeg_iso_10918_1992 lineage_id: nishi_dct8_q10

dependencies 1 imports · 29 importers

nx_syscalls.nx nx_dct8.nx nx_cam_poster.nx nx_codec_rd2_gate.nx nx_codec_rd_gate.nx nx_codec_real_rd.nx nx_codec_real_rd2.nx nx_codec_real_rd2f.nx nx_codec_real_rd2g.nx nx_codec_real_rd3.nx nx_galx_thumb_oneshot.nx nx_intra_block_gate.nx

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

imports: nx_syscalls.nx

imported by: nx_cam_poster.nxnx_codec_rd2_gate.nxnx_codec_rd_gate.nxnx_codec_real_rd.nxnx_codec_real_rd2.nxnx_codec_real_rd2f.nxnx_codec_real_rd2g.nxnx_codec_real_rd3.nxnx_galx_thumb_oneshot.nxnx_intra_block_gate.nxnx_intra_image_gate.nxnx_jpeg_block_enc_gate.nxnx_jpeg_color_write.nxnx_jpeg_color_write_gate.nxnx_jpeg_decoder.nxnx_jpeg_rst_gate.nxnx_jpeg_write.nxnx_jpeg_write_gate.nxnx_reader_panels_gate.nxnx_reader_tile.nxnx_reader_tile_gate.nxnx_reader_zoomserve_gate.nxnx_vcodec.nxnx_vcodec_entropy_gap.nxnx_vcodec_ffv1_entropy_gate.nxnx_vcodec_neural_entropy_gate.nxnx_vcodec_sigcoder_gate.nxnx_vcodec_tsize_rd_gate.nxnx_video_codec.nx

structs

none

consts

37const NX_DCT8_VERDICT_UNKNOWN: i64 = 0
38const NX_DCT8_VERDICT_OK: i64 = 1
39const NX_DCT8_VERDICT_BAD_PARAMS: i64 = 2
40const NX_DCT8_VERDICT_N: i64 = 3

functions

46func nx_dct8_init(M: *i64) -> i64
76func nx_dct8_forward_1d(M: *i64, x: *i64, y: *i64) -> i64
called by 1: nx_dct8_forward_2d
96func nx_dct8_inverse_1d(M: *i64, y: *i64, x: *i64) -> i64
called by 1: nx_dct8_inverse_2d
115func nx_dct8_forward_2d(M: *i64, block: *i64, out: *i64,
153func nx_dct8_inverse_2d(M: *i64, coeffs: *i64, out: *i64,
191func nx_dct8_verdict_is_valid(v: i64) -> i64