12bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/***********************************************************************
22bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianCopyright (c) 2006-2011, Skype Limited. All rights reserved.
32bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianRedistribution and use in source and binary forms, with or without
42bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianmodification, are permitted provided that the following conditions
52bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianare met:
62bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian- Redistributions of source code must retain the above copyright notice,
72bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianthis list of conditions and the following disclaimer.
82bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian- Redistributions in binary form must reproduce the above copyright
92bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramaniannotice, this list of conditions and the following disclaimer in the
102bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramaniandocumentation and/or other materials provided with the distribution.
112bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian- Neither the name of Internet Society, IETF or IETF Trust, nor the
122bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramaniannames of specific contributors, may be used to endorse or promote
132bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianproducts derived from this software without specific prior written
142bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianpermission.
152bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
162bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
192bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
202bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
212bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
222bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
232bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
242bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
252bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh VenkatasubramanianPOSSIBILITY OF SUCH DAMAGE.
262bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian***********************************************************************/
272bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
282bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#ifdef HAVE_CONFIG_H
292bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#include "config.h"
302bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#endif
312bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
322bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#include "structs.h"
332bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#include "define.h"
342bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#include "tables.h"
352bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
362bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#ifdef __cplusplus
372bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianextern "C"
382bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{
392bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#endif
402bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
412bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Piece-wise linear mapping from bitrate in kbps to coding quality in dB SNR */
422bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int32 silk_TargetRate_table_NB[ TARGET_RATE_TAB_SZ ] = {
432bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    0,      8000,   9400,   11500,  13500,  17500,  25000,  MAX_TARGET_RATE_BPS
442bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
452bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int32 silk_TargetRate_table_MB[ TARGET_RATE_TAB_SZ ] = {
462bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    0,      9000,   12000,  14500,  18500,  24500,  35500,  MAX_TARGET_RATE_BPS
472bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
482bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int32 silk_TargetRate_table_WB[ TARGET_RATE_TAB_SZ ] = {
492bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    0,      10500,  14000,  17000,  21500,  28500,  42000,  MAX_TARGET_RATE_BPS
502bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
512bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int16 silk_SNR_table_Q1[ TARGET_RATE_TAB_SZ ] = {
522bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    18,     29,     38,     40,     46,     52,     62,     84
532bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
542bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
552bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Tables for stereo predictor coding */
562bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int16 silk_stereo_pred_quant_Q13[ STEREO_QUANT_TAB_SIZE ] = {
572bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    -13732, -10050, -8266, -7526, -6500, -5000, -2950,  -820,
582bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian       820,   2950,  5000,  6500,  7526,  8266, 10050, 13732
592bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
602bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8  silk_stereo_pred_joint_iCDF[ 25 ] = {
612bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    249, 247, 246, 245, 244,
622bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    234, 210, 202, 201, 200,
632bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    197, 174,  82,  59,  56,
642bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian     55,  54,  46,  22,  12,
652bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian     11,  10,   9,   7,   0
662bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
672bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8  silk_stereo_only_code_mid_iCDF[ 2 ] = { 64, 0 };
682bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
692bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Tables for LBRR flags */
702bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianstatic const opus_uint8 silk_LBRR_flags_2_iCDF[ 3 ] = { 203, 150, 0 };
712bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianstatic const opus_uint8 silk_LBRR_flags_3_iCDF[ 7 ] = { 215, 195, 166, 125, 110, 82, 0 };
722bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 * const silk_LBRR_flags_iCDF_ptr[ 2 ] = {
732bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    silk_LBRR_flags_2_iCDF,
742bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    silk_LBRR_flags_3_iCDF
752bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
762bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
772bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Table for LSB coding */
782bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_lsb_iCDF[ 2 ] = { 120, 0 };
792bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
802bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Tables for LTPScale */
812bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_LTPscale_iCDF[ 3 ] = { 128, 64, 0 };
822bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
832bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Tables for signal type and offset coding */
842bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_type_offset_VAD_iCDF[ 4 ] = {
852bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian       232,    158,    10,      0
862bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
872bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_type_offset_no_VAD_iCDF[ 2 ] = {
882bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian       230,      0
892bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
902bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
912bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Tables for NLSF interpolation factor */
922bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_NLSF_interpolation_factor_iCDF[ 5 ] = { 243, 221, 192, 181, 0 };
932bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
942bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Quantization offsets */
952bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int16  silk_Quantization_Offsets_Q10[ 2 ][ 2 ] = {
962bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian    { OFFSET_UVL_Q10, OFFSET_UVH_Q10 }, { OFFSET_VL_Q10, OFFSET_VH_Q10 }
972bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
982bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
992bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Table for LTPScale */
1002bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int16 silk_LTPScales_table_Q14[ 3 ] = { 15565, 12288, 8192 };
1012bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
1022bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Uniform entropy tables */
1032bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_uniform3_iCDF[ 3 ] = { 171, 85, 0 };
1042bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_uniform4_iCDF[ 4 ] = { 192, 128, 64, 0 };
1052bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_uniform5_iCDF[ 5 ] = { 205, 154, 102, 51, 0 };
1062bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_uniform6_iCDF[ 6 ] = { 213, 171, 128, 85, 43, 0 };
1072bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_uniform8_iCDF[ 8 ] = { 224, 192, 160, 128, 96, 64, 32, 0 };
1082bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
1092bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_uint8 silk_NLSF_EXT_iCDF[ 7 ] = { 100, 40, 16, 7, 3, 1, 0 };
1102bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
1112bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/*  Elliptic/Cauer filters designed with 0.1 dB passband ripple,
1122bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian        80 dB minimum stopband attenuation, and
1132bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian        [0.95 : 0.15 : 0.35] normalized cut off frequencies. */
1142bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
1152bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Interpolation points for filter coefficients used in the bandwidth transition smoother */
1162bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int32 silk_Transition_LP_B_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NB ] =
1172bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{
1182bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    250767114,  501534038,  250767114  },
1192bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    209867381,  419732057,  209867381  },
1202bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    170987846,  341967853,  170987846  },
1212bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    131531482,  263046905,  131531482  },
1222bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{     89306658,  178584282,   89306658  }
1232bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
1242bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
1252bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian/* Interpolation points for filter coefficients used in the bandwidth transition smoother */
1262bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanianconst opus_int32 silk_Transition_LP_A_Q28[ TRANSITION_INT_NUM ][ TRANSITION_NA ] =
1272bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{
1282bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    506393414,  239854379  },
1292bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    411067935,  169683996  },
1302bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    306733530,  116694253  },
1312bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{    185807084,   77959395  },
1322bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian{     35497197,   57401098  }
1332bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian};
1342bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
1352bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#ifdef __cplusplus
1362bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian}
1372bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian#endif
1382bd8b54017b5320bc0c1df9bf86f4cdc9f8db242Vignesh Venkatasubramanian
139