Improvements to error handling and warning fixes
[opus.git] / silk / SKP_Silk_main.h
1 /***********************************************************************\r
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. \r
3 Redistribution and use in source and binary forms, with or without \r
4 modification, (subject to the limitations in the disclaimer below) \r
5 are permitted provided that the following conditions are met:\r
6 - Redistributions of source code must retain the above copyright notice,\r
7 this list of conditions and the following disclaimer.\r
8 - Redistributions in binary form must reproduce the above copyright \r
9 notice, this list of conditions and the following disclaimer in the \r
10 documentation and/or other materials provided with the distribution.\r
11 - Neither the name of Skype Limited, nor the names of specific \r
12 contributors, may be used to endorse or promote products derived from \r
13 this software without specific prior written permission.\r
14 NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED \r
15 BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND \r
16 CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
17 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND \r
18 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE \r
19 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, \r
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
22 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
23 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
26 ***********************************************************************/\r
27 \r
28 #ifndef SKP_SILK_MAIN_H\r
29 #define SKP_SILK_MAIN_H\r
30 \r
31 #ifdef __cplusplus\r
32 extern "C"\r
33 {\r
34 #endif\r
35 \r
36 #include "SKP_Silk_SigProc_FIX.h"\r
37 #include "SKP_Silk_define.h"\r
38 #include "SKP_Silk_structs.h"\r
39 #include "SKP_Silk_tables.h"\r
40 #include "SKP_Silk_PLC.h"\r
41 #include "SKP_Silk_control.h"\r
42 #include "SKP_debug.h"\r
43 #include "entenc.h"\r
44 #include "entdec.h"\r
45 \r
46 \r
47 /* Uncomment the next line to store intermadiate data to files */\r
48 //#define SAVE_ALL_INTERNAL_DATA      1\r
49 /* Uncomment the next line to force a fixed internal sampling rate (independent of what bitrate is used */\r
50 //#define FORCE_INTERNAL_FS_KHZ       16\r
51 \r
52 \r
53 /* Convert Left/Right stereo signal to adaptive Mid/Side representation */\r
54 void SKP_Silk_stereo_LR_to_MS( \r
55     ec_enc              *psRangeEnc,                    /* I/O  Compressor data structure                   */\r
56     stereo_state        *state,                         /* I/O  State                                       */\r
57     SKP_int16           x1[],                           /* I/O  Left input signal, becomes mid signal       */\r
58     SKP_int16           x2[],                           /* I/O  Right input signal, becomes side signal     */\r
59     SKP_int             fs_kHz,                         /* I    Samples rate (kHz)                          */\r
60     SKP_int             frame_length                    /* I    Number of samples                           */\r
61 );\r
62 \r
63 /* Convert adaptive Mid/Side representation to Left/Right stereo signal */\r
64 void SKP_Silk_stereo_MS_to_LR( \r
65     stereo_state        *state,                         /* I/O  State                                       */\r
66     SKP_int16           x1[],                           /* I/O  Left input signal, becomes mid signal       */\r
67     SKP_int16           x2[],                           /* I/O  Right input signal, becomes side signal     */\r
68     const SKP_int32     pred_Q13[],                     /* I    Predictors                                  */\r
69     SKP_int             fs_kHz,                         /* I    Samples rate (kHz)                          */\r
70     SKP_int             frame_length                    /* I    Number of samples                           */\r
71 );\r
72 \r
73 /* Find least-squares prediction gain for one signal based on another and quantize it */\r
74 SKP_int32 SKP_Silk_stereo_find_predictor(               /* O    Returns predictor in Q13                    */\r
75     const SKP_int16     x[],                            /* I    Basis signal                                */\r
76     const SKP_int16     y[],                            /* I    Target signal                               */\r
77     SKP_int             length                          /* I    Number of samples                           */\r
78 );\r
79 \r
80 /* Quantize mid/side predictors and entropy code the quantization indices */\r
81 void SKP_Silk_stereo_encode_pred(\r
82     ec_enc              *psRangeEnc,                    /* I/O  Compressor data structure                   */\r
83     SKP_int32           pred_Q13[]                      /* I/O  Predictors (out: quantized)                 */\r
84 );\r
85 \r
86 /* Decode mid/side predictors */\r
87 void SKP_Silk_stereo_decode_pred(\r
88     ec_dec              *psRangeDec,                    /* I/O  Compressor data structure                   */\r
89     SKP_int32           pred_Q13[]                      /* O    Predictors                                  */\r
90 );\r
91 \r
92 /* Encodes signs of excitation */\r
93 void SKP_Silk_encode_signs(\r
94     ec_enc                      *psRangeEnc,                        /* I/O  Compressor data structure                   */\r
95     const SKP_int8              pulses[],                           /* I    pulse signal                                */\r
96     SKP_int                     length,                             /* I    length of input                             */\r
97     const SKP_int               signalType,                         /* I    Signal type                                 */\r
98     const SKP_int               quantOffsetType,                    /* I    Quantization offset type                    */\r
99     const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */\r
100 );\r
101 \r
102 /* Decodes signs of excitation */\r
103 void SKP_Silk_decode_signs(\r
104     ec_dec                      *psRangeDec,                        /* I/O  Compressor data structure                   */\r
105     SKP_int                     pulses[],                           /* I/O  pulse signal                                */\r
106     SKP_int                     length,                             /* I    length of input                             */\r
107     const SKP_int               signalType,                         /* I    Signal type                                 */\r
108     const SKP_int               quantOffsetType,                    /* I    Quantization offset type                    */\r
109     const SKP_int               sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */\r
110 );\r
111 \r
112 /* Check encoder control struct */\r
113 SKP_int check_control_input( \r
114     SKP_SILK_SDK_EncControlStruct        *encControl     /* I:   Control structure                               */\r
115 );\r
116 \r
117 /* Control internal sampling rate */\r
118 SKP_int SKP_Silk_control_audio_bandwidth(\r
119     SKP_Silk_encoder_state      *psEncC             /* I/O  Pointer to Silk encoder state               */\r
120 );\r
121 \r
122 /* Control SNR of redidual quantizer */\r
123 SKP_int SKP_Silk_control_SNR(\r
124     SKP_Silk_encoder_state      *psEncC,            /* I/O  Pointer to Silk encoder state               */\r
125     SKP_int32                   TargetRate_bps      /* I    Target max bitrate (bps)                    */\r
126 );\r
127 \r
128 /***************/\r
129 /* Shell coder */\r
130 /***************/\r
131 \r
132 /* Encode quantization indices of excitation */\r
133 void SKP_Silk_encode_pulses(\r
134     ec_enc                      *psRangeEnc,        /* I/O  compressor data structure                   */\r
135     const SKP_int               signalType,         /* I    Signal type                                 */\r
136     const SKP_int               quantOffsetType,    /* I    quantOffsetType                             */\r
137     SKP_int8                    pulses[],           /* I    quantization indices                        */\r
138     const SKP_int               frame_length        /* I    Frame length                                */\r
139 );\r
140 \r
141 /* Shell encoder, operates on one shell code frame of 16 pulses */\r
142 void SKP_Silk_shell_encoder(\r
143     ec_enc                      *psRangeEnc,        /* I/O  compressor data structure                   */\r
144     const SKP_int               *pulses0            /* I    data: nonnegative pulse amplitudes          */\r
145 );\r
146 \r
147 /* Shell decoder, operates on one shell code frame of 16 pulses */\r
148 void SKP_Silk_shell_decoder(\r
149     SKP_int                     *pulses0,           /* O    data: nonnegative pulse amplitudes          */\r
150     ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */\r
151     const SKP_int               pulses4             /* I    number of pulses per pulse-subframe         */\r
152 );\r
153 \r
154 /* Gain scalar quantization with hysteresis, uniform on log scale */\r
155 void SKP_Silk_gains_quant(\r
156     SKP_int8                        ind[ MAX_NB_SUBFR ],        /* O    gain indices                            */\r
157     SKP_int32                       gain_Q16[ MAX_NB_SUBFR ],   /* I/O  gains (quantized out)                   */\r
158     SKP_int8                        *prev_ind,                  /* I/O  last index in previous frame            */\r
159     const SKP_int                   conditional,                /* I    first gain is delta coded if 1          */\r
160     const SKP_int                   nb_subfr                    /* I    number of subframes                     */\r
161 );\r
162 \r
163 /* Gains scalar dequantization, uniform on log scale */\r
164 void SKP_Silk_gains_dequant(\r
165     SKP_int32                       gain_Q16[ MAX_NB_SUBFR ],   /* O    quantized gains                         */\r
166     const SKP_int8                  ind[ MAX_NB_SUBFR ],        /* I    gain indices                            */\r
167     SKP_int8                        *prev_ind,                  /* I/O  last index in previous frame            */\r
168     const SKP_int                   conditional,                /* I    first gain is delta coded if 1          */\r
169     const SKP_int                   nb_subfr                    /* I    number of subframes                     */\r
170 );\r
171 \r
172 /* Convert NLSF parameters to stable AR prediction filter coefficients */\r
173 void SKP_Silk_NLSF2A_stable(\r
174     SKP_int16                   pAR_Q12[ MAX_LPC_ORDER ],   /* O    Stabilized AR coefs [LPC_order]     */ \r
175     const SKP_int16             pNLSF[ MAX_LPC_ORDER ],     /* I    NLSF vector         [LPC_order]     */\r
176     const SKP_int               LPC_order                   /* I    LPC/LSF order                       */\r
177 );\r
178 \r
179 /* Interpolate two vectors */\r
180 void SKP_Silk_interpolate(\r
181     SKP_int16                       xi[ MAX_LPC_ORDER ],    /* O    interpolated vector                     */\r
182     const SKP_int16                 x0[ MAX_LPC_ORDER ],    /* I    first vector                            */\r
183     const SKP_int16                 x1[ MAX_LPC_ORDER ],    /* I    second vector                           */\r
184     const SKP_int                   ifact_Q2,               /* I    interp. factor, weight on 2nd vector    */\r
185     const SKP_int                   d                       /* I    number of parameters                    */\r
186 );\r
187 \r
188 /* LTP tap quantizer */\r
189 void SKP_Silk_quant_LTP_gains(\r
190     SKP_int16           B_Q14[ MAX_NB_SUBFR * LTP_ORDER ],              /* I/O  (un)quantized LTP gains     */\r
191     SKP_int8            cbk_index[ MAX_NB_SUBFR ],                      /* O    Codebook Index              */\r
192     SKP_int8            *periodicity_index,                             /* O    Periodicity Index           */\r
193     const SKP_int32     W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ],      /* I    Error Weights in Q18        */\r
194     SKP_int             mu_Q9,                                          /* I    Mu value (R/D tradeoff)     */\r
195     SKP_int             lowComplexity,                                  /* I    Flag for low complexity     */\r
196     const SKP_int       nb_subfr                                        /* I    number of subframes         */\r
197 );\r
198 \r
199 /* Entropy constrained matrix-weighted VQ, for a single input data vector */\r
200 void SKP_Silk_VQ_WMat_EC(\r
201     SKP_int8                        *ind,               /* O    index of best codebook vector               */\r
202     SKP_int32                       *rate_dist_Q14,     /* O    best weighted quantization error + mu * rate*/\r
203     const SKP_int16                 *in_Q14,            /* I    input vector to be quantized                */\r
204     const SKP_int32                 *W_Q18,             /* I    weighting matrix                            */\r
205     const SKP_int8                  *cb_Q7,             /* I    codebook                                    */\r
206     const SKP_uint8                 *cl_Q5,             /* I    code length for each codebook vector        */\r
207     const SKP_int                   mu_Q9,              /* I    tradeoff between weighted error and rate    */\r
208     SKP_int                         L                   /* I    number of vectors in codebook               */\r
209 );\r
210 \r
211 /***********************************/\r
212 /* Noise shaping quantization (NSQ)*/\r
213 /***********************************/\r
214 void SKP_Silk_NSQ(\r
215     const SKP_Silk_encoder_state    *psEncC,                                    /* I/O  Encoder State                       */\r
216     SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */\r
217     SideInfoIndices                 *psIndices,                                 /* I/O  Quantization Indices                */\r
218     const SKP_int16                 x[],                                        /* I    prefiltered input signal            */\r
219     SKP_int8                        pulses[],                                   /* O    quantized qulse signal              */\r
220     const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefficients  */\r
221     const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],    /* I    Long term prediction coefficients   */\r
222     const SKP_int16                 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I                                     */\r
223     const SKP_int                   HarmShapeGain_Q14[ MAX_NB_SUBFR ],          /* I                                        */\r
224     const SKP_int                   Tilt_Q14[ MAX_NB_SUBFR ],                   /* I    Spectral tilt                       */\r
225     const SKP_int32                 LF_shp_Q14[ MAX_NB_SUBFR ],                 /* I                                        */\r
226     const SKP_int32                 Gains_Q16[ MAX_NB_SUBFR ],                  /* I                                        */\r
227     const SKP_int                   pitchL[ MAX_NB_SUBFR ],                     /* I                                        */\r
228     const SKP_int                   Lambda_Q10,                                 /* I                                        */\r
229     const SKP_int                   LTP_scale_Q14                               /* I    LTP state scaling                   */\r
230 );\r
231 \r
232 /* Noise shaping using delayed decision */\r
233 void SKP_Silk_NSQ_del_dec(\r
234     const SKP_Silk_encoder_state    *psEncC,                                    /* I/O  Encoder State                       */\r
235     SKP_Silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                           */\r
236     SideInfoIndices                 *psIndices,                                 /* I/O  Quantization Indices                */\r
237     const SKP_int16                 x[],                                        /* I    Prefiltered input signal            */\r
238     SKP_int8                        pulses[],                                   /* O    Quantized pulse signal              */\r
239     const SKP_int16                 PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Prediction coefs                    */\r
240     const SKP_int16                 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],    /* I    LT prediction coefs                 */\r
241     const SKP_int16                 AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I                                     */\r
242     const SKP_int                   HarmShapeGain_Q14[ MAX_NB_SUBFR ],          /* I                                        */\r
243     const SKP_int                   Tilt_Q14[ MAX_NB_SUBFR ],                   /* I    Spectral tilt                       */\r
244     const SKP_int32                 LF_shp_Q14[ MAX_NB_SUBFR ],                 /* I                                        */\r
245     const SKP_int32                 Gains_Q16[ MAX_NB_SUBFR ],                  /* I                                        */\r
246     const SKP_int                   pitchL[ MAX_NB_SUBFR ],                     /* I                                        */\r
247     const SKP_int                   Lambda_Q10,                                 /* I                                        */\r
248     const SKP_int                   LTP_scale_Q14                               /* I    LTP state scaling                   */\r
249 );\r
250 \r
251 /************/\r
252 /* Silk VAD */\r
253 /************/\r
254 /* Initialize the Silk VAD */\r
255 SKP_int SKP_Silk_VAD_Init(                          /* O    Return value, 0 if success                  */ \r
256     SKP_Silk_VAD_state          *psSilk_VAD         /* I/O  Pointer to Silk VAD state                   */ \r
257 ); \r
258 \r
259 /* Silk VAD noise level estimation */\r
260 void SKP_Silk_VAD_GetNoiseLevels(\r
261     const SKP_int32             pX[ VAD_N_BANDS ],  /* I    subband energies                            */\r
262     SKP_Silk_VAD_state          *psSilk_VAD         /* I/O  Pointer to Silk VAD state                   */ \r
263 );\r
264 \r
265 /* Get speech activity level in Q8 */\r
266 SKP_int SKP_Silk_VAD_GetSA_Q8(                      /* O    Return value, 0 if success                  */\r
267     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
268     const SKP_int16             pIn[]               /* I    PCM input                                   */\r
269 );\r
270 \r
271 /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */\r
272 void SKP_Silk_HP_variable_cutoff(\r
273     SKP_Silk_encoder_state          *psEncC,        /* I/O  Encoder state                               */\r
274     SKP_int16                       *out,           /* O    high-pass filtered output signal            */\r
275     const SKP_int16                 *in,            /* I    input signal                                */\r
276     const SKP_int                   frame_length    /* I    length of input                             */\r
277 );\r
278 \r
279 /* Low-pass filter with variable cutoff frequency based on  */\r
280 /* piece-wise linear interpolation between elliptic filters */\r
281 /* Start by setting transition_frame_no = 1;                */\r
282 void SKP_Silk_LP_variable_cutoff(\r
283     SKP_Silk_LP_state           *psLP,              /* I/O  LP filter state                             */\r
284     SKP_int16                   *signal,            /* I/O  Low-pass filtered output signal             */\r
285     const SKP_int               frame_length        /* I    Frame length                                */\r
286 );\r
287 \r
288 /******************/\r
289 /* NLSF Quantizer */\r
290 /******************/\r
291 /* Limit, stabilize, convert and quantize NLSFs */ \r
292 void SKP_Silk_process_NLSFs(\r
293     SKP_Silk_encoder_state          *psEncC,                                /* I/O  Encoder state                               */\r
294     SKP_int16                       PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ],     /* O    Prediction coefficients                     */\r
295     SKP_int16                       pNLSF_Q15[         MAX_LPC_ORDER ],     /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */\r
296     const SKP_int16                 prev_NLSFq_Q15[    MAX_LPC_ORDER ]      /* I    Previous Normalized LSFs (0 - (2^15-1))     */\r
297 );\r
298 \r
299 SKP_int32 SKP_Silk_NLSF_encode(                             /* O    Returns RD value in Q25                 */\r
300           SKP_int8                  *NLSFIndices,           /* I    Codebook path vector [ LPC_ORDER + 1 ]  */\r
301           SKP_int16                 *pNLSF_Q15,             /* I/O  Quantized NLSF vector [ LPC_ORDER ]     */\r
302     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,             /* I    Codebook object                         */\r
303     const SKP_int16                 *pW_Q5,                 /* I    NLSF weight vector [ LPC_ORDER ]        */\r
304     const SKP_int                   NLSF_mu_Q20,            /* I    Rate weight for the RD optimization     */\r
305     const SKP_int                   nSurvivors,             /* I    Max survivors after first stage         */\r
306     const SKP_int                   signalType              /* I    Signal type: 0/1/2                      */\r
307 );\r
308 \r
309 /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */\r
310 void SKP_Silk_NLSF_VQ(\r
311     SKP_int32                   err_Q26[],              /* O    Quantization errors [K]                     */\r
312     const SKP_int16             in_Q15[],               /* I    Input vectors to be quantized [LPC_order]   */\r
313     const SKP_uint8             pCB_Q8[],               /* I    Codebook vectors [K*LPC_order]              */\r
314     const SKP_int               K,                      /* I    Number of codebook vectors                  */\r
315     const SKP_int               LPC_order               /* I    Number of LPCs                              */\r
316 );\r
317 \r
318 /* Delayed-decision quantizer for NLSF residuals */\r
319 SKP_int32 SKP_Silk_NLSF_del_dec_quant(                  /* O    Returns RD value in Q25                     */\r
320     SKP_int8                    indices[],              /* O    Quantization indices [ order ]              */\r
321     const SKP_int16             x_Q10[],                /* I    Input [ order ]                             */\r
322     const SKP_int16             w_Q5[],                 /* I    Weights [ order ]                           */\r
323     const SKP_uint8             pred_coef_Q8[],         /* I    Backward predictor coefs [ order ]          */\r
324     const SKP_int16             ec_ix[],                /* I    Indices to entropy coding tables [ order ]  */\r
325     const SKP_uint8             ec_rates_Q5[],          /* I    Rates []                                    */\r
326     const SKP_int               quant_step_size_Q16,    /* I    Quantization step size                      */\r
327     const SKP_int16             inv_quant_step_size_Q6, /* I    Inverse quantization step size              */\r
328     const SKP_int32             mu_Q20,                 /* I    R/D tradeoff                                */\r
329     const SKP_int16             order                   /* I    Number of input values                      */\r
330 );\r
331 \r
332 /* Unpack predictor values and indices for entropy coding tables */\r
333 void SKP_Silk_NLSF_unpack(\r
334           SKP_int16                 ec_ix[],                /* O    Indices to entropy tales [ LPC_ORDER ]  */\r
335           SKP_uint8                 pred_Q8[],              /* O    LSF predictor [ LPC_ORDER ]             */\r
336     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB,             /* I    Codebook object                         */\r
337     const SKP_int                   CB1_index               /* I    Index of vector in first LSF codebook   */\r
338 );\r
339 \r
340 /***********************/\r
341 /* NLSF vector decoder */\r
342 /***********************/\r
343 void SKP_Silk_NLSF_decode(\r
344           SKP_int16                 *pNLSF_Q15,             /* O    Quantized NLSF vector [ LPC_ORDER ]     */\r
345           SKP_int8                  *NLSFIndices,           /* I    Codebook path vector [ LPC_ORDER + 1 ]  */\r
346     const SKP_Silk_NLSF_CB_struct   *psNLSF_CB              /* I    Codebook object                         */\r
347 );\r
348 \r
349 /****************************************************/\r
350 /* Decoder Functions                                */\r
351 /****************************************************/\r
352 SKP_int SKP_Silk_create_decoder(\r
353     SKP_Silk_decoder_state          **ppsDec            /* I/O  Decoder state pointer pointer               */\r
354 );\r
355 \r
356 SKP_int SKP_Silk_free_decoder(\r
357     SKP_Silk_decoder_state          *psDec              /* I/O  Decoder state pointer                       */\r
358 );\r
359 \r
360 SKP_int SKP_Silk_init_decoder(\r
361     SKP_Silk_decoder_state          *psDec              /* I/O  Decoder state pointer                       */\r
362 );\r
363 \r
364 /* Set decoder sampling rate */\r
365 void SKP_Silk_decoder_set_fs(\r
366     SKP_Silk_decoder_state          *psDec,             /* I/O  Decoder state pointer                       */\r
367     SKP_int                         fs_kHz              /* I    Sampling frequency (kHz)                    */\r
368 );\r
369 \r
370 /****************/\r
371 /* Decode frame */\r
372 /****************/\r
373 SKP_int SKP_Silk_decode_frame(\r
374     SKP_Silk_decoder_state      *psDec,             /* I/O  Pointer to Silk decoder state               */\r
375     ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */\r
376     SKP_int16                   pOut[],             /* O    Pointer to output speech frame              */\r
377     SKP_int32                   *pN,                /* O    Pointer to size of output frame             */\r
378     SKP_int                     lostFlag            /* I    0: no loss, 1 loss, 2 decode fec            */\r
379 );\r
380 \r
381 /* Decode LBRR side info and excitation */\r
382 void SKP_Silk_LBRR_extract(\r
383     SKP_Silk_decoder_state      *psDec,             /* I/O  State                                       */\r
384     ec_dec                      *psRangeDec         /* I/O  Compressor data structure                   */\r
385 );\r
386 \r
387 /* Decode indices from payload v4 Bitstream */\r
388 void SKP_Silk_decode_indices(\r
389     SKP_Silk_decoder_state      *psDec,             /* I/O  State                                       */\r
390     ec_dec                      *psRangeDec,        /* I/O  Compressor data structure                   */\r
391     SKP_int                     FrameIndex,         /* I    Frame number                                */\r
392     SKP_int                     decode_LBRR         /* I    Flag indicating LBRR data is being decoded  */\r
393 );\r
394 \r
395 /* Decode parameters from payload */\r
396 void SKP_Silk_decode_parameters(\r
397     SKP_Silk_decoder_state      *psDec,                             /* I/O  State                                    */\r
398     SKP_Silk_decoder_control    *psDecCtrl                          /* I/O  Decoder control                          */\r
399 );\r
400 \r
401 /* Core decoder. Performs inverse NSQ operation LTP + LPC */\r
402 void SKP_Silk_decode_core(\r
403     SKP_Silk_decoder_state      *psDec,                             /* I/O  Decoder state               */\r
404     SKP_Silk_decoder_control    *psDecCtrl,                         /* I    Decoder control             */\r
405     SKP_int16                   xq[],                               /* O    Decoded speech              */\r
406     const SKP_int               pulses[ MAX_FRAME_LENGTH ]          /* I    Pulse signal                */\r
407 );\r
408 \r
409 /* Decode quantization indices of excitation (Shell coding) */\r
410 void SKP_Silk_decode_pulses(\r
411     ec_dec                          *psRangeDec,        /* I/O  Compressor data structure                   */\r
412     SKP_int                         pulses[],           /* O    Excitation signal                           */\r
413     const SKP_int                   signalType,         /* I    Sigtype                                     */\r
414     const SKP_int                   quantOffsetType,    /* I    quantOffsetType                             */\r
415     const SKP_int                   frame_length        /* I    Frame length                                */\r
416 );\r
417 \r
418 /******************/\r
419 /* CNG */\r
420 /******************/\r
421 \r
422 /* Reset CNG */\r
423 void SKP_Silk_CNG_Reset(\r
424     SKP_Silk_decoder_state      *psDec              /* I/O  Decoder state                               */\r
425 );\r
426 \r
427 /* Updates CNG estimate, and applies the CNG when packet was lost */\r
428 void SKP_Silk_CNG(\r
429     SKP_Silk_decoder_state      *psDec,             /* I/O  Decoder state                               */\r
430     SKP_Silk_decoder_control    *psDecCtrl,         /* I/O  Decoder control                             */\r
431     SKP_int16                   signal[],           /* I/O  Signal                                      */\r
432     SKP_int                     length              /* I    Length of residual                          */\r
433 );\r
434 \r
435 /* Encoding of various parameters */\r
436 void SKP_Silk_encode_indices(\r
437     SKP_Silk_encoder_state      *psEncC,            /* I/O  Encoder state                               */\r
438     ec_enc                      *psRangeEnc,        /* I/O  Compressor data structure                   */\r
439     SKP_int                     FrameIndex,         /* I    Frame number                                */\r
440     SKP_int                     encode_LBRR         /* I    Flag indicating LBRR data is being encoded  */\r
441 );\r
442 \r
443 #ifdef __cplusplus\r
444 }\r
445 #endif\r
446 \r
447 #endif\r