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