[xiph-cvs] cvs commit: speex/libspeex gain_table.c gain_table_lbr.c ltp.c ltp.h modes.c

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



jm          03/01/28 01:52:40

  Modified:    libspeex gain_table.c gain_table_lbr.c ltp.c ltp.h modes.c
  Log:
  Gain codebook also converted to signed char.

Revision  Changes    Path
1.7       +129 -161  speex/libspeex/gain_table.c

Index: gain_table.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/gain_table.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- gain_table.c	25 Jan 2003 05:45:48 -0000	1.6
+++ gain_table.c	28 Jan 2003 06:52:40 -0000	1.7
@@ -1,161 +1,129 @@
-/* Copyright (C) 2002 Jean-Marc Valin 
-   File: gain_table.c
-   Codebook for 3-tap pitch prediction gain (128 entries)
-  
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are
-   met:
-
-   1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.  
-
-   2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-   3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
-   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-   POSSIBILITY OF SUCH DAMAGE.
-*/
-
-float gain_cdbk_nb[] = {
-0,0,0,
-0.062755,  -0.551342,  0.421540,
--0.150363,  0.404424,  0.001225,
--0.385059,  0.344518,  -0.339050,
-0.253004,  0.922525,  -0.134325,
-0.797711,  0.207298,  -0.132452,
--0.205284,  0.869993,  0.168836,
-0.381250,  0.282361,  0.213362,
-0.511557,  0.726356,  -0.411456,
-0.213205,  -0.880939,  -0.114481,
--0.087361,  0.828807,  0.223046,
-0.203493,  0.809983,  -0.176178,
-0.661478,  0.762294,  -0.250586,
--0.315981,  -0.411233,  0.300318,
--0.194221,  0.489564,  0.332354,
-0.314585,  0.331551,  -0.034170,
-0.714691,  0.503023,  -0.211847,
--0.077114,  -0.046936,  -0.034251,
-0.111448,  1.194711,  0.036302,
-0.591707,  0.440950,  -0.478105,
-0.015255,  1.174960,  -0.140954,
-0.135889,  0.968711,  -0.179098,
--0.167709,  0.904867,  0.283567,
--0.015464,  0.519642,  0.302785,
-0.292544,  0.778571,  -0.073074,
--0.223209,  -0.647006,  -0.201825,
--0.060343,  0.879177,  0.109328,
--0.065641,  0.331451,  0.192766,
-0.109450,  0.695144,  0.220786,
--0.059634,  -0.580311,  -0.414489,
--0.195686,  0.599741,  0.630645,
-0.151037,  0.275520,  0.128741,
-0.485775,  0.705795,  -0.188048,
--0.107445,  -0.242973,  0.096488,
-0.002256,  0.985752,  -0.075257,
--0.009754,  0.731055,  -0.211925,
-0.117978,  0.967401,  -0.066418,
--0.140817,  0.987609,  0.142895,
--0.275615,  0.847037,  0.439390,
-0.159816,  0.534635,  0.178252,
-0.241865,  0.973769,  -0.025038,
-0.390984,  -0.437161,  0.067293,
--0.094812,  1.152626,  0.063490,
--0.189819,  0.328223,  0.823244,
-0.242738,  0.618335,  -0.187829,
--0.105747,  -0.364308,  -0.178488,
-0.332118,  -0.050869,  0.907884,
-0.362725,  0.500717,  -0.030776,
-0.371470,  2.389027,  -0.758519,
-0.613652,  0.255025,  0.153263,
--0.078645,  1.023368,  0.014171,
-0.082268,  0.388670,  -0.060537,
--0.029138,  1.599227,  -0.397880,
--0.076498,  0.328396,  -0.251380,
--0.117753,  0.772892,  0.476635,
--0.011502,  0.592414,  0.409736,
-0.359342,  0.495128,  0.183963,
-0.177247,  1.581225,  -0.008922,
-0.046118,  1.020201,  0.020504,
--0.358123,  0.680523,  0.484358,
--0.011173,  0.928046,  0.156119,
--0.283681,  -0.020872,  -0.236879,
--0.288344,  1.344203,  1.297906,
-0.478199,  0.426105,  -0.180429,
-0.437023,  0.843117,  -0.117708,
--0.102861,  -0.531496,  0.116496,
--0.022004,  0.517811,  0.094120,
-0.124500,  0.135515,  0.109872,
-0.324995,  0.830981,  -0.197011,
-0.110316,  -0.205667,  0.206492,
--0.178459,  2.136809,  0.256389,
-0.571335,  0.167367,  0.520906,
-0.254870,  0.667184,  -0.012582,
-0.294991,  -1.045667,  0.441186,
--0.084671,  1.012571,  0.272680,
-0.107486,  1.072982,  -0.479951,
--0.059855,  0.872191,  0.013070,
--0.334498,  -0.377732,  -0.090863,
--0.148432,  0.445259,  0.560717,
--0.011102,  0.706627,  0.037709,
-1.264755,  1.312855,  -0.972929,
-0.427258,  0.028012,  0.270659,
-0.508489,  1.095174,  -0.126054,
-0.138141,  0.689060,  -0.066889,
-0.227053,  1.125286,  -0.234592,
--0.073214,  -0.138420,  -0.109450,
--0.259768,  1.034736,  0.500517,
-0.224840,  0.384070,  0.434633,
-0.251096,  0.766042,  0.076803,
-0.969989,  0.576600,  -0.472454,
-0.567736,  1.250295,  -0.561253,
--0.173068,  0.670076,  0.328527,
-0.218455,  0.793616,  0.266100,
-0.136564,  -0.461201,  -0.110116,
--0.161192,  0.652356,  0.476224,
-0.164136,  0.302808,  0.290994,
-0.355293,  0.698620,  -0.238562,
-0.139048,  -0.472423,  0.129851,
--0.189859,  1.431454,  0.173670,
-0.218201,  0.458996,  -0.307158,
-0.155604,  0.848000,  -0.058913,
--0.665377,  1.397551,  0.745416,
-0.195905,  0.549550,  0.654307,
-0.046667,  0.861746,  -0.097261,
-0.423542,  -0.468622,  -0.290162,
--0.298927,  1.125929,  0.217439,
--0.149400,  0.696023,  0.131298,
--0.036852,  0.717124,  0.193478,
--0.370020,  -0.668003,  0.089119,
-0.097258,  0.995974,  0.727015,
-0.099711,  0.763332,  0.051975,
-0.397417,  0.940052,  -0.307845,
-0.314526,  0.024086,  0.573651,
-0.422973,  -0.249544,  0.425072,
-0.537855,  0.533196,  -0.168307,
-0.828189,  0.742845,  0.744092,
-0.110322,  -0.209465,  -0.004052,
--0.164941,  0.780225,  0.337240,
-0.647682,  0.506853,  0.477262,
-0.481078,  0.614996,  0.027556,
-0.797248,  -0.254371,  0.438093,
-0.057783,  0.892067,  0.048618,
-0.157052,  0.505817,  0.019286,
--0.006495,  0.763456,  0.341807,
--0.505296,  -0.145069,  -0.462940,
--0.309828,  0.736220,  0.746342,
-0.036447,  0.151773,  0.000962,
-0.393744,  0.638035,  -0.094556,
-};
+signed char gain_cdbk_nb[] = {
+-32,-32,-32,
+-28,-67,-5,
+-42,-6,-32,
+-57,-10,-54,
+-16,27,-41,
+19,-19,-40,
+-45,24,-21,
+-8,-14,-18,
+1,14,-58,
+-18,-88,-39,
+-38,21,-18,
+-19,20,-43,
+10,17,-48,
+-52,-58,-13,
+-44,-1,-11,
+-12,-11,-34,
+14,0,-46,
+-37,-35,-34,
+-25,44,-30,
+6,-4,-63,
+-31,43,-41,
+-23,30,-43,
+-43,26,-14,
+-33,1,-13,
+-13,18,-37,
+-46,-73,-45,
+-36,24,-25,
+-36,-11,-20,
+-25,12,-18,
+-36,-69,-59,
+-45,6,8,
+-22,-14,-24,
+-1,13,-44,
+-39,-48,-26,
+-32,31,-37,
+-33,15,-46,
+-24,30,-36,
+-41,31,-23,
+-50,22,-4,
+-22,2,-21,
+-17,30,-34,
+-7,-60,-28,
+-38,42,-28,
+-44,-11,21,
+-16,8,-44,
+-39,-55,-43,
+-11,-35,26,
+-9,0,-34,
+-8,121,-81,
+7,-16,-22,
+-37,33,-31,
+-27,-7,-36,
+-34,70,-57,
+-37,-11,-48,
+-40,17,-1,
+-33,6,-6,
+-9,0,-20,
+-21,69,-33,
+-29,33,-31,
+-55,12,-1,
+-33,27,-22,
+-50,-33,-47,
+-50,54,51,
+-1,-5,-44,
+-4,22,-40,
+-39,-66,-25,
+-33,1,-26,
+-24,-23,-25,
+-11,21,-45,
+-25,-45,-19,
+-43,105,-16,
+5,-21,1,
+-16,11,-33,
+-13,-99,-4,
+-37,33,-15,
+-25,37,-63,
+-36,24,-31,
+-53,-56,-38,
+-41,-4,4,
+-33,13,-30,
+49,52,-94,
+-5,-30,-15,
+1,38,-40,
+-23,12,-36,
+-17,40,-47,
+-37,-41,-39,
+-49,34,0,
+-18,-7,-4,
+-16,17,-27,
+30,5,-62,
+4,48,-68,
+-43,11,-11,
+-18,19,-15,
+-23,-62,-39,
+-42,10,-2,
+-21,-13,-13,
+-9,13,-47,
+-23,-62,-24,
+-44,60,-21,
+-18,-3,-52,
+-22,22,-36,
+-75,57,16,
+-19,3,10,
+-29,23,-38,
+-5,-62,-51,
+-51,40,-18,
+-42,13,-24,
+-34,14,-20,
+-56,-75,-26,
+-26,32,15,
+-26,17,-29,
+-7,28,-52,
+-12,-30,5,
+-5,-48,-5,
+2,2,-43,
+21,16,16,
+-25,-45,-32,
+-43,18,-10,
+9,0,-1,
+-1,7,-30,
+19,-48,-4,
+-28,25,-29,
+-22,0,-31,
+-32,17,-10,
+-64,-41,-62,
+-52,15,16,
+-30,-22,-32,
+-7,9,-38};

<p><p>1.5       +33 -65    speex/libspeex/gain_table_lbr.c

Index: gain_table_lbr.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/gain_table_lbr.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- gain_table_lbr.c	25 Jan 2003 05:45:48 -0000	1.4
+++ gain_table_lbr.c	28 Jan 2003 06:52:40 -0000	1.5
@@ -1,65 +1,33 @@
-/* Copyright (C) 2002 Jean-Marc Valin 
-   File: gain_table_lbr.c
-   Codebook for 3-tap pitch prediction gain (32 entries)
-  
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions are
-   met:
-
-   1. Redistributions of source code must retain the above copyright notice,
-   this list of conditions and the following disclaimer.  
-
-   2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in the
-   documentation and/or other materials provided with the distribution.
-
-   3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-   OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-   DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
-   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-   POSSIBILITY OF SUCH DAMAGE.
-*/
-
-float gain_cdbk_lbr[] = {
-0,0,0,
-0.019578,  -0.411369,  0.250244,
--0.141413,  0.127455,  -0.177373,
--0.379174,  0.154715,  -0.359933,
-0.295340,  1.014952,  -0.144606,
-0.431555,  -0.107415,  0.360701,
--0.141305,  0.735394,  0.312635,
-0.382416,  0.267769,  0.318738,
-0.511146,  0.524061,  -0.190435,
-0.153482,  -0.531485,  -0.149959,
--0.094091,  0.930054,  0.139366,
-0.164167,  0.711936,  -0.077780,
-0.503705,  0.823130,  -0.273699,
--0.330264,  -0.613346,  0.085310,
--0.083597,  0.481953,  0.201470,
-0.195682,  0.429066,  0.059682,
-0.598746,  1.523378,  -0.189717,
--0.010502,  -0.257728,  -0.018047,
--0.132438,  1.383543,  0.280042,
-0.234771,  0.555249,  -0.210053,
-0.010973,  1.090455,  -0.009557,
-0.141315,  0.930896,  -0.128939,
--0.168645,  0.950529,  0.314244,
--0.028768,  0.695554,  0.133637,
-0.246305,  0.740436,  0.073124,
-0.280190,  -0.787092,  0.268726,
-0.010162,  0.894487,  0.006648,
-0.177218,  0.572144,  0.427882,
--0.237882,  -0.484537,  -0.303846,
--0.211570,  0.684685,  0.539195,
-0.064373,  0.236576,  0.042304,
-0.347794,  0.726175,  -0.126887,
-};
+signed char gain_cdbk_lbr[] = {
+-32,-32,-32,
+-31,-58,-16,
+-41,-24,-43,
+-56,-22,-55,
+-13,33,-41,
+-4,-39,-9,
+-41,15,-12,
+-8,-15,-12,
+1,2,-44,
+-22,-66,-42,
+-38,28,-23,
+-21,14,-37,
+0,21,-50,
+-53,-71,-27,
+-37,-1,-19,
+-19,-5,-28,
+6,65,-44,
+-33,-48,-33,
+-40,57,-14,
+-17,4,-45,
+-31,38,-33,
+-23,28,-40,
+-43,29,-12,
+-34,13,-23,
+-16,15,-27,
+-14,-82,-15,
+-31,25,-32,
+-21,5,-5,
+-47,-63,-51,
+-46,12,3,
+-28,-17,-29,
+-10,14,-40};

<p><p>1.73      +23 -18    speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- ltp.c	25 Jan 2003 05:45:48 -0000	1.72
+++ ltp.c	28 Jan 2003 06:52:40 -0000	1.73
@@ -165,7 +165,7 @@
    float A[3][3];
    float gain[3];
    int   gain_cdbk_size;
-   float *gain_cdbk;
+   signed char *gain_cdbk;
    float err1,err2;
 
    ltp_params *params;
@@ -216,7 +216,7 @@
    
    {
       float C[9];
-      float *ptr=gain_cdbk;
+      signed char *ptr=gain_cdbk;
       int best_cdbk=0;
       float best_sum=0;
       C[0]=corr[2];
@@ -232,16 +232,21 @@
       for (i=0;i<gain_cdbk_size;i++)
       {
          float sum=0;
+         float g0,g1,g2;
          ptr = gain_cdbk+3*i;
-         sum += C[0]*ptr[0];
-         sum += C[1]*ptr[1];
-         sum += C[2]*ptr[2];
-         sum -= C[3]*ptr[0]*ptr[1];
-         sum -= C[4]*ptr[2]*ptr[1];
-         sum -= C[5]*ptr[2]*ptr[0];
-         sum -= .5*C[6]*ptr[0]*ptr[0];
-         sum -= .5*C[7]*ptr[1]*ptr[1];
-         sum -= .5*C[8]*ptr[2]*ptr[2];
+         g0=0.015625*ptr[0]+.5;
+         g1=0.015625*ptr[1]+.5;
+         g2=0.015625*ptr[2]+.5;
+
+         sum += C[0]*g0;
+         sum += C[1]*g1;
+         sum += C[2]*g2;
+         sum -= C[3]*g0*g1;
+         sum -= C[4]*g2*g1;
+         sum -= C[5]*g2*g0;
+         sum -= .5*C[6]*g0*g0;
+         sum -= .5*C[7]*g1*g1;
+         sum -= .5*C[8]*g2*g2;
 
          /* If 1, force "safe" pitch values to handle packet loss better */
          if (0) {
@@ -260,9 +265,9 @@
             best_cdbk=i;
          }
       }
-      gain[0] = gain_cdbk[best_cdbk*3];
-      gain[1] = gain_cdbk[best_cdbk*3+1];
-      gain[2] = gain_cdbk[best_cdbk*3+2];
+      gain[0] = 0.015625*gain_cdbk[best_cdbk*3]  + .5;
+      gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;
+      gain[2] = 0.015625*gain_cdbk[best_cdbk*3+2]+ .5;
 
       *cdbk_index=best_cdbk;
    }
@@ -428,7 +433,7 @@
    int pitch;
    int gain_index;
    float gain[3];
-   float *gain_cdbk;
+   signed char *gain_cdbk;
    ltp_params *params;
    params = (ltp_params*) par;
    gain_cdbk=params->gain_cdbk;
@@ -437,9 +442,9 @@
    pitch += start;
    gain_index = speex_bits_unpack_unsigned(bits, params->gain_bits);
    /*printf ("decode pitch: %d %d\n", pitch, gain_index);*/
-   gain[0] = gain_cdbk[gain_index*3];
-   gain[1] = gain_cdbk[gain_index*3+1];
-   gain[2] = gain_cdbk[gain_index*3+2];
+   gain[0] = 0.015625*gain_cdbk[gain_index*3]+.5;
+   gain[1] = 0.015625*gain_cdbk[gain_index*3+1]+.5;
+   gain[2] = 0.015625*gain_cdbk[gain_index*3+2]+.5;
 
    if (count_lost && pitch > subframe_offset)
    {

<p><p>1.33      +1 -1      speex/libspeex/ltp.h

Index: ltp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- ltp.h	23 Jan 2003 07:29:39 -0000	1.32
+++ ltp.h	28 Jan 2003 06:52:40 -0000	1.33
@@ -34,7 +34,7 @@
 
 
 typedef struct ltp_params {
-   float  *gain_cdbk;
+   signed char *gain_cdbk;
    int     gain_bits;
    int     pitch_bits;
 } ltp_params;

<p><p>1.102     +2 -2      speex/libspeex/modes.c

Index: modes.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/modes.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- modes.c	27 Jan 2003 08:31:45 -0000	1.101
+++ modes.c	28 Jan 2003 06:52:40 -0000	1.102
@@ -48,8 +48,8 @@
 SpeexMode *speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
 
 /* Extern declarations for all codebooks we use here */
-extern float gain_cdbk_nb[];
-extern float gain_cdbk_lbr[];
+extern signed char gain_cdbk_nb[];
+extern signed char gain_cdbk_lbr[];
 extern signed char hexc_table[];
 extern signed char exc_5_256_table[];
 extern signed char exc_5_64_table[];

<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