nx_quant_table.nx
buildroot/runtime/nx_quant_table.nx
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
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
| 28 | const NX_MAGIC_5000: i64 = 5000 |
| 30 | const NX_QT_VERDICT_UNKNOWN: i64 = 0 |
| 31 | const NX_QT_VERDICT_OK: i64 = 1 |
| 32 | const NX_QT_VERDICT_BAD_PARAMS: i64 = 2 |
| 33 | const NX_QT_VERDICT_N: i64 = 3 |
functions
| 36 | func _qt_luma_base(out: *i64) -> i64 called by 1: nx_qt_luma |
| 57 | func _qt_chroma_base(out: *i64) -> i64 called by 1: nx_qt_chroma |
| 78 | func _qt_scale(base: *i64, scale: i64, qt_out: *i64) -> i64 |
| 91 | func _qt_quality_to_scale(q: i64) -> i64 |
| 101 | func nx_qt_luma(qt_out: *i64, quality: i64) -> i64 called by 16: encode_jpegmainmainmainmainmain+10 calls 4: sys_mmap_qt_luma_base_qt_quality_to_scale_qt_scale |
| 111 | func nx_qt_chroma(qt_out: *i64, quality: i64) -> i64 called by 7: encode_jpegmainmainmainrt_emitmain+1 calls 4: sys_mmap_qt_chroma_base_qt_quality_to_scale_qt_scale |
| 121 | func nx_qt_uniform(qt_out: *i64, step: i64) -> i64 |
| 132 | func nx_qt_verdict_is_valid(v: i64) -> i64 |