Skip to content
Discussion options

You must be logged in to vote

Hi,

I've looked at your test case. This isn't a bug in KFR.

The main issue is that the coefficient format is wrong. Your sos array contains a single 4th-order direct-form IIR filter:

[ a0=1, a1, a2, a3, a4,   b0, b1, b2, b3, b4 ]

The reference filter interprets it this way, but kfr_filter_create_iir_plan_f64 expects a cascade of 2nd-order sections, where each section is [a0, a1, a2, b0, b1, b2]. Passing direct-form coefficients to the SOS API will produce incorrect results.

There's also an out-of-bounds read. With sos_count = 2, KFR reads 2 × 6 = 12 doubles, but your array only contains 10, so it reads past the end. That's undefined behavior and explains the inconsistent results.

The fix…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@dancasarin
Comment options

@jpka-
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jpka-
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants