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

jm at svn.xiph.org jm at svn.xiph.org
Tue May 16 08:12:35 PDT 2006


Author: jm
Date: 2006-05-16 08:12:29 -0700 (Tue, 16 May 2006)
New Revision: 11408

Modified:
   trunk/speex/libspeex/cb_search.c
   trunk/speex/libspeex/filters.c
   trunk/speex/libspeex/fixed_debug.h
   trunk/speex/libspeex/lpc.c
   trunk/speex/libspeex/modes.c
   trunk/speex/libspeex/sb_celp.c
Log:
removed a bunch of overflow cases, most of which were in wideband


Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c	2006-05-16 15:07:32 UTC (rev 11407)
+++ trunk/speex/libspeex/cb_search.c	2006-05-16 15:12:29 UTC (rev 11408)
@@ -70,7 +70,7 @@
          for (k=0;k<=j;k++)
             resj = MAC16_16(resj,shape[k],r[j-k]);
 #ifdef FIXED_POINT
-         res16 = EXTRACT16(SHR32(resj, 11));
+         res16 = EXTRACT16(SHR32(resj, 13));
 #else
          res16 = 0.03125f*resj;
 #endif
@@ -89,7 +89,7 @@
 {
    int n;
    for (n=0;n<len;n++)
-      t[n] = SUB32(t[n],MULT16_16_Q11_32(g,r[n]));
+      t[n] = SUB16(t[n],PSHR32(MULT16_16(g,r[n]),13));
 }
 #endif
 
@@ -154,7 +154,7 @@
    
    /* FIXME: make that adaptive? */
    for (i=0;i<nsf;i++)
-      t[i]=EXTRACT16(PSHR32(target[i],6));
+      t[i]=EXTRACT16(PSHR32(target[i],8));
 
    compute_weighted_codebook(shape_cb, r, resp, resp2, E, shape_cb_size, subvect_size, stack);
 
@@ -349,7 +349,7 @@
    
    /* FIXME: make that adaptive? */
    for (i=0;i<nsf;i++)
-      t[i]=EXTRACT16(PSHR32(target[i],6));
+      t[i]=EXTRACT16(PSHR32(target[i],8));
 
    for (j=0;j<N;j++)
       speex_move(&ot[j][0], t, nsf*sizeof(spx_word16_t));

Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2006-05-16 15:07:32 UTC (rev 11407)
+++ trunk/speex/libspeex/filters.c	2006-05-16 15:12:29 UTC (rev 11408)
@@ -85,9 +85,9 @@
       scale_1 = EXTRACT16(PDIV32_16(SHL32(EXTEND32(SIG_SCALING),7),scale));
       for (i=0;i<len;i++)
       {
-         y[i] = SHR32(MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT))),7);
+         y[i] = PSHR32(MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT))),7);
       }
-   } else {
+   } else if (scale > SHR32(EXTEND32(SIG_SCALING), 2)) {
       spx_word16_t scale_1;
       scale = PSHR32(scale, SIG_SHIFT-5);
       scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale);
@@ -95,6 +95,16 @@
       {
          y[i] = MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT-2)));
       }
+   } else {
+      spx_word16_t scale_1;
+      scale = PSHR32(scale, SIG_SHIFT-7);
+      if (scale < 5)
+         scale = 5;
+      scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale);
+      for (i=0;i<len;i++)
+      {
+         y[i] = SHL32(MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT-2))),2);
+      }
    }
 }
 
@@ -526,14 +536,13 @@
    i++;
    for (;i<N;i++)
       y[i] = VERY_SMALL;
-   
    for (i=0;i<ord;i++)
       mem1[i] = mem2[i] = 0;
    for (i=0;i<N;i++)
    {
       y1 = ADD16(y[i], EXTRACT16(PSHR32(mem1[0],LPC_SHIFT)));
       ny1i = NEG16(y1);
-      y[i] = ADD16(SHL16(y1,1), EXTRACT16(PSHR32(mem2[0],LPC_SHIFT)));
+      y[i] = PSHR32(ADD32(SHL32(EXTEND32(y1),LPC_SHIFT+1),mem2[0]),LPC_SHIFT);
       ny2i = NEG16(y[i]);
       for (j=0;j<ord-1;j++)
       {

Modified: trunk/speex/libspeex/fixed_debug.h
===================================================================
--- trunk/speex/libspeex/fixed_debug.h	2006-05-16 15:07:32 UTC (rev 11407)
+++ trunk/speex/libspeex/fixed_debug.h	2006-05-16 15:12:29 UTC (rev 11408)
@@ -170,7 +170,7 @@
    }
    res = a+b;
    if (!VERIFY_SHORT(res))
-      fprintf (stderr, "ADD16: output is not short: %d\n", res);
+      fprintf (stderr, "ADD16: output is not short: %d+%d=%d\n", a,b,res);
    spx_mips++;
    return res;
 }
@@ -197,7 +197,9 @@
    }
    res = a+b;
    if (!VERIFY_INT(res))
+   {
       fprintf (stderr, "ADD32: output is not int: %d\n", (int)res);
+   }
    spx_mips++;
    return res;
 }
@@ -440,7 +442,7 @@
    spx_mips+=36;
    return res;
 }
+#define PDIV32(a,b) DIV32(ADD32((a),(b)>>1),b)
+#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b)
 
-
-
 #endif

Modified: trunk/speex/libspeex/lpc.c
===================================================================
--- trunk/speex/libspeex/lpc.c	2006-05-16 15:07:32 UTC (rev 11407)
+++ trunk/speex/libspeex/lpc.c	2006-05-16 15:12:29 UTC (rev 11408)
@@ -94,7 +94,7 @@
       for (j = 0; j < i; j++) 
          rr = SUB32(rr,MULT16_16(lpc[j],ac[i - j]));
 #ifdef FIXED_POINT
-      r = DIV32_16(rr+PSHR32(error,1),ADD16(error,4));
+      r = DIV32_16(rr+PSHR32(error,1),ADD16(error,8));
 #else
       r = rr/(error+.003*ac[0]);
 #endif

Modified: trunk/speex/libspeex/modes.c
===================================================================
--- trunk/speex/libspeex/modes.c	2006-05-16 15:07:32 UTC (rev 11407)
+++ trunk/speex/libspeex/modes.c	2006-05-16 15:12:29 UTC (rev 11408)
@@ -493,8 +493,8 @@
 #else
    0.9, 0.6, /* gamma1, gamma2 */
 #endif
-   .001,   /*lag_factor*/
-   QCONST16(.0001,15), /*lpc_floor*/
+   .012,   /*lag_factor*/
+   QCONST16(.0002,15), /*lpc_floor*/
    0.9,
    {NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
    3,
@@ -539,8 +539,8 @@
 #else
    0.9, 0.6, /* gamma1, gamma2 */
 #endif
-   .002,   /*lag_factor*/
-   QCONST16(.0001,15), /*lpc_floor*/
+   .012,   /*lag_factor*/
+   QCONST16(.0002,15), /*lpc_floor*/
    0.7,
    {NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
    1,

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2006-05-16 15:07:32 UTC (rev 11407)
+++ trunk/speex/libspeex/sb_celp.c	2006-05-16 15:12:29 UTC (rev 11408)
@@ -724,7 +724,7 @@
          if (st->subframeSize==80)
             gc *= 1.4142;
 
-         scale = SHL(MULT16_16(PDIV32_16(SHL(gc,SIG_SHIFT-4),filter_ratio),(1+el)),4);
+         scale = SHL32(MULT16_16(PDIV32_16(SHL32(EXTEND32(gc),SIG_SHIFT-6),filter_ratio),(1+el)),6);
 
          compute_impulse_response(st->interp_qlpc, st->bw_lpc1, st->bw_lpc2, syn_resp, st->subframeSize, st->lpcSize, stack);
 
@@ -1191,7 +1191,7 @@
          if (st->subframeSize==80)
             gc *= 1.4142;
 
-         scale = SHL(MULT16_16(PDIV32_16(SHL(gc,SIG_SHIFT-4),filter_ratio),(1+el)),4);
+         scale = SHL(MULT16_16(PDIV32_16(SHL(gc,SIG_SHIFT-6),filter_ratio),(1+el)),6);
 
          SUBMODE(innovation_unquant)(exc, SUBMODE(innovation_params), st->subframeSize, 
                                 bits, stack);



More information about the commits mailing list