decoder/wavpack: read float samples as-is, don't convert to integer

For MPD's new floating point support: when a decoded wavpack file
needs to be resampled, don't convert float to int and back to float.
This commit is contained in:
Max Kellermann 2011-10-08 15:01:01 +02:00
parent 8465c5fe0e
commit 92bb10eed8

View File

@ -111,12 +111,11 @@ static void
format_samples_float(G_GNUC_UNUSED int bytes_per_sample, void *buffer,
uint32_t count)
{
int32_t *dst = buffer;
float *src = buffer;
assert_static(sizeof(*dst) <= sizeof(*src));
float *p = buffer;
while (count--) {
*dst++ = (int32_t)(*src++ + 0.5f);
*p /= (1 << 23);
++p;
}
}
@ -127,7 +126,7 @@ static enum sample_format
wavpack_bits_to_sample_format(bool is_float, int bytes_per_sample)
{
if (is_float)
return SAMPLE_FORMAT_S24_P32;
return SAMPLE_FORMAT_FLOAT;
switch (bytes_per_sample) {
case 1: