arm_rfft_q15.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_rfft_q15.c
  4. * Description: RFFT & RIFFT Q15 process function
  5. *
  6. * $Date: 18. March 2019
  7. * $Revision: V1.6.0
  8. *
  9. * Target Processor: Cortex-M cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "arm_math.h"
  29. /* ----------------------------------------------------------------------
  30. * Internal functions prototypes
  31. * -------------------------------------------------------------------- */
  32. void arm_split_rfft_q15(
  33. q15_t * pSrc,
  34. uint32_t fftLen,
  35. const q15_t * pATable,
  36. const q15_t * pBTable,
  37. q15_t * pDst,
  38. uint32_t modifier);
  39. void arm_split_rifft_q15(
  40. q15_t * pSrc,
  41. uint32_t fftLen,
  42. const q15_t * pATable,
  43. const q15_t * pBTable,
  44. q15_t * pDst,
  45. uint32_t modifier);
  46. /**
  47. @addtogroup RealFFT
  48. @{
  49. */
  50. /**
  51. @brief Processing function for the Q15 RFFT/RIFFT.
  52. @param[in] S points to an instance of the Q15 RFFT/RIFFT structure
  53. @param[in] pSrc points to input buffer (Source buffer is modified by this function.)
  54. @param[out] pDst points to output buffer
  55. @return none
  56. @par Input an output formats
  57. Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process.
  58. Hence the output format is different for different RFFT sizes.
  59. The input and output formats for different RFFT sizes and number of bits to upscale are mentioned in the tables below for RFFT and RIFFT:
  60. @par
  61. \image html RFFTQ15.gif "Input and Output Formats for Q15 RFFT"
  62. @par
  63. \image html RIFFTQ15.gif "Input and Output Formats for Q15 RIFFT"
  64. @par
  65. If the input buffer is of length N, the output buffer must have length 2*N.
  66. The input buffer is modified by this function.
  67. */
  68. void arm_rfft_q15(
  69. const arm_rfft_instance_q15 * S,
  70. q15_t * pSrc,
  71. q15_t * pDst)
  72. {
  73. #if defined(ARM_MATH_MVEI)
  74. const arm_cfft_instance_q15 *S_CFFT = &(S->cfftInst);
  75. #else
  76. const arm_cfft_instance_q15 *S_CFFT = S->pCfft;
  77. #endif
  78. uint32_t L2 = S->fftLenReal >> 1U;
  79. uint32_t i;
  80. /* Calculation of RIFFT of input */
  81. if (S->ifftFlagR == 1U)
  82. {
  83. /* Real IFFT core process */
  84. arm_split_rifft_q15 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier);
  85. /* Complex IFFT process */
  86. arm_cfft_q15 (S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR);
  87. for(i = 0; i < S->fftLenReal; i++)
  88. {
  89. pDst[i] = pDst[i] << 1U;
  90. }
  91. }
  92. else
  93. {
  94. /* Calculation of RFFT of input */
  95. /* Complex FFT process */
  96. arm_cfft_q15 (S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR);
  97. /* Real FFT core process */
  98. arm_split_rfft_q15 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier);
  99. }
  100. }
  101. /**
  102. @} end of RealFFT group
  103. */
  104. /**
  105. @brief Core Real FFT process
  106. @param[in] pSrc points to input buffer
  107. @param[in] fftLen length of FFT
  108. @param[in] pATable points to twiddle Coef A buffer
  109. @param[in] pBTable points to twiddle Coef B buffer
  110. @param[out] pDst points to output buffer
  111. @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table
  112. @return none
  113. @par
  114. The function implements a Real FFT
  115. */
  116. #if defined(ARM_MATH_MVEI)
  117. void arm_split_rfft_q15(
  118. q15_t * pSrc,
  119. uint32_t fftLen,
  120. const q15_t * pATable,
  121. const q15_t * pBTable,
  122. q15_t * pDst,
  123. uint32_t modifier)
  124. {
  125. q15_t const *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  126. q15_t *pDst1 = &pDst[2], *pDst2 = &pDst[(4U * fftLen) - 1U - 14]; /* temp pointers for output buffer */
  127. q15_t const *pSrc1 = &pSrc[2], *pSrc2 = &pSrc[(2U * fftLen) - 1U - 14]; /* temp pointers for input buffer */
  128. q15_t const *pVecSrc1;
  129. q15_t *pVecDst1;
  130. q15x8x2_t vecIn, vecSum;
  131. uint32_t blkCnt;
  132. uint16x8_t vecStridesFwd, vecStridesBkwd;
  133. q15x8_t vecInBkwd, vecCoefFwd0, vecCoefFwd1;
  134. /*
  135. * Init coefficient pointers
  136. */
  137. pCoefA = &pATable[modifier * 2U];
  138. pCoefB = &pBTable[modifier * 2U];
  139. /*
  140. * scatter / gather offsets
  141. * for ascending & descending addressing
  142. */
  143. vecStridesFwd = vidupq_u16((uint32_t)0, 2); // 0, 2, 4, 6, 8, 10, 12, 14
  144. vecStridesBkwd = vddupq_u16(14, 2); // 14, 12, 10, 8, 6, 4, 2, 0
  145. vecStridesFwd = vecStridesFwd * (uint16_t) modifier;
  146. pVecSrc1 = (q15_t const *) pSrc1;
  147. pVecDst1 = pDst1;
  148. blkCnt = fftLen >> 3;
  149. while (blkCnt > 0U)
  150. {
  151. vecCoefFwd0 = vldrhq_gather_shifted_offset(pCoefA, vecStridesFwd);
  152. vecCoefFwd1 = vldrhq_gather_shifted_offset(&pCoefA[1], vecStridesFwd);
  153. vecIn = vld2q(pVecSrc1);
  154. pVecSrc1 += 16;
  155. /*
  156. * outR = *pSrc1 * CoefA1;
  157. */
  158. vecSum.val[0] = vrmulhq(vecIn.val[0], vecCoefFwd0);
  159. /*
  160. * outI = *pSrc1++ * CoefA2;
  161. */
  162. vecSum.val[1] = vrmulhq(vecIn.val[0], vecCoefFwd1);
  163. vecInBkwd = vldrhq_gather_shifted_offset(pSrc2, vecStridesBkwd);
  164. /*
  165. * outR -= (*pSrc1 + *pSrc2) * CoefA2;
  166. */
  167. vecInBkwd = vqaddq(vecIn.val[1], vecInBkwd);
  168. vecSum.val[0] = vqsubq(vecSum.val[0], vrmulhq(vecInBkwd, vecCoefFwd1));
  169. vecInBkwd = vldrhq_gather_shifted_offset(pSrc2, vecStridesBkwd);
  170. /*
  171. * outI += *pSrc1++ * CoefA1;
  172. */
  173. vecSum.val[1] = vqaddq(vecSum.val[1], vrmulhq(vecIn.val[1], vecCoefFwd0));
  174. vecCoefFwd0 = vldrhq_gather_shifted_offset(pCoefB, vecStridesFwd);
  175. /*
  176. * outI -= *pSrc2-- * CoefB1;
  177. */
  178. vecSum.val[1] = vqsubq(vecSum.val[1], vrmulhq(vecInBkwd, vecCoefFwd0));
  179. vecInBkwd = vldrhq_gather_shifted_offset(&pSrc2[-1], vecStridesBkwd);
  180. /*
  181. * outI -= *pSrc2 * CoefA2;
  182. */
  183. vecSum.val[1] = vqsubq(vecSum.val[1], vrmulhq(vecInBkwd, vecCoefFwd1));
  184. /*
  185. * outR += *pSrc2-- * CoefB1;
  186. */
  187. vecSum.val[0] = vqaddq(vecSum.val[0], vrmulhq(vecInBkwd, vecCoefFwd0));
  188. vst2q(pVecDst1, vecSum);
  189. pVecDst1 += 16;
  190. /*
  191. * write complex conjugate output
  192. */
  193. vecSum.val[1] = -vecSum.val[1];
  194. vstrhq_scatter_shifted_offset(pDst2, vecStridesBkwd, vecSum.val[1]);
  195. vstrhq_scatter_shifted_offset(&pDst2[-1], vecStridesBkwd, vecSum.val[0]);
  196. /*
  197. * update fwd and backwd offsets
  198. */
  199. vecStridesFwd = vecStridesFwd + (uint16_t)(modifier * 16U);
  200. /* cannot use negative 16-bit offsets (would lead to positive 32-65K jump*/
  201. //vecStridesBkwd = vecStridesBkwd - (uint16_t)16;
  202. pSrc2 = pSrc2 - 16;
  203. pDst2 = pDst2 - 16;
  204. blkCnt--;
  205. }
  206. pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1;
  207. pDst[(2U * fftLen) + 1U] = 0;
  208. pDst[0] = (pSrc[0] + pSrc[1]) >> 1;
  209. pDst[1] = 0;
  210. }
  211. #else
  212. void arm_split_rfft_q15(
  213. q15_t * pSrc,
  214. uint32_t fftLen,
  215. const q15_t * pATable,
  216. const q15_t * pBTable,
  217. q15_t * pDst,
  218. uint32_t modifier)
  219. {
  220. uint32_t i; /* Loop Counter */
  221. q31_t outR, outI; /* Temporary variables for output */
  222. const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  223. q15_t *pSrc1, *pSrc2;
  224. #if defined (ARM_MATH_DSP)
  225. q15_t *pD1, *pD2;
  226. #endif
  227. /* Init coefficient pointers */
  228. pCoefA = &pATable[modifier * 2];
  229. pCoefB = &pBTable[modifier * 2];
  230. pSrc1 = &pSrc[2];
  231. pSrc2 = &pSrc[(2U * fftLen) - 2U];
  232. #if defined (ARM_MATH_DSP)
  233. i = 1U;
  234. pD1 = pDst + 2;
  235. pD2 = pDst + (4U * fftLen) - 2;
  236. for (i = fftLen - 1; i > 0; i--)
  237. {
  238. /*
  239. outR = ( pSrc[2 * i] * pATable[2 * i]
  240. - pSrc[2 * i + 1] * pATable[2 * i + 1]
  241. + pSrc[2 * n - 2 * i] * pBTable[2 * i]
  242. + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
  243. outI = ( pIn[2 * i + 1] * pATable[2 * i]
  244. + pIn[2 * i] * pATable[2 * i + 1]
  245. + pIn[2 * n - 2 * i] * pBTable[2 * i + 1]
  246. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i])
  247. */
  248. #ifndef ARM_MATH_BIG_ENDIAN
  249. /* pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1] */
  250. outR = __SMUSD(read_q15x2 (pSrc1), read_q15x2((q15_t *) pCoefA));
  251. #else
  252. /* -(pSrc[2 * i + 1] * pATable[2 * i + 1] - pSrc[2 * i] * pATable[2 * i]) */
  253. outR = -(__SMUSD(read_q15x2 (pSrc1), read_q15x2((q15_t *) pCoefA)));
  254. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  255. /* pSrc[2 * n - 2 * i] * pBTable[2 * i] + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]) */
  256. outR = __SMLAD(read_q15x2 (pSrc2), read_q15x2((q15_t *) pCoefB), outR) >> 16U;
  257. /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */
  258. #ifndef ARM_MATH_BIG_ENDIAN
  259. outI = __SMUSDX(read_q15x2_da (&pSrc2), read_q15x2((q15_t *) pCoefB));
  260. #else
  261. outI = __SMUSDX(read_q15x2 ((q15_t *) pCoefB), read_q15x2_da (&pSrc2));
  262. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  263. /* (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] */
  264. outI = __SMLADX(read_q15x2_ia (&pSrc1), read_q15x2 ((q15_t *) pCoefA), outI);
  265. /* write output */
  266. *pD1++ = (q15_t) outR;
  267. *pD1++ = outI >> 16U;
  268. /* write complex conjugate output */
  269. pD2[0] = (q15_t) outR;
  270. pD2[1] = -(outI >> 16U);
  271. pD2 -= 2;
  272. /* update coefficient pointer */
  273. pCoefB = pCoefB + (2U * modifier);
  274. pCoefA = pCoefA + (2U * modifier);
  275. }
  276. pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1U;
  277. pDst[2U * fftLen + 1U] = 0;
  278. pDst[0] = (pSrc[0] + pSrc[1]) >> 1U;
  279. pDst[1] = 0;
  280. #else
  281. i = 1U;
  282. while (i < fftLen)
  283. {
  284. /*
  285. outR = ( pSrc[2 * i] * pATable[2 * i]
  286. - pSrc[2 * i + 1] * pATable[2 * i + 1]
  287. + pSrc[2 * n - 2 * i] * pBTable[2 * i]
  288. + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
  289. */
  290. outR = *pSrc1 * *pCoefA;
  291. outR = outR - (*(pSrc1 + 1) * *(pCoefA + 1));
  292. outR = outR + (*pSrc2 * *pCoefB);
  293. outR = (outR + (*(pSrc2 + 1) * *(pCoefB + 1))) >> 16;
  294. /*
  295. outI = ( pIn[2 * i + 1] * pATable[2 * i]
  296. + pIn[2 * i] * pATable[2 * i + 1]
  297. + pIn[2 * n - 2 * i] * pBTable[2 * i + 1]
  298. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]);
  299. */
  300. outI = *pSrc2 * *(pCoefB + 1);
  301. outI = outI - (*(pSrc2 + 1) * *pCoefB);
  302. outI = outI + (*(pSrc1 + 1) * *pCoefA);
  303. outI = outI + (*pSrc1 * *(pCoefA + 1));
  304. /* update input pointers */
  305. pSrc1 += 2U;
  306. pSrc2 -= 2U;
  307. /* write output */
  308. pDst[2U * i] = (q15_t) outR;
  309. pDst[2U * i + 1U] = outI >> 16U;
  310. /* write complex conjugate output */
  311. pDst[(4U * fftLen) - (2U * i)] = (q15_t) outR;
  312. pDst[((4U * fftLen) - (2U * i)) + 1U] = -(outI >> 16U);
  313. /* update coefficient pointer */
  314. pCoefB = pCoefB + (2U * modifier);
  315. pCoefA = pCoefA + (2U * modifier);
  316. i++;
  317. }
  318. pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1;
  319. pDst[2U * fftLen + 1U] = 0;
  320. pDst[0] = (pSrc[0] + pSrc[1]) >> 1;
  321. pDst[1] = 0;
  322. #endif /* #if defined (ARM_MATH_DSP) */
  323. }
  324. #endif /* defined(ARM_MATH_MVEI) */
  325. /**
  326. @brief Core Real IFFT process
  327. @param[in] pSrc points to input buffer
  328. @param[in] fftLen length of FFT
  329. @param[in] pATable points to twiddle Coef A buffer
  330. @param[in] pBTable points to twiddle Coef B buffer
  331. @param[out] pDst points to output buffer
  332. @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table
  333. @return none
  334. @par
  335. The function implements a Real IFFT
  336. */
  337. #if defined(ARM_MATH_MVEI)
  338. void arm_split_rifft_q15(
  339. q15_t * pSrc,
  340. uint32_t fftLen,
  341. const q15_t * pATable,
  342. const q15_t * pBTable,
  343. q15_t * pDst,
  344. uint32_t modifier)
  345. {
  346. q15_t const *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  347. q15_t const *pSrc1 = &pSrc[0], *pSrc2 = &pSrc[(2U * fftLen) + 1U - 14U];
  348. q15_t *pDst1 = &pDst[0];
  349. q15_t const *pVecSrc1;
  350. q15_t *pVecDst1;
  351. q15x8x2_t vecIn, vecSum;
  352. uint32_t blkCnt;
  353. uint16x8_t vecStridesFwd, vecStridesBkwd;
  354. q15x8_t vecInBkwd, vecCoefFwd0, vecCoefFwd1;
  355. /*
  356. * Init coefficient pointers
  357. */
  358. pCoefA = &pATable[0];
  359. pCoefB = &pBTable[0];
  360. /*
  361. * scatter / gather offsets
  362. * for ascending & descending addressing
  363. */
  364. vecStridesFwd = vidupq_u16((uint32_t)0, 2); // 0, 2, 4, 6, 8, 10, 12, 14
  365. vecStridesBkwd = vddupq_u16(14, 2); // 14, 12, 10, 8, 6, 4, 2, 0
  366. vecStridesFwd = vecStridesFwd * (uint16_t) modifier;
  367. pVecSrc1 = (q15_t const *) pSrc1;
  368. pVecDst1 = pDst1;
  369. blkCnt = fftLen >> 3;
  370. while (blkCnt > 0U)
  371. {
  372. vecCoefFwd0 = vldrhq_gather_shifted_offset(pCoefA, vecStridesFwd);
  373. vecCoefFwd1 = vldrhq_gather_shifted_offset(&pCoefA[1], vecStridesFwd);
  374. vecIn = vld2q(pVecSrc1);
  375. pVecSrc1 += 16;
  376. /*
  377. * outR = *pSrc1 * CoefA1;
  378. */
  379. vecSum.val[0] = vmulhq(vecIn.val[0], vecCoefFwd0);
  380. /*
  381. * outI = -(*pSrc1++) * CoefA2;
  382. */
  383. vecIn.val[0] = vnegq(vecIn.val[0]);
  384. vecSum.val[1] = vmulhq(vecIn.val[0], vecCoefFwd1);
  385. vecInBkwd = vldrhq_gather_shifted_offset(pSrc2, vecStridesBkwd);
  386. /*
  387. * outR += (*pSrc1 + *pSrc2) * CoefA2;
  388. */
  389. vecInBkwd = vqaddq(vecIn.val[1], vecInBkwd);
  390. vecSum.val[0] = vqaddq(vecSum.val[0], vmulhq(vecInBkwd, vecCoefFwd1));
  391. vecInBkwd = vldrhq_gather_shifted_offset(pSrc2, vecStridesBkwd);
  392. /*
  393. * outI += *pSrc1++ * CoefA1;
  394. */
  395. vecSum.val[1] = vqaddq(vecSum.val[1], vmulhq(vecIn.val[1], vecCoefFwd0));
  396. vecCoefFwd0 = vldrhq_gather_shifted_offset(pCoefB, vecStridesFwd);
  397. /*
  398. * outI -= *pSrc2-- * CoefB1;
  399. */
  400. vecSum.val[1] = vqsubq(vecSum.val[1], vmulhq(vecInBkwd, vecCoefFwd0));
  401. vecInBkwd = vldrhq_gather_shifted_offset(&pSrc2[-1], vecStridesBkwd);
  402. /*
  403. * outI += *pSrc2 * CoefA2;
  404. */
  405. vecSum.val[1] = vqaddq(vecSum.val[1], vmulhq(vecInBkwd, vecCoefFwd1));
  406. /*
  407. * outR += *pSrc2-- * CoefB1;
  408. */
  409. vecSum.val[0] = vqaddq(vecSum.val[0], vmulhq(vecInBkwd, vecCoefFwd0));
  410. vst2q(pVecDst1, vecSum);
  411. pVecDst1 += 16;
  412. /*
  413. * update fwd and backwd offsets
  414. */
  415. vecStridesFwd = vecStridesFwd + (uint16_t)(modifier * 16U);
  416. /* cannot use negative 16-bit offsets (would lead to positive 32-65K jump*/
  417. //vecStridesBkwd = vecStridesBkwd - (uint16_t)16;
  418. pSrc2 = pSrc2 - 16;
  419. blkCnt--;
  420. }
  421. }
  422. #else
  423. void arm_split_rifft_q15(
  424. q15_t * pSrc,
  425. uint32_t fftLen,
  426. const q15_t * pATable,
  427. const q15_t * pBTable,
  428. q15_t * pDst,
  429. uint32_t modifier)
  430. {
  431. uint32_t i; /* Loop Counter */
  432. q31_t outR, outI; /* Temporary variables for output */
  433. const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  434. q15_t *pSrc1, *pSrc2;
  435. q15_t *pDst1 = &pDst[0];
  436. pCoefA = &pATable[0];
  437. pCoefB = &pBTable[0];
  438. pSrc1 = &pSrc[0];
  439. pSrc2 = &pSrc[2 * fftLen];
  440. i = fftLen;
  441. while (i > 0U)
  442. {
  443. /*
  444. outR = ( pIn[2 * i] * pATable[2 * i]
  445. + pIn[2 * i + 1] * pATable[2 * i + 1]
  446. + pIn[2 * n - 2 * i] * pBTable[2 * i]
  447. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
  448. outI = ( pIn[2 * i + 1] * pATable[2 * i]
  449. - pIn[2 * i] * pATable[2 * i + 1]
  450. - pIn[2 * n - 2 * i] * pBTable[2 * i + 1]
  451. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]);
  452. */
  453. #if defined (ARM_MATH_DSP)
  454. #ifndef ARM_MATH_BIG_ENDIAN
  455. /* pIn[2 * n - 2 * i] * pBTable[2 * i] - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]) */
  456. outR = __SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *) pCoefB));
  457. #else
  458. /* -(-pIn[2 * n - 2 * i] * pBTable[2 * i] + pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1])) */
  459. outR = -(__SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *) pCoefB)));
  460. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  461. /* pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] + pIn[2 * n - 2 * i] * pBTable[2 * i] */
  462. outR = __SMLAD(read_q15x2(pSrc1), read_q15x2 ((q15_t *) pCoefA), outR) >> 16U;
  463. /* -pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */
  464. outI = __SMUADX(read_q15x2_da (&pSrc2), read_q15x2((q15_t *) pCoefB));
  465. /* pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] */
  466. #ifndef ARM_MATH_BIG_ENDIAN
  467. outI = __SMLSDX(read_q15x2 ((q15_t *) pCoefA), read_q15x2_ia (&pSrc1), -outI);
  468. #else
  469. outI = __SMLSDX(read_q15x2_ia (&pSrc1), read_q15x2 ((q15_t *) pCoefA), -outI);
  470. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  471. /* write output */
  472. #ifndef ARM_MATH_BIG_ENDIAN
  473. write_q15x2_ia (&pDst1, __PKHBT(outR, (outI >> 16U), 16));
  474. #else
  475. write_q15x2_ia (&pDst1, __PKHBT((outI >> 16U), outR, 16));
  476. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  477. #else /* #if defined (ARM_MATH_DSP) */
  478. outR = *pSrc2 * *pCoefB;
  479. outR = outR - (*(pSrc2 + 1) * *(pCoefB + 1));
  480. outR = outR + (*pSrc1 * *pCoefA);
  481. outR = (outR + (*(pSrc1 + 1) * *(pCoefA + 1))) >> 16;
  482. outI = *(pSrc1 + 1) * *pCoefA;
  483. outI = outI - (*pSrc1 * *(pCoefA + 1));
  484. outI = outI - (*pSrc2 * *(pCoefB + 1));
  485. outI = outI - (*(pSrc2 + 1) * *(pCoefB));
  486. /* update input pointers */
  487. pSrc1 += 2U;
  488. pSrc2 -= 2U;
  489. /* write output */
  490. *pDst1++ = (q15_t) outR;
  491. *pDst1++ = (q15_t) (outI >> 16);
  492. #endif /* #if defined (ARM_MATH_DSP) */
  493. /* update coefficient pointer */
  494. pCoefB = pCoefB + (2 * modifier);
  495. pCoefA = pCoefA + (2 * modifier);
  496. i--;
  497. }
  498. }
  499. #endif /* defined(ARM_MATH_MVEI) */