annotate src/opus-1.3/silk/main.h @ 169:223a55898ab9 tip default

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