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

Jean-Marc Valin jm at xiph.org
Mon Jan 27 16:50:22 PST 2003



jm          03/01/27 19:50:22

  Modified:    libspeex high_lsp_tables.c lsp_tables_nb.c quant_lsp.c
                        quant_lsp.h
  Log:
  LSP codebooks are now signed short instead of float, reducing size in
  binary by a factor of 4.

Revision  Changes    Path
1.4       +3 -67     speex/libspeex/high_lsp_tables.c

Index: high_lsp_tables.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/high_lsp_tables.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- high_lsp_tables.c	28 Jan 2003 00:02:55 -0000	1.3
+++ high_lsp_tables.c	28 Jan 2003 00:50:22 -0000	1.4
@@ -29,7 +29,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
  
-float high_lsp_cdbk[]={
+signed char high_lsp_cdbk[]={
 39,12,-14,-20,-29,-61,-67,-76,
 -32,-71,-67,68,77,46,34,5,
 -13,-48,-46,-72,-81,-84,-60,-58,
@@ -96,7 +96,7 @@
 -42,-74,-48,21,-4,70,52,10};
 
 
-float high_lsp_cdbk2[]={
+signed char high_lsp_cdbk2[]={
 -36,-62,6,-9,-10,-14,-56,23,
 1,-26,23,-48,-17,12,8,-7,
 23,29,-36,-28,-6,-29,-17,-5,
@@ -160,68 +160,4 @@
 -28,-37,63,44,41,3,2,14,
 9,-6,75,-8,-7,-12,-15,-12,
 13,9,-4,30,-22,-65,15,0,
--45,4,-4,1,5,22,11,23,
--15,-16,3,-51,8,-24,-50,12,
--14,-49,-5,-5,-25,49,1,3,
-20,8,-7,-38,-24,-21,5,-39,
-39,31,53,25,-26,2,-3,22,
--32,-9,-27,49,73,24,10,13,
--2,-8,-10,-41,-106,15,34,3,
--29,-58,-30,53,-5,-53,10,-9,
-11,57,-34,-36,6,48,30,7,
-28,6,12,25,-51,-1,-20,-37,
-10,-2,-20,-8,-4,16,19,7,
--8,-16,-35,-77,42,34,25,9,
--18,21,-36,45,25,-7,-26,-53,
-29,2,35,8,1,46,-2,-5,
--36,-19,41,37,-23,-37,52,27,
-27,38,-7,-37,48,-21,-7,-12,
--42,42,50,23,20,-38,-18,17,
--42,17,-9,14,6,-42,-92,-15,
--38,28,6,-27,-25,32,-23,-37,
--4,-3,-27,-16,24,38,-12,-32,
-45,39,16,-13,-7,-27,-83,25,
-14,1,-33,26,38,47,-10,16,
-0,-32,37,-16,-27,-65,13,27,
--34,-45,-24,-31,1,15,41,4,
-55,57,23,-11,8,17,-20,-6,
-22,7,12,15,16,-10,-60,-47,
-44,56,3,-7,-70,46,41,19,
--16,-5,-27,-10,57,-8,14,27,
-17,14,-34,32,-11,5,-29,36,
--38,-75,30,16,-20,1,22,-10,
-12,-3,8,-4,0,-21,-24,-10,
-13,9,-25,7,32,-38,27,-43,
--72,36,1,34,19,14,10,-32,
--4,-8,-1,-49,34,47,-38,10,
-8,5,1,-5,-28,42,-35,23,
--5,8,-15,-70,4,-19,29,21,
-4,87,36,5,-29,-39,19,5,
--28,-19,11,22,30,-4,-22,-13,
-21,-4,-10,-22,-44,-32,-12,30,
--16,-37,-61,41,-42,25,29,5,
--5,33,28,2,33,25,-41,29,
--11,-31,-5,-5,-27,-20,-36,-79,
-5,2,12,40,-34,52,31,2,
--24,-47,4,-8,48,25,3,7,
-13,35,12,11,0,9,2,-3,
--2,-1,10,46,26,20,31,7,
-13,19,51,12,4,-18,50,24,
-19,30,28,-33,-1,-39,8,13,
--44,46,37,9,-48,3,26,-9,
-5,-15,4,36,-9,-48,-83,44,
--5,-34,11,-31,-72,17,-34,-14,
-9,-7,-56,-35,-37,26,20,-11,
-13,19,9,-22,-37,-17,-52,-10,
--10,-4,-5,10,-5,33,31,-54,
--26,-15,-32,-37,-47,-75,10,3,
--16,-47,-18,-10,-37,-27,2,5,
-38,13,-2,-21,27,18,26,7,
--28,-35,43,-3,43,14,-25,-67,
-63,26,-25,-4,-11,53,5,-1,
--9,-38,5,-4,10,3,5,45,
-40,24,-1,31,24,-24,-42,13,
--55,-82,4,59,44,12,-19,2,
--13,-3,43,34,-15,13,-25,-25,
-11,24,-22,60,8,-31,28,20,
--73,-1,-34,20,-3,-13,-1,12};
+-45,4,-4,1,5,22,11,23};

<p><p>1.5       +5 -5      speex/libspeex/lsp_tables_nb.c

Index: lsp_tables_nb.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp_tables_nb.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- lsp_tables_nb.c	27 Jan 2003 22:09:39 -0000	1.4
+++ lsp_tables_nb.c	28 Jan 2003 00:50:22 -0000	1.5
@@ -29,7 +29,7 @@
    POSSIBILITY OF SUCH DAMAGE.
 */
 
-float cdbk_nb[]={
+signed char cdbk_nb[]={
 30,19,38,34,40,32,46,43,58,43,
 5,-18,-25,-40,-33,-55,-52,20,34,28,
 -20,-63,-97,-92,61,53,47,49,53,75,
@@ -95,7 +95,7 @@
 -6,-41,-67,6,-2,-9,19,2,85,74,
 -22,-67,-84,-71,-50,3,11,-9,2,62};
 
-float cdbk_nb_low1[]={
+signed char cdbk_nb_low1[]={
 -34,-52,-15,45,2,
 23,21,52,24,-33,
 -9,-1,9,-44,-41,
@@ -161,7 +161,7 @@
 13,20,20,-19,-22,
 -2,-8,2,51,-51};
 
-float cdbk_nb_low2[]={
+signed char cdbk_nb_low2[]={
 -6,53,-21,-24,4,
 26,17,-4,-37,25,
 17,-36,-13,31,3,
@@ -227,7 +227,7 @@
 -23,-29,-16,1,-3,
 -8,-10,31,64,-65};
 
-float cdbk_nb_high1[]={
+signed char cdbk_nb_high1[]={
 -26,-8,29,21,4,
 19,-39,33,-7,-36,
 56,54,48,40,29,
@@ -293,7 +293,7 @@
 29,17,8,-29,-39,
 -69,18,15,-15,-5};
 
-float cdbk_nb_high2[]={
+signed char cdbk_nb_high2[]={
 11,47,16,-9,-46,
 -32,26,-64,34,-5,
 38,-7,47,20,2,

<p><p>1.21      +9 -9      speex/libspeex/quant_lsp.c

Index: quant_lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/quant_lsp.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- quant_lsp.c	28 Jan 2003 00:02:55 -0000	1.20
+++ quant_lsp.c	28 Jan 2003 00:50:22 -0000	1.21
@@ -37,13 +37,13 @@
 static float quant_weight[MAX_LSP_SIZE];
 
 /* Note: x is modified*/
-static int lsp_quant(float *x, float *cdbk, int nbVec, int nbDim)
+static int lsp_quant(float *x, signed char *cdbk, int nbVec, int nbDim)
 {
    int i,j;
    float dist, tmp;
    float best_dist=0;
    int best_id=0;
-   float *ptr=cdbk;
+   signed char *ptr=cdbk;
    for (i=0;i<nbVec;i++)
    {
       dist=0;
@@ -66,13 +66,13 @@
 }
 
 /* Note: x is modified*/
-static int lsp_weight_quant(float *x, float *weight, float *cdbk, int nbVec, int nbDim)
+static int lsp_weight_quant(float *x, float *weight, signed char *cdbk, int nbVec, int nbDim)
 {
    int i,j;
    float dist, tmp;
    float best_dist=0;
    int best_id=0;
-   float *ptr=cdbk;
+   signed char *ptr=cdbk;
    for (i=0;i<nbVec;i++)
    {
       dist=0;
@@ -250,8 +250,8 @@
 }
 
 
-extern float high_lsp_cdbk[];
-extern float high_lsp_cdbk2[];
+extern signed char high_lsp_cdbk[];
+extern signed char high_lsp_cdbk2[];
 
 
 void lsp_quant_high(float *lsp, float *qlsp, int order, SpeexBits *bits)
@@ -282,8 +282,8 @@
    for (i=0;i<order;i++)
       qlsp[i]*=2;
 
-   id = lsp_weight_quant(qlsp, quant_weight, high_lsp_cdbk2, 64, order);
-   speex_bits_pack(bits, id, 6);
+   id = lsp_weight_quant(qlsp, quant_weight, high_lsp_cdbk2, 128, order);
+   speex_bits_pack(bits, id, 7);
 
    for (i=0;i<order;i++)
       qlsp[i]*=0.0019531;
@@ -305,7 +305,7 @@
       lsp[i] += 0.0039062*high_lsp_cdbk[id*order+i];
 
 
-   id=speex_bits_unpack_unsigned(bits, 6);
+   id=speex_bits_unpack_unsigned(bits, 7);
    for (i=0;i<order;i++)
       lsp[i] += 0.0019531*high_lsp_cdbk2[id*order+i];
 }

<p><p>1.15      +5 -5      speex/libspeex/quant_lsp.h

Index: quant_lsp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/quant_lsp.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- quant_lsp.h	11 Oct 2002 03:39:34 -0000	1.14
+++ quant_lsp.h	28 Jan 2003 00:50:22 -0000	1.15
@@ -44,11 +44,11 @@
 #define NB_CDBK_SIZE_HIGH2 64
 
 /*Narrowband codebooks*/
-extern float cdbk_nb[];
-extern float cdbk_nb_low1[];
-extern float cdbk_nb_low2[];
-extern float cdbk_nb_high1[];
-extern float cdbk_nb_high2[];
+extern signed char cdbk_nb[];
+extern signed char cdbk_nb_low1[];
+extern signed char cdbk_nb_low2[];
+extern signed char cdbk_nb_high1[];
+extern signed char cdbk_nb_high2[];
 
 /* Quantizes narrowband LSPs with 30 bits */
 void lsp_quant_nb(float *lsp, float *qlsp, int order, SpeexBits *bits);

<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