src/math/iir_df2t_generic.c
/* 32 bit data, 32 bit coefficients and 64 bit state variables */
32 bit data, 32 bit coefficients and 64 bit state variables
32 bit data 32 bit coefficients and 64 bit state variables
int32_t iir_df2t(struct iir_state_df2t *iir, int32_t x)
{
	int32_t in;
	int32_t tmp;
	int64_t acc;
	int32_t out = 0;
	int i;
	int j;
	int d = 0; 
	int c = 0; 
	if (!iir->biquads)
		return x;
	in = x;
	for (j = 0; j < iir->biquads; j += iir->biquads_in_series) {
		for (i = 0; i < iir->biquads_in_series; i++) {
			acc = ((int64_t)iir->coef[c + 4]) * in + iir->delay[d]; 
			tmp = (int32_t)sat_int32(Q_SHIFT_RND(acc, 61, 31));
			acc = iir->delay[d + 1];
			acc += ((int64_t)iir->coef[c + 3]) * in; 
			acc += ((int64_t)iir->coef[c + 1]) * tmp; 
			iir->delay[d] = acc;
			acc = ((int64_t)iir->coef[c + 2]) * in; 
			acc += ((int64_t)iir->coef[c]) * tmp; 
			iir->delay[d + 1] = acc;
			acc = ((int64_t)iir->coef[c + 6]) * tmp; 
			acc = Q_SHIFT_RND(acc, 45 + iir->coef[c + 5], 31);
			in = sat_int32(acc);
			c += SOF_EQ_IIR_NBIQUAD_DF2T;
			d += IIR_DF2T_NUM_DELAYS;
		}
		out = sat_int32((int64_t)out + in);
	}
	return out;
}
int32_t iir_df2t ( struct iir_state_df2t * iir , int32_t x ) { int32_t in ; int32_t tmp ; int64_t acc ; int32_t out = 0 ; int i ; int j ; int d = 0 ; int c = 0 ; if ( ! iir -> biquads ) return x ; in = x ; for ( j = 0 ; j < iir -> biquads ; j += iir -> biquads_in_series ) { for ( i = 0 ; i < iir -> biquads_in_series ; i ++ ) { acc = ( ( int64_t ) iir -> coef [ c + 4 ] ) * in + iir -> delay [ d ] ; tmp = ( int32_t ) sat_int32 ( Q_SHIFT_RND ( acc , 61 , 31 ) ) ; acc = iir -> delay [ d + 1 ] ; acc += ( ( int64_t ) iir -> coef [ c + 3 ] ) * in ; acc += ( ( int64_t ) iir -> coef [ c + 1 ] ) * tmp ; iir -> delay [ d ] = acc ; acc = ( ( int64_t ) iir -> coef [ c + 2 ] ) * in ; acc += ( ( int64_t ) iir -> coef [ c ] ) * tmp ; iir -> delay [ d + 1 ] = acc ; acc = ( ( int64_t ) iir -> coef [ c + 6 ] ) * tmp ; acc = Q_SHIFT_RND ( acc , 45 + iir -> coef [ c + 5 ] , 31 ) ; in = sat_int32 ( acc ) ; c += SOF_EQ_IIR_NBIQUAD_DF2T ; d += IIR_DF2T_NUM_DELAYS ; } out = sat_int32 ( ( int64_t ) out + in ) ; } return out ; }
32 bit data, 32 bit coefficients and 64 bit state variables
32 bit data 32 bit coefficients and 64 bit state variables
/* Index to delays */ /* Index to coefficient a2 */ /* Bypass is set with number of biquads set to zero. */ /* Coefficients order in coef[] is {a2, a1, b2, b1, b0, shift, gain} */ /* Compute output: Delay is Q3.61
			 * Q2.30 x Q1.31 -> Q3.61
			 * Shift Q3.61 to Q3.31 with rounding, saturate to Q1.31
			 */ /* Coef b0 */ /* Compute first delay */ /* Coef  b1 */ /* Coef a1 */ /* Compute second delay */ /* Coef  b2 */ /* Coef a2 */ /* Apply gain Q2.14 x Q1.31 -> Q3.45 */ /* Gain */ /* Apply biquad output shift right parameter
			 * simultaneously with Q3.45 to Q3.31 conversion. Then
			 * saturate to 32 bits Q1.31 and prepare for next
			 * biquad.
			 */ /* Proceed to next biquad coefficients and delay
			 * lines.
			 */ /* Output of previous section is in variable in */