[xiph-cvs] cvs commit: speex/libspeex quant_lsp.c

Jean-Marc Valin jm at xiph.org
Mon Nov 3 00:59:34 PST 2003



jm          03/11/03 03:59:34

  Modified:    libspeex quant_lsp.c
  Log:
  fixed-point: integerized lsp weight computation

Revision  Changes    Path
1.30      +18 -13    speex/libspeex/quant_lsp.c

Index: quant_lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/quant_lsp.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- quant_lsp.c	2 Nov 2003 05:08:56 -0000	1.29
+++ quant_lsp.c	3 Nov 2003 08:59:33 -0000	1.30
@@ -42,7 +42,7 @@
 #define LSP_DIV_256(x) (SHL((spx_word16_t)x, 5))
 #define LSP_DIV_512(x) (SHL((spx_word16_t)x, 4))
 #define LSP_DIV_1024(x) (SHL((spx_word16_t)x, 3))
-
+#define LSP_PI 25736
 #else
 
 #define LSP_LINEAR(i) (.25*(i)+.25)
@@ -50,25 +50,30 @@
 #define LSP_DIV_256(x) (0.0039062*(x))
 #define LSP_DIV_512(x) (0.0019531*(x))
 #define LSP_DIV_1024(x) (0.00097656*(x))
-
+#define LSP_PI M_PI
 #endif
 
 static void compute_quant_weights(spx_lsp_t *qlsp, spx_word16_t *quant_weight, int order)
 {
    int i;
    float tmp1, tmp2;
-   quant_weight[0] = 10/((qlsp[1]-qlsp[0])/LSP_SCALING);
-   quant_weight[order-1] = 10/((qlsp[order-1]-qlsp[order-2])/LSP_SCALING);
-   for (i=1;i<order-1;i++)
+   for (i=0;i<order;i++)
    {
-#if 1
-      tmp1 = 10/((.15+(qlsp[i]-qlsp[i-1])/LSP_SCALING)*(.15+(qlsp[i]-qlsp[i-1])/LSP_SCALING));
-      tmp2 = 10/((.15+(qlsp[i+1]-qlsp[i])/LSP_SCALING)*(.15+(qlsp[i+1]-qlsp[i])/LSP_SCALING));
+      if (i==0)
+         tmp1 = qlsp[i];
+      else
+         tmp1 = qlsp[i]-qlsp[i-1];
+      if (i==order-1)
+         tmp2 = LSP_PI-qlsp[i];
+      else
+         tmp2 = qlsp[i+1]-qlsp[i];
+      if (tmp2<tmp1)
+         tmp1 = tmp2;
+#ifdef FIXED_POINT
+      quant_weight[i] = DIV32_16(81920,ADD16(300,tmp1));
 #else
-      tmp1 = 10/(qlsp[i]-qlsp[i-1]);
-      tmp2 = 10/(qlsp[i+1]-qlsp[i]);
+      quant_weight[i] = 10/(.04+tmp1);
 #endif
-      quant_weight[i] = tmp1 > tmp2 ? tmp1 : tmp2;
    }
 
 }
@@ -87,7 +92,7 @@
       dist=0;
       for (j=0;j<nbDim;j++)
       {
-         tmp=(x[j]-SHL((spx_word16_t)*ptr++,5));
+         tmp=SUB16(x[j],SHL((spx_word16_t)*ptr++,5));
          dist+=MULT16_16(tmp,tmp);
       }
       if (dist<best_dist || i==0)
@@ -117,7 +122,7 @@
       dist=0;
       for (j=0;j<nbDim;j++)
       {
-         tmp=(x[j]-SHL((spx_word16_t)*ptr++,5));
+         tmp=SUB16(x[j],SHL((spx_word16_t)*ptr++,5));
          dist+=MULT16_32_Q15(weight[j],MULT16_16(tmp,tmp));
       }
       if (dist<best_dist || i==0)

<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