JpxDecoder
A pure-Kotlin JPEG 2000 decoder (ITU-T T.800), taking either JP2 container boxes or a raw codestream, all of Part 1. Produces an 8-bpc Gray or RGB raster plus an optional alpha plane from a cdef opacity channel.
Handled: SIZ/COD/QCD with COC/QCC overrides, multiple tiles and tile-parts, LRCP/RLCP/RPCL/PCRL/CPRL progressions and POC progression order changes, general precincts, tag trees, multi-layer tier-2 packet headers (with SOP/EPH), in the bitstream or packed into PPM or PPT segments, EBCOT tier-1 with every Part 1 code-block style (selective arithmetic coding bypass, context reset, termination on each pass, vertically causal contexts, segmentation symbols), RGN regions of interest by the Maxshift method, reversible 5/3 and irreversible 9/7 inverse DWT, RCT and ICT multiple-component transforms, DC level shift, component subsampling by nearest upsample, and bit depths up to 16. The high-throughput block coder of Part 15 (HTJ2K, ITU-T T.814) decodes too, one HT set a code-block, beside or in place of EBCOT.
Not handled: HT code-blocks mixed with EBCOT ones in one tile-component, HT code-blocks of more than one HT set, and the Part 2 extensions. ImageKodec.probe names them, so a caller can find out without attempting a decode.
Types
Functions
Decode data at full size, or null when it is damaged or uses a feature this decoder lacks.
Decode data with each side divided by reduction, rounded up: 1, 2, 4 or 8. The decoder drops the finest wavelet levels, as OpenJPEG's reduce option does, so the full-size samples never exist. Each output sample is the low-pass value at every reduction-th sample of the image, not the mean of a block. When a component has fewer levels than that, the decoder drops the levels it has and averages blocks of the result for the rest. cancellationCheck runs as for the full decode.