Mark 3d084b7543
Some checks failed
Check / formatting (push) Failing after 11s
Check / linting (push) Failing after 14s
Check / build (push) Failing after 1m26s
Move
2025-01-26 19:28:51 -08:00

48 lines
1.0 KiB
Rust

use std::convert::TryInto;
const GROUP_BY: usize = 16;
pub const fn out_size(in_size: usize) -> usize {
in_size / 16
}
pub fn run(buf: &mut [u8]) {
let n_raw = buf.len();
let mut in_cursor = 0;
let mut out_cursor = 0;
while in_cursor + GROUP_BY <= n_raw {
let a: &[u8; 16] = buf[in_cursor..in_cursor + 16].try_into().unwrap();
let mut out = 0u8;
if a[0] == 0x1E {
out |= 0b10000000;
}
if a[2] == 0x1E {
out |= 0b10000000 >> 1;
}
if a[4] == 0x1E {
out |= 0b10000000 >> 2;
}
if a[6] == 0x1E {
out |= 0b10000000 >> 3;
}
if a[8] == 0x1E {
out |= 0b10000000 >> 4;
}
if a[10] == 0x1E {
out |= 0b10000000 >> 5;
}
if a[12] == 0x1E {
out |= 0b10000000 >> 6;
}
if a[14] == 0x1E {
out |= 0b10000000 >> 7;
}
buf[out_cursor] = out;
out_cursor += 1;
in_cursor += GROUP_BY;
}
}