reset samplefrac to 8-bits, to prevent overflow

issue: https://github.com/ioquake/ioq3/issues/106
This commit is contained in:
fmwviormv 2016-10-07 01:21:15 +03:30 committed by GitHub
parent 1246d16834
commit 2ef641b969

View file

@ -126,13 +126,15 @@ static int ResampleSfx( sfx_t *sfx, int channels, int inrate, int inwidth, int s
outcount = samples / stepscale;
srcsample = 0;
samplefrac = 0;
fracstep = stepscale * 256 * channels;
chunk = sfx->soundData;
for (i=0 ; i<outcount ; i++)
{
srcsample = samplefrac >> 8;
srcsample += samplefrac >> 8;
samplefrac &= 255;
samplefrac += fracstep;
for (j=0 ; j<channels ; j++)
{
@ -178,12 +180,14 @@ static int ResampleSfxRaw( short *sfx, int channels, int inrate, int inwidth, in
outcount = samples / stepscale;
srcsample = 0;
samplefrac = 0;
fracstep = stepscale * 256 * channels;
for (i=0 ; i<outcount ; i++)
{
srcsample = samplefrac >> 8;
srcsample += samplefrac >> 8;
samplefrac &= 255;
samplefrac += fracstep;
for (j=0 ; j<channels ; j++)
{