diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-04-19 11:44:38 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-04-19 11:44:38 +0200 |
commit | 1ab66e82c8d65ee7dbaded31d4c07e1ddaf8b868 (patch) | |
tree | f957ef5926b20fce780cfcac50335acda2a30078 /src | |
parent | 3df56a114f8f6549d7c518b9737451b3f0a6ff5e (diff) | |
download | xine-lib-1ab66e82c8d65ee7dbaded31d4c07e1ddaf8b868.tar.gz xine-lib-1ab66e82c8d65ee7dbaded31d4c07e1ddaf8b868.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/audio_out.c | 16 |
1 files changed, 7 insertions, 9 deletions
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<num_frames*num_channels; i++) { + for (i=0; i<total_frames; i++) { test = mem[i] * amp_factor; /* Force limit on amp_factor to prevent clipping */ if (test < INT8_MIN) { @@ -614,7 +612,7 @@ static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { int32_t test; int16_t *mem = (int16_t *) buf; - for (i=0; i<num_frames*num_channels; i++) { + for (i=0; i<total_frames; i++) { test = mem[i] * amp_factor; /* Force limit on amp_factor to prevent clipping */ if (test < INT16_MIN) { |