OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
5 are met: | 5 are met: |
6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
(...skipping 18 matching lines...) Expand all Loading... |
29 #define SILK_MAIN_FIX_H | 29 #define SILK_MAIN_FIX_H |
30 | 30 |
31 #include "SigProc_FIX.h" | 31 #include "SigProc_FIX.h" |
32 #include "structs_FIX.h" | 32 #include "structs_FIX.h" |
33 #include "control.h" | 33 #include "control.h" |
34 #include "main.h" | 34 #include "main.h" |
35 #include "PLC.h" | 35 #include "PLC.h" |
36 #include "debug.h" | 36 #include "debug.h" |
37 #include "entenc.h" | 37 #include "entenc.h" |
38 | 38 |
| 39 #if ((defined(OPUS_ARM_ASM) && defined(FIXED_POINT)) \ |
| 40 || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) |
| 41 #include "fixed/arm/warped_autocorrelation_FIX_arm.h" |
| 42 #endif |
| 43 |
39 #ifndef FORCE_CPP_BUILD | 44 #ifndef FORCE_CPP_BUILD |
40 #ifdef __cplusplus | 45 #ifdef __cplusplus |
41 extern "C" | 46 extern "C" |
42 { | 47 { |
43 #endif | 48 #endif |
44 #endif | 49 #endif |
45 | 50 |
46 #define silk_encoder_state_Fxx silk_encoder_state_FIX | 51 #define silk_encoder_state_Fxx silk_encoder_state_FIX |
47 #define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FIX | 52 #define silk_encode_do_VAD_Fxx silk_encode_do_VAD_FIX |
48 #define silk_encode_frame_Fxx silk_encode_frame_FIX | 53 #define silk_encode_frame_Fxx silk_encode_frame_FIX |
49 | 54 |
| 55 #define QC 10 |
| 56 #define QS 13 |
| 57 |
50 /*********************/ | 58 /*********************/ |
51 /* Encoder Functions */ | 59 /* Encoder Functions */ |
52 /*********************/ | 60 /*********************/ |
53 | 61 |
54 /* High-pass filter with cutoff frequency adaptation based on pitch lag statisti
cs */ | 62 /* High-pass filter with cutoff frequency adaptation based on pitch lag statisti
cs */ |
55 void silk_HP_variable_cutoff( | 63 void silk_HP_variable_cutoff( |
56 silk_encoder_state_Fxx state_Fxx[] /* I
/O Encoder states
*/ | 64 silk_encoder_state_Fxx state_Fxx[] /* I
/O Encoder states
*/ |
57 ); | 65 ); |
58 | 66 |
59 /* Encoder main function */ | 67 /* Encoder main function */ |
(...skipping 14 matching lines...) Expand all Loading... |
74 /* Initializes the Silk encoder state */ | 82 /* Initializes the Silk encoder state */ |
75 opus_int silk_init_encoder( | 83 opus_int silk_init_encoder( |
76 silk_encoder_state_Fxx *psEnc, /* I
/O Pointer to Silk FIX encoder state
*/ | 84 silk_encoder_state_Fxx *psEnc, /* I
/O Pointer to Silk FIX encoder state
*/ |
77 int arch /* I
Run-time architecture
*/ | 85 int arch /* I
Run-time architecture
*/ |
78 ); | 86 ); |
79 | 87 |
80 /* Control the Silk encoder */ | 88 /* Control the Silk encoder */ |
81 opus_int silk_control_encoder( | 89 opus_int silk_control_encoder( |
82 silk_encoder_state_Fxx *psEnc, /* I
/O Pointer to Silk encoder state
*/ | 90 silk_encoder_state_Fxx *psEnc, /* I
/O Pointer to Silk encoder state
*/ |
83 silk_EncControlStruct *encControl, /* I
Control structure
*/ | 91 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
*/ | 92 const opus_int allow_bw_switch, /* I
Flag to allow switching audio bandwidth
*/ |
86 const opus_int channelNb, /* I
Channel number
*/ | 93 const opus_int channelNb, /* I
Channel number
*/ |
87 const opus_int force_fs_kHz | 94 const opus_int force_fs_kHz |
88 ); | 95 ); |
89 | 96 |
90 /****************/ | |
91 /* Prefiltering */ | |
92 /****************/ | |
93 void silk_prefilter_FIX( | |
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 | |
100 void silk_warped_LPC_analysis_filter_FIX_c( | |
101 opus_int32 state[], /* I/O State [order
+ 1] */ | |
102 opus_int32 res_Q2[], /* O Residual sig
nal [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 fact
or */ | |
106 const opus_int length, /* I Length of in
put signal */ | |
107 const opus_int order /* I Filter order
(even) */ | |
108 ); | |
109 | |
110 | |
111 /**************************/ | 97 /**************************/ |
112 /* Noise shaping analysis */ | 98 /* Noise shaping analysis */ |
113 /**************************/ | 99 /**************************/ |
114 /* Compute noise shaping coefficients and initial gain values */ | 100 /* Compute noise shaping coefficients and initial gain values */ |
115 void silk_noise_shape_analysis_FIX( | 101 void silk_noise_shape_analysis_FIX( |
116 silk_encoder_state_FIX *psEnc, /* I
/O Encoder state FIX
*/ | 102 silk_encoder_state_FIX *psEnc, /* I
/O Encoder state FIX
*/ |
117 silk_encoder_control_FIX *psEncCtrl, /* I
/O Encoder control FIX
*/ | 103 silk_encoder_control_FIX *psEncCtrl, /* I
/O Encoder control FIX
*/ |
118 const opus_int16 *pitch_res, /* I
LPC residual from pitch analysis
*/ | 104 const opus_int16 *pitch_res, /* I
LPC residual from pitch analysis
*/ |
119 const opus_int16 *x, /* I
Input signal [ frame_length + la_shape ]
*/ | 105 const opus_int16 *x, /* I
Input signal [ frame_length + la_shape ]
*/ |
120 int arch /* I
Run-time architecture
*/ | 106 int arch /* I
Run-time architecture
*/ |
121 ); | 107 ); |
122 | 108 |
123 /* Autocorrelations for a warped frequency axis */ | 109 /* Autocorrelations for a warped frequency axis */ |
124 void silk_warped_autocorrelation_FIX( | 110 void silk_warped_autocorrelation_FIX_c( |
125 opus_int32 *corr, /* O
Result [order + 1]
*/ | 111 opus_int32 *corr, /* O
Result [order + 1]
*/ |
126 opus_int *scale, /* O
Scaling of the correlation vector
*/ | 112 opus_int *scale, /* O
Scaling of the correlation vector
*/ |
127 const opus_int16 *input, /* I
Input data to correlate
*/ | 113 const opus_int16 *input, /* I
Input data to correlate
*/ |
128 const opus_int warping_Q16, /* I
Warping coefficient
*/ | 114 const opus_int warping_Q16, /* I
Warping coefficient
*/ |
129 const opus_int length, /* I
Length of input
*/ | 115 const opus_int length, /* I
Length of input
*/ |
130 const opus_int order /* I
Correlation order (even)
*/ | 116 const opus_int order /* I
Correlation order (even)
*/ |
131 ); | 117 ); |
132 | 118 |
| 119 #if !defined(OVERRIDE_silk_warped_autocorrelation_FIX) |
| 120 #define silk_warped_autocorrelation_FIX(corr, scale, input, warping_Q16, length,
order, arch) \ |
| 121 ((void)(arch), silk_warped_autocorrelation_FIX_c(corr, scale, input, war
ping_Q16, length, order)) |
| 122 #endif |
| 123 |
133 /* Calculation of LTP state scaling */ | 124 /* Calculation of LTP state scaling */ |
134 void silk_LTP_scale_ctrl_FIX( | 125 void silk_LTP_scale_ctrl_FIX( |
135 silk_encoder_state_FIX *psEnc, /* I
/O encoder state
*/ | 126 silk_encoder_state_FIX *psEnc, /* I
/O encoder state
*/ |
136 silk_encoder_control_FIX *psEncCtrl, /* I
/O encoder control
*/ | 127 silk_encoder_control_FIX *psEncCtrl, /* I
/O encoder control
*/ |
137 opus_int condCoding /* I
The type of conditional coding to use
*/ | 128 opus_int condCoding /* I
The type of conditional coding to use
*/ |
138 ); | 129 ); |
139 | 130 |
140 /**********************************************/ | 131 /**********************************************/ |
141 /* Prediction Analysis */ | 132 /* Prediction Analysis */ |
142 /**********************************************/ | 133 /**********************************************/ |
(...skipping 18 matching lines...) Expand all Loading... |
161 /* LPC analysis */ | 152 /* LPC analysis */ |
162 void silk_find_LPC_FIX( | 153 void silk_find_LPC_FIX( |
163 silk_encoder_state *psEncC, /* I
/O Encoder state
*/ | 154 silk_encoder_state *psEncC, /* I
/O Encoder state
*/ |
164 opus_int16 NLSF_Q15[], /* O
NLSFs
*/ | 155 opus_int16 NLSF_Q15[], /* O
NLSFs
*/ |
165 const opus_int16 x[], /* I
Input signal
*/ | 156 const opus_int16 x[], /* I
Input signal
*/ |
166 const opus_int32 minInvGain_Q30 /* I
Inverse of max prediction gain
*/ | 157 const opus_int32 minInvGain_Q30 /* I
Inverse of max prediction gain
*/ |
167 ); | 158 ); |
168 | 159 |
169 /* LTP analysis */ | 160 /* LTP analysis */ |
170 void silk_find_LTP_FIX( | 161 void silk_find_LTP_FIX( |
171 opus_int16 b_Q14[ MAX_NB_SUBFR * LTP_ORDER ], /* O
LTP coefs
*/ | 162 opus_int32 XXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_OR
DER ], /* O Correlation matrix
*/ |
172 opus_int32 WLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ]
, /* O Weight for LTP quantization
*/ | 163 opus_int32 xXLTP_Q17[ MAX_NB_SUBFR * LTP_ORDER ], /* O
Correlation vector
*/ |
173 opus_int *LTPredCodGain_Q7, /* O
LTP coding gain
*/ | 164 const opus_int16 r_lpc[], /* I
Residual signal after LPC
*/ |
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
*/ | 165 const opus_int lag[ MAX_NB_SUBFR ], /* I
LTP lags
*/ |
176 const opus_int32 Wght_Q15[ MAX_NB_SUBFR ], /* I
weights
*/ | 166 const opus_int subfr_length, /* I
Subframe length
*/ |
177 const opus_int subfr_length, /* I
subframe length
*/ | 167 const opus_int nb_subfr, /* I
Number of subframes
*/ |
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
*/ | 168 int arch /* I
Run-time architecture
*/ |
182 ); | 169 ); |
183 | 170 |
184 void silk_LTP_analysis_filter_FIX( | 171 void silk_LTP_analysis_filter_FIX( |
185 opus_int16 *LTP_res, /* O
LTP residual signal of length MAX_NB_SUBFR * ( pre_length + subfr_length )
*/ | 172 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
*/ | 173 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
*/ | 174 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
*/ | 175 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
*/ | 176 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
*/ | 177 const opus_int subfr_length, /* I
Length of each subframe
*/ |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 ); | 211 ); |
225 | 212 |
226 /******************/ | 213 /******************/ |
227 /* Linear Algebra */ | 214 /* Linear Algebra */ |
228 /******************/ | 215 /******************/ |
229 /* Calculates correlation matrix X'*X */ | 216 /* Calculates correlation matrix X'*X */ |
230 void silk_corrMatrix_FIX( | 217 void silk_corrMatrix_FIX( |
231 const opus_int16 *x, /* I
x vector [L + order - 1] used to form data matrix X
*/ | 218 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
*/ | 219 const opus_int L, /* I
Length of vectors
*/ |
233 const opus_int order, /* I
Max lag for correlation
*/ | 220 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 ]
*/ | 221 opus_int32 *XX, /* O
Pointer to X'*X correlation matrix [ order x order ]
*/ |
236 opus_int *rshifts, /* I
/O Right shifts of correlations
*/ | 222 opus_int32 *nrg, /* O
Energy of x vector
*/ |
| 223 opus_int *rshifts, /* O
Right shifts of correlations
*/ |
237 int arch /* I
Run-time architecture
*/ | 224 int arch /* I
Run-time architecture
*/ |
238 ); | 225 ); |
239 | 226 |
240 /* Calculates correlation vector X'*t */ | 227 /* Calculates correlation vector X'*t */ |
241 void silk_corrVector_FIX( | 228 void silk_corrVector_FIX( |
242 const opus_int16 *x, /* I
x vector [L + order - 1] used to form data matrix X
*/ | 229 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]
*/ | 230 const opus_int16 *t, /* I
Target vector [L]
*/ |
244 const opus_int L, /* I
Length of vectors
*/ | 231 const opus_int L, /* I
Length of vectors
*/ |
245 const opus_int order, /* I
Max lag for correlation
*/ | 232 const opus_int order, /* I
Max lag for correlation
*/ |
246 opus_int32 *Xt, /* O
Pointer to X'*t correlation vector [order]
*/ | 233 opus_int32 *Xt, /* O
Pointer to X'*t correlation vector [order]
*/ |
247 const opus_int rshifts, /* I
Right shifts of correlations
*/ | 234 const opus_int rshifts, /* I
Right shifts of correlations
*/ |
248 int arch /* I
Run-time architecture
*/ | 235 int arch /* I
Run-time architecture
*/ |
249 ); | 236 ); |
250 | 237 |
251 /* Add noise to matrix diagonal */ | |
252 void silk_regularize_correlations_FIX( | |
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 | 238 #ifndef FORCE_CPP_BUILD |
268 #ifdef __cplusplus | 239 #ifdef __cplusplus |
269 } | 240 } |
270 #endif /* __cplusplus */ | 241 #endif /* __cplusplus */ |
271 #endif /* FORCE_CPP_BUILD */ | 242 #endif /* FORCE_CPP_BUILD */ |
272 #endif /* SILK_MAIN_FIX_H */ | 243 #endif /* SILK_MAIN_FIX_H */ |
OLD | NEW |