#format-conversion #yuv

yuvutils-rs

High performance utilities for YUV format handling and conversion

45 releases (4 breaking)

new 0.5.5 Nov 21, 2024
0.4.13 Oct 24, 2024
0.3.1 Jul 13, 2024

#77 in Images

Download history 1/week @ 2024-08-04 5/week @ 2024-08-11 1/week @ 2024-08-18 231/week @ 2024-08-25 860/week @ 2024-09-01 35/week @ 2024-09-08 76/week @ 2024-09-15 212/week @ 2024-09-22 152/week @ 2024-09-29 56/week @ 2024-10-06 765/week @ 2024-10-13 306/week @ 2024-10-20 112/week @ 2024-10-27 235/week @ 2024-11-03 229/week @ 2024-11-10 599/week @ 2024-11-17

1,223 downloads per month
Used in 2 crates

Apache-2.0 OR BSD-3-Clause

2MB
34K SLoC

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

cargo add yuvutils-rs

RGB to YCbCr

rgb_to_yuv422(&mut y_plane, y_stride,
              &mut u_plane, u_width,
              &mut v_plane, v_width,
              &rgb, rgb_stride,
              width, height, 
              YuvRange::Full, YuvStandardMatrix::Bt709);

RGB to sharp YUV

rgb_to_sharp_yuv420(&mut y_plane, y_stride,
                    &mut u_plane, u_width,
                    &mut v_plane, v_width,
                    &rgb, rgb_stride,
                    width, height, 
                    YuvRange::Full, YuvStandardMatrix::Bt709,
                    SharpYuvGammaTransfer::Srgb);

YCbCr to RGB

yuv422_to_rgb(&y_plane, y_stride, 
              &u_plane, u_stride,
              &v_plane, v_stride,
              &mut rgb, rgb_stride,
              width, height, 
              YuvRange::Full, YuvStandardMatrix::Bt709);

RGB To YCgCo

rgb_to_ycgco420(&mut y_plane, y_stride,
                &mut cg_plane, cg_width,
                &mut cg_plane, cg_width,
                &rgb, rgb_stride,
                width, height, 
                YuvRange::TV);

YCgCo to RGB

ycgco420_to_rgb(&y_plane, y_stride, 
                &cg_plane, cg_stride,
                &co_plane, co_stride,
                &mut rgb, rgb_stride,
                width, height, 
                YuvRange::TV);

This project is licensed under either of

  • BSD-3-Clause License (see LICENSE)
  • Apache License, Version 2.0 (see LICENSE)

at your option.

Dependencies

~93–415KB