webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
main_FLP.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_FLP_H
29 #define SILK_MAIN_FLP_H
30 
31 #include "SigProc_FLP.h"
32 #include "SigProc_FIX.h"
33 #include "structs_FLP.h"
34 #include "main.h"
35 #include "define.h"
36 #include "debug.h"
37 #include "entenc.h"
38 
39 #ifdef __cplusplus
40 extern "C"
41 {
42 #endif
43 
44 #define silk_encoder_state_Fxx silk_encoder_state_FLP
45 #define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FLP
46 #define silk_encode_frame_Fxx silk_encode_frame_FLP
47 
48 /*********************/
49 /* Encoder Functions */
50 /*********************/
51 
52 /* High-pass filter with cutoff frequency adaptation based on pitch lag statistics */
54  silk_encoder_state_Fxx state_Fxx[] /* I/O Encoder states */
55 );
56 
57 /* Encoder main function */
59  silk_encoder_state_FLP *psEnc /* I/O Encoder state FLP */
60 );
61 
62 /* Encoder main function */
64  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
65  opus_int32 *pnBytesOut, /* O Number of payload bytes; */
66  ec_enc *psRangeEnc, /* I/O compressor data structure */
67  opus_int condCoding, /* I The type of conditional coding to use */
68  opus_int maxBits, /* I If > 0: maximum number of output bits */
69  opus_int useCBR /* I Flag to force constant-bitrate operation */
70 );
71 
72 /* Initializes the Silk encoder state */
74  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
75  int arch /* I Run-tim architecture */
76 );
77 
78 /* Control the Silk encoder */
80  silk_encoder_state_FLP *psEnc, /* I/O Pointer to Silk encoder state FLP */
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 */
84  const opus_int channelNb, /* I Channel number */
85  const opus_int force_fs_kHz
86 );
87 
88 /****************/
89 /* Prefiltering */
90 /****************/
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 /**************************/
99 /* Noise shaping analysis */
100 /**************************/
101 /* Compute noise shaping coefficients and initial gain values */
103  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
104  silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
105  const silk_float *pitch_res, /* I LPC residual from pitch analysis */
106  const silk_float *x /* I Input signal [frame_length + la_shape] */
107 );
108 
109 /* Autocorrelations for a warped frequency axis */
111  silk_float *corr, /* O Result [order + 1] */
112  const silk_float *input, /* I Input data to correlate */
113  const silk_float warping, /* I Warping coefficient */
114  const opus_int length, /* I Length of input */
115  const opus_int order /* I Correlation order (even) */
116 );
117 
118 /* Calculation of LTP state scaling */
120  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
121  silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
122  opus_int condCoding /* I The type of conditional coding to use */
123 );
124 
125 /**********************************************/
126 /* Prediction Analysis */
127 /**********************************************/
128 /* Find pitch lags */
130  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
131  silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
132  silk_float res[], /* O Residual */
133  const silk_float x[], /* I Speech signal */
134  int arch /* I Run-time architecture */
135 );
136 
137 /* Find LPC and LTP coefficients */
139  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
140  silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
141  const silk_float res_pitch[], /* I Residual from pitch analysis */
142  const silk_float x[], /* I Speech signal */
143  opus_int condCoding /* I The type of conditional coding to use */
144 );
145 
146 /* LPC analysis */
147 void silk_find_LPC_FLP(
148  silk_encoder_state *psEncC, /* I/O Encoder state */
149  opus_int16 NLSF_Q15[], /* O NLSFs */
150  const silk_float x[], /* I Input signal */
151  const silk_float minInvGain /* I Prediction gain from LTP (dB) */
152 );
153 
154 /* LTP analysis */
155 void silk_find_LTP_FLP(
156  silk_float b[ MAX_NB_SUBFR * LTP_ORDER ], /* O LTP coefs */
157  silk_float WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ], /* O Weight for LTP quantization */
158  silk_float *LTPredCodGain, /* O LTP coding gain */
159  const silk_float r_lpc[], /* I LPC residual */
160  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 */
163  const opus_int nb_subfr, /* I number of subframes */
164  const opus_int mem_offset /* I Number of samples in LTP memory */
165 );
166 
168  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 */
170  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 */
172  const silk_float invGains[ MAX_NB_SUBFR ], /* I Inverse quantization gains */
173  const opus_int subfr_length, /* I Length of each subframe */
174  const opus_int nb_subfr, /* I number of subframes */
175  const opus_int pre_length /* I Preceding samples for each subframe */
176 );
177 
178 /* Calculates residual energies of input subframes where all subframes have LPC_order */
179 /* of preceding samples */
181  silk_float nrgs[ MAX_NB_SUBFR ], /* O Residual energy per subframe */
182  const silk_float x[], /* I Input signal */
183  silk_float a[ 2 ][ MAX_LPC_ORDER ], /* I AR coefs for each frame half */
184  const silk_float gains[], /* I Quantization gains */
185  const opus_int subfr_length, /* I Subframe length */
186  const opus_int nb_subfr, /* I number of subframes */
187  const opus_int LPC_order /* I LPC order */
188 );
189 
190 /* 16th order LPC analysis filter */
192  silk_float r_LPC[], /* O LPC residual signal */
193  const silk_float PredCoef[], /* I LPC coefficients */
194  const silk_float s[], /* I Input signal */
195  const opus_int length, /* I Length of input signal */
196  const opus_int Order /* I LPC order */
197 );
198 
199 /* LTP tap quantizer */
201  silk_float B[ MAX_NB_SUBFR * LTP_ORDER ], /* I/O (Un-)quantized LTP gains */
202  opus_int8 cbk_index[ MAX_NB_SUBFR ], /* O Codebook index */
203  opus_int8 *periodicity_index, /* O Periodicity index */
204  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 */
206  const opus_int mu_Q10, /* I Mu value (R/D tradeoff) */
207  const opus_int lowComplexity, /* I Flag for low complexity */
208  const opus_int nb_subfr, /* I number of subframes */
209  int arch /* I Run-time architecture */
210 );
211 
212 /* Residual energy: nrg = wxx - 2 * wXx * c + c' * wXX * c */
213 silk_float silk_residual_energy_covar_FLP( /* O Weighted residual energy */
214  const silk_float *c, /* I Filter coefficients */
215  silk_float *wXX, /* I/O Weighted correlation matrix, reg. out */
216  const silk_float *wXx, /* I Weighted correlation vector */
217  const silk_float wxx, /* I Weighted correlation value */
218  const opus_int D /* I Dimension */
219 );
220 
221 /* Processing of gains */
223  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
224  silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
225  opus_int condCoding /* I The type of conditional coding to use */
226 );
227 
228 /******************/
229 /* Linear Algebra */
230 /******************/
231 /* Calculates correlation matrix X'*X */
233  const silk_float *x, /* I x vector [ L+order-1 ] used to create X */
234  const opus_int L, /* I Length of vectors */
235  const opus_int Order, /* I Max lag for correlation */
236  silk_float *XX /* O X'*X correlation matrix [order x order] */
237 );
238 
239 /* Calculates correlation vector X'*t */
241  const silk_float *x, /* I x vector [L+order-1] used to create X */
242  const silk_float *t, /* I Target vector [L] */
243  const opus_int L, /* I Length of vecors */
244  const opus_int Order, /* I Max lag for correlation */
245  silk_float *Xt /* O X'*t correlation vector [order] */
246 );
247 
248 /* Add noise to matrix diagonal */
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. */
265 /* Window types: */
266 /* 1 -> sine window from 0 to pi/2 */
267 /* 2 -> sine window from pi/2 to pi */
269  silk_float px_win[], /* O Pointer to windowed signal */
270  const silk_float px[], /* I Pointer to input signal */
271  const opus_int win_type, /* I Selects a window type */
272  const opus_int length /* I Window length, multiple of 4 */
273 );
274 
275 /* Wrapper functions. Call flp / fix code */
276 
277 /* Convert AR filter coefficients to NLSF parameters */
278 void silk_A2NLSF_FLP(
279  opus_int16 *NLSF_Q15, /* O NLSF vector [ LPC_order ] */
280  const silk_float *pAR, /* I LPC coefficients [ LPC_order ] */
281  const opus_int LPC_order /* I LPC order */
282 );
283 
284 /* Convert NLSF parameters to AR prediction filter coefficients */
285 void silk_NLSF2A_FLP(
286  silk_float *pAR, /* O LPC coefficients [ LPC_order ] */
287  const opus_int16 *NLSF_Q15, /* I NLSF vector [ LPC_order ] */
288  const opus_int LPC_order /* I LPC order */
289 );
290 
291 /* Limit, stabilize, and quantize NLSFs */
293  silk_encoder_state *psEncC, /* I/O Encoder state */
294  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)) */
296  const opus_int16 prev_NLSF_Q15[ MAX_LPC_ORDER ] /* I Previous Normalized LSFs (0 - (2^15-1)) */
297 );
298 
299 /* Floating-point Silk NSQ wrapper */
301  silk_encoder_state_FLP *psEnc, /* I/O Encoder state FLP */
302  silk_encoder_control_FLP *psEncCtrl, /* I/O Encoder control FLP */
303  SideInfoIndices *psIndices, /* I/O Quantization indices */
304  silk_nsq_state *psNSQ, /* I/O Noise Shaping Quantzation state */
305  opus_int8 pulses[], /* O Quantized pulse signal */
306  const silk_float x[] /* I Prefiltered input signal */
307 );
308 
309 #ifdef __cplusplus
310 }
311 #endif
312 
313 #endif
opus_int silk_encode_frame_FLP(silk_encoder_state_FLP *psEnc, opus_int32 *pnBytesOut, ec_enc *psRangeEnc, opus_int condCoding, opus_int maxBits, opus_int useCBR)
Definition: encode_frame_FLP.c:76
void silk_quant_LTP_gains_FLP(silk_float B[MAX_NB_SUBFR *LTP_ORDER], opus_int8 cbk_index[MAX_NB_SUBFR], opus_int8 *periodicity_index, opus_int32 *sum_log_gain_Q7, const silk_float W[MAX_NB_SUBFR *LTP_ORDER *LTP_ORDER], const opus_int mu_Q10, const opus_int lowComplexity, const opus_int nb_subfr, int arch)
Definition: wrappers_FLP.c:174
#define silk_encoder_state_Fxx
Definition: main_FLP.h:44
int c
Definition: cpp_unittests.cpp:275
short opus_int16
Definition: opus_types.h:144
void silk_warped_autocorrelation_FLP(silk_float *corr, const silk_float *input, const silk_float warping, const opus_int length, const opus_int order)
Definition: warped_autocorrelation_FLP.c:35
opus_int silk_control_encoder(silk_encoder_state_FLP *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)
#define opus_int
Definition: opus_types.h:151
#define B(x, j)
Definition: sha512.c:425
#define opus_int8
Definition: opus_types.h:153
void silk_noise_shape_analysis_FLP(silk_encoder_state_FLP *psEnc, silk_encoder_control_FLP *psEncCtrl, const silk_float *pitch_res, const silk_float *x)
Definition: noise_shape_analysis_FLP.c:128
bool t
Definition: UpdateContents.py:37
void silk_residual_energy_FLP(silk_float nrgs[MAX_NB_SUBFR], const silk_float x[], silk_float a[2][MAX_LPC_ORDER], const silk_float gains[], const opus_int subfr_length, const opus_int nb_subfr, const opus_int LPC_order)
Definition: residual_energy_FLP.c:91
void silk_NLSF2A_FLP(silk_float *pAR, const opus_int16 *NLSF_Q15, const opus_int LPC_order)
Definition: wrappers_FLP.c:54
void silk_solve_LDL_FLP(silk_float *A, const opus_int M, const silk_float *b, silk_float *x)
Definition: solve_LS_FLP.c:73
void silk_find_LTP_FLP(silk_float b[MAX_NB_SUBFR *LTP_ORDER], silk_float WLTP[MAX_NB_SUBFR *LTP_ORDER *LTP_ORDER], silk_float *LTPredCodGain, const silk_float r_lpc[], const opus_int lag[MAX_NB_SUBFR], const silk_float Wght[MAX_NB_SUBFR], const opus_int subfr_length, const opus_int nb_subfr, const opus_int mem_offset)
Definition: find_LTP_FLP.c:35
Definition: structs_FLP.h:80
opus_int silk_init_encoder(silk_encoder_state_FLP *psEnc, int arch)
#define silk_float
Definition: typedef.h:36
Definition: control.h:46
#define LTP_ORDER
Definition: define.h:141
void silk_A2NLSF_FLP(opus_int16 *NLSF_Q15, const silk_float *pAR, const opus_int LPC_order)
Definition: wrappers_FLP.c:37
void silk_encode_do_VAD_FLP(silk_encoder_state_FLP *psEnc)
Definition: encode_frame_FLP.c:43
void silk_HP_variable_cutoff(silk_encoder_state_Fxx state_Fxx[])
Definition: HP_variable_cutoff.c:39
void silk_process_gains_FLP(silk_encoder_state_FLP *psEnc, silk_encoder_control_FLP *psEncCtrl, opus_int condCoding)
Definition: process_gains_FLP.c:36
Definition: structs_FLP.h:67
EGLSurface EGLint x
Definition: eglext.h:950
Definition: gcc-loops.cpp:33
int opus_int32
Definition: opus_types.h:146
void silk_LTP_analysis_filter_FLP(silk_float *LTP_res, const silk_float *x, const silk_float B[LTP_ORDER *MAX_NB_SUBFR], const opus_int pitchL[MAX_NB_SUBFR], const silk_float invGains[MAX_NB_SUBFR], const opus_int subfr_length, const opus_int nb_subfr, const opus_int pre_length)
Definition: LTP_analysis_filter_FLP.c:34
void silk_find_pitch_lags_FLP(silk_encoder_state_FLP *psEnc, silk_encoder_control_FLP *psEncCtrl, silk_float res[], const silk_float x[], int arch)
Definition: find_pitch_lags_FLP.c:36
Definition: structs.h:115
silk_float silk_residual_energy_covar_FLP(const silk_float *c, silk_float *wXX, const silk_float *wXx, const silk_float wxx, const opus_int D)
Definition: residual_energy_FLP.c:38
Definition: type_traits_unittest.cc:95
void silk_find_pred_coefs_FLP(silk_encoder_state_FLP *psEnc, silk_encoder_control_FLP *psEncCtrl, const silk_float res_pitch[], const silk_float x[], opus_int condCoding)
Definition: find_pred_coefs_FLP.c:35
void silk_regularize_correlations_FLP(silk_float *XX, silk_float *xx, const silk_float noise, const opus_int D)
Definition: regularize_correlations_FLP.c:35
Definition: entcode.h:62
void silk_LPC_analysis_filter_FLP(silk_float r_LPC[], const silk_float PredCoef[], const silk_float s[], const opus_int length, const opus_int Order)
Definition: LPC_analysis_filter_FLP.c:210
Definition: structs.h:45
void silk_corrMatrix_FLP(const silk_float *x, const opus_int L, const opus_int Order, silk_float *XX)
Definition: corrMatrix_FLP.c:59
GLboolean GLboolean GLboolean GLboolean a
Definition: gl2ext.h:306
void silk_prefilter_FLP(silk_encoder_state_FLP *psEnc, const silk_encoder_control_FLP *psEncCtrl, silk_float xw[], const silk_float x[])
Definition: prefilter_FLP.c:94
string arch
Definition: runtests.py:65
void silk_find_LPC_FLP(silk_encoder_state *psEncC, opus_int16 NLSF_Q15[], const silk_float x[], const silk_float minInvGain)
Definition: find_LPC_FLP.c:37
M
Definition: parse_delay_file.m:61
struct A s
Definition: structs.h:132
void silk_LTP_scale_ctrl_FLP(silk_encoder_state_FLP *psEnc, silk_encoder_control_FLP *psEncCtrl, opus_int condCoding)
Definition: LTP_scale_ctrl_FLP.c:34
void silk_apply_sine_window_FLP(silk_float px_win[], const silk_float px[], const opus_int win_type, const opus_int length)
Definition: apply_sine_window_FLP.c:38
#define MAX_LPC_ORDER
Definition: define.h:137
#define MAX_NB_SUBFR
Definition: define.h:85
void silk_process_NLSFs_FLP(silk_encoder_state *psEncC, silk_float PredCoef[2][MAX_LPC_ORDER], opus_int16 NLSF_Q15[MAX_LPC_ORDER], const opus_int16 prev_NLSF_Q15[MAX_LPC_ORDER])
Definition: wrappers_FLP.c:73
void silk_corrVector_FLP(const silk_float *x, const silk_float *t, const opus_int L, const opus_int Order, silk_float *Xt)
Definition: corrMatrix_FLP.c:39
GLboolean GLboolean GLboolean b
Definition: gl2ext.h:306
string input
Definition: tokenizer_unittest.cc:198
res
Definition: harness.py:111
Order
Definition: RenderStyleConstants.h:619
void silk_NSQ_wrapper_FLP(silk_encoder_state_FLP *psEnc, silk_encoder_control_FLP *psEncCtrl, SideInfoIndices *psIndices, silk_nsq_state *psNSQ, opus_int8 pulses[], const silk_float x[])
Definition: wrappers_FLP.c:95
GLuint GLsizei GLsizei * length
Definition: gl2.h:435