From: James Courtier-D. <jcd...@us...> - 2004-03-08 18:50:37
|
Update of /cvsroot/xine/xine-lib/src/xine-engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17557/xine-lib/src/xine-engine Modified Files: audio_out.c Log Message: Limit software amp so that audio is not clipped. Index: audio_out.c =================================================================== RCS file: /cvsroot/xine/xine-lib/src/xine-engine/audio_out.c,v retrieving revision 1.164 retrieving revision 1.165 diff -u -r1.164 -r1.165 --- audio_out.c 3 Mar 2004 20:09:16 -0000 1.164 +++ audio_out.c 8 Mar 2004 18:33:54 -0000 1.165 @@ -540,6 +540,7 @@ int i; int num_channels; double amp_factor; + int32_t test; num_channels = _x_ao_mode2channels (this->input.mode); if (!num_channels) @@ -549,7 +550,18 @@ if (this->amp_mute) amp_factor=0.0; for (i=0; i<num_frames*num_channels; i++) { - mem[i] = mem[i] * amp_factor; + test = mem[i] * amp_factor; +/* Force limit on amp_factor to prevent clipping */ + if (test < INT16_MIN) { + this->amp_factor = amp_factor = amp_factor * INT16_MIN / test; + test=INT16_MIN; + } + if (test > INT16_MAX) { + this->amp_factor = amp_factor = amp_factor * INT16_MIN / test; + test=INT16_MAX; + } + mem[i] = test; + } } |