annotate src/opus-1.3/silk/float/main_FLP.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_FLP_H
Chris@69 29 #define SILK_MAIN_FLP_H
Chris@69 30
Chris@69 31 #include "SigProc_FLP.h"
Chris@69 32 #include "SigProc_FIX.h"
Chris@69 33 #include "structs_FLP.h"
Chris@69 34 #include "main.h"
Chris@69 35 #include "define.h"
Chris@69 36 #include "debug.h"
Chris@69 37 #include "entenc.h"
Chris@69 38
Chris@69 39 #ifdef __cplusplus
Chris@69 40 extern "C"
Chris@69 41 {
Chris@69 42 #endif
Chris@69 43
Chris@69 44 #define silk_encoder_state_Fxx silk_encoder_state_FLP
Chris@69 45 #define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FLP
Chris@69 46 #define silk_encode_frame_Fxx silk_encode_frame_FLP
Chris@69 47
Chris@69 48 /*********************/
Chris@69 49 /* Encoder Functions */
Chris@69 50 /*********************/
Chris@69 51
Chris@69 52 /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
Chris@69 53 void silk_HP_variable_cutoff(
Chris@69 54 silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */
Chris@69 55 );
Chris@69 56
Chris@69 57 /* Encoder main function */
Chris@69 58 void silk_encode_do_VAD_FLP(
Chris@69 59 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 60 opus_int activity /* I Decision of Opus voice activity detector */
Chris@69 61 );
Chris@69 62
Chris@69 63 /* Encoder main function */
Chris@69 64 opus_int silk_encode_frame_FLP(
Chris@69 65 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 66 opus_int32 *pnBytesOut, /* O Number of payload bytes; */
Chris@69 67 ec_enc *psRangeEnc, /* I/O compressor data structure */
Chris@69 68 opus_int condCoding, /* I The type of conditional coding to use */
Chris@69 69 opus_int maxBits, /* I If > 0: maximum number of output bits */
Chris@69 70 opus_int useCBR /* I Flag to force constant-bitrate operation */
Chris@69 71 );
Chris@69 72
Chris@69 73 /* Initializes the Silk encoder state */
Chris@69 74 opus_int silk_init_encoder(
Chris@69 75 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 76 int arch /* I Run-tim architecture */
Chris@69 77 );
Chris@69 78
Chris@69 79 /* Control the Silk encoder */
Chris@69 80 opus_int silk_control_encoder(
Chris@69 81 silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
Chris@69 82 silk_EncControlStruct *encControl, /* I Control structure */
Chris@69 83 const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
Chris@69 84 const opus_int channelNb, /* I Channel number */
Chris@69 85 const opus_int force_fs_kHz
Chris@69 86 );
Chris@69 87
Chris@69 88 /**************************/
Chris@69 89 /* Noise shaping analysis */
Chris@69 90 /**************************/
Chris@69 91 /* Compute noise shaping coefficients and initial gain values */
Chris@69 92 void silk_noise_shape_analysis_FLP(
Chris@69 93 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 94 silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
Chris@69 95 const silk_float *pitch_res, /* I LPC residual from pitch analysis */
Chris@69 96 const silk_float *x /* I Input signal [frame_length + la_shape] */
Chris@69 97 );
Chris@69 98
Chris@69 99 /* Autocorrelations for a warped frequency axis */
Chris@69 100 void silk_warped_autocorrelation_FLP(
Chris@69 101 silk_float *corr, /* O Result [order + 1] */
Chris@69 102 const silk_float *input, /* I Input data to correlate */
Chris@69 103 const silk_float warping, /* I Warping coefficient */
Chris@69 104 const opus_int length, /* I Length of input */
Chris@69 105 const opus_int order /* I Correlation order (even) */
Chris@69 106 );
Chris@69 107
Chris@69 108 /* Calculation of LTP state scaling */
Chris@69 109 void silk_LTP_scale_ctrl_FLP(
Chris@69 110 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 111 silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
Chris@69 112 opus_int condCoding /* I The type of conditional coding to use */
Chris@69 113 );
Chris@69 114
Chris@69 115 /**********************************************/
Chris@69 116 /* Prediction Analysis */
Chris@69 117 /**********************************************/
Chris@69 118 /* Find pitch lags */
Chris@69 119 void silk_find_pitch_lags_FLP(
Chris@69 120 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 121 silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
Chris@69 122 silk_float res[], /* O Residual */
Chris@69 123 const silk_float x[], /* I Speech signal */
Chris@69 124 int arch /* I Run-time architecture */
Chris@69 125 );
Chris@69 126
Chris@69 127 /* Find LPC and LTP coefficients */
Chris@69 128 void silk_find_pred_coefs_FLP(
Chris@69 129 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 130 silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
Chris@69 131 const silk_float res_pitch[], /* I Residual from pitch analysis */
Chris@69 132 const silk_float x[], /* I Speech signal */
Chris@69 133 opus_int condCoding /* I The type of conditional coding to use */
Chris@69 134 );
Chris@69 135
Chris@69 136 /* LPC analysis */
Chris@69 137 void silk_find_LPC_FLP(
Chris@69 138 silk_encoder_state *psEncC, /* I/O Encoder state */
Chris@69 139 opus_int16 NLSF_Q15[], /* O NLSFs */
Chris@69 140 const silk_float x[], /* I Input signal */
Chris@69 141 const silk_float minInvGain /* I Prediction gain from LTP (dB) */
Chris@69 142 );
Chris@69 143
Chris@69 144 /* LTP analysis */
Chris@69 145 void silk_find_LTP_FLP(
Chris@69 146 silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
Chris@69 147 silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* O Weight for LTP quantization */
Chris@69 148 const silk_float r_ptr[], /* I LPC residual */
Chris@69 149 const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
Chris@69 150 const opus_int subfr_length, /* I Subframe length */
Chris@69 151 const opus_int nb_subfr /* I number of subframes */
Chris@69 152 );
Chris@69 153
Chris@69 154 void silk_LTP_analysis_filter_FLP(
Chris@69 155 silk_float *LTP_res, /* O LTP res MAX_NB_SUBFR*(pre_lgth+subfr_lngth) */
Chris@69 156 const silk_float *x, /* I Input signal, with preceding samples */
Chris@69 157 const silk_float B[ LTP_ORDER * MAX_NB_SUBFR ], /* I LTP coefficients for each subframe */
Chris@69 158 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
Chris@69 159 const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
Chris@69 160 const opus_int subfr_length, /* I Length of each subframe */
Chris@69 161 const opus_int nb_subfr, /* I number of subframes */
Chris@69 162 const opus_int pre_length /* I Preceding samples for each subframe */
Chris@69 163 );
Chris@69 164
Chris@69 165 /* Calculates residual energies of input subframes where all subframes have LPC_order */
Chris@69 166 /* of preceding samples */
Chris@69 167 void silk_residual_energy_FLP(
Chris@69 168 silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
Chris@69 169 const silk_float x[], /* I Input signal */
Chris@69 170 silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
Chris@69 171 const silk_float gains[], /* I Quantization gains */
Chris@69 172 const opus_int subfr_length, /* I Subframe length */
Chris@69 173 const opus_int nb_subfr, /* I number of subframes */
Chris@69 174 const opus_int LPC_order /* I LPC order */
Chris@69 175 );
Chris@69 176
Chris@69 177 /* 16th order LPC analysis filter */
Chris@69 178 void silk_LPC_analysis_filter_FLP(
Chris@69 179 silk_float r_LPC[], /* O LPC residual signal */
Chris@69 180 const silk_float PredCoef[], /* I LPC coefficients */
Chris@69 181 const silk_float s[], /* I Input signal */
Chris@69 182 const opus_int length, /* I Length of input signal */
Chris@69 183 const opus_int Order /* I LPC order */
Chris@69 184 );
Chris@69 185
Chris@69 186 /* LTP tap quantizer */
Chris@69 187 void silk_quant_LTP_gains_FLP(
Chris@69 188 silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* O Quantized LTP gains */
Chris@69 189 opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
Chris@69 190 opus_int8 *periodicity_index, /* O Periodicity index */
Chris@69 191 opus_int32 *sum_log_gain_Q7, /* I/O Cumulative max prediction gain */
Chris@69 192 silk_float *pred_gain_dB, /* O LTP prediction gain */
Chris@69 193 const silk_float XX[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* I Correlation matrix */
Chris@69 194 const silk_float xX[ MAX_NB_SUBFR * LTP_ORDER ], /* I Correlation vector */
Chris@69 195 const opus_int subfr_len, /* I Number of samples per subframe */
Chris@69 196 const opus_int nb_subfr, /* I Number of subframes */
Chris@69 197 int arch /* I Run-time architecture */
Chris@69 198 );
Chris@69 199
Chris@69 200 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
Chris@69 201 silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */
Chris@69 202 const silk_float *c, /* I Filter coefficients */
Chris@69 203 silk_float *wXX, /* I/O Weighted correlation matrix, reg. out */
Chris@69 204 const silk_float *wXx, /* I Weighted correlation vector */
Chris@69 205 const silk_float wxx, /* I Weighted correlation value */
Chris@69 206 const opus_int D /* I Dimension */
Chris@69 207 );
Chris@69 208
Chris@69 209 /* Processing of gains */
Chris@69 210 void silk_process_gains_FLP(
Chris@69 211 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 212 silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
Chris@69 213 opus_int condCoding /* I The type of conditional coding to use */
Chris@69 214 );
Chris@69 215
Chris@69 216 /******************/
Chris@69 217 /* Linear Algebra */
Chris@69 218 /******************/
Chris@69 219 /* Calculates correlation matrix X'*X */
Chris@69 220 void silk_corrMatrix_FLP(
Chris@69 221 const silk_float *x, /* I x vector [ L+order-1 ] used to create X */
Chris@69 222 const opus_int L, /* I Length of vectors */
Chris@69 223 const opus_int Order, /* I Max lag for correlation */
Chris@69 224 silk_float *XX /* O X'*X correlation matrix [order x order] */
Chris@69 225 );
Chris@69 226
Chris@69 227 /* Calculates correlation vector X'*t */
Chris@69 228 void silk_corrVector_FLP(
Chris@69 229 const silk_float *x, /* I x vector [L+order-1] used to create X */
Chris@69 230 const silk_float *t, /* I Target vector [L] */
Chris@69 231 const opus_int L, /* I Length of vecors */
Chris@69 232 const opus_int Order, /* I Max lag for correlation */
Chris@69 233 silk_float *Xt /* O X'*t correlation vector [order] */
Chris@69 234 );
Chris@69 235
Chris@69 236 /* Apply sine window to signal vector. */
Chris@69 237 /* Window types: */
Chris@69 238 /* 1 -> sine window from 0 to pi/2 */
Chris@69 239 /* 2 -> sine window from pi/2 to pi */
Chris@69 240 void silk_apply_sine_window_FLP(
Chris@69 241 silk_float px_win[], /* O Pointer to windowed signal */
Chris@69 242 const silk_float px[], /* I Pointer to input signal */
Chris@69 243 const opus_int win_type, /* I Selects a window type */
Chris@69 244 const opus_int length /* I Window length, multiple of 4 */
Chris@69 245 );
Chris@69 246
Chris@69 247 /* Wrapper functions. Call flp / fix code */
Chris@69 248
Chris@69 249 /* Convert AR filter coefficients to NLSF parameters */
Chris@69 250 void silk_A2NLSF_FLP(
Chris@69 251 opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
Chris@69 252 const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */
Chris@69 253 const opus_int LPC_order /* I LPC order */
Chris@69 254 );
Chris@69 255
Chris@69 256 /* Convert NLSF parameters to AR prediction filter coefficients */
Chris@69 257 void silk_NLSF2A_FLP(
Chris@69 258 silk_float *pAR, /* O LPC coefficients [ LPC_order ] */
Chris@69 259 const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
Chris@69 260 const opus_int LPC_order, /* I LPC order */
Chris@69 261 int arch /* I Run-time architecture */
Chris@69 262 );
Chris@69 263
Chris@69 264 /* Limit, stabilize, and quantize NLSFs */
Chris@69 265 void silk_process_NLSFs_FLP(
Chris@69 266 silk_encoder_state *psEncC, /* I/O Encoder state */
Chris@69 267 silk_float PredCoef[ 2 ][ MAX_LPC_ORDER ], /* O Prediction coefficients */
Chris@69 268 opus_int16 NLSF_Q15[ MAX_LPC_ORDER ], /* I/O Normalized LSFs (quant out) (0 - (2^15-1)) */
Chris@69 269 const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
Chris@69 270 );
Chris@69 271
Chris@69 272 /* Floating-point Silk NSQ wrapper */
Chris@69 273 void silk_NSQ_wrapper_FLP(
Chris@69 274 silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
Chris@69 275 silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
Chris@69 276 SideInfoIndices *psIndices, /* I/O Quantization indices */
Chris@69 277 silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
Chris@69 278 opus_int8 pulses[], /* O Quantized pulse signal */
Chris@69 279 const silk_float x[] /* I Prefiltered input signal */
Chris@69 280 );
Chris@69 281
Chris@69 282 #ifdef __cplusplus
Chris@69 283 }
Chris@69 284 #endif
Chris@69 285
Chris@69 286 #endif