[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25650] trunk/blender/intern/audaspace/ intern/AUD_LinearResampleReader.cpp: Another fix for the new year's commit, fixing the linear resampler ( and such the error that I though was in the envelope!).

Joerg Mueller nexyon at gmail.com
Fri Jan 1 15:18:43 CET 2010


Revision: 25650
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25650
Author:   nexyon
Date:     2010-01-01 15:18:43 +0100 (Fri, 01 Jan 2010)

Log Message:
-----------
Another fix for the new year's commit, fixing the linear resampler (and such the error that I though was in the envelope!).

Modified Paths:
--------------
    trunk/blender/intern/audaspace/intern/AUD_LinearResampleReader.cpp

Modified: trunk/blender/intern/audaspace/intern/AUD_LinearResampleReader.cpp
===================================================================
--- trunk/blender/intern/audaspace/intern/AUD_LinearResampleReader.cpp	2010-01-01 14:04:39 UTC (rev 25649)
+++ trunk/blender/intern/audaspace/intern/AUD_LinearResampleReader.cpp	2010-01-01 14:18:43 UTC (rev 25650)
@@ -28,8 +28,9 @@
 
 #include <cmath>
 #include <cstring>
-#include <cstdio>
 
+#define CC channels + channel
+
 AUD_LinearResampleReader::AUD_LinearResampleReader(AUD_IReader* reader,
 												   AUD_Specs specs) :
 		AUD_EffectReader(reader)
@@ -77,7 +78,8 @@
 
 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 @@
 		{
 			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;





More information about the Bf-blender-cvs mailing list