@ -37,78 +37,32 @@
@ {
*/
# if defined(ARM_MATH_NEON)
/**
@ brief Initialization function for the floating - point transposed direct form II Biquad cascade filter .
@ param [ in , out ] S points to an instance of the filter data structure .
@ brief Compute new coefficient arrays for use in vectorized filter ( Neon only ) .
@ param [ in ] numStages number of 2 nd order stages in the filter .
@ param [ in ] pCoeffs points to the filter coefficients .
@ param [ in ] p State points to the state buffer .
@ param [ in ] pCoeffs points to the original filter coefficients .
@ param [ in ] p ComputedCoeffs points to the new computed coefficients for the vectorized Neon version .
@ return none
@ par Coefficient and State Ordering
The coefficients are stored in the array < code > pCoeffs < / code > in the following order
in the not Neon version .
< pre >
{ b10 , b11 , b12 , a11 , a12 , b20 , b21 , b22 , a21 , a22 , . . . }
< / pre >
@ par Size of coefficient arrays :
pCoeffs has size 5 * numStages
@ par
where < code > b1x < / code > and < code > a1x < / code > are the coefficients for the first stage ,
< code > b2x < / code > and < code > a2x < / code > are the coefficients for the second stage ,
and so on . The < code > pCoeffs < / code > array contains a total of < code > 5 * numStages < / code > values .
For Neon version , this array is bigger . If numstages = 4 x + y , then the array has size :
32 * x + 5 * y
and it must be initialized using the function
arm_biquad_cascade_df2T_compute_coefs_f32 which is taking the
standard array coefficient as parameters .
pComputedCoeffs has size 8 * numStages
But , an array of 8 * numstages is a good approximation .
Then , the initialization can be done with :
< pre >
arm_biquad_cascade_df2T_init_f32 ( & SNeon , nbCascade , neonCoefs , stateNeon ) ;
arm_biquad_cascade_df2T_compute_coefs_f32 ( & SNeon , nbCascade , coefs ) ;
< / pre >
@ par In this example , neonCoefs is a bigger array of size 8 * numStages .
coefs is the standard array :
< pre >
{ b10 , b11 , b12 , a11 , a12 , b20 , b21 , b22 , a21 , a22 , . . . }
< / pre >
@ par
The < code > pState < / code > is a pointer to state array .
Each Biquad stage has 2 state variables < code > d1 , < / code > and < code > d2 < / code > .
The 2 state variables for stage 1 are first , then the 2 state variables for stage 2 , and so on .
The state array has a total length of < code > 2 * numStages < / code > values .
The state variables are updated after each block of data is processed ; the coefficients are untouched .
*/
# if defined(ARM_MATH_NEON)
/*
Must be called after initializing the biquad instance .
pCoeffs has size 5 * nbCascade
Whereas the pCoeffs for the init has size ( 4 * 4 + 4 * 4 ) * nbCascade
So this pCoeffs is the one which would be used for the not Neon version .
The pCoeffs passed in init is bigger than the one for the not Neon version .
pComputedCoeffs is the array to be used in arm_biquad_cascade_df2T_init_f32 .
*/
void arm_biquad_cascade_df2T_compute_coefs_f32 (
arm_biquad_cascade_df2T_instance_f32 * S ,
uint8_t numStages ,
const float32_t * pCoeffs )
const float32_t * pCoeffs ,
float32_t * pComputedCoeffs )
{
uint8_t cnt ;
float32_t * pDstCoeffs ;
float32_t b0 [ 4 ] , b1 [ 4 ] , b2 [ 4 ] , a1 [ 4 ] , a2 [ 4 ] ;
pDstCoeffs = ( float32_t * ) S - > pCoeffs ;
cnt = numStages > > 2 ;
while ( cnt > 0 )
{
@ -123,52 +77,52 @@ void arm_biquad_cascade_df2T_compute_coefs_f32(
}
/* Vec 1 */
* p Dst Coeffs+ + = 0 ;
* p Dst Coeffs+ + = b0 [ 1 ] ;
* p Dst Coeffs+ + = b0 [ 2 ] ;
* p Dst Coeffs+ + = b0 [ 3 ] ;
* p Computed Coeffs+ + = 0 ;
* p Computed Coeffs+ + = b0 [ 1 ] ;
* p Computed Coeffs+ + = b0 [ 2 ] ;
* p Computed Coeffs+ + = b0 [ 3 ] ;
/* Vec 2 */
* p Dst Coeffs+ + = 0 ;
* p Dst Coeffs+ + = 0 ;
* p Dst Coeffs+ + = b0 [ 1 ] * b0 [ 2 ] ;
* p Dst Coeffs+ + = b0 [ 2 ] * b0 [ 3 ] ;
* p Computed Coeffs+ + = 0 ;
* p Computed Coeffs+ + = 0 ;
* p Computed Coeffs+ + = b0 [ 1 ] * b0 [ 2 ] ;
* p Computed Coeffs+ + = b0 [ 2 ] * b0 [ 3 ] ;
/* Vec 3 */
* p Dst Coeffs+ + = 0 ;
* p Dst Coeffs+ + = 0 ;
* p Dst Coeffs+ + = 0 ;
* p Dst Coeffs+ + = b0 [ 1 ] * b0 [ 2 ] * b0 [ 3 ] ;
* p Computed Coeffs+ + = 0 ;
* p Computed Coeffs+ + = 0 ;
* p Computed Coeffs+ + = 0 ;
* p Computed Coeffs+ + = b0 [ 1 ] * b0 [ 2 ] * b0 [ 3 ] ;
/* Vec 4 */
* p Dst Coeffs+ + = b0 [ 0 ] ;
* p Dst Coeffs+ + = b0 [ 0 ] * b0 [ 1 ] ;
* p Dst Coeffs+ + = b0 [ 0 ] * b0 [ 1 ] * b0 [ 2 ] ;
* p Dst Coeffs+ + = b0 [ 0 ] * b0 [ 1 ] * b0 [ 2 ] * b0 [ 3 ] ;
* p Computed Coeffs+ + = b0 [ 0 ] ;
* p Computed Coeffs+ + = b0 [ 0 ] * b0 [ 1 ] ;
* p Computed Coeffs+ + = b0 [ 0 ] * b0 [ 1 ] * b0 [ 2 ] ;
* p Computed Coeffs+ + = b0 [ 0 ] * b0 [ 1 ] * b0 [ 2 ] * b0 [ 3 ] ;
/* Vec 5 */
* p Dst Coeffs+ + = b1 [ 0 ] ;
* p Dst Coeffs+ + = b1 [ 1 ] ;
* p Dst Coeffs+ + = b1 [ 2 ] ;
* p Dst Coeffs+ + = b1 [ 3 ] ;
* p Computed Coeffs+ + = b1 [ 0 ] ;
* p Computed Coeffs+ + = b1 [ 1 ] ;
* p Computed Coeffs+ + = b1 [ 2 ] ;
* p Computed Coeffs+ + = b1 [ 3 ] ;
/* Vec 6 */
* p Dst Coeffs+ + = b2 [ 0 ] ;
* p Dst Coeffs+ + = b2 [ 1 ] ;
* p Dst Coeffs+ + = b2 [ 2 ] ;
* p Dst Coeffs+ + = b2 [ 3 ] ;
* p Computed Coeffs+ + = b2 [ 0 ] ;
* p Computed Coeffs+ + = b2 [ 1 ] ;
* p Computed Coeffs+ + = b2 [ 2 ] ;
* p Computed Coeffs+ + = b2 [ 3 ] ;
/* Vec 7 */
* p Dst Coeffs+ + = a1 [ 0 ] ;
* p Dst Coeffs+ + = a1 [ 1 ] ;
* p Dst Coeffs+ + = a1 [ 2 ] ;
* p Dst Coeffs+ + = a1 [ 3 ] ;
* p Computed Coeffs+ + = a1 [ 0 ] ;
* p Computed Coeffs+ + = a1 [ 1 ] ;
* p Computed Coeffs+ + = a1 [ 2 ] ;
* p Computed Coeffs+ + = a1 [ 3 ] ;
/* Vec 8 */
* p Dst Coeffs+ + = a2 [ 0 ] ;
* p Dst Coeffs+ + = a2 [ 1 ] ;
* p Dst Coeffs+ + = a2 [ 2 ] ;
* p Dst Coeffs+ + = a2 [ 3 ] ;
* p Computed Coeffs+ + = a2 [ 0 ] ;
* p Computed Coeffs+ + = a2 [ 1 ] ;
* p Computed Coeffs+ + = a2 [ 2 ] ;
* p Computed Coeffs+ + = a2 [ 3 ] ;
cnt - - ;
}
@ -176,17 +130,66 @@ void arm_biquad_cascade_df2T_compute_coefs_f32(
cnt = numStages & 0x3 ;
while ( cnt > 0 )
{
* p Dst Coeffs+ + = * pCoeffs + + ;
* p Dst Coeffs+ + = * pCoeffs + + ;
* p Dst Coeffs+ + = * pCoeffs + + ;
* p Dst Coeffs+ + = * pCoeffs + + ;
* p Dst Coeffs+ + = * pCoeffs + + ;
* p Computed Coeffs+ + = * pCoeffs + + ;
* p Computed Coeffs+ + = * pCoeffs + + ;
* p Computed Coeffs+ + = * pCoeffs + + ;
* p Computed Coeffs+ + = * pCoeffs + + ;
* p Computed Coeffs+ + = * pCoeffs + + ;
cnt - - ;
}
}
# endif
/**
@ brief Initialization function for the floating - point transposed direct form II Biquad cascade filter .
@ param [ in , out ] S points to an instance of the filter data structure .
@ param [ in ] numStages number of 2 nd order stages in the filter .
@ param [ in ] pCoeffs points to the filter coefficients .
@ param [ in ] pState points to the state buffer .
@ return none
@ par Coefficient and State Ordering
The coefficients are stored in the array < code > pCoeffs < / code > in the following order
in the not Neon version .
< pre >
{ b10 , b11 , b12 , a11 , a12 , b20 , b21 , b22 , a21 , a22 , . . . }
< / pre >
@ par
where < code > b1x < / code > and < code > a1x < / code > are the coefficients for the first stage ,
< code > b2x < / code > and < code > a2x < / code > are the coefficients for the second stage ,
and so on . The < code > pCoeffs < / code > array contains a total of < code > 5 * numStages < / code > values .
For Neon version , this array is bigger . If numstages = 4 x + y , then the array has size :
32 * x + 5 * y
and it must be initialized using the function
arm_biquad_cascade_df2T_compute_coefs_f32 which is taking the
standard array coefficient as parameters .
But , an array of 8 * numstages is a good approximation .
Then , the initialization can be done with :
< pre >
arm_biquad_cascade_df2T_compute_coefs_f32 ( nbCascade , coefs , computedCoefs ) ;
arm_biquad_cascade_df2T_init_f32 ( & SNeon , nbCascade , computedCoefs , stateNeon ) ;
< / pre >
@ par In this example , computedCoefs is a bigger array of size 8 * numStages .
coefs is the standard array :
< pre >
{ b10 , b11 , b12 , a11 , a12 , b20 , b21 , b22 , a21 , a22 , . . . }
< / pre >
@ par
The < code > pState < / code > is a pointer to state array .
Each Biquad stage has 2 state variables < code > d1 , < / code > and < code > d2 < / code > .
The 2 state variables for stage 1 are first , then the 2 state variables for stage 2 , and so on .
The state array has a total length of < code > 2 * numStages < / code > values .
The state variables are updated after each block of data is processed ; the coefficients are untouched .
*/
void arm_biquad_cascade_df2T_init_f32 (
arm_biquad_cascade_df2T_instance_f32 * S ,
uint8_t numStages ,