Rust utilities for YUV format handling and conversion.
Fast and simple YUV approximation conversion in pure Rust. At most the same as libyuv does. Performance will be equal to libyuv or slightly higher on platforms where SIMD is implemented. Otherwise equal or slower.
Mostly implemented AVX-512, AVX2, SSE, NEON, WASM
X86 targets with SSE and AVX uses runtime dispatch to detect available cpu features.
Supports:
- YCbCr ( aka YUV )
- YCgCo
- YCgCo-R
- YUY2
- Identity ( GBR )
- Sharp YUV
All the methods support RGB, BGR, BGRA and RGBA
SIMD
rustc avx2
, avx512f
, avx512bw
, neon
, sse4.1
features should be set when you expect than code will run on supported device.
For AVX-512 target feature avx512bw
is required along with feature nightly_avx512
and nightly
rust channel compiler.
Wasm simd128
should be enabled for implemented SIMD wasm paths support
Rayon
Some paths have multi-threading support, consider this feature if you're working on platform with multi-threading.
Adding to project
RGB to YCbCr
let mut planar_image =
alloc;
rgb_to_yuv422
.unwrap;
YCbCr to RGB
yuv420_to_rgb
.unwrap;
Benchmarks
YUV 8 bit-depth conversion
Tests performed on the image 5763x3842
Encoding
time(NEON) | Time(AVX) | |
---|---|---|
utils RGB->YUV 4:2:0 | 4.37ms | 6.14ms |
libyuv RGB->YUV 4:2:0 | 3.66ms | 33.87ms |
utils RGBA->YUV 4:2:0 | 4.88ms | 7.34ms |
libyuv RGBA->YUV 4:2:0 | 4.87ms | 23.48ms |
utils RGBA->YUV 4:2:2 | 4.99ms | 7.08ms |
libyuv RGBA->YUV 4:2:2 | 5.90ms | 35.23ms |
utils RGBA->YUV 4:4:4 | 5.37ms | 7.97ms |
Decoding
time(NEON) | Time(AVX) | |
---|---|---|
utils YUV NV12->RGB | 4.08ms | 6.48ms |
libyuv YUV NV12->RGB | 5.20ms | 45.28ms |
utils YUV 4:2:0->RGB | 3.49ms | 5.44ms |
libyuv YUV 4:2:0->RGB | 5.70ms | 44.95ms |
utils YUV 4:2:0->RGBA | 4.02ms | 5.98ms |
libyuv YUV 4:2:0->RGBA | 6.13ms | 6.88ms |
utils YUV 4:2:2->RGBA | 5.39ms | 6.91ms |
libyuv YUV 4:2:2->RGBA | 5.91ms | 6.91ms |
utils YUV 4:4:4->RGBA | 5.04ms | 7.20ms |
libyuv YUV 4:4:4->RGBA | 4.82ms | 7.30ms |
This project is licensed under either of
at your option.