Skip to content

Commit

Permalink
fn filter_8tap: Simplify using an indices iterator.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen committed Jun 20, 2024
1 parent 36a3fbd commit 8ea195c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/mc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ unsafe fn filter_8tap<T: Into<i32>>(
f: &[i8; 8],
stride: isize,
) -> FilterResult {
let pixel = f
.into_iter()
.enumerate()
.map(|(i, &f)| {
let [i, x] = [i, x].map(|it| it as isize);
let j = x + (i - 3) * stride;
i32::from(f) * src.offset(j).read().into()
let pixel = (0..f.len())
.map(|i| {
let j = x as isize + (i as isize - 3) * stride;
f[i] as i32 * src.offset(j).read().into()
})
.sum();
FilterResult { pixel }
Expand Down

0 comments on commit 8ea195c

Please sign in to comment.