code wiki / (root) / nx_quant_table.nx

nx_quant_table.nx

buildroot/runtime/nx_quant_table.nx

5167 B136 linesdepth 2pulls 2 transitivereach 20 importersview sourcekind librarytopic quant
docsdependenciesstructsconstsfunctions

about

nx_quant_table.nx -- perceptual quantisation matrices. The two 64-entry tables from ITU-T Recommendation T.81 (JPEG) Annex K -- fully public since 1992 -- give a 30-50% rate-distortion advantage over uniform quantisation at moderate quality on natural images. Math: each post-DCT coefficient at zig-zag position (r,c) is divided by qt[r*8+c], where qt is the quant matrix. Higher divisors for high-frequency coefficients aggressively discard the perceptually-unimportant detail; small divisors for the low-frequency corner preserve structure. Quality factor Q in 1..100 maps to a scale factor: Q >= 50: scale = 200 - 2 * Q (Q=50 -> 100; Q=100 -> 0) Q < 50: scale = 5000 / Q (Q=1 -> 5000; Q=49 -> 102) Then qt[i] = clamp((base[i] * scale + 50) / 100, 1, 255). genealogy_id: itu_t_t_81_1992_annex_k + jpeg_iso_10918_1992 + nx_dct8_q10 lineage_id: nishi_quant_table_q10

dependencies 1 imports · 18 importers

nx_syscalls.nx nx_quant_table.nx nx_cam_poster.nx nx_codec_rd2_gate.nx nx_codec_rd_gate.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_jpeg_block_enc_gate.nx nx_jpeg_color_write.nx

diagram shows first 10 each side; +0 more imports, +8 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_rd2.nxnx_codec_real_rd2f.nxnx_codec_real_rd2g.nxnx_codec_real_rd3.nxnx_galx_thumb_oneshot.nxnx_jpeg_block_enc_gate.nxnx_jpeg_color_write.nxnx_jpeg_color_write_gate.nxnx_jpeg_rst_gate.nxnx_jpeg_write_gate.nxnx_reader_panels_gate.nxnx_reader_tile.nxnx_reader_tile_gate.nxnx_reader_zoomserve_gate.nxnx_video_codec.nx

structs

none

consts

28const NX_MAGIC_5000: i64 = 5000
30const NX_QT_VERDICT_UNKNOWN: i64 = 0
31const NX_QT_VERDICT_OK: i64 = 1
32const NX_QT_VERDICT_BAD_PARAMS: i64 = 2
33const NX_QT_VERDICT_N: i64 = 3

functions

36func _qt_luma_base(out: *i64) -> i64
called by 1: nx_qt_luma
57func _qt_chroma_base(out: *i64) -> i64
called by 1: nx_qt_chroma
78func _qt_scale(base: *i64, scale: i64, qt_out: *i64) -> i64
91func _qt_quality_to_scale(q: i64) -> i64
101func nx_qt_luma(qt_out: *i64, quality: i64) -> i64
111func nx_qt_chroma(qt_out: *i64, quality: i64) -> i64
121func nx_qt_uniform(qt_out: *i64, step: i64) -> i64
132func nx_qt_verdict_is_valid(v: i64) -> i64