void memcpy_to_float_from_q8_23(float *dst, const int32_t *src, size_t count);
/**
+ * Expand and copy samples from unsigned 8-bit offset by 0x80 to signed 32-bit.
+ *
+ * \param dst Destination buffer
+ * \param src Source buffer
+ * \param 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_i32_from_u8(int32_t *dst, const uint8_t *src, size_t count);
+
+/**
* Copy samples from signed fixed point 16-bit Q0.15 to signed fixed-point 32-bit Q0.31.
* The output data range is [0x80000000, 0x7fff0000] at intervals of 0x10000.
*
}
}
+void memcpy_to_i32_from_u8(int32_t *dst, const uint8_t *src, size_t count)
+{
+ dst += count;
+ src += count;
+ for (; count > 0; --count) {
+ *--dst = ((int32_t)(*--src) - 0x80) << 24;
+ }
+}
+
void memcpy_to_i32_from_i16(int32_t *dst, const int16_t *src, size_t count)
{
dst += count;
}
constexpr size_t testsize = std::min(u8size, size);
+ zeroFill(fary);
memcpy_to_float_from_u8(fary.data(), u8ref.data(), testsize);
memcpy_to_u8_from_float(u8ary.data(), fary.data(), testsize);
EXPECT_EQ(0, memcmp(u8ary.data(), u8ref.data(), u8ary.size() * sizeof(u8ary[0])));
+
+ // test conversion from u8 to i32
+ zeroFill(i32ary);
+ memcpy_to_i32_from_u8(i32ary.data(), u8ref.data(), testsize);
+ checkMonotone(i32ary.data(), testsize);
}
template<typename T>