Add q4_27 conversion from float with tests
Change-Id: If7cb0b1e1fbd34202a4be69e91cb2c8743ab0ad6
Signed-off-by: Andy Hung <hunga@google.com>
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
index 4553688..443ed9c 100644
--- a/audio_utils/primitives.c
+++ b/audio_utils/primitives.c
@@ -60,10 +60,9 @@
}
}
-void memcpy_to_float_from_q4_27(float *dst, const int32_t *src, size_t c)
+void memcpy_to_float_from_q4_27(float *dst, const int32_t *src, size_t count)
{
- size_t i;
- for (i = 0; i < c; ++i) {
+ while (count--) {
*dst++ = float_from_q4_27(*src++);
}
}
@@ -141,6 +140,13 @@
}
}
+void memcpy_to_q4_27_from_float(int32_t *dst, const float *src, size_t count)
+{
+ while (count--) {
+ *dst++ = clampq4_27_from_float(*src++);
+ }
+}
+
void memcpy_to_i16_from_q8_23(int16_t *dst, const int32_t *src, size_t count)
{
while (count--) {