Skip to content

Commit

Permalink
yuyv444_to_rgb: avoid highlight overflows (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt authored Mar 7, 2024
1 parent 8ac5ce9 commit c094032
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nokhwa-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1714,9 +1714,9 @@ pub fn yuyv444_to_rgb(y: i32, u: i32, v: i32) -> [u8; 3] {
let c298 = (y - 16) * 298;
let d = u - 128;
let e = v - 128;
let r = ((c298 + 409 * e + 128) >> 8) as u8;
let g = ((c298 - 100 * d - 208 * e + 128) >> 8) as u8;
let b = ((c298 + 516 * d + 128) >> 8) as u8;
let r = ((c298 + 409 * e + 128) >> 8).clamp(0, 255) as u8;
let g = ((c298 - 100 * d - 208 * e + 128) >> 8).clamp(0, 255) as u8;
let b = ((c298 + 516 * d + 128) >> 8).clamp(0, 255) as u8;
[r, g, b]
}

Expand Down

0 comments on commit c094032

Please sign in to comment.