📄 iirfilter_5.c
字号:
#include <stdlib.h>
#include <math.h>
int iirFilter_5( float *inputData, float *outputData,
float *coeff, float *state, int sampleNumber )
{
/* #pragma TCS_unroll=0 */
#pragma apge unroll=0
int i;
float * restrict input, * restrict output;
float temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8;
float coeff_a0, coeff_a1, coeff_a2, coeff_b1, coeff_b2;
float state_0, state_1, state_2, state_3;
float inSample1, inSample2, inSample3, inSample4;
float outSample1, outSample2, outSample3, outSample4;
input = inputData; output = outputData;
coeff_a0 = coeff[0]; coeff_a1 = coeff[1]; coeff_a2 = coeff[2];
coeff_b1 = coeff[3]; coeff_b2 = coeff[4];
state_0 = state[0]; state_1 = state[1];
state_2 = state[2]; state_3 = state[3];
inSample1 = input[0];
inSample2 = input[1];
inSample3 = input[0];
inSample4 = input[1];
for( i=0; i < sampleNumber; i+=4 )
{
temp1 = coeff_a0*inSample1;
temp2 = coeff_a1*state_0;
temp3 = coeff_a2*state_1;
temp4 = coeff_b1*state_2;
temp5 = coeff_b2*state_3;
temp6 = temp1 + temp2; temp7 = temp3 - temp4;
temp8 = temp6 - temp5;
outSample1 = temp7 + temp8;
output[i] = outSample1;
temp1 = coeff_a0*inSample2;
temp2 = coeff_a1*inSample1;
temp3 = coeff_a2*state_0;
temp4 = coeff_b1*outSample1;
temp5 = coeff_b2*state_2;
temp6 = temp1 + temp2; temp7 = temp3 - temp4;
temp8 = temp6 - temp5;
outSample2 = temp7 + temp8;
output[i+1] = outSample2;
temp1 = coeff_a0*inSample3;
temp2 = coeff_a1*inSample2;
temp3 = coeff_a2*inSample1;
temp4 = coeff_b1*outSample2;
temp5 = coeff_b2*outSample1;
temp6 = temp1 + temp2; temp7 = temp3 - temp4;
temp8 = temp6 - temp5;
outSample3 = temp7 + temp8;
output[i+2] = outSample3;
temp1 = coeff_a0*inSample4;
temp2 = coeff_a1*inSample3;
temp3 = coeff_a2*inSample2;
temp4 = coeff_b1*outSample3;
temp5 = coeff_b2*outSample2;
temp6 = temp1 + temp2; temp7 = temp3 - temp4;
temp8 = temp6 - temp5;
outSample4 = temp7 + temp8;
output[i+3] = outSample4;
state_0 = inSample4;
state_1 = inSample3;
state_2 = outSample4;
state_3 = outSample3;
inSample1 = input[i+4];
inSample2 = input[i+5];
inSample3 = input[i+6];
inSample4 = input[i+7];
}
state[0] = state_0; state[1] = state_1;
state[2] = state_2; state[3] = state_3;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -