hyper_jpeg is a high-level JPEG encoding library for Nim.
It automatically selects the best backend:
- V4L2 hardware encoder (if available)
- TurboJPEG fallback
Users do not need to care about backend differences.
- Unified API for JPEG encoding
- Automatic backend selection
- Zero-copy path for V4L2 (RGBA -> NV12 directly into MMAP buffer)
- TurboJPEG fallback
- Result-based error handling (no exceptions)
Test environment:
- TI AM67A
- Cortex-A53 1.4GHz x4
- CPU-only (no GPU acceleration)
On 1920x1080 RGBA input:
- Zero-copy path: ~10.8 ms
- Copy-based path: ~13.9 ms
- ~22% improvement
- Byte-identical output
import hyper_jpeg
let enc = ?JpegEncoder.open(1920, 1080)
let jpeg = ?enc.encodeRgba(
dataPtr,
1920,
1080,
stride,
quality = 90
)
?enc.close()| Backend | Description |
|---|---|
| V4L2 | Hardware JPEG encoder |
| TurboJPEG | Software fallback |
- libyuv_nim
- v4l2_jpeg
- libturbojpeg_nim
- results
MIT License