/[pcsx2_0.9.7]/trunk/3rdparty/SoundTouch/FIRFilter.h
ViewVC logotype

Annotation of /trunk/3rdparty/SoundTouch/FIRFilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations) (download)
Mon Sep 6 11:19:43 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 5256 byte(s)
Exported ./upsream/trunk @r3730 from http://pcsx2.googlecode.com/svn/trunk/
1 william 8 ////////////////////////////////////////////////////////////////////////////////
2     ///
3     /// General FIR digital filter routines with MMX optimization.
4     ///
5     /// Note : MMX optimized functions reside in a separate, platform-specific file,
6     /// e.g. 'mmx_win.cpp' or 'mmx_gcc.cpp'
7     ///
8     /// Author : Copyright (c) Olli Parviainen
9     /// Author e-mail : oparviai 'at' iki.fi
10     /// SoundTouch WWW: http://www.surina.net/soundtouch
11     ///
12     ////////////////////////////////////////////////////////////////////////////////
13     //
14     // Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
15     // File revision : $Revision: 4 $
16     //
17     // $Id: FIRFilter.h 63 2009-02-21 16:00:14Z oparviai $
18     //
19     ////////////////////////////////////////////////////////////////////////////////
20     //
21     // License :
22     //
23     // SoundTouch audio processing library
24     // Copyright (c) Olli Parviainen
25     //
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.
30     //
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.
35     //
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
39     //
40     ////////////////////////////////////////////////////////////////////////////////
41    
42     #ifndef FIRFilter_H
43     #define FIRFilter_H
44    
45     #include <stddef.h>
46     #include "STTypes.h"
47    
48     namespace soundtouch
49     {
50    
51     class FIRFilter
52     {
53     protected:
54     // Number of FIR filter taps
55     uint length;
56     // Number of FIR filter taps divided by 8
57     uint lengthDiv8;
58    
59     // Result divider factor in 2^k format
60     uint resultDivFactor;
61    
62     // Result divider value.
63     SAMPLETYPE resultDivider;
64    
65     // Memory for filter coefficients
66     SAMPLETYPE *filterCoeffs;
67    
68     virtual uint evaluateFilterStereo(SAMPLETYPE *dest,
69     const SAMPLETYPE *src,
70     uint numSamples) const;
71     virtual uint evaluateFilterMono(SAMPLETYPE *dest,
72     const SAMPLETYPE *src,
73     uint numSamples) const;
74    
75     public:
76     FIRFilter();
77     virtual ~FIRFilter();
78    
79     /// Operator 'new' is overloaded so that it automatically creates a suitable instance
80     /// depending on if we've a MMX-capable CPU available or not.
81     static void * operator new(size_t s);
82    
83     static FIRFilter *newInstance();
84    
85     /// Applies the filter to the given sequence of samples.
86     /// Note : The amount of outputted samples is by value of 'filter_length'
87     /// smaller than the amount of input samples.
88     ///
89     /// \return Number of samples copied to 'dest'.
90     uint evaluate(SAMPLETYPE *dest,
91     const SAMPLETYPE *src,
92     uint numSamples,
93     uint numChannels) const;
94    
95     uint getLength() const;
96    
97     virtual void setCoefficients(const SAMPLETYPE *coeffs,
98     uint newLength,
99     uint uResultDivFactor);
100     };
101    
102    
103     // Optional subclasses that implement CPU-specific optimizations:
104    
105     #ifdef ALLOW_MMX
106    
107     /// Class that implements MMX optimized functions exclusive for 16bit integer samples type.
108     class FIRFilterMMX : public FIRFilter
109     {
110     protected:
111     short *filterCoeffsUnalign;
112     short *filterCoeffsAlign;
113    
114     virtual uint evaluateFilterStereo(short *dest, const short *src, uint numSamples) const;
115     public:
116     FIRFilterMMX();
117     ~FIRFilterMMX();
118    
119     virtual void setCoefficients(const short *coeffs, uint newLength, uint uResultDivFactor);
120     };
121    
122     #endif // ALLOW_MMX
123    
124    
125     #ifdef ALLOW_3DNOW
126    
127     /// Class that implements 3DNow! optimized functions exclusive for floating point samples type.
128     class FIRFilter3DNow : public FIRFilter
129     {
130     protected:
131     float *filterCoeffsUnalign;
132     float *filterCoeffsAlign;
133    
134     virtual uint evaluateFilterStereo(float *dest, const float *src, uint numSamples) const;
135     public:
136     FIRFilter3DNow();
137     ~FIRFilter3DNow();
138     virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
139     };
140    
141     #endif // ALLOW_3DNOW
142    
143    
144     #ifdef ALLOW_SSE
145     /// Class that implements SSE optimized functions exclusive for floating point samples type.
146     class FIRFilterSSE : public FIRFilter
147     {
148     protected:
149     float *filterCoeffsUnalign;
150     float *filterCoeffsAlign;
151    
152     virtual uint evaluateFilterStereo(float *dest, const float *src, uint numSamples) const;
153     public:
154     FIRFilterSSE();
155     ~FIRFilterSSE();
156    
157     virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
158     };
159    
160     #endif // ALLOW_SSE
161    
162     }
163    
164     #endif // FIRFilter_H

  ViewVC Help
Powered by ViewVC 1.1.22