Commit d9583aa9 authored by Max Kellermann's avatar Max Kellermann

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.
parent df251a99
...@@ -896,15 +896,24 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -896,15 +896,24 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
samplesLeft = (data->synth).pcm.length; 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; mpd_sint16 *sample;
samplesLeft--; samplesLeft--;
if (!data->decodedFirstFrame && if (data->dropSamplesAtEnd &&
(i < data->dropSamplesAtStart)) {
continue;
} else if (data->dropSamplesAtEnd &&
(data->currentFrame == (data->maxFrames - data->dropFramesAtEnd)) && (data->currentFrame == (data->maxFrames - data->dropFramesAtEnd)) &&
(samplesLeft < data->dropSamplesAtEnd)) { (samplesLeft < data->dropSamplesAtEnd)) {
/* stop decoding, effectively dropping /* stop decoding, effectively dropping
...@@ -947,8 +956,6 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -947,8 +956,6 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
} }
} }
data->decodedFirstFrame = 1;
if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK && if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK &&
data->inStream->seekable) { data->inStream->seekable) {
long j = 0; long j = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment