aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:12 +0200
committerEric Wong <normalperson@yhbt.net>2008-08-30 19:30:38 -0700
commit33b39572ddff251333d92e174d304adb6b2d3b83 (patch)
tree5ab65b3178217115ee2685a77cd03e1602b3067d /src/inputPlugins
parentfdad7dc9df25ba74d8a4c4d9fab7a25e3e0ef3ca (diff)
downloadmpd-33b39572ddff251333d92e174d304adb6b2d3b83.tar.gz
mpd-33b39572ddff251333d92e174d304adb6b2d3b83.tar.xz
mpd-33b39572ddff251333d92e174d304adb6b2d3b83.zip
mp3: dither a whole block at a time
Fill the whole output buffer at a time by using dither_buffer()'s ability to decode blocks. Calculate how many samples fit into the output buffer before each invocation.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/mp3_plugin.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 9c4925dfa..2bdff4bd4 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -957,12 +957,18 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
pcm_length -= data->dropSamplesAtEnd;
}
- for (; i < pcm_length; i++) {
- unsigned int num_samples;
+ while (i < pcm_length) {
+ unsigned int num_samples =
+ (data->outputBufferEnd - data->outputPtr) /
+ (2 * MAD_NCHANNELS(&(data->frame).header));
+ if (num_samples > pcm_length - i)
+ num_samples = pcm_length - i;
+
+ i += num_samples;
num_samples = dither_buffer((mpd_sint16 *) data->outputPtr,
&data->synth, &data->dither,
- i, i + 1,
+ i - num_samples, i,
MAD_NCHANNELS(&(data->frame).header));
data->outputPtr += 2 * num_samples;