aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-10 16:34:52 +0200
committerMax Kellermann <max@duempel.org>2008-10-10 16:34:52 +0200
commitbac136608d91999fdf366391be9633aa107c21f6 (patch)
tree1c6c56877800fe18f09715124c3f8bb68bee676d /src
parent5de7521900285dab2ffa8b9a0af6f883494686b5 (diff)
downloadmpd-bac136608d91999fdf366391be9633aa107c21f6.tar.gz
mpd-bac136608d91999fdf366391be9633aa107c21f6.tar.xz
mpd-bac136608d91999fdf366391be9633aa107c21f6.zip
mp3: hard-code dithering to 16 bits
The dithering function audio_linear_dither() worked for signed 16 bits only anyway, having a variable "bits" just disables important gcc optimizations.
Diffstat (limited to 'src')
-rw-r--r--src/inputPlugins/mp3_plugin.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 2990de1ac..1bfc707a5 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -65,13 +65,14 @@ static unsigned long prng(unsigned long state)
return (state * 0x0019660dL + 0x3c6ef35fL) & 0xffffffffL;
}
-static int16_t audio_linear_dither(unsigned int bits, mad_fixed_t sample,
- struct audio_dither *dither)
+static int16_t audio_linear_dither(mad_fixed_t sample,
+ struct audio_dither *dither)
{
- unsigned int scalebits;
mad_fixed_t output, mask, rnd;
enum {
+ bits = 16,
+ scalebits = MAD_F_FRACBITS + 1 - bits,
MIN = -MAD_F_ONE,
MAX = MAD_F_ONE - 1
};
@@ -83,7 +84,6 @@ static int16_t audio_linear_dither(unsigned int bits, mad_fixed_t sample,
output = sample + (1L << (MAD_F_FRACBITS + 1 - bits - 1));
- scalebits = MAD_F_FRACBITS + 1 - bits;
mask = (1L << scalebits) - 1;
rnd = prng(dither->random);
@@ -119,13 +119,11 @@ static unsigned dither_buffer(int16_t *dest0, const struct mad_synth *synth,
unsigned int i;
for (i = start; i < end; ++i) {
- *dest++ = audio_linear_dither(16,
- synth->pcm.samples[0][i],
+ *dest++ = audio_linear_dither(synth->pcm.samples[0][i],
dither);
if (num_channels == 2)
- *dest++ = audio_linear_dither(16,
- synth->pcm.samples[1][i],
+ *dest++ = audio_linear_dither(synth->pcm.samples[1][i],
dither);
}