[Scummvm-cvs-logs] SF.net SVN: scummvm: [28986] scummvm/branches/gsoc2007-mixer/sound/rate.cpp
dogmatixman at users.sourceforge.net
dogmatixman at users.sourceforge.net
Thu Sep 20 14:59:31 CEST 2007
Revision: 28986
http://scummvm.svn.sourceforge.net/scummvm/?rev=28986&view=rev
Author: dogmatixman
Date: 2007-09-20 05:59:31 -0700 (Thu, 20 Sep 2007)
Log Message:
-----------
Eliminated circular indexing of the input buffer during the FilteringRateConverter's main filter loop. This has a tradeoff of doubling the input buffer length.
Modified Paths:
--------------
scummvm/branches/gsoc2007-mixer/sound/rate.cpp
Modified: scummvm/branches/gsoc2007-mixer/sound/rate.cpp
===================================================================
--- scummvm/branches/gsoc2007-mixer/sound/rate.cpp 2007-09-20 12:47:04 UTC (rev 28985)
+++ scummvm/branches/gsoc2007-mixer/sound/rate.cpp 2007-09-20 12:59:31 UTC (rev 28986)
@@ -411,7 +411,12 @@
numChan = (stereo ? 2 : 1);
- inBuf = (st_sample_t *)calloc(numChan * subLen, sizeof(st_sample_t));
+ /*
+ * Buffer for the input samples. Twice the required length is
+ * allocated so that the input samples can be read linearly in the main
+ * filtering loop.
+ */
+ inBuf = (st_sample_t *)calloc(2 * numChan * subLen, sizeof(st_sample_t));
inPos = 0;
@@ -438,6 +443,17 @@
uint8 inLen;
inLen = input.readBuffer(&inBuf[inPos], numChan);
+
+ /*
+ * Store a second copy of the input sample(s) so that
+ * the input buffer can be accessed linearly (rather
+ * than circularly) during the filtering loop
+ */
+ inBuf[inPos + numChan * subLen] = inBuf[inPos];
+ if (stereo) {
+ inBuf[inPos + numChan * subLen + 1] = inBuf[inPos + 1];
+ }
+
if (inLen == 0) {
/* No more input samples */
return this->drain(obuf, (oend - obuf) / 2, vol_l, vol_r);
@@ -459,10 +475,10 @@
double *base = coeffs + (currBank * subLen);
for (i = 0; i < subLen; i++) {
- accum0 += (double)inBuf[(inPos + numChan * i) % (numChan * subLen)]
+ accum0 += (double)inBuf[inPos + numChan * i]
* base[i];
if (stereo) {
- accum1 += (double)inBuf[(inPos + numChan * i + 1) % (numChan * subLen)]
+ accum1 += (double)inBuf[inPos + numChan * i + 1]
* base[i];
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list