Mercurial > SDL_sound_CoreAudio
comparison filter_templates.h @ 403:b1e511c879d1
More altcvt updates and fixes from Frank.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 13 Jul 2002 23:41:08 +0000 |
parents | 44ed8bdeba74 |
children | 45ee760a6f5a |
comparison
equal
deleted
inserted
replaced
402:7ced6c44b827 | 403:b1e511c879d1 |
---|---|
33 /*-------------------------------------------------------------------------*/ | 33 /*-------------------------------------------------------------------------*/ |
34 /* this filter (Kaiser-window beta=6.8) gives a decent -80dB attentuation */ | 34 /* this filter (Kaiser-window beta=6.8) gives a decent -80dB attentuation */ |
35 /*-------------------------------------------------------------------------*/ | 35 /*-------------------------------------------------------------------------*/ |
36 #define sum_d(v,dx) ((int) v[CH(dx)] + v[CH(1-dx)]) | 36 #define sum_d(v,dx) ((int) v[CH(dx)] + v[CH(1-dx)]) |
37 static Sint16* Suffix(doubleRate)( Sint16 *outp, Sint16 *inp, int length, | 37 static Sint16* Suffix(doubleRate)( Sint16 *outp, Sint16 *inp, int length, |
38 VarFilter* filt, int* cpos ) | 38 VarFilter* filt, RateAux* aux ) |
39 { | 39 { |
40 int out; | 40 int out; |
41 Sint16 *to; | 41 Sint16 *to; |
42 | 42 |
43 to = inp - length; | 43 to = inp - length; |
66 outp[CH(0)] = ( 32770 * inp[CH(0)] + out) >> 16; | 66 outp[CH(0)] = ( 32770 * inp[CH(0)] + out) >> 16; |
67 | 67 |
68 inp -= CH(1); | 68 inp -= CH(1); |
69 outp -= CH(2); | 69 outp -= CH(2); |
70 } | 70 } |
71 | |
71 return outp; | 72 return outp; |
72 } | 73 } |
73 #undef sum_d | 74 #undef sum_d |
74 | 75 |
75 /*-------------------------------------------------------------------------*/ | 76 /*-------------------------------------------------------------------------*/ |
76 #define sum_h(v,dx) ((int) v[CH(dx)] + v[CH(-dx)]) | 77 #define sum_h(v,dx) ((int) v[CH(dx)] + v[CH(-dx)]) |
77 static Sint16* Suffix(halfRate)( Sint16 *outp, Sint16 *inp, int length, | 78 static Sint16* Suffix(halfRate)( Sint16 *outp, Sint16 *inp, int length, |
78 VarFilter* filt, int* cpos ) | 79 VarFilter* filt, RateAux* aux ) |
79 { | 80 { |
80 int out; | 81 int out; |
81 Sint16* to; | 82 Sint16* to; |
82 | 83 |
83 to = inp + length; | 84 to = inp + length; |
85 inp += aux->carry; | |
84 | 86 |
85 while( inp < to ) | 87 while( inp < to ) |
86 { | 88 { |
87 out = 0; | 89 out = 0; |
88 out-= 9 * sum_h( inp, 31); | 90 out-= 9 * sum_h( inp, 31); |
103 out+= 20798 * sum_h( inp, 1); | 105 out+= 20798 * sum_h( inp, 1); |
104 out+= 32770 * (int)inp[0]; | 106 out+= 32770 * (int)inp[0]; |
105 | 107 |
106 outp[0] = out >> 16; | 108 outp[0] = out >> 16; |
107 | 109 |
108 inp+= CH(2); | 110 inp += CH(2); |
109 outp += CH(1); | 111 outp += CH(1); |
110 } | 112 } |
113 | |
114 aux->carry = inp < to + CH(1) ? 0 : CH(1); | |
111 return outp; | 115 return outp; |
112 } | 116 } |
113 #undef sum_h | 117 #undef sum_h |
114 | 118 |
115 /*-------------------------------------------------------------------------*/ | 119 /*-------------------------------------------------------------------------*/ |
116 static Sint16* Suffix(increaseRate)( Sint16 *outp, Sint16 *inp, int length, | 120 static Sint16* Suffix(increaseRate)( Sint16 *outp, Sint16 *inp, int length, |
117 VarFilter* filter, int* cpos ) | 121 VarFilter* filter, RateAux* aux ) |
118 { | 122 { |
119 const static int fsize = CH(2*_fsize); | 123 const static int fsize = CH(2*_fsize); |
120 Sint16 *f; | 124 Sint16 *f; |
121 int out; | 125 int out; |
122 int i, pos; | 126 int i, pos; |
123 Sint16* to; | 127 Sint16* to; |
124 | 128 |
125 inp -= fsize; | 129 inp -= fsize; |
126 to = inp - length; | 130 to = inp - length; |
127 pos = *cpos; | 131 pos = aux->pos; |
128 | 132 |
129 while( inp > to ) | 133 while( inp > to ) |
130 { | 134 { |
131 out = 0; | 135 out = 0; |
132 f = filter->c[pos]; | 136 f = filter->c[pos]; |
144 inp -= CH( 4 * _fsize ); | 148 inp -= CH( 4 * _fsize ); |
145 inp -= CH( filter->incr[pos] ); | 149 inp -= CH( filter->incr[pos] ); |
146 outp -= CH(1); | 150 outp -= CH(1); |
147 } | 151 } |
148 | 152 |
149 *cpos = pos; | 153 aux->pos = pos; |
150 return outp; | 154 return outp; |
151 } | 155 } |
152 | 156 |
153 /*-------------------------------------------------------------------------*/ | 157 /*-------------------------------------------------------------------------*/ |
154 static Sint16* Suffix(decreaseRate)( Sint16 *outp, Sint16 *inp, int length, | 158 static Sint16* Suffix(decreaseRate)( Sint16 *outp, Sint16 *inp, int length, |
155 VarFilter* filter, int* cpos ) | 159 VarFilter* filter, RateAux* aux ) |
156 { | 160 { |
157 const static int fsize = CH(2*_fsize); | 161 const static int fsize = CH(2*_fsize); |
158 Sint16 *f; | 162 Sint16 *f; |
159 int out; | 163 int out; |
160 int i, pos; | 164 int i, pos; |
161 Sint16 *to; | 165 Sint16 *to; |
162 | 166 |
163 inp -= fsize; | 167 inp -= fsize; |
164 to = inp + length; | 168 to = inp + length; |
165 pos = *cpos; | 169 pos = aux->pos; |
170 inp += aux->carry; | |
166 | 171 |
167 while( inp < to ) | 172 while( inp < to ) |
168 { | 173 { |
169 out = 0; | 174 out = 0; |
170 f = filter->c[pos]; | 175 f = filter->c[pos]; |
181 inp += CH( filter->incr[pos] ); | 186 inp += CH( filter->incr[pos] ); |
182 outp += CH(1); | 187 outp += CH(1); |
183 pos = ( pos + 1 ) % filter->ratio.denominator; | 188 pos = ( pos + 1 ) % filter->ratio.denominator; |
184 } | 189 } |
185 | 190 |
186 *cpos = pos; | 191 aux->pos = pos; |
192 aux->carry = inp < to + CH(1) ? 0 : CH(1); | |
187 return outp; | 193 return outp; |
188 } | 194 } |
189 | 195 |
190 /*-------------------------------------------------------------------------*/ | 196 /*-------------------------------------------------------------------------*/ |
191 #undef CH | 197 #undef CH |