diff dsp/rateconversion/Decimator.cpp @ 163:4f092806782b

Fix incorrect handling of decimation factor 1; documentation
author Chris Cannam
date Thu, 30 Jan 2014 09:51:06 +0000
parents e5907ae6de17
children fdaa63607c15
line wrap: on
line diff
--- a/dsp/rateconversion/Decimator.cpp	Tue Dec 03 10:16:49 2013 +0000
+++ b/dsp/rateconversion/Decimator.cpp	Thu Jan 30 09:51:06 2014 +0000
@@ -199,10 +199,15 @@
 
 void Decimator::process(const double *src, double *dst)
 {
-    if( m_decFactor != 1 )
-    {
-	doAntiAlias( src, decBuffer, m_inputLength );
+    if (m_decFactor == 1) {
+        for( unsigned int i = 0; i < m_outputLength; i++ ) {
+            dst[i] = src[i];
+        }
+        return;
     }
+        
+    doAntiAlias( src, decBuffer, m_inputLength );
+
     unsigned idx = 0;
 
     for( unsigned int i = 0; i < m_outputLength; i++ )
@@ -213,10 +218,15 @@
 
 void Decimator::process(const float *src, float *dst)
 {
-    if( m_decFactor != 1 )
-    {
-	doAntiAlias( src, decBuffer, m_inputLength );
+    if (m_decFactor == 1) {
+        for( unsigned int i = 0; i < m_outputLength; i++ ) {
+            dst[i] = src[i];
+        }
+        return;
     }
+
+    doAntiAlias( src, decBuffer, m_inputLength );
+
     unsigned idx = 0;
 
     for( unsigned int i = 0; i < m_outputLength; i++ )