annotate src/opus-1.3/silk/fixed/main_FIX.h @ 168:ceec0dd9ec9c

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 07 Feb 2020 11:51:13 +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_FIX_H
cannam@154 29 #define SILK_MAIN_FIX_H
cannam@154 30
cannam@154 31 #include "SigProc_FIX.h"
cannam@154 32 #include "structs_FIX.h"
cannam@154 33 #include "control.h"
cannam@154 34 #include "main.h"
cannam@154 35 #include "PLC.h"
cannam@154 36 #include "debug.h"
cannam@154 37 #include "entenc.h"
cannam@154 38
cannam@154 39 #if ((defined(OPUS_ARM_ASM) && defined(FIXED_POINT)) \
cannam@154 40 || defined(OPUS_ARM_MAY_HAVE_NEON_INTR))
cannam@154 41 #include "fixed/arm/warped_autocorrelation_FIX_arm.h"
cannam@154 42 #endif
cannam@154 43
cannam@154 44 #ifndef FORCE_CPP_BUILD
cannam@154 45 #ifdef __cplusplus
cannam@154 46 extern "C"
cannam@154 47 {
cannam@154 48 #endif
cannam@154 49 #endif
cannam@154 50
cannam@154 51 #define silk_encoder_state_Fxx silk_encoder_state_FIX
cannam@154 52 #define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FIX
cannam@154 53 #define silk_encode_frame_Fxx silk_encode_frame_FIX
cannam@154 54
cannam@154 55 #define QC 10
cannam@154 56 #define QS 13
cannam@154 57
cannam@154 58 /*********************/
cannam@154 59 /* Encoder Functions */
cannam@154 60 /*********************/
cannam@154 61
cannam@154 62 /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
cannam@154 63 void silk_HP_variable_cutoff(
cannam@154 64 silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */
cannam@154 65 );
cannam@154 66
cannam@154 67 /* Encoder main function */
cannam@154 68 void silk_encode_do_VAD_FIX(
cannam@154 69 silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
cannam@154 70 opus_int activity /* I Decision of Opus voice activity detector */
cannam@154 71 );
cannam@154 72
cannam@154 73 /* Encoder main function */
cannam@154 74 opus_int silk_encode_frame_FIX(
cannam@154 75 silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
cannam@154 76 opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
cannam@154 77 ec_enc *psRangeEnc, /* I/O compressor data structure */
cannam@154 78 opus_int condCoding, /* I The type of conditional coding to use */
cannam@154 79 opus_int maxBits, /* I If > 0: maximum number of output bits */
cannam@154 80 opus_int useCBR /* I Flag to force constant-bitrate operation */
cannam@154 81 );
cannam@154 82
cannam@154 83 /* Initializes the Silk encoder state */
cannam@154 84 opus_int silk_init_encoder(
cannam@154 85 silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk FIX encoder state */
cannam@154 86 int arch /* I Run-time architecture */
cannam@154 87 );
cannam@154 88
cannam@154 89 /* Control the Silk encoder */
cannam@154 90 opus_int silk_control_encoder(
cannam@154 91 silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
cannam@154 92 silk_EncControlStruct *encControl, /* I Control structure */
cannam@154 93 const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
cannam@154 94 const opus_int channelNb, /* I Channel number */
cannam@154 95 const opus_int force_fs_kHz
cannam@154 96 );
cannam@154 97
cannam@154 98 /**************************/
cannam@154 99 /* Noise shaping analysis */
cannam@154 100 /**************************/
cannam@154 101 /* Compute noise shaping coefficients and initial gain values */
cannam@154 102 void silk_noise_shape_analysis_FIX(
cannam@154 103 silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
cannam@154 104 silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
cannam@154 105 const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
cannam@154 106 const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */
cannam@154 107 int arch /* I Run-time architecture */
cannam@154 108 );
cannam@154 109
cannam@154 110 /* Autocorrelations for a warped frequency axis */
cannam@154 111 void silk_warped_autocorrelation_FIX_c(
cannam@154 112 opus_int32 *corr, /* O Result [order + 1] */
cannam@154 113 opus_int *scale, /* O Scaling of the correlation vector */
cannam@154 114 const opus_int16 *input, /* I Input data to correlate */
cannam@154 115 const opus_int warping_Q16, /* I Warping coefficient */
cannam@154 116 const opus_int length, /* I Length of input */
cannam@154 117 const opus_int order /* I Correlation order (even) */
cannam@154 118 );
cannam@154 119
cannam@154 120 #if !defined(OVERRIDE_silk_warped_autocorrelation_FIX)
cannam@154 121 #define silk_warped_autocorrelation_FIX(corr, scale, input, warping_Q16, length, order, arch) \
cannam@154 122 ((void)(arch), silk_warped_autocorrelation_FIX_c(corr, scale, input, warping_Q16, length, order))
cannam@154 123 #endif
cannam@154 124
cannam@154 125 /* Calculation of LTP state scaling */
cannam@154 126 void silk_LTP_scale_ctrl_FIX(
cannam@154 127 silk_encoder_state_FIX *psEnc, /* I/O encoder state */
cannam@154 128 silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
cannam@154 129 opus_int condCoding /* I The type of conditional coding to use */
cannam@154 130 );
cannam@154 131
cannam@154 132 /**********************************************/
cannam@154 133 /* Prediction Analysis */
cannam@154 134 /**********************************************/
cannam@154 135 /* Find pitch lags */
cannam@154 136 void silk_find_pitch_lags_FIX(
cannam@154 137 silk_encoder_state_FIX *psEnc, /* I/O encoder state */
cannam@154 138 silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
cannam@154 139 opus_int16 res[], /* O residual */
cannam@154 140 const opus_int16 x[], /* I Speech signal */
cannam@154 141 int arch /* I Run-time architecture */
cannam@154 142 );
cannam@154 143
cannam@154 144 /* Find LPC and LTP coefficients */
cannam@154 145 void silk_find_pred_coefs_FIX(
cannam@154 146 silk_encoder_state_FIX *psEnc, /* I/O encoder state */
cannam@154 147 silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
cannam@154 148 const opus_int16 res_pitch[], /* I Residual from pitch analysis */
cannam@154 149 const opus_int16 x[], /* I Speech signal */
cannam@154 150 opus_int condCoding /* I The type of conditional coding to use */
cannam@154 151 );
cannam@154 152
cannam@154 153 /* LPC analysis */
cannam@154 154 void silk_find_LPC_FIX(
cannam@154 155 silk_encoder_state *psEncC, /* I/O Encoder state */
cannam@154 156 opus_int16 NLSF_Q15[], /* O NLSFs */
cannam@154 157 const opus_int16 x[], /* I Input signal */
cannam@154 158 const opus_int32 minInvGain_Q30 /* I Inverse of max prediction gain */
cannam@154 159 );
cannam@154 160
cannam@154 161 /* LTP analysis */
cannam@154 162 void silk_find_LTP_FIX(
cannam@154 163 opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Correlation matrix */
cannam@154 164 opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O Correlation vector */
cannam@154 165 const opus_int16 r_lpc[], /* I Residual signal after LPC */
cannam@154 166 const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
cannam@154 167 const opus_int subfr_length, /* I Subframe length */
cannam@154 168 const opus_int nb_subfr, /* I Number of subframes */
cannam@154 169 int arch /* I Run-time architecture */
cannam@154 170 );
cannam@154 171
cannam@154 172 void silk_LTP_analysis_filter_FIX(
cannam@154 173 opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
cannam@154 174 const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceding samples */
cannam@154 175 const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
cannam@154 176 const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */
cannam@154 177 const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */
cannam@154 178 const opus_int subfr_length, /* I Length of each subframe */
cannam@154 179 const opus_int nb_subfr, /* I Number of subframes */
cannam@154 180 const opus_int pre_length /* I Length of the preceding samples starting at &x[0] for each subframe */
cannam@154 181 );
cannam@154 182
cannam@154 183 /* Calculates residual energies of input subframes where all subframes have LPC_order */
cannam@154 184 /* of preceding samples */
cannam@154 185 void silk_residual_energy_FIX(
cannam@154 186 opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
cannam@154 187 opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
cannam@154 188 const opus_int16 x[], /* I Input signal */
cannam@154 189 opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
cannam@154 190 const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
cannam@154 191 const opus_int subfr_length, /* I Subframe length */
cannam@154 192 const opus_int nb_subfr, /* I Number of subframes */
cannam@154 193 const opus_int LPC_order, /* I LPC order */
cannam@154 194 int arch /* I Run-time architecture */
cannam@154 195 );
cannam@154 196
cannam@154 197 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
cannam@154 198 opus_int32 silk_residual_energy16_covar_FIX(
cannam@154 199 const opus_int16 *c, /* I Prediction vector */
cannam@154 200 const opus_int32 *wXX, /* I Correlation matrix */
cannam@154 201 const opus_int32 *wXx, /* I Correlation vector */
cannam@154 202 opus_int32 wxx, /* I Signal energy */
cannam@154 203 opus_int D, /* I Dimension */
cannam@154 204 opus_int cQ /* I Q value for c vector 0 - 15 */
cannam@154 205 );
cannam@154 206
cannam@154 207 /* Processing of gains */
cannam@154 208 void silk_process_gains_FIX(
cannam@154 209 silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
cannam@154 210 silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */
cannam@154 211 opus_int condCoding /* I The type of conditional coding to use */
cannam@154 212 );
cannam@154 213
cannam@154 214 /******************/
cannam@154 215 /* Linear Algebra */
cannam@154 216 /******************/
cannam@154 217 /* Calculates correlation matrix X'*X */
cannam@154 218 void silk_corrMatrix_FIX(
cannam@154 219 const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
cannam@154 220 const opus_int L, /* I Length of vectors */
cannam@154 221 const opus_int order, /* I Max lag for correlation */
cannam@154 222 opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */
cannam@154 223 opus_int32 *nrg, /* O Energy of x vector */
cannam@154 224 opus_int *rshifts, /* O Right shifts of correlations */
cannam@154 225 int arch /* I Run-time architecture */
cannam@154 226 );
cannam@154 227
cannam@154 228 /* Calculates correlation vector X'*t */
cannam@154 229 void silk_corrVector_FIX(
cannam@154 230 const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
cannam@154 231 const opus_int16 *t, /* I Target vector [L] */
cannam@154 232 const opus_int L, /* I Length of vectors */
cannam@154 233 const opus_int order, /* I Max lag for correlation */
cannam@154 234 opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
cannam@154 235 const opus_int rshifts, /* I Right shifts of correlations */
cannam@154 236 int arch /* I Run-time architecture */
cannam@154 237 );
cannam@154 238
cannam@154 239 #ifndef FORCE_CPP_BUILD
cannam@154 240 #ifdef __cplusplus
cannam@154 241 }
cannam@154 242 #endif /* __cplusplus */
cannam@154 243 #endif /* FORCE_CPP_BUILD */
cannam@154 244 #endif /* SILK_MAIN_FIX_H */