fparkan/vendor/qoi/tests/common.rs
Valentin Popov 1b6a04ca55
Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
2024-01-08 01:21:28 +04:00

13 lines
364 B
Rust

#[allow(unused)]
pub fn hash<const N: usize>(px: [u8; N]) -> u8 {
let r = px[0];
let g = px[1];
let b = px[2];
let a = if N >= 4 { px[3] } else { 0xff };
let rm = r.wrapping_mul(3);
let gm = g.wrapping_mul(5);
let bm = b.wrapping_mul(7);
let am = a.wrapping_mul(11);
rm.wrapping_add(gm).wrapping_add(bm).wrapping_add(am) % 64
}