2
/******************************************************************
4
iLBC Speech Coder ANSI-C Source Code
8
Copyright (C) The Internet Society (2004).
11
******************************************************************/
13
#include "iLBC_define.h"
15
/*----------------------------------------------------------------*
17
*---------------------------------------------------------------*/
20
float *InOut, /* (i/o) on entrance InOut[-orderCoef] to
21
InOut[-1] contain the state of the
22
filter (delayed samples). InOut[0] to
23
InOut[lengthInOut-1] contain the filter
24
input, on en exit InOut[-orderCoef] to
25
InOut[-1] is unchanged and InOut[0] to
26
InOut[lengthInOut-1] contain filtered
28
float *Coef,/* (i) filter coefficients, Coef[0] is assumed
30
int lengthInOut,/* (i) number of input/output samples */
31
int orderCoef /* (i) number of filter coefficients */
35
for(n=0;n<lengthInOut;n++){
36
for(k=1;k<=orderCoef;k++){
37
*InOut -= Coef[k]*InOut[-k];
48
/*----------------------------------------------------------------*
50
*---------------------------------------------------------------*/
53
float *In, /* (i) In[0] to In[lengthInOut-1] contain
54
filter input samples */
55
float *Coef,/* (i) filter coefficients (Coef[0] is assumed
57
int lengthInOut,/* (i) number of input/output samples */
58
int orderCoef, /* (i) number of filter coefficients */
59
float *Out /* (i/o) on entrance Out[-orderCoef] to Out[-1]
60
contain the filter state, on exit Out[0]
61
to Out[lengthInOut-1] contain filtered
66
for(n=0;n<lengthInOut;n++){
68
for(k=1;k<=orderCoef;k++){
69
*Out += Coef[k]*In[-k];
76
/*----------------------------------------------------------------*
78
*---------------------------------------------------------------*/
81
float *In, /* (i) In[0] to In[lengthInOut-1] contain
82
filter input samples In[-orderCoef] to
83
In[-1] contain state of all-zero
85
float *ZeroCoef,/* (i) filter coefficients for all-zero
86
section (ZeroCoef[0] is assumed to
88
float *PoleCoef,/* (i) filter coefficients for all-pole section
89
(ZeroCoef[0] is assumed to be 1.0) */
90
int lengthInOut,/* (i) number of input/output samples */
96
int orderCoef, /* (i) number of filter coefficients */
97
float *Out /* (i/o) on entrance Out[-orderCoef] to Out[-1]
98
contain state of all-pole section. On
99
exit Out[0] to Out[lengthInOut-1]
100
contain filtered samples */
102
AllZeroFilter(In,ZeroCoef,lengthInOut,orderCoef,Out);
103
AllPoleFilter(Out,PoleCoef,lengthInOut,orderCoef);
106
/*----------------------------------------------------------------*
107
* downsample (LP filter and decimation)
108
*---------------------------------------------------------------*/
111
float *In, /* (i) input samples */
112
float *Coef, /* (i) filter coefficients */
113
int lengthIn, /* (i) number of input samples */
114
float *state, /* (i) filter state */
115
float *Out /* (o) downsampled output */
118
float *Out_ptr = Out;
119
float *Coef_ptr, *In_ptr;
123
/* LP filter and decimate at the same time */
125
for (i = DELAY_DS; i < lengthIn; i+=FACTOR_DS)
129
state_ptr = &state[FILTERORDER_DS-2];
133
stop = (i < FILTERORDER_DS) ? i + 1 : FILTERORDER_DS;
135
for (j = 0; j < stop; j++)
137
o += *Coef_ptr++ * (*In_ptr--);
139
for (j = i + 1; j < FILTERORDER_DS; j++)
141
o += *Coef_ptr++ * (*state_ptr--);
152
/* Get the last part (use zeros as input for the future) */
154
for (i=(lengthIn+FACTOR_DS); i<(lengthIn+DELAY_DS);
162
for (j=0; j<FILTERORDER_DS; j++) {
163
o += *Coef_ptr++ * (*Out_ptr--);
166
Coef_ptr = &Coef[i-lengthIn];
167
In_ptr = &In[lengthIn-1];
168
for (j=0; j<FILTERORDER_DS-(i-lengthIn); j++) {
169
o += *Coef_ptr++ * (*In_ptr--);