yuv
Fast, pure-Rust conversion between YUV and RGB color formats with SIMD acceleration.
Repository Health
Technical Analysis
yuv (crate for the yuvutils-rs project) is a pure-Rust library for converting between YUV/YCbCr and RGB pixel formats. It targets performance on par with or slightly better than Google’s libyuv by using hand-written SIMD paths — AVX-512, AVX2, SSE, NEON, and WASM simd128 — selected at runtime based on the CPU’s available features.
It supports a broad range of color models and layouts, including YCbCr, YCgCo (and the reversible YCgCo-Re/Ro variants), YUY2, identity/GBR, and Sharp YUV, across RGB, BGR, RGBA, and BGRA buffers. Optional Rayon-based multithreading further accelerates conversion of large frames.
What You Get
- Bidirectional conversion between YUV/YCbCr families and RGB/BGR/RGBA/BGRA buffers
- Support for YCbCr, YCgCo, YCgCo-Re/Ro, YUY2, identity (GBR), and Sharp YUV models
- Runtime SIMD dispatch across AVX-512, AVX2, SSE4.1, NEON, and WASM simd128
- Optional Rayon multithreading for parallel conversion of large frames
- Performance comparable to libyuv without a C dependency
Common Use Cases
- Converting decoded video frames from YUV420 to RGBA for display or further processing
- Encoding RGB image data into a YUV planar format before compression
- Building cross-platform media pipelines that need fast, safe color conversion
- Handling NV12/NV21 and packed YUY2 buffers from cameras or codecs
Under The Hood
Architecture - The crate exposes conversion functions per format pair (e.g. YUV420 to RGBA) that operate on caller-provided planar or packed buffers. Each function has a scalar fallback plus per-target SIMD implementations, and x86 paths use runtime feature detection to dispatch to SSE4.1, AVX2, or AVX-512 kernels; ARM uses NEON (with optional RDM) and WASM uses simd128. Optional Rayon feature-gates parallel row processing. Tech Stack - Pure Rust with architecture-specific intrinsics; AVX-512 support requires the nightly_avx512 feature on nightly Rust, while SSE/AVX2/NEON work on stable. Rayon is an optional dependency for multithreading. Code Quality - The project is actively developed and well maintained, versioned frequently (0.8.16), with CI builds across platforms and a large user base (3M+ downloads); the README documents supported formats and SIMD requirements precisely. API Design - The API is a flat set of well-named conversion functions taking source/destination slices, strides, dimensions, and a color range/matrix — familiar to anyone who has used libyuv — with no builder ceremony, keeping integration straightforward for media developers.