Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "arm_math.h"
00027
00061 void arm_biquad_cascade_df1_fast_q31(
00062 const arm_biquad_casd_df1_inst_q31 * S,
00063 q31_t * pSrc,
00064 q31_t * pDst,
00065 uint32_t blockSize)
00066 {
00067 q31_t acc;
00068 q31_t Xn1, Xn2, Yn1, Yn2;
00069 q31_t b0, b1, b2, a1, a2;
00070 q31_t *pIn = pSrc;
00071 q31_t *pOut = pDst;
00072 q31_t *pState = S->pState;
00073 q31_t *pCoeffs = S->pCoeffs;
00074 q31_t Xn;
00075 int32_t shift = (int32_t) S->postShift + 1;
00076 uint32_t sample, stage = S->numStages;
00077
00078
00079 do
00080 {
00081
00082 b0 = *pCoeffs++;
00083 b1 = *pCoeffs++;
00084 b2 = *pCoeffs++;
00085 a1 = *pCoeffs++;
00086 a2 = *pCoeffs++;
00087
00088
00089 Xn1 = pState[0];
00090 Xn2 = pState[1];
00091 Yn1 = pState[2];
00092 Yn2 = pState[3];
00093
00094
00095
00096
00097
00098
00099
00100 sample = blockSize >> 2u;
00101
00102
00103
00104 while(sample > 0u)
00105 {
00106
00107 Xn = *pIn;
00108
00109
00110
00111 acc = (q31_t) (((q63_t) b1 * Xn1) >> 32);
00112
00113 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b0 * (Xn))) >> 32);
00114
00115 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn2))) >> 32);
00116
00117 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn1))) >> 32);
00118
00119 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn2))) >> 32);
00120
00121
00122 Yn2 = acc << shift;
00123
00124
00125 Xn2 = *(pIn + 1u);
00126
00127
00128 *pOut = Yn2;
00129
00130
00131
00132 acc = (q31_t) (((q63_t) b0 * (Xn2)) >> 32);
00133
00134 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn))) >> 32);
00135
00136 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn1))) >> 32);
00137
00138 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn2))) >> 32);
00139
00140 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn1))) >> 32);
00141
00142
00143 Yn1 = acc << shift;
00144
00145
00146 Xn1 = *(pIn + 2u);
00147
00148
00149 *(pOut + 1u) = Yn1;
00150
00151
00152
00153 acc = (q31_t) (((q63_t) b0 * (Xn1)) >> 32);
00154
00155 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn2))) >> 32);
00156
00157 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn))) >> 32);
00158
00159 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn1))) >> 32);
00160
00161 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn2))) >> 32);
00162
00163
00164 Yn2 = acc << shift;
00165
00166
00167 Xn = *(pIn + 3u);
00168
00169
00170 *(pOut + 2u) = Yn2;
00171 pIn += 4u;
00172
00173
00174
00175 acc = (q31_t) (((q63_t) b0 * (Xn)) >> 32);
00176
00177 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn1))) >> 32);
00178
00179 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn2))) >> 32);
00180
00181 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn2))) >> 32);
00182
00183 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn1))) >> 32);
00184
00185
00186
00187
00188 Xn2 = Xn1;
00189
00190
00191 Yn1 = acc << shift;
00192
00193
00194 Xn1 = Xn;
00195
00196
00197 *(pOut + 3u) = Yn1;
00198 pOut += 4u;
00199
00200
00201 sample--;
00202 }
00203
00204
00205
00206 sample = (blockSize & 0x3u);
00207
00208 while(sample > 0u)
00209 {
00210
00211 Xn = *pIn++;
00212
00213
00214
00215 acc = (q31_t) (((q63_t) b0 * (Xn)) >> 32);
00216
00217 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b1 * (Xn1))) >> 32);
00218
00219 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) b2 * (Xn2))) >> 32);
00220
00221 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a1 * (Yn1))) >> 32);
00222
00223 acc = (q31_t) ((((q63_t) acc << 32) + ((q63_t) a2 * (Yn2))) >> 32);
00224
00225 acc = acc << shift;
00226
00227
00228
00229
00230
00231
00232
00233 Xn2 = Xn1;
00234 Xn1 = Xn;
00235 Yn2 = Yn1;
00236 Yn1 = acc;
00237
00238
00239 *pOut++ = acc;
00240
00241
00242 sample--;
00243 }
00244
00245
00246
00247 pIn = pDst;
00248
00249
00250 pOut = pDst;
00251
00252
00253 *pState++ = Xn1;
00254 *pState++ = Xn2;
00255 *pState++ = Yn1;
00256 *pState++ = Yn2;
00257
00258 } while(--stage);
00259 }
00260