【发布时间】:2012-04-06 12:42:30
【问题描述】:
与 IIR 滤波器系数相关的快速问题。这是我在网上找到的一个直接形式 II 双二阶 IIR 处理器的非常典型的实现。
// b0, b1, b2, a1, a2 are filter coefficients
// m1, m2 are the memory locations
// dn is the de-denormal coeff (=1.0e-20f)
void processBiquad(const float* in, float* out, unsigned length)
{
for(unsigned i = 0; i < length; ++i)
{
register float w = in[i] - a1*m1 - a2*m2 + dn;
out[i] = b1*m1 + b2*m2 + b0*w;
m2 = m1; m1 = w;
}
dn = -dn;
}
我知道考虑到现代编译器对这类事情的聪明程度,“寄存器”在某种程度上是不必要的。我的问题是,将滤波器系数存储在单个变量中而不是使用数组和取消引用值是否有任何潜在的性能优势?这个问题的答案是否取决于目标平台?
即
out[i] = b[1]*m[1] + b[2]*m[2] + b[0]*w;
对
out[i] = b1*m1 + b2*m2 + b0*w;
【问题讨论】:
标签: c++ c optimization filter signal-processing