23 #ifndef INCLUDED_volk_32f_s32f_32f_fm_detect_32f_a_H
24 #define INCLUDED_volk_32f_s32f_32f_fm_detect_32f_a_H
30 #include <xmmintrin.h>
39 static inline void volk_32f_s32f_32f_fm_detect_32f_a_sse(
float* outputVector,
const float* inputVector,
const float bound,
float* saveValue,
unsigned int num_points){
43 unsigned int number = 1;
47 const unsigned int quarterPoints = (num_points-1) / 4;
49 float* outPtr = outputVector;
50 const float* inPtr = inputVector;
51 __m128 upperBound = _mm_set_ps1(bound);
52 __m128 lowerBound = _mm_set_ps1(-bound);
56 __m128 posBoundAdjust = _mm_set_ps1(-2*bound);
57 __m128 negBoundAdjust = _mm_set_ps1(2*bound);
59 *outPtr = *inPtr - *saveValue;
60 if (*outPtr > bound) *outPtr -= 2*bound;
61 if (*outPtr < -bound) *outPtr += 2*bound;
64 for (j = 1; j < ( (4 < num_points) ? 4 : num_points); j++) {
65 *outPtr = *(inPtr) - *(inPtr-1);
66 if (*outPtr > bound) *outPtr -= 2*bound;
67 if (*outPtr < -bound) *outPtr += 2*bound;
72 for (; number < quarterPoints; number++) {
74 next3old1 = _mm_loadu_ps((
float*) (inPtr-1));
75 next4 = _mm_load_ps(inPtr);
78 next3old1 = _mm_sub_ps(next4, next3old1);
80 boundAdjust = _mm_cmpgt_ps(next3old1, upperBound);
81 boundAdjust = _mm_and_ps(boundAdjust, posBoundAdjust);
82 next4 = _mm_cmplt_ps(next3old1, lowerBound);
83 next4 = _mm_and_ps(next4, negBoundAdjust);
84 boundAdjust = _mm_or_ps(next4, boundAdjust);
86 next3old1 = _mm_add_ps(next3old1, boundAdjust);
87 _mm_store_ps(outPtr,next3old1);
91 for (number = (4 > (quarterPoints*4) ? 4 : (4 * quarterPoints)); number < num_points; number++) {
92 *outPtr = *(inPtr) - *(inPtr-1);
93 if (*outPtr > bound) *outPtr -= 2*bound;
94 if (*outPtr < -bound) *outPtr += 2*bound;
99 *saveValue = inputVector[num_points-1];
103 #ifdef LV_HAVE_GENERIC
112 static inline void volk_32f_s32f_32f_fm_detect_32f_generic(
float* outputVector,
const float* inputVector,
const float bound,
float* saveValue,
unsigned int num_points){
113 if (num_points < 1) {
116 unsigned int number = 0;
117 float* outPtr = outputVector;
118 const float* inPtr = inputVector;
121 *outPtr = *inPtr - *saveValue;
122 if (*outPtr > bound) *outPtr -= 2*bound;
123 if (*outPtr < -bound) *outPtr += 2*bound;
127 for (number = 1; number < num_points; number++) {
128 *outPtr = *(inPtr) - *(inPtr-1);
129 if (*outPtr > bound) *outPtr -= 2*bound;
130 if (*outPtr < -bound) *outPtr += 2*bound;
135 *saveValue = inputVector[num_points-1];