comparison libaf/af_resample.c @ 24889:4055d43fc406

libaf: Remove rational number implementation Remove the mul/cancel/gcd functions and some related code. Use ff_gcd instead of the removed af_gcd in af_resample.c.
author uau
date Thu, 01 Nov 2007 06:52:06 +0000
parents b2402b4f0afa
children 9079c9745ff9
comparison
equal deleted inserted replaced
24888:b2402b4f0afa 24889:4055d43fc406
11 /* This audio filter changes the sample rate. */ 11 /* This audio filter changes the sample rate. */
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <stdlib.h> 13 #include <stdlib.h>
14 #include <inttypes.h> 14 #include <inttypes.h>
15 15
16 #include "libavutil/common.h"
16 #include "af.h" 17 #include "af.h"
17 #include "dsp.h" 18 #include "dsp.h"
18 19
19 /* Below definition selects the length of each poly phase component. 20 /* Below definition selects the length of each poly phase component.
20 Valid definitions are L8 and L16, where the number denotes the 21 Valid definitions are L8 and L16, where the number denotes the
187 af->mul = (double)af->data->rate / n->rate; 188 af->mul = (double)af->data->rate / n->rate;
188 return rv; 189 return rv;
189 } 190 }
190 191
191 // Calculate up and down sampling factors 192 // Calculate up and down sampling factors
192 d=af_gcd(af->data->rate,n->rate); 193 d=ff_gcd(af->data->rate,n->rate);
193 194
194 // If sloppy resampling is enabled limit the upsampling factor 195 // If sloppy resampling is enabled limit the upsampling factor
195 if(((s->setup & FREQ_MASK) == FREQ_SLOPPY) && (af->data->rate/d > 5000)){ 196 if(((s->setup & FREQ_MASK) == FREQ_SLOPPY) && (af->data->rate/d > 5000)){
196 int up=af->data->rate/2; 197 int up=af->data->rate/2;
197 int dn=n->rate/2; 198 int dn=n->rate/2;
198 int m=2; 199 int m=2;
199 while(af->data->rate/(d*m) > 5000){ 200 while(af->data->rate/(d*m) > 5000){
200 d=af_gcd(up,dn); 201 d=ff_gcd(up,dn);
201 up/=2; dn/=2; m*=2; 202 up/=2; dn/=2; m*=2;
202 } 203 }
203 d*=m; 204 d*=m;
204 } 205 }
205 206