media/libopus/silk/define.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libopus/silk/define.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,235 @@
     1.4 +/***********************************************************************
     1.5 +Copyright (c) 2006-2011, Skype Limited. All rights reserved.
     1.6 +Redistribution and use in source and binary forms, with or without
     1.7 +modification, are permitted provided that the following conditions
     1.8 +are met:
     1.9 +- Redistributions of source code must retain the above copyright notice,
    1.10 +this list of conditions and the following disclaimer.
    1.11 +- Redistributions in binary form must reproduce the above copyright
    1.12 +notice, this list of conditions and the following disclaimer in the
    1.13 +documentation and/or other materials provided with the distribution.
    1.14 +- Neither the name of Internet Society, IETF or IETF Trust, nor the
    1.15 +names of specific contributors, may be used to endorse or promote
    1.16 +products derived from this software without specific prior written
    1.17 +permission.
    1.18 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    1.19 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.20 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.21 +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    1.22 +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    1.23 +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1.24 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    1.25 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    1.26 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    1.27 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.28 +POSSIBILITY OF SUCH DAMAGE.
    1.29 +***********************************************************************/
    1.30 +
    1.31 +#ifndef SILK_DEFINE_H
    1.32 +#define SILK_DEFINE_H
    1.33 +
    1.34 +#include "errors.h"
    1.35 +#include "typedef.h"
    1.36 +
    1.37 +#ifdef __cplusplus
    1.38 +extern "C"
    1.39 +{
    1.40 +#endif
    1.41 +
    1.42 +/* Max number of encoder channels (1/2) */
    1.43 +#define ENCODER_NUM_CHANNELS                    2
    1.44 +/* Number of decoder channels (1/2) */
    1.45 +#define DECODER_NUM_CHANNELS                    2
    1.46 +
    1.47 +#define MAX_FRAMES_PER_PACKET                   3
    1.48 +
    1.49 +/* Limits on bitrate */
    1.50 +#define MIN_TARGET_RATE_BPS                     5000
    1.51 +#define MAX_TARGET_RATE_BPS                     80000
    1.52 +#define TARGET_RATE_TAB_SZ                      8
    1.53 +
    1.54 +/* LBRR thresholds */
    1.55 +#define LBRR_NB_MIN_RATE_BPS                    12000
    1.56 +#define LBRR_MB_MIN_RATE_BPS                    14000
    1.57 +#define LBRR_WB_MIN_RATE_BPS                    16000
    1.58 +
    1.59 +/* DTX settings */
    1.60 +#define NB_SPEECH_FRAMES_BEFORE_DTX             10      /* eq 200 ms */
    1.61 +#define MAX_CONSECUTIVE_DTX                     20      /* eq 400 ms */
    1.62 +
    1.63 +/* Maximum sampling frequency */
    1.64 +#define MAX_FS_KHZ                              16
    1.65 +#define MAX_API_FS_KHZ                          48
    1.66 +
    1.67 +/* Signal types */
    1.68 +#define TYPE_NO_VOICE_ACTIVITY                  0
    1.69 +#define TYPE_UNVOICED                           1
    1.70 +#define TYPE_VOICED                             2
    1.71 +
    1.72 +/* Conditional coding types */
    1.73 +#define CODE_INDEPENDENTLY                      0
    1.74 +#define CODE_INDEPENDENTLY_NO_LTP_SCALING       1
    1.75 +#define CODE_CONDITIONALLY                      2
    1.76 +
    1.77 +/* Settings for stereo processing */
    1.78 +#define STEREO_QUANT_TAB_SIZE                   16
    1.79 +#define STEREO_QUANT_SUB_STEPS                  5
    1.80 +#define STEREO_INTERP_LEN_MS                    8       /* must be even */
    1.81 +#define STEREO_RATIO_SMOOTH_COEF                0.01    /* smoothing coef for signal norms and stereo width */
    1.82 +
    1.83 +/* Range of pitch lag estimates */
    1.84 +#define PITCH_EST_MIN_LAG_MS                    2       /* 2 ms -> 500 Hz */
    1.85 +#define PITCH_EST_MAX_LAG_MS                    18      /* 18 ms -> 56 Hz */
    1.86 +
    1.87 +/* Maximum number of subframes */
    1.88 +#define MAX_NB_SUBFR                            4
    1.89 +
    1.90 +/* Number of samples per frame */
    1.91 +#define LTP_MEM_LENGTH_MS                       20
    1.92 +#define SUB_FRAME_LENGTH_MS                     5
    1.93 +#define MAX_SUB_FRAME_LENGTH                    ( SUB_FRAME_LENGTH_MS * MAX_FS_KHZ )
    1.94 +#define MAX_FRAME_LENGTH_MS                     ( SUB_FRAME_LENGTH_MS * MAX_NB_SUBFR )
    1.95 +#define MAX_FRAME_LENGTH                        ( MAX_FRAME_LENGTH_MS * MAX_FS_KHZ )
    1.96 +
    1.97 +/* Milliseconds of lookahead for pitch analysis */
    1.98 +#define LA_PITCH_MS                             2
    1.99 +#define LA_PITCH_MAX                            ( LA_PITCH_MS * MAX_FS_KHZ )
   1.100 +
   1.101 +/* Order of LPC used in find pitch */
   1.102 +#define MAX_FIND_PITCH_LPC_ORDER                16
   1.103 +
   1.104 +/* Length of LPC window used in find pitch */
   1.105 +#define FIND_PITCH_LPC_WIN_MS                   ( 20 + (LA_PITCH_MS << 1) )
   1.106 +#define FIND_PITCH_LPC_WIN_MS_2_SF              ( 10 + (LA_PITCH_MS << 1) )
   1.107 +#define FIND_PITCH_LPC_WIN_MAX                  ( FIND_PITCH_LPC_WIN_MS * MAX_FS_KHZ )
   1.108 +
   1.109 +/* Milliseconds of lookahead for noise shape analysis */
   1.110 +#define LA_SHAPE_MS                             5
   1.111 +#define LA_SHAPE_MAX                            ( LA_SHAPE_MS * MAX_FS_KHZ )
   1.112 +
   1.113 +/* Maximum length of LPC window used in noise shape analysis */
   1.114 +#define SHAPE_LPC_WIN_MAX                       ( 15 * MAX_FS_KHZ )
   1.115 +
   1.116 +/* dB level of lowest gain quantization level */
   1.117 +#define MIN_QGAIN_DB                            2
   1.118 +/* dB level of highest gain quantization level */
   1.119 +#define MAX_QGAIN_DB                            88
   1.120 +/* Number of gain quantization levels */
   1.121 +#define N_LEVELS_QGAIN                          64
   1.122 +/* Max increase in gain quantization index */
   1.123 +#define MAX_DELTA_GAIN_QUANT                    36
   1.124 +/* Max decrease in gain quantization index */
   1.125 +#define MIN_DELTA_GAIN_QUANT                    -4
   1.126 +
   1.127 +/* Quantization offsets (multiples of 4) */
   1.128 +#define OFFSET_VL_Q10                           32
   1.129 +#define OFFSET_VH_Q10                           100
   1.130 +#define OFFSET_UVL_Q10                          100
   1.131 +#define OFFSET_UVH_Q10                          240
   1.132 +
   1.133 +#define QUANT_LEVEL_ADJUST_Q10                  80
   1.134 +
   1.135 +/* Maximum numbers of iterations used to stabilize an LPC vector */
   1.136 +#define MAX_LPC_STABILIZE_ITERATIONS            16
   1.137 +#define MAX_PREDICTION_POWER_GAIN               1e4f
   1.138 +#define MAX_PREDICTION_POWER_GAIN_AFTER_RESET   1e2f
   1.139 +
   1.140 +#define MAX_LPC_ORDER                           16
   1.141 +#define MIN_LPC_ORDER                           10
   1.142 +
   1.143 +/* Find Pred Coef defines */
   1.144 +#define LTP_ORDER                               5
   1.145 +
   1.146 +/* LTP quantization settings */
   1.147 +#define NB_LTP_CBKS                             3
   1.148 +
   1.149 +/* Flag to use harmonic noise shaping */
   1.150 +#define USE_HARM_SHAPING                        1
   1.151 +
   1.152 +/* Max LPC order of noise shaping filters */
   1.153 +#define MAX_SHAPE_LPC_ORDER                     16
   1.154 +
   1.155 +#define HARM_SHAPE_FIR_TAPS                     3
   1.156 +
   1.157 +/* Maximum number of delayed decision states */
   1.158 +#define MAX_DEL_DEC_STATES                      4
   1.159 +
   1.160 +#define LTP_BUF_LENGTH                          512
   1.161 +#define LTP_MASK                                ( LTP_BUF_LENGTH - 1 )
   1.162 +
   1.163 +#define DECISION_DELAY                          32
   1.164 +#define DECISION_DELAY_MASK                     ( DECISION_DELAY - 1 )
   1.165 +
   1.166 +/* Number of subframes for excitation entropy coding */
   1.167 +#define SHELL_CODEC_FRAME_LENGTH                16
   1.168 +#define LOG2_SHELL_CODEC_FRAME_LENGTH           4
   1.169 +#define MAX_NB_SHELL_BLOCKS                     ( MAX_FRAME_LENGTH / SHELL_CODEC_FRAME_LENGTH )
   1.170 +
   1.171 +/* Number of rate levels, for entropy coding of excitation */
   1.172 +#define N_RATE_LEVELS                           10
   1.173 +
   1.174 +/* Maximum sum of pulses per shell coding frame */
   1.175 +#define MAX_PULSES                              16
   1.176 +
   1.177 +#define MAX_MATRIX_SIZE                         MAX_LPC_ORDER /* Max of LPC Order and LTP order */
   1.178 +
   1.179 +#if( MAX_LPC_ORDER > DECISION_DELAY )
   1.180 +# define NSQ_LPC_BUF_LENGTH                     MAX_LPC_ORDER
   1.181 +#else
   1.182 +# define NSQ_LPC_BUF_LENGTH                     DECISION_DELAY
   1.183 +#endif
   1.184 +
   1.185 +/***************************/
   1.186 +/* Voice activity detector */
   1.187 +/***************************/
   1.188 +#define VAD_N_BANDS                             4
   1.189 +
   1.190 +#define VAD_INTERNAL_SUBFRAMES_LOG2             2
   1.191 +#define VAD_INTERNAL_SUBFRAMES                  ( 1 << VAD_INTERNAL_SUBFRAMES_LOG2 )
   1.192 +
   1.193 +#define VAD_NOISE_LEVEL_SMOOTH_COEF_Q16         1024    /* Must be <  4096 */
   1.194 +#define VAD_NOISE_LEVELS_BIAS                   50
   1.195 +
   1.196 +/* Sigmoid settings */
   1.197 +#define VAD_NEGATIVE_OFFSET_Q5                  128     /* sigmoid is 0 at -128 */
   1.198 +#define VAD_SNR_FACTOR_Q16                      45000
   1.199 +
   1.200 +/* smoothing for SNR measurement */
   1.201 +#define VAD_SNR_SMOOTH_COEF_Q18                 4096
   1.202 +
   1.203 +/* Size of the piecewise linear cosine approximation table for the LSFs */
   1.204 +#define LSF_COS_TAB_SZ_FIX                      128
   1.205 +
   1.206 +/******************/
   1.207 +/* NLSF quantizer */
   1.208 +/******************/
   1.209 +#define NLSF_W_Q                                2
   1.210 +#define NLSF_VQ_MAX_VECTORS                     32
   1.211 +#define NLSF_VQ_MAX_SURVIVORS                   32
   1.212 +#define NLSF_QUANT_MAX_AMPLITUDE                4
   1.213 +#define NLSF_QUANT_MAX_AMPLITUDE_EXT            10
   1.214 +#define NLSF_QUANT_LEVEL_ADJ                    0.1
   1.215 +#define NLSF_QUANT_DEL_DEC_STATES_LOG2          2
   1.216 +#define NLSF_QUANT_DEL_DEC_STATES               ( 1 << NLSF_QUANT_DEL_DEC_STATES_LOG2 )
   1.217 +
   1.218 +/* Transition filtering for mode switching */
   1.219 +#define TRANSITION_TIME_MS                      5120    /* 5120 = 64 * FRAME_LENGTH_MS * ( TRANSITION_INT_NUM - 1 ) = 64*(20*4)*/
   1.220 +#define TRANSITION_NB                           3       /* Hardcoded in tables */
   1.221 +#define TRANSITION_NA                           2       /* Hardcoded in tables */
   1.222 +#define TRANSITION_INT_NUM                      5       /* Hardcoded in tables */
   1.223 +#define TRANSITION_FRAMES                       ( TRANSITION_TIME_MS / MAX_FRAME_LENGTH_MS )
   1.224 +#define TRANSITION_INT_STEPS                    ( TRANSITION_FRAMES  / ( TRANSITION_INT_NUM - 1 ) )
   1.225 +
   1.226 +/* BWE factors to apply after packet loss */
   1.227 +#define BWE_AFTER_LOSS_Q16                      63570
   1.228 +
   1.229 +/* Defines for CN generation */
   1.230 +#define CNG_BUF_MASK_MAX                        255     /* 2^floor(log2(MAX_FRAME_LENGTH))-1    */
   1.231 +#define CNG_GAIN_SMTH_Q16                       4634    /* 0.25^(1/4)                           */
   1.232 +#define CNG_NLSF_SMTH_Q16                       16348   /* 0.25                                 */
   1.233 +
   1.234 +#ifdef __cplusplus
   1.235 +}
   1.236 +#endif
   1.237 +
   1.238 +#endif

mercurial