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

jm at motherfish-iii.xiph.org jm at motherfish-iii.xiph.org
Mon Jun 6 23:56:26 PDT 2005


Author: jm
Date: 2005-06-06 23:56:21 -0700 (Mon, 06 Jun 2005)
New Revision: 9384

Modified:
   trunk/speex/libspeex/arch.h
   trunk/speex/libspeex/fixed_bfin.h
   trunk/speex/libspeex/fixed_generic.h
   trunk/speex/libspeex/ltp.c
Log:
Added MAX16 operator


Modified: trunk/speex/libspeex/arch.h
===================================================================
--- trunk/speex/libspeex/arch.h	2005-06-07 04:58:41 UTC (rev 9383)
+++ trunk/speex/libspeex/arch.h	2005-06-07 06:56:21 UTC (rev 9384)
@@ -38,6 +38,9 @@
 #include "speex/speex_types.h"
 
 #define ABS(x) ((x) < 0 ? (-(x)) : (x))
+#define ABS16(x) ((x) < 0 ? (-(x)) : (x))
+#define MAX16(a,b) ((a) > (b) ? (a) : (b))
+#define ABS32(x) ((x) < 0 ? (-(x)) : (x))
 
 #ifdef FIXED_POINT
 

Modified: trunk/speex/libspeex/fixed_bfin.h
===================================================================
--- trunk/speex/libspeex/fixed_bfin.h	2005-06-07 04:58:41 UTC (rev 9383)
+++ trunk/speex/libspeex/fixed_bfin.h	2005-06-07 06:56:21 UTC (rev 9384)
@@ -59,6 +59,20 @@
    return res;
 }
 
+#undef MAX16
+static inline spx_word16_t MAX16(spx_word16_t a, spx_word16_t b)
+{
+   spx_word32_t res;
+   __asm__  (
+         "%1 = %1.L (X);\n\t"
+         "%2 = %2.L (X);\n\t"
+         "%0 = MAX(%1,%2);"
+   : "=d" (res)
+   : "%d" (a), "d" (b)
+   );
+   return res;
+}
+
 #undef MULT16_32_Q15
 static inline spx_word32_t MULT16_32_Q15(spx_word16_t a, spx_word32_t b)
 {

Modified: trunk/speex/libspeex/fixed_generic.h
===================================================================
--- trunk/speex/libspeex/fixed_generic.h	2005-06-07 04:58:41 UTC (rev 9383)
+++ trunk/speex/libspeex/fixed_generic.h	2005-06-07 06:56:21 UTC (rev 9384)
@@ -53,10 +53,6 @@
 #define PSHR(a,shift) (SHR((a)+(1<<((shift)-1)),shift))
 #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
-static inline spx_word32_t slow_saturate(spx_word32_t x, spx_word16_t a)
-{
-  return (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)));
-}
 
 #define ADD16(a,b) ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))
 #define SUB16(a,b) ((spx_word16_t)(a)-(spx_word16_t)(b))

Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c	2005-06-07 04:58:41 UTC (rev 9383)
+++ trunk/speex/libspeex/ltp.c	2005-06-07 06:56:21 UTC (rev 9384)
@@ -490,11 +490,7 @@
          g[2]=ADD16((spx_word16_t)ptr[2],32);
 
          /* We favor "safe" pitch values to handle packet loss better */
-         gain_sum = g[1];
-         if (g[0]>0)
-            gain_sum += g[0];
-         if (g[2]>0)
-            gain_sum += g[2];
+         gain_sum = ADD16(ADD16(g[1],MAX16(g[0], 0)),MAX16(g[2], 0));
          if (gain_sum > 64)
          {
             gain_sum = SUB16(gain_sum, 64);



More information about the commits mailing list