aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:13 +0200
committerEric Wong <normalperson@yhbt.net>2008-08-30 19:46:22 -0700
commit6bb58f41a999fba23a758c072c8c1fd87cf209d3 (patch)
treee68c46c9f6e191044d63877cdac51cdf3f48ea56
parent66ecc1901ad51a1c8a54064fd5ac33454a7cd4b2 (diff)
downloadmpd-6bb58f41a999fba23a758c072c8c1fd87cf209d3.tar.gz
mpd-6bb58f41a999fba23a758c072c8c1fd87cf209d3.tar.xz
mpd-6bb58f41a999fba23a758c072c8c1fd87cf209d3.zip
mp3: moved num_samples calculation out of the loop
The previous patch removed all loop specific dependencies from the num_samples formula; we can now calculate it before entering the loop.
-rw-r--r--src/inputPlugins/mp3_plugin.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 16770e63f..40a2b9c73 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -850,7 +850,7 @@ static void mp3Read_seek(mp3DecodeData * data)
static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
{
- unsigned int pcm_length;
+ unsigned int pcm_length, max_samples;
unsigned int i;
int ret;
int skip;
@@ -945,14 +945,15 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
pcm_length -= data->dropSamplesAtEnd;
}
+ max_samples = sizeof(data->outputBuffer) /
+ (2 * MAD_NCHANNELS(&(data->frame).header));
+
while (i < pcm_length) {
enum dc_action action;
- unsigned int num_samples = sizeof(data->outputBuffer) /
- (2 * MAD_NCHANNELS(&(data->frame).header));
-
- if (num_samples > pcm_length - i)
- num_samples = pcm_length - i;
+ unsigned int num_samples = pcm_length - i;
+ if (num_samples > max_samples)
+ num_samples = max_samples;
i += num_samples;
num_samples = dither_buffer((mpd_sint16 *)