Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00063 void arm_float_to_q31(
00064 float32_t * pSrc,
00065 q31_t * pDst,
00066 uint32_t blockSize)
00067 {
00068 float32_t *pIn = pSrc;
00069 uint32_t blkCnt;
00070
00071 #ifdef ARM_MATH_ROUNDING
00072
00073 float32_t in;
00074
00075 #endif
00076
00077
00078
00079 blkCnt = blockSize >> 3u;
00080
00081
00082
00083 while(blkCnt > 0u)
00084 {
00085 #ifdef ARM_MATH_ROUNDING
00086
00087
00088 in = *pIn++;
00089 in = (in * 2147483648.0f);
00090 in += in > 0 ? 0.5 : -0.5;
00091 *pDst++ = clip_q63_to_q31((q63_t) (in));
00092
00093 in = *pIn++;
00094 in = (in * 2147483648.0f);
00095 in += in > 0 ? 0.5 : -0.5;
00096 *pDst++ = clip_q63_to_q31((q63_t) (in));
00097
00098 in = *pIn++;
00099 in = (in * 2147483648.0f);
00100 in += in > 0 ? 0.5 : -0.5;
00101 *pDst++ = clip_q63_to_q31((q63_t) (in));
00102
00103 in = *pIn++;
00104 in = (in * 2147483648.0f);
00105 in += in > 0 ? 0.5 : -0.5;
00106 *pDst++ = clip_q63_to_q31((q63_t) (in));
00107
00108 in = *pIn++;
00109 in = (in * 2147483648.0f);
00110 in += in > 0 ? 0.5 : -0.5;
00111 *pDst++ = clip_q63_to_q31((q63_t) (in));
00112
00113 in = *pIn++;
00114 in = (in * 2147483648.0f);
00115 in += in > 0 ? 0.5 : -0.5;
00116 *pDst++ = clip_q63_to_q31((q63_t) (in));
00117
00118 in = *pIn++;
00119 in = (in * 2147483648.0f);
00120 in += in > 0 ? 0.5 : -0.5;
00121 *pDst++ = clip_q63_to_q31((q63_t) (in));
00122
00123 in = *pIn++;
00124 in = (in * 2147483648.0f);
00125 in += in > 0 ? 0.5 : -0.5;
00126 *pDst++ = clip_q63_to_q31((q63_t) (in));
00127
00128 #else
00129
00130
00131
00132 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00133 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00134 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00135 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00136 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00137 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00138 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00139 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00140
00141 #endif
00142
00143
00144 blkCnt--;
00145 }
00146
00147
00148
00149 blkCnt = blockSize % 0x8u;
00150
00151 while(blkCnt > 0u)
00152 {
00153 #ifdef ARM_MATH_ROUNDING
00154
00155
00156
00157 in = *pIn++;
00158 in = (in * 2147483648.0f);
00159 in += in > 0 ? 0.5 : -0.5;
00160 *pDst++ = clip_q63_to_q31((q63_t) (in));
00161
00162 #else
00163
00164
00165
00166 *pDst++ = clip_q63_to_q31((q63_t) (*pIn++ * 2147483648.0f));
00167
00168 #endif
00169
00170
00171 blkCnt--;
00172 }
00173 }
00174