Expand description
Memory-safe JPEG XR decoder (ITU-T T.832 | ISO/IEC 29199-2).
A forbid(unsafe_code) Rust port of the decoder path of Microsoft’s jxrlib (“JPEG XR Device
Porting Kit”, BSD 2-clause, see LICENSE), written to replace a machine translation of the
same library that could write past its buffers. The port keeps jxrlib’s arithmetic and its
macroblock schedule, so decoded pixels are bit-identical to jxrlib’s (which is what
imagecodecs, czifile and ZEISS libCZI use). Malformed codestreams give an Error, never a
panic or an out-of-bounds access; reads past the end of the data stop decoding.
Supported: every codec sub-version, spatial and frequency bitstream order, tiles (soft and
hard), all overlap modes, internal Y-only, 4:2:0, 4:2:2, 4:4:4 and N-component planes,
scaled and unscaled arithmetic, flexbits trimming and dropped subbands, and output as grey,
RGB/BGR or N-channel samples of 8/16 bit unsigned, 16/32 bit fixed point, half and single
float. Not supported (clean Error::Unsupported): alpha planes, CMYK, RGBE, packed
5/6/10-bit and bilevel formats, YCC outputs and non-identity orientation tags.
let bytes = std::fs::read("tile.jxr")?;
let img = openreadout_jpegxr::decode(&bytes, 1 << 30)?;
println!("{}x{} x{} {:?}", img.width, img.height, img.channels, img.sample);Structs§
- Image
- A decoded image:
width * height * channelsinterleaved samples, no row padding. - Info
- Size and sample layout of a codestream, read from its headers only.
Enums§
- Error
- Decoding failure.
- Sample
Type - Sample type of a decoded image. Multi-byte samples are little-endian.
Functions§
- decode
- Decode a JPEG XR file (
II BCcontainer) or bare codestream (WMPHOTO). Refuses, before allocating anything large, images whose decoded size or working memory exceedsmax_bytes. - probe
- Read the size and sample layout without decoding pixels.
Type Aliases§
- Result
- Result alias of this crate.