nx_dct8.nx
buildroot/runtime/nx_dct8.nx
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 · 27 importers
diagram shows first 10 each side; +0 more imports, +17 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_sigcoder_gate.nxnx_vcodec_tsize_rd_gate.nxnx_video_codec.nx
structs
| none |
consts
| 37 | const NX_DCT8_VERDICT_UNKNOWN: i64 = 0 |
| 38 | const NX_DCT8_VERDICT_OK: i64 = 1 |
| 39 | const NX_DCT8_VERDICT_BAD_PARAMS: i64 = 2 |
| 40 | const NX_DCT8_VERDICT_N: i64 = 3 |
functions
| 46 | func nx_dct8_init(M: *i64) -> i64 |
| 76 | func nx_dct8_forward_1d(M: *i64, x: *i64, y: *i64) -> i64 called by 1: nx_dct8_forward_2d |
| 96 | func nx_dct8_inverse_1d(M: *i64, y: *i64, x: *i64) -> i64 called by 1: nx_dct8_inverse_2d |
| 115 | func nx_dct8_forward_2d(M: *i64, block: *i64, out: *i64, |
| 153 | func nx_dct8_inverse_2d(M: *i64, coeffs: *i64, out: *i64, |
| 191 | func nx_dct8_verdict_is_valid(v: i64) -> i64 |