[xiph-commits] r11311 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Fri Apr 28 22:02:33 PDT 2006


Author: jm
Date: 2006-04-28 22:02:29 -0700 (Fri, 28 Apr 2006)
New Revision: 11311

Modified:
   trunk/speex/libspeex/_kiss_fft_guts.h
   trunk/speex/libspeex/kiss_fft.h
   trunk/speex/libspeex/mdf.c
   trunk/speex/libspeex/pseudofloat.h
Log:
patch by Brian Retford to remove the weird struct manipulations


Modified: trunk/speex/libspeex/_kiss_fft_guts.h
===================================================================
--- trunk/speex/libspeex/_kiss_fft_guts.h	2006-04-29 04:40:50 UTC (rev 11310)
+++ trunk/speex/libspeex/_kiss_fft_guts.h	2006-04-29 05:02:29 UTC (rev 11311)
@@ -45,8 +45,9 @@
    C_ADDTO( res , a)    : res += a
  * */
 #ifdef FIXED_POINT
+#include "misc.h"
 # define FRACBITS 15
-# define SAMPPROD int32_t 
+# define SAMPPROD spx_int32_t 
 #define SAMP_MAX 32767
 
 #define SAMP_MIN -SAMP_MAX

Modified: trunk/speex/libspeex/kiss_fft.h
===================================================================
--- trunk/speex/libspeex/kiss_fft.h	2006-04-29 04:40:50 UTC (rev 11310)
+++ trunk/speex/libspeex/kiss_fft.h	2006-04-29 05:02:29 UTC (rev 11311)
@@ -34,8 +34,8 @@
 
 
 #ifdef FIXED_POINT
-#include <sys/types.h>	
-#  define kiss_fft_scalar int16_t
+#include "misc.h"	
+#  define kiss_fft_scalar spx_int16_t
 #else
 # ifndef kiss_fft_scalar
 /*  default is float */

Modified: trunk/speex/libspeex/mdf.c
===================================================================
--- trunk/speex/libspeex/mdf.c	2006-04-29 04:40:50 UTC (rev 11310)
+++ trunk/speex/libspeex/mdf.c	2006-04-29 05:02:29 UTC (rev 11311)
@@ -90,7 +90,7 @@
 #endif
 
 #ifdef FIXED_POINT
-static const spx_float_t MIN_LEAK = ((spx_float_t){16777, -24});
+static const spx_float_t MIN_LEAK = {16777, -24};
 #define TOP16(x) ((x)>>16)
 #else
 static const spx_float_t MIN_LEAK = .001f;

Modified: trunk/speex/libspeex/pseudofloat.h
===================================================================
--- trunk/speex/libspeex/pseudofloat.h	2006-04-29 04:40:50 UTC (rev 11310)
+++ trunk/speex/libspeex/pseudofloat.h	2006-04-29 05:02:29 UTC (rev 11311)
@@ -45,9 +45,9 @@
    spx_int16_t e;
 } spx_float_t;
 
-#define FLOAT_ZERO ((spx_float_t){0,0})
-#define FLOAT_ONE ((spx_float_t){16384,-14})
-#define FLOAT_HALF ((spx_float_t){16384,-15})
+static const spx_float_t FLOAT_ZERO = {0,0};
+static const spx_float_t FLOAT_ONE = {16384,-14};
+static const spx_float_t FLOAT_HALF = {16384,-15};
 
 #define MIN(a,b) ((a)<(b)?(a):(b))
 static inline spx_float_t PSEUDOFLOAT(spx_int32_t x)
@@ -60,7 +60,10 @@
       x = -x;
    }
    if (x==0)
-      return (spx_float_t) {0,0};
+   {
+      spx_float_t r = {0,0};
+      return r;
+   }
    while (x>32767)
    {
       x >>= 1;
@@ -74,9 +77,15 @@
       e--;
    }
    if (sign)
-      return (spx_float_t) {-x,e};
+   {
+      spx_float_t r = {-x,e};
+      return r;
+   }
    else      
-      return (spx_float_t) {x,e};
+   {
+      spx_float_t r = {x,e};
+      return r;
+   }
 }
 
 
@@ -87,7 +96,16 @@
       return b;
    else if (b.m==0)
       return a;
-   r = (a).e > (b).e ? (spx_float_t) {((a).m>>1) + ((b).m>>MIN(15,(a).e-(b).e+1)),(a).e+1} : (spx_float_t) {((b).m>>1) + ((a).m>>MIN(15,(b).e-(a).e+1)),(b).e+1};
+   if ((a).e > (b).e) 
+   {
+      r.m = ((a).m>>1) + ((b).m>>MIN(15,(a).e-(b).e+1));
+      r.e = (a).e+1;
+   }
+   else 
+   {
+      r.m = ((b).m>>1) + ((a).m>>MIN(15,(b).e-(a).e+1));
+      r.e = (b).e+1;
+   }
    if (r.m>0)
    {
       if (r.m<16384)
@@ -113,7 +131,16 @@
       return b;
    else if (b.m==0)
       return a;
-   r = (a).e > (b).e ? (spx_float_t) {((a).m>>1) - ((b).m>>MIN(15,(a).e-(b).e+1)),(a).e+1} : (spx_float_t) {((a).m>>MIN(15,(b).e-(a).e+1)) - ((b).m>>1) ,(b).e+1};
+   if ((a).e > (b).e)
+   {
+      r.m = ((a).m>>1) - ((b).m>>MIN(15,(a).e-(b).e+1));
+      r.e = (a).e+1;
+   }
+   else 
+   {
+      r.m = ((a).m>>MIN(15,(b).e-(a).e+1)) - ((b).m>>1);
+      r.e = (b).e+1;
+   }
    if (r.m>0)
    {
       if (r.m<16384)
@@ -152,7 +179,7 @@
 
 static inline spx_float_t FLOAT_MULT(spx_float_t a, spx_float_t b)
 {
-   spx_float_t r = (spx_float_t) {(spx_int16_t)((spx_int32_t)(a).m*(b).m>>15), (a).e+(b).e+15};
+   spx_float_t r = {(spx_int16_t)((spx_int32_t)(a).m*(b).m>>15), (a).e+(b).e+15};
    if (r.m>0)
    {
       if (r.m<16384)
@@ -174,7 +201,8 @@
 
 static inline spx_float_t FLOAT_SHL(spx_float_t a, int b)
 {
-   return (spx_float_t) {a.m,a.e+b};
+  spx_float_t r = {a.m,a.e+b};
+  return r;
 }
 
 static inline spx_int16_t FLOAT_EXTRACT16(spx_float_t a)
@@ -196,9 +224,12 @@
 static inline spx_float_t FLOAT_MUL32U(spx_word32_t a, spx_word32_t b)
 {
    int e=0;
+   spx_float_t r;
    /* FIXME: Handle the sign */
    if (a==0)
-      return (spx_float_t) {0,0};
+   {
+      return FLOAT_ZERO;
+   }
    while (a>32767)
    {
       a >>= 1;
@@ -219,15 +250,20 @@
       b <<= 1;
       e--;
    }
-   return (spx_float_t) {MULT16_16_Q15(a,b),e+15};
+   r.m = MULT16_16_Q15(a,b);
+   r.e = e+15;
+   return r;
 }
 
 static inline spx_float_t FLOAT_DIV32_FLOAT(spx_word32_t a, spx_float_t b)
 {
    int e=0;
+   spx_float_t r;
    /* FIXME: Handle the sign */
    if (a==0)
-      return (spx_float_t) {0,0};
+   {
+      return FLOAT_ZERO;
+   }
    while (a<SHL32(b.m,14))
    {
       a <<= 1;
@@ -238,16 +274,21 @@
       a >>= 1;
       e++;
    }
-   return (spx_float_t) {DIV32_16(a,b.m),e-b.e};
+   r.m = DIV32_16(a,b.m);
+   r.e = e-b.e;
+   return r;
 }
 
 
 static inline spx_float_t FLOAT_DIV32(spx_word32_t a, spx_word32_t b)
 {
    int e=0;
+   spx_float_t r;
    /* FIXME: Handle the sign */
    if (a==0)
-      return (spx_float_t) {0,0};
+   {
+      return FLOAT_ZERO;
+   }
    while (b>32767)
    {
       b >>= 1;
@@ -263,13 +304,16 @@
       a >>= 1;
       e++;
    }
-   return (spx_float_t) {DIV32_16(a,b),e};
+   r.m = DIV32_16(a,b);
+   r.e = e;
+   return r;
 }
 
 static inline spx_float_t FLOAT_DIVU(spx_float_t a, spx_float_t b)
 {
    int e=0;
    spx_int32_t num;
+   spx_float_t r;
    num = a.m;
    while (a.m >= b.m)
    {
@@ -277,7 +321,9 @@
       a.m >>= 1;
    }
    num = num << (15-e);
-   return (spx_float_t) {DIV32_16(num,b.m),a.e-b.e-15+e};
+   r.m = DIV32_16(num,b.m);
+   r.e = a.e-b.e-15+e;
+   return r;
 }
 
 #else



More information about the commits mailing list