Function rgb2yuv420::convert_rgb_to_yuv420sp_nv12
[−]
[src]
pub fn convert_rgb_to_yuv420sp_nv12(
img: &[u8],
width: u32,
height: u32,
bytes_per_pixel: usize
) -> Vec<u8>
Converts an RGB image to YUV420sp NV12 (semi-planar/2 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, v, u, v, ...]
Examples
let rgb = vec![0u8; 12]; let yuv = rgb2yuv420::convert_rgb_to_yuv420sp_nv12(&rgb, 2, 2, 3); assert_eq!(yuv.len(), rgb.len() / 2);