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

jm at svn.xiph.org jm at svn.xiph.org
Tue Dec 26 03:37:31 PST 2006


Author: jm
Date: 2006-12-26 03:37:28 -0800 (Tue, 26 Dec 2006)
New Revision: 12242

Modified:
   trunk/speex/libspeex/fixed_debug.h
   trunk/speex/libspeex/ltp.c
Log:
merged some fixed-point and floating-point code in open-loop pitch search. 
Also added more debug info for DIV32.


Modified: trunk/speex/libspeex/fixed_debug.h
===================================================================
--- trunk/speex/libspeex/fixed_debug.h	2006-12-25 22:46:08 UTC (rev 12241)
+++ trunk/speex/libspeex/fixed_debug.h	2006-12-26 11:37:28 UTC (rev 12242)
@@ -459,22 +459,24 @@
    spx_mips+=20;
    return res;
 }
-static inline int DIV32(long long a, long long b) 
+
+#define DIV32(a, b) _DIV32(a, b, __FILE__, __LINE__)
+static inline int _DIV32(long long a, long long b, char *file, int line) 
 {
    long long res;
    if (b==0)
    {
-      fprintf(stderr, "DIV32: divide by zero: %d/%d\n", (int)a, (int)b);
+      fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line);
       return 0;
    }
 
    if (!VERIFY_INT(a) || !VERIFY_INT(b))
    {
-      fprintf (stderr, "DIV32: inputs are not int/short: %d %d\n", (int)a, (int)b);
+      fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line);
    }
    res = a/b;
    if (!VERIFY_INT(res))
-      fprintf (stderr, "DIV32: output is not int: %d\n", (int)res);
+      fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int)res, file, line);
    spx_mips+=36;
    return res;
 }

Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c	2006-12-25 22:46:08 UTC (rev 12241)
+++ trunk/speex/libspeex/ltp.c	2006-12-26 11:37:28 UTC (rev 12242)
@@ -185,7 +185,6 @@
    ALLOC(best_ener, N, spx_word32_t);
    ALLOC(corr, end-start+1, spx_word32_t);
    ALLOC(energy, end-start+2, spx_word32_t);
-
    for (i=0;i<N;i++)
    {
         best_score[i]=-1;
@@ -233,8 +232,8 @@
 #endif
 
    /* FIXME: Fixed-point and floating-point code should be merged */
-#ifdef FIXED_POINT
    {
+#ifdef FIXED_POINT
       VARDECL(spx_word16_t *corr16);
       VARDECL(spx_word16_t *ener16);
       ALLOC(corr16, end-start+1, spx_word16_t);
@@ -242,7 +241,10 @@
       /* Normalize to 180 so we can square it and it still fits in 16 bits */
       normalize16(corr, corr16, 180, end-start+1);
       normalize16(energy, ener16, 180, end-start+1);
-
+#else
+      spx_word16_t *corr16 = corr;
+      spx_word16_t *ener16 = energy;
+#endif
       for (i=start;i<=end;i++)
       {
          spx_word16_t tmp = MULT16_16_16(corr16[i-start],corr16[i-start]);
@@ -273,31 +275,6 @@
          }
       }
    }
-#else
-   for (i=start;i<=end;i++)
-   {
-      float tmp = corr[i-start]*corr[i-start];
-      if (tmp*best_ener[N-1]>best_score[N-1]*(1+energy[i-start]))
-      {
-         for (j=0;j<N;j++)
-         {
-            if (tmp*best_ener[j]>best_score[j]*(1+energy[i-start]))
-            {
-               for (k=N-1;k>j;k--)
-               {
-                  best_score[k]=best_score[k-1];
-                  best_ener[k]=best_ener[k-1];
-                  pitch[k]=pitch[k-1];
-               }
-               best_score[j]=tmp;
-               best_ener[j]=energy[i-start]+1;
-               pitch[j]=i;
-               break;
-            }
-         }
-      }
-   }
-#endif
 
    /* Compute open-loop gain */
    if (gain)



More information about the commits mailing list