Add support for Q8.23 data in audio primitives
Change-Id: I420f1564c0f2c46c81e4596b9d76506e1ebc4a14
Signed-off-by: Andy Hung <hunga@google.com>
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
index 9a50bac..91e1bbb 100644
--- a/audio_utils/primitives.c
+++ b/audio_utils/primitives.c
@@ -127,6 +127,34 @@
}
}
+void memcpy_to_q8_23_from_i16(int32_t *dst, const int16_t *src, size_t count)
+{
+ while (count--) {
+ *dst++ = (int32_t)*src++ << 8;
+ }
+}
+
+void memcpy_to_q8_23_from_float_with_clamp(int32_t *dst, const float *src, size_t count)
+{
+ while (count--) {
+ *dst++ = clamp24_from_float(*src++);
+ }
+}
+
+void memcpy_to_i16_from_q8_23(int16_t *dst, const int32_t *src, size_t count)
+{
+ while (count--) {
+ *dst++ = clamp16(*src++ >> 8);
+ }
+}
+
+void memcpy_to_float_from_q8_23(float *dst, const int32_t *src, size_t count)
+{
+ while (count--) {
+ *dst++ = float_from_q8_23(*src++);
+ }
+}
+
void memcpy_to_i32_from_i16(int32_t *dst, const int16_t *src, size_t count)
{
while (count--) {