transform_functions_f16.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /******************************************************************************
  2. * @file transform_functions_f16.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_F16_H_
  26. #define _TRANSFORM_FUNCTIONS_F16_H_
  27. #include "arm_math_types_f16.h"
  28. #include "arm_math_memory.h"
  29. #include "dsp/none.h"
  30. #include "dsp/utils.h"
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #endif
  35. #if defined(ARM_FLOAT16_SUPPORTED)
  36. /**
  37. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  38. */
  39. typedef struct
  40. {
  41. uint16_t fftLen; /**< length of the FFT. */
  42. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  43. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  44. const float16_t *pTwiddle; /**< points to the Twiddle factor table. */
  45. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  46. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  47. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  48. float16_t onebyfftLen; /**< value of 1/fftLen. */
  49. } arm_cfft_radix2_instance_f16;
  50. /**
  51. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  52. */
  53. typedef struct
  54. {
  55. uint16_t fftLen; /**< length of the FFT. */
  56. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  57. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  58. const float16_t *pTwiddle; /**< points to the Twiddle factor table. */
  59. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  60. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  61. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  62. float16_t onebyfftLen; /**< value of 1/fftLen. */
  63. } arm_cfft_radix4_instance_f16;
  64. /**
  65. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  66. */
  67. typedef struct
  68. {
  69. uint16_t fftLen; /**< length of the FFT. */
  70. const float16_t *pTwiddle; /**< points to the Twiddle factor table. */
  71. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  72. uint16_t bitRevLength; /**< bit reversal table length. */
  73. #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE)
  74. const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \
  75. const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \
  76. const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \
  77. const float16_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \
  78. const float16_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \
  79. const float16_t *rearranged_twiddle_stride3;
  80. #endif
  81. } arm_cfft_instance_f16;
  82. arm_status arm_cfft_init_f16(
  83. arm_cfft_instance_f16 * S,
  84. uint16_t fftLen);
  85. void arm_cfft_f16(
  86. const arm_cfft_instance_f16 * S,
  87. float16_t * p1,
  88. uint8_t ifftFlag,
  89. uint8_t bitReverseFlag);
  90. /**
  91. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  92. */
  93. typedef struct
  94. {
  95. arm_cfft_instance_f16 Sint; /**< Internal CFFT structure. */
  96. uint16_t fftLenRFFT; /**< length of the real sequence */
  97. const float16_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  98. } arm_rfft_fast_instance_f16 ;
  99. arm_status arm_rfft_fast_init_f16 (
  100. arm_rfft_fast_instance_f16 * S,
  101. uint16_t fftLen);
  102. void arm_rfft_fast_f16(
  103. const arm_rfft_fast_instance_f16 * S,
  104. float16_t * p, float16_t * pOut,
  105. uint8_t ifftFlag);
  106. /* Deprecated */
  107. arm_status arm_cfft_radix4_init_f16(
  108. arm_cfft_radix4_instance_f16 * S,
  109. uint16_t fftLen,
  110. uint8_t ifftFlag,
  111. uint8_t bitReverseFlag);
  112. /* Deprecated */
  113. void arm_cfft_radix4_f16(
  114. const arm_cfft_radix4_instance_f16 * S,
  115. float16_t * pSrc);
  116. /* Deprecated */
  117. arm_status arm_cfft_radix2_init_f16(
  118. arm_cfft_radix2_instance_f16 * S,
  119. uint16_t fftLen,
  120. uint8_t ifftFlag,
  121. uint8_t bitReverseFlag);
  122. /* Deprecated */
  123. void arm_cfft_radix2_f16(
  124. const arm_cfft_radix2_instance_f16 * S,
  125. float16_t * pSrc);
  126. /**
  127. * @brief Instance structure for the Floating-point MFCC function.
  128. */
  129. typedef struct
  130. {
  131. const float16_t *dctCoefs; /**< Internal DCT coefficients */
  132. const float16_t *filterCoefs; /**< Internal Mel filter coefficients */
  133. const float16_t *windowCoefs; /**< Windowing coefficients */
  134. const uint32_t *filterPos; /**< Internal Mel filter positions in spectrum */
  135. const uint32_t *filterLengths; /**< Internal Mel filter lengths */
  136. uint32_t fftLen; /**< FFT length */
  137. uint32_t nbMelFilters; /**< Number of Mel filters */
  138. uint32_t nbDctOutputs; /**< Number of DCT outputs */
  139. #if defined(ARM_MFCC_CFFT_BASED)
  140. /* Implementation of the MFCC is using a CFFT */
  141. arm_cfft_instance_f16 cfft; /**< Internal CFFT instance */
  142. #else
  143. /* Implementation of the MFCC is using a RFFT (default) */
  144. arm_rfft_fast_instance_f16 rfft;
  145. #endif
  146. } arm_mfcc_instance_f16 ;
  147. arm_status arm_mfcc_init_f16(
  148. arm_mfcc_instance_f16 * S,
  149. uint32_t fftLen,
  150. uint32_t nbMelFilters,
  151. uint32_t nbDctOutputs,
  152. const float16_t *dctCoefs,
  153. const uint32_t *filterPos,
  154. const uint32_t *filterLengths,
  155. const float16_t *filterCoefs,
  156. const float16_t *windowCoefs
  157. );
  158. /**
  159. @brief MFCC F16
  160. @param[in] S points to the mfcc instance structure
  161. @param[in] pSrc points to the input samples
  162. @param[out] pDst points to the output MFCC values
  163. @param[inout] pTmp points to a temporary buffer of complex
  164. @return none
  165. */
  166. void arm_mfcc_f16(
  167. const arm_mfcc_instance_f16 * S,
  168. float16_t *pSrc,
  169. float16_t *pDst,
  170. float16_t *pTmp
  171. );
  172. #endif /* defined(ARM_FLOAT16_SUPPORTED)*/
  173. #ifdef __cplusplus
  174. }
  175. #endif
  176. #endif /* ifndef _TRANSFORM_FUNCTIONS_F16_H_ */