aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/wavpack_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-10-08 15:01:01 +0200
committerMax Kellermann <max@duempel.org>2011-10-20 02:55:05 +0200
commit92bb10eed823dadad517a918698e160e1f561f9a (patch)
treea41194ee6a4264732dd48a61608fa6f695c1b382 /src/decoder/wavpack_decoder_plugin.c
parent8465c5fe0e154b96edea992fdcb574060934b9e5 (diff)
downloadmpd-92bb10eed823dadad517a918698e160e1f561f9a.tar.gz
mpd-92bb10eed823dadad517a918698e160e1f561f9a.tar.xz
mpd-92bb10eed823dadad517a918698e160e1f561f9a.zip
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.
Diffstat (limited to 'src/decoder/wavpack_decoder_plugin.c')
-rw-r--r--src/decoder/wavpack_decoder_plugin.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/decoder/wavpack_decoder_plugin.c b/src/decoder/wavpack_decoder_plugin.c
index 487831088..4945b75ce 100644
--- a/src/decoder/wavpack_decoder_plugin.c
+++ b/src/decoder/wavpack_decoder_plugin.c
@@ -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: