1 ////////////////////////////////////////////////////////////////////////////////
3 /// General FIR digital filter routines with MMX optimization.
5 /// Note : MMX optimized functions reside in a separate, platform-specific file,
6 /// e.g. 'mmx_win.cpp' or 'mmx_gcc.cpp'
8 /// Author : Copyright (c) Olli Parviainen
9 /// Author e-mail : oparviai @ iki.fi
10 /// SoundTouch WWW: http://www.iki.fi/oparviai/soundtouch
12 ////////////////////////////////////////////////////////////////////////////////
14 // Last changed : $Date$
15 // File revision : $Revision$
19 ////////////////////////////////////////////////////////////////////////////////
23 // SoundTouch audio processing library
24 // Copyright (c) Olli Parviainen
26 // This library is free software; you can redistribute it and/or
27 // modify it under the terms of the GNU Lesser General Public
28 // License as published by the Free Software Foundation; either
29 // version 2.1 of the License, or (at your option) any later version.
31 // This library is distributed in the hope that it will be useful,
32 // but WITHOUT ANY WARRANTY; without even the implied warranty of
33 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 // Lesser General Public License for more details.
36 // You should have received a copy of the GNU Lesser General Public
37 // License along with this library; if not, write to the Free Software
38 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 ////////////////////////////////////////////////////////////////////////////////
53 // Number of FIR filter taps
55 // Number of FIR filter taps divided by 8
58 // Result divider factor in 2^k format
61 // Result divider value.
62 SAMPLETYPE resultDivider;
64 // Memory for filter coefficients
65 SAMPLETYPE *filterCoeffs;
67 virtual uint evaluateFilterStereo(SAMPLETYPE *dest,
68 const SAMPLETYPE *src,
69 uint numSamples) const;
70 virtual uint evaluateFilterMono(SAMPLETYPE *dest,
71 const SAMPLETYPE *src,
72 uint numSamples) const;
79 static FIRFilter *newInstance();
81 /// Applies the filter to the given sequence of samples.
82 /// Note : The amount of outputted samples is by value of 'filter_length'
83 /// smaller than the amount of input samples.
85 /// \return Number of samples copied to 'dest'.
86 uint evaluate(SAMPLETYPE *dest,
87 const SAMPLETYPE *src,
89 uint numChannels) const;
91 uint getLength() const;
93 virtual void setCoefficients(const SAMPLETYPE *coeffs,
95 uint uResultDivFactor);
99 // Optional subclasses that implement CPU-specific optimizations:
103 /// Class that implements MMX optimized functions exclusive for 16bit integer samples type.
104 class FIRFilterMMX : public FIRFilter
107 short *filterCoeffsUnalign;
108 short *filterCoeffsAlign;
110 virtual uint evaluateFilterStereo(short *dest, const short *src, uint numSamples) const;
115 virtual void setCoefficients(const short *coeffs, uint newLength, uint uResultDivFactor);
123 /// Class that implements 3DNow! optimized functions exclusive for floating point samples type.
124 class FIRFilter3DNow : public FIRFilter
127 float *filterCoeffsUnalign;
128 float *filterCoeffsAlign;
130 virtual uint evaluateFilterStereo(float *dest, const float *src, uint numSamples) const;
134 virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
137 #endif // ALLOW_3DNOW
141 /// Class that implements SSE optimized functions exclusive for floating point samples type.
142 class FIRFilterSSE : public FIRFilter
145 float *filterCoeffsUnalign;
146 float *filterCoeffsAlign;
148 virtual uint evaluateFilterStereo(float *dest, const float *src, uint numSamples) const;
153 virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
160 #endif // FIRFilter_H