Fixes two SILK PLC issues
[opus.git] / silk / main.h
1 /***********************************************************************
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Redistribution and use in source and binary forms, with or without
4 modification, (subject to the limitations in the disclaimer below)
5 are permitted provided that the following conditions are met:
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.
11 - Neither the name of Skype Limited, nor the names of specific
12 contributors, may be used to endorse or promote products derived from
13 this software without specific prior written permission.
14 NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED
15 BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
16 CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
17 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***********************************************************************/
27
28 #ifndef SILK_MAIN_H
29 #define SILK_MAIN_H
30
31 #include "SigProc_FIX.h"
32 #include "define.h"
33 #include "structs.h"
34 #include "tables.h"
35 #include "PLC.h"
36 #include "control.h"
37 #include "debug.h"
38 #include "entenc.h"
39 #include "entdec.h"
40
41 /* Simple way to make [8000, 12000, 16000, 24000, 48000] to [0,1,2,3,4] */
42 #define rateID(R) ( ( ( ((R)>>12) - ((R)>16000) ) >> ((R)>24000) ) - 1 )
43
44 /* Convert Left/Right stereo signal to adaptive Mid/Side representation */
45 void silk_stereo_LR_to_MS(
46     stereo_enc_state            *state,                         /* I/O  State                                       */
47     opus_int16                  x1[],                           /* I/O  Left input signal, becomes mid signal       */
48     opus_int16                  x2[],                           /* I/O  Right input signal, becomes side signal     */
49     opus_int8                   ix[ 2 ][ 3 ],                   /* O    Quantization indices                        */
50     opus_int8                   *mid_only_flag,                 /* O    Flag: only mid signal coded                 */
51     opus_int32                  mid_side_rates_bps[],           /* O    Bitrates for mid and side signals           */
52     opus_int32                  total_rate_bps,                 /* I    Total bitrate                               */
53     opus_int                    prev_speech_act_Q8,             /* I    Speech activity level in previous frame     */
54     opus_int                    toMono,                         /* I    Last frame before a stereo->mono transition */
55     opus_int                    fs_kHz,                         /* I    Sample rate (kHz)                           */
56     opus_int                    frame_length                    /* I    Number of samples                           */
57 );
58
59 /* Convert adaptive Mid/Side representation to Left/Right stereo signal */
60 void silk_stereo_MS_to_LR(
61     stereo_dec_state            *state,                         /* I/O  State                                       */
62     opus_int16                  x1[],                           /* I/O  Left input signal, becomes mid signal       */
63     opus_int16                  x2[],                           /* I/O  Right input signal, becomes side signal     */
64     const opus_int32            pred_Q13[],                     /* I    Predictors                                  */
65     opus_int                    fs_kHz,                         /* I    Samples rate (kHz)                          */
66     opus_int                    frame_length                    /* I    Number of samples                           */
67 );
68
69 /* Find least-squares prediction gain for one signal based on another and quantize it */
70 opus_int32 silk_stereo_find_predictor(                          /* O    Returns predictor in Q13                    */
71     opus_int32                  *ratio_Q14,                     /* O    Ratio of residual and mid energies          */
72     const opus_int16            x[],                            /* I    Basis signal                                */
73     const opus_int16            y[],                            /* I    Target signal                               */
74     opus_int32                  mid_res_amp_Q0[],               /* I/O  Smoothed mid, residual norms                */
75     opus_int                    length,                         /* I    Number of samples                           */
76     opus_int                    smooth_coef_Q16                 /* I    Smoothing coefficient                       */
77 );
78
79 /* Quantize mid/side predictors */
80 void silk_stereo_quant_pred(
81     opus_int32                  pred_Q13[],                     /* I/O  Predictors (out: quantized)                 */
82     opus_int8                   ix[ 2 ][ 3 ]                    /* O    Quantization indices                        */
83 );
84
85 /* Entropy code the mid/side quantization indices */
86 void silk_stereo_encode_pred(
87     ec_enc                      *psRangeEnc,                    /* I/O  Compressor data structure                   */
88     opus_int8                   ix[ 2 ][ 3 ]                    /* I    Quantization indices                        */
89 );
90
91 /* Entropy code the mid-only flag */
92 void silk_stereo_encode_mid_only(
93     ec_enc                      *psRangeEnc,                    /* I/O  Compressor data structure                   */
94     opus_int8                   mid_only_flag
95 );
96
97 /* Decode mid/side predictors */
98 void silk_stereo_decode_pred(
99     ec_dec                      *psRangeDec,                    /* I/O  Compressor data structure                   */
100     opus_int32                  pred_Q13[]                      /* O    Predictors                                  */
101 );
102
103 /* Decode mid-only flag */
104 void silk_stereo_decode_mid_only(
105     ec_dec                      *psRangeDec,                    /* I/O  Compressor data structure                   */
106     opus_int                    *decode_only_mid                /* O    Flag that only mid channel has been coded   */
107 );
108
109 /* Encodes signs of excitation */
110 void silk_encode_signs(
111     ec_enc                      *psRangeEnc,                        /* I/O  Compressor data structure                   */
112     const opus_int8             pulses[],                           /* I    pulse signal                                */
113     opus_int                    length,                             /* I    length of input                             */
114     const opus_int              signalType,                         /* I    Signal type                                 */
115     const opus_int              quantOffsetType,                    /* I    Quantization offset type                    */
116     const opus_int              sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */
117 );
118
119 /* Decodes signs of excitation */
120 void silk_decode_signs(
121     ec_dec                      *psRangeDec,                        /* I/O  Compressor data structure                   */
122     opus_int                    pulses[],                           /* I/O  pulse signal                                */
123     opus_int                    length,                             /* I    length of input                             */
124     const opus_int              signalType,                         /* I    Signal type                                 */
125     const opus_int              quantOffsetType,                    /* I    Quantization offset type                    */
126     const opus_int              sum_pulses[ MAX_NB_SHELL_BLOCKS ]   /* I    Sum of absolute pulses per block            */
127 );
128
129 /* Check encoder control struct */
130 opus_int check_control_input(
131     silk_EncControlStruct        *encControl                    /* I    Control structure                           */
132 );
133
134 /* Control internal sampling rate */
135 opus_int silk_control_audio_bandwidth(
136     silk_encoder_state          *psEncC,                        /* I/O  Pointer to Silk encoder state               */
137     silk_EncControlStruct       *encControl                     /* I    Control structure                           */
138 );
139
140 /* Control SNR of redidual quantizer */
141 opus_int silk_control_SNR(
142     silk_encoder_state          *psEncC,                        /* I/O  Pointer to Silk encoder state               */
143     opus_int32                  TargetRate_bps                  /* I    Target max bitrate (bps)                    */
144 );
145
146 /***************/
147 /* Shell coder */
148 /***************/
149
150 /* Encode quantization indices of excitation */
151 void silk_encode_pulses(
152     ec_enc                      *psRangeEnc,                    /* I/O  compressor data structure                   */
153     const opus_int              signalType,                     /* I    Signal type                                 */
154     const opus_int              quantOffsetType,                /* I    quantOffsetType                             */
155     opus_int8                   pulses[],                       /* I    quantization indices                        */
156     const opus_int              frame_length                    /* I    Frame length                                */
157 );
158
159 /* Shell encoder, operates on one shell code frame of 16 pulses */
160 void silk_shell_encoder(
161     ec_enc                      *psRangeEnc,                    /* I/O  compressor data structure                   */
162     const opus_int              *pulses0                        /* I    data: nonnegative pulse amplitudes          */
163 );
164
165 /* Shell decoder, operates on one shell code frame of 16 pulses */
166 void silk_shell_decoder(
167     opus_int                    *pulses0,                       /* O    data: nonnegative pulse amplitudes          */
168     ec_dec                      *psRangeDec,                    /* I/O  Compressor data structure                   */
169     const opus_int              pulses4                         /* I    number of pulses per pulse-subframe         */
170 );
171
172 /* Gain scalar quantization with hysteresis, uniform on log scale */
173 void silk_gains_quant(
174     opus_int8                   ind[ MAX_NB_SUBFR ],            /* O    gain indices                                */
175     opus_int32                  gain_Q16[ MAX_NB_SUBFR ],       /* I/O  gains (quantized out)                       */
176     opus_int8                   *prev_ind,                      /* I/O  last index in previous frame                */
177     const opus_int              conditional,                    /* I    first gain is delta coded if 1              */
178     const opus_int              nb_subfr                        /* I    number of subframes                         */
179 );
180
181 /* Gains scalar dequantization, uniform on log scale */
182 void silk_gains_dequant(
183     opus_int32                  gain_Q16[ MAX_NB_SUBFR ],       /* O    quantized gains                             */
184     const opus_int8             ind[ MAX_NB_SUBFR ],            /* I    gain indices                                */
185     opus_int8                   *prev_ind,                      /* I/O  last index in previous frame                */
186     const opus_int              conditional,                    /* I    first gain is delta coded if 1              */
187     const opus_int              nb_subfr                        /* I    number of subframes                          */
188 );
189
190 /* Compute unique identifier of gain indices vector */
191 opus_int32 silk_gains_ID(                                       /* O    returns unique identifier of gains          */
192     const opus_int8             ind[ MAX_NB_SUBFR ],            /* I    gain indices                                */
193     const opus_int              nb_subfr                        /* I    number of subframes                         */
194 );
195
196 /* Interpolate two vectors */
197 void silk_interpolate(
198     opus_int16                  xi[ MAX_LPC_ORDER ],            /* O    interpolated vector                         */
199     const opus_int16            x0[ MAX_LPC_ORDER ],            /* I    first vector                                */
200     const opus_int16            x1[ MAX_LPC_ORDER ],            /* I    second vector                               */
201     const opus_int              ifact_Q2,                       /* I    interp. factor, weight on 2nd vector        */
202     const opus_int              d                               /* I    number of parameters                        */
203 );
204
205 /* LTP tap quantizer */
206 void silk_quant_LTP_gains(
207     opus_int16                  B_Q14[ MAX_NB_SUBFR * LTP_ORDER ],          /* I/O  (un)quantized LTP gains         */
208     opus_int8                   cbk_index[ MAX_NB_SUBFR ],                  /* O    Codebook Index                  */
209     opus_int8                   *periodicity_index,                         /* O    Periodicity Index               */
210     const opus_int32            W_Q18[ MAX_NB_SUBFR*LTP_ORDER*LTP_ORDER ],  /* I    Error Weights in Q18            */
211     opus_int                    mu_Q9,                                      /* I    Mu value (R/D tradeoff)         */
212     opus_int                    lowComplexity,                              /* I    Flag for low complexity         */
213     const opus_int              nb_subfr                                    /* I    number of subframes             */
214 );
215
216 /* Entropy constrained matrix-weighted VQ, for a single input data vector */
217 void silk_VQ_WMat_EC(
218     opus_int8                   *ind,                           /* O    index of best codebook vector               */
219     opus_int32                  *rate_dist_Q14,                 /* O    best weighted quant error + mu * rate       */
220     const opus_int16            *in_Q14,                        /* I    input vector to be quantized                */
221     const opus_int32            *W_Q18,                         /* I    weighting matrix                            */
222     const opus_int8             *cb_Q7,                         /* I    codebook                                    */
223     const opus_uint8            *cl_Q5,                         /* I    code length for each codebook vector        */
224     const opus_int              mu_Q9,                          /* I    tradeoff betw. weighted error and rate      */
225     opus_int                    L                               /* I    number of vectors in codebook               */
226 );
227
228 /************************************/
229 /* Noise shaping quantization (NSQ) */
230 /************************************/
231 void silk_NSQ(
232     const silk_encoder_state    *psEncC,                                    /* I/O  Encoder State                   */
233     silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                       */
234     SideInfoIndices             *psIndices,                                 /* I/O  Quantization Indices            */
235     const opus_int16            x[],                                        /* I    Prefiltered input signal        */
236     opus_int8                   pulses[],                                   /* O    Quantized pulse signal          */
237     const opus_int16            PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefs     */
238     const opus_int16            LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],    /* I    Long term prediction coefs      */
239     const opus_int16            AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs             */
240     const opus_int              HarmShapeGain_Q14[ MAX_NB_SUBFR ],          /* I    Long term shaping coefs         */
241     const opus_int              Tilt_Q14[ MAX_NB_SUBFR ],                   /* I    Spectral tilt                   */
242     const opus_int32            LF_shp_Q14[ MAX_NB_SUBFR ],                 /* I    Low frequency shaping coefs     */
243     const opus_int32            Gains_Q16[ MAX_NB_SUBFR ],                  /* I    Quantization step sizes         */
244     const opus_int              pitchL[ MAX_NB_SUBFR ],                     /* I    Pitch lags                      */
245     const opus_int              Lambda_Q10,                                 /* I    Rate/distortion tradeoff        */
246     const opus_int              LTP_scale_Q14                               /* I    LTP state scaling               */
247 );
248
249 /* Noise shaping using delayed decision */
250 void silk_NSQ_del_dec(
251     const silk_encoder_state    *psEncC,                                    /* I/O  Encoder State                   */
252     silk_nsq_state              *NSQ,                                       /* I/O  NSQ state                       */
253     SideInfoIndices             *psIndices,                                 /* I/O  Quantization Indices            */
254     const opus_int16            x[],                                        /* I    Prefiltered input signal        */
255     opus_int8                   pulses[],                                   /* O    Quantized pulse signal          */
256     const opus_int16            PredCoef_Q12[ 2 * MAX_LPC_ORDER ],          /* I    Short term prediction coefs     */
257     const opus_int16            LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],    /* I    Long term prediction coefs      */
258     const opus_int16            AR2_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs             */
259     const opus_int              HarmShapeGain_Q14[ MAX_NB_SUBFR ],          /* I    Long term shaping coefs         */
260     const opus_int              Tilt_Q14[ MAX_NB_SUBFR ],                   /* I    Spectral tilt                   */
261     const opus_int32            LF_shp_Q14[ MAX_NB_SUBFR ],                 /* I    Low frequency shaping coefs     */
262     const opus_int32            Gains_Q16[ MAX_NB_SUBFR ],                  /* I    Quantization step sizes         */
263     const opus_int              pitchL[ MAX_NB_SUBFR ],                     /* I    Pitch lags                      */
264     const opus_int              Lambda_Q10,                                 /* I    Rate/distortion tradeoff        */
265     const opus_int              LTP_scale_Q14                               /* I    LTP state scaling               */
266 );
267
268 /************/
269 /* Silk VAD */
270 /************/
271 /* Initialize the Silk VAD */
272 opus_int silk_VAD_Init(                                         /* O    Return value, 0 if success                  */
273     silk_VAD_state              *psSilk_VAD                     /* I/O  Pointer to Silk VAD state                   */
274 );
275
276 /* Get speech activity level in Q8 */
277 opus_int silk_VAD_GetSA_Q8(                                     /* O    Return value, 0 if success                  */
278     silk_encoder_state          *psEncC,                        /* I/O  Encoder state                               */
279     const opus_int16            pIn[]                           /* I    PCM input                                   */
280 );
281
282 /* Low-pass filter with variable cutoff frequency based on  */
283 /* piece-wise linear interpolation between elliptic filters */
284 /* Start by setting transition_frame_no = 1;                */
285 void silk_LP_variable_cutoff(
286     silk_LP_state               *psLP,                          /* I/O  LP filter state                             */
287     opus_int16                  *frame,                         /* I/O  Low-pass filtered output signal             */
288     const opus_int              frame_length                    /* I    Frame length                                */
289 );
290
291 /******************/
292 /* NLSF Quantizer */
293 /******************/
294 /* Limit, stabilize, convert and quantize NLSFs */
295 void silk_process_NLSFs(
296     silk_encoder_state          *psEncC,                            /* I/O  Encoder state                               */
297     opus_int16                  PredCoef_Q12[ 2 ][ MAX_LPC_ORDER ], /* O    Prediction coefficients                     */
298     opus_int16                  pNLSF_Q15[         MAX_LPC_ORDER ], /* I/O  Normalized LSFs (quant out) (0 - (2^15-1))  */
299     const opus_int16            prev_NLSFq_Q15[    MAX_LPC_ORDER ]  /* I    Previous Normalized LSFs (0 - (2^15-1))     */
300 );
301
302 opus_int32 silk_NLSF_encode(                                    /* O    Returns RD value in Q25                     */
303           opus_int8             *NLSFIndices,                   /* I    Codebook path vector [ LPC_ORDER + 1 ]      */
304           opus_int16            *pNLSF_Q15,                     /* I/O  Quantized NLSF vector [ LPC_ORDER ]         */
305     const silk_NLSF_CB_struct   *psNLSF_CB,                     /* I    Codebook object                             */
306     const opus_int16            *pW_QW,                         /* I    NLSF weight vector [ LPC_ORDER ]            */
307     const opus_int              NLSF_mu_Q20,                    /* I    Rate weight for the RD optimization         */
308     const opus_int              nSurvivors,                     /* I    Max survivors after first stage             */
309     const opus_int              signalType                      /* I    Signal type: 0/1/2                          */
310 );
311
312 /* Compute quantization errors for an LPC_order element input vector for a VQ codebook */
313 void silk_NLSF_VQ(
314     opus_int32                  err_Q26[],                      /* O    Quantization errors [K]                     */
315     const opus_int16            in_Q15[],                       /* I    Input vectors to be quantized [LPC_order]   */
316     const opus_uint8            pCB_Q8[],                       /* I    Codebook vectors [K*LPC_order]              */
317     const opus_int              K,                              /* I    Number of codebook vectors                  */
318     const opus_int              LPC_order                       /* I    Number of LPCs                              */
319 );
320
321 /* Delayed-decision quantizer for NLSF residuals */
322 opus_int32 silk_NLSF_del_dec_quant(                             /* O    Returns RD value in Q25                     */
323     opus_int8                   indices[],                      /* O    Quantization indices [ order ]              */
324     const opus_int16            x_Q10[],                        /* I    Input [ order ]                             */
325     const opus_int16            w_Q5[],                         /* I    Weights [ order ]                           */
326     const opus_uint8            pred_coef_Q8[],                 /* I    Backward predictor coefs [ order ]          */
327     const opus_int16            ec_ix[],                        /* I    Indices to entropy coding tables [ order ]  */
328     const opus_uint8            ec_rates_Q5[],                  /* I    Rates []                                    */
329     const opus_int              quant_step_size_Q16,            /* I    Quantization step size                      */
330     const opus_int16            inv_quant_step_size_Q6,         /* I    Inverse quantization step size              */
331     const opus_int32            mu_Q20,                         /* I    R/D tradeoff                                */
332     const opus_int16            order                           /* I    Number of input values                      */
333 );
334
335 /* Unpack predictor values and indices for entropy coding tables */
336 void silk_NLSF_unpack(
337           opus_int16            ec_ix[],                        /* O    Indices to entropy tales [ LPC_ORDER ]      */
338           opus_uint8            pred_Q8[],                      /* O    LSF predictor [ LPC_ORDER ]                 */
339     const silk_NLSF_CB_struct   *psNLSF_CB,                     /* I    Codebook object                             */
340     const opus_int              CB1_index                       /* I    Index of vector in first LSF codebook       */
341 );
342
343 /***********************/
344 /* NLSF vector decoder */
345 /***********************/
346 void silk_NLSF_decode(
347           opus_int16            *pNLSF_Q15,                     /* O    Quantized NLSF vector [ LPC_ORDER ]         */
348           opus_int8             *NLSFIndices,                   /* I    Codebook path vector [ LPC_ORDER + 1 ]      */
349     const silk_NLSF_CB_struct   *psNLSF_CB                      /* I    Codebook object                             */
350 );
351
352 /****************************************************/
353 /* Decoder Functions                                */
354 /****************************************************/
355 opus_int silk_init_decoder(
356     silk_decoder_state          *psDec                          /* I/O  Decoder state pointer                       */
357 );
358
359 /* Set decoder sampling rate */
360 opus_int silk_decoder_set_fs(
361     silk_decoder_state          *psDec,                         /* I/O  Decoder state pointer                       */
362     opus_int                    fs_kHz,                         /* I    Sampling frequency (kHz)                    */
363     opus_int                    fs_API_Hz                       /* I    API Sampling frequency (Hz)                 */
364 );
365
366 /****************/
367 /* Decode frame */
368 /****************/
369 opus_int silk_decode_frame(
370     silk_decoder_state          *psDec,                         /* I/O  Pointer to Silk decoder state               */
371     ec_dec                      *psRangeDec,                    /* I/O  Compressor data structure                   */
372     opus_int16                  pOut[],                         /* O    Pointer to output speech frame              */
373     opus_int32                  *pN,                            /* O    Pointer to size of output frame             */
374     opus_int                    lostFlag,                       /* I    0: no loss, 1 loss, 2 decode fec            */
375     opus_int                    condCoding                      /* I    The type of conditional coding to use       */
376 );
377
378 /* Decode indices from bitstream */
379 void silk_decode_indices(
380     silk_decoder_state          *psDec,                         /* I/O  State                                       */
381     ec_dec                      *psRangeDec,                    /* I/O  Compressor data structure                   */
382     opus_int                    FrameIndex,                     /* I    Frame number                                */
383     opus_int                    decode_LBRR,                    /* I    Flag indicating LBRR data is being decoded  */
384     opus_int                    condCoding                      /* I    The type of conditional coding to use       */
385 );
386
387 /* Decode parameters from payload */
388 void silk_decode_parameters(
389     silk_decoder_state          *psDec,                         /* I/O  State                                       */
390     silk_decoder_control        *psDecCtrl,                     /* I/O  Decoder control                             */
391     opus_int                    condCoding                      /* I    The type of conditional coding to use       */
392 );
393
394 /* Core decoder. Performs inverse NSQ operation LTP + LPC */
395 void silk_decode_core(
396     silk_decoder_state          *psDec,                         /* I/O  Decoder state                               */
397     silk_decoder_control        *psDecCtrl,                     /* I    Decoder control                             */
398     opus_int16                  xq[],                           /* O    Decoded speech                              */
399     const opus_int              pulses[ MAX_FRAME_LENGTH ]      /* I    Pulse signal                                */
400 );
401
402 /* Decode quantization indices of excitation (Shell coding) */
403 void silk_decode_pulses(
404     ec_dec                      *psRangeDec,                    /* I/O  Compressor data structure                   */
405     opus_int                    pulses[],                       /* O    Excitation signal                           */
406     const opus_int              signalType,                     /* I    Sigtype                                     */
407     const opus_int              quantOffsetType,                /* I    quantOffsetType                             */
408     const opus_int              frame_length                    /* I    Frame length                                */
409 );
410
411 /******************/
412 /* CNG */
413 /******************/
414
415 /* Reset CNG */
416 void silk_CNG_Reset(
417     silk_decoder_state          *psDec                          /* I/O  Decoder state                               */
418 );
419
420 /* Updates CNG estimate, and applies the CNG when packet was lost */
421 void silk_CNG(
422     silk_decoder_state          *psDec,                         /* I/O  Decoder state                               */
423     silk_decoder_control        *psDecCtrl,                     /* I/O  Decoder control                             */
424     opus_int16                  frame[],                        /* I/O  Signal                                      */
425     opus_int                    length                          /* I    Length of residual                          */
426 );
427
428 /* Encoding of various parameters */
429 void silk_encode_indices(
430     silk_encoder_state          *psEncC,                        /* I/O  Encoder state                               */
431     ec_enc                      *psRangeEnc,                    /* I/O  Compressor data structure                   */
432     opus_int                    FrameIndex,                     /* I    Frame number                                */
433     opus_int                    encode_LBRR,                    /* I    Flag indicating LBRR data is being encoded  */
434     opus_int                    condCoding                      /* I    The type of conditional coding to use       */
435 );
436
437 #endif