# GPU-accelerated JPEG 2000 in Rust

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

Accelerate supported JPEG 2000 and HTJ2K operations with Apple Metal or NVIDIA CUDA. Portable CPU decoding and encoding are also available.

## Acceleration options

- **Apple Metal:** `j2k-metal`, `j2k-jpeg-metal` and `j2k-transcode-metal` accelerate supported codec operations on Apple GPUs.
- **NVIDIA CUDA:** `j2k-cuda`, `j2k-jpeg-cuda` and `j2k-transcode-cuda` use Rust kernels compiled with cuda-oxide for supported NVIDIA GPU operations.
- **CPU:** Portable decoding and encoding without a GPU. Automatic selection uses the CPU when a suitable GPU route is unavailable or has not measured faster.

`BackendRequest::Auto` uses the CPU when a GPU route is unavailable, unsupported, or not measured to improve the requested shape. Explicit Metal and CUDA requests return an error for unsupported shapes. GPU support for a format does not mean that every stage or shape runs on the GPU.

## Formats and evidence

GPU acceleration covers supported operations on JPEG 2000 Part 1 codestreams, JP2 files, HTJ2K Part 15 codestreams, and JPH files. CUDA and Metal decodes of signed grayscale and color sources follow the CPU's sample conversion. Consult the [support matrix](https://github.com/frames-sg/j2k/blob/main/docs/public-support.md) for exact coverage. Performance comparisons must be read with the [benchmark methodology and evidence](https://github.com/frames-sg/j2k/blob/main/docs/benchmark-evidence.md), which records hardware, commands, inputs, skipped rows, comparator versions, and publication eligibility.

## Related resources

- [Apple Metal acceleration](https://frames-sg.com/j2k/metal-jpeg2000-rust/)
- [NVIDIA CUDA acceleration](https://frames-sg.com/j2k/cuda-jpeg2000-rust/)
- [J2K API documentation](https://docs.rs/j2k)
- [Source repository](https://github.com/frames-sg/j2k)
