webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
main_FIX.h
Go to the documentation of this file.
1 /***********************************************************************
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions
5 are met:
6 - Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright
9 notice, this list of conditions and the following disclaimer in the
10 documentation and/or other materials provided with the distribution.
11 - Neither the name of Internet Society, IETF or IETF Trust, nor the
12 names of specific contributors, may be used to endorse or promote
13 products derived from this software without specific prior written
14 permission.
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 POSSIBILITY OF SUCH DAMAGE.
26 ***********************************************************************/
27 
28 #ifndef SILK_MAIN_FIX_H
29 #define SILK_MAIN_FIX_H
30 
31 #include "SigProc_FIX.h"
32 #include "structs_FIX.h"
33 #include "control.h"
34 #include "main.h"
35 #include "PLC.h"
36 #include "debug.h"
37 #include "entenc.h"
38 
39 #ifndef FORCE_CPP_BUILD
40 #ifdef __cplusplus
41 extern "C"
42 {
43 #endif
44 #endif
45 
46 #define silk_encoder_state_Fxx silk_encoder_state_FIX
47 #define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FIX
48 #define silk_encode_frame_Fxx silk_encode_frame_FIX
49 
50 /*********************/
51 /* Encoder Functions */
52 /*********************/
53 
54 /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
56  silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */
57 );
58 
59 /* Encoder main function */
61  silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */
62 );
63 
64 /* Encoder main function */
66  silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */
67  opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */
68  ec_enc *psRangeEnc, /* I/O compressor data structure */
69  opus_int condCoding, /* I The type of conditional coding to use */
70  opus_int maxBits, /* I If > 0: maximum number of output bits */
71  opus_int useCBR /* I Flag to force constant-bitrate operation */
72 );
73 
74 /* Initializes the Silk encoder state */
76  silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk FIX encoder state */
77  int arch /* I Run-time architecture */
78 );
79 
80 /* Control the Silk encoder */
82  silk_encoder_state_Fxx *psEnc, /* I/O Pointer to Silk encoder state */
83  silk_EncControlStruct *encControl, /* I Control structure */
84  const opus_int32 TargetRate_bps, /* I Target max bitrate (bps) */
85  const opus_int allow_bw_switch, /* I Flag to allow switching audio bandwidth */
86  const opus_int channelNb, /* I Channel number */
87  const opus_int force_fs_kHz
88 );
89 
90 /****************/
91 /* Prefiltering */
92 /****************/
94  silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
95  const silk_encoder_control_FIX *psEncCtrl, /* I Encoder control */
96  opus_int32 xw_Q10[], /* O Weighted signal */
97  const opus_int16 x[] /* I Speech signal */
98 );
99 
101  opus_int32 state[], /* I/O State [order + 1] */
102  opus_int32 res_Q2[], /* O Residual signal [length] */
103  const opus_int16 coef_Q13[], /* I Coefficients [order] */
104  const opus_int16 input[], /* I Input signal [length] */
105  const opus_int16 lambda_Q16, /* I Warping factor */
106  const opus_int length, /* I Length of input signal */
107  const opus_int order /* I Filter order (even) */
108 );
109 
110 
111 /**************************/
112 /* Noise shaping analysis */
113 /**************************/
114 /* Compute noise shaping coefficients and initial gain values */
116  silk_encoder_state_FIX *psEnc, /* I/O Encoder state FIX */
117  silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control FIX */
118  const opus_int16 *pitch_res, /* I LPC residual from pitch analysis */
119  const opus_int16 *x, /* I Input signal [ frame_length + la_shape ] */
120  int arch /* I Run-time architecture */
121 );
122 
123 /* Autocorrelations for a warped frequency axis */
125  opus_int32 *corr, /* O Result [order + 1] */
126  opus_int *scale, /* O Scaling of the correlation vector */
127  const opus_int16 *input, /* I Input data to correlate */
128  const opus_int warping_Q16, /* I Warping coefficient */
129  const opus_int length, /* I Length of input */
130  const opus_int order /* I Correlation order (even) */
131 );
132 
133 /* Calculation of LTP state scaling */
135  silk_encoder_state_FIX *psEnc, /* I/O encoder state */
136  silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
137  opus_int condCoding /* I The type of conditional coding to use */
138 );
139 
140 /**********************************************/
141 /* Prediction Analysis */
142 /**********************************************/
143 /* Find pitch lags */
145  silk_encoder_state_FIX *psEnc, /* I/O encoder state */
146  silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
147  opus_int16 res[], /* O residual */
148  const opus_int16 x[], /* I Speech signal */
149  int arch /* I Run-time architecture */
150 );
151 
152 /* Find LPC and LTP coefficients */
154  silk_encoder_state_FIX *psEnc, /* I/O encoder state */
155  silk_encoder_control_FIX *psEncCtrl, /* I/O encoder control */
156  const opus_int16 res_pitch[], /* I Residual from pitch analysis */
157  const opus_int16 x[], /* I Speech signal */
158  opus_int condCoding /* I The type of conditional coding to use */
159 );
160 
161 /* LPC analysis */
162 void silk_find_LPC_FIX(
163  silk_encoder_state *psEncC, /* I/O Encoder state */
164  opus_int16 NLSF_Q15[], /* O NLSFs */
165  const opus_int16 x[], /* I Input signal */
166  const opus_int32 minInvGain_Q30 /* I Inverse of max prediction gain */
167 );
168 
169 /* LTP analysis */
170 void silk_find_LTP_FIX(
171  opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
172  opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
173  opus_int *LTPredCodGain_Q7, /* O LTP coding gain */
174  const opus_int16 r_lpc[], /* I residual signal after LPC signal + state for first 10 ms */
175  const opus_int lag[ MAX_NB_SUBFR ], /* I LTP lags */
176  const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I weights */
177  const opus_int subfr_length, /* I subframe length */
178  const opus_int nb_subfr, /* I number of subframes */
179  const opus_int mem_offset, /* I number of samples in LTP memory */
180  opus_int corr_rshifts[ MAX_NB_SUBFR ], /* O right shifts applied to correlations */
181  int arch /* I Run-time architecture */
182 );
183 
185  opus_int16 *LTP_res, /* O LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length ) */
186  const opus_int16 *x, /* I Pointer to input signal with at least max( pitchL ) preceding samples */
187  const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ],/* I LTP_ORDER LTP coefficients for each MAX_NB_SUBFR subframe */
188  const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lag, one for each subframe */
189  const opus_int32 invGains_Q16[ MAX_NB_SUBFR ], /* I Inverse quantization gains, one for each subframe */
190  const opus_int subfr_length, /* I Length of each subframe */
191  const opus_int nb_subfr, /* I Number of subframes */
192  const opus_int pre_length /* I Length of the preceding samples starting at &x[0] for each subframe */
193 );
194 
195 /* Calculates residual energies of input subframes where all subframes have LPC_order */
196 /* of preceding samples */
198  opus_int32 nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
199  opus_int nrgsQ[ MAX_NB_SUBFR ], /* O Q value per subframe */
200  const opus_int16 x[], /* I Input signal */
201  opus_int16 a_Q12[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
202  const opus_int32 gains[ MAX_NB_SUBFR ], /* I Quantization gains */
203  const opus_int subfr_length, /* I Subframe length */
204  const opus_int nb_subfr, /* I Number of subframes */
205  const opus_int LPC_order, /* I LPC order */
206  int arch /* I Run-time architecture */
207 );
208 
209 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
211  const opus_int16 *c, /* I Prediction vector */
212  const opus_int32 *wXX, /* I Correlation matrix */
213  const opus_int32 *wXx, /* I Correlation vector */
214  opus_int32 wxx, /* I Signal energy */
215  opus_int D, /* I Dimension */
216  opus_int cQ /* I Q value for c vector 0 - 15 */
217 );
218 
219 /* Processing of gains */
221  silk_encoder_state_FIX *psEnc, /* I/O Encoder state */
222  silk_encoder_control_FIX *psEncCtrl, /* I/O Encoder control */
223  opus_int condCoding /* I The type of conditional coding to use */
224 );
225 
226 /******************/
227 /* Linear Algebra */
228 /******************/
229 /* Calculates correlation matrix X'*X */
231  const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
232  const opus_int L, /* I Length of vectors */
233  const opus_int order, /* I Max lag for correlation */
234  const opus_int head_room, /* I Desired headroom */
235  opus_int32 *XX, /* O Pointer to X'*X correlation matrix [ order x order ] */
236  opus_int *rshifts, /* I/O Right shifts of correlations */
237  int arch /* I Run-time architecture */
238 );
239 
240 /* Calculates correlation vector X'*t */
242  const opus_int16 *x, /* I x vector [L + order - 1] used to form data matrix X */
243  const opus_int16 *t, /* I Target vector [L] */
244  const opus_int L, /* I Length of vectors */
245  const opus_int order, /* I Max lag for correlation */
246  opus_int32 *Xt, /* O Pointer to X'*t correlation vector [order] */
247  const opus_int rshifts, /* I Right shifts of correlations */
248  int arch /* I Run-time architecture */
249 );
250 
251 /* Add noise to matrix diagonal */
253  opus_int32 *XX, /* I/O Correlation matrices */
254  opus_int32 *xx, /* I/O Correlation values */
255  opus_int32 noise, /* I Noise to add */
256  opus_int D /* I Dimension of XX */
257 );
258 
259 /* Solves Ax = b, assuming A is symmetric */
260 void silk_solve_LDL_FIX(
261  opus_int32 *A, /* I Pointer to symetric square matrix A */
262  opus_int M, /* I Size of matrix */
263  const opus_int32 *b, /* I Pointer to b vector */
264  opus_int32 *x_Q16 /* O Pointer to x solution vector */
265 );
266 
267 #ifndef FORCE_CPP_BUILD
268 #ifdef __cplusplus
269 }
270 #endif /* __cplusplus */
271 #endif /* FORCE_CPP_BUILD */
272 #endif /* SILK_MAIN_FIX_H */
void silk_warped_autocorrelation_FIX(opus_int32 *corr, opus_int *scale, const opus_int16 *input, const opus_int warping_Q16, const opus_int length, const opus_int order)
Definition: warped_autocorrelation_FIX_mipsr1.h:45
void silk_LTP_analysis_filter_FIX(opus_int16 *LTP_res, const opus_int16 *x, const opus_int16 LTPCoef_Q14[LTP_ORDER *MAX_NB_SUBFR], const opus_int pitchL[MAX_NB_SUBFR], const opus_int32 invGains_Q16[MAX_NB_SUBFR], const opus_int subfr_length, const opus_int nb_subfr, const opus_int pre_length)
Definition: LTP_analysis_filter_FIX.c:34
opus_int silk_encode_frame_FIX(silk_encoder_state_FIX *psEnc, opus_int32 *pnBytesOut, ec_enc *psRangeEnc, opus_int condCoding, opus_int maxBits, opus_int useCBR)
Definition: encode_frame_FIX.c:77
int c
Definition: cpp_unittests.cpp:275
short opus_int16
Definition: opus_types.h:144
Definition: structs_FIX.h:67
#define opus_int
Definition: opus_types.h:151
bool t
Definition: UpdateContents.py:37
void silk_regularize_correlations_FIX(opus_int32 *XX, opus_int32 *xx, opus_int32 noise, opus_int D)
Definition: regularize_correlations_FIX.c:35
opus_int silk_init_encoder(silk_encoder_state_Fxx *psEnc, int arch)
Definition: init_encoder.c:42
void silk_noise_shape_analysis_FIX(silk_encoder_state_FIX *psEnc, silk_encoder_control_FIX *psEncCtrl, const opus_int16 *pitch_res, const opus_int16 *x, int arch)
Definition: noise_shape_analysis_FIX_mipsr1.h:34
void silk_prefilter_FIX(silk_encoder_state_FIX *psEnc, const silk_encoder_control_FIX *psEncCtrl, opus_int32 xw_Q10[], const opus_int16 x[])
Definition: prefilter_FIX.c:100
void silk_HP_variable_cutoff(silk_encoder_state_Fxx state_Fxx[])
Definition: HP_variable_cutoff.c:39
Definition: control.h:46
#define LTP_ORDER
Definition: define.h:141
void silk_find_LPC_FIX(silk_encoder_state *psEncC, opus_int16 NLSF_Q15[], const opus_int16 x[], const opus_int32 minInvGain_Q30)
Definition: find_LPC_FIX.c:37
EGLSurface EGLint x
Definition: eglext.h:950
Definition: gcc-loops.cpp:33
int opus_int32
Definition: opus_types.h:146
void silk_find_LTP_FIX(opus_int16 b_Q14[MAX_NB_SUBFR *LTP_ORDER], opus_int32 WLTP[MAX_NB_SUBFR *LTP_ORDER *LTP_ORDER], opus_int *LTPredCodGain_Q7, const opus_int16 r_lpc[], const opus_int lag[MAX_NB_SUBFR], const opus_int32 Wght_Q15[MAX_NB_SUBFR], const opus_int subfr_length, const opus_int nb_subfr, const opus_int mem_offset, opus_int corr_rshifts[MAX_NB_SUBFR], int arch)
Definition: find_LTP_FIX.c:43
void silk_find_pitch_lags_FIX(silk_encoder_state_FIX *psEnc, silk_encoder_control_FIX *psEncCtrl, opus_int16 res[], const opus_int16 x[], int arch)
Definition: find_pitch_lags_FIX.c:37
Definition: type_traits_unittest.cc:95
void silk_residual_energy_FIX(opus_int32 nrgs[MAX_NB_SUBFR], opus_int nrgsQ[MAX_NB_SUBFR], const opus_int16 x[], opus_int16 a_Q12[2][MAX_LPC_ORDER], const opus_int32 gains[MAX_NB_SUBFR], const opus_int subfr_length, const opus_int nb_subfr, const opus_int LPC_order, int arch)
Definition: residual_energy_FIX.c:37
Definition: entcode.h:62
void silk_solve_LDL_FIX(opus_int32 *A, opus_int M, const opus_int32 *b, opus_int32 *x_Q16)
Definition: solve_LS_FIX.c:76
#define silk_encoder_state_Fxx
Definition: main_FIX.h:46
Definition: structs_FIX.h:80
opus_int32 silk_residual_energy16_covar_FIX(const opus_int16 *c, const opus_int32 *wXX, const opus_int32 *wXx, opus_int32 wxx, opus_int D, opus_int cQ)
Definition: residual_energy16_FIX.c:35
string arch
Definition: runtests.py:65
void silk_process_gains_FIX(silk_encoder_state_FIX *psEnc, silk_encoder_control_FIX *psEncCtrl, opus_int condCoding)
Definition: process_gains_FIX.c:36
void silk_encode_do_VAD_FIX(silk_encoder_state_FIX *psEnc)
Definition: encode_frame_FIX.c:44
M
Definition: parse_delay_file.m:61
Definition: structs.h:132
void silk_warped_LPC_analysis_filter_FIX_c(opus_int32 state[], opus_int32 res_Q2[], const opus_int16 coef_Q13[], const opus_int16 input[], const opus_int16 lambda_Q16, const opus_int length, const opus_int order)
Definition: prefilter_FIX.c:58
void silk_LTP_scale_ctrl_FIX(silk_encoder_state_FIX *psEnc, silk_encoder_control_FIX *psEncCtrl, opus_int condCoding)
Definition: LTP_scale_ctrl_FIX.c:35
#define MAX_LPC_ORDER
Definition: define.h:137
opus_int silk_control_encoder(silk_encoder_state_Fxx *psEnc, silk_EncControlStruct *encControl, const opus_int32 TargetRate_bps, const opus_int allow_bw_switch, const opus_int channelNb, const opus_int force_fs_kHz)
Definition: control_codec.c:65
#define MAX_NB_SUBFR
Definition: define.h:85
GLboolean GLboolean GLboolean b
Definition: gl2ext.h:306
void silk_corrVector_FIX(const opus_int16 *x, const opus_int16 *t, const opus_int L, const opus_int order, opus_int32 *Xt, const opus_int rshifts, int arch)
Definition: corrMatrix_FIX.c:39
void silk_find_pred_coefs_FIX(silk_encoder_state_FIX *psEnc, silk_encoder_control_FIX *psEncCtrl, const opus_int16 res_pitch[], const opus_int16 x[], opus_int condCoding)
Definition: find_pred_coefs_FIX.c:35
string input
Definition: tokenizer_unittest.cc:198
res
Definition: harness.py:111
void silk_corrMatrix_FIX(const opus_int16 *x, const opus_int L, const opus_int order, const opus_int head_room, opus_int32 *XX, opus_int *rshifts, int arch)
Definition: corrMatrix_FIX.c:76
string state
Definition: buildtests.py:34
GLuint GLsizei GLsizei * length
Definition: gl2.h:435