From 1ab66e82c8d65ee7dbaded31d4c07e1ddaf8b868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 19 Apr 2007 11:44:38 +0200 Subject: audio_filter_amp: calculate the total number of frames to iterate over just once. This way, it avoids to calculate the multiplication in the for loops and in the memset() call. --- src/xine-engine/audio_out.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index fb2758c7a..66e28d80d 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -578,18 +578,16 @@ static void audio_filter_compress (aos_t *this, int16_t *mem, int num_frames) { } static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { - - int i; - int num_channels; double amp_factor; - - num_channels = _x_ao_mode2channels (this->input.mode); - if (!num_channels) + int i; + const int total_frames = num_frames * _x_ao_mode2channels (this->input.mode); + + if (!total_frames) return; amp_factor=this->amp_factor; if (this->amp_mute || amp_factor == 0) { - memset (buf, 0, num_frames * num_channels * (this->input.bits / 8)); + memset (buf, 0, total_frames * (this->input.bits / 8)); return; } @@ -597,7 +595,7 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { int16_t test; int8_t *mem = (int8_t *) buf; - for (i=0; i