arm_rfft_q15.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_rfft_q15.c
  4. * Description: RFFT & RIFFT Q15 process function
  5. *
  6. * $Date: 23 April 2021
  7. * $Revision: V1.9.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2021 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 "dsp/transform_functions.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 RealFFTQ15
  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. @par Input an output formats
  56. Internally input is downscaled by 2 for every stage to avoid saturations inside CFFT/CIFFT process.
  57. Hence the output format is different for different RFFT sizes.
  58. 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:
  59. @par Input and Output formats for RFFT Q15
  60. | RFFT Size | Input Format | Output Format | Number of bits to upscale |
  61. | ---------: | ------------: | -------------: | ------------------------: |
  62. | 32 | 1.15 | 6.10 | 5 |
  63. | 64 | 1.15 | 7.9 | 6 |
  64. | 128 | 1.15 | 8.8 | 7 |
  65. | 256 | 1.15 | 9.7 | 8 |
  66. | 512 | 1.15 | 10.6 | 9 |
  67. | 1024 | 1.15 | 11.5 | 10 |
  68. | 2048 | 1.15 | 12.4 | 11 |
  69. | 4096 | 1.15 | 13.3 | 12 |
  70. | 8192 | 1.15 | 14.2 | 13 |
  71. @par Input and Output formats for RIFFT Q15
  72. | RIFFT Size | Input Format | Output Format | Number of bits to upscale |
  73. | ----------: | ------------: | -------------: | ------------------------: |
  74. | 32 | 1.15 | 6.10 | 0 |
  75. | 64 | 1.15 | 7.9 | 0 |
  76. | 128 | 1.15 | 8.8 | 0 |
  77. | 256 | 1.15 | 9.7 | 0 |
  78. | 512 | 1.15 | 10.6 | 0 |
  79. | 1024 | 1.15 | 11.5 | 0 |
  80. | 2048 | 1.15 | 12.4 | 0 |
  81. | 4096 | 1.15 | 13.3 | 0 |
  82. | 8192 | 1.15 | 14.2 | 0 |
  83. @par
  84. If the input buffer is of length N (fftLenReal), the output buffer must have length 2N
  85. since it is containing the conjugate part (except for MVE version where N+2 is enough).
  86. The input buffer is modified by this function.
  87. @par
  88. For the RIFFT, the source buffer must have length N+2 since the Nyquist frequency value
  89. is needed but conjugate part is ignored.
  90. It is not using the packing trick of the float version.
  91. */
  92. void arm_rfft_q15(
  93. const arm_rfft_instance_q15 * S,
  94. q15_t * pSrc,
  95. q15_t * pDst)
  96. {
  97. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  98. const arm_cfft_instance_q15 *S_CFFT = &(S->cfftInst);
  99. #else
  100. const arm_cfft_instance_q15 *S_CFFT = S->pCfft;
  101. #endif
  102. uint32_t L2 = S->fftLenReal >> 1U;
  103. /* Calculation of RIFFT of input */
  104. if (S->ifftFlagR == 1U)
  105. {
  106. /* Real IFFT core process */
  107. arm_split_rifft_q15 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier);
  108. /* Complex IFFT process */
  109. arm_cfft_q15 (S_CFFT, pDst, S->ifftFlagR, S->bitReverseFlagR);
  110. arm_shift_q15(pDst, 1, pDst, S->fftLenReal);
  111. }
  112. else
  113. {
  114. /* Calculation of RFFT of input */
  115. /* Complex FFT process */
  116. arm_cfft_q15 (S_CFFT, pSrc, S->ifftFlagR, S->bitReverseFlagR);
  117. /* Real FFT core process */
  118. arm_split_rfft_q15 (pSrc, L2, S->pTwiddleAReal, S->pTwiddleBReal, pDst, S->twidCoefRModifier);
  119. }
  120. }
  121. /**
  122. @} end of RealFFTQ15 group
  123. */
  124. /**
  125. @brief Core Real FFT process
  126. @param[in] pSrc points to input buffer
  127. @param[in] fftLen length of FFT
  128. @param[in] pATable points to twiddle Coef A buffer
  129. @param[in] pBTable points to twiddle Coef B buffer
  130. @param[out] pDst points to output buffer
  131. @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table
  132. @par
  133. The function implements a Real FFT
  134. */
  135. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  136. #include "arm_helium_utils.h"
  137. #include "arm_vec_fft.h"
  138. #if defined(__CMSIS_GCC_H)
  139. #define MVE_CMPLX_MULT_FX_AxB_S16(A,B) vqdmladhxq_s16(vqdmlsdhq_s16((__typeof(A))vuninitializedq_s16(), A, B), A, B)
  140. #define MVE_CMPLX_MULT_FX_AxConjB_S16(A,B) vqdmladhq_s16(vqdmlsdhxq_s16((__typeof(A))vuninitializedq_s16(), A, B), A, B)
  141. #endif
  142. void arm_split_rfft_q15(
  143. q15_t * pSrc,
  144. uint32_t fftLen,
  145. const q15_t * pATable,
  146. const q15_t * pBTable,
  147. q15_t * pDst,
  148. uint32_t modifier)
  149. {
  150. uint32_t i; /* Loop Counter */
  151. const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  152. q15_t *pOut1 = &pDst[2];
  153. q15_t *pIn1 = &pSrc[2];
  154. uint16x8_t offsetIn = { 6, 7, 4, 5, 2, 3, 0, 1 };
  155. uint16x8_t offsetCoef;
  156. const uint16_t offsetCoefArr[16] = {
  157. 0, 0, 2, 2, 4, 4, 6, 6,
  158. 0, 1, 0, 1, 0, 1, 0, 1
  159. };
  160. offsetCoef = vmulq_n_u16(vld1q_u16(offsetCoefArr), modifier) + vld1q_u16(offsetCoefArr + 8);
  161. offsetIn = vaddq_n_u16(offsetIn, (2 * fftLen - 8));
  162. /* Init coefficient pointers */
  163. pCoefA = &pATable[modifier * 2];
  164. pCoefB = &pBTable[modifier * 2];
  165. const q15_t *pCoefAb, *pCoefBb;
  166. pCoefAb = pCoefA;
  167. pCoefBb = pCoefB;
  168. pIn1 = &pSrc[2];
  169. i = fftLen - 1U;
  170. i = i / 4 + 1;
  171. while (i > 0U) {
  172. q15x8_t in1 = vld1q_s16(pIn1);
  173. q15x8_t in2 = vldrhq_gather_shifted_offset_s16(pSrc, offsetIn);
  174. q15x8_t coefA = vldrhq_gather_shifted_offset_s16(pCoefAb, offsetCoef);
  175. q15x8_t coefB = vldrhq_gather_shifted_offset_s16(pCoefBb, offsetCoef);
  176. #if defined(__CMSIS_GCC_H)
  177. q15x8_t out = vhaddq_s16(MVE_CMPLX_MULT_FX_AxB_S16(in1, coefA),
  178. MVE_CMPLX_MULT_FX_AxConjB_S16(coefB, in2));
  179. #else
  180. q15x8_t out = vhaddq_s16(MVE_CMPLX_MULT_FX_AxB(in1, coefA, q15x8_t),
  181. MVE_CMPLX_MULT_FX_AxConjB(coefB, in2, q15x8_t));
  182. #endif
  183. vst1q_s16(pOut1, out);
  184. pOut1 += 8;
  185. offsetCoef = vaddq_n_u16(offsetCoef, modifier * 8);
  186. offsetIn -= 8;
  187. pIn1 += 8;
  188. i -= 1;
  189. }
  190. pDst[2 * fftLen] = (pSrc[0] - pSrc[1]) >> 1U;
  191. pDst[2 * fftLen + 1] = 0;
  192. pDst[0] = (pSrc[0] + pSrc[1]) >> 1U;
  193. pDst[1] = 0;
  194. }
  195. #else
  196. void arm_split_rfft_q15(
  197. q15_t * pSrc,
  198. uint32_t fftLen,
  199. const q15_t * pATable,
  200. const q15_t * pBTable,
  201. q15_t * pDst,
  202. uint32_t modifier)
  203. {
  204. uint32_t i; /* Loop Counter */
  205. q31_t outR, outI; /* Temporary variables for output */
  206. const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  207. q15_t *pSrc1, *pSrc2;
  208. #if defined (ARM_MATH_DSP)
  209. q15_t *pD1, *pD2;
  210. #endif
  211. /* Init coefficient pointers */
  212. pCoefA = &pATable[modifier * 2];
  213. pCoefB = &pBTable[modifier * 2];
  214. pSrc1 = &pSrc[2];
  215. pSrc2 = &pSrc[(2U * fftLen) - 2U];
  216. #if defined (ARM_MATH_DSP)
  217. i = 1U;
  218. pD1 = pDst + 2;
  219. pD2 = pDst + (4U * fftLen) - 2;
  220. for (i = fftLen - 1; i > 0; i--)
  221. {
  222. /*
  223. outR = ( pSrc[2 * i] * pATable[2 * i]
  224. - pSrc[2 * i + 1] * pATable[2 * i + 1]
  225. + pSrc[2 * n - 2 * i] * pBTable[2 * i]
  226. + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
  227. outI = ( pIn[2 * i + 1] * pATable[2 * i]
  228. + pIn[2 * i] * pATable[2 * i + 1]
  229. + pIn[2 * n - 2 * i] * pBTable[2 * i + 1]
  230. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i])
  231. */
  232. #ifndef ARM_MATH_BIG_ENDIAN
  233. /* pSrc[2 * i] * pATable[2 * i] - pSrc[2 * i + 1] * pATable[2 * i + 1] */
  234. outR = __SMUSD(read_q15x2 (pSrc1), read_q15x2((q15_t *) pCoefA));
  235. #else
  236. /* -(pSrc[2 * i + 1] * pATable[2 * i + 1] - pSrc[2 * i] * pATable[2 * i]) */
  237. outR = -(__SMUSD(read_q15x2 (pSrc1), read_q15x2((q15_t *) pCoefA)));
  238. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  239. /* pSrc[2 * n - 2 * i] * pBTable[2 * i] + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]) */
  240. outR = __SMLAD(read_q15x2 (pSrc2), read_q15x2((q15_t *) pCoefB), outR) >> 16U;
  241. /* pIn[2 * n - 2 * i] * pBTable[2 * i + 1] - pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */
  242. #ifndef ARM_MATH_BIG_ENDIAN
  243. outI = __SMUSDX(read_q15x2_da (&pSrc2), read_q15x2((q15_t *) pCoefB));
  244. #else
  245. outI = __SMUSDX(read_q15x2 ((q15_t *) pCoefB), read_q15x2_da (&pSrc2));
  246. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  247. /* (pIn[2 * i + 1] * pATable[2 * i] + pIn[2 * i] * pATable[2 * i + 1] */
  248. outI = __SMLADX(read_q15x2_ia (&pSrc1), read_q15x2 ((q15_t *) pCoefA), outI);
  249. /* write output */
  250. *pD1++ = (q15_t) outR;
  251. *pD1++ = outI >> 16U;
  252. /* write complex conjugate output */
  253. pD2[0] = (q15_t) outR;
  254. pD2[1] = -(outI >> 16U);
  255. pD2 -= 2;
  256. /* update coefficient pointer */
  257. pCoefB = pCoefB + (2U * modifier);
  258. pCoefA = pCoefA + (2U * modifier);
  259. }
  260. pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1U;
  261. pDst[2U * fftLen + 1U] = 0;
  262. pDst[0] = (pSrc[0] + pSrc[1]) >> 1U;
  263. pDst[1] = 0;
  264. #else
  265. i = 1U;
  266. while (i < fftLen)
  267. {
  268. /*
  269. outR = ( pSrc[2 * i] * pATable[2 * i]
  270. - pSrc[2 * i + 1] * pATable[2 * i + 1]
  271. + pSrc[2 * n - 2 * i] * pBTable[2 * i]
  272. + pSrc[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
  273. */
  274. outR = *pSrc1 * *pCoefA;
  275. outR = outR - (*(pSrc1 + 1) * *(pCoefA + 1));
  276. outR = outR + (*pSrc2 * *pCoefB);
  277. outR = (outR + (*(pSrc2 + 1) * *(pCoefB + 1))) >> 16;
  278. /*
  279. outI = ( pIn[2 * i + 1] * pATable[2 * i]
  280. + pIn[2 * i] * pATable[2 * i + 1]
  281. + pIn[2 * n - 2 * i] * pBTable[2 * i + 1]
  282. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]);
  283. */
  284. outI = *pSrc2 * *(pCoefB + 1);
  285. outI = outI - (*(pSrc2 + 1) * *pCoefB);
  286. outI = outI + (*(pSrc1 + 1) * *pCoefA);
  287. outI = outI + (*pSrc1 * *(pCoefA + 1));
  288. /* update input pointers */
  289. pSrc1 += 2U;
  290. pSrc2 -= 2U;
  291. /* write output */
  292. pDst[2U * i] = (q15_t) outR;
  293. pDst[2U * i + 1U] = outI >> 16U;
  294. /* write complex conjugate output */
  295. pDst[(4U * fftLen) - (2U * i)] = (q15_t) outR;
  296. pDst[((4U * fftLen) - (2U * i)) + 1U] = -(outI >> 16U);
  297. /* update coefficient pointer */
  298. pCoefB = pCoefB + (2U * modifier);
  299. pCoefA = pCoefA + (2U * modifier);
  300. i++;
  301. }
  302. pDst[2U * fftLen] = (pSrc[0] - pSrc[1]) >> 1;
  303. pDst[2U * fftLen + 1U] = 0;
  304. pDst[0] = (pSrc[0] + pSrc[1]) >> 1;
  305. pDst[1] = 0;
  306. #endif /* #if defined (ARM_MATH_DSP) */
  307. }
  308. #endif /* defined(ARM_MATH_MVEI) */
  309. /**
  310. @brief Core Real IFFT process
  311. @param[in] pSrc points to input buffer
  312. @param[in] fftLen length of FFT
  313. @param[in] pATable points to twiddle Coef A buffer
  314. @param[in] pBTable points to twiddle Coef B buffer
  315. @param[out] pDst points to output buffer
  316. @param[in] modifier twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table
  317. @par
  318. The function implements a Real IFFT
  319. */
  320. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  321. #include "arm_helium_utils.h"
  322. #include "arm_vec_fft.h"
  323. void arm_split_rifft_q15(
  324. q15_t * pSrc,
  325. uint32_t fftLen,
  326. const q15_t * pATable,
  327. const q15_t * pBTable,
  328. q15_t * pDst,
  329. uint32_t modifier)
  330. {
  331. uint32_t i; /* Loop Counter */
  332. const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  333. q15_t *pIn1;
  334. uint16x8_t offset = { 6, 7, 4, 5, 2, 3, 0, 1 };
  335. uint16x8_t offsetCoef;
  336. int16x8_t conj = { 1, -1, 1, -1, 1, -1, 1, -1 }; /* conjugate */
  337. const uint16_t offsetCoefArr[16] = {
  338. 0, 0, 2, 2, 4, 4, 6, 6,
  339. 0, 1, 0, 1, 0, 1, 0, 1
  340. };
  341. offsetCoef = vmulq_n_u16(vld1q_u16(offsetCoefArr), modifier) + vld1q_u16(offsetCoefArr + 8);
  342. offset = vaddq_n_u16(offset, (2 * fftLen - 6));
  343. /* Init coefficient pointers */
  344. pCoefA = &pATable[0];
  345. pCoefB = &pBTable[0];
  346. const q15_t *pCoefAb, *pCoefBb;
  347. pCoefAb = pCoefA;
  348. pCoefBb = pCoefB;
  349. pIn1 = &pSrc[0];
  350. i = fftLen;
  351. i = i / 4;
  352. while (i > 0U) {
  353. q15x8_t in1 = vld1q_s16(pIn1);
  354. q15x8_t in2 = vldrhq_gather_shifted_offset_s16(pSrc, offset);
  355. q15x8_t coefA = vldrhq_gather_shifted_offset_s16(pCoefAb, offsetCoef);
  356. q15x8_t coefB = vldrhq_gather_shifted_offset_s16(pCoefBb, offsetCoef);
  357. /* can we avoid the conjugate here ? */
  358. q15x8_t out = vhaddq_s16(MVE_CMPLX_MULT_FX_AxConjB(in1, coefA, q15x8_t),
  359. vmulq(conj, MVE_CMPLX_MULT_FX_AxB(in2, coefB, q15x8_t)));
  360. vst1q_s16(pDst, out);
  361. pDst += 8;
  362. offsetCoef = vaddq_n_u16(offsetCoef, modifier * 8);
  363. offset -= 8;
  364. pIn1 += 8;
  365. i -= 1;
  366. }
  367. }
  368. #else
  369. void arm_split_rifft_q15(
  370. q15_t * pSrc,
  371. uint32_t fftLen,
  372. const q15_t * pATable,
  373. const q15_t * pBTable,
  374. q15_t * pDst,
  375. uint32_t modifier)
  376. {
  377. uint32_t i; /* Loop Counter */
  378. q31_t outR, outI; /* Temporary variables for output */
  379. const q15_t *pCoefA, *pCoefB; /* Temporary pointers for twiddle factors */
  380. q15_t *pSrc1, *pSrc2;
  381. q15_t *pDst1 = &pDst[0];
  382. pCoefA = &pATable[0];
  383. pCoefB = &pBTable[0];
  384. pSrc1 = &pSrc[0];
  385. pSrc2 = &pSrc[2 * fftLen];
  386. i = fftLen;
  387. while (i > 0U)
  388. {
  389. /*
  390. outR = ( pIn[2 * i] * pATable[2 * i]
  391. + pIn[2 * i + 1] * pATable[2 * i + 1]
  392. + pIn[2 * n - 2 * i] * pBTable[2 * i]
  393. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]);
  394. outI = ( pIn[2 * i + 1] * pATable[2 * i]
  395. - pIn[2 * i] * pATable[2 * i + 1]
  396. - pIn[2 * n - 2 * i] * pBTable[2 * i + 1]
  397. - pIn[2 * n - 2 * i + 1] * pBTable[2 * i]);
  398. */
  399. #if defined (ARM_MATH_DSP)
  400. #ifndef ARM_MATH_BIG_ENDIAN
  401. /* pIn[2 * n - 2 * i] * pBTable[2 * i] - pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1]) */
  402. outR = __SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *) pCoefB));
  403. #else
  404. /* -(-pIn[2 * n - 2 * i] * pBTable[2 * i] + pIn[2 * n - 2 * i + 1] * pBTable[2 * i + 1])) */
  405. outR = -(__SMUSD(read_q15x2(pSrc2), read_q15x2((q15_t *) pCoefB)));
  406. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  407. /* pIn[2 * i] * pATable[2 * i] + pIn[2 * i + 1] * pATable[2 * i + 1] + pIn[2 * n - 2 * i] * pBTable[2 * i] */
  408. outR = __SMLAD(read_q15x2(pSrc1), read_q15x2 ((q15_t *) pCoefA), outR) >> 16U;
  409. /* -pIn[2 * n - 2 * i] * pBTable[2 * i + 1] + pIn[2 * n - 2 * i + 1] * pBTable[2 * i] */
  410. outI = __SMUADX(read_q15x2_da (&pSrc2), read_q15x2((q15_t *) pCoefB));
  411. /* pIn[2 * i + 1] * pATable[2 * i] - pIn[2 * i] * pATable[2 * i + 1] */
  412. #ifndef ARM_MATH_BIG_ENDIAN
  413. outI = __SMLSDX(read_q15x2 ((q15_t *) pCoefA), read_q15x2_ia (&pSrc1), -outI);
  414. #else
  415. outI = __SMLSDX(read_q15x2_ia (&pSrc1), read_q15x2 ((q15_t *) pCoefA), -outI);
  416. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  417. /* write output */
  418. #ifndef ARM_MATH_BIG_ENDIAN
  419. write_q15x2_ia (&pDst1, __PKHBT(outR, (outI >> 16U), 16));
  420. #else
  421. write_q15x2_ia (&pDst1, __PKHBT((outI >> 16U), outR, 16));
  422. #endif /* #ifndef ARM_MATH_BIG_ENDIAN */
  423. #else /* #if defined (ARM_MATH_DSP) */
  424. outR = *pSrc2 * *pCoefB;
  425. outR = outR - (*(pSrc2 + 1) * *(pCoefB + 1));
  426. outR = outR + (*pSrc1 * *pCoefA);
  427. outR = (outR + (*(pSrc1 + 1) * *(pCoefA + 1))) >> 16;
  428. outI = *(pSrc1 + 1) * *pCoefA;
  429. outI = outI - (*pSrc1 * *(pCoefA + 1));
  430. outI = outI - (*pSrc2 * *(pCoefB + 1));
  431. outI = outI - (*(pSrc2 + 1) * *(pCoefB));
  432. /* update input pointers */
  433. pSrc1 += 2U;
  434. pSrc2 -= 2U;
  435. /* write output */
  436. *pDst1++ = (q15_t) outR;
  437. *pDst1++ = (q15_t) (outI >> 16);
  438. #endif /* #if defined (ARM_MATH_DSP) */
  439. /* update coefficient pointer */
  440. pCoefB = pCoefB + (2 * modifier);
  441. pCoefA = pCoefA + (2 * modifier);
  442. i--;
  443. }
  444. }
  445. #endif /* defined(ARM_MATH_MVEI) */