Home | History | Annotate | Download | only in source
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #include "pitch_lag_tables.h"
     12 #include "settings.h"
     13 
     14 /* header file for coding tables for the pitch filter side-info in the entropy coder */
     15 /********************* Pitch Filter Gain Coefficient Tables ************************/
     16 
     17 /* tables for use with small pitch gain */
     18 
     19 /* cdf for quantized pitch filter lags */
     20 const uint16_t WebRtcIsac_kQPitchLagCdf1Lo[127] = {
     21  0,  134,  336,  549,  778,  998,  1264,  1512,  1777,  2070,
     22  2423,  2794,  3051,  3361,  3708,  3979,  4315,  4610,  4933,  5269,
     23  5575,  5896,  6155,  6480,  6816,  7129,  7477,  7764,  8061,  8358,
     24  8718,  9020,  9390,  9783,  10177,  10543,  10885,  11342,  11795,  12213,
     25  12680,  13096,  13524,  13919,  14436,  14903,  15349,  15795,  16267,  16734,
     26  17266,  17697,  18130,  18632,  19080,  19447,  19884,  20315,  20735,  21288,
     27  21764,  22264,  22723,  23193,  23680,  24111,  24557,  25022,  25537,  26082,
     28  26543,  27090,  27620,  28139,  28652,  29149,  29634,  30175,  30692,  31273,
     29  31866,  32506,  33059,  33650,  34296,  34955,  35629,  36295,  36967,  37726,
     30  38559,  39458,  40364,  41293,  42256,  43215,  44231,  45253,  46274,  47359,
     31  48482,  49678,  50810,  51853,  53016,  54148,  55235,  56263,  57282,  58363,
     32  59288,  60179,  61076,  61806,  62474,  63129,  63656,  64160,  64533,  64856,
     33  65152,  65535,  65535,  65535,  65535,  65535,  65535};
     34 
     35 const uint16_t WebRtcIsac_kQPitchLagCdf2Lo[20] = {
     36  0,  429,  3558,  5861,  8558,  11639,  15210,  19502,  24773,  31983,
     37  42602,  48567,  52601,  55676,  58160,  60172,  61889,  63235,  65383,  65535};
     38 
     39 const uint16_t WebRtcIsac_kQPitchLagCdf3Lo[2] = {
     40  0,  65535};
     41 
     42 const uint16_t WebRtcIsac_kQPitchLagCdf4Lo[10] = {
     43  0,  2966,  6368,  11182,  19431,  37793,  48532,  55353,  60626,  65535};
     44 
     45 const uint16_t *WebRtcIsac_kQPitchLagCdfPtrLo[4] = {WebRtcIsac_kQPitchLagCdf1Lo, WebRtcIsac_kQPitchLagCdf2Lo, WebRtcIsac_kQPitchLagCdf3Lo, WebRtcIsac_kQPitchLagCdf4Lo};
     46 
     47 /* size of first cdf table */
     48 const uint16_t WebRtcIsac_kQPitchLagCdfSizeLo[1] = {128};
     49 
     50 /* index limits and ranges */
     51 const int16_t WebRtcIsac_kQIndexLowerLimitLagLo[4] = {
     52 -140, -9,  0, -4};
     53 
     54 const int16_t WebRtcIsac_kQIndexUpperLimitLagLo[4] = {
     55 -20,  9,  0,  4};
     56 
     57 /* initial index for arithmetic decoder */
     58 const uint16_t WebRtcIsac_kQInitIndexLagLo[3] = {
     59  10,  1,  5};
     60 
     61 /* mean values of pitch filter lags */
     62 const double WebRtcIsac_kQMeanLag2Lo[19] = {
     63 -17.21385070, -15.82678944, -14.07123081, -12.03003877, -10.01311864, -8.00794627, -5.91162987, -3.89231876, -1.90220980, -0.01879275,
     64  1.89144232,  3.88123171,  5.92146992,  7.96435361,  9.98923648,  11.98266347,  13.96101002,  15.74855713,  17.10976611};
     65 
     66 const double WebRtcIsac_kQMeanLag3Lo[1] = {
     67  0.00000000};
     68 
     69 const double WebRtcIsac_kQMeanLag4Lo[9] = {
     70 -7.76246496, -5.92083980, -3.94095226, -1.89502305,  0.03724681,  1.93054221,  3.96443467,  5.91726366,  7.78434291};
     71 
     72 const double WebRtcIsac_kQPitchLagStepsizeLo = 2.000000;
     73 
     74 
     75 /* tables for use with medium pitch gain */
     76 
     77 /* cdf for quantized pitch filter lags */
     78 const uint16_t WebRtcIsac_kQPitchLagCdf1Mid[255] = {
     79  0,  28,  61,  88,  121,  149,  233,  331,  475,  559,
     80  624,  661,  689,  712,  745,  791,  815,  843,  866,  922,
     81  959,  1024,  1061,  1117,  1178,  1238,  1280,  1350,  1453,  1513,
     82  1564,  1625,  1671,  1741,  1788,  1904,  2072,  2421,  2626,  2770,
     83  2840,  2900,  2942,  3012,  3068,  3115,  3147,  3194,  3254,  3319,
     84  3366,  3520,  3678,  3780,  3850,  3911,  3957,  4032,  4106,  4185,
     85  4292,  4474,  4683,  4842,  5019,  5191,  5321,  5428,  5540,  5675,
     86  5763,  5847,  5959,  6127,  6304,  6564,  6839,  7090,  7263,  7421,
     87  7556,  7728,  7872,  7984,  8142,  8361,  8580,  8743,  8938,  9227,
     88  9409,  9539,  9674,  9795,  9930,  10060,  10177,  10382,  10614,  10861,
     89  11038,  11271,  11415,  11629,  11792,  12044,  12193,  12416,  12574,  12821,
     90  13007,  13235,  13445,  13654,  13901,  14134,  14488,  15000,  15703,  16285,
     91  16504,  16797,  17086,  17328,  17579,  17807,  17998,  18268,  18538,  18836,
     92  19087,  19274,  19474,  19716,  19935,  20270,  20833,  21303,  21532,  21741,
     93  21978,  22207,  22523,  22770,  23054,  23613,  23943,  24204,  24399,  24651,
     94  24832,  25074,  25270,  25549,  25759,  26015,  26150,  26424,  26713,  27048,
     95  27342,  27504,  27681,  27854,  28021,  28207,  28412,  28664,  28859,  29064,
     96  29278,  29548,  29748,  30107,  30377,  30656,  30856,  31164,  31452,  31755,
     97  32011,  32328,  32626,  32919,  33319,  33789,  34329,  34925,  35396,  35973,
     98  36443,  36964,  37551,  38156,  38724,  39357,  40023,  40908,  41587,  42602,
     99  43924,  45037,  45810,  46597,  47421,  48291,  49092,  50051,  51448,  52719,
    100  53440,  54241,  54944,  55977,  56676,  57299,  57872,  58389,  59059,  59688,
    101  60237,  60782,  61094,  61573,  61890,  62290,  62658,  63030,  63217,  63454,
    102  63622,  63882,  64003,  64273,  64427,  64529,  64581,  64697,  64758,  64902,
    103  65414,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,
    104  65535,  65535,  65535,  65535,  65535};
    105 
    106 const uint16_t WebRtcIsac_kQPitchLagCdf2Mid[36] = {
    107  0,  71,  335,  581,  836,  1039,  1323,  1795,  2258,  2608,
    108  3005,  3591,  4243,  5344,  7163,  10583,  16848,  28078,  49448,  57007,
    109  60357,  61850,  62837,  63437,  63872,  64188,  64377,  64614,  64774,  64949,
    110  65039,  65115,  65223,  65360,  65474,  65535};
    111 
    112 const uint16_t WebRtcIsac_kQPitchLagCdf3Mid[2] = {
    113  0,  65535};
    114 
    115 const uint16_t WebRtcIsac_kQPitchLagCdf4Mid[20] = {
    116  0,  28,  246,  459,  667,  1045,  1523,  2337,  4337,  11347,
    117  44231,  56709,  60781,  62243,  63161,  63969,  64608,  65062,  65502,  65535};
    118 
    119 const uint16_t *WebRtcIsac_kQPitchLagCdfPtrMid[4] = {WebRtcIsac_kQPitchLagCdf1Mid, WebRtcIsac_kQPitchLagCdf2Mid, WebRtcIsac_kQPitchLagCdf3Mid, WebRtcIsac_kQPitchLagCdf4Mid};
    120 
    121 /* size of first cdf table */
    122 const uint16_t WebRtcIsac_kQPitchLagCdfSizeMid[1] = {256};
    123 
    124 /* index limits and ranges */
    125 const int16_t WebRtcIsac_kQIndexLowerLimitLagMid[4] = {
    126 -280, -17,  0, -9};
    127 
    128 const int16_t WebRtcIsac_kQIndexUpperLimitLagMid[4] = {
    129 -40,  17,  0,  9};
    130 
    131 /* initial index for arithmetic decoder */
    132 const uint16_t WebRtcIsac_kQInitIndexLagMid[3] = {
    133  18,  1,  10};
    134 
    135 /* mean values of pitch filter lags */
    136 const double WebRtcIsac_kQMeanLag2Mid[35] = {
    137 -16.89183900, -15.86949778, -15.05476653, -14.00664348, -13.02793036, -12.07324237, -11.00542532, -10.11250602, -8.90792971, -8.02474753,
    138 -7.00426767, -5.94055287, -4.98251338, -3.91053158, -2.98820425, -1.93524245, -0.92978085, -0.01722509,  0.91317387,  1.92973955,
    139  2.96908851,  3.93728974,  4.96308471,  5.92244151,  7.08673497,  8.00993708,  9.04656316,  9.98538742,  10.97851694,  11.94772884,
    140  13.02426166,  14.00039951,  15.01347042,  15.80758023,  16.94086895};
    141 
    142 const double WebRtcIsac_kQMeanLag3Mid[1] = {
    143  0.00000000};
    144 
    145 const double WebRtcIsac_kQMeanLag4Mid[19] = {
    146 -8.60409403, -7.89198395, -7.03450280, -5.86260421, -4.93822322, -3.93078706, -2.91302322, -1.91824007, -0.87003282,  0.02822649,
    147  0.89951758,  1.87495484,  2.91802604,  3.96874074,  5.06571703,  5.93618227,  7.00520185,  7.88497726,  8.64160364};
    148 
    149 const double WebRtcIsac_kQPitchLagStepsizeMid = 1.000000;
    150 
    151 
    152 /* tables for use with large pitch gain */
    153 
    154 /* cdf for quantized pitch filter lags */
    155 const uint16_t WebRtcIsac_kQPitchLagCdf1Hi[511] = {
    156  0,  7,  18,  33,  69,  105,  156,  228,  315,  612,
    157  680,  691,  709,  724,  735,  738,  742,  746,  749,  753,
    158  756,  760,  764,  774,  782,  785,  789,  796,  800,  803,
    159  807,  814,  818,  822,  829,  832,  847,  854,  858,  869,
    160  876,  883,  898,  908,  934,  977,  1010,  1050,  1060,  1064,
    161  1075,  1078,  1086,  1089,  1093,  1104,  1111,  1122,  1133,  1136,
    162  1151,  1162,  1183,  1209,  1252,  1281,  1339,  1364,  1386,  1401,
    163  1411,  1415,  1426,  1430,  1433,  1440,  1448,  1455,  1462,  1477,
    164  1487,  1495,  1502,  1506,  1509,  1516,  1524,  1531,  1535,  1542,
    165  1553,  1556,  1578,  1589,  1611,  1625,  1639,  1643,  1654,  1665,
    166  1672,  1687,  1694,  1705,  1708,  1719,  1730,  1744,  1752,  1759,
    167  1791,  1795,  1820,  1867,  1886,  1915,  1936,  1943,  1965,  1987,
    168  2041,  2099,  2161,  2175,  2200,  2211,  2226,  2233,  2244,  2251,
    169  2266,  2280,  2287,  2298,  2309,  2316,  2331,  2342,  2356,  2378,
    170  2403,  2418,  2447,  2497,  2544,  2602,  2863,  2895,  2903,  2935,
    171  2950,  2971,  3004,  3011,  3018,  3029,  3040,  3062,  3087,  3127,
    172  3152,  3170,  3199,  3243,  3293,  3322,  3340,  3377,  3402,  3427,
    173  3474,  3518,  3543,  3579,  3601,  3637,  3659,  3706,  3731,  3760,
    174  3818,  3847,  3869,  3901,  3920,  3952,  4068,  4169,  4220,  4271,
    175  4524,  4571,  4604,  4632,  4672,  4730,  4777,  4806,  4857,  4904,
    176  4951,  5002,  5031,  5060,  5107,  5150,  5212,  5266,  5331,  5382,
    177  5432,  5490,  5544,  5610,  5700,  5762,  5812,  5874,  5972,  6022,
    178  6091,  6163,  6232,  6305,  6402,  6540,  6685,  6880,  7090,  7271,
    179  7379,  7452,  7542,  7625,  7687,  7770,  7843,  7911,  7966,  8024,
    180  8096,  8190,  8252,  8320,  8411,  8501,  8585,  8639,  8751,  8842,
    181  8918,  8986,  9066,  9127,  9203,  9269,  9345,  9406,  9464,  9536,
    182  9612,  9667,  9735,  9844,  9931,  10036,  10119,  10199,  10260,  10358,
    183  10441,  10514,  10666,  10734,  10872,  10951,  11053,  11125,  11223,  11324,
    184  11516,  11664,  11737,  11816,  11892,  12008,  12120,  12200,  12280,  12392,
    185  12490,  12576,  12685,  12812,  12917,  13003,  13108,  13210,  13300,  13384,
    186  13470,  13579,  13673,  13771,  13879,  13999,  14136,  14201,  14368,  14614,
    187  14759,  14867,  14958,  15030,  15121,  15189,  15280,  15385,  15461,  15555,
    188  15653,  15768,  15884,  15971,  16069,  16145,  16210,  16279,  16380,  16463,
    189  16539,  16615,  16688,  16818,  16919,  17017,  18041,  18338,  18523,  18649,
    190  18790,  18917,  19047,  19167,  19315,  19460,  19601,  19731,  19858,  20068,
    191  20173,  20318,  20466,  20625,  20741,  20911,  21045,  21201,  21396,  21588,
    192  21816,  22022,  22305,  22547,  22786,  23072,  23322,  23600,  23879,  24168,
    193  24433,  24769,  25120,  25511,  25895,  26289,  26792,  27219,  27683,  28077,
    194  28566,  29094,  29546,  29977,  30491,  30991,  31573,  32105,  32594,  33173,
    195  33788,  34497,  35181,  35833,  36488,  37255,  37921,  38645,  39275,  39894,
    196  40505,  41167,  41790,  42431,  43096,  43723,  44385,  45134,  45858,  46607,
    197  47349,  48091,  48768,  49405,  49955,  50555,  51167,  51985,  52611,  53078,
    198  53494,  53965,  54435,  54996,  55601,  56125,  56563,  56838,  57244,  57566,
    199  57967,  58297,  58771,  59093,  59419,  59647,  59886,  60143,  60461,  60693,
    200  60917,  61170,  61416,  61634,  61891,  62122,  62310,  62455,  62632,  62839,
    201  63103,  63436,  63639,  63805,  63906,  64015,  64192,  64355,  64475,  64558,
    202  64663,  64742,  64811,  64865,  64916,  64956,  64981,  65025,  65068,  65115,
    203  65195,  65314,  65419,  65535,  65535,  65535,  65535,  65535,  65535,  65535,
    204  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,
    205  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,
    206  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,  65535,
    207  65535};
    208 
    209 const uint16_t WebRtcIsac_kQPitchLagCdf2Hi[68] = {
    210  0,  7,  11,  22,  37,  52,  56,  59,  81,  85,
    211  89,  96,  115,  130,  137,  152,  170,  181,  193,  200,
    212  207,  233,  237,  259,  289,  318,  363,  433,  592,  992,
    213  1607,  3062,  6149,  12206,  25522,  48368,  58223,  61918,  63640,  64584,
    214  64943,  65098,  65206,  65268,  65294,  65335,  65350,  65372,  65387,  65402,
    215  65413,  65420,  65428,  65435,  65439,  65450,  65454,  65468,  65472,  65476,
    216  65483,  65491,  65498,  65505,  65516,  65520,  65528,  65535};
    217 
    218 const uint16_t WebRtcIsac_kQPitchLagCdf3Hi[2] = {
    219  0,  65535};
    220 
    221 const uint16_t WebRtcIsac_kQPitchLagCdf4Hi[35] = {
    222  0,  7,  19,  30,  41,  48,  63,  74,  82,  96,
    223  122,  152,  215,  330,  701,  2611,  10931,  48106,  61177,  64341,
    224  65112,  65238,  65309,  65338,  65364,  65379,  65401,  65427,  65453,  65465,
    225  65476,  65490,  65509,  65528,  65535};
    226 
    227 const uint16_t *WebRtcIsac_kQPitchLagCdfPtrHi[4] = {WebRtcIsac_kQPitchLagCdf1Hi, WebRtcIsac_kQPitchLagCdf2Hi, WebRtcIsac_kQPitchLagCdf3Hi, WebRtcIsac_kQPitchLagCdf4Hi};
    228 
    229 /* size of first cdf table */
    230 const uint16_t WebRtcIsac_kQPitchLagCdfSizeHi[1] = {512};
    231 
    232 /* index limits and ranges */
    233 const int16_t WebRtcIsac_kQindexLowerLimitLagHi[4] = {
    234 -552, -34,  0, -16};
    235 
    236 const int16_t WebRtcIsac_kQindexUpperLimitLagHi[4] = {
    237 -80,  32,  0,  17};
    238 
    239 /* initial index for arithmetic decoder */
    240 const uint16_t WebRtcIsac_kQInitIndexLagHi[3] = {
    241  34,  1,  18};
    242 
    243 /* mean values of pitch filter lags */
    244 const double WebRtcIsac_kQMeanLag2Hi[67] = {
    245 -17.07263295, -16.50000000, -15.83966081, -15.55613708, -14.96948007, -14.50000000, -14.00000000, -13.48377986, -13.00000000, -12.50000000,
    246 -11.93199636, -11.44530414, -11.04197641, -10.39910301, -10.15202337, -9.51322461, -8.93357741, -8.46456632, -8.10270672, -7.53751847,
    247 -6.98686404, -6.50000000, -6.08463150, -5.46872991, -5.00864717, -4.50163760, -4.01382410, -3.43856708, -2.96898001, -2.46554810,
    248 -1.96861004, -1.47106701, -0.97197237, -0.46561654, -0.00531409,  0.45767857,  0.96777907,  1.47507903,  1.97740425,  2.46695420,
    249  3.00695774,  3.47167185,  4.02712538,  4.49280007,  5.01087640,  5.48191963,  6.04916550,  6.51511058,  6.97297819,  7.46565499,
    250  8.01489405,  8.39912001,  8.91819757,  9.50000000,  10.11654065,  10.50000000,  11.03712583,  11.50000000,  12.00000000,  12.38964346,
    251  12.89466127,  13.43657881,  13.96013840,  14.46279912,  15.00000000,  15.39412269,  15.96662441};
    252 
    253 const double WebRtcIsac_kQMeanLag3Hi[1] = {
    254  0.00000000};
    255 
    256 const double WebRtcIsac_kQMeanLag4Hi[34] = {
    257 -7.98331221, -7.47988769, -7.03626557, -6.52708003, -6.06982173, -5.51856292, -5.05827033, -4.45909878, -3.99125864, -3.45308135,
    258 -3.02328139, -2.47297273, -1.94341995, -1.44699056, -0.93612243, -0.43012406,  0.01120357,  0.44054812,  0.93199883,  1.45669587,
    259  1.97218322,  2.50187419,  2.98748690,  3.49343202,  4.01660147,  4.50984306,  5.01402683,  5.58936797,  5.91787793,  6.59998900,
    260  6.85034315,  7.53503316,  7.87711194,  8.53631648};
    261 
    262 const double WebRtcIsac_kQPitchLagStepsizeHi = 0.500000;
    263 
    264 /* transform matrix */
    265 const double WebRtcIsac_kTransform[4][4] = {
    266 {-0.50000000, -0.50000000, -0.50000000, -0.50000000},
    267 { 0.67082039,  0.22360680, -0.22360680, -0.67082039},
    268 { 0.50000000, -0.50000000, -0.50000000,  0.50000000},
    269 { 0.22360680, -0.67082039,  0.67082039, -0.22360680}};
    270 
    271 /* transpose transform matrix */
    272 const double WebRtcIsac_kTransformTranspose[4][4] = {
    273 {-0.50000000,  0.67082039,  0.50000000,  0.22360680},
    274 {-0.50000000,  0.22360680, -0.50000000, -0.67082039},
    275 {-0.50000000, -0.22360680, -0.50000000,  0.67082039},
    276 {-0.50000000, -0.67082039,  0.50000000, -0.22360680}};
    277 
    278