# Metal JPEG2000 Rust

Canonical page: https://frames-sg.com/j2k/metal-jpeg2000-rust/

J2K provides Apple Metal acceleration on macOS for supported JPEG 2000 and HTJ2K device-output and encode-stage routes, plus supported coefficient-domain stages of JPEG-to-HTJ2K transcode workflows.

## Crates

- `j2k-metal` exposes Metal-backed JPEG 2000 and HTJ2K decode and encode-stage APIs: `cargo add j2k-metal`.
- `j2k-jpeg-metal` decodes every JPEG the CPU decoder supports into Metal memory, and encodes baseline and lossless JPEG from Metal buffers: `cargo add j2k-jpeg-metal`.
- `j2k-transcode-metal` accelerates supported coefficient-domain stages of JPEG-to-HTJ2K transcode: `cargo add j2k-transcode-metal`.

Packetization remains outside the accelerated transform stages. The Metal crates use retained `objc2-metal` protocol objects directly and do not depend on `metal-rs`.

Explicit Metal requests return an unsupported-request error for shapes without a Metal route. `BackendRequest::Auto` uses the CPU for unsupported shapes and for shapes not measured to benefit from the GPU. Device decodes of signed grayscale and color sources follow the CPU's sample conversion. The [support matrix](https://github.com/frames-sg/j2k/blob/main/docs/public-support.md) is authoritative for current coverage.

## Related resources

- [GPU acceleration overview](https://frames-sg.com/j2k/gpu-jpeg2000-rust/)
- [J2K Metal API documentation](https://docs.rs/j2k-metal)
- [Benchmark methodology and evidence](https://github.com/frames-sg/j2k/blob/main/docs/benchmark-evidence.md)
- [Source repository](https://github.com/frames-sg/j2k)
