From 3535eaec2095e685e9a4be0ace8a813ca441dc89 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 30 Jun 2007 00:03:32 +0000 Subject: 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 --- sound/rate.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sound') 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::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::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 -- cgit v1.2.3