Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 1 | /*********************************************************************** |
| 2 | Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 | Redistribution and use in source and binary forms, with or without |
Jean-Marc Valin | ae00e60 | 2012-04-20 16:31:04 -0400 | [diff] [blame] | 4 | modification, are permitted provided that the following conditions |
| 5 | are met: |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 6 | - Redistributions of source code must retain the above copyright notice, |
| 7 | this list of conditions and the following disclaimer. |
| 8 | - Redistributions in binary form must reproduce the above copyright |
| 9 | notice, this list of conditions and the following disclaimer in the |
| 10 | documentation and/or other materials provided with the distribution. |
Ralph Giles | f2446c2 | 2013-09-16 14:40:04 -0700 | [diff] [blame] | 11 | - Neither the name of Internet Society, IETF or IETF Trust, nor the |
Jean-Marc Valin | ae00e60 | 2012-04-20 16:31:04 -0400 | [diff] [blame] | 12 | names of specific contributors, may be used to endorse or promote |
| 13 | products derived from this software without specific prior written |
| 14 | permission. |
Timothy B. Terriberry | 80ad383 | 2013-05-19 18:00:39 -0700 | [diff] [blame] | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Jean-Marc Valin | ae00e60 | 2012-04-20 16:31:04 -0400 | [diff] [blame] | 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 | POSSIBILITY OF SUCH DAMAGE. |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 26 | ***********************************************************************/ |
| 27 | |
| 28 | #ifndef SILK_STRUCTS_H |
| 29 | #define SILK_STRUCTS_H |
| 30 | |
Jean-Marc Valin | 1c2f563 | 2011-09-16 01:16:53 -0700 | [diff] [blame] | 31 | #include "typedef.h" |
| 32 | #include "SigProc_FIX.h" |
| 33 | #include "define.h" |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 34 | #include "entenc.h" |
| 35 | #include "entdec.h" |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" |
| 39 | { |
| 40 | #endif |
| 41 | |
| 42 | /************************************/ |
| 43 | /* Noise shaping quantization state */ |
| 44 | /************************************/ |
| 45 | typedef struct { |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 46 | opus_int16 xq[ 2 * MAX_FRAME_LENGTH ]; /* Buffer for quantized output signal */ |
Koen Vos | a51ebd6 | 2011-12-14 11:39:29 -0500 | [diff] [blame] | 47 | opus_int32 sLTP_shp_Q14[ 2 * MAX_FRAME_LENGTH ]; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 48 | opus_int32 sLPC_Q14[ MAX_SUB_FRAME_LENGTH + NSQ_LPC_BUF_LENGTH ]; |
| 49 | opus_int32 sAR2_Q14[ MAX_SHAPE_LPC_ORDER ]; |
Koen Vos | a51ebd6 | 2011-12-14 11:39:29 -0500 | [diff] [blame] | 50 | opus_int32 sLF_AR_shp_Q14; |
Koen Vos | 6e40eb5 | 2016-02-21 11:34:11 +0800 | [diff] [blame] | 51 | opus_int32 sDiff_shp_Q14; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 52 | opus_int lagPrev; |
| 53 | opus_int sLTP_buf_idx; |
| 54 | opus_int sLTP_shp_buf_idx; |
| 55 | opus_int32 rand_seed; |
Koen Vos | a51ebd6 | 2011-12-14 11:39:29 -0500 | [diff] [blame] | 56 | opus_int32 prev_gain_Q16; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 57 | opus_int rewhite_flag; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 58 | } silk_nsq_state; |
| 59 | |
| 60 | /********************************/ |
| 61 | /* VAD state */ |
| 62 | /********************************/ |
| 63 | typedef struct { |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 64 | opus_int32 AnaState[ 2 ]; /* Analysis filterbank state: 0-8 kHz */ |
| 65 | opus_int32 AnaState1[ 2 ]; /* Analysis filterbank state: 0-4 kHz */ |
| 66 | opus_int32 AnaState2[ 2 ]; /* Analysis filterbank state: 0-2 kHz */ |
| 67 | opus_int32 XnrgSubfr[ VAD_N_BANDS ]; /* Subframe energies */ |
| 68 | opus_int32 NrgRatioSmth_Q8[ VAD_N_BANDS ]; /* Smoothed energy level in each band */ |
| 69 | opus_int16 HPstate; /* State of differentiator in the lowest band */ |
| 70 | opus_int32 NL[ VAD_N_BANDS ]; /* Noise energy level in each band */ |
| 71 | opus_int32 inv_NL[ VAD_N_BANDS ]; /* Inverse noise energy level in each band */ |
| 72 | opus_int32 NoiseLevelBias[ VAD_N_BANDS ]; /* Noise level estimator bias/offset */ |
| 73 | opus_int32 counter; /* Frame counter used in the initial phase */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 74 | } silk_VAD_state; |
| 75 | |
| 76 | /* Variable cut-off low-pass filter state */ |
| 77 | typedef struct { |
| 78 | opus_int32 In_LP_State[ 2 ]; /* Low pass filter state */ |
| 79 | opus_int32 transition_frame_no; /* Counter which is mapped to a cut-off frequency */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 80 | opus_int mode; /* Operating mode, <0: switch down, >0: switch up; 0: do nothing */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 81 | } silk_LP_state; |
| 82 | |
| 83 | /* Structure containing NLSF codebook */ |
| 84 | typedef struct { |
| 85 | const opus_int16 nVectors; |
| 86 | const opus_int16 order; |
| 87 | const opus_int16 quantStepSize_Q16; |
| 88 | const opus_int16 invQuantStepSize_Q6; |
| 89 | const opus_uint8 *CB1_NLSF_Q8; |
Koen Vos | 2955f68 | 2016-02-21 13:16:46 +0800 | [diff] [blame] | 90 | const opus_int16 *CB1_Wght_Q9; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 91 | const opus_uint8 *CB1_iCDF; |
| 92 | const opus_uint8 *pred_Q8; |
| 93 | const opus_uint8 *ec_sel; |
| 94 | const opus_uint8 *ec_iCDF; |
| 95 | const opus_uint8 *ec_Rates_Q5; |
| 96 | const opus_int16 *deltaMin_Q15; |
| 97 | } silk_NLSF_CB_struct; |
| 98 | |
| 99 | typedef struct { |
| 100 | opus_int16 pred_prev_Q13[ 2 ]; |
| 101 | opus_int16 sMid[ 2 ]; |
| 102 | opus_int16 sSide[ 2 ]; |
| 103 | opus_int32 mid_side_amp_Q0[ 4 ]; |
| 104 | opus_int16 smth_width_Q14; |
| 105 | opus_int16 width_prev_Q14; |
Jean-Marc Valin | b24e574 | 2011-10-11 21:09:14 -0400 | [diff] [blame] | 106 | opus_int16 silent_side_len; |
Koen Vos | 4e1ce38 | 2011-08-25 13:50:21 -0400 | [diff] [blame] | 107 | opus_int8 predIx[ MAX_FRAMES_PER_PACKET ][ 2 ][ 3 ]; |
| 108 | opus_int8 mid_only_flags[ MAX_FRAMES_PER_PACKET ]; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 109 | } stereo_enc_state; |
| 110 | |
| 111 | typedef struct { |
| 112 | opus_int16 pred_prev_Q13[ 2 ]; |
| 113 | opus_int16 sMid[ 2 ]; |
| 114 | opus_int16 sSide[ 2 ]; |
| 115 | } stereo_dec_state; |
| 116 | |
| 117 | typedef struct { |
| 118 | opus_int8 GainsIndices[ MAX_NB_SUBFR ]; |
| 119 | opus_int8 LTPIndex[ MAX_NB_SUBFR ]; |
| 120 | opus_int8 NLSFIndices[ MAX_LPC_ORDER + 1 ]; |
| 121 | opus_int16 lagIndex; |
| 122 | opus_int8 contourIndex; |
| 123 | opus_int8 signalType; |
| 124 | opus_int8 quantOffsetType; |
| 125 | opus_int8 NLSFInterpCoef_Q2; |
| 126 | opus_int8 PERIndex; |
| 127 | opus_int8 LTP_scaleIndex; |
| 128 | opus_int8 Seed; |
| 129 | } SideInfoIndices; |
| 130 | |
| 131 | /********************************/ |
| 132 | /* Encoder state */ |
| 133 | /********************************/ |
| 134 | typedef struct { |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 135 | opus_int32 In_HP_State[ 2 ]; /* High pass filter state */ |
| 136 | opus_int32 variable_HP_smth1_Q15; /* State of first smoother */ |
| 137 | opus_int32 variable_HP_smth2_Q15; /* State of second smoother */ |
| 138 | silk_LP_state sLP; /* Low pass filter state */ |
| 139 | silk_VAD_state sVAD; /* Voice activity detector state */ |
| 140 | silk_nsq_state sNSQ; /* Noise Shape Quantizer State */ |
| 141 | opus_int16 prev_NLSFq_Q15[ MAX_LPC_ORDER ]; /* Previously quantized NLSF vector */ |
| 142 | opus_int speech_activity_Q8; /* Speech activity */ |
| 143 | opus_int allow_bandwidth_switch; /* Flag indicating that switching of internal bandwidth is allowed */ |
| 144 | opus_int8 LBRRprevLastGainIndex; |
| 145 | opus_int8 prevSignalType; |
| 146 | opus_int prevLag; |
| 147 | opus_int pitch_LPC_win_length; |
| 148 | opus_int max_pitch_lag; /* Highest possible pitch lag (samples) */ |
| 149 | opus_int32 API_fs_Hz; /* API sampling frequency (Hz) */ |
| 150 | opus_int32 prev_API_fs_Hz; /* Previous API sampling frequency (Hz) */ |
| 151 | opus_int maxInternal_fs_Hz; /* Maximum internal sampling frequency (Hz) */ |
| 152 | opus_int minInternal_fs_Hz; /* Minimum internal sampling frequency (Hz) */ |
| 153 | opus_int desiredInternal_fs_Hz; /* Soft request for internal sampling frequency (Hz) */ |
| 154 | opus_int fs_kHz; /* Internal sampling frequency (kHz) */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 155 | opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ |
| 156 | opus_int frame_length; /* Frame length (samples) */ |
| 157 | opus_int subfr_length; /* Subframe length (samples) */ |
| 158 | opus_int ltp_mem_length; /* Length of LTP memory */ |
| 159 | opus_int la_pitch; /* Look-ahead for pitch analysis (samples) */ |
| 160 | opus_int la_shape; /* Look-ahead for noise shape analysis (samples) */ |
| 161 | opus_int shapeWinLength; /* Window length for noise shape analysis (samples) */ |
| 162 | opus_int32 TargetRate_bps; /* Target bitrate (bps) */ |
| 163 | opus_int PacketSize_ms; /* Number of milliseconds to put in each packet */ |
| 164 | opus_int PacketLoss_perc; /* Packet loss rate measured by farend */ |
| 165 | opus_int32 frameCounter; |
| 166 | opus_int Complexity; /* Complexity setting */ |
| 167 | opus_int nStatesDelayedDecision; /* Number of states in delayed decision quantization */ |
| 168 | opus_int useInterpolatedNLSFs; /* Flag for using NLSF interpolation */ |
| 169 | opus_int shapingLPCOrder; /* Filter order for noise shaping filters */ |
| 170 | opus_int predictLPCOrder; /* Filter order for prediction filters */ |
| 171 | opus_int pitchEstimationComplexity; /* Complexity level for pitch estimator */ |
| 172 | opus_int pitchEstimationLPCOrder; /* Whitening filter order for pitch estimator */ |
| 173 | opus_int32 pitchEstimationThreshold_Q16; /* Threshold for pitch estimator */ |
Timothy B. Terriberry | 554b349 | 2014-10-03 21:49:57 -0700 | [diff] [blame] | 174 | opus_int32 sum_log_gain_Q7; /* Cumulative max prediction gain */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 175 | opus_int NLSF_MSVQ_Survivors; /* Number of survivors in NLSF MSVQ */ |
| 176 | opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation, pitch prediction */ |
| 177 | opus_int controlled_since_last_payload; /* Flag for ensuring codec_control only runs once per packet */ |
| 178 | opus_int warping_Q16; /* Warping parameter for warped noise shaping */ |
| 179 | opus_int useCBR; /* Flag to enable constant bitrate */ |
| 180 | opus_int prefillFlag; /* Flag to indicate that only buffers are prefilled, no coding */ |
| 181 | const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ |
| 182 | const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ |
| 183 | const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ |
| 184 | opus_int input_quality_bands_Q15[ VAD_N_BANDS ]; |
| 185 | opus_int input_tilt_Q15; |
| 186 | opus_int SNR_dB_Q7; /* Quality setting */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 187 | |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 188 | opus_int8 VAD_flags[ MAX_FRAMES_PER_PACKET ]; |
| 189 | opus_int8 LBRR_flag; |
| 190 | opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 191 | |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 192 | SideInfoIndices indices; |
| 193 | opus_int8 pulses[ MAX_FRAME_LENGTH ]; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 194 | |
Timothy B. Terriberry | 39386e0 | 2013-11-18 13:30:13 -0500 | [diff] [blame] | 195 | int arch; |
| 196 | |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 197 | /* Input/output buffering */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 198 | opus_int16 inputBuf[ MAX_FRAME_LENGTH + 2 ]; /* Buffer containing input signal */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 199 | opus_int inputBufIx; |
| 200 | opus_int nFramesPerPacket; |
| 201 | opus_int nFramesEncoded; /* Number of frames analyzed in current packet */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 202 | |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 203 | opus_int nChannelsAPI; |
| 204 | opus_int nChannelsInternal; |
| 205 | opus_int channelNb; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 206 | |
| 207 | /* Parameters For LTP scaling Control */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 208 | opus_int frames_since_onset; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 209 | |
| 210 | /* Specifically for entropy coding */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 211 | opus_int ec_prevSignalType; |
| 212 | opus_int16 ec_prevLagIndex; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 213 | |
| 214 | silk_resampler_state_struct resampler_state; |
| 215 | |
| 216 | /* DTX */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 217 | opus_int useDTX; /* Flag to enable DTX */ |
| 218 | opus_int inDTX; /* Flag to signal DTX period */ |
| 219 | opus_int noSpeechCounter; /* Counts concecutive nonactive frames, used by DTX */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 220 | |
| 221 | /* Inband Low Bitrate Redundancy (LBRR) data */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 222 | opus_int useInBandFEC; /* Saves the API setting for query */ |
| 223 | opus_int LBRR_enabled; /* Depends on useInBandFRC, bitrate and packet loss rate */ |
| 224 | opus_int LBRR_GainIncreases; /* Gains increment for coding LBRR frames */ |
| 225 | SideInfoIndices indices_LBRR[ MAX_FRAMES_PER_PACKET ]; |
| 226 | opus_int8 pulses_LBRR[ MAX_FRAMES_PER_PACKET ][ MAX_FRAME_LENGTH ]; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 227 | } silk_encoder_state; |
| 228 | |
| 229 | |
| 230 | /* Struct for Packet Loss Concealment */ |
| 231 | typedef struct { |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 232 | opus_int32 pitchL_Q8; /* Pitch lag to use for voiced concealment */ |
| 233 | opus_int16 LTPCoef_Q14[ LTP_ORDER ]; /* LTP coeficients to use for voiced concealment */ |
| 234 | opus_int16 prevLPC_Q12[ MAX_LPC_ORDER ]; |
| 235 | opus_int last_frame_lost; /* Was previous frame lost */ |
| 236 | opus_int32 rand_seed; /* Seed for unvoiced signal generation */ |
| 237 | opus_int16 randScale_Q14; /* Scaling of unvoiced random signal */ |
| 238 | opus_int32 conc_energy; |
| 239 | opus_int conc_energy_shift; |
| 240 | opus_int16 prevLTP_scale_Q14; |
Koen Vos | 0dbd0ca | 2011-10-28 21:05:22 -0400 | [diff] [blame] | 241 | opus_int32 prevGain_Q16[ 2 ]; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 242 | opus_int fs_kHz; |
Koen Vos | 0dbd0ca | 2011-10-28 21:05:22 -0400 | [diff] [blame] | 243 | opus_int nb_subfr; |
| 244 | opus_int subfr_length; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 245 | } silk_PLC_struct; |
| 246 | |
| 247 | /* Struct for CNG */ |
| 248 | typedef struct { |
Koen Vos | a51ebd6 | 2011-12-14 11:39:29 -0500 | [diff] [blame] | 249 | opus_int32 CNG_exc_buf_Q14[ MAX_FRAME_LENGTH ]; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 250 | opus_int16 CNG_smth_NLSF_Q15[ MAX_LPC_ORDER ]; |
| 251 | opus_int32 CNG_synth_state[ MAX_LPC_ORDER ]; |
| 252 | opus_int32 CNG_smth_Gain_Q16; |
| 253 | opus_int32 rand_seed; |
| 254 | opus_int fs_kHz; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 255 | } silk_CNG_struct; |
| 256 | |
| 257 | /********************************/ |
| 258 | /* Decoder state */ |
| 259 | /********************************/ |
| 260 | typedef struct { |
Koen Vos | a51ebd6 | 2011-12-14 11:39:29 -0500 | [diff] [blame] | 261 | opus_int32 prev_gain_Q16; |
| 262 | opus_int32 exc_Q14[ MAX_FRAME_LENGTH ]; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 263 | opus_int32 sLPC_Q14_buf[ MAX_LPC_ORDER ]; |
| 264 | opus_int16 outBuf[ MAX_FRAME_LENGTH + 2 * MAX_SUB_FRAME_LENGTH ]; /* Buffer for output signal */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 265 | opus_int lagPrev; /* Previous Lag */ |
| 266 | opus_int8 LastGainIndex; /* Previous gain index */ |
| 267 | opus_int fs_kHz; /* Sampling frequency in kHz */ |
| 268 | opus_int32 fs_API_hz; /* API sample frequency (Hz) */ |
| 269 | opus_int nb_subfr; /* Number of 5 ms subframes in a frame */ |
| 270 | opus_int frame_length; /* Frame length (samples) */ |
| 271 | opus_int subfr_length; /* Subframe length (samples) */ |
| 272 | opus_int ltp_mem_length; /* Length of LTP memory */ |
| 273 | opus_int LPC_order; /* LPC order */ |
| 274 | opus_int16 prevNLSF_Q15[ MAX_LPC_ORDER ]; /* Used to interpolate LSFs */ |
| 275 | opus_int first_frame_after_reset; /* Flag for deactivating NLSF interpolation */ |
| 276 | const opus_uint8 *pitch_lag_low_bits_iCDF; /* Pointer to iCDF table for low bits of pitch lag index */ |
| 277 | const opus_uint8 *pitch_contour_iCDF; /* Pointer to iCDF table for pitch contour index */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 278 | |
| 279 | /* For buffering payload in case of more frames per packet */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 280 | opus_int nFramesDecoded; |
| 281 | opus_int nFramesPerPacket; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 282 | |
| 283 | /* Specifically for entropy coding */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 284 | opus_int ec_prevSignalType; |
| 285 | opus_int16 ec_prevLagIndex; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 286 | |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 287 | opus_int VAD_flags[ MAX_FRAMES_PER_PACKET ]; |
| 288 | opus_int LBRR_flag; |
| 289 | opus_int LBRR_flags[ MAX_FRAMES_PER_PACKET ]; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 290 | |
| 291 | silk_resampler_state_struct resampler_state; |
| 292 | |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 293 | const silk_NLSF_CB_struct *psNLSF_CB; /* Pointer to NLSF codebook */ |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 294 | |
| 295 | /* Quantization indices */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 296 | SideInfoIndices indices; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 297 | |
| 298 | /* CNG state */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 299 | silk_CNG_struct sCNG; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 300 | |
| 301 | /* Stuff used for PLC */ |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 302 | opus_int lossCnt; |
| 303 | opus_int prevSignalType; |
Linfeng Zhang | 95d4c9f | 2016-07-13 17:25:49 -0700 | [diff] [blame] | 304 | int arch; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 305 | |
| 306 | silk_PLC_struct sPLC; |
| 307 | |
| 308 | } silk_decoder_state; |
| 309 | |
| 310 | /************************/ |
| 311 | /* Decoder control */ |
| 312 | /************************/ |
| 313 | typedef struct { |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 314 | /* Prediction and coding parameters */ |
| 315 | opus_int pitchL[ MAX_NB_SUBFR ]; |
| 316 | opus_int32 Gains_Q16[ MAX_NB_SUBFR ]; |
| 317 | /* Holds interpolated and final coefficients, 4-byte aligned */ |
Jean-Marc Valin | fb3a437 | 2011-09-16 00:58:26 -0700 | [diff] [blame] | 318 | silk_DWORD_ALIGN opus_int16 PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ]; |
Koen Vos | acc7a6c | 2011-10-28 19:44:26 -0400 | [diff] [blame] | 319 | opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ]; |
| 320 | opus_int LTP_scale_Q14; |
Gregory Maxwell | ae23114 | 2011-07-30 08:18:48 -0400 | [diff] [blame] | 321 | } silk_decoder_control; |
| 322 | |
| 323 | |
| 324 | #ifdef __cplusplus |
| 325 | } |
| 326 | #endif |
| 327 | |
| 328 | #endif |