Expand description
Cleanroom JPEG 2000 decoder for the PDF JPXDecode filter (ISO 32000
7.4.9), implemented purely from ITU-T T.800 (08/2002).
Scope: JP2 box containers and raw codestreams; the full Annex A marker set; Tier-2 packet decoding with all five progression orders and POC; Tier-1 EBCOT (Annex D) over the Annex C MQ coder; Annex E dequantization with RGN maxshift; the Annex F 5-3 and 9-7 inverse wavelets; Annex G component transforms and Annex I palette/colour metadata.
Contract: header-level problems (bad signature, unparsable SIZ/COD,
exceeded DecodeLimits) are hard errors, and so is corruption that
prevents ANY packet of the image from decoding. Once the first packet
of the image has decoded, the decoder is lenient — a corrupt packet or
code-block zeroes the remainder of its scope (at most its own tile;
sibling tiles keep decoding), appends one warning to
DecodedImage::warnings, and decoding continues. Output samples are
8-bit: deeper sources are right-shifted to 8 with round-to-nearest,
signed samples are level-shifted per T.800 G.1.2. The decoder never
panics on hostile input and contains no unsafe.
Structs§
- Decode
Limits - Hard bounds on attacker-controlled allocation and work, checked before the corresponding allocations happen.
- Decoded
Image - A fully decoded image.
- JpxWarning
- One soft finding attached to a
DecodedImage(leniency doctrine).
Enums§
- Color
Kind - Colour interpretation of the decoded samples, from the JP2 colr box (T.800 I.5.3.3) or, for raw codestreams, guessed from the component count.
- JpxError
- Decoder error.
Functions§
- decode
- Decodes a JPEG 2000 image (JP2 file or raw codestream) into 8-bit interleaved samples.
Type Aliases§
- Result
- Crate-wide result alias.