JFLib

img_jxl_enc#

the new JPEG XL writer (linked into codectest, and the module jxlenc that codectest --jxlenc loads) -- crate root lib/img_jxl_enc/lib.rs

img_jxl_enc -- the new JPEG XL writer (jxl-plus: a port of libjxl 0.11.1's encoder; jxl-tools,
jxl-speed), split out of img_jxl so that an app can load it as a module (jxl-module)
                                                                      [jxl-plus: no asm]

  use_static()                   the app saves JPEG XL with this writer, linked in (codectest,
                                 JFPainter, the check tools): img_jxl::writer::set_static(enew::encode_px)
  enew::encode / encode_px / encode_with_splines   the writer itself (options: the header
                                 of img_jxl/lib.rs)

Who links what: img_jxl (reader, the assembly-compatible writer, the writer's options and
samples in writer.rs) is in every app that registers JPEG XL; this crate only where the
app calls use_static() or one of its functions (codectest, JFPainter).  An app that calls
img_jxl::writer::use_module() instead (codectest --jxlenc FILE) gets the module jxlenc (modules/jxlenc: this crate built
as a no_std cdylib over the module runtime) runs encode_px on the samples the host read.
The output is the same byte for byte either way, for any number of threads.

Modules (moved from img_jxl, same names; `crate::<decoder module>` paths resolve through
the re-exports below): enew (options, lossless frame), evdct (VarDCT frame), emod (modular
streams, transforms), ema (MA tree learning), eans (entropy coding: ANS / prefix codes,
clustering, LZ77), efrm (headers, TOC), eicc (ICC stream), etx (forward transforms, quant
tables), dctk (the transforms as simd kernels; jxl-speed), eaq (adaptive quantization,
gaborish), eacs (AC strategy search), ecfl (chroma from luma); jxl-tools: epatch (patch
search, packing, dictionary), edots (dots for the dictionary), espline (test-only spline
writer), enoise (photon noise LUT), efeat (the frame's feature sections), ebutter
(Butteraugli), ebq (the effort 8 / 9 quantization loop).

img_jxl_enc API#

Re-exports: img_jxl::{ bits, blend, brotli, dct, dec, emath, enc, ent, epf, ewr, frm, hdr, icc, jpeg, modular, mtr, noise, par, rnd, spline, tab, vac, vdc, venc, vqt, vrc, writer, }

Re-exports: img_jxl::{decode_linear, Recon}

  • fn use_static() save JPEG XL with this writer, linked into the app (instead of the module file)

From lib/img_jxl_enc/enew.rs (img_jxl_enc::enew):

  • fn encode(sf: &Surface, o: &Opts) -> Result<Vec<u8>, i32> encode (see the module header)

  • fn encode_px(px: &Px, o: &Opts) -> Result<Vec<u8>, i32> encode the samples of image_of (jxl-module: what the module runs; the linked writer too)

  • fn encode_with_splines(sf: &Surface, opt: &ImgOpt, q: &crate::spline::Quantized) -> Result<Vec<u8>, i32> the writer with the test-only spline bundle q in the frame (jxl-tools: libjxl's encoder cannot write splines; the decoder's checks use this)

img_jxl_enc modules#

The codec's building blocks (public for the codec test app codectest; see their source headers):

ModuleContent
img_jxl_enc::dctkthe VarDCT transforms as simd kernels: ComputeScaledDCT / ComputeScaledIDCT of rows x cols blocks (4, 8, 16, 32, 64 each)
img_jxl_enc::eacsAC strategy selection of the VarDCT writer (libjxl 0.11.1 enc_ac_strategy.cc: EstimateEntropy, FindBest8x8Transform, TryMergeAcs, ...
img_jxl_enc::eansentropy coding of the new encoder: tokens, hybrid uint configs, histogram clustering, ANS histograms with a chosen precision, prefix codes, context maps, ...
img_jxl_enc::eaqadaptive quantization, inverse gaborish and the quantizer of the VarDCT writer (libjxl 0.11.1 enc_adaptive_quantization.cc InitialQuantField / ...
img_jxl_enc::ebqthe writer's Butteraugli quantization loop at efforts 8 and 9 (libjxl 0.11.1 enc_adaptive_quantization.cc FindBestQuantization, quantizer.cc SetQuantField): ...
img_jxl_enc::ebutterButteraugli, the perceptual distance the writer's effort 8 / 9 quantization loop minimizes (libjxl 0.7 lib/jxl/butteraugli/butteraugli.cc: ...
img_jxl_enc::ecflchroma from luma of the VarDCT writer: the Y-to-X / Y-to-B factor of every 64x64 tile (libjxl 0.11.1 enc_chroma_from_luma.cc FindBestMultiplier, ComputeTile)
img_jxl_enc::edotsdots for the patch dictionary: small Gaussian-like spots (stars, specks) of the XYB image go into the reference frame as the image minus a strongly smoothed ...
img_jxl_enc::efeatthe image features a frame of the new writer may carry, written at the start of its LfGlobal section in the order the decoder reads them: patches ...
img_jxl_enc::efrmheaders of the new encoder: image header (size, metadata, colour encoding or ICC, transform data), frame header (all frame kinds the new encoder writes), ...
img_jxl_enc::eiccICC profile encoding of the image header (libjxl 0.11.1 enc_icc_codec.cc PredictICC, WriteICC; icc_codec_common.cc); the inverse of icc.rs
img_jxl_enc::emaMA tree learning of the new encoder (libjxl 0.11.1 modular/encoding/enc_ma.cc, enc_encoding.cc PredefinedTree / MakeFixedTree, enc_modular.cc MergeTrees)
img_jxl_enc::emodmodular encoding of the new encoder: predictors and properties, tree data gathering, channel tokens, forward transforms (RCT, palette, squeeze), cost ...
img_jxl_enc::enewthe new JPEG XL writer (jxl-plus): options, effort mapping, the lossless modular frame (libjxl 0.11.1 enc_modular.cc ComputeEncodingData / ...
img_jxl_enc::enoisephoton noise for the new lossy writer: the noise LUT of a simulated camera sensor at an ISO setting, written into the frame (libjxl 0.11.1 ...
img_jxl_enc::epatchpatches for the new writer: repeated small content (text glyphs, icons) found in the image goes once into a reference-only frame and is added back at every ...
img_jxl_enc::esplinethe test-only spline writer: a frame's spline bundle from given quantized splines (libjxl enc_splines.cc EncodeSplines / QuantizedSplineEncoder::Tokenize; ...
img_jxl_enc::etxforward transforms of the VarDCT writer (libjxl 0.11.1 enc_transforms-inl.h TransformFromPixels, DCFromLowestFrequencies; dct-inl.h ComputeScaledDCT) and ...
img_jxl_enc::evdctthe new lossy writer: one VarDCT frame in XYB, as libjxl 0.11.1 at the same effort (enc_frame.cc ComputeVarDCTEncodingData / EncodeGroups, enc_heuristics.cc ...

Source: docs/API.md in the JFLib repository.