diff --git a/src/analysis.c b/src/analysis.c index a7a8919476928585e43957b6a68b4741d4a8b4f4..6742a85c82258cb97290de6ab5795800c05dae69 100644 --- a/src/analysis.c +++ b/src/analysis.c @@ -44,7 +44,7 @@ extern const MLP net; #define M_PI 3.141592653 #endif -float dct_table[128] = { +static const float dct_table[128] = { 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.351851, 0.338330, 0.311806, 0.273300, 0.224292, 0.166664, 0.102631, 0.034654, @@ -63,7 +63,7 @@ float dct_table[128] = { 0.224292, 0.311806, -0.102631, -0.351851, -0.034654, 0.338330, 0.166664, -0.273300, }; -float analysis_window[240] = { +static const float analysis_window[240] = { 0.000043f, 0.000171f, 0.000385f, 0.000685f, 0.001071f, 0.001541f, 0.002098f, 0.002739f, 0.003466f, 0.004278f, 0.005174f, 0.006156f, 0.007222f, 0.008373f, 0.009607f, 0.010926f, 0.012329f, 0.013815f, 0.015385f, 0.017037f, 0.018772f, 0.020590f, 0.022490f, 0.024472f, @@ -100,9 +100,9 @@ static const int tbands[NB_TBANDS+1] = { 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 68, 80, 96, 120 }; -static const float tweight[NB_TBANDS+1] = { +/*static const float tweight[NB_TBANDS+1] = { .3, .4, .5, .6, .7, .8, .9, 1., 1., 1., 1., 1., 1., 1., .8, .7, .6, .5 -}; +};*/ #define NB_TONAL_SKIP_BANDS 9 diff --git a/src/mlp.c b/src/mlp.c index 200f1cb3049cad077f00770ca7aa2a065af49a0d..dd3690dbd272b1648290db3a2f46bd1f9911fda1 100644 --- a/src/mlp.c +++ b/src/mlp.c @@ -64,16 +64,22 @@ static inline double tansig_approx(double x) { int i; double y, dy; - if (x>=10) - return 1; - if (x<=-10) - return -1; + double sign=1; + if (x>=8) + return 1; + if (x<=-8) + return -1; + if (x<0) + { + x=-x; + sign=-1; + } i = lrint(25*x); x -= .04*i; - y = tansig_table[250+i]; + y = tansig_table[i]; dy = 1-y*y; y = y + x*dy*(1 - y*x); - return y; + return sign*y; } #endif diff --git a/src/tansig_table.h b/src/tansig_table.h index ccf43daaadaca835cd8f3c4d85e0a41a8806d42f..a5aba23050b6584ec0bd514fbefbd423045d63eb 100644 --- a/src/tansig_table.h +++ b/src/tansig_table.h @@ -1,56 +1,6 @@ /* This file is auto-generated by gen_tables */ -static const opus_val16 tansig_table[501] = { --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -1.000000, -1.000000, -1.000000, -1.000000, --1.000000, -0.999999, -0.999999, -0.999999, -0.999999, --0.999999, -0.999999, -0.999999, -0.999999, -0.999999, --0.999999, -0.999999, -0.999999, -0.999999, -0.999998, --0.999998, -0.999998, -0.999998, -0.999998, -0.999998, --0.999997, -0.999997, -0.999997, -0.999997, -0.999997, --0.999996, -0.999996, -0.999996, -0.999995, -0.999995, --0.999994, -0.999994, -0.999994, -0.999993, -0.999992, --0.999992, -0.999991, -0.999990, -0.999990, -0.999989, --0.999988, -0.999987, -0.999986, -0.999984, -0.999983, --0.999982, -0.999980, -0.999978, -0.999977, -0.999975, --0.999973, -0.999970, -0.999968, -0.999965, -0.999962, --0.999959, -0.999956, -0.999952, -0.999948, -0.999944, --0.999939, -0.999934, -0.999929, -0.999923, -0.999916, --0.999909, -0.999902, -0.999893, -0.999885, -0.999875, --0.999865, -0.999853, -0.999841, -0.999828, -0.999813, --0.999798, -0.999781, -0.999763, -0.999743, -0.999722, --0.999699, -0.999673, -0.999646, -0.999617, -0.999585, --0.999550, -0.999513, -0.999472, -0.999428, -0.999381, --0.999329, -0.999273, -0.999213, -0.999147, -0.999076, --0.999000, -0.998916, -0.998826, -0.998728, -0.998623, --0.998508, -0.998384, -0.998249, -0.998104, -0.997946, --0.997775, -0.997590, -0.997389, -0.997172, -0.996937, --0.996682, -0.996407, -0.996108, -0.995784, -0.995434, --0.995055, -0.994644, -0.994199, -0.993718, -0.993196, --0.992631, -0.992020, -0.991359, -0.990642, -0.989867, --0.989027, -0.988119, -0.987136, -0.986072, -0.984921, --0.983675, -0.982327, -0.980869, -0.979293, -0.977587, --0.975743, -0.973749, -0.971594, -0.969265, -0.966747, --0.964028, -0.961090, -0.957917, -0.954492, -0.950795, --0.946806, -0.942503, -0.937863, -0.932862, -0.927473, --0.921669, -0.915420, -0.908698, -0.901468, -0.893698, --0.885352, -0.876393, -0.866784, -0.856485, -0.845456, --0.833655, -0.821040, -0.807569, -0.793199, -0.777888, --0.761594, -0.744277, -0.725897, -0.706419, -0.685809, --0.664037, -0.641077, -0.616909, -0.591519, -0.564900, --0.537050, -0.507977, -0.477700, -0.446244, -0.413644, --0.379949, -0.345214, -0.309507, -0.272905, -0.235496, --0.197375, -0.158649, -0.119427, -0.079830, -0.039979, +static const opus_val16 tansig_table[201] = { 0.000000, 0.039979, 0.079830, 0.119427, 0.158649, 0.197375, 0.235496, 0.272905, 0.309507, 0.345214, 0.379949, 0.413644, 0.446244, 0.477700, 0.507977, @@ -91,15 +41,5 @@ static const opus_val16 tansig_table[501] = { 0.999999, 0.999999, 0.999999, 0.999999, 0.999999, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, -1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000, };