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