crappy wideband codec at 28.5 kbps...
authorjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Tue, 19 Mar 2002 07:37:57 +0000 (07:37 +0000)
committerjmvalin <jmvalin@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Tue, 19 Mar 2002 07:37:57 +0000 (07:37 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@3164 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/Makefile.am
libspeex/cb_search.c
libspeex/exc_gains_wb2_table.c [new file with mode: 0644]
libspeex/modes.c
libspeex/modes.h
libspeex/speex.c
libspeex/speex.h

index 3fba14c..3368c3f 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in. -*-Makefile-*-
 
-# $Id: Makefile.am,v 1.14 2002/03/18 05:25:25 jmvalin Exp $
+# $Id: Makefile.am,v 1.15 2002/03/19 07:37:57 jmvalin Exp $
 
 # Disable automatic dependency tracking if using other tools than gcc and gmake
 #AUTOMAKE_OPTIONS = no-dependencies
@@ -25,6 +25,7 @@ libspeex_la_SOURCES = speex.c \
        exc_wb_table.c \
        exc_gains_table.c \
        exc_gains_wb_table.c \
+       exc_gains_wb2_table.c \
        vq.c
 
 
index d1cad93..30b1131 100644 (file)
@@ -37,7 +37,7 @@
 #include "stack_alloc.h"
 #include "vq.h"
 
-
+extern float exc_gains_wb2_table[];
 /*---------------------------------------------------------------------------*\
                                                                              
  void overlap_cb_search()                                                            
@@ -127,8 +127,6 @@ int   nsf                       /* number of samples in subframe */
 }
 
 
-
-
 void split_cb_search(
 float target[],                        /* target vector */
 float ak[],                    /* LPCs for this subframe */
@@ -251,25 +249,39 @@ float *stack
          frame_bits_pack(bits,max_index,3);
 
          /*Vector quantize gains[i]*/
-#if 1
+         if (nb_subvect<=5)
+         {
          best_vq_index = vq_index(gains, gain_cb, nb_subvect, gain_cb_size);
          frame_bits_pack(bits,best_vq_index,params->gain_bits);
          printf ("best_gains_vq_index %d %f %d\n", best_vq_index, min_dist, max_index);
          for (i=0;i<nb_subvect;i++)
             gains[i]= sign[i]*gain_cb[best_vq_index*nb_subvect+i]/max_gain/(Ee[ind[i]]+.001);
-#else
+         } else
+         {
+            float tmp[5];
+            int best_vq_index2;
          best_vq_index = vq_index(gains, gain_cb, nb_subvect/2, gain_cb_size);
+         for (i=0;i<5;i++)
+            tmp[i]=gains[i]-gain_cb[best_vq_index*nb_subvect/2+i];
+         best_vq_index2 = vq_index(tmp, exc_gains_wb2_table, nb_subvect/2, 256);
+
          frame_bits_pack(bits,best_vq_index,params->gain_bits);
          printf ("best_gains_vq_index %d %f %d\n", best_vq_index, min_dist, max_index);
          for (i=0;i<nb_subvect/2;i++)
-            gains[i]= sign[i]*gain_cb[best_vq_index*nb_subvect+i]/max_gain/(Ee[ind[i]]+.001);
+            gains[i]= sign[i]*(gain_cb[best_vq_index*nb_subvect/2+i]+exc_gains_wb2_table[best_vq_index2*nb_subvect/2+i])/max_gain/(Ee[ind[i]]+.001);
+
 
          best_vq_index = vq_index(gains+5, gain_cb, nb_subvect/2, gain_cb_size);
          frame_bits_pack(bits,best_vq_index,params->gain_bits);
+         for (i=0;i<5;i++)
+            tmp[i]=gains[i+5]-gain_cb[best_vq_index*nb_subvect/2+i];
+         best_vq_index2 = vq_index(tmp, exc_gains_wb2_table, nb_subvect/2, 256);
+
          printf ("best_gains_vq_index %d %f %d\n", best_vq_index, min_dist, max_index);
          for (i=0;i<nb_subvect/2;i++)
-            gains[i+5]= sign[i+5]*gain_cb[best_vq_index*nb_subvect+i]/max_gain/(Ee[ind[i+5]]+.001);
-#endif
+            gains[i+5]= sign[i+5]*(gain_cb[best_vq_index*nb_subvect/2+i]+exc_gains_wb2_table[best_vq_index2*nb_subvect/2+i])/max_gain/(Ee[ind[i+5]]+.001);
+         }
+
     
 
          POP(stack);
@@ -303,6 +315,7 @@ float *stack
    POP(stack);
 }
 
+
 void split_cb_unquant(
 float *exc,
 void *par,                      /* non-overlapping codebook */
diff --git a/libspeex/exc_gains_wb2_table.c b/libspeex/exc_gains_wb2_table.c
new file mode 100644 (file)
index 0000000..6aca3b0
--- /dev/null
@@ -0,0 +1,256 @@
+float exc_gains_wb2_table[256][5]={{-0.118248,-0.0903213,0.160174,-0.00123334,-0.21934},
+{0.0505919,-0.0288106,0.113996,0.0903071,-0.00984134},
+{0.113899,0.0433762,0.0882876,-0.0475371,0.054177},
+{0.0287272,0.0557836,-0.00316624,-0.00900847,-0.118819},
+{0.169872,-0.0428092,-0.187625,-0.0316026,0.192647},
+{0.0167698,-0.142869,-0.0351879,0.265943,-0.0151464},
+{-0.0439277,0.0326567,0.0561901,-0.0317043,0.0802247},
+{0.236985,0.0123511,-0.0784394,0.0999724,-0.000952686},
+{-0.142704,0.0920849,-0.0689582,-0.216057,0.145676},
+{0.0870207,0.0781122,0.162467,0.0399935,0.132958},
+{-0.128981,-0.0322974,0.0975815,-0.192499,-0.127642},
+{-0.102565,0.0270426,-0.127481,0.241065,-0.03122},
+{-0.031502,0.0855054,-0.042886,-0.0460144,0.130236},
+{-0.0942379,-0.0666479,0.018312,-0.0035047,0.101889},
+{0.119479,-0.0830763,0.103715,-0.103599,0.136849},
+{0.116035,-0.115112,-0.11395,0.0527047,-0.051518},
+{0.0851824,0.0296121,0.0979554,-0.0176937,-0.0838851},
+{-0.0112637,0.028357,0.0369974,0.0105319,-0.0231346},
+{0.121805,0.0930936,-0.00238656,0.0863224,-0.0727254},
+{-0.0432159,-0.0528344,-0.209758,-0.0481518,0.0781262},
+{0.0248402,0.0336596,0.0237071,-0.192787,0.13139},
+{0.126233,-0.072863,-0.0467142,0.0464679,0.109896},
+{0.170159,-0.17628,0.182159,-0.14398,-0.0677172},
+{0.191179,0.021901,-0.164383,0.211337,0.107637},
+{-0.160441,-0.129184,-0.164481,-0.0581384,-0.0482571},
+{-0.00853661,0.109003,0.0868082,0.0574961,0.0500668},
+{-0.109208,0.195432,0.113082,-0.188925,-0.0272042},
+{-0.0299113,-0.0692338,0.0743079,0.14364,-0.0928262},
+{-0.0594452,0.00192586,-0.0398129,0.0028896,0.0505964},
+{-0.194273,-0.181545,-0.100771,0.0257618,0.16813},
+{0.0232689,-0.165526,0.0938331,-0.0170004,0.0503893},
+{0.115822,0.0488415,-0.0185969,-0.100979,-0.113991},
+{-0.0881329,-0.154451,-0.150513,0.141348,-0.169259},
+{-0.0967658,0.0316989,0.15287,0.207056,-0.113766},
+{0.0288717,0.222654,0.0992637,-0.108253,0.203114},
+{0.149484,0.170655,0.0330888,-0.0228212,-0.13421},
+{0.151065,0.193866,0.0325463,0.109316,0.115277},
+{-0.0833898,-0.0723221,-0.108558,0.0713306,0.0150844},
+{-0.123702,-0.0347264,-0.0161615,-0.0769248,0.21856},
+{0.0850155,0.0358546,-0.111971,0.172465,-0.0381443},
+{-0.00562417,0.0637628,-0.0880934,-0.0930861,-0.0854997},
+{-0.0743979,-0.0691272,0.0790718,0.0997547,0.209345},
+{-0.0966082,-0.0529807,0.0990055,-0.0560605,-0.0616145},
+{-0.113037,-0.0149218,-0.194147,0.0931876,-0.0973557},
+{0.0333043,0.118144,0.0640649,-0.0455162,0.11294},
+{-0.150547,-0.203358,0.167846,0.165407,-0.0506945},
+{0.215828,0.0206265,0.127525,0.141395,0.0328834},
+{0.171978,0.199465,-0.148811,0.0608004,-0.0363784},
+{0.207549,0.0567694,0.00271488,0.111912,-0.225866},
+{0.0155828,0.149448,0.242043,-0.0861693,0.0510899},
+{0.0888324,0.10938,0.07555,0.0142276,-0.0216691},
+{0.0214858,0.171821,-0.0244336,-0.0760368,-0.0824601},
+{0.0414856,-0.00586913,-0.0997506,-0.00577843,0.120878},
+{0.206369,-0.201865,-0.0216558,0.130528,0.142588},
+{-0.183288,-0.192407,0.178432,-0.0646742,-0.0618598},
+{-0.049987,0.22806,-0.127391,0.179344,0.0497315},
+{-0.108284,-0.0479562,-0.0635562,-0.0832492,0.0205858},
+{-0.0948941,0.0868876,-0.0408448,0.226686,0.187384},
+{0.0251597,0.08785,0.071672,-0.141627,-0.133452},
+{-0.155272,0.231644,-0.0209745,-0.0133405,-0.062469},
+{-0.0836352,0.131699,-0.0986062,0.0511172,0.112163},
+{0.0893659,-0.193779,0.00118796,-0.179715,0.00102202},
+{0.119815,-0.0858676,0.0934043,-0.0284529,-0.0302291},
+{0.0310123,-0.00273832,-0.185191,-0.138868,-0.106802},
+{-0.00197316,-0.0625116,0.0356324,0.0373121,-0.0913948},
+{0.0469119,-0.115567,0.013378,0.0512016,-0.00884529},
+{-0.0054091,0.14038,0.0786078,-0.0434374,-0.0334637},
+{0.142066,0.103044,-0.0165019,-0.0255876,0.00274315},
+{0.186876,0.147007,-0.0810922,-0.139466,0.186235},
+{-0.0335924,-0.0913917,-0.00179792,0.134602,0.0222772},
+{-0.189227,-0.1338,0.0606105,-0.137663,0.0726223},
+{0.223312,-0.146251,-0.00913947,0.15792,-0.0921836},
+{-0.237208,0.0788275,-0.00364851,-0.137355,0.0177244},
+{0.113999,-0.0294367,0.112812,0.218815,0.197584},
+{-0.0923468,-0.0160347,0.0377776,0.00664991,-0.138003},
+{-0.0138741,0.0193135,0.0164956,0.20613,0.020337},
+{-0.0614057,0.0770052,0.00462154,-0.0770676,0.0117294},
+{-0.00976218,-0.0324956,0.0846505,0.0717681,0.089268},
+{0.197169,-0.0861648,-0.0393096,-0.202897,0.133087},
+{0.0543078,-0.025779,-0.0784255,-0.0383263,-0.071554},
+{0.00346738,0.0918708,0.0889084,0.0733931,-0.117767},
+{0.0180189,-0.00725124,0.12383,-0.0206228,0.0229105},
+{0.0540825,0.086697,0.111825,0.141422,-0.00640936},
+{-0.0735588,0.0334725,-0.135384,-0.00238102,-0.0119568},
+{0.0778553,-0.0388443,-0.0860914,-0.131339,0.0227053},
+{0.0266403,-0.0852892,-0.0992023,-0.00763189,0.0356529},
+{0.00799259,-0.103089,0.0501901,-0.0677319,-0.101507},
+{0.0489552,0.0960309,-0.181675,0.0209609,0.0690927},
+{-0.0350492,-0.0869723,-0.117222,-0.0763548,-0.03173},
+{-0.0203635,0.0408595,0.00286856,0.0968222,0.103525},
+{-0.113889,0.112892,0.0742673,0.0281804,-0.063894},
+{-0.141711,0.0132815,0.0191571,-0.0186625,-0.00306751},
+{-0.0267719,-0.112676,-0.120889,0.064112,0.227007},
+{-0.0777065,-0.113766,-0.092422,-0.0108326,0.0968495},
+{0.0338721,-0.0694403,0.0371834,-0.110895,0.0595546},
+{0.233015,-0.0093755,0.0307845,-0.0208098,0.0466165},
+{0.0187611,-0.276649,-0.0356151,-0.0282908,0.0544491},
+{0.0997084,-0.197142,0.139543,0.138167,-0.00540141},
+{0.177072,0.041443,0.0769368,-0.180746,-0.00228053},
+{0.0342045,0.110077,-0.124734,0.00300083,-0.164575},
+{0.118184,-0.00621488,-0.0177149,-0.0733277,0.0962981},
+{-0.060397,0.0164447,-0.24464,0.173789,0.130628},
+{-0.0754428,-0.0365944,0.230153,-0.144083,0.0101652},
+{0.027001,0.0293775,0.0095744,0.112659,-0.0472224},
+{-0.145668,0.109364,-0.177459,-0.0381539,-0.148942},
+{-0.0278113,0.0288286,0.179824,-0.0107439,0.275314},
+{-0.0380222,-0.167598,0.0994236,-0.141864,-0.0543759},
+{-0.0393469,0.0302542,-0.0790297,0.049888,-0.109961},
+{-0.201511,0.166796,0.188599,-0.0172545,0.149758},
+{-0.193334,-0.201259,-0.0500669,0.0493143,-0.0727459},
+{0.251968,-0.118383,0.200768,-0.0195926,0.0904261},
+{0.0289901,-0.0248818,-0.163649,0.0332636,-0.0656504},
+{0.164211,0.00118964,0.230827,0.0419142,-0.102895},
+{-0.215429,-0.0414835,0.0926556,0.0669367,-0.07967},
+{-0.0307506,0.138865,0.184538,0.212962,0.113124},
+{0.108699,0.1417,-0.152162,-0.127156,-0.0141149},
+{-0.0722352,0.0677319,-0.20078,-0.0562445,0.215757},
+{0.0697919,-0.170059,0.105691,0.0437521,0.212155},
+{-0.0585262,-0.151522,0.0438088,-0.0896096,0.15222},
+{0.0309129,0.202446,-0.0377962,0.001907,0.0555512},
+{-0.00289158,-0.0254041,-0.0392423,0.0623743,-0.00261949},
+{-0.0924203,0.0306853,0.0784937,0.121956,0.012477},
+{-0.0045806,-0.0170649,0.185222,-0.0886237,-0.127234},
+{-0.0625116,0.15723,0.0233099,0.195328,-0.048966},
+{-0.280417,0.125247,-0.0293725,0.123373,0.0369287},
+{0.0866752,-0.154833,-0.194282,-0.129443,0.0390598},
+{0.0891091,0.0249416,0.0335585,0.0929396,0.0755667},
+{0.0119323,-0.053161,-0.0295525,-0.134307,-0.0748131},
+{-0.0846423,-0.159101,-0.00308256,-0.0317854,-0.187703},
+{0.0189504,-0.0974639,0.165927,0.010335,-0.0669706},
+{0.0934099,-0.0401971,0.209317,-0.0872991,0.0246268},
+{-0.00359445,0.137584,-0.0205745,0.067999,-0.0611908},
+{0.147272,-0.0421384,-0.143954,-0.0368442,0.0271839},
+{0.0421469,-0.0360598,-0.0600746,0.170344,0.145347},
+{-0.0203904,-0.0158103,0.137789,-0.071433,0.137754},
+{0.0916375,0.00349815,-0.0857336,0.0687138,0.0317099},
+{-0.0424813,-0.113985,-0.0590368,-0.201567,0.0395139},
+{0.0316336,-0.0200706,0.0330931,-0.0152883,0.144802},
+{-0.207718,0.0568574,0.161737,-0.0825114,-0.0906158},
+{-0.146887,0.104078,-0.0858594,0.0936961,-0.0731951},
+{-0.0470482,0.160163,-0.0668586,-0.147814,0.0284234},
+{-0.061808,-0.15783,-0.0210107,-0.0495429,0.0113599},
+{0.153672,0.0648023,0.188418,-0.180681,0.184214},
+{0.211429,-0.17088,-0.0535839,-0.0247789,-0.131494},
+{0.0352645,-0.0115695,0.0804035,0.0168668,-0.208683},
+{-0.0541791,0.0153687,0.128841,0.0477276,-0.0713366},
+{0.131821,0.159715,-0.0281126,0.234108,-0.0542472},
+{-0.104645,0.0383343,-0.169126,-0.158743,-0.0189743},
+{0.0426111,0.0342361,-0.172954,-0.170265,0.122879},
+{0.0121114,-0.0866013,-0.0163905,0.0444945,0.107004},
+{0.0837522,-0.207279,0.120954,-0.0122023,-0.171522},
+{0.0946501,0.146836,-0.165315,0.119598,0.203275},
+{-0.0855449,-0.0257687,-0.10755,-0.0638105,-0.122213},
+{-0.100735,0.105633,0.00765256,0.0786506,0.0496864},
+{-0.056502,0.159621,0.193012,-0.0629858,-0.134093},
+{-0.138256,-0.0699661,-0.0162787,0.150332,-0.0636841},
+{-0.0735093,0.00373668,-0.103763,0.0465298,0.127709},
+{-0.143947,-0.112512,-0.132902,-0.147266,0.108412},
+{0.103288,-0.0650844,0.0940859,0.0378152,0.0826279},
+{0.055988,0.0598786,0.0067025,-0.0837237,-0.024286},
+{-0.0147287,-0.0672451,-0.0799861,0.142243,-0.0782013},
+{0.0488559,-0.0971178,0.244845,0.159864,-0.170948},
+{0.115222,0.201341,0.0292798,-0.146891,0.0200016},
+{0.152591,0.163476,-0.098961,-0.153761,-0.192124},
+{0.125596,0.0817735,-0.0576625,0.0175927,0.120742},
+{-0.0264798,-0.177993,-0.168879,0.0371509,-0.0153855},
+{-0.141536,0.052748,0.160385,-0.180193,0.1676},
+{0.117999,-0.0626229,-0.195904,0.211675,-0.150182},
+{-0.104018,0.125576,-0.0530812,-0.178902,-0.1383},
+{-0.17696,0.00374954,0.0917941,0.0197422,0.079975},
+{-0.0492265,-0.0748854,0.0411042,-0.0633745,0.00473631},
+{-0.137732,-0.0145727,-0.0559519,0.0774897,-0.220439},
+{-0.0915724,0.0737896,0.0579136,0.0157323,0.167938},
+{-0.15875,-0.151377,0.052411,0.0680781,0.0575547},
+{0.192015,0.00930675,0.0473749,0.0301401,0.215313},
+{0.163065,0.028092,-0.109934,0.00276047,-0.111297},
+{0.211405,-0.014898,0.0706439,-0.0485663,-0.128365},
+{-0.0735221,0.0531558,0.18108,0.0505551,0.086096},
+{0.0379808,0.0795417,0.193889,0.0282139,-0.0335529},
+{0.0442296,0.0502351,-0.0399216,-0.230638,-0.0355739},
+{0.0511992,0.0185631,-0.0267206,-0.11195,0.255986},
+{0.116278,-0.187006,-0.193574,0.104807,0.0963592},
+{-0.0796247,-0.0910838,0.13973,-0.0236921,0.0570298},
+{-0.012659,0.153795,-0.183274,0.129534,-0.101718},
+{-0.042893,-0.029388,-0.0314668,-0.0427583,-0.0536977},
+{-0.0782101,0.243769,0.039591,0.106455,0.174727},
+{0.092894,-0.087995,0.0640747,-0.172245,-0.188958},
+{-0.204312,0.128097,0.0547843,0.157636,-0.203402},
+{-0.17678,0.147208,-0.228526,0.0278318,0.0502795},
+{0.0552183,-0.129317,-0.0477975,-0.0654259,-0.0244198},
+{0.122497,-0.0109398,0.00490269,0.029181,-0.0221199},
+{0.154953,-0.0526826,-0.110481,-0.147433,-0.114739},
+{-0.0814938,-0.15216,0.0806935,0.0379707,-0.0791998},
+{0.110613,-0.0698286,-0.00689732,0.143655,0.0175145},
+{0.0214549,0.0858973,0.104745,-0.135563,0.0250991},
+{0.0661632,0.0763365,-0.0891647,0.00507962,-0.0319421},
+{0.217674,0.0628425,-0.100356,-0.0953654,0.0168884},
+{-0.1129,-0.0408577,-0.0291854,0.116409,0.0996814},
+{-0.108905,-0.0110996,0.0627132,-0.124285,0.0644265},
+{0.121377,-0.0562659,0.0767151,0.091977,-0.0989605},
+{-0.124304,0.062933,-0.0863845,-0.0704085,0.0716253},
+{-0.032042,-0.0827936,0.148869,0.173134,0.0566336},
+{-0.198434,0.0115822,-0.0205161,-0.0617167,-0.1283},
+{-0.050366,0.0502487,-0.091483,0.117861,0.0136856},
+{-0.0749119,0.0183143,-0.00743906,-0.155241,-0.0275047},
+{-0.0716606,-0.0650685,0.0683313,0.0570523,0.00614789},
+{0.170217,-0.154612,-0.00797698,-0.0373634,0.0535267},
+{0.0829654,-0.0713311,-0.00478617,-0.0137013,-0.124468},
+{-0.0628004,0.145008,0.0357808,-0.0391233,-0.239912},
+{-0.0794881,0.0586379,0.137579,-0.0588676,0.00481111},
+{0.107436,0.0114506,0.103155,0.240589,-0.0964913},
+{-0.0378529,0.119217,-0.0668421,-0.00570637,0.00387393},
+{-0.00562167,0.0216612,-0.092992,-0.0915635,0.0213126},
+{0.0207835,-0.0761744,-0.141375,0.119864,0.0477221},
+{0.0458936,-0.0252219,0.0854023,-0.108242,-0.0536257},
+{0.051886,0.116353,-0.0511672,0.121298,0.0458216},
+{0.0359931,-0.166556,-0.118295,-0.0814767,-0.135671},
+{0.0253774,0.0698017,-0.0195229,0.064894,0.227343},
+{-0.061009,0.0511503,0.0579108,-0.0776525,-0.0925163},
+{-0.098085,0.0240004,-0.00545791,0.0753657,-0.0552257},
+{-0.221028,0.0902189,-0.0495172,0.0307082,0.237697},
+{-0.0332626,-0.0411516,-0.0508722,-0.0910603,0.112237},
+{0.0421978,-0.0327166,-0.000771736,-0.0284324,0.0194985},
+{0.137238,-0.0419911,-0.01056,-0.0845596,-0.0326973},
+{0.0188133,-0.192993,-0.0246451,0.07936,-0.0836802},
+{0.0201842,-0.15399,0.0217178,0.174981,-0.20902},
+{0.207279,0.174621,0.168776,-0.00713064,0.000885962},
+{0.0170264,0.267317,-0.063856,0.0713687,-0.17105},
+{0.0624021,0.0918137,-0.0562975,-0.0873559,0.0754395},
+{-0.1528,-0.149471,-0.143195,0.199454,0.0703591},
+{0.0268299,-0.0535574,0.119328,-0.242533,0.00818973},
+{0.0807057,-0.0283622,-0.0507313,0.0942948,-0.119937},
+{-0.0919717,0.0879579,-0.0490018,-0.0383224,-0.0813515},
+{-0.172421,-0.149647,0.212398,0.0239194,0.165925},
+{-0.120685,-0.109185,-0.0230932,-0.122668,-0.0822865},
+{0.0510037,-0.0558475,-0.129015,0.0147875,-0.229606},
+{-0.098109,0.168955,0.0490106,-0.0545812,0.0772269},
+{-0.108299,-0.0858775,-0.0263694,0.0199443,-0.0362012},
+{0.0401172,-0.0879589,0.26063,0.0674477,0.0975288},
+{0.0993497,-0.00156441,-0.295087,0.0351,-0.0709351},
+{0.0598115,0.173527,0.187665,0.130056,-0.214068},
+{-0.110694,-0.0224932,0.246397,0.0549758,-0.0380774},
+{-0.173647,0.199207,0.182867,0.12095,-0.0483334},
+{-0.040217,0.191711,-0.181361,-0.0698609,-0.0406225},
+{-0.0156589,0.238328,-0.113888,-0.0824466,0.172756},
+{-0.0229313,-0.188714,-3.74661e-05,0.123303,0.0980829},
+{0.00587689,-0.190791,0.182726,-0.194,0.170508},
+{0.0242901,0.252354,0.0886593,0.0572889,-0.0223712},
+{-0.0339953,-0.0909718,-0.0723043,0.0265104,-0.101172},
+{-0.201602,-0.0196106,0.0875607,0.215563,0.112039},
+{0.133278,0.103058,0.197293,-0.164694,-0.148155},
+{-0.00263098,0.0668595,-0.0281583,0.164603,-0.174486},
+{-0.210904,-0.0175887,-0.108181,0.0336131,0.0365998},
+{0.0576604,-0.136688,-0.0711227,-0.0813818,0.165383},
+{0.0357962,0.0664384,-0.00584431,0.0175678,0.0475538},
+{-0.00922982,-0.0128747,-0.0305928,-0.109736,-0.190979}};
index f4c527f..04f5c27 100644 (file)
@@ -56,7 +56,7 @@ split_cb_params split_cb_wb = {
    10,              /*nb_subvect*/
    exc_wb_table,    /*shape_cb*/
    7,               /*shape_bits*/
-   NULL/*exc_gains_wb_table*/, /*gain_cb*/
+   exc_gains_wb_table, /*gain_cb*/
    8                /*gain_bits*/
 };
 
@@ -73,6 +73,7 @@ SpeexMode nb_mode = {
    0.6,    /*gamma2*/
    .005,
    1.0001,
+   0.0,
    /*LSP quantization*/
    lsp_quant_nb,
    lsp_unquant_nb,
@@ -99,7 +100,8 @@ SpeexMode wb_mode = {
    0.9,    /*gamma1*/
    0.6,    /*gamma2*/
    .002,
-   1.00002,
+   1.00001,
+   0.0,
    /*LSP quantization*/
    lsp_quant_wb,
    lsp_unquant_wb,
index 1e9e079..af668c3 100644 (file)
@@ -58,6 +58,7 @@ typedef struct SpeexMode {
    float   gamma2;
    float   lag_factor;
    float   lpc_floor;
+   float   preemph;
    /*LSP functions*/
    lsp_quant_func    lsp_quant;
    lsp_unquant_func  lsp_unquant;
index 2a4875f..1280174 100644 (file)
@@ -55,6 +55,8 @@ void encoder_init(EncState *st, SpeexMode *mode)
    st->max_pitch=mode->pitchEnd;
    st->lag_factor=mode->lag_factor;
    st->lpc_floor = mode->lpc_floor;
+   st->preemph = mode->preemph;
+  
 
    st->lsp_quant = mode->lsp_quant;
    st->ltp_quant = mode->ltp_quant;
@@ -62,6 +64,8 @@ void encoder_init(EncState *st, SpeexMode *mode)
    st->innovation_quant = mode->innovation_quant;
    st->innovation_params = mode->innovation_params;
 
+   st->pre_mem=0;
+   st->pre_mem2=0;
 
    /* Over-sampling filter (fractional pitch)*/
    st->os_fact=4;
@@ -106,7 +110,7 @@ void encoder_init(EncState *st, SpeexMode *mode)
 
    st->autocorr = malloc((st->lpcSize+1)*sizeof(float));
 
-   st->stack = calloc(10000, sizeof(float));
+   st->stack = calloc(20000, sizeof(float));
 
    st->buf2 = malloc(st->windowSize*sizeof(float));
 
@@ -167,8 +171,11 @@ void encode(EncState *st, float *in, FrameBits *bits)
 
    /* Copy new data in input buffer */
    memmove(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
-   for (i=0;i<st->frameSize;i++)
-      st->inBuf[st->bufSize-st->frameSize+i] = in[i];
+   st->inBuf[st->bufSize-st->frameSize] = in[0] - st->preemph*st->pre_mem;
+   for (i=1;i<st->frameSize;i++)
+      st->inBuf[st->bufSize-st->frameSize+i] = in[i] - st->preemph*in[i-1];
+   st->pre_mem = in[st->frameSize-1];
+
    memmove(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
    memmove(st->swBuf, st->swBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
 
@@ -264,6 +271,10 @@ void encode(EncState *st, float *in, FrameBits *bits)
       bw_lpc(st->gamma1, st->interp_lpc, st->bw_lpc1, st->lpcSize);
       bw_lpc(st->gamma2, st->interp_lpc, st->bw_lpc2, st->lpcSize);
       
+      /*for (i=1;i<=st->lpcSize;i++)
+         st->bw_lpc2[i]=0;
+      st->bw_lpc2[1]=-st->preemph;*/
+
       /* Reset excitation */
       for (i=0;i<st->subframeSize;i++)
          exc[i]=0;
@@ -317,28 +328,29 @@ void encode(EncState *st, float *in, FrameBits *bits)
       snr = 10*log10((esig+1)/(enoise+1));
       printf ("pitch SNR = %f\n", snr);
 
-#if 1 /*If set to 1, compute "real innovation" i.e. cheat to get perfect reconstruction*/
+#if 0 /*If set to 1, compute "real innovation" i.e. cheat to get perfect reconstruction*/
       syn_filt_zero(target, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
       residue_zero(res, st->interp_qlpc, st->buf2, st->subframeSize, st->lpcSize);
       residue_zero(st->buf2, st->bw_lpc2, st->buf2, st->subframeSize, st->lpcSize);
-      if (snr>9 && (rand()%10==0))
+      if (1||(snr>9 && (rand()%10==0)))
       {
          printf ("exc ");
          for (i=0;i<st->subframeSize;i++)
          {
-            if (i && i%8==0)
+            if (0&&i && i%8==0)
                printf ("\nexc ");
             printf ("%f ", st->buf2[i]);
          }
          printf ("\n");
       }
-      /*for (i=0;i<st->subframeSize;i++)
+      for (i=0;i<st->subframeSize;i++)
          exc[i]+=st->buf2[i];
-#else*/
+#else
       /* Perform a split-codebook search */
       st->innovation_quant(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
                            st->innovation_params, st->lpcSize,
                            st->subframeSize, exc, bits, st->stack);
+
 #endif
       /* Compute weighted noise energy and SNR */
       enoise=0;
@@ -372,8 +384,10 @@ void encode(EncState *st, float *in, FrameBits *bits)
    st->first = 0;
 
    /* Replace input by synthesized speech */
-   for (i=0;i<st->frameSize;i++)
-     in[i]=st->frame[i];
+   in[0] = st->frame[0] + st->preemph*st->pre_mem2;
+   for (i=1;i<st->frameSize;i++)
+     in[i]=st->frame[i] + st->preemph*in[i-1];
+   st->pre_mem2=in[st->frameSize-1];
 }
 
 
index 445dde1..1741c3f 100644 (file)
@@ -40,7 +40,10 @@ typedef struct EncState {
    float  gamma2;         /* Perceptual filter: A(z/gamma2) */
    float  lag_factor;     /* Lag windowing gaussian width */
    float  lpc_floor;      /* Noise floor multiplier for A[0] in LPC analysis*/
-   float *stack;          /* Pseudo-stack allocation */
+   float  preemph;        /* Pre-emphasis: P(z) = 1 - a*z^-1*/
+   float  pre_mem;        /* 1-element memory for pre-emphasis */
+   float  pre_mem2;       /* 1-element memory for pre-emphasis */
+   float *stack;          /* Pseudo-stack allocation for temporary memory */
    int    os_fact;        /* Over-sampling factor for fractional pitch */
    int    os_filt_ord2;   /* Over-sampling filter size for fractional pitch */
    float *os_exc;         /* Over-sampled excitation for fractional pitch */