| OLD | NEW |
| 1 /*********************************************************************** | 1 /*********************************************************************** |
| 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
| 3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
| 4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
| 5 are met: | 5 are met: |
| 6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
| 7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
| 8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
| 9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
| 10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 /* Initializes the Silk encoder state */ | 72 /* Initializes the Silk encoder state */ |
| 73 opus_int silk_init_encoder( | 73 opus_int silk_init_encoder( |
| 74 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ | 74 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ |
| 75 int arch /* I
Run-tim architecture */ | 75 int arch /* I
Run-tim architecture */ |
| 76 ); | 76 ); |
| 77 | 77 |
| 78 /* Control the Silk encoder */ | 78 /* Control the Silk encoder */ |
| 79 opus_int silk_control_encoder( | 79 opus_int silk_control_encoder( |
| 80 silk_encoder_state_FLP *psEnc, /* I/O
Pointer to Silk encoder state FLP */ | 80 silk_encoder_state_FLP *psEnc, /* I/O
Pointer to Silk encoder state FLP */ |
| 81 silk_EncControlStruct *encControl, /* I
Control structure */ | 81 silk_EncControlStruct *encControl, /* I
Control structure */ |
| 82 const opus_int32 TargetRate_bps, /* I
Target max bitrate (bps) */ | |
| 83 const opus_int allow_bw_switch, /* I
Flag to allow switching audio bandwidth */ | 82 const opus_int allow_bw_switch, /* I
Flag to allow switching audio bandwidth */ |
| 84 const opus_int channelNb, /* I
Channel number */ | 83 const opus_int channelNb, /* I
Channel number */ |
| 85 const opus_int force_fs_kHz | 84 const opus_int force_fs_kHz |
| 86 ); | 85 ); |
| 87 | 86 |
| 88 /****************/ | |
| 89 /* Prefiltering */ | |
| 90 /****************/ | |
| 91 void silk_prefilter_FLP( | |
| 92 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ | |
| 93 const silk_encoder_control_FLP *psEncCtrl, /* I
Encoder control FLP */ | |
| 94 silk_float xw[], /* O
Weighted signal */ | |
| 95 const silk_float x[] /* I
Speech signal */ | |
| 96 ); | |
| 97 | |
| 98 /**************************/ | 87 /**************************/ |
| 99 /* Noise shaping analysis */ | 88 /* Noise shaping analysis */ |
| 100 /**************************/ | 89 /**************************/ |
| 101 /* Compute noise shaping coefficients and initial gain values */ | 90 /* Compute noise shaping coefficients and initial gain values */ |
| 102 void silk_noise_shape_analysis_FLP( | 91 void silk_noise_shape_analysis_FLP( |
| 103 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ | 92 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ |
| 104 silk_encoder_control_FLP *psEncCtrl, /* I/O
Encoder control FLP */ | 93 silk_encoder_control_FLP *psEncCtrl, /* I/O
Encoder control FLP */ |
| 105 const silk_float *pitch_res, /* I
LPC residual from pitch analysis */ | 94 const silk_float *pitch_res, /* I
LPC residual from pitch analysis */ |
| 106 const silk_float *x /* I
Input signal [frame_length + la_shape] */ | 95 const silk_float *x /* I
Input signal [frame_length + la_shape] */ |
| 107 ); | 96 ); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 /* LPC analysis */ | 135 /* LPC analysis */ |
| 147 void silk_find_LPC_FLP( | 136 void silk_find_LPC_FLP( |
| 148 silk_encoder_state *psEncC, /* I/O
Encoder state */ | 137 silk_encoder_state *psEncC, /* I/O
Encoder state */ |
| 149 opus_int16 NLSF_Q15[], /* O
NLSFs */ | 138 opus_int16 NLSF_Q15[], /* O
NLSFs */ |
| 150 const silk_float x[], /* I
Input signal */ | 139 const silk_float x[], /* I
Input signal */ |
| 151 const silk_float minInvGain /* I
Prediction gain from LTP (dB) */ | 140 const silk_float minInvGain /* I
Prediction gain from LTP (dB) */ |
| 152 ); | 141 ); |
| 153 | 142 |
| 154 /* LTP analysis */ | 143 /* LTP analysis */ |
| 155 void silk_find_LTP_FLP( | 144 void silk_find_LTP_FLP( |
| 156 silk_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O
LTP coefs */ | 145 silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ],
/* O Weight for LTP quantization */ |
| 157 silk_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ]
, /* O Weight for LTP quantization */ | 146 silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O
Weight for LTP quantization */ |
| 158 silk_float *LTPredCodGain, /* O
LTP coding gain */ | 147 const silk_float r_ptr[], /* I
LPC residual */ |
| 159 const silk_float r_lpc[], /* I
LPC residual */ | |
| 160 const opus_int lag[ MAX_NB_SUBFR ], /* I
LTP lags */ | 148 const opus_int lag[ MAX_NB_SUBFR ], /* I
LTP lags */ |
| 161 const silk_float Wght[ MAX_NB_SUBFR ], /* I
Weights */ | |
| 162 const opus_int subfr_length, /* I
Subframe length */ | 149 const opus_int subfr_length, /* I
Subframe length */ |
| 163 const opus_int nb_subfr, /* I
number of subframes */ | 150 const opus_int nb_subfr /* I
number of subframes */ |
| 164 const opus_int mem_offset /* I
Number of samples in LTP memory */ | |
| 165 ); | 151 ); |
| 166 | 152 |
| 167 void silk_LTP_analysis_filter_FLP( | 153 void silk_LTP_analysis_filter_FLP( |
| 168 silk_float *LTP_res, /* O
LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */ | 154 silk_float *LTP_res, /* O
LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */ |
| 169 const silk_float *x, /* I
Input signal, with preceding samples */ | 155 const silk_float *x, /* I
Input signal, with preceding samples */ |
| 170 const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I
LTP coefficients for each subframe */ | 156 const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I
LTP coefficients for each subframe */ |
| 171 const opus_int pitchL[ MAX_NB_SUBFR ], /* I
Pitch lags */ | 157 const opus_int pitchL[ MAX_NB_SUBFR ], /* I
Pitch lags */ |
| 172 const silk_float invGains[ MAX_NB_SUBFR ], /* I
Inverse quantization gains */ | 158 const silk_float invGains[ MAX_NB_SUBFR ], /* I
Inverse quantization gains */ |
| 173 const opus_int subfr_length, /* I
Length of each subframe */ | 159 const opus_int subfr_length, /* I
Length of each subframe */ |
| 174 const opus_int nb_subfr, /* I
number of subframes */ | 160 const opus_int nb_subfr, /* I
number of subframes */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 191 void silk_LPC_analysis_filter_FLP( | 177 void silk_LPC_analysis_filter_FLP( |
| 192 silk_float r_LPC[], /* O
LPC residual signal */ | 178 silk_float r_LPC[], /* O
LPC residual signal */ |
| 193 const silk_float PredCoef[], /* I
LPC coefficients */ | 179 const silk_float PredCoef[], /* I
LPC coefficients */ |
| 194 const silk_float s[], /* I
Input signal */ | 180 const silk_float s[], /* I
Input signal */ |
| 195 const opus_int length, /* I
Length of input signal */ | 181 const opus_int length, /* I
Length of input signal */ |
| 196 const opus_int Order /* I
LPC order */ | 182 const opus_int Order /* I
LPC order */ |
| 197 ); | 183 ); |
| 198 | 184 |
| 199 /* LTP tap quantizer */ | 185 /* LTP tap quantizer */ |
| 200 void silk_quant_LTP_gains_FLP( | 186 void silk_quant_LTP_gains_FLP( |
| 201 silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O
(Un-)quantized LTP gains */ | 187 silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O
Quantized LTP gains */ |
| 202 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O
Codebook index */ | 188 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O
Codebook index */ |
| 203 opus_int8 *periodicity_index, /* O
Periodicity index */ | 189 opus_int8 *periodicity_index, /* O
Periodicity index */ |
| 204 opus_int32 *sum_log_gain_Q7, /* I/O
Cumulative max prediction gain */ | 190 opus_int32 *sum_log_gain_Q7, /* I/O
Cumulative max prediction gain */ |
| 205 const silk_float W[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /
* I Error weights */ | 191 silk_float *pred_gain_dB, /* O
LTP prediction gain */ |
| 206 const opus_int mu_Q10, /* I
Mu value (R/D tradeoff) */ | 192 const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ],
/* I Correlation matrix */ |
| 207 const opus_int lowComplexity, /* I
Flag for low complexity */ | 193 const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I
Correlation vector */ |
| 208 const opus_int nb_subfr, /* I
number of subframes */ | 194 const opus_int subfr_len, /* I
Number of samples per subframe */ |
| 195 const opus_int nb_subfr, /* I
Number of subframes */ |
| 209 int arch /* I
Run-time architecture */ | 196 int arch /* I
Run-time architecture */ |
| 210 ); | 197 ); |
| 211 | 198 |
| 212 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ | 199 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */ |
| 213 silk_float silk_residual_energy_covar_FLP( /* O
Weighted residual energy */ | 200 silk_float silk_residual_energy_covar_FLP( /* O
Weighted residual energy */ |
| 214 const silk_float *c, /* I
Filter coefficients */ | 201 const silk_float *c, /* I
Filter coefficients */ |
| 215 silk_float *wXX, /* I/O
Weighted correlation matrix, reg. out */ | 202 silk_float *wXX, /* I/O
Weighted correlation matrix, reg. out */ |
| 216 const silk_float *wXx, /* I
Weighted correlation vector */ | 203 const silk_float *wXx, /* I
Weighted correlation vector */ |
| 217 const silk_float wxx, /* I
Weighted correlation value */ | 204 const silk_float wxx, /* I
Weighted correlation value */ |
| 218 const opus_int D /* I
Dimension */ | 205 const opus_int D /* I
Dimension */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 238 | 225 |
| 239 /* Calculates correlation vector X'*t */ | 226 /* Calculates correlation vector X'*t */ |
| 240 void silk_corrVector_FLP( | 227 void silk_corrVector_FLP( |
| 241 const silk_float *x, /* I
x vector [L+order-1] used to create X */ | 228 const silk_float *x, /* I
x vector [L+order-1] used to create X */ |
| 242 const silk_float *t, /* I
Target vector [L] */ | 229 const silk_float *t, /* I
Target vector [L] */ |
| 243 const opus_int L, /* I
Length of vecors */ | 230 const opus_int L, /* I
Length of vecors */ |
| 244 const opus_int Order, /* I
Max lag for correlation */ | 231 const opus_int Order, /* I
Max lag for correlation */ |
| 245 silk_float *Xt /* O
X'*t correlation vector [order] */ | 232 silk_float *Xt /* O
X'*t correlation vector [order] */ |
| 246 ); | 233 ); |
| 247 | 234 |
| 248 /* Add noise to matrix diagonal */ | |
| 249 void silk_regularize_correlations_FLP( | |
| 250 silk_float *XX, /* I/O
Correlation matrices */ | |
| 251 silk_float *xx, /* I/O
Correlation values */ | |
| 252 const silk_float noise, /* I
Noise energy to add */ | |
| 253 const opus_int D /* I
Dimension of XX */ | |
| 254 ); | |
| 255 | |
| 256 /* Function to solve linear equation Ax = b, where A is an MxM symmetric matrix
*/ | |
| 257 void silk_solve_LDL_FLP( | |
| 258 silk_float *A, /* I/O
Symmetric square matrix, out: reg. */ | |
| 259 const opus_int M, /* I
Size of matrix */ | |
| 260 const silk_float *b, /* I
Pointer to b vector */ | |
| 261 silk_float *x /* O
Pointer to x solution vector */ | |
| 262 ); | |
| 263 | |
| 264 /* Apply sine window to signal vector. */ | 235 /* Apply sine window to signal vector. */ |
| 265 /* Window types: */ | 236 /* Window types: */ |
| 266 /* 1 -> sine window from 0 to pi/2 */ | 237 /* 1 -> sine window from 0 to pi/2 */ |
| 267 /* 2 -> sine window from pi/2 to pi */ | 238 /* 2 -> sine window from pi/2 to pi */ |
| 268 void silk_apply_sine_window_FLP( | 239 void silk_apply_sine_window_FLP( |
| 269 silk_float px_win[], /* O
Pointer to windowed signal */ | 240 silk_float px_win[], /* O
Pointer to windowed signal */ |
| 270 const silk_float px[], /* I
Pointer to input signal */ | 241 const silk_float px[], /* I
Pointer to input signal */ |
| 271 const opus_int win_type, /* I
Selects a window type */ | 242 const opus_int win_type, /* I
Selects a window type */ |
| 272 const opus_int length /* I
Window length, multiple of 4 */ | 243 const opus_int length /* I
Window length, multiple of 4 */ |
| 273 ); | 244 ); |
| 274 | 245 |
| 275 /* Wrapper functions. Call flp / fix code */ | 246 /* Wrapper functions. Call flp / fix code */ |
| 276 | 247 |
| 277 /* Convert AR filter coefficients to NLSF parameters */ | 248 /* Convert AR filter coefficients to NLSF parameters */ |
| 278 void silk_A2NLSF_FLP( | 249 void silk_A2NLSF_FLP( |
| 279 opus_int16 *NLSF_Q15, /* O
NLSF vector [ LPC_order ] */ | 250 opus_int16 *NLSF_Q15, /* O
NLSF vector [ LPC_order ] */ |
| 280 const silk_float *pAR, /* I
LPC coefficients [ LPC_order ] */ | 251 const silk_float *pAR, /* I
LPC coefficients [ LPC_order ] */ |
| 281 const opus_int LPC_order /* I
LPC order */ | 252 const opus_int LPC_order /* I
LPC order */ |
| 282 ); | 253 ); |
| 283 | 254 |
| 284 /* Convert NLSF parameters to AR prediction filter coefficients */ | 255 /* Convert NLSF parameters to AR prediction filter coefficients */ |
| 285 void silk_NLSF2A_FLP( | 256 void silk_NLSF2A_FLP( |
| 286 silk_float *pAR, /* O
LPC coefficients [ LPC_order ] */ | 257 silk_float *pAR, /* O
LPC coefficients [ LPC_order ] */ |
| 287 const opus_int16 *NLSF_Q15, /* I
NLSF vector [ LPC_order ] */ | 258 const opus_int16 *NLSF_Q15, /* I
NLSF vector [ LPC_order ] */ |
| 288 const opus_int LPC_order /* I
LPC order */ | 259 const opus_int LPC_order, /* I
LPC order */ |
| 260 int arch /* I
Run-time architecture */ |
| 289 ); | 261 ); |
| 290 | 262 |
| 291 /* Limit, stabilize, and quantize NLSFs */ | 263 /* Limit, stabilize, and quantize NLSFs */ |
| 292 void silk_process_NLSFs_FLP( | 264 void silk_process_NLSFs_FLP( |
| 293 silk_encoder_state *psEncC, /* I/O
Encoder state */ | 265 silk_encoder_state *psEncC, /* I/O
Encoder state */ |
| 294 silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O
Prediction coefficients */ | 266 silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O
Prediction coefficients */ |
| 295 opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O
Normalized LSFs (quant out) (0 - (2^15-1)) */ | 267 opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O
Normalized LSFs (quant out) (0 - (2^15-1)) */ |
| 296 const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I
Previous Normalized LSFs (0 - (2^15-1)) */ | 268 const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I
Previous Normalized LSFs (0 - (2^15-1)) */ |
| 297 ); | 269 ); |
| 298 | 270 |
| 299 /* Floating-point Silk NSQ wrapper */ | 271 /* Floating-point Silk NSQ wrapper */ |
| 300 void silk_NSQ_wrapper_FLP( | 272 void silk_NSQ_wrapper_FLP( |
| 301 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ | 273 silk_encoder_state_FLP *psEnc, /* I/O
Encoder state FLP */ |
| 302 silk_encoder_control_FLP *psEncCtrl, /* I/O
Encoder control FLP */ | 274 silk_encoder_control_FLP *psEncCtrl, /* I/O
Encoder control FLP */ |
| 303 SideInfoIndices *psIndices, /* I/O
Quantization indices */ | 275 SideInfoIndices *psIndices, /* I/O
Quantization indices */ |
| 304 silk_nsq_state *psNSQ, /* I/O
Noise Shaping Quantzation state */ | 276 silk_nsq_state *psNSQ, /* I/O
Noise Shaping Quantzation state */ |
| 305 opus_int8 pulses[], /* O
Quantized pulse signal */ | 277 opus_int8 pulses[], /* O
Quantized pulse signal */ |
| 306 const silk_float x[] /* I
Prefiltered input signal */ | 278 const silk_float x[] /* I
Prefiltered input signal */ |
| 307 ); | 279 ); |
| 308 | 280 |
| 309 #ifdef __cplusplus | 281 #ifdef __cplusplus |
| 310 } | 282 } |
| 311 #endif | 283 #endif |
| 312 | 284 |
| 313 #endif | 285 #endif |
| OLD | NEW |