Added a new 3.95 kbps mode
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Wed, 15 Jan 2003 06:47:42 +0000 (06:47 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Wed, 15 Jan 2003 06:47:42 +0000 (06:47 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@4244 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/Makefile.am
libspeex/exc_20_32_table.c [new file with mode: 0644]
libspeex/ltp.c
libspeex/modes.c
libspeex/nb_celp.c

index c731605..7214af8 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.47 2002/11/09 06:00:02 jm Exp $
+# $Id: Makefile.am,v 1.48 2003/01/15 06:47:42 jm Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -30,6 +30,7 @@ libspeex_la_SOURCES = nb_celp.c \
        exc_8_128_table.c \
        exc_10_32_table.c \
        exc_10_16_table.c \
+       exc_20_32_table.c \
        hexc_10_32_table.c \
        misc.c \
        speex_header.c \
diff --git a/libspeex/exc_20_32_table.c b/libspeex/exc_20_32_table.c
new file mode 100644 (file)
index 0000000..c0f3b0a
--- /dev/null
@@ -0,0 +1,33 @@
+float exc_20_32_table[32][20] = {
+{0.385835,0.992346,0.796313,1.446102,1.139713,1.017143,0.279276,0.425243,-0.106878,0.184183,0.038228,-0.245123,0.012730,-0.324168,-0.163760,-0.217982,-0.213392,-0.227542,-0.170264,-0.151936},
+{0.971193,-0.838796,0.761915,-1.001168,-0.131621,0.314058,-0.358956,0.668808,-0.087411,0.585429,0.717812,-0.296646,0.700731,0.762464,-0.310948,-0.016843,-0.320548,-0.421614,-0.209698,-0.336131},
+{1.300680,-1.036860,0.959123,0.599127,-0.249762,-0.007131,-0.309187,-0.496772,0.043369,-0.668863,-0.518291,0.316086,-0.242373,0.438656,0.249137,0.122018,0.355125,-0.057376,0.161573,-0.067216},
+{-1.025148,0.359204,-0.507815,1.032122,0.345914,-0.127016,0.284016,-0.138467,0.331290,0.054365,0.199766,-0.165487,0.242338,-0.142125,0.356631,-0.127905,-0.188290,0.811983,-1.129505,-0.496041},
+{0.011671,0.129687,-0.053924,-0.240914,0.372778,0.181264,-0.046397,1.065158,-1.452582,-0.696987,0.270583,0.289095,0.658603,0.288260,0.164672,-2.048077,-0.141369,0.821359,0.058932,0.323760},
+{0.408075,0.077340,0.588409,0.293135,0.375968,-2.516703,0.104592,0.393360,0.403192,-0.002328,-0.422742,0.690342,-1.106197,0.187115,-0.225966,-0.122861,0.190001,-0.194680,0.306107,-0.172453},
+{-0.955610,1.183418,-1.024461,0.010252,-0.318900,-0.342537,0.170888,-0.383625,0.381676,-0.530637,0.157411,0.013592,-0.186269,0.404311,-0.292379,0.296958,0.237922,0.794205,1.018358,0.077626},
+{-0.384395,0.259387,-0.201207,0.318145,-0.077994,0.669112,0.215683,0.537019,1.358154,0.151841,0.330280,-0.216059,-0.278106,-0.626328,-1.118496,-0.616814,-0.733059,-0.117618,-0.129731,-0.103909},
+{0.849610,-0.290472,-0.272329,-1.517342,-1.229773,-1.173713,-0.351210,-0.283009,0.172041,0.171681,0.703925,0.781676,0.159396,0.091620,0.083648,0.137389,0.032849,0.052800,-0.107164,-0.029171},
+{2.713863,1.207143,0.544065,-0.666989,-0.278257,-0.583533,-0.294948,-0.460758,-0.406373,-0.448269,-0.521434,-0.358012,-0.313450,-0.335205,-0.263591,-0.189493,-0.040122,-0.103973,-0.099783,-0.029992},
+{-1.691674,-1.066625,-0.831425,-0.256805,-0.343753,-0.123115,-0.156514,0.000917,-0.001975,0.117673,0.246964,0.201293,0.280475,0.217209,0.276448,0.231693,0.196328,0.167198,0.143119,0.153387},
+{1.514880,0.303884,0.603754,-0.310767,0.365980,-0.021511,0.284034,-0.088431,0.066848,0.164088,-0.081589,0.064552,-0.064324,-0.074085,-0.008105,-0.069918,-0.808197,0.190970,0.282203,-0.204342},
+{-0.502056,-0.275469,0.066395,0.205878,0.207856,-0.149065,-1.353599,0.348577,0.699642,-0.329322,-0.271779,1.061478,1.152068,-0.462842,-0.399558,-0.190709,0.037886,-0.030227,0.032629,0.029476},
+{-1.985638,1.765144,1.631739,-0.349145,-0.830419,0.143945,0.119901,0.081185,0.019313,0.064743,0.040646,0.078267,-0.018597,-0.131681,-0.140082,-0.296924,-0.231042,-0.129048,-0.131543,0.051739},
+{-0.030559,-0.231545,-0.221884,-0.377203,-0.323813,-0.460783,-0.295142,-0.157309,-0.148739,-0.333705,-0.505932,-0.393362,0.194903,0.495250,0.129282,-0.420668,-0.495023,-0.307201,-0.109728,0.065070},
+{-1.474353,-0.392089,0.779041,1.474723,0.590693,-0.429642,-0.617767,-0.239793,-0.537290,0.003881,-0.078881,-0.400310,0.046188,0.176495,-0.541946,-0.422946,0.461712,0.037270,0.303429,0.184004},
+{-0.759844,0.012397,-0.320760,0.585986,-2.140632,-0.242911,0.427647,1.524819,0.525373,-0.162524,1.027569,-0.894868,0.108914,-0.118797,-0.012699,0.050330,-0.237233,0.145058,-0.178383,0.074577},
+{3.759964,-1.736372,-0.361864,-1.456705,0.712682,-0.268598,0.198618,-0.143019,0.036373,0.066447,-0.145022,0.035130,-0.313634,0.113027,-0.030529,-0.029092,0.125707,-0.038351,0.013620,-0.081670},
+{0.940485,-1.623113,-2.090365,0.949771,0.689662,0.350968,-0.017770,-0.135986,0.106887,0.015180,0.216693,0.053881,0.014546,0.042327,-0.303911,-0.130736,-0.251271,-0.397434,0.146890,0.020686},
+{0.029633,-0.044113,0.159388,0.417427,-0.278814,-0.083593,-0.319607,-1.946398,0.698646,1.501474,-0.134252,-0.183153,0.077333,0.091292,0.160409,0.046381,0.037752,0.124384,0.020741,0.409460},
+{0.090864,-0.616610,0.306949,-0.284595,0.393090,-0.073778,-0.122314,0.294586,-0.621735,1.383154,-0.026121,0.627200,-1.008127,-2.091311,0.588945,0.007938,0.870969,0.335745,0.254418,0.059720},
+{-0.348770,0.455005,-0.604507,-1.657717,0.959462,0.064076,1.054576,0.297955,0.196952,-0.110019,-1.827442,0.264742,0.303143,0.404530,0.436989,0.044981,0.376071,0.074242,0.009656,-0.014408},
+{-4.262995,1.147041,-0.260538,1.370506,-0.277051,0.799494,-0.078401,0.550266,0.054289,0.190935,0.345641,-0.024946,0.266418,0.022031,0.142033,0.079121,0.007883,0.035092,0.041595,0.073067},
+{0.382906,0.099986,-0.074785,-0.107647,0.204940,0.768958,0.270952,0.555063,-0.184521,-1.169576,0.107498,-0.236252,-0.502023,0.097978,-0.302950,-0.215380,0.541929,-1.065573,-1.367053,0.349255},
+{0.521566,-0.462151,-0.085519,-0.494477,-0.042172,-0.398518,0.346581,-1.449019,-2.034899,-0.047868,0.255850,0.418121,0.049987,0.133044,0.133524,0.163043,0.472510,0.166609,0.274186,0.175704},
+{0.256274,0.072129,0.251612,0.092785,0.319909,-0.024228,0.097667,-0.092256,0.182805,-0.067163,0.097233,0.086064,-0.151065,0.297435,-0.358582,0.213001,0.194301,-0.072778,0.197981,-0.071450},
+{-0.269718,0.603940,-0.379499,0.375257,-0.886130,1.200993,0.910549,-0.028665,0.374531,0.071952,0.160101,0.719147,-0.297580,0.100560,0.113843,-0.481381,0.664543,-0.130710,0.103240,0.103560},
+{0.191717,0.535866,-0.280262,-0.113455,-0.262102,-0.633476,0.817274,0.161083,-0.314874,0.198765,0.023377,-0.582393,0.566044,-0.478782,-0.383030,1.471533,-0.172203,-0.053126,-0.204375,-0.265743},
+{-0.024458,-0.517485,-0.047456,-0.048482,-0.441589,0.928241,-0.433317,0.051121,-0.213779,-0.109931,-0.024182,-0.374648,0.349026,-0.785762,0.494592,-0.083353,-0.371568,0.359167,-0.228303,0.220736},
+{-0.521106,0.025764,0.596348,-0.876477,0.958118,-0.209415,-0.300574,0.227734,-0.322891,0.094214,0.382447,0.140715,-0.510845,0.179149,0.743704,1.285724,-0.909848,-1.685125,0.015615,0.028941},
+{0.228998,-0.020179,0.148300,-0.177826,0.414240,0.308158,-0.137401,-0.248048,0.237154,-0.280059,-0.853601,-1.668661,-1.183038,-0.023576,0.316119,0.599634,0.516425,0.503233,0.378773,0.361508},
+{-0.010699,0.102772,-0.217199,-0.118139,0.392144,0.377085,-0.955779,-0.434499,0.181432,-0.150895,0.105105,0.158355,0.523786,1.346176,1.571707,0.768078,0.301679,0.037410,-0.175212,-0.065956}};
index afbdf1c..f67ff58 100644 (file)
@@ -547,8 +547,8 @@ int complexity
 )
 {
    int i;
-   if (pitch_coef>.9)
-      pitch_coef=.9;
+   if (pitch_coef>.99)
+      pitch_coef=.99;
    for (i=0;i<nsf;i++)
    {
       exc[i]=exc[i-start]*pitch_coef;
@@ -574,8 +574,8 @@ float last_pitch_gain)
 {
    int i;
    /*pitch_coef=.9;*/
-   if (pitch_coef>.9)
-      pitch_coef=.9;
+   if (pitch_coef>.99)
+      pitch_coef=.99;
    for (i=0;i<nsf;i++)
    {
       exc[i]=exc[i-start]*pitch_coef;
index 66ef39f..e07000f 100644 (file)
@@ -56,6 +56,7 @@ extern float exc_5_64_table[];
 extern float exc_8_128_table[];
 extern float exc_10_32_table[];
 extern float exc_10_16_table[];
+extern float exc_20_32_table[];
 extern float hexc_10_32_table[];
 
 static int nb_mode_query(void *mode, int request, void *ptr);
@@ -91,13 +92,22 @@ static ltp_params ltp_params_med = {
 
 /* Split-VQ innovation parameters for very low bit-rate narrowband */
 static split_cb_params split_cb_nb_vlbr = {
-   10,               /*subvect_size*/
-   4,               /*nb_subvect*/
-   exc_10_16_table, /*shape_cb*/
+   20,               /*subvect_size*/
+   2,               /*nb_subvect*/
+   exc_10_32_table, /*shape_cb*/
    4,               /*shape_bits*/
    0,
 };
 
+/* Split-VQ innovation parameters for very low bit-rate narrowband */
+static split_cb_params split_cb_nb_ulbr = {
+   20,               /*subvect_size*/
+   2,               /*nb_subvect*/
+   exc_20_32_table, /*shape_cb*/
+   5,               /*shape_bits*/
+   0,
+};
+
 /* Split-VQ innovation parameters for low bit-rate narrowband */
 static split_cb_params split_cb_nb_lbr = {
    10,              /*subvect_size*/
@@ -175,6 +185,28 @@ static SpeexSubmode nb_submode1 = {
    43
 };
 
+/* 3.95 kbps very low bit-rate mode */
+static SpeexSubmode nb_submode8 = {
+   0,
+   1,
+   0,
+   0,
+   /*LSP quantization*/
+   lsp_quant_lbr,
+   lsp_unquant_lbr,
+   /*No pitch quantization*/
+   forced_pitch_quant,
+   forced_pitch_unquant,
+   NULL,
+   /*Innovation quantization*/
+   split_cb_search_shape_sign,
+   split_cb_shape_sign_unquant,
+   &split_cb_nb_ulbr,
+
+   0.7, 0.5, .65,
+   79
+};
+
 /* 5.95 kbps very low bit-rate mode */
 static SpeexSubmode nb_submode2 = {
    0,
@@ -322,9 +354,9 @@ static SpeexNBMode nb_mode = {
    1.0001, /*lpc_floor*/
    0.0,    /*preemph*/
    {NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7,
-   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+   &nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
    5,
-   {1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7}
+   {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
 };
 
 
index 51ca5de..ae28e4f 100644 (file)
@@ -1070,6 +1070,7 @@ int nb_decode(void *state, SpeexBits *bits, float *out)
             }
          }
 
+         /* FIXME: Check for overflow */
          m = speex_bits_unpack_unsigned(bits, 4);
          if (m==15) /* We found a terminator */
          {
@@ -1084,13 +1085,13 @@ int nb_decode(void *state, SpeexBits *bits, float *out)
             int ret = st->user_callback.func(bits, state, st->user_callback.data);
             if (ret)
                return ret;
-         } else if (m>7) /* Invalid mode */
+         } else if (m>8) /* Invalid mode */
          {
             speex_warning("Invalid mode encountered: corrupted stream?");
             return -2;
          }
       
-      } while (m>7);
+      } while (m>8);
 
       /* Get the sub-mode that was used */
       st->submodeID = m;