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.
This commit is contained in:
parent
e99536e8eb
commit
af83ac5ec6
@ -932,12 +932,18 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
|
|||||||
pcm_length -= data->dropSamplesAtEnd;
|
pcm_length -= data->dropSamplesAtEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < pcm_length; i++) {
|
while (i < pcm_length) {
|
||||||
unsigned int num_samples;
|
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,
|
num_samples = dither_buffer((mpd_sint16 *) data->outputPtr,
|
||||||
&data->synth, &data->dither,
|
&data->synth, &data->dither,
|
||||||
i, i + 1,
|
i - num_samples, i,
|
||||||
MAD_NCHANNELS(&(data->frame).header));
|
MAD_NCHANNELS(&(data->frame).header));
|
||||||
data->outputPtr += 2 * num_samples;
|
data->outputPtr += 2 * num_samples;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user