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

jm at motherfish-iii.xiph.org jm at motherfish-iii.xiph.org
Wed May 25 14:11:37 PDT 2005


Author: jm
Date: 2005-05-25 14:11:32 -0700 (Wed, 25 May 2005)
New Revision: 9313

Modified:
   trunk/speex/libspeex/filters.c
   trunk/speex/libspeex/lsp.c
   trunk/speex/libspeex/nb_celp.c
Log:
Fixed-point fixes for 16-bit archs


Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2005-05-25 15:20:56 UTC (rev 9312)
+++ trunk/speex/libspeex/filters.c	2005-05-25 21:11:32 UTC (rev 9313)
@@ -68,11 +68,11 @@
 void signal_div(const spx_sig_t *x, spx_sig_t *y, spx_word32_t scale, int len)
 {
    int i;
-   if (scale > SHL32(SIG_SCALING, 8))
+   if (scale > SHL32(EXTEND32(SIG_SCALING), 8))
    {
       spx_word16_t scale_1;
       scale = PSHR32(scale, SIG_SHIFT);
-      scale_1 = EXTRACT16(DIV32_16(SHL32(SIG_SCALING,7),scale));
+      scale_1 = EXTRACT16(DIV32_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);
@@ -80,7 +80,7 @@
    } else {
       spx_word16_t scale_1;
       scale = PSHR32(scale, SIG_SHIFT-5);
-      scale_1 = DIV32_16(SHL32(SIG_SCALING,3),scale);
+      scale_1 = DIV32_16(SHL32(EXTEND32(SIG_SCALING),3),scale);
       for (i=0;i<len;i++)
       {
          y[i] = MULT16_16(scale_1, EXTRACT16(SHR32(x[i],SIG_SHIFT-2)));
@@ -573,9 +573,9 @@
    {
       spx_word16_t g = gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain);
       if (g > 166)
-         comb_gain = MULT16_16_Q15(DIV32_16(SHL(165,15),g), comb_gain);
+         comb_gain = MULT16_16_Q15(DIV32_16(SHL32(EXTEND32(165),15),g), comb_gain);
       if (g < 64)
-         comb_gain = MULT16_16_Q15(SHL(g, 9), comb_gain);
+         comb_gain = MULT16_16_Q15(SHL16(g, 9), comb_gain);
    }
 #else
    {

Modified: trunk/speex/libspeex/lsp.c
===================================================================
--- trunk/speex/libspeex/lsp.c	2005-05-25 15:20:56 UTC (rev 9312)
+++ trunk/speex/libspeex/lsp.c	2005-05-25 21:11:32 UTC (rev 9313)
@@ -172,12 +172,12 @@
 
     /* Evaluate Chebyshev series formulation using iterative approach  */
     /* Evaluate polynomial and return value also free memory space */
-    sum = ADD32(coefn[m2], MULT16_16_P14(coefn[m2-1],x));
+    sum = ADD32(EXTEND32(coefn[m2]), EXTEND32(MULT16_16_P14(coefn[m2-1],x)));
     /*x *= 2;*/
     for(i=2;i<=m2;i++)
     {
        T[i] = SUB16(MULT16_16_Q13(x,T[i-1]), T[i-2]);
-       sum = ADD32(sum, MULT16_16_P14(coefn[m2-i],T[i]));
+       sum = ADD32(sum, EXTEND32(MULT16_16_P14(coefn[m2-i],T[i])));
        /*printf ("%f ", sum);*/
     }
     
@@ -469,9 +469,9 @@
         /* FIXME: perhaps apply bandwidth expansion in case of overflow? */
 	if (j>0)
 	{
-        if (xout1 + xout2>SHL(32766,8))
+        if (xout1 + xout2>SHL32(EXTEND32(32766),8))
            ak[j-1] = 32767;
-        else if (xout1 + xout2 < -SHL(32766,8))
+        else if (xout1 + xout2 < -SHL32(EXTEND32(32766),8))
            ak[j-1] = -32767;
         else
            ak[j-1] = EXTRACT16(PSHR32(ADD32(xout1,xout2),8));
@@ -580,7 +580,7 @@
 void lsp_interpolate(spx_lsp_t *old_lsp, spx_lsp_t *new_lsp, spx_lsp_t *interp_lsp, int len, int subframe, int nb_subframes)
 {
    int i;
-   spx_word16_t tmp = DIV32_16(SHL32(1 + subframe,14),nb_subframes);
+   spx_word16_t tmp = DIV32_16(SHL32(EXTEND32(1 + subframe),14),nb_subframes);
    spx_word16_t tmp2 = 16384-tmp;
    for (i=0;i<len;i++)
    {

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2005-05-25 15:20:56 UTC (rev 9312)
+++ trunk/speex/libspeex/nb_celp.c	2005-05-25 21:11:32 UTC (rev 9313)
@@ -809,7 +809,7 @@
 #ifdef FIXED_POINT
          {
             spx_word32_t f = DIV32(ener,PSHR32(ol_gain,SIG_SHIFT));
-            if (f<32768)
+            if (f<=32767)
                fine_gain = f;
             else
                fine_gain = 32767;



More information about the commits mailing list