annotate src/opus-1.3/silk/main.h @ 79:91c729825bca pa_catalina

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