Pixel format conversions in pure Rust with SIMD optimizations on x86_64 and aarch64. The performance goal is to approximately reach the memory bandwidth limit and thus optimal performance when the input and output are not already in CPU cache.
Limitations and future work:
- Supports exactly one conversion: UYVY to I420. More will be added as needed.
- Expects to process full horizontal lines. This is likely to change to allow working on cropped regions.
- Does not support output to a frame with padding, as required by some APIs/devices.
- The ARM NEON code is less optimized than the AVX2 code today.
You may find the notes in docs/simd.md helpful if you are new
to SIMD and thinking of contributing.
The main alternative to pixelfmt is Chrome's C++
libyuv library.
Rust bindings are available via the yuv-sys or libyuv crates.
Some reasons to prefer pixelfmt:
pixelfmtis pure Rust and thus may be easier and quicker to build, particularly when cross-compiling.pixelfmtis less total code.pixelfmt'suyvy_to_i420implementation benchmarks as slightly faster thanlibyuv's. This appears to come down to design choices:libyuvhas separate routines to extract the Y and U+V planes, wherepixelfmtgains some performance by doing it all with a single read of the UYVY data.pixelfmtalso has a hand-optimized conversion function wherelibyuvuses a more generalized autovectorization approach.pixelfmtuses safe Rust when possible, wherelibyuvis entirely written in (unsafe) C++. That said,pixelfmtstill has a fair bit ofunsafelogic for vendor SIMD intrinsics.
Some reasons to prefer libyuv:
libyuvis much more widely used.libyuvis much more comprehensive and flexible.
SPDX-License-Identifier: MIT OR Apache-2.0
See LICENSE-MIT.txt or LICENSE-APACHE, respectively.