MCPcopy Create free account
hub / github.com/RustCV/RustCV / bgra_to_bgr

Function bgra_to_bgr

rustcv/src/videoio/mod.rs:385–399  ·  view source on GitHub ↗

辅助:BGRA -> BGR

(src: &[u8], dest: &mut [u8], width: usize, height: usize)

Source from the content-addressed store, hash-verified

383 }
384}
385
386// 辅助:NV12 (semi-planar YUV 4:2:0) -> BGR
387fn nv12_to_bgr(src: &[u8], dest: &mut [u8], width: usize, height: usize) {
388 let y_size = width * height;
389 let uv_size = width * height.div_ceil(2);
390 if src.len() < y_size + uv_size || dest.len() < width * height * 3 {
391 return;
392 }
393 let uv_plane = &src[y_size..];
394 for y in 0..height {
395 let uv_row = (y / 2) * width;
396 for x in 0..width {
397 let y_val = src[y * width + x] as i32;
398 let uv_idx = uv_row + (x / 2) * 2;
399 let u = uv_plane[uv_idx] as i32 - 128;
400 let v = uv_plane[uv_idx + 1] as i32 - 128;
401 let c = y_val - 16;
402 let r = (298 * c + 409 * v + 128) >> 8;

Callers 1

readMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected