From f41fe1e0b5d86470fab406831c18d032e9835d84 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Oct 2008 16:40:48 +0200 Subject: mp3: dither an arbitrary number of channels The mp3 plugin did not use the MAD_NCHANNELS() value correctly: when a stream was not stereo, it was assumed to be mono, although the correct number was passed to MPD. libmad doesn't support more than 2 channels, but this change allows gcc to optimize its inlining strategy. --- src/inputPlugins/mp3_plugin.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 1bfc707a5..13e4a4619 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -116,14 +116,11 @@ static unsigned dither_buffer(int16_t *dest0, const struct mad_synth *synth, unsigned int num_channels) { int16_t *dest = dest0; - unsigned int i; + unsigned int i, c; for (i = start; i < end; ++i) { - *dest++ = audio_linear_dither(synth->pcm.samples[0][i], - dither); - - if (num_channels == 2) - *dest++ = audio_linear_dither(synth->pcm.samples[1][i], + for (c = 0; c < num_channels; ++c) + *dest++ = audio_linear_dither(synth->pcm.samples[c][i], dither); } -- cgit v1.2.3