JPEG coefficients / HTJ2K / Rust

JPEG-to-HTJ2K Transcoding

j2k-transcode converts supported baseline JPEG inputs to HTJ2K from their DCT coefficients—without first decoding the image to pixels.

Change the compressed representation, not the workflow boundary.

The transcode crate owns the CPU pipeline and shared contracts used by optional CUDA and Metal adapters. The HTJ2K codestream is assembled by the core crate.

Input

Read supported baseline JPEG coefficients

Parse a supported baseline JPEG, retain its DCT-domain information and reject input modes that the transcode contract cannot represent safely.

Transform

Build HTJ2K coefficient stages

Run the coefficient-domain transform and HT block-coding stages without materializing an intermediate decoded pixel image.

Output

Assemble an HTJ2K codestream

Produce the ordered codestream and per-input results. Applications can wrap suitable output in JPH or place it in another supported container.

Portable core. Optional accelerated stages.

CPU

Parallel batches with bounded waves

The default batch pipeline uses the current Rayon pool, keeps host memory bounded and returns outputs and tile errors in input order.

CUDA / Metal

Resident stage contracts checked metadata

Adapter types describe resident DCT grids, wavelet subbands and codestream buffers. Constructors validate the associated geometry and metadata.

No silent approximation

Unsupported JPEG modes return errors

The coefficient-domain route is deliberately narrower than general JPEG decoding. Unsupported types and modes do not fall back to a hidden pixel round trip.

Library or CLI.

Use the library to integrate transcode stages, or use the J2K CLI for a direct smoke test with an explicit HTJ2K request.

LibraryCPU pipeline
$ cargo add j2k-transcode

Add j2k-transcode-cuda or j2k-transcode-metal for supported accelerator stages.

CLISmoke test
$ cargo install j2k-cli
$ j2k transcode input.jpg output.j2k --htj2k --lossless-53

The output is an HTJ2K codestream; choose the required wrapper in the surrounding workflow.

Place the transcode route