filters_bfin.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /* Copyright (C) 2005 Analog Devices */
  2. /**
  3. @file filters_bfin.h
  4. @brief Various analysis/synthesis filters (Blackfin version)
  5. */
  6. /*
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions
  9. are met:
  10. - Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. - Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. - Neither the name of the Xiph.org Foundation nor the names of its
  16. contributors may be used to endorse or promote products derived from
  17. this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
  22. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  23. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  25. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include "bfin.h"
  31. #define OVERRIDE_NORMALIZE16
  32. int normalize16(const spx_sig_t *x, spx_word16_t *y, spx_sig_t max_scale, int len)
  33. {
  34. spx_sig_t max_val=1;
  35. int sig_shift;
  36. __asm__
  37. (
  38. "%0 = 0;\n\t"
  39. "I0 = %1;\n\t"
  40. "L0 = 0;\n\t"
  41. "R1 = [I0++];\n\t"
  42. "LOOP norm_max%= LC0 = %2;\n\t"
  43. "LOOP_BEGIN norm_max%=;\n\t"
  44. "R2 = ABS R1 || R1 = [I0++];\n\t"
  45. "%0 = MAX(%0, R2);\n\t"
  46. "LOOP_END norm_max%=;\n\t"
  47. : "=&d" (max_val)
  48. : "a" (x), "a" (len)
  49. : "R1", "R2", "ASTAT" BFIN_HWLOOP0_REGS
  50. );
  51. sig_shift=0;
  52. while (max_val>max_scale)
  53. {
  54. sig_shift++;
  55. max_val >>= 1;
  56. }
  57. __asm__ __volatile__
  58. (
  59. "I0 = %0;\n\t"
  60. "L0 = 0;\n\t"
  61. "P1 = %1;\n\t"
  62. "R0 = [I0++];\n\t"
  63. "LOOP norm_shift%= LC0 = %3;\n\t"
  64. "LOOP_BEGIN norm_shift%=;\n\t"
  65. "R1 = ASHIFT R0 by %2.L || R0 = [I0++];\n\t"
  66. "W[P1++] = R1;\n\t"
  67. "LOOP_END norm_shift%=;\n\t"
  68. "R1 = ASHIFT R0 by %2.L;\n\t"
  69. "W[P1++] = R1;\n\t"
  70. : : "a" (x), "a" (y), "d" (-sig_shift), "a" (len-1)
  71. : "I0", "L0", "P1", "R0", "R1", "memory", "ASTAT" BFIN_HWLOOP0_REGS
  72. );
  73. return sig_shift;
  74. }
  75. #define OVERRIDE_FILTER_MEM16
  76. void filter_mem16(const spx_word16_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_word16_t *_y, int N, int ord, spx_mem_t *mem, char *stack)
  77. {
  78. VARDECL(spx_word32_t *xy2);
  79. VARDECL(spx_word32_t *numden_a);
  80. spx_word32_t *xy;
  81. spx_word16_t *numden;
  82. int i;
  83. ALLOC(xy2, (N+1), spx_word32_t);
  84. ALLOC(numden_a, (2*ord+2), spx_word32_t);
  85. xy = xy2+1;
  86. numden = (spx_word16_t*) numden_a;
  87. for (i=0;i<ord;i++)
  88. {
  89. numden[2*i] = num[i];
  90. numden[2*i+1] = den[i];
  91. }
  92. __asm__ __volatile__
  93. (
  94. /* Register setup */
  95. "R0 = %5;\n\t" /*ord */
  96. "P0 = %3;\n\t"
  97. "I0 = P0;\n\t"
  98. "B0 = P0;\n\t" /* numden */
  99. "L0 = 0;\n\t"
  100. "P2 = %0;\n\t" /* Fused xy */
  101. "I2 = P2;\n\t"
  102. "L2 = 0;\n\t"
  103. "P4 = %6;\n\t" /* mem */
  104. "P0 = %1;\n\t" /* _x */
  105. "P1 = %2;\n\t" /* _y */
  106. /* First sample */
  107. "R1 = [P4++];\n\t"
  108. "R1 <<= 3;\n\t" /* shift mem */
  109. "R1.L = R1 (RND);\n\t"
  110. "R2 = W[P0++];\n\t" /* load x[0] */
  111. "R1.L = R1.L + R2.L;\n\t"
  112. "W[P1++] = R1;\n\t" /* store y[0] */
  113. "R2 = PACK(R1.L, R2.L);\n\t" /* pack x16 and y16 */
  114. "[P2] = R2;\n\t"
  115. /* Samples 1 to ord-1 (using memory) */
  116. "R0 += -1;\n\t"
  117. "R3 = 0;\n\t"
  118. "LC0 = R0;\n\t"
  119. "LOOP filter_start%= LC0;\n\t"
  120. "LOOP_BEGIN filter_start%=;\n\t"
  121. "R3 += 1;\n\t"
  122. "LC1 = R3;\n\t"
  123. "R1 = [P4++];\n\t"
  124. "A1 = R1;\n\t"
  125. "A0 = 0;\n\t"
  126. "I0 = B0;\n\t"
  127. "I2 = P2;\n\t"
  128. "P2 += 4;\n\t"
  129. "R4 = [I0++] || R5 = [I2--];\n\t"
  130. "LOOP filter_start_inner%= LC1;\n\t"
  131. "LOOP_BEGIN filter_start_inner%=;\n\t"
  132. "A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
  133. "LOOP_END filter_start_inner%=;\n\t"
  134. "A0 += A1;\n\t"
  135. "R4 = A0;\n\t"
  136. "R4 <<= 3;\n\t" /* shift mem */
  137. "R4.L = R4 (RND);\n\t"
  138. "R2 = W[P0++];\n\t" /* load x */
  139. "R4.L = R4.L + R2.L;\n\t"
  140. "W[P1++] = R4;\n\t" /* store y */
  141. //"R4 <<= 2;\n\t"
  142. //"R2 <<= 2;\n\t"
  143. "R2 = PACK(R4.L, R2.L);\n\t" /* pack x16 and y16 */
  144. "[P2] = R2;\n\t"
  145. "LOOP_END filter_start%=;\n\t"
  146. /* Samples ord to N*/
  147. "R0 = %5;\n\t"
  148. "R0 <<= 1;\n\t"
  149. "I0 = B0;\n\t" /* numden */
  150. "R0 <<= 1;\n\t"
  151. "L0 = R0;\n\t"
  152. "R0 = %5;\n\t" /* org */
  153. "R2 = %4;\n\t" /* N */
  154. "R2 = R2 - R0;\n\t"
  155. "R4 = [I0++];\n\t" /* numden */
  156. "LC0 = R2;\n\t"
  157. "P3 = R0;\n\t"
  158. "R0 <<= 2;\n\t"
  159. "R0 += 8;\n\t"
  160. "I2 = P2;\n\t"
  161. "M0 = R0;\n\t"
  162. "A1 = A0 = 0;\n\t"
  163. "R5 = [I2--];\n\t" /* load xy */
  164. "LOOP filter_mid%= LC0;\n\t"
  165. "LOOP_BEGIN filter_mid%=;\n\t"
  166. "LOOP filter_mid_inner%= LC1=P3;\n\t"
  167. "LOOP_BEGIN filter_mid_inner%=;\n\t"
  168. "A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
  169. "LOOP_END filter_mid_inner%=;\n\t"
  170. "R0 = (A0 += A1) || I2 += M0;\n\t"
  171. "R0 = R0 << 3 || R5 = W[P0++];\n\t" /* load x */
  172. "R0.L = R0 (RND);\n\t"
  173. "R0.L = R0.L + R5.L;\n\t"
  174. "R5 = PACK(R0.L, R5.L) || W[P1++] = R0;\n\t" /* shift y | store y */
  175. "A1 = A0 = 0 || [I2--] = R5\n\t"
  176. "LOOP_END filter_mid%=;\n\t"
  177. "I2 += 4;\n\t"
  178. "P2 = I2;\n\t"
  179. /* Update memory */
  180. "P4 = %6;\n\t"
  181. "R0 = %5;\n\t"
  182. "LC0 = R0;\n\t"
  183. "P0 = B0;\n\t"
  184. "A1 = A0 = 0;\n\t"
  185. "LOOP mem_update%= LC0;\n\t"
  186. "LOOP_BEGIN mem_update%=;\n\t"
  187. "I2 = P2;\n\t"
  188. "I0 = P0;\n\t"
  189. "P0 += 4;\n\t"
  190. "R0 = LC0;\n\t"
  191. "LC1 = R0;\n\t"
  192. "R5 = [I2--] || R4 = [I0++];\n\t"
  193. "LOOP mem_accum%= LC1;\n\t"
  194. "LOOP_BEGIN mem_accum%=;\n\t"
  195. "A1 -= R4.H*R5.H, A0 += R4.L*R5.L (IS) || R4 = [I0++] || R5 = [I2--];\n\t"
  196. "LOOP_END mem_accum%=;\n\t"
  197. "R0 = (A0 += A1);\n\t"
  198. "A1 = A0 = 0 || [P4++] = R0;\n\t"
  199. "LOOP_END mem_update%=;\n\t"
  200. "L0 = 0;\n\t"
  201. : : "m" (xy), "m" (_x), "m" (_y), "m" (numden), "m" (N), "m" (ord), "m" (mem)
  202. : "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B0", "I0", "I2", "L0", "L2", "M0", "memory",
  203. "ASTAT" BFIN_HWLOOP0_REGS BFIN_HWLOOP1_REGS
  204. );
  205. }
  206. #define OVERRIDE_IIR_MEM16
  207. void iir_mem16(const spx_word16_t *_x, const spx_coef_t *den, spx_word16_t *_y, int N, int ord, spx_mem_t *mem, char *stack)
  208. {
  209. VARDECL(spx_word16_t *y);
  210. spx_word16_t *yy;
  211. ALLOC(y, (N+2), spx_word16_t);
  212. yy = y+2;
  213. __asm__ __volatile__
  214. (
  215. /* Register setup */
  216. "R0 = %5;\n\t" /*ord */
  217. "P1 = %3;\n\t"
  218. "I1 = P1;\n\t"
  219. "B1 = P1;\n\t"
  220. "L1 = 0;\n\t"
  221. "P3 = %0;\n\t"
  222. "I3 = P3;\n\t"
  223. "L3 = 0;\n\t"
  224. "P4 = %6;\n\t"
  225. "P0 = %1;\n\t"
  226. "P1 = %2;\n\t"
  227. /* First sample */
  228. "R1 = [P4++];\n\t"
  229. "R1 = R1 << 3 (S);\n\t"
  230. "R1.L = R1 (RND);\n\t"
  231. "R2 = W[P0++];\n\t"
  232. "R1 = R1 + R2;\n\t"
  233. "W[P1++] = R1;\n\t"
  234. "W[P3] = R1;\n\t"
  235. /* Samples 1 to ord-1 (using memory) */
  236. "R0 += -1;\n\t"
  237. "R3 = 0;\n\t"
  238. "LC0 = R0;\n\t"
  239. "LOOP filter_start%= LC0;\n\t"
  240. "LOOP_BEGIN filter_start%=;\n\t"
  241. "R3 += 1;\n\t"
  242. "LC1 = R3;\n\t"
  243. "R1 = [P4++];\n\t"
  244. "A1 = R1;\n\t"
  245. "I1 = B1;\n\t"
  246. "I3 = P3;\n\t"
  247. "P3 += 2;\n\t"
  248. "LOOP filter_start_inner%= LC1;\n\t"
  249. "LOOP_BEGIN filter_start_inner%=;\n\t"
  250. "R4.L = W[I1++];\n\t"
  251. "R5.L = W[I3--];\n\t"
  252. "A1 -= R4.L*R5.L (IS);\n\t"
  253. "LOOP_END filter_start_inner%=;\n\t"
  254. "R1 = A1;\n\t"
  255. "R1 <<= 3;\n\t"
  256. "R1.L = R1 (RND);\n\t"
  257. "R2 = W[P0++];\n\t"
  258. "R1 = R1 + R2;\n\t"
  259. "W[P1++] = R1;\n\t"
  260. "W[P3] = R1;\n\t"
  261. "LOOP_END filter_start%=;\n\t"
  262. /* Samples ord to N*/
  263. "R0 = %5;\n\t"
  264. "R0 <<= 1;\n\t"
  265. "I1 = B1;\n\t"
  266. "L1 = R0;\n\t"
  267. "R0 = %5;\n\t"
  268. "R2 = %4;\n\t"
  269. "R2 = R2 - R0;\n\t"
  270. "R4.L = W[I1++];\n\t"
  271. "LC0 = R2;\n\t"
  272. "LOOP filter_mid%= LC0;\n\t"
  273. "LOOP_BEGIN filter_mid%=;\n\t"
  274. "LC1 = R0;\n\t"
  275. "A1 = 0;\n\t"
  276. "I3 = P3;\n\t"
  277. "P3 += 2;\n\t"
  278. "R5.L = W[I3--];\n\t"
  279. "LOOP filter_mid_inner%= LC1;\n\t"
  280. "LOOP_BEGIN filter_mid_inner%=;\n\t"
  281. "A1 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
  282. "LOOP_END filter_mid_inner%=;\n\t"
  283. "R1 = A1;\n\t"
  284. "R1 = R1 << 3 || R2 = W[P0++];\n\t"
  285. "R1.L = R1 (RND);\n\t"
  286. "R1 = R1 + R2;\n\t"
  287. "W[P1++] = R1;\n\t"
  288. "W[P3] = R1;\n\t"
  289. "LOOP_END filter_mid%=;\n\t"
  290. /* Update memory */
  291. "P4 = %6;\n\t"
  292. "R0 = %5;\n\t"
  293. "LC0 = R0;\n\t"
  294. "P1 = B1;\n\t"
  295. "LOOP mem_update%= LC0;\n\t"
  296. "LOOP_BEGIN mem_update%=;\n\t"
  297. "A0 = 0;\n\t"
  298. "I3 = P3;\n\t"
  299. "I1 = P1;\n\t"
  300. "P1 += 2;\n\t"
  301. "R0 = LC0;\n\t"
  302. "LC1=R0;\n\t"
  303. "R5.L = W[I3--] || R4.L = W[I1++];\n\t"
  304. "LOOP mem_accum%= LC1;\n\t"
  305. "LOOP_BEGIN mem_accum%=;\n\t"
  306. "A0 -= R4.L*R5.L (IS) || R4.L = W[I1++] || R5.L = W[I3--];\n\t"
  307. "LOOP_END mem_accum%=;\n\t"
  308. "R0 = A0;\n\t"
  309. "[P4++] = R0;\n\t"
  310. "LOOP_END mem_update%=;\n\t"
  311. "L1 = 0;\n\t"
  312. : : "m" (yy), "m" (_x), "m" (_y), "m" (den), "m" (N), "m" (ord), "m" (mem)
  313. : "A0", "A1", "R0", "R1", "R2", "R3", "R4", "R5", "P0", "P1", "P2", "P3", "P4", "B1", "I1", "I3", "L1", "L3", "memory",
  314. "ASTAT" BFIN_HWLOOP0_REGS BFIN_HWLOOP1_REGS
  315. );
  316. }
  317. #define OVERRIDE_FIR_MEM16
  318. void fir_mem16(const spx_word16_t *x, const spx_coef_t *num, spx_word16_t *y, int N, int ord, spx_mem_t *mem, char *stack)
  319. {
  320. int i;
  321. spx_coef_t den2[12];
  322. spx_coef_t *den;
  323. den = (spx_coef_t*)((((int)den2)+4)&0xfffffffc);
  324. for (i=0;i<10;i++)
  325. den[i] = 0;
  326. filter_mem16(x, num, den, y, N, ord, mem, stack);
  327. }
  328. #define OVERRIDE_COMPUTE_IMPULSE_RESPONSE
  329. void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
  330. {
  331. int i;
  332. VARDECL(spx_word16_t *ytmp);
  333. ALLOC(ytmp, N, spx_word16_t);
  334. spx_word16_t *ytmp2 = ytmp;
  335. y[0] = LPC_SCALING;
  336. for (i=0;i<ord;i++)
  337. y[i+1] = awk1[i];
  338. i++;
  339. for (;i<N;i++)
  340. y[i] = 0;
  341. N-=1;
  342. __asm__ __volatile__
  343. (
  344. "I0 = %0;\n\t"
  345. "I1 = %1;\n\t"
  346. "L0 = 0;\n\t"
  347. "L1 = 0;\n\t"
  348. "L2 = 0;\n\t"
  349. "L3 = 0;\n\t"
  350. "R0 = 1;\n\t"
  351. "R0 <<= 13;\n\t"
  352. "W[I0] = R0.L;\n\t"
  353. "R0 <<= 1;\n\t"
  354. "W[I1] = R0.L;\n\t"
  355. "R0 = %5;\n\t"
  356. "LC0 = R0;\n\t"
  357. "R2 = 0;\n\t"
  358. "LOOP samples%= LC0;\n\t"
  359. "LOOP_BEGIN samples%=;\n\t"
  360. "R2 += 1;\n\t"
  361. "R2 = MIN(R2, %4);\n\t"
  362. "I0 = %0;\n\t"
  363. "I1 = %1;\n\t"
  364. "I2 = %2;\n\t"
  365. "I3 = %3;\n\t"
  366. "%0 += 2;\n\t"
  367. "%1 += 2;\n\t"
  368. "A1 = A0 = 0;\n\t"
  369. "R0.L = W[I0--] || R1.L = W[I2++];\n\t"
  370. "LC1 = R2;\n\t"
  371. "LOOP filter%= LC1;\n\t"
  372. "LOOP_BEGIN filter%=;\n\t"
  373. "A0 -= R0.L*R1.L (IS) || R0.L = W[I1--] || R1.L = W[I3++];\n\t"
  374. "A1 -= R0.L*R1.L (IS) || R0.L = W[I0--] || R1.L = W[I2++];\n\t"
  375. "LOOP_END filter%=;\n\t"
  376. "R0 = A0, R1 = A1;\n\t"
  377. "R3 = W[%1] (X);\n\t"
  378. "R3 <<= 13;\n\t"
  379. "R0 = R0 + R3;\n\t"
  380. "R3 = R0 >>> 13;\n\t"
  381. "W[%0] = R3.L;\n\t"
  382. "R0 <<= 1;\n\t"
  383. "R1 = R1 + R0;\n\t"
  384. "R1 >>>= 13;\n\t"
  385. "W[%1] = R1.L;\n\t"
  386. "LOOP_END samples%=;\n\t"
  387. : "=a" (ytmp2), "=a" (y)
  388. : "a" (awk2), "a" (ak), "d" (ord), "m" (N), "0" (ytmp2), "1" (y)
  389. : "A0", "A1", "R0", "R1", "R2", "R3", "I0", "I1", "I2", "I3", "L0", "L1", "L2", "L3",
  390. "ASTAT" BFIN_HWLOOP0_REGS BFIN_HWLOOP1_REGS
  391. );
  392. }
  393. #if 0 /* Equivalent C function for filter_mem2 and compute_impulse_response */
  394. #define min(a,b) ((a)<(b) ? (a):(b))
  395. void compute_impulse_response(const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_word16_t *y, int N, int ord, char *stack)
  396. {
  397. int i,j;
  398. VARDECL(spx_word16_t *ytmp);
  399. ALLOC(ytmp, N, spx_word16_t);
  400. y[0] = LPC_SCALING;
  401. for (i=0;i<ord;i++)
  402. y[i+1] = awk1[i];
  403. i++;
  404. for (;i<N;i++)
  405. y[i] = 0;
  406. for (i=0;i<N;i++)
  407. {
  408. spx_word32_t yi = SHL32(EXTEND32(y[i]),LPC_SHIFT);
  409. spx_word32_t yi2 = 0;
  410. for (j=0;j<min(i,ord);j++)
  411. {
  412. yi = MAC16_16(yi, awk2[j], -ytmp[i-j-1]);
  413. yi2 = MAC16_16(yi2, ak[j], -y[i-j-1]);
  414. }
  415. ytmp[i] = EXTRACT16(SHR32(yi,LPC_SHIFT));
  416. yi2 = ADD32(yi2,SHL32(yi,1));
  417. y[i] = EXTRACT16(SHR32(yi2,LPC_SHIFT));
  418. }
  419. }
  420. void filter_mem2(const spx_sig_t *_x, const spx_coef_t *num, const spx_coef_t *den, spx_sig_t *_y, int N, int ord, spx_mem_t *mem)
  421. {
  422. int i,j;
  423. spx_word16_t xi,yi,nyi;
  424. spx_word16_t x[N],y[N];
  425. spx_word16_t *xx, *yy;
  426. xx = x;
  427. yy = y;
  428. for (i=0;i<N;i++)
  429. {
  430. x[i] = EXTRACT16(SHR32(_x[i],SIG_SHIFT));
  431. }
  432. for (i=0;i<ord;i++)
  433. {
  434. spx_word32_t yi = mem[i];
  435. for (j=0;j<i;j++)
  436. {
  437. yi = MAC16_16(yi, num[j], x[i-j-1]);
  438. yi = MAC16_16(yi, den[j], -y[i-j-1]);
  439. }
  440. _y[i] = ADD32(_x[i],SHL32(yi,1));
  441. y[i] = EXTRACT16(SHR32(_y[i],SIG_SHIFT));
  442. }
  443. for (i=ord;i<N;i++)
  444. {
  445. spx_word32_t yi = 0;
  446. for (j=0;j<ord;j++)
  447. {
  448. yi = MAC16_16(yi, num[j], x[i-j-1]);
  449. yi = MAC16_16(yi, den[j], -y[i-j-1]);
  450. }
  451. _y[i] = ADD32(_x[i],SHL32(yi,1));
  452. y[i] = EXTRACT16(SHR32(_y[i],SIG_SHIFT));
  453. }
  454. for (i=0;i<ord;i++)
  455. {
  456. spx_mem_t m = 0;
  457. for (j=0;j<ord-i;j++)
  458. {
  459. m = MAC16_16(m, x[N-1-j], num[j+i]);
  460. m = MAC16_16(m, -y[N-1-j], den[j+i]);
  461. }
  462. mem[i] = m;
  463. }
  464. }
  465. #endif