Move memcpy_to_i16_from_u8 from libmedia

Change-Id: I178b953767f11abcca721efcd7f255d0cb2f3bd0
diff --git a/audio_utils/include/audio_utils/primitives.h b/audio_utils/include/audio_utils/primitives.h
index c67ed1b..16adbff 100644
--- a/audio_utils/include/audio_utils/primitives.h
+++ b/audio_utils/include/audio_utils/primitives.h
@@ -34,6 +34,16 @@
  */
 void ditherAndClamp(int32_t* out, const int32_t *sums, size_t c);
 
+/* Expand and copy samples from unsigned 8-bit offset by 0x80 to signed 16-bit.
+ * Parameters:
+ *  dst     Destination buffer
+ *  src     Source buffer
+ *  count   Number of samples to copy
+ * The destination and source buffers must either be completely separate (non-overlapping), or
+ * they must both start at the same address.  Partially overlapping buffers are not supported.
+ */
+void memcpy_to_i16_from_u8(int16_t *dst, const uint8_t *src, size_t count);
+
 /**
  * Clamp (aka hard limit or clip) a signed 32-bit sample to 16-bit range.
  */
diff --git a/audio_utils/primitives.c b/audio_utils/primitives.c
index e19950f..8697ea1 100644
--- a/audio_utils/primitives.c
+++ b/audio_utils/primitives.c
@@ -29,3 +29,12 @@
         *out++ = (r<<16) | (l & 0xFFFF);
     }
 }
+
+void memcpy_to_i16_from_u8(int16_t *dst, const uint8_t *src, size_t count)
+{
+    dst += count;
+    src += count;
+    while (count--) {
+        *--dst = (int16_t)(*--src - 0x80) << 8;
+    }
+}