Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Mueller <nexyon@gmail.com>2010-01-01 17:18:43 +0300
committerJoerg Mueller <nexyon@gmail.com>2010-01-01 17:18:43 +0300
commitc58f2dfc9d27a5635360a96116fb3a887c35b890 (patch)
treeda386df74b4914f00aa118dae42052089d9021d8 /intern/audaspace
parent422335b3a247a719031cb5c8da83df1ae3c5fc03 (diff)
Another fix for the new year's commit, fixing the linear resampler (and such the error that I though was in the envelope!).
Diffstat (limited to 'intern/audaspace')
-rw-r--r--intern/audaspace/intern/AUD_LinearResampleReader.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/intern/audaspace/intern/AUD_LinearResampleReader.cpp b/intern/audaspace/intern/AUD_LinearResampleReader.cpp
index 70e29b9570d..dcd5310575d 100644
--- a/intern/audaspace/intern/AUD_LinearResampleReader.cpp
+++ b/intern/audaspace/intern/AUD_LinearResampleReader.cpp
@@ -28,7 +28,8 @@
#include <cmath>
#include <cstring>
-#include <cstdio>
+
+#define CC channels + channel
AUD_LinearResampleReader::AUD_LinearResampleReader(AUD_IReader* reader,
AUD_Specs specs) :
@@ -77,7 +78,8 @@ AUD_Specs AUD_LinearResampleReader::getSpecs()
void AUD_LinearResampleReader::read(int & length, sample_t* & buffer)
{
- int size = length * AUD_SAMPLE_SIZE(m_tspecs);
+ int samplesize = AUD_SAMPLE_SIZE(m_tspecs);
+ int size = length * samplesize;
if(m_buffer->getSize() < size)
m_buffer->resize(size);
@@ -102,36 +104,29 @@ void AUD_LinearResampleReader::read(int & length, sample_t* & buffer)
{
spos = (m_position + i) / m_factor - m_sposition;
- if((floor(spos) < -2) || (ceil(spos) >= len))
- {
- fprintf(stderr, "FATAL ERROR: REPORT THIS TO neXyon!\n");
-// exit(1);
- }
-
if(floor(spos) < 0)
{
- low = m_cache->getBuffer()[(int)(floor(spos) + 2) * channels
- + channel];
+ low = m_cache->getBuffer()[(int)(floor(spos) + 2) * CC];
if(ceil(spos) < 0)
- high = m_cache->getBuffer()[(int)(ceil(spos) + 2)
- * channels + channel];
+ high = m_cache->getBuffer()[(int)(ceil(spos) + 2) * CC];
else
- high = buf[(int)ceil(spos) * channels + channel];
+ high = buf[(int)ceil(spos) * CC];
}
else
{
- low = buf[(int)floor(spos) * channels + channel];
- high = buf[(int)ceil(spos) * channels + channel];
+ low = buf[(int)floor(spos) * CC];
+ high = buf[(int)ceil(spos) * CC];
}
- buffer[i * channels + channel] = low + (spos - floor(spos)) *
- (high - low);
+ buffer[i * CC] = low + (spos - floor(spos)) * (high - low);
}
}
if(len > 1)
- memcpy(m_cache->getBuffer(), buf + (len - 2) * channels, 2 * channels);
+ memcpy(m_cache->getBuffer(),
+ buf + (len - 2) * channels,
+ 2 * samplesize);
else if(len == 1)
- memcpy(m_cache->getBuffer() + 1 * channels, buf, channels);
+ memcpy(m_cache->getBuffer() + 1 * channels, buf, samplesize);
m_sposition += len;
m_position += length;