Add mono <-> stereo upmix and downmix routines
Change-Id: I3d960fb27fd3440f903333903c0dbf2ab59d3b56
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
index 8697ea1..bec87e0 100644
--- a/audio_utils/primitives.c
+++ b/audio_utils/primitives.c
@@ -38,3 +38,21 @@
*--dst = (int16_t)(*--src - 0x80) << 8;
}
}
+
+void downmix_to_mono_i16_from_stereo_i16(int16_t *dst, const int16_t *src, size_t count)
+{
+ while (count--) {
+ *dst++ = (int16_t)(((int32_t)src[0] + (int32_t)src[1]) >> 1);
+ src += 2;
+ }
+}
+
+void upmix_to_stereo_i16_from_mono_i16(int16_t *dst, const int16_t *src, size_t count)
+{
+ while (count--) {
+ int32_t temp = *src++;
+ dst[0] = temp;
+ dst[1] = temp;
+ dst += 2;
+ }
+}