summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py7
-rw-r--r--volk/include/volk/volk_32f_s32f_convert_16i_a.h15
-rw-r--r--volk/include/volk/volk_32f_s32f_convert_16i_u.h15
3 files changed, 18 insertions, 19 deletions
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py
index 926f1c08b..0d89a149c 100755
--- a/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_float_to_short.py
@@ -34,10 +34,7 @@ class test_float_to_short (gr_unittest.TestCase):
def test_001(self):
src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3, -4.4, -5.5)
- expected_result = [int(round(s)) for s in src_data]
-
- ### Volk results
- expected_result = [0, 1, 2, 3, 4, 6, -1, -2, -3, -4, -5]
+ expected_result = [0, 1, 2, 3, 4, 6, -1, -2, -3, -4, -6]
src = gr.vector_source_f(src_data)
op = gr.float_to_short()
@@ -71,7 +68,7 @@ class test_float_to_short (gr_unittest.TestCase):
scale = 2
vlen = 3
src_data = (0.0, 1.1, 2.2, 3.3, 4.4, 5.5, -1.1, -2.2, -3.3)
- expected_result = [0, 2, 4, 7, 9, 11, -2, -4, -6]
+ expected_result = [0, 2, 4, 7, 9, 11, -2, -4, -7]
src = gr.vector_source_f(src_data)
s2v = gr.stream_to_vector(gr.sizeof_float, vlen)
op = gr.float_to_short(vlen, scale)
diff --git a/volk/include/volk/volk_32f_s32f_convert_16i_a.h b/volk/include/volk/volk_32f_s32f_convert_16i_a.h
index 10c921b08..a24959678 100644
--- a/volk/include/volk/volk_32f_s32f_convert_16i_a.h
+++ b/volk/include/volk/volk_32f_s32f_convert_16i_a.h
@@ -4,6 +4,7 @@
#include <volk/volk_common.h>
#include <inttypes.h>
#include <stdio.h>
+#include <math.h>
#ifdef LV_HAVE_SSE2
#include <emmintrin.h>
@@ -57,7 +58,7 @@ static inline void volk_32f_s32f_convert_16i_a_sse2(int16_t* outputVector, const
r = max_val;
else if(r < min_val)
r = min_val;
- outputVector[number] = (int16_t)(r);
+ outputVector[number] = (int16_t)rintf(r);
}
}
#endif /* LV_HAVE_SSE2 */
@@ -98,10 +99,10 @@ static inline void volk_32f_s32f_convert_16i_a_sse(int16_t* outputVector, const
ret = _mm_max_ps(_mm_min_ps(_mm_mul_ps(ret, vScalar), vmax_val), vmin_val);
_mm_store_ps(outputFloatBuffer, ret);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[0]);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[1]);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[2]);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[3]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[0]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[1]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[2]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[3]);
}
number = quarterPoints * 4;
@@ -111,7 +112,7 @@ static inline void volk_32f_s32f_convert_16i_a_sse(int16_t* outputVector, const
r = max_val;
else if(r < min_val)
r = min_val;
- outputVector[number] = (int16_t)(r);
+ outputVector[number] = (int16_t)rintf(r);
}
}
#endif /* LV_HAVE_SSE */
@@ -138,7 +139,7 @@ static inline void volk_32f_s32f_convert_16i_a_generic(int16_t* outputVector, co
r = min_val;
else if(r > max_val)
r = max_val;
- *outputVectorPtr++ = (int16_t)(r);
+ *outputVectorPtr++ = (int16_t)rintf(r);
}
}
#endif /* LV_HAVE_GENERIC */
diff --git a/volk/include/volk/volk_32f_s32f_convert_16i_u.h b/volk/include/volk/volk_32f_s32f_convert_16i_u.h
index f339a7d10..f58158041 100644
--- a/volk/include/volk/volk_32f_s32f_convert_16i_u.h
+++ b/volk/include/volk/volk_32f_s32f_convert_16i_u.h
@@ -3,6 +3,7 @@
#include <inttypes.h>
#include <stdio.h>
+#include <math.h>
#ifdef LV_HAVE_SSE2
#include <emmintrin.h>
@@ -57,7 +58,7 @@ static inline void volk_32f_s32f_convert_16i_u_sse2(int16_t* outputVector, const
r = max_val;
else if(r < min_val)
r = min_val;
- outputVector[number] = (int16_t)(r);
+ outputVector[number] = (int16_t)rintf(r);
}
}
#endif /* LV_HAVE_SSE2 */
@@ -99,10 +100,10 @@ static inline void volk_32f_s32f_convert_16i_u_sse(int16_t* outputVector, const
ret = _mm_max_ps(_mm_min_ps(_mm_mul_ps(ret, vScalar), vmax_val), vmin_val);
_mm_store_ps(outputFloatBuffer, ret);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[0]);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[1]);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[2]);
- *outputVectorPtr++ = (int16_t)(outputFloatBuffer[3]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[0]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[1]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[2]);
+ *outputVectorPtr++ = (int16_t)rintf(outputFloatBuffer[3]);
}
number = quarterPoints * 4;
@@ -112,7 +113,7 @@ static inline void volk_32f_s32f_convert_16i_u_sse(int16_t* outputVector, const
r = max_val;
else if(r < min_val)
r = min_val;
- outputVector[number] = (int16_t)(r);
+ outputVector[number] = (int16_t)rintf(r);
}
}
#endif /* LV_HAVE_SSE */
@@ -140,7 +141,7 @@ static inline void volk_32f_s32f_convert_16i_u_generic(int16_t* outputVector, co
r = max_val;
else if(r < min_val)
r = min_val;
- *outputVectorPtr++ = (int16_t)(r);
+ *outputVectorPtr++ = (int16_t)rintf(r);
}
}
#endif /* LV_HAVE_GENERIC */