[iortcw] 20/95: All: Reset samplefrac to 8-bits to prevent overflow

Simon McVittie smcv at debian.org
Fri Sep 8 10:41:50 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to tag 1.51
in repository iortcw.

commit a62442538e674d755d29391741c6a080b4cc1e6a
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Wed Jan 25 17:36:55 2017 -0500

    All: Reset samplefrac to 8-bits to prevent overflow
---
 MP/code/client/snd_mem.c | 8 ++++++--
 SP/code/client/snd_mem.c | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/MP/code/client/snd_mem.c b/MP/code/client/snd_mem.c
index c5bc8db..77ff1ce 100644
--- a/MP/code/client/snd_mem.c
+++ b/MP/code/client/snd_mem.c
@@ -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++)
 		{
diff --git a/SP/code/client/snd_mem.c b/SP/code/client/snd_mem.c
index b5b8500..acbcc35 100644
--- a/SP/code/client/snd_mem.c
+++ b/SP/code/client/snd_mem.c
@@ -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++)
 		{
@@ -177,12 +179,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++)
 		{

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list