diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:12 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:12 +0200 |
commit | af83ac5ec6c29be8b95513ad65dace6cecab617a (patch) | |
tree | 9f6dac2fc0e08c7cea671a50a3cbb8a608fcd7ba /src/inputPlugins/mp3_plugin.c | |
parent | e99536e8eb56cb829a67ea19f29426ec4b938dcc (diff) | |
download | mpd-af83ac5ec6c29be8b95513ad65dace6cecab617a.tar.gz mpd-af83ac5ec6c29be8b95513ad65dace6cecab617a.tar.xz mpd-af83ac5ec6c29be8b95513ad65dace6cecab617a.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 '')
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 2a6346bda..0a99cab21 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -932,12 +932,18 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, 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; |