modified autogen.sh to remove reference to osl/
[converter.git] / tests / c_files / iir_4_64.c
blobb8bfe4d7a34d4cdd30b548249cfed481d8b38fef
1 /* 4-cascaded IIR biquad filter processing 64 points */
2 /* Modified to use arrays - SMP */
4 //#include "traps.h"
6 #define NPOINTS 64
7 #define NSECTIONS 4
9 float input[NPOINTS];
10 float output[NPOINTS];
11 float coefficient[NSECTIONS][NSECTIONS][NSECTIONS];
12 float internal_state[8][NSECTIONS][2];
14 void iir(float input[NPOINTS], float output[NPOINTS],
15 float coefficient[NSECTIONS][NSECTIONS][NSECTIONS],
16 float internal_state[8][NSECTIONS][2]);
18 main()
20 int i;
22 float *pcoef = coefficient[0][0];
23 float *pint = internal_state[0][0];
25 for(i=0;i<NPOINTS;i++)
27 pcoef[i]=1;
28 pint[i]=1;
30 //input_dsp(input,NPOINTS,0);
32 iir(input, output, coefficient, internal_state);
34 //output_dsp(input,NPOINTS,0);
35 //output_dsp(coefficient,NPOINTS,0);
36 //output_dsp(internal_state,NPOINTS,0);
37 //output_dsp(output,NPOINTS,0);
40 void iir(float input[NPOINTS], float output[NPOINTS],
41 float coefficient[NSECTIONS][NSECTIONS][NSECTIONS],
42 float internal_state[8][NSECTIONS][2])
43 /* input: input sample array */
44 /* output: output sample array */
45 /* coefficient: coefficient array */
46 /* internal_state: internal state array */
48 int i, imod8, imodNSECTIONS;
49 int j;
51 float state_2, state_1;
52 float coef_a21, coef_a11, coef_b21, coef_b11;
53 float sum;
55 for (i = 0; i < NPOINTS; ++i) {
57 imod8 = i % 8;
58 imodNSECTIONS = i % NSECTIONS;
60 #pragma scop
61 sum = input[i];
63 for (j = 0; j < NSECTIONS; ++j) {
65 state_2 = internal_state[imod8][j][0];
66 state_1 = internal_state[imod8][j][1];
68 sum -= internal_state[imod8][j][0] * coefficient[imodNSECTIONS][j][0] +
69 internal_state[imod8][j][1] * coefficient[imodNSECTIONS][j][1];
71 internal_state[imod8][j][0] = internal_state[imod8][j][1];
72 internal_state[imod8][j][1] = sum;
74 sum += state_2 * coefficient[imodNSECTIONS][j][2] +
75 state_1 * coefficient[imodNSECTIONS][j][3];
79 output[i] = sum;
80 #pragma endscop