NVIDIA nvJPEG2000#

The nvJPEG2000 library accelerates the decoding and encoding of JPEG2000 images on NVIDIA GPUs. The library is built on the CUDA platform and is supported on Pascal+ GPU architectures.

Note

Throughout this document, the terms “CPU” and “Host” are used synonymously. Similarly, the terms “GPU” and “Device” are synonymous.

Decoder#

The library utilizes both CPU and GPU for decoding. Tier 2 decode stage (first stage of decode; please refer to the JPEG2000 specification for details) is run on the CPU. All other stages of the decoding process are offloaded to the GPU.

The nvJPEG2000 decoder supports the following:

JPEG2000 Options:

  • Up to 16 bits per component for integer outputs

  • FP16 and FP32 outputs, for streams carrying NLT type 3 on every component (which requires the reversible 5-3 wavelet); FP16 requires BDnlt of 16 on every component, FP32 requires 16 or 32

  • No of components : up to 16384 (the CSiz limit); device memory scales linearly with the component count

  • Reversible(5-3) and irreversible(9-7) wavelet transforms

  • Multiple tiles per image

  • Up to 32 layers per image

  • Chroma sub-sampling types - 444, 422, and 420, on the first three components only; components at index 3 and above must not be sub-sampled

  • All progression orders

  • Tile/Resolution based decoding

  • Partial decoding of tiles and images

  • jp2 file format and jpeg2000 codestream

  • High throughput jpeg2000(All code-blocks have to be HT code-blocks with one HT set and no refinement)

Features:

  • Decode multiple images in pipeline mode. Refer to nvJPEG2000-Decoder-Pipelined sample for details.

  • Color conversion to RGB.

  • Both planar and interleaved outputs are supported.

Encoder#

The library utilizes both GPU and CPU to create JPEG2000 bitstreams. The encode APIs require that the input image is on device memory, and the compressed bitstream will be written to host memory.

The nvJPEG2000 encoder supports the following:

JPEG2000 options

  • Up to 16 bits per component for integer inputs

  • FP16 and FP32 inputs, through the NLT type 3 transform (requires high throughput jpeg2000 and the reversible 5-3 wavelet); BDnlt is 16 for FP16, and 16 or 32 for FP32

  • No of components : up to 16384 (the CSiz limit); device and pinned memory scale linearly with the component count

  • Reversible(5-3) and irreversible(9-7) wavelet transforms

  • Multiple tiles per image

  • Single layer per image

  • All progression orders

  • Chroma sub-sampling types - 444, 422, and 420, on the first three components only; components at index 3 and above must not be sub-sampled

  • jp2 file format and jpeg2000 codestream

  • High throughput jpeg2000

  • Lossy encode using one of the following options
    • Quantization step

    • Q-Factor (JPEG like quality)

    • PSNR

Features

  • Both planar and interleaved inputs are supported.

Prerequisites#

  • CUDA Toolkit version 12.0 and above

  • CUDA Driver version r525 and above

Platforms Supported#

  • Linux versions:

Distribution

OS Version

Default GCC

GLIBC

x86_64

RHEL 10

10

14.3.1

2.39

RHEL 9

9

11.5.0

2.34

RHEL 8

8

8.5.0

2.28

Rocky Linux 10

10

14.3.1

2.39

Rocky Linux 9

9

11.5.0

2.34

Rocky Linux 8

8

8.5.0

2.28

Amazon Linux 2023

2023

11.4.1

2.34

MSFT Azure Linux

3

13.2.0

2.38-8

Ubuntu 26.04 LTS

26.04

15.2.0

2.43

Ubuntu 24.04 LTS

24.04

14.3.0

2.39

Ubuntu 22.04 LTS

22.04

12.3.0

2.35

OpenSUSE Leap 16

16

15.1.1

2.40

OpenSUSE Leap 15

15

7.5.0

2.38

SUSE SLES 16

16

15.1.1

2.40

SUSE SLES 15

15

7.5.0

2.38

Debian 13

13

14.2.0

2.41

Debian 12

12

12.2.0

2.36

Fedora 44

44

15.2.1

2.43

KylinOS V11

V11

12.3.1

2.38

arm64 systems (sbsa)

RHEL 10

10

14.3.1

2.39

RHEL 9

9

11.5.0

2.34

RHEL 8

8

8.5.0

2.28

Amazon Linux 2023

2023

11.4.1

2.34

MSFT Azure Linux

3

13.2.0

2.38-8

Ubuntu 26.04 LTS

26.04

15.2.0

2.43

Ubuntu 24.04 LTS

24.04

13.4.0

2.39

Ubuntu 22.04 LTS

22.04

11.4.0

2.35

OpenSUSE Leap 16

16

15.1.1

2.40

SUSE SLES 16

16

15.1.1

2.40

SUSE SLES 15

15

7.5.0

2.38

Debian 13

13

14.2.0

2.41

Debian 12

12

12.2.0

2.36

KylinOS V11

V11

12.3.1

2.38

arm64 sbsa Jetson (dGPU + iGPU with OpenRM/nvgpu)

Ubuntu 24.04 LTS Rel39 (JP7.x)

24.04

13.3.0

2.39

  • Windows Versions

    • Windows 10/11.

  • Tegra

    • arm64-sbsa builds are supported on Thor starting CUDA 13.0.

    • arm64-sbsa builds are supported on Orin starting CUDA 13.2.

    • aarch64-jetson binaries based on CUDA 12 are available for Orin.

Thread Safety#

Not all nvJPEG2000 types are thread safe. The following should be instantiated separately for each thread: nvjpeg2kStream_t, nvjpeg2kDecodeState_t, nvjpeg2kDecodeParams_t, nvjpeg2kEncodeState_t, and nvjpeg2kEncodeParams_t.

nvjpeg2kHandle_t and nvjpeg2kEncoder_t can be shared by multiple threads. Custom allocators used to create a handle must be thread safe, because every thread that uses the handle, directly or through an encoder created from it with nvjpeg2kEncoderCreate, calls those allocators.

Changing the configuration of a handle, for example with nvjpeg2kSetDeviceMemoryPadding or nvjpeg2kSetPinnedMemoryPadding, is not synchronized with the library’s use of that configuration. The padding is read every time the library sizes a buffer allocated through the handle, whether or not the buffer then grows. Both the decoder and the encoder do this:

  • Decoder: nvjpeg2kDecodeStateCreate, and nvjpeg2kDecode, nvjpeg2kDecodeImage and nvjpeg2kDecodeTile on a decode state created from the handle.

  • Encoder: nvjpeg2kEncodeStateCreate and nvjpeg2kEncode on an encoder created from the handle with nvjpeg2kEncoderCreate.

When multiple threads reuse a handle, change its configuration under a lock that those threads also hold around their nvJPEG2000 calls that use the handle, directly or through such an encoder or decode or encode state. Alternatively, configure the handle before sharing it between threads.