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 | d9583aa95b93899cb2b946df11f7220b68723e6f (patch) | |
tree | 48b1b8a226f9024e7b171fd3d0acbf4646ff1ac8 /src/inputPlugins | |
parent | df251a9960c2ced5f3ac06b57de3b789c189df03 (diff) | |
download | mpd-d9583aa95b93899cb2b946df11f7220b68723e6f.tar.gz mpd-d9583aa95b93899cb2b946df11f7220b68723e6f.tar.xz mpd-d9583aa95b93899cb2b946df11f7220b68723e6f.zip |
mp3: don't check dropSamplesAtStart in the loop
Performance improvement by moving stuff out of a loop: skip part of
the first frame before entering the loop.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 2fbc61878..87fbfb49c 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -896,15 +896,24 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, samplesLeft = (data->synth).pcm.length; - for (i = 0; i < (data->synth).pcm.length; i++) { + if (!data->decodedFirstFrame) { + if (data->dropSamplesAtStart >= samplesLeft) { + i = samplesLeft; + samplesLeft = 0; + } else { + i = data->dropSamplesAtStart; + samplesLeft -= data->dropSamplesAtStart; + } + data->decodedFirstFrame = 1; + } else + i = 0; + + for (; i < (data->synth).pcm.length; i++) { mpd_sint16 *sample; samplesLeft--; - if (!data->decodedFirstFrame && - (i < data->dropSamplesAtStart)) { - continue; - } else if (data->dropSamplesAtEnd && + if (data->dropSamplesAtEnd && (data->currentFrame == (data->maxFrames - data->dropFramesAtEnd)) && (samplesLeft < data->dropSamplesAtEnd)) { /* stop decoding, effectively dropping @@ -947,8 +956,6 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, } } - data->decodedFirstFrame = 1; - if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK && data->inStream->seekable) { long j = 0; |