[xiph-cvs] cvs commit: speex/libspeex fixed_debug.h lsp.c ltp.c

Jean-Marc Valin jm at xiph.org
Sat Nov 29 11:25:48 PST 2003



jm          03/11/29 14:25:48

  Modified:    libspeex fixed_debug.h lsp.c ltp.c
  Log:
  fixed-point: fixed another overflow problem

Revision  Changes    Path
1.4       +2 -2      speex/libspeex/fixed_debug.h

Index: fixed_debug.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/fixed_debug.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- fixed_debug.h	29 Nov 2003 08:12:51 -0000	1.3
+++ fixed_debug.h	29 Nov 2003 19:25:48 -0000	1.4
@@ -250,12 +250,12 @@
    long long res;
    if (b==0)
    {
-      fprintf(stderr, "DIV32_16: divide by zero: %d/%d\n", a, b);
+      fprintf(stderr, "DIV32_16: divide by zero: %d/%d\n", (int)a, (int)b);
       return 0;
    }
    if (!VERIFY_INT(a) || !VERIFY_SHORT(b))
    {
-      fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d\n", a, b);
+      fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d\n", (int)a, (int)b);
    }
    res = a/b;
    if (!VERIFY_SHORT(res))

<p><p>1.49      +2 -0      speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- lsp.c	29 Nov 2003 07:38:24 -0000	1.48
+++ lsp.c	29 Nov 2003 19:25:48 -0000	1.49
@@ -128,6 +128,8 @@
     /*Prevents overflows*/
     if (x>16383)
        x = 16383;
+    if (x<-16383)
+       x = -16383;
 
     /* Allocate memory for Chebyshev series formulation */
     T=PUSH(stack, m2+1, spx_word16_t);

<p><p>1.103     +5 -6      speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- ltp.c	29 Nov 2003 02:45:02 -0000	1.102
+++ ltp.c	29 Nov 2003 19:25:48 -0000	1.103
@@ -383,18 +383,17 @@
 #endif
       *cdbk_index=best_cdbk;
    }
-   
+
 #ifdef FIXED_POINT
    for (i=0;i<nsf;i++)
-     exc[i]=MULT16_32_Q13(SHL(gain[0],7),e[2][i])+MULT16_32_Q13(SHL(gain[1],7),e[1][i])+MULT16_32_Q13(SHL(gain[2],7),e[0][i]);
+     exc[i]=SHL(MULT16_32_Q14(SHL(gain[0],7),e[2][i])+MULT16_32_Q14(SHL(gain[1],7),e[1][i])+MULT16_32_Q14(SHL(gain[2],7),e[0][i]),1);
    
    err=0;
    for (i=0;i<nsf;i++)
    {
-      spx_sig_t perr=target[i]-(MULT16_32_Q13(SHL(gain[0],7),x[2][i])+MULT16_32_Q13(SHL(gain[1],7),x[1][i])+MULT16_32_Q13(SHL(gain[2],7),x[0][i]));
-      spx_word16_t perr2 = SHR(perr,15);
+      spx_sig_t perr=target[i]-SHL((MULT16_32_Q14(SHL(gain[0],7),x[2][i])+MULT16_32_Q14(SHL(gain[1],7),x[1][i])+MULT16_32_Q14(SHL(gain[2],7),x[0][i])),1);
+      spx_word16_t perr2 = PSHR(perr,15);
       err = ADD64(err,MULT16_16(perr2,perr2));
-      
    }
 #else
    for (i=0;i<nsf;i++)
@@ -625,7 +624,7 @@
 #ifdef FIXED_POINT
       {
          for (i=0;i<nsf;i++)
-            exc[i]=MULT16_32_Q13(SHL(sgain[0],7),e[2][i])+MULT16_32_Q13(SHL(sgain[1],7),e[1][i])+MULT16_32_Q13(SHL(sgain[2],7),e[0][i]);
+            exc[i]=SHL(MULT16_32_Q14(SHL(sgain[0],7),e[2][i])+MULT16_32_Q14(SHL(sgain[1],7),e[1][i])+MULT16_32_Q14(SHL(sgain[2],7),e[0][i]),1);
       }
 #else
       for (i=0;i<nsf;i++)

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list