Texas Instruments TMS320C64X Security Camera User Manual


 
DSP_iir
4-54
IIR With 5 Coefficients
DSP_iir
Function void DSP_iir (short * restrict r1, const short * restrict x, short * restrict r2, const
short * restrict h2, const short * restrict h1, int nr)
Arguments r1[nr+4] Output array (used in actual computation. First four elements
must have the previous outputs.)
x[nr+4] Input array
r2[nr] Output array (stored)
h2[5] Moving-average filter coefficients
h1[5] Auto-regressive filter coefficients. h1[0] is not used.
nr Number of output samples. Must be 8.
Description The IIR performs an auto-regressive moving-average (ARMA) filter with 4
auto-regressive filter coefficients and 5 moving-average filter coefficients for
nr output samples.
Algorithm This is the C equivalent of the assembly code without restrictions. Note that
the assembly code is hand optimized and restrictions may apply.
void DSP_iir(short *r1, short *x, short *r2, short *h2,
short *h1, int nr)
{
int j,i;
int sum;
for (i=0; i<nr; i++){
sum = h2[0] * x[4+i];
for (j = 1; j <= 4; j++)
sum += h2[j]*x[4+i−j]−h1[j]*r1[4+i−j];
r1[4+i] = (sum >> 15);
r2[i] = r1[4+i];
}
}