Skip to main content

Crate rust_j2k

Crate rust_j2k 

Source
Expand description

Pure-Rust JPEG 2000 codec, built GRIB2-decode-first toward OpenJPEG-level coverage. No C dependency, so it cross-compiles cleanly to every target.

JPEG 2000 (ISO/IEC 15444-1 and later parts) is a large standard. The first deliverable decodes the slice GRIB2 §5.40 (grid_jpeg) needs, which keeps the initial surface tractable while exercising the whole pipeline:

  • the raw codestream (Annex A), not yet the JP2 file format (no boxes);
  • a single component (one scalar grid), so no multi-component or color transform (MCT) yet;
  • integer samples, signed or unsigned, up to 32 bits;
  • both the reversible 5/3 (lossless) and irreversible 9/7 (lossy) wavelet paths (the 9/7 path is graded by re-encoding a real grid with OpenJPEG, since no operational GRIB2 producer ships lossy 9/7).

Multi-component/color, JP2 boxes, HTJ2K, and an encoder are later-phase work, not permanent non-goals. See docs/roadmap.md and docs/scope.md.

§Pipeline

bytes ─▶ codestream ─▶ tier-2 ─▶ tier-1 ─▶ dequant ─▶ inverse DWT ─▶ Image
        (markers)     (packets)  (MQ+EBCOT) (quant)    (5/3 | 9/7)

Each stage is a module below. decode wires them together.

§Status

Phase 1 complete: the GRIB2 §5.40 decode path is implemented end to end and passes the conformance gate (bit-exact 5/3, within tolerance 9/7). See each module’s docs for the ISO §reference and what it owns. Correctness is defined by the conformance harness in tests/ (cross-check against OpenJPEG / eccodes), not by self-consistency. Later phases widen this same engine toward general Part 1; see docs/roadmap.md and docs/scope.md.

Re-exports§

pub use error::Error;
pub use error::Result;
pub use image::Image;

Modules§

codestream
Stage 1 — codestream parsing (ISO/IEC 15444-1 Annex A).
dwt
Stage 5 — inverse discrete wavelet transform (ISO/IEC 15444-1 Annex F).
error
Error type for the decoder. One flat enum; each stage maps its failures to the variant that names the layer, so a caller can tell a malformed header from an unsupported feature from a Tier-1 decode fault.
image
Decoder output: one integer component in raster order, plus the metadata a caller needs to interpret the samples (bit depth + signedness).
quant
Stage 4 — dequantization (ISO/IEC 15444-1 Annex E.1).
tier1
Stage 3 — Tier-1 / EBCOT block coding (ISO/IEC 15444-1 Annex C-D).
tier2
Stage 2 — Tier-2 packet decoding (ISO/IEC 15444-1 Annex B).

Functions§

decode
Decode a JPEG 2000 codestream (Annex A, no JP2 wrapper) into a single integer-component Image.