transform_functions.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /******************************************************************************
  2. * @file transform_functions.h
  3. * @brief Public header file for CMSIS DSP Library
  4. * @version V1.10.0
  5. * @date 08 July 2021
  6. * Target Processor: Cortex-M and Cortex-A cores
  7. ******************************************************************************/
  8. /*
  9. * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved.
  10. *
  11. * SPDX-License-Identifier: Apache-2.0
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the License); you may
  14. * not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  21. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. #ifndef _TRANSFORM_FUNCTIONS_H_
  26. #define _TRANSFORM_FUNCTIONS_H_
  27. #include "arm_math_types.h"
  28. #include "arm_math_memory.h"
  29. #include "dsp/none.h"
  30. #include "dsp/utils.h"
  31. #include "dsp/basic_math_functions.h"
  32. #include "dsp/complex_math_functions.h"
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. /**
  38. * @defgroup groupTransforms Transform Functions
  39. */
  40. /**
  41. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  42. */
  43. typedef struct
  44. {
  45. uint16_t fftLen; /**< length of the FFT. */
  46. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  47. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  48. const q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
  49. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  50. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  51. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  52. } arm_cfft_radix2_instance_q15;
  53. /* Deprecated */
  54. arm_status arm_cfft_radix2_init_q15(
  55. arm_cfft_radix2_instance_q15 * S,
  56. uint16_t fftLen,
  57. uint8_t ifftFlag,
  58. uint8_t bitReverseFlag);
  59. /* Deprecated */
  60. void arm_cfft_radix2_q15(
  61. const arm_cfft_radix2_instance_q15 * S,
  62. q15_t * pSrc);
  63. /**
  64. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  65. */
  66. typedef struct
  67. {
  68. uint16_t fftLen; /**< length of the FFT. */
  69. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  70. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  71. const q15_t *pTwiddle; /**< points to the twiddle factor table. */
  72. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  73. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  74. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  75. } arm_cfft_radix4_instance_q15;
  76. /* Deprecated */
  77. arm_status arm_cfft_radix4_init_q15(
  78. arm_cfft_radix4_instance_q15 * S,
  79. uint16_t fftLen,
  80. uint8_t ifftFlag,
  81. uint8_t bitReverseFlag);
  82. /* Deprecated */
  83. void arm_cfft_radix4_q15(
  84. const arm_cfft_radix4_instance_q15 * S,
  85. q15_t * pSrc);
  86. /**
  87. * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
  88. */
  89. typedef struct
  90. {
  91. uint16_t fftLen; /**< length of the FFT. */
  92. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  93. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  94. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  95. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  96. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  97. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  98. } arm_cfft_radix2_instance_q31;
  99. /* Deprecated */
  100. arm_status arm_cfft_radix2_init_q31(
  101. arm_cfft_radix2_instance_q31 * S,
  102. uint16_t fftLen,
  103. uint8_t ifftFlag,
  104. uint8_t bitReverseFlag);
  105. /* Deprecated */
  106. void arm_cfft_radix2_q31(
  107. const arm_cfft_radix2_instance_q31 * S,
  108. q31_t * pSrc);
  109. /**
  110. * @brief Instance structure for the Q31 CFFT/CIFFT function.
  111. */
  112. typedef struct
  113. {
  114. uint16_t fftLen; /**< length of the FFT. */
  115. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  116. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  117. const q31_t *pTwiddle; /**< points to the twiddle factor table. */
  118. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  119. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  120. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  121. } arm_cfft_radix4_instance_q31;
  122. /* Deprecated */
  123. void arm_cfft_radix4_q31(
  124. const arm_cfft_radix4_instance_q31 * S,
  125. q31_t * pSrc);
  126. /* Deprecated */
  127. arm_status arm_cfft_radix4_init_q31(
  128. arm_cfft_radix4_instance_q31 * S,
  129. uint16_t fftLen,
  130. uint8_t ifftFlag,
  131. uint8_t bitReverseFlag);
  132. /**
  133. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  134. */
  135. typedef struct
  136. {
  137. uint16_t fftLen; /**< length of the FFT. */
  138. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  139. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  140. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  141. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  142. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  143. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  144. float32_t onebyfftLen; /**< value of 1/fftLen. */
  145. } arm_cfft_radix2_instance_f32;
  146. /* Deprecated */
  147. arm_status arm_cfft_radix2_init_f32(
  148. arm_cfft_radix2_instance_f32 * S,
  149. uint16_t fftLen,
  150. uint8_t ifftFlag,
  151. uint8_t bitReverseFlag);
  152. /* Deprecated */
  153. void arm_cfft_radix2_f32(
  154. const arm_cfft_radix2_instance_f32 * S,
  155. float32_t * pSrc);
  156. /**
  157. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  158. */
  159. typedef struct
  160. {
  161. uint16_t fftLen; /**< length of the FFT. */
  162. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  163. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  164. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  165. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  166. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  167. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  168. float32_t onebyfftLen; /**< value of 1/fftLen. */
  169. } arm_cfft_radix4_instance_f32;
  170. /* Deprecated */
  171. arm_status arm_cfft_radix4_init_f32(
  172. arm_cfft_radix4_instance_f32 * S,
  173. uint16_t fftLen,
  174. uint8_t ifftFlag,
  175. uint8_t bitReverseFlag);
  176. /* Deprecated */
  177. void arm_cfft_radix4_f32(
  178. const arm_cfft_radix4_instance_f32 * S,
  179. float32_t * pSrc);
  180. /**
  181. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  182. */
  183. typedef struct
  184. {
  185. uint16_t fftLen; /**< length of the FFT. */
  186. const q15_t *pTwiddle; /**< points to the Twiddle factor table. */
  187. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  188. uint16_t bitRevLength; /**< bit reversal table length. */
  189. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  190. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  191. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  192. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  193. const q15_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  194. const q15_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  195. const q15_t *rearranged_twiddle_stride3;
  196. #endif
  197. } arm_cfft_instance_q15;
  198. arm_status arm_cfft_init_q15(
  199. arm_cfft_instance_q15 * S,
  200. uint16_t fftLen);
  201. void arm_cfft_q15(
  202. const arm_cfft_instance_q15 * S,
  203. q15_t * p1,
  204. uint8_t ifftFlag,
  205. uint8_t bitReverseFlag);
  206. /**
  207. * @brief Instance structure for the fixed-point CFFT/CIFFT function.
  208. */
  209. typedef struct
  210. {
  211. uint16_t fftLen; /**< length of the FFT. */
  212. const q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  213. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  214. uint16_t bitRevLength; /**< bit reversal table length. */
  215. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  216. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  217. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  218. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  219. const q31_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  220. const q31_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  221. const q31_t *rearranged_twiddle_stride3;
  222. #endif
  223. } arm_cfft_instance_q31;
  224. arm_status arm_cfft_init_q31(
  225. arm_cfft_instance_q31 * S,
  226. uint16_t fftLen);
  227. void arm_cfft_q31(
  228. const arm_cfft_instance_q31 * S,
  229. q31_t * p1,
  230. uint8_t ifftFlag,
  231. uint8_t bitReverseFlag);
  232. /**
  233. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  234. */
  235. typedef struct
  236. {
  237. uint16_t fftLen; /**< length of the FFT. */
  238. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  239. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  240. uint16_t bitRevLength; /**< bit reversal table length. */
  241. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  242. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  243. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  244. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  245. const float32_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  246. const float32_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  247. const float32_t *rearranged_twiddle_stride3;
  248. #endif
  249. } arm_cfft_instance_f32;
  250. arm_status arm_cfft_init_f32(
  251. arm_cfft_instance_f32 * S,
  252. uint16_t fftLen);
  253. void arm_cfft_f32(
  254. const arm_cfft_instance_f32 * S,
  255. float32_t * p1,
  256. uint8_t ifftFlag,
  257. uint8_t bitReverseFlag);
  258. /**
  259. * @brief Instance structure for the Double Precision Floating-point CFFT/CIFFT function.
  260. */
  261. typedef struct
  262. {
  263. uint16_t fftLen; /**< length of the FFT. */
  264. const float64_t *pTwiddle; /**< points to the Twiddle factor table. */
  265. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  266. uint16_t bitRevLength; /**< bit reversal table length. */
  267. } arm_cfft_instance_f64;
  268. arm_status arm_cfft_init_f64(
  269. arm_cfft_instance_f64 * S,
  270. uint16_t fftLen);
  271. void arm_cfft_f64(
  272. const arm_cfft_instance_f64 * S,
  273. float64_t * p1,
  274. uint8_t ifftFlag,
  275. uint8_t bitReverseFlag);
  276. /**
  277. * @brief Instance structure for the Q15 RFFT/RIFFT function.
  278. */
  279. typedef struct
  280. {
  281. uint32_t fftLenReal; /**< length of the real FFT. */
  282. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  283. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  284. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  285. const q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  286. const q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  287. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  288. arm_cfft_instance_q15 cfftInst;
  289. #else
  290. const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  291. #endif
  292. } arm_rfft_instance_q15;
  293. arm_status arm_rfft_init_q15(
  294. arm_rfft_instance_q15 * S,
  295. uint32_t fftLenReal,
  296. uint32_t ifftFlagR,
  297. uint32_t bitReverseFlag);
  298. void arm_rfft_q15(
  299. const arm_rfft_instance_q15 * S,
  300. q15_t * pSrc,
  301. q15_t * pDst);
  302. /**
  303. * @brief Instance structure for the Q31 RFFT/RIFFT function.
  304. */
  305. typedef struct
  306. {
  307. uint32_t fftLenReal; /**< length of the real FFT. */
  308. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  309. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  310. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  311. const q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  312. const q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  313. #if defined(ARM_MATH_MVEI) && !defined(ARM_MATH_AUTOVECTORIZE)
  314. arm_cfft_instance_q31 cfftInst;
  315. #else
  316. const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  317. #endif
  318. } arm_rfft_instance_q31;
  319. arm_status arm_rfft_init_q31(
  320. arm_rfft_instance_q31 * S,
  321. uint32_t fftLenReal,
  322. uint32_t ifftFlagR,
  323. uint32_t bitReverseFlag);
  324. void arm_rfft_q31(
  325. const arm_rfft_instance_q31 * S,
  326. q31_t * pSrc,
  327. q31_t * pDst);
  328. /**
  329. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  330. */
  331. typedef struct
  332. {
  333. uint32_t fftLenReal; /**< length of the real FFT. */
  334. uint16_t fftLenBy2; /**< length of the complex FFT. */
  335. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  336. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  337. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  338. const float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  339. const float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  340. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  341. } arm_rfft_instance_f32;
  342. arm_status arm_rfft_init_f32(
  343. arm_rfft_instance_f32 * S,
  344. arm_cfft_radix4_instance_f32 * S_CFFT,
  345. uint32_t fftLenReal,
  346. uint32_t ifftFlagR,
  347. uint32_t bitReverseFlag);
  348. void arm_rfft_f32(
  349. const arm_rfft_instance_f32 * S,
  350. float32_t * pSrc,
  351. float32_t * pDst);
  352. /**
  353. * @brief Instance structure for the Double Precision Floating-point RFFT/RIFFT function.
  354. */
  355. typedef struct
  356. {
  357. arm_cfft_instance_f64 Sint; /**< Internal CFFT structure. */
  358. uint16_t fftLenRFFT; /**< length of the real sequence */
  359. const float64_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  360. } arm_rfft_fast_instance_f64 ;
  361. arm_status arm_rfft_fast_init_f64 (
  362. arm_rfft_fast_instance_f64 * S,
  363. uint16_t fftLen);
  364. void arm_rfft_fast_f64(
  365. arm_rfft_fast_instance_f64 * S,
  366. float64_t * p, float64_t * pOut,
  367. uint8_t ifftFlag);
  368. /**
  369. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  370. */
  371. typedef struct
  372. {
  373. arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
  374. uint16_t fftLenRFFT; /**< length of the real sequence */
  375. const float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  376. } arm_rfft_fast_instance_f32 ;
  377. arm_status arm_rfft_fast_init_f32 (
  378. arm_rfft_fast_instance_f32 * S,
  379. uint16_t fftLen);
  380. void arm_rfft_fast_f32(
  381. const arm_rfft_fast_instance_f32 * S,
  382. float32_t * p, float32_t * pOut,
  383. uint8_t ifftFlag);
  384. /**
  385. * @brief Instance structure for the floating-point DCT4/IDCT4 function.
  386. */
  387. typedef struct
  388. {
  389. uint16_t N; /**< length of the DCT4. */
  390. uint16_t Nby2; /**< half of the length of the DCT4. */
  391. float32_t normalize; /**< normalizing factor. */
  392. const float32_t *pTwiddle; /**< points to the twiddle factor table. */
  393. const float32_t *pCosFactor; /**< points to the cosFactor table. */
  394. arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
  395. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  396. } arm_dct4_instance_f32;
  397. /**
  398. * @brief Initialization function for the floating-point DCT4/IDCT4.
  399. * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure.
  400. * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
  401. * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
  402. * @param[in] N length of the DCT4.
  403. * @param[in] Nby2 half of the length of the DCT4.
  404. * @param[in] normalize normalizing factor.
  405. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length.
  406. */
  407. arm_status arm_dct4_init_f32(
  408. arm_dct4_instance_f32 * S,
  409. arm_rfft_instance_f32 * S_RFFT,
  410. arm_cfft_radix4_instance_f32 * S_CFFT,
  411. uint16_t N,
  412. uint16_t Nby2,
  413. float32_t normalize);
  414. /**
  415. * @brief Processing function for the floating-point DCT4/IDCT4.
  416. * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure.
  417. * @param[in] pState points to state buffer.
  418. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  419. */
  420. void arm_dct4_f32(
  421. const arm_dct4_instance_f32 * S,
  422. float32_t * pState,
  423. float32_t * pInlineBuffer);
  424. /**
  425. * @brief Instance structure for the Q31 DCT4/IDCT4 function.
  426. */
  427. typedef struct
  428. {
  429. uint16_t N; /**< length of the DCT4. */
  430. uint16_t Nby2; /**< half of the length of the DCT4. */
  431. q31_t normalize; /**< normalizing factor. */
  432. const q31_t *pTwiddle; /**< points to the twiddle factor table. */
  433. const q31_t *pCosFactor; /**< points to the cosFactor table. */
  434. arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
  435. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  436. } arm_dct4_instance_q31;
  437. /**
  438. * @brief Initialization function for the Q31 DCT4/IDCT4.
  439. * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure.
  440. * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure
  441. * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure
  442. * @param[in] N length of the DCT4.
  443. * @param[in] Nby2 half of the length of the DCT4.
  444. * @param[in] normalize normalizing factor.
  445. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  446. */
  447. arm_status arm_dct4_init_q31(
  448. arm_dct4_instance_q31 * S,
  449. arm_rfft_instance_q31 * S_RFFT,
  450. arm_cfft_radix4_instance_q31 * S_CFFT,
  451. uint16_t N,
  452. uint16_t Nby2,
  453. q31_t normalize);
  454. /**
  455. * @brief Processing function for the Q31 DCT4/IDCT4.
  456. * @param[in] S points to an instance of the Q31 DCT4 structure.
  457. * @param[in] pState points to state buffer.
  458. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  459. */
  460. void arm_dct4_q31(
  461. const arm_dct4_instance_q31 * S,
  462. q31_t * pState,
  463. q31_t * pInlineBuffer);
  464. /**
  465. * @brief Instance structure for the Q15 DCT4/IDCT4 function.
  466. */
  467. typedef struct
  468. {
  469. uint16_t N; /**< length of the DCT4. */
  470. uint16_t Nby2; /**< half of the length of the DCT4. */
  471. q15_t normalize; /**< normalizing factor. */
  472. const q15_t *pTwiddle; /**< points to the twiddle factor table. */
  473. const q15_t *pCosFactor; /**< points to the cosFactor table. */
  474. arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
  475. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  476. } arm_dct4_instance_q15;
  477. /**
  478. * @brief Initialization function for the Q15 DCT4/IDCT4.
  479. * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure.
  480. * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
  481. * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
  482. * @param[in] N length of the DCT4.
  483. * @param[in] Nby2 half of the length of the DCT4.
  484. * @param[in] normalize normalizing factor.
  485. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  486. */
  487. arm_status arm_dct4_init_q15(
  488. arm_dct4_instance_q15 * S,
  489. arm_rfft_instance_q15 * S_RFFT,
  490. arm_cfft_radix4_instance_q15 * S_CFFT,
  491. uint16_t N,
  492. uint16_t Nby2,
  493. q15_t normalize);
  494. /**
  495. * @brief Processing function for the Q15 DCT4/IDCT4.
  496. * @param[in] S points to an instance of the Q15 DCT4 structure.
  497. * @param[in] pState points to state buffer.
  498. * @param[in,out] pInlineBuffer points to the in-place input and output buffer.
  499. */
  500. void arm_dct4_q15(
  501. const arm_dct4_instance_q15 * S,
  502. q15_t * pState,
  503. q15_t * pInlineBuffer);
  504. /**
  505. * @brief Instance structure for the Floating-point MFCC function.
  506. */
  507. typedef struct
  508. {
  509. const float32_t *dctCoefs; /**< Internal DCT coefficients */
  510. const float32_t *filterCoefs; /**< Internal Mel filter coefficients */
  511. const float32_t *windowCoefs; /**< Windowing coefficients */
  512. const uint32_t *filterPos; /**< Internal Mel filter positions in spectrum */
  513. const uint32_t *filterLengths; /**< Internal Mel filter lengths */
  514. uint32_t fftLen; /**< FFT length */
  515. uint32_t nbMelFilters; /**< Number of Mel filters */
  516. uint32_t nbDctOutputs; /**< Number of DCT outputs */
  517. #if defined(ARM_MFCC_CFFT_BASED)
  518. /* Implementation of the MFCC is using a CFFT */
  519. arm_cfft_instance_f32 cfft; /**< Internal CFFT instance */
  520. #else
  521. /* Implementation of the MFCC is using a RFFT (default) */
  522. arm_rfft_fast_instance_f32 rfft;
  523. #endif
  524. } arm_mfcc_instance_f32 ;
  525. arm_status arm_mfcc_init_f32(
  526. arm_mfcc_instance_f32 * S,
  527. uint32_t fftLen,
  528. uint32_t nbMelFilters,
  529. uint32_t nbDctOutputs,
  530. const float32_t *dctCoefs,
  531. const uint32_t *filterPos,
  532. const uint32_t *filterLengths,
  533. const float32_t *filterCoefs,
  534. const float32_t *windowCoefs
  535. );
  536. /**
  537. @brief MFCC F32
  538. @param[in] S points to the mfcc instance structure
  539. @param[in] pSrc points to the input samples
  540. @param[out] pDst points to the output MFCC values
  541. @param[inout] pTmp points to a temporary buffer of complex
  542. @return none
  543. */
  544. void arm_mfcc_f32(
  545. const arm_mfcc_instance_f32 * S,
  546. float32_t *pSrc,
  547. float32_t *pDst,
  548. float32_t *pTmp
  549. );
  550. typedef struct
  551. {
  552. const q31_t *dctCoefs; /**< Internal DCT coefficients */
  553. const q31_t *filterCoefs; /**< Internal Mel filter coefficients */
  554. const q31_t *windowCoefs; /**< Windowing coefficients */
  555. const uint32_t *filterPos; /**< Internal Mel filter positions in spectrum */
  556. const uint32_t *filterLengths; /**< Internal Mel filter lengths */
  557. uint32_t fftLen; /**< FFT length */
  558. uint32_t nbMelFilters; /**< Number of Mel filters */
  559. uint32_t nbDctOutputs; /**< Number of DCT outputs */
  560. #if defined(ARM_MFCC_CFFT_BASED)
  561. /* Implementation of the MFCC is using a CFFT */
  562. arm_cfft_instance_q31 cfft; /**< Internal CFFT instance */
  563. #else
  564. /* Implementation of the MFCC is using a RFFT (default) */
  565. arm_rfft_instance_q31 rfft;
  566. #endif
  567. } arm_mfcc_instance_q31 ;
  568. arm_status arm_mfcc_init_q31(
  569. arm_mfcc_instance_q31 * S,
  570. uint32_t fftLen,
  571. uint32_t nbMelFilters,
  572. uint32_t nbDctOutputs,
  573. const q31_t *dctCoefs,
  574. const uint32_t *filterPos,
  575. const uint32_t *filterLengths,
  576. const q31_t *filterCoefs,
  577. const q31_t *windowCoefs
  578. );
  579. /**
  580. @brief MFCC Q31
  581. @param[in] S points to the mfcc instance structure
  582. @param[in] pSrc points to the input samples
  583. @param[out] pDst points to the output MFCC values
  584. @param[inout] pTmp points to a temporary buffer of complex
  585. @return none
  586. */
  587. arm_status arm_mfcc_q31(
  588. const arm_mfcc_instance_q31 * S,
  589. q31_t *pSrc,
  590. q31_t *pDst,
  591. q31_t *pTmp
  592. );
  593. typedef struct
  594. {
  595. const q15_t *dctCoefs; /**< Internal DCT coefficients */
  596. const q15_t *filterCoefs; /**< Internal Mel filter coefficients */
  597. const q15_t *windowCoefs; /**< Windowing coefficients */
  598. const uint32_t *filterPos; /**< Internal Mel filter positions in spectrum */
  599. const uint32_t *filterLengths; /**< Internal Mel filter lengths */
  600. uint32_t fftLen; /**< FFT length */
  601. uint32_t nbMelFilters; /**< Number of Mel filters */
  602. uint32_t nbDctOutputs; /**< Number of DCT outputs */
  603. #if defined(ARM_MFCC_CFFT_BASED)
  604. /* Implementation of the MFCC is using a CFFT */
  605. arm_cfft_instance_q15 cfft; /**< Internal CFFT instance */
  606. #else
  607. /* Implementation of the MFCC is using a RFFT (default) */
  608. arm_rfft_instance_q15 rfft;
  609. #endif
  610. } arm_mfcc_instance_q15 ;
  611. arm_status arm_mfcc_init_q15(
  612. arm_mfcc_instance_q15 * S,
  613. uint32_t fftLen,
  614. uint32_t nbMelFilters,
  615. uint32_t nbDctOutputs,
  616. const q15_t *dctCoefs,
  617. const uint32_t *filterPos,
  618. const uint32_t *filterLengths,
  619. const q15_t *filterCoefs,
  620. const q15_t *windowCoefs
  621. );
  622. /**
  623. @brief MFCC Q15
  624. @param[in] S points to the mfcc instance structure
  625. @param[in] pSrc points to the input samples
  626. @param[out] pDst points to the output MFCC values in q8.7 format
  627. @param[inout] pTmp points to a temporary buffer of complex
  628. @return error status
  629. */
  630. arm_status arm_mfcc_q15(
  631. const arm_mfcc_instance_q15 * S,
  632. q15_t *pSrc,
  633. q15_t *pDst,
  634. q31_t *pTmp
  635. );
  636. #ifdef __cplusplus
  637. }
  638. #endif
  639. #endif /* ifndef _TRANSFORM_FUNCTIONS_H_ */