[MPlayer-cvslog] r26382 - in trunk/libaf: dsp.h filter.c filter.h window.c window.h

diego subversion at mplayerhq.hu
Thu Apr 10 12:01:54 CEST 2008


Author: diego
Date: Thu Apr 10 12:01:54 2008
New Revision: 26382

Log:
Fix illegal identifier: Rename _ftype_t macro to FLOAT_TYPE.


Modified:
   trunk/libaf/dsp.h
   trunk/libaf/filter.c
   trunk/libaf/filter.h
   trunk/libaf/window.c
   trunk/libaf/window.h

Modified: trunk/libaf/dsp.h
==============================================================================
--- trunk/libaf/dsp.h	(original)
+++ trunk/libaf/dsp.h	Thu Apr 10 12:01:54 2008
@@ -14,7 +14,7 @@
 /* Implementation of routines used for DSP */
 
 /* Size of floating point type used in routines */
-#define _ftype_t float
+#define FLOAT_TYPE float
 
 #include "window.h"
 #include "filter.h"

Modified: trunk/libaf/filter.c
==============================================================================
--- trunk/libaf/filter.c	(original)
+++ trunk/libaf/filter.c	Thu Apr 10 12:01:54 2008
@@ -25,9 +25,10 @@
    w filter taps
    x input signal must be a circular buffer which is indexed backwards 
 */
-inline _ftype_t af_filter_fir(register unsigned int n, _ftype_t* w, _ftype_t* x)
+inline FLOAT_TYPE af_filter_fir(register unsigned int n, FLOAT_TYPE* w,
+                                FLOAT_TYPE* x)
 {
-  register _ftype_t y; // Output
+  register FLOAT_TYPE y; // Output
   y = 0.0; 
   do{
     n--;
@@ -46,10 +47,12 @@ inline _ftype_t af_filter_fir(register u
    y  output buffer
    s  output buffer stride
 */
-_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)
+FLOAT_TYPE* af_filter_pfir(unsigned int n, unsigned int d, unsigned int xi,
+                           FLOAT_TYPE** w, FLOAT_TYPE** x, FLOAT_TYPE* y,
+                           unsigned int s)
 {
-  register _ftype_t* xt = *x + xi;
-  register _ftype_t* wt = *w;
+  register FLOAT_TYPE* xt = *x + xi;
+  register FLOAT_TYPE* wt = *w;
   register int    nt = 2*n;
   while(d-- > 0){
     *y = af_filter_fir(n,wt,xt);
@@ -65,9 +68,10 @@ _ftype_t* af_filter_pfir(unsigned int n,
    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.
 */
-int af_filter_updatepq(unsigned int n, unsigned int d, unsigned int xi, _ftype_t** xq, _ftype_t* in, unsigned int s)
+int af_filter_updatepq(unsigned int n, unsigned int d, unsigned int xi,
+                       FLOAT_TYPE** xq, FLOAT_TYPE* in, unsigned int s)
 {
-  register _ftype_t* txq = *xq + xi;
+  register FLOAT_TYPE* txq = *xq + xi;
   register int nt = n*2;
   
   while(d-- >0){
@@ -95,18 +99,19 @@ int af_filter_updatepq(unsigned int n, u
    
    returns 0 if OK, -1 if fail
 */
-int af_filter_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, FLOAT_TYPE* w, FLOAT_TYPE* fc,
+                         unsigned int flags, FLOAT_TYPE opt)
 {
   unsigned int	o   = n & 1;          	// Indicator for odd filter length
   unsigned int	end = ((n + 1) >> 1) - o;       // Loop end
   unsigned int	i;			// Loop index
 
-  _ftype_t k1 = 2 * M_PI;		// 2*pi*fc1
-  _ftype_t k2 = 0.5 * (_ftype_t)(1 - o);// Constant used if the filter has even length
-  _ftype_t k3;				// 2*pi*fc2 Constant used in BP and BS design
-  _ftype_t g  = 0.0;     		// Gain
-  _ftype_t t1,t2,t3;     		// Temporary variables
-  _ftype_t fc1,fc2;			// Cutoff frequencies
+  FLOAT_TYPE k1 = 2 * M_PI;		// 2*pi*fc1
+  FLOAT_TYPE k2 = 0.5 * (FLOAT_TYPE)(1 - o);// Constant used if the filter has even length
+  FLOAT_TYPE k3;		        // 2*pi*fc2 Constant used in BP and BS design
+  FLOAT_TYPE g  = 0.0;     		// Gain
+  FLOAT_TYPE t1,t2,t3;     		// Temporary variables
+  FLOAT_TYPE fc1,fc2;			// Cutoff frequencies
 
   // Sanity check
   if(!w || (n == 0)) return -1;
@@ -150,7 +155,7 @@ int af_filter_design_fir(unsigned int n,
 
       // Create filter
       for (i=0 ; i<end ; i++){
-	t1 = (_ftype_t)(i+1) - k2;
+	t1 = (FLOAT_TYPE)(i+1) - k2;
 	w[end-i-1] = w[n-end+i] = w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
 	g += 2*w[end-i-1]; // Total gain in filter
       }
@@ -163,7 +168,7 @@ int af_filter_design_fir(unsigned int n,
 
       // Create filter
       for (i=0 ; i<end ; i++){
-	t1 = (_ftype_t)(i+1);
+	t1 = (FLOAT_TYPE)(i+1);
 	w[end-i-1] = w[n-end+i] = -1 * w[end-i-1] * sin(k1 * t1)/(M_PI * t1); // Sinc
 	g += ((i&1) ? (2*w[end-i-1]) : (-2*w[end-i-1])); // Total gain in filter
       }
@@ -188,7 +193,7 @@ int af_filter_design_fir(unsigned int n,
 
       // Create filter
       for (i=0 ; i<end ; i++){
-	t1 = (_ftype_t)(i+1) - k2;
+	t1 = (FLOAT_TYPE)(i+1) - k2;
 	t2 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
 	t3 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
 	g += w[end-i-1] * (t3 + t2);   // Total gain in filter
@@ -203,7 +208,7 @@ int af_filter_design_fir(unsigned int n,
 
       // Create filter
       for (i=0 ; i<end ; i++){
-	t1 = (_ftype_t)(i+1);
+	t1 = (FLOAT_TYPE)(i+1);
 	t2 = sin(k1 * t1)/(M_PI * t1); // Sinc fc1
 	t3 = sin(k3 * t1)/(M_PI * t1); // Sinc fc2
 	w[end-i-1] = w[n-end+i] = w[end-i-1] * (t2 - t3); 
@@ -233,12 +238,13 @@ int af_filter_design_fir(unsigned int n,
 
    returns 0 if OK, -1 if fail
 */
-int af_filter_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, FLOAT_TYPE* w,
+                          FLOAT_TYPE** pw, FLOAT_TYPE g, unsigned int flags)
 {
   int l = (int)n/k;	// Length of individual FIR filters
   int i;     	// Counters
   int j;
-  _ftype_t t;	// g * w[i]
+  FLOAT_TYPE t;	// g * w[i]
   
   // Sanity check
   if(l<1 || k<1 || !w || !pw)
@@ -274,9 +280,9 @@ int af_filter_design_pfir(unsigned int n
    Note that a0 is assumed to be 1, so there is no wrapping
    of it.  
 */
-static void af_filter_prewarp(_ftype_t* a, _ftype_t fc, _ftype_t fs)
+static void af_filter_prewarp(FLOAT_TYPE* a, FLOAT_TYPE fc, FLOAT_TYPE fs)
 {
-  _ftype_t wp;
+  FLOAT_TYPE wp;
   wp = 2.0 * fs * tan(M_PI * fc / fs);
   a[2] = a[2]/(wp * wp);
   a[1] = a[1]/wp;
@@ -310,9 +316,10 @@ static void af_filter_prewarp(_ftype_t* 
    Return: On return, set coef z-domain coefficients and k to the gain
    required to maintain overall gain = 1.0;
 */
-static void af_filter_bilinear(_ftype_t* a, _ftype_t* b, _ftype_t* k, _ftype_t fs, _ftype_t *coef)
+static void af_filter_bilinear(FLOAT_TYPE* a, FLOAT_TYPE* b, FLOAT_TYPE* k,
+                               FLOAT_TYPE fs, FLOAT_TYPE *coef)
 {
-  _ftype_t ad, bd;
+  FLOAT_TYPE ad, bd;
 
   /* alpha (Numerator in s-domain) */
   ad = 4. * a[2] * fs * fs + 2. * a[1] * fs + a[0];
@@ -410,16 +417,17 @@ static void af_filter_bilinear(_ftype_t*
 
    return -1 if fail 0 if success.
 */
-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)
+int af_filter_szxform(FLOAT_TYPE* a, FLOAT_TYPE* b, FLOAT_TYPE Q, FLOAT_TYPE fc,
+                      FLOAT_TYPE fs, FLOAT_TYPE *k, FLOAT_TYPE *coef)
 {
-  _ftype_t at[3];
-  _ftype_t bt[3];
+  FLOAT_TYPE at[3];
+  FLOAT_TYPE bt[3];
 
   if(!a || !b || !k || !coef || (Q>1000.0 || Q< 1.0)) 
     return -1;
 
-  memcpy(at,a,3*sizeof(_ftype_t));
-  memcpy(bt,b,3*sizeof(_ftype_t));
+  memcpy(at,a,3*sizeof(FLOAT_TYPE));
+  memcpy(bt,b,3*sizeof(FLOAT_TYPE));
 
   bt[1]/=Q;
 

Modified: trunk/libaf/filter.h
==============================================================================
--- trunk/libaf/filter.h	(original)
+++ trunk/libaf/filter.h	Thu Apr 10 12:01:54 2008
@@ -44,18 +44,28 @@
 #define ODD         0x00000010 // Make filter HP
 
 // Exported functions
-extern _ftype_t af_filter_fir(unsigned int n, _ftype_t* w, _ftype_t* x);
+extern FLOAT_TYPE af_filter_fir(unsigned int n, FLOAT_TYPE* w, FLOAT_TYPE* x);
 
-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 FLOAT_TYPE* af_filter_pfir(unsigned int n, unsigned int k,
+                                  unsigned int xi, FLOAT_TYPE** w,
+                                  FLOAT_TYPE** x, FLOAT_TYPE* y,
+                                  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 af_filter_updateq(unsigned int n, unsigned int xi,
+//                             FLOAT_TYPE* xq, FLOAT_TYPE* in);
+extern int af_filter_updatepq(unsigned int n, unsigned int k, unsigned int xi,
+                              FLOAT_TYPE** xq, FLOAT_TYPE* in, unsigned int s);
 
-extern int af_filter_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, FLOAT_TYPE* w, FLOAT_TYPE* fc,
+                                unsigned int flags, FLOAT_TYPE opt);
 
-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 af_filter_design_pfir(unsigned int n, unsigned int k, FLOAT_TYPE* w,
+                                 FLOAT_TYPE** pw, FLOAT_TYPE g,
+                                 unsigned int flags);
 
-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);
+extern int af_filter_szxform(FLOAT_TYPE* a, FLOAT_TYPE* b, FLOAT_TYPE Q,
+                             FLOAT_TYPE fc, FLOAT_TYPE fs, FLOAT_TYPE *k,
+                             FLOAT_TYPE *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

Modified: trunk/libaf/window.c
==============================================================================
--- trunk/libaf/window.c	(original)
+++ trunk/libaf/window.c	Thu Apr 10 12:01:54 2008
@@ -24,7 +24,7 @@
 // n window length
 // w buffer for the window parameters
 */
-void af_window_boxcar(int n, _ftype_t* w)
+void af_window_boxcar(int n, FLOAT_TYPE* w)
 {
   int i;
   // Calculate window coefficients
@@ -44,16 +44,16 @@ void af_window_boxcar(int n, _ftype_t* w
 // n window length
 // w buffer for the window parameters
 */
-void af_window_triang(int n, _ftype_t* w)
+void af_window_triang(int n, FLOAT_TYPE* w)
 {
-  _ftype_t k1  = (_ftype_t)(n & 1);
-  _ftype_t k2  = 1/((_ftype_t)n + k1);
+  FLOAT_TYPE k1  = (FLOAT_TYPE)(n & 1);
+  FLOAT_TYPE k2  = 1/((FLOAT_TYPE)n + k1);
   int      end = (n + 1) >> 1;
   int	   i;
   
   // Calculate window coefficients
   for (i=0 ; i<end ; i++)
-    w[i] = w[n-i-1] = (2.0*((_ftype_t)(i+1))-(1.0-k1))*k2;
+    w[i] = w[n-i-1] = (2.0*((FLOAT_TYPE)(i+1))-(1.0-k1))*k2;
 }
 
 
@@ -65,14 +65,14 @@ void af_window_triang(int n, _ftype_t* w
 // n window length
 // w buffer for the window parameters
 */
-void af_window_hanning(int n, _ftype_t* w)
+void af_window_hanning(int n, FLOAT_TYPE* w)
 {
   int	   i;
-  _ftype_t k = 2*M_PI/((_ftype_t)(n+1)); // 2*pi/(N+1)
+  FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n+1)); // 2*pi/(N+1)
   
   // Calculate window coefficients
   for (i=0; i<n; i++)
-    *w++ = 0.5*(1.0 - cos(k*(_ftype_t)(i+1)));
+    *w++ = 0.5*(1.0 - cos(k*(FLOAT_TYPE)(i+1)));
 }
 
 /*
@@ -84,14 +84,14 @@ void af_window_hanning(int n, _ftype_t* 
 // n window length
 // w buffer for the window parameters
 */
-void af_window_hamming(int n,_ftype_t* w)
+void af_window_hamming(int n,FLOAT_TYPE* w)
 {
   int      i;
-  _ftype_t k = 2*M_PI/((_ftype_t)(n-1)); // 2*pi/(N-1)
+  FLOAT_TYPE k = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
 
   // Calculate window coefficients
   for (i=0; i<n; i++)
-    *w++ = 0.54 - 0.46*cos(k*(_ftype_t)i);
+    *w++ = 0.54 - 0.46*cos(k*(FLOAT_TYPE)i);
 }
 
 /*
@@ -103,15 +103,15 @@ void af_window_hamming(int n,_ftype_t* w
 // n window length
 // w buffer for the window parameters
 */
-void af_window_blackman(int n,_ftype_t* w)
+void af_window_blackman(int n,FLOAT_TYPE* w)
 {
   int      i;
-  _ftype_t k1 = 2*M_PI/((_ftype_t)(n-1)); // 2*pi/(N-1)
-  _ftype_t k2 = 2*k1; // 4*pi/(N-1)
+  FLOAT_TYPE k1 = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
+  FLOAT_TYPE k2 = 2*k1; // 4*pi/(N-1)
 
   // Calculate window coefficients
   for (i=0; i<n; i++)
-    *w++ = 0.42 - 0.50*cos(k1*(_ftype_t)i) + 0.08*cos(k2*(_ftype_t)i);
+    *w++ = 0.42 - 0.50*cos(k1*(FLOAT_TYPE)i) + 0.08*cos(k2*(FLOAT_TYPE)i);
 }
 
 /*
@@ -123,15 +123,16 @@ void af_window_blackman(int n,_ftype_t* 
 // n window length
 // w buffer for the window parameters
 */
-void af_window_flattop(int n,_ftype_t* w)
+void af_window_flattop(int n,FLOAT_TYPE* w)
 {
   int      i;
-  _ftype_t k1 = 2*M_PI/((_ftype_t)(n-1)); // 2*pi/(N-1)
-  _ftype_t k2 = 2*k1;                   // 4*pi/(N-1)
+  FLOAT_TYPE k1 = 2*M_PI/((FLOAT_TYPE)(n-1)); // 2*pi/(N-1)
+  FLOAT_TYPE k2 = 2*k1;                   // 4*pi/(N-1)
   
   // Calculate window coefficients
   for (i=0; i<n; i++)
-    *w++ = 0.2810638602 - 0.5208971735*cos(k1*(_ftype_t)i) + 0.1980389663*cos(k2*(_ftype_t)i);
+    *w++ = 0.2810638602 - 0.5208971735*cos(k1*(FLOAT_TYPE)i)
+                        + 0.1980389663*cos(k2*(FLOAT_TYPE)i);
 }
 
 /* Computes the 0th order modified Bessel function of the first kind.  
@@ -142,16 +143,16 @@ void af_window_flattop(int n,_ftype_t* w
 */
 #define BIZ_EPSILON 1E-21 // Max error acceptable 
 
-static _ftype_t besselizero(_ftype_t x)
+static FLOAT_TYPE besselizero(FLOAT_TYPE x)
 { 
-  _ftype_t temp;
-  _ftype_t sum   = 1.0;
-  _ftype_t u     = 1.0;
-  _ftype_t halfx = x/2.0;
+  FLOAT_TYPE temp;
+  FLOAT_TYPE sum   = 1.0;
+  FLOAT_TYPE u     = 1.0;
+  FLOAT_TYPE halfx = x/2.0;
   int      n     = 1;
 
   do {
-    temp = halfx/(_ftype_t)n;
+    temp = halfx/(FLOAT_TYPE)n;
     u *=temp * temp;
     sum += u;
     n++;
@@ -186,17 +187,17 @@ static _ftype_t besselizero(_ftype_t x)
 // 8.960   5.7     0.000275  -90
 // 10.056  6.4     0.000087  -100
 */
-void af_window_kaiser(int n, _ftype_t* w, _ftype_t b)
+void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b)
 {
-  _ftype_t tmp;
-  _ftype_t k1  = 1.0/besselizero(b);
+  FLOAT_TYPE tmp;
+  FLOAT_TYPE k1  = 1.0/besselizero(b);
   int	   k2  = 1 - (n & 1);
   int      end = (n + 1) >> 1;
   int      i; 
   
   // Calculate window coefficients
   for (i=0 ; i<end ; i++){
-    tmp = (_ftype_t)(2*i + k2) / ((_ftype_t)n - 1.0);
+    tmp = (FLOAT_TYPE)(2*i + k2) / ((FLOAT_TYPE)n - 1.0);
     w[end-(1&(!k2))+i] = w[end-1-i] = k1 * besselizero(b*sqrt(1.0 - tmp*tmp));
   }
 }

Modified: trunk/libaf/window.h
==============================================================================
--- trunk/libaf/window.h	(original)
+++ trunk/libaf/window.h	Thu Apr 10 12:01:54 2008
@@ -22,12 +22,12 @@
 #ifndef MPLAYER_WINDOW_H
 #define MPLAYER_WINDOW_H
 
-extern void af_window_boxcar(int n, _ftype_t* w);
-extern void af_window_triang(int n, _ftype_t* w);
-extern void af_window_hanning(int n, _ftype_t* w);
-extern void af_window_hamming(int n,_ftype_t* w);
-extern void af_window_blackman(int n,_ftype_t* w);
-extern void af_window_flattop(int n,_ftype_t* w);
-extern void af_window_kaiser(int n, _ftype_t* w,_ftype_t b);
+extern void af_window_boxcar(int n, FLOAT_TYPE* w);
+extern void af_window_triang(int n, FLOAT_TYPE* w);
+extern void af_window_hanning(int n, FLOAT_TYPE* w);
+extern void af_window_hamming(int n, FLOAT_TYPE* w);
+extern void af_window_blackman(int n, FLOAT_TYPE* w);
+extern void af_window_flattop(int n, FLOAT_TYPE* w);
+extern void af_window_kaiser(int n, FLOAT_TYPE* w, FLOAT_TYPE b);
 
 #endif /* MPLAYER_WINDOW_H */



More information about the MPlayer-cvslog mailing list