Function rgb2yuv420::convert_rgb_to_yuv420p [] [src]

pub fn convert_rgb_to_yuv420p(
    img: &[u8],
    width: u32,
    height: u32,
    bytes_per_pixel: usize
) -> Vec<u8>

Converts an RGB image to YUV420p (planar/3 planes)

Arguments

  • img - should contain the pixel data in the following format: [r, g, b, ... , r, g, b, ... , r, g, b, ...]

  • bytes_per_pixel - should contain the number of bytes used by one pixel (eg.: RGB is 3 bytes and RGBA is 4 bytes)

Return

[y, y, y, ... , u, u, u, ... , v, v, v, ...]

Examples

let rgb = vec![0u8; 12];
let yuv = rgb2yuv420::convert_rgb_to_yuv420p(&rgb, 2, 2, 3);
assert_eq!(yuv.len(), rgb.len() / 2);