changeset 14275:de13fd557440

less namespace pollution #2 (prefixed globals in filter.c with af_filter_)
author alex
date Wed, 29 Dec 2004 19:50:44 +0000
parents 012426ca576b
children fa80ed52127b
files libaf/af_hrtf.c libaf/af_resample.c libaf/af_sub.c libaf/af_surround.c libaf/filter.c libaf/filter.h
diffstat 6 files changed, 28 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_hrtf.c	Wed Dec 29 19:41:21 2004 +0000
+++ b/libaf/af_hrtf.c	Wed Dec 29 19:50:44 2004 +0000
@@ -49,10 +49,10 @@
     int k = offset >= 0 ? offset % nx : nx + (offset % nx);
 
     if(nk + k <= nx)
-	return fir(nk, sx + k, sk);
+	return af_filter_fir(nk, sx + k, sk);
     else
-	return fir(nk + k - nx, sx, sk + nx - k) +
-	    fir(nx - k, sx + k, sk);
+	return af_filter_fir(nk + k - nx, sx, sk + nx - k) +
+	    af_filter_fir(nx - k, sx + k, sk);
 }
 
 /* Detect when the impulse response starts (significantly) */
@@ -392,7 +392,7 @@
 	return AF_ERROR;
     }
     fc = 2.0 * BASSFILTFREQ / (float)af->data->rate;
-    if(design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) ==
+    if(af_filter_design_fir(s->basslen, s->ba_ir, &fc, LP | KAISER, 4 * M_PI) ==
        -1) {
 	af_msg(AF_MSG_ERROR, "[hrtf] Unable to design low-pass "
 	       "filter.\n");
--- a/libaf/af_resample.c	Wed Dec 29 19:41:21 2004 +0000
+++ b/libaf/af_resample.c	Wed Dec 29 19:50:44 2004 +0000
@@ -245,7 +245,7 @@
 
       // Design prototype filter type using Kaiser window with beta = 10
       if(NULL == w || NULL == s->w || 
-	 -1 == design_fir(s->up*L, w, &fc, LP|KAISER , 10.0)){
+	 -1 == af_filter_design_fir(s->up*L, w, &fc, LP|KAISER , 10.0)){
 	af_msg(AF_MSG_ERROR,"[resample] Unable to design prototype filter.\n");
 	return AF_ERROR;
       }
--- a/libaf/af_sub.c	Wed Dec 29 19:41:21 2004 +0000
+++ b/libaf/af_sub.c	Wed Dec 29 19:50:44 2004 +0000
@@ -66,9 +66,9 @@
 
     // Design low-pass filter
     s->k = 1.0;
-    if((-1 == szxform(sp[0].a, sp[0].b, Q, s->fc,
+    if((-1 == af_filter_szxform(sp[0].a, sp[0].b, Q, s->fc,
        (float)af->data->rate, &s->k, s->w[0])) ||
-       (-1 == szxform(sp[1].a, sp[1].b, Q, s->fc,
+       (-1 == af_filter_szxform(sp[1].a, sp[1].b, Q, s->fc,
        (float)af->data->rate, &s->k, s->w[1])))
       return AF_ERROR;
     return af_test_output(af,(af_data_t*)arg);
--- a/libaf/af_surround.c	Wed Dec 29 19:41:21 2004 +0000
+++ b/libaf/af_surround.c	Wed Dec 29 19:50:44 2004 +0000
@@ -102,7 +102,7 @@
     }
     // Surround filer coefficients
     fc = 2.0 * 7000.0/(float)af->data->rate;
-    if (-1 == design_fir(L, s->w, &fc, LP|HAMMING, 0)){
+    if (-1 == af_filter_design_fir(L, s->w, &fc, LP|HAMMING, 0)){
       af_msg(AF_MSG_ERROR,"[surround] Unable to design low-pass filter.\n");
       return AF_ERROR;
     }
--- a/libaf/filter.c	Wed Dec 29 19:41:21 2004 +0000
+++ b/libaf/filter.c	Wed Dec 29 19:50:44 2004 +0000
@@ -25,7 +25,7 @@
    w filter taps
    x input signal must be a circular buffer which is indexed backwards 
 */
-inline _ftype_t fir(register unsigned int n, _ftype_t* w, _ftype_t* x)
+inline _ftype_t af_filter_fir(register unsigned int n, _ftype_t* w, _ftype_t* x)
 {
   register _ftype_t y; // Output
   y = 0.0; 
@@ -46,13 +46,13 @@
    y  output buffer
    s  output buffer stride
 */
-inline _ftype_t* pfir(unsigned int n, unsigned int d, unsigned int xi, _ftype_t** w, _ftype_t** x, _ftype_t* y, unsigned int s)
+inline _ftype_t* af_filter_pfir(unsigned int n, unsigned int d, unsigned int xi, _ftype_t** w, _ftype_t** x, _ftype_t* y, unsigned int s)
 {
   register _ftype_t* xt = *x + xi;
   register _ftype_t* wt = *w;
   register int    nt = 2*n;
   while(d-- > 0){
-    *y = fir(n,wt,xt);
+    *y = af_filter_fir(n,wt,xt);
     wt+=n;
     xt+=nt;
     y+=s;
@@ -65,7 +65,7 @@
    at the new samples, xi current index in xq and n the length of the
    filter. xq must be n*2 by k big, s is the index for in.
 */
-inline int updatepq(unsigned int n, unsigned int d, unsigned int xi, _ftype_t** xq, _ftype_t* in, unsigned int s)  
+inline int af_filter_updatepq(unsigned int n, unsigned int d, unsigned int xi, _ftype_t** xq, _ftype_t* in, unsigned int s)  
 {
   register _ftype_t* txq = *xq + xi;
   register int nt = n*2;
@@ -95,7 +95,7 @@
    
    returns 0 if OK, -1 if fail
 */
-int design_fir(unsigned int n, _ftype_t* w, _ftype_t* fc, unsigned int flags, _ftype_t opt)
+int af_filter_design_fir(unsigned int n, _ftype_t* w, _ftype_t* fc, unsigned int flags, _ftype_t opt)
 {
   unsigned int	o   = n & 1;          	// Indicator for odd filter length
   unsigned int	end = ((n + 1) >> 1) - o;       // Loop end
@@ -233,7 +233,7 @@
 
    returns 0 if OK, -1 if fail
 */
-int design_pfir(unsigned int n, unsigned int k, _ftype_t* w, _ftype_t** pw, _ftype_t g, unsigned int flags)
+int af_filter_design_pfir(unsigned int n, unsigned int k, _ftype_t* w, _ftype_t** pw, _ftype_t g, unsigned int flags)
 {
   int l = (int)n/k;	// Length of individual FIR filters
   int i;     	// Counters
@@ -274,7 +274,7 @@
    Note that a0 is assumed to be 1, so there is no wrapping
    of it.  
 */
-void prewarp(_ftype_t* a, _ftype_t fc, _ftype_t fs)
+void af_filter_prewarp(_ftype_t* a, _ftype_t fc, _ftype_t fs)
 {
   _ftype_t wp;
   wp = 2.0 * fs * tan(M_PI * fc / fs);
@@ -310,7 +310,7 @@
    Return: On return, set coef z-domain coefficients and k to the gain
    required to maintain overall gain = 1.0;
 */
-void bilinear(_ftype_t* a, _ftype_t* b, _ftype_t* k, _ftype_t fs, _ftype_t *coef)
+void af_filter_bilinear(_ftype_t* a, _ftype_t* b, _ftype_t* k, _ftype_t fs, _ftype_t *coef)
 {
   _ftype_t ad, bd;
 
@@ -410,7 +410,7 @@
 
    return -1 if fail 0 if success.
 */
-int szxform(_ftype_t* a, _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef)
+int af_filter_szxform(_ftype_t* a, _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef)
 {
   _ftype_t at[3];
   _ftype_t bt[3];
@@ -424,10 +424,10 @@
   bt[1]/=Q;
 
   /* Calculate a and b and overwrite the original values */
-  prewarp(at, fc, fs);
-  prewarp(bt, fc, fs);
+  af_filter_prewarp(at, fc, fs);
+  af_filter_prewarp(bt, fc, fs);
   /* Execute bilinear transform */
-  bilinear(at, bt, k, fs, coef);
+  af_filter_bilinear(at, bt, k, fs, coef);
 
   return 0;
 }
--- a/libaf/filter.h	Wed Dec 29 19:41:21 2004 +0000
+++ b/libaf/filter.h	Wed Dec 29 19:50:44 2004 +0000
@@ -44,25 +44,25 @@
 #define ODD         0x00000010 // Make filter HP
 
 // Exported functions
-extern _ftype_t fir(unsigned int n, _ftype_t* w, _ftype_t* x);
+extern _ftype_t af_filter_fir(unsigned int n, _ftype_t* w, _ftype_t* x);
 
-extern _ftype_t* pfir(unsigned int n, unsigned int k, unsigned int xi, _ftype_t** w, _ftype_t** x, _ftype_t* y, unsigned int s);
+extern _ftype_t* af_filter_pfir(unsigned int n, unsigned int k, unsigned int xi, _ftype_t** w, _ftype_t** x, _ftype_t* y, unsigned int s);
 
-extern int updateq(unsigned int n, unsigned int xi, _ftype_t* xq, _ftype_t* in);
-extern int updatepq(unsigned int n, unsigned int k, unsigned int xi, _ftype_t** xq, _ftype_t* in, unsigned int s);
+//extern int af_filter_updateq(unsigned int n, unsigned int xi, _ftype_t* xq, _ftype_t* in);
+extern int af_filter_updatepq(unsigned int n, unsigned int k, unsigned int xi, _ftype_t** xq, _ftype_t* in, unsigned int s);
 
-extern int design_fir(unsigned int n, _ftype_t* w, _ftype_t* fc, unsigned int flags, _ftype_t opt);
+extern int af_filter_design_fir(unsigned int n, _ftype_t* w, _ftype_t* fc, unsigned int flags, _ftype_t opt);
 
-extern int design_pfir(unsigned int n, unsigned int k, _ftype_t* w, _ftype_t** pw, _ftype_t g, unsigned int flags);
+extern int af_filter_design_pfir(unsigned int n, unsigned int k, _ftype_t* w, _ftype_t** pw, _ftype_t g, unsigned int flags);
 
-extern int szxform(_ftype_t* a, _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef);
+extern int af_filter_szxform(_ftype_t* a, _ftype_t* b, _ftype_t Q, _ftype_t fc, _ftype_t fs, _ftype_t *k, _ftype_t *coef);
 
 /* Add new data to circular queue designed to be used with a FIR
    filter. xq is the circular queue, in pointing at the new sample, xi
    current index for xq and n the length of the filter. xq must be n*2
    long. 
 */
-#define updateq(n,xi,xq,in)\
+#define af_filter_updateq(n,xi,xq,in)\
   xq[xi]=(xq)[(xi)+(n)]=*(in);\
   xi=(++(xi))&((n)-1);