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 "spectrum_ar_model_tables.h"
     12 #include "settings.h"
     13 
     14 /********************* AR Coefficient Tables ************************/
     15 /* cdf for quantized reflection coefficient 1 */
     16 const uint16_t WebRtcIsac_kQArRc1Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
     17  0,  2,  4,  129,  7707,  57485,  65495,  65527,  65529,  65531,
     18  65533,  65535};
     19 
     20 /* cdf for quantized reflection coefficient 2 */
     21 const uint16_t WebRtcIsac_kQArRc2Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
     22  0,  2,  4,  7,  531,  25298,  64525,  65526,  65529,  65531,
     23  65533,  65535};
     24 
     25 /* cdf for quantized reflection coefficient 3 */
     26 const uint16_t WebRtcIsac_kQArRc3Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
     27  0,  2,  4,  6,  620,  22898,  64843,  65527,  65529,  65531,
     28  65533,  65535};
     29 
     30 /* cdf for quantized reflection coefficient 4 */
     31 const uint16_t WebRtcIsac_kQArRc4Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
     32  0,  2,  4,  6,  35,  10034,  60733,  65506,  65529,  65531,
     33  65533,  65535};
     34 
     35 /* cdf for quantized reflection coefficient 5 */
     36 const uint16_t WebRtcIsac_kQArRc5Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
     37  0,  2,  4,  6,  36,  7567,  56727,  65385,  65529,  65531,
     38  65533,  65535};
     39 
     40 /* cdf for quantized reflection coefficient 6 */
     41 const uint16_t WebRtcIsac_kQArRc6Cdf[NUM_AR_RC_QUANT_BAUNDARY] = {
     42  0,  2,  4,  6,  14,  6579,  57360,  65409,  65529,  65531,
     43  65533,  65535};
     44 
     45 /* representation levels for quantized reflection coefficient 1 */
     46 const int16_t WebRtcIsac_kQArRc1Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
     47  -32104, -29007, -23202, -15496, -9279, -2577, 5934, 17535, 24512, 29503, 32104
     48 };
     49 
     50 /* representation levels for quantized reflection coefficient 2 */
     51 const int16_t WebRtcIsac_kQArRc2Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
     52  -32104, -29503, -23494, -15261, -7309, -1399, 6158, 16381, 24512, 29503, 32104
     53 };
     54 
     55 /* representation levels for quantized reflection coefficient 3 */
     56 const int16_t WebRtcIsac_kQArRc3Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
     57 -32104, -29503, -23157, -15186, -7347, -1359, 5829, 17535, 24512, 29503, 32104
     58 };
     59 
     60 /* representation levels for quantized reflection coefficient 4 */
     61 const int16_t WebRtcIsac_kQArRc4Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
     62 -32104, -29503, -24512, -15362, -6665, -342, 6596, 14585, 24512, 29503, 32104
     63 };
     64 
     65 /* representation levels for quantized reflection coefficient 5 */
     66 const int16_t WebRtcIsac_kQArRc5Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
     67 -32104, -29503, -24512, -15005, -6564, -106, 7123, 14920, 24512, 29503, 32104
     68 };
     69 
     70 /* representation levels for quantized reflection coefficient 6 */
     71 const int16_t WebRtcIsac_kQArRc6Levels[NUM_AR_RC_QUANT_BAUNDARY - 1] = {
     72 -32104, -29503, -24512, -15096, -6656, -37, 7036, 14847, 24512, 29503, 32104
     73 };
     74 
     75 /* quantization boundary levels for reflection coefficients */
     76 const int16_t WebRtcIsac_kQArBoundaryLevels[NUM_AR_RC_QUANT_BAUNDARY] = {
     77 -32768, -31441, -27566, -21458, -13612, -4663, 4663, 13612, 21458, 27566, 31441,
     78 32767
     79 };
     80 
     81 /* initial index for AR reflection coefficient quantizer and cdf table search */
     82 const uint16_t WebRtcIsac_kQArRcInitIndex[6] = {
     83  5,  5,  5,  5,  5,  5};
     84 
     85 /* pointers to AR cdf tables */
     86 const uint16_t *WebRtcIsac_kQArRcCdfPtr[AR_ORDER] = {
     87   WebRtcIsac_kQArRc1Cdf, WebRtcIsac_kQArRc2Cdf, WebRtcIsac_kQArRc3Cdf,
     88   WebRtcIsac_kQArRc4Cdf, WebRtcIsac_kQArRc5Cdf, WebRtcIsac_kQArRc6Cdf
     89 };
     90 
     91 /* pointers to AR representation levels tables */
     92 const int16_t *WebRtcIsac_kQArRcLevelsPtr[AR_ORDER] = {
     93   WebRtcIsac_kQArRc1Levels, WebRtcIsac_kQArRc2Levels, WebRtcIsac_kQArRc3Levels,
     94   WebRtcIsac_kQArRc4Levels, WebRtcIsac_kQArRc5Levels, WebRtcIsac_kQArRc6Levels
     95 };
     96 
     97 
     98 /******************** GAIN Coefficient Tables ***********************/
     99 /* cdf for Gain coefficient */
    100 const uint16_t WebRtcIsac_kQGainCdf[19] = {
    101  0,  2,  4,  6,  8,  10,  12,  14,  16,  1172,
    102  11119,  29411,  51699,  64445,  65527,  65529,  65531,  65533,  65535};
    103 
    104 /* representation levels for quantized squared Gain coefficient */
    105 const int32_t WebRtcIsac_kQGain2Levels[18] = {
    106 // 17, 28, 46, 76, 128, 215, 364, 709, 1268, 1960, 3405, 6078, 11286, 17827, 51918, 134498, 487432, 2048000};
    107  128, 128, 128, 128, 128, 215, 364, 709, 1268, 1960, 3405, 6078, 11286, 17827, 51918, 134498, 487432, 2048000};
    108 /* quantization boundary levels for squared Gain coefficient */
    109 const int32_t WebRtcIsac_kQGain2BoundaryLevels[19] = {
    110 0, 21, 35, 59, 99, 166, 280, 475, 815, 1414, 2495, 4505, 8397, 16405, 34431, 81359, 240497, 921600, 0x7FFFFFFF};
    111 
    112 /* pointers to Gain cdf table */
    113 const uint16_t *WebRtcIsac_kQGainCdf_ptr[1] = {WebRtcIsac_kQGainCdf};
    114 
    115 /* Gain initial index for gain quantizer and cdf table search */
    116 const uint16_t WebRtcIsac_kQGainInitIndex[1] = {11};
    117 
    118 /************************* Cosine Tables ****************************/
    119 /* Cosine table */
    120 const int16_t WebRtcIsac_kCos[6][60] = {
    121 {512,  512,  511,  510,  508,  507,  505,  502,  499,  496,  493,  489,  485,  480,  476,  470,  465,  459,  453,  447,
    122 440,  433,  426,  418,  410,  402,  394,  385,  376,  367,  357,  348,  338,  327,  317,  306,  295,  284,  273,  262,
    123 250,  238,  226,  214,  202,  190,  177,  165,  152,  139,  126,  113,  100,  87,  73,  60,  47,  33,  20,  7},
    124 {512,  510,  508,  503,  498,  491,  483,  473,  462,  450,  437,  422,  406,  389,  371,  352,  333,  312,  290,  268,
    125 244,  220,  196,  171,  145,  120,  93,  67,  40,  13,  -13,  -40,  -67,  -93,  -120,  -145,  -171,  -196,  -220,  -244,
    126 -268,  -290,  -312,  -333,  -352,  -371,  -389,  -406,  -422,  -437,  -450,  -462,  -473,  -483,  -491,  -498,  -503,  -508,  -510,  -512},
    127 {512,  508,  502,  493,  480,  465,  447,  426,  402,  376,  348,  317,  284,  250,  214,  177,  139,  100,  60,  20,
    128 -20,  -60,  -100,  -139,  -177,  -214,  -250,  -284,  -317,  -348,  -376,  -402,  -426,  -447,  -465,  -480,  -493,  -502,  -508,  -512,
    129 -512,  -508,  -502,  -493,  -480,  -465,  -447,  -426,  -402,  -376,  -348,  -317,  -284,  -250,  -214,  -177,  -139,  -100,  -60,  -20},
    130 {511,  506,  495,  478,  456,  429,  398,  362,  322,  279,  232,  183,  133,  80,  27,  -27,  -80,  -133,  -183,  -232,
    131 -279,  -322,  -362,  -398,  -429,  -456,  -478,  -495,  -506,  -511,  -511,  -506,  -495,  -478,  -456,  -429,  -398,  -362,  -322,  -279,
    132 -232,  -183,  -133,  -80,  -27,  27,  80,  133,  183,  232,  279,  322,  362,  398,  429,  456,  478,  495,  506,  511},
    133 {511,  502,  485,  459,  426,  385,  338,  284,  226,  165,  100,  33,  -33,  -100,  -165,  -226,  -284,  -338,  -385,  -426,
    134 -459,  -485,  -502,  -511,  -511,  -502,  -485,  -459,  -426,  -385,  -338,  -284,  -226,  -165,  -100,  -33,  33,  100,  165,  226,
    135 284,  338,  385,  426,  459,  485,  502,  511,  511,  502,  485,  459,  426,  385,  338,  284,  226,  165,  100,  33},
    136 {510,  498,  473,  437,  389,  333,  268,  196,  120,  40,  -40,  -120,  -196,  -268,  -333,  -389,  -437,  -473,  -498,  -510,
    137 -510,  -498,  -473,  -437,  -389,  -333,  -268,  -196,  -120,  -40,  40,  120,  196,  268,  333,  389,  437,  473,  498,  510,
    138 510,  498,  473,  437,  389,  333,  268,  196,  120,  40,  -40,  -120,  -196,  -268,  -333,  -389,  -437,  -473,  -498,  -510}
    139 };
    140