diff options
| author | Max Horn | 2007-06-30 00:03:32 +0000 | 
|---|---|---|
| committer | Max Horn | 2007-06-30 00:03:32 +0000 | 
| commit | 3535eaec2095e685e9a4be0ace8a813ca441dc89 (patch) | |
| tree | 151e386a8d8280db388cd55a4ff86b6fd96c9c01 | |
| parent | b62ef0496c6e4e73848aa8db919e9df5444cb9e1 (diff) | |
| download | scummvm-rg350-3535eaec2095e685e9a4be0ace8a813ca441dc89.tar.gz scummvm-rg350-3535eaec2095e685e9a4be0ace8a813ca441dc89.tar.bz2 scummvm-rg350-3535eaec2095e685e9a4be0ace8a813ca441dc89.zip | |
Tweak LinearRateConverter code so that opos is in the range [0,1[ instead of [-1,0[ when entering the interpolation loop (this allows us to get rid of '& FRAC_LO_MASK')
svn-id: r27780
| -rw-r--r-- | sound/rate.cpp | 9 | 
1 files changed, 4 insertions, 5 deletions
| diff --git a/sound/rate.cpp b/sound/rate.cpp index 5944e64694..6e8e83f9a6 100644 --- a/sound/rate.cpp +++ b/sound/rate.cpp @@ -223,7 +223,7 @@ int LinearRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp  	while (obuf < oend) {  		// read enough input samples so that opos < 0 -		while (0 <= opos) { +		while (FRAC_ONE <= opos) {  			// Check if we have to refill the buffer  			if (inLen == 0) {  				inPtr = inBuf; @@ -243,13 +243,12 @@ int LinearRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp  		// Loop as long as the outpos trails behind, and as long as there is  		// still space in the output buffer. -		while (0 > opos && obuf < oend) { +		while (opos < FRAC_ONE && obuf < oend) {  			// interpolate  			st_sample_t out0, out1; -			const frac_t scale = (opos & FRAC_LO_MASK); -			out0 = (st_sample_t)(ilast0 + (((icur0 - ilast0) * scale + FRAC_HALF) >> FRAC_BITS)); +			out0 = (st_sample_t)(ilast0 + (((icur0 - ilast0) * opos + FRAC_HALF) >> FRAC_BITS));  			out1 = (stereo ? -						  (st_sample_t)(ilast1 + (((icur1 - ilast1) * scale + FRAC_HALF) >> FRAC_BITS)) : +						  (st_sample_t)(ilast1 + (((icur1 - ilast1) * opos + FRAC_HALF) >> FRAC_BITS)) :  						  out0);  			// output left channel | 
