From bac136608d91999fdf366391be9633aa107c21f6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Oct 2008 16:34:52 +0200 Subject: 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. --- src/inputPlugins/mp3_plugin.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3