diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:12 +0200 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-08-30 19:20:32 -0700 |
commit | a7eebfdd0e84653e2a005b47f4091c263c0bbd99 (patch) | |
tree | b32f8ce84b9ed0be108ebdcda4e2173fad032571 /src | |
parent | 6489019322e07411a0c9552644d8ddb62961d0eb (diff) | |
download | mpd-a7eebfdd0e84653e2a005b47f4091c263c0bbd99.tar.gz mpd-a7eebfdd0e84653e2a005b47f4091c263c0bbd99.tar.xz mpd-a7eebfdd0e84653e2a005b47f4091c263c0bbd99.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')
-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 684655f97..11d543199 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -921,15 +921,24 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo) 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 @@ -972,8 +981,6 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo) } } - data->decodedFirstFrame = 1; - if (dc_seek()) { if (data->inStream->seekable) mp3Read_seek(data); |