12-bit JPEG Codec on CUDA
Updated:
Fastvideo 12-bit JPEG codec implements the JPEG standard's Extended mode — 12 bits per channel instead of the 8 bits of standard Baseline JPEG — entirely on the GPU. It is the 12-bit extension of our Fast JPEG codec on CUDA, sharing its fully parallel architecture, and it exists for a simple reason: modern image sensors deliver 12 bits or more per channel, and truncating them to 8 bits before compression discards exactly the precision that medical, scientific, and HDR applications pay for. The produced streams conform to DICOM requirements and are compatible with the 12-bit format of libjpeg and libjpeg-turbo.
Why 12-bit JPEG 
Twelve bits per channel is the practical minimum for imaging systems that measure rather than merely display: an 8-bit pipeline holds 256 levels per channel, a 12-bit one holds 4096, and the difference decides whether gradients, shadows, and diagnostic detail survive compression. Yet 12-bit JPEGs remain rare in the wild — few viewers and libraries handle the Extended mode — so the format's speed and compatibility advantages often go unused. Our codec fills that gap with a high performance 12-bit JPEG/MJPEG implementation that supports both Baseline 8-bit and Extended 12-bit modes in one library, so a single integration covers both worlds.
Features of the 12-bit Extended JPEG Codec
- Compliance with the 12-bit Extension of the JPEG standard; compatibility with libjpeg and libjpeg-turbo 12-bit format
- Encoding and decoding of 12-bit per channel grayscale and color images, fully on the GPU; Baseline 8-bit mode is supported by the same library
- Produced JPEG streams conform to DICOM (Digital Imaging and Communications in Medicine) requirements
- Arbitrary width and height, from 1×1 up to 16,000×16,000 and more (optional)
- Subsampling 4:4:4 / 4:2:2 / 4:2:0; quality 1–100; standard quantization and Huffman tables for luma and chroma
- HDR image support; floating point precision for the color transform, 2D DCT, and quantization
- Input formats: 12/16-bit PGM, 12/16-bit YUV, 36/48-bit PPM/BMP; data from RAM/HDD/RAID/SSD or GPU memory, continuous mode
- Read/edit/write of any EXIF section
- 12-bit JPEG viewer with OpenGL integration; MJPEG streams via FFmpeg (FFmpeg is under LGPL v2.1)
- OS: Windows 10/11, Linux Ubuntu, L4T; CUDA 12.6
The codec inherits the fully parallel design of our 8-bit implementation — including parallel entropy coding on the GPU. How that works, and the current benchmark tables on the NVIDIA GeForce RTX 4090, are described on the Fast JPEG codec page.
Benchmarks for 12-bit JPEG Encoding
Reference measurement: a ~50 MPix 14-bit RAW image from the Canon 5DS R, converted to 12-bit per channel color data (8736×5856, 36-bit PPM), encoded with quality 90, all computations on GPU, single image mode:
- Subsampling 4:4:4 — 8.6 ms
- Subsampling 4:2:2 — 5.9 ms
- Subsampling 4:2:0 — 5.8 ms
- Grayscale image of the same resolution — 3.9 ms
These figures were measured on the NVIDIA GeForce GTX 1080 (25–40 GB/s for large 12-bit images); on current GPU generations the codec runs several times faster — see the up-to-date Fastvideo SDK benchmarks and the RTX 4090 tables on the JPEG codec page.
Who Needs a 12-bit JPEG Codec
- Medical imaging with DICOM: MRI, CT, X-Ray, ultrasound, endoscopy, microscopy
- RAW image and video processing; digital cinema
- HDR (WDR) imaging
- Machine vision and industrial cameras with 12-bit and higher sensors; high speed cameras
- Astronomy, aerial imaging, and geospatial software
- Augmented and virtual reality, 3D video and 3D reconstruction
- Display projection, traffic, and surveillance systems
Licensing
The 12-bit JPEG codec is licensed standalone or as a module of the Fastvideo GPU Image Processing SDK, to software developers, camera manufacturers, system integrators, and resellers. A demo, documentation, and a quotation are available upon request; we also develop custom GPU image processing software to specification — use the contact form below.