Expand description
JPEG decoding for baseline (SOF0/SOF1) and progressive (SOF2) profiles.
Part of the pith zero-dependency hashing suite: this crate depends
only on pith-digest, pith-math and pith-image, so the
whole suite resolves without a single registry package.
§Scope
Decodes JFIF/EXIF-style JPEG streams: 8-bit precision, Huffman entropy
coding, 1–3 components, sampling factors up to 2×2 per component
(4:4:4, 4:2:2, 4:4:0, 4:2:0 and friends), restart markers, and the full
progressive script (spectral selection + successive approximation,
interleaved DC scans, EOBRUN). Arithmetic-coded frames (SOF9–SOF11,
SOF13–SOF15), lossless frames (SOF3/SOF7/SOF11/SOF15), differential
frames (SOF5–SOF7/13–15), 12-bit precision and CMYK output are refused
with Error::Unsupported naming the exact coding process.
§Fidelity contract
The integer pipeline is a transcription of libjpeg-turbo’s islow
IDCT (jidctint.c), fancy chroma upsampling (jdsample.c) and
fixed-point YCbCr→RGB (jdcolor.c), so output is byte-exact with
libjpeg -dct int -nosmooth (which is what Pillow produces). The only
deliberate divergence is arithmetic on adversarially large
coefficients: intermediate sums are i64, where libjpeg’s int
accumulators would wrap.
pith_math::idct2/idct2_2d is not used on the decode path: it is
an orthonormal DCT-III in f64 whose rounding differs from JPEG’s
fixed-point islow, so substituting it would break byte-exactness with
the reference decoder. It is used in this crate’s test-suite as an
independent oracle that the transcription stays inside the documented
tolerance (see tests/ and src/idct.rs).
Modules§
- ffi
- The C ABI surface of
pith-jpeg: the entry points the Python (ctypes), Node (koffi) and Go (cgo) SDKs bind through. - reference
- The committed reference contract of this crate, re-expressed over the crate’s own pipeline.
Enums§
- Jpeg
- A decoded JPEG image: single-component frames yield
Image<Gray>, three-component frames yieldImage<Rgb>.
Functions§
- decode
- Decodes a JPEG byte stream into pixels.