Skip to content

Commit

Permalink
Move filter assertion closer to where it's used
Browse files Browse the repository at this point in the history
The only unsafe part of filter_signal_in_place_fixed_size_simdx4 now
should be making sure the CPU supports it at runtime.
  • Loading branch information
valadaptive committed Jan 20, 2025
1 parent d7b93a9 commit 68771d8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/ntscrs/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ impl TransferFunction {
scale: f32,
delay: usize,
) {
// Ensure the chunks are actually of equal length
let width = signal[0].len();
for i in 1..ROWS {
assert_eq!(signal[i].len(), width);
}

let mut z = initial.map(|initial| S::load(&self.initial_condition(initial)));

let mut num: [f32; 4] = [0f32; 4];
Expand Down Expand Up @@ -407,12 +413,6 @@ impl TransferFunction {
) {
let filter_len = usize::max(self.num.len(), self.den.len());

// Ensure the chunks are actually of equal length
let width = signal[0].len();
for i in 1..ROWS {
assert_eq!(signal[i].len(), width);
}

match filter_len {
// Specialize fixed-size implementations for filter sizes 1-8
1 => self.filter_signal_in_place_fixed_size::<1, ROWS>(signal, initial, scale, delay),
Expand Down

0 comments on commit 68771d8

Please sign in to comment.