comparison libao2/pl_resample.c @ 4725:534ef9323eca

MMX part rewritten and 16 tap filter added for better sound qualty
author anders
date Sat, 16 Feb 2002 13:08:14 +0000
parents 99dc749591e2
children c2bb05709676
comparison
equal deleted inserted replaced
4724:798fdbcef121 4725:534ef9323eca
38 38
39 #define min(a,b) (((a) < (b)) ? (a) : (b)) 39 #define min(a,b) (((a) < (b)) ? (a) : (b))
40 #define max(a,b) (((a) > (b)) ? (a) : (b)) 40 #define max(a,b) (((a) > (b)) ? (a) : (b))
41 41
42 /* Below definition selects the length of each poly phase component. 42 /* Below definition selects the length of each poly phase component.
43 Valid definitions are L4 and L8, where the number denotes the 43 Valid definitions are L8 and L16, where the number denotes the
44 length of the filter. This definition affects the computational 44 length of the filter. This definition affects the computational
45 complexity (see play()), the performance (see filter.h) and the 45 complexity (see play()), the performance (see filter.h) and the
46 memory usage. For now the filterlenght is choosen to 4 and without 46 memory usage. The filterlenght is choosen to 8 if the machine is
47 assembly optimization if no SSE is present. 47 slow and to 16 if the machine is fast and has MMX.
48 */ 48 */
49 49
50 // #ifdef HAVE_SSE 50 #if !defined(HAVE_SSE) && !defined(HAVE_3DNOW) //This machine is slow
51 #define L8 1 // Filter bank type 51 #define L8 1 // Filter bank type
52 #define W W8 // Filter bank parameters 52 #define W W8 // Filter bank parameters
53 #define L 8 // Filter length 53 #define L 8 // Filter length
54 // #else 54 #else // Fat machine
55 // #define L4 1 55 #define L16 1
56 // #define W W4 56 #define W W16
57 // #define L 4 57 #define L 16
58 // #endif 58 #endif
59 59
60 #define CH 6 // Max number of channels 60 #define CH 6 // Max number of channels
61 #define UP 128 /* Up sampling factor. Increasing this value will 61 #define UP 128 /* Up sampling factor. Increasing this value will
62 improve frequency accuracy. Think about the L1 62 improve frequency accuracy. Think about the L1
63 cashing of filter parameters - how big can it be? */ 63 cashing of filter parameters - how big can it be? */
186 register int16_t* out = pl_resample.data+ci; 186 register int16_t* out = pl_resample.data+ci;
187 int16_t* end = in+ao_plugin_data.len/2; // Block loop end 187 int16_t* end = in+ao_plugin_data.len/2; // Block loop end
188 188
189 wi = pwi; xi = pxi; 189 wi = pwi; xi = pxi;
190 190
191 LOAD_QUE(x);
192 while(in < end){ 191 while(in < end){
193 register uint16_t i = inc; 192 register uint16_t i = inc;
194 if(wi<level) i++; 193 if(wi<level) i++;
195 194
196 UPDATE_QUE(in); 195 UPDATE_QUE(in,x,xi);
197 in+=nch; 196 in+=nch;
198
199 while(i--){ 197 while(i--){
200 // Run the FIR filter 198 // Run the FIR filter
201 FIR((&x[xi]),(&w[wi*L]),out); 199 FIR((&x[xi]),(&w[wi*L]),out);
202 len++; out+=nch; 200 len++; out+=nch;
203 // Update wi to point at the correct polyphase component 201 // Update wi to point at the correct polyphase component
204 wi=(wi+dn)%up; 202 wi=(wi+dn)%up;
205 } 203 }
206 } 204 }
207 SAVE_QUE(x);
208 } 205 }
209 206
210 // Save values that needs to be kept for next time 207 // Save values that needs to be kept for next time
211 pwi = wi; 208 pwi = wi;
212 pxi = xi; 209 pxi = xi;
241 register int16_t* out = pl_resample.data+ci; 238 register int16_t* out = pl_resample.data+ci;
242 // Block loop end 239 // Block loop end
243 register int16_t* end = in+ao_plugin_data.len/2; 240 register int16_t* end = in+ao_plugin_data.len/2;
244 i = pi; wi = pwi; xi = pxi; 241 i = pi; wi = pwi; xi = pxi;
245 242
246 LOAD_QUE(x);
247 while(in < end){ 243 while(in < end){
248 244
249 UPDATE_QUE(in); 245 UPDATE_QUE(in,x,xi);
250 in+=nch; 246 in+=nch;
251 247
252 if(!--i){ 248 if(!--i){
253 // Run the FIR filter 249 // Run the FIR filter
254 FIR((&x[xi]),(&pl_resample.w[wi*L]),out); 250 FIR((&x[xi]),(&pl_resample.w[wi*L]),out);
260 // Insert i number of new samples in queue 256 // Insert i number of new samples in queue
261 i = inc; 257 i = inc;
262 if(wi<level) i++; 258 if(wi<level) i++;
263 } 259 }
264 } 260 }
265 SAVE_QUE(x);
266 } 261 }
267 // Save values that needs to be kept for next time 262 // Save values that needs to be kept for next time
268 pwi = wi; 263 pwi = wi;
269 pxi = xi; 264 pxi = xi;
270 pi = i; 265 pi = i;