aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-30 08:44:51 +0100
committerMax Kellermann <max@duempel.org>2008-10-30 08:44:51 +0100
commit0db07a920e237ce46bb1e0fa7da5d945967e7b62 (patch)
tree8f59dd4e200a8c6bdc70b03efeb317b9bf6f3e91 /src/decoder
parent6773dea5b01d884b942f9fa8400510f15ab77c26 (diff)
downloadmpd-0db07a920e237ce46bb1e0fa7da5d945967e7b62.tar.gz
mpd-0db07a920e237ce46bb1e0fa7da5d945967e7b62.tar.xz
mpd-0db07a920e237ce46bb1e0fa7da5d945967e7b62.zip
mpc: moved sample size into a constant
Don't hard-code the "16 bits" or "2 bytes" in multiple locations.
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/mpc_plugin.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/decoder/mpc_plugin.c b/src/decoder/mpc_plugin.c
index 9deaa9780..009828718 100644
--- a/src/decoder/mpc_plugin.c
+++ b/src/decoder/mpc_plugin.c
@@ -68,18 +68,22 @@ static inline int16_t convertSample(MPC_SAMPLE_FORMAT sample)
/* only doing 16-bit audio for now */
int32_t val;
- const int clip_min = -1 << (16 - 1);
- const int clip_max = (1 << (16 - 1)) - 1;
+ enum {
+ bits = 16,
+ };
+
+ const int clip_min = -1 << (bits - 1);
+ const int clip_max = (1 << (bits - 1)) - 1;
#ifdef MPC_FIXED_POINT
- const int shift = 16 - MPC_FIXED_POINT_SCALE_SHIFT;
+ const int shift = bits - MPC_FIXED_POINT_SCALE_SHIFT;
if (shift < 0)
val = sample << -shift;
else
val = sample << shift;
#else
- const int float_scale = 1 << (16 - 1);
+ const int float_scale = 1 << (bits - 1);
val = sample * float_scale;
#endif
@@ -191,7 +195,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream)
for (i = 0; i < ret; i++) {
/* 16 bit audio again */
*dest++ = convertSample(sample_buffer[i]);
- chunkpos += 2;
+ chunkpos += sizeof(*dest);
if (chunkpos >= MPC_CHUNK_SIZE) {
total_time = ((float)samplePos) /