comparison 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
comparison
equal deleted inserted replaced
162:a2b3fd07d862 163:4f092806782b
197 197
198 } 198 }
199 199
200 void Decimator::process(const double *src, double *dst) 200 void Decimator::process(const double *src, double *dst)
201 { 201 {
202 if( m_decFactor != 1 ) 202 if (m_decFactor == 1) {
203 { 203 for( unsigned int i = 0; i < m_outputLength; i++ ) {
204 doAntiAlias( src, decBuffer, m_inputLength ); 204 dst[i] = src[i];
205 } 205 }
206 return;
207 }
208
209 doAntiAlias( src, decBuffer, m_inputLength );
210
206 unsigned idx = 0; 211 unsigned idx = 0;
207 212
208 for( unsigned int i = 0; i < m_outputLength; i++ ) 213 for( unsigned int i = 0; i < m_outputLength; i++ )
209 { 214 {
210 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; 215 dst[ idx++ ] = decBuffer[ m_decFactor * i ];
211 } 216 }
212 } 217 }
213 218
214 void Decimator::process(const float *src, float *dst) 219 void Decimator::process(const float *src, float *dst)
215 { 220 {
216 if( m_decFactor != 1 ) 221 if (m_decFactor == 1) {
217 { 222 for( unsigned int i = 0; i < m_outputLength; i++ ) {
218 doAntiAlias( src, decBuffer, m_inputLength ); 223 dst[i] = src[i];
219 } 224 }
225 return;
226 }
227
228 doAntiAlias( src, decBuffer, m_inputLength );
229
220 unsigned idx = 0; 230 unsigned idx = 0;
221 231
222 for( unsigned int i = 0; i < m_outputLength; i++ ) 232 for( unsigned int i = 0; i < m_outputLength; i++ )
223 { 233 {
224 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; 234 dst[ idx++ ] = decBuffer[ m_decFactor * i ];