diff options
author | Max Kellermann <max@duempel.org> | 2008-11-12 07:03:44 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-12 07:03:44 +0100 |
commit | 975d5cd77e80c8fbaf5ab307767cb4740dac4be4 (patch) | |
tree | f588ecfc5451abbf89774b9a1cd80f9ad81d5a78 /src/decoder/mpc_plugin.c | |
parent | 865757835ec586963847c630790d636c35914fa8 (diff) | |
download | mpd-975d5cd77e80c8fbaf5ab307767cb4740dac4be4.tar.gz mpd-975d5cd77e80c8fbaf5ab307767cb4740dac4be4.tar.xz mpd-975d5cd77e80c8fbaf5ab307767cb4740dac4be4.zip |
mpc: make the buffer large enough for one mpc frame
Don't split the buffer conversion loop. When libmpcdec returns a
chunk, convert and send the whole chunk at a time. This moves several
checks out of the loop, and greatly improves performance.
Diffstat (limited to 'src/decoder/mpc_plugin.c')
-rw-r--r-- | src/decoder/mpc_plugin.c | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/src/decoder/mpc_plugin.c b/src/decoder/mpc_plugin.c index 81a82b98e..e1f6353de 100644 --- a/src/decoder/mpc_plugin.c +++ b/src/decoder/mpc_plugin.c @@ -108,8 +108,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) MPC_SAMPLE_FORMAT sample_buffer[MPC_DECODER_BUFFER_LENGTH]; long ret; -#define MPC_CHUNK_SIZE 4096 - int32_t chunk[MPC_CHUNK_SIZE / sizeof(int32_t)]; + int32_t chunk[G_N_ELEMENTS(sample_buffer)]; int chunkpos = 0; long bitRate = 0; int32_t *dest = chunk; @@ -188,37 +187,21 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) for (i = 0; i < ret; i++) { *dest++ = convertSample(sample_buffer[i]); chunkpos += sizeof(*dest); - - if (chunkpos >= MPC_CHUNK_SIZE) { - total_time = ((float)samplePos) / - audio_format.sample_rate; - - bitRate = vbrUpdateBits * - audio_format.sample_rate / 1152 / 1000; - - decoder_data(mpd_decoder, inStream, - chunk, chunkpos, - total_time, - bitRate, replayGainInfo); - - chunkpos = 0; - dest = chunk; - if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) - break; - } } - } - if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP && - chunkpos > 0) { total_time = ((float)samplePos) / audio_format.sample_rate; + bitRate = vbrUpdateBits * audio_format.sample_rate + / 1152 / 1000; - bitRate = - vbrUpdateBits * audio_format.sample_rate / 1152 / 1000; + decoder_data(mpd_decoder, inStream, + chunk, chunkpos, + total_time, + bitRate, replayGainInfo); - decoder_data(mpd_decoder, NULL, - chunk, chunkpos, total_time, bitRate, - replayGainInfo); + dest = chunk; + + if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) + break; } replay_gain_info_free(replayGainInfo); |