OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 // Minimum and maximum operation functions and their pointers. | 143 // Minimum and maximum operation functions and their pointers. |
144 // Implementation in min_max_operations.c. | 144 // Implementation in min_max_operations.c. |
145 | 145 |
146 // Returns the largest absolute value in a signed 16-bit vector. | 146 // Returns the largest absolute value in a signed 16-bit vector. |
147 // | 147 // |
148 // Input: | 148 // Input: |
149 // - vector : 16-bit input vector. | 149 // - vector : 16-bit input vector. |
150 // - length : Number of samples in vector. | 150 // - length : Number of samples in vector. |
151 // | 151 // |
152 // Return value : Maximum absolute value in vector; | 152 // Return value : Maximum absolute value in vector. |
153 // or -1, if (vector == NULL || length == 0). | |
154 typedef int16_t (*MaxAbsValueW16)(const int16_t* vector, size_t length); | 153 typedef int16_t (*MaxAbsValueW16)(const int16_t* vector, size_t length); |
155 extern MaxAbsValueW16 WebRtcSpl_MaxAbsValueW16; | 154 extern MaxAbsValueW16 WebRtcSpl_MaxAbsValueW16; |
156 int16_t WebRtcSpl_MaxAbsValueW16C(const int16_t* vector, size_t length); | 155 int16_t WebRtcSpl_MaxAbsValueW16C(const int16_t* vector, size_t length); |
157 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) | 156 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) |
158 int16_t WebRtcSpl_MaxAbsValueW16Neon(const int16_t* vector, size_t length); | 157 int16_t WebRtcSpl_MaxAbsValueW16Neon(const int16_t* vector, size_t length); |
159 #endif | 158 #endif |
160 #if defined(MIPS32_LE) | 159 #if defined(MIPS32_LE) |
161 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, size_t length); | 160 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, size_t length); |
162 #endif | 161 #endif |
163 | 162 |
164 // Returns the largest absolute value in a signed 32-bit vector. | 163 // Returns the largest absolute value in a signed 32-bit vector. |
165 // | 164 // |
166 // Input: | 165 // Input: |
167 // - vector : 32-bit input vector. | 166 // - vector : 32-bit input vector. |
168 // - length : Number of samples in vector. | 167 // - length : Number of samples in vector. |
169 // | 168 // |
170 // Return value : Maximum absolute value in vector; | 169 // Return value : Maximum absolute value in vector. |
171 // or -1, if (vector == NULL || length == 0). | |
172 typedef int32_t (*MaxAbsValueW32)(const int32_t* vector, size_t length); | 170 typedef int32_t (*MaxAbsValueW32)(const int32_t* vector, size_t length); |
173 extern MaxAbsValueW32 WebRtcSpl_MaxAbsValueW32; | 171 extern MaxAbsValueW32 WebRtcSpl_MaxAbsValueW32; |
174 int32_t WebRtcSpl_MaxAbsValueW32C(const int32_t* vector, size_t length); | 172 int32_t WebRtcSpl_MaxAbsValueW32C(const int32_t* vector, size_t length); |
175 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) | 173 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) |
176 int32_t WebRtcSpl_MaxAbsValueW32Neon(const int32_t* vector, size_t length); | 174 int32_t WebRtcSpl_MaxAbsValueW32Neon(const int32_t* vector, size_t length); |
177 #endif | 175 #endif |
178 #if defined(MIPS_DSP_R1_LE) | 176 #if defined(MIPS_DSP_R1_LE) |
179 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, size_t length); | 177 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, size_t length); |
180 #endif | 178 #endif |
181 | 179 |
182 // Returns the maximum value of a 16-bit vector. | 180 // Returns the maximum value of a 16-bit vector. |
183 // | 181 // |
184 // Input: | 182 // Input: |
185 // - vector : 16-bit input vector. | 183 // - vector : 16-bit input vector. |
186 // - length : Number of samples in vector. | 184 // - length : Number of samples in vector. |
187 // | 185 // |
188 // Return value : Maximum sample value in |vector|. | 186 // Return value : Maximum sample value in |vector|. |
189 // If (vector == NULL || length == 0) WEBRTC_SPL_WORD16_MIN | |
190 // is returned. Note that WEBRTC_SPL_WORD16_MIN is a feasible | |
191 // value and we can't catch errors purely based on it. | |
192 typedef int16_t (*MaxValueW16)(const int16_t* vector, size_t length); | 187 typedef int16_t (*MaxValueW16)(const int16_t* vector, size_t length); |
193 extern MaxValueW16 WebRtcSpl_MaxValueW16; | 188 extern MaxValueW16 WebRtcSpl_MaxValueW16; |
194 int16_t WebRtcSpl_MaxValueW16C(const int16_t* vector, size_t length); | 189 int16_t WebRtcSpl_MaxValueW16C(const int16_t* vector, size_t length); |
195 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) | 190 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) |
196 int16_t WebRtcSpl_MaxValueW16Neon(const int16_t* vector, size_t length); | 191 int16_t WebRtcSpl_MaxValueW16Neon(const int16_t* vector, size_t length); |
197 #endif | 192 #endif |
198 #if defined(MIPS32_LE) | 193 #if defined(MIPS32_LE) |
199 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, size_t length); | 194 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, size_t length); |
200 #endif | 195 #endif |
201 | 196 |
202 // Returns the maximum value of a 32-bit vector. | 197 // Returns the maximum value of a 32-bit vector. |
203 // | 198 // |
204 // Input: | 199 // Input: |
205 // - vector : 32-bit input vector. | 200 // - vector : 32-bit input vector. |
206 // - length : Number of samples in vector. | 201 // - length : Number of samples in vector. |
207 // | 202 // |
208 // Return value : Maximum sample value in |vector|. | 203 // Return value : Maximum sample value in |vector|. |
209 // If (vector == NULL || length == 0) WEBRTC_SPL_WORD32_MIN | |
210 // is returned. Note that WEBRTC_SPL_WORD32_MIN is a feasible | |
211 // value and we can't catch errors purely based on it. | |
212 typedef int32_t (*MaxValueW32)(const int32_t* vector, size_t length); | 204 typedef int32_t (*MaxValueW32)(const int32_t* vector, size_t length); |
213 extern MaxValueW32 WebRtcSpl_MaxValueW32; | 205 extern MaxValueW32 WebRtcSpl_MaxValueW32; |
214 int32_t WebRtcSpl_MaxValueW32C(const int32_t* vector, size_t length); | 206 int32_t WebRtcSpl_MaxValueW32C(const int32_t* vector, size_t length); |
215 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) | 207 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) |
216 int32_t WebRtcSpl_MaxValueW32Neon(const int32_t* vector, size_t length); | 208 int32_t WebRtcSpl_MaxValueW32Neon(const int32_t* vector, size_t length); |
217 #endif | 209 #endif |
218 #if defined(MIPS32_LE) | 210 #if defined(MIPS32_LE) |
219 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, size_t length); | 211 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, size_t length); |
220 #endif | 212 #endif |
221 | 213 |
222 // Returns the minimum value of a 16-bit vector. | 214 // Returns the minimum value of a 16-bit vector. |
223 // | 215 // |
224 // Input: | 216 // Input: |
225 // - vector : 16-bit input vector. | 217 // - vector : 16-bit input vector. |
226 // - length : Number of samples in vector. | 218 // - length : Number of samples in vector. |
227 // | 219 // |
228 // Return value : Minimum sample value in |vector|. | 220 // Return value : Minimum sample value in |vector|. |
229 // If (vector == NULL || length == 0) WEBRTC_SPL_WORD16_MAX | |
230 // is returned. Note that WEBRTC_SPL_WORD16_MAX is a feasible | |
231 // value and we can't catch errors purely based on it. | |
232 typedef int16_t (*MinValueW16)(const int16_t* vector, size_t length); | 221 typedef int16_t (*MinValueW16)(const int16_t* vector, size_t length); |
233 extern MinValueW16 WebRtcSpl_MinValueW16; | 222 extern MinValueW16 WebRtcSpl_MinValueW16; |
234 int16_t WebRtcSpl_MinValueW16C(const int16_t* vector, size_t length); | 223 int16_t WebRtcSpl_MinValueW16C(const int16_t* vector, size_t length); |
235 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) | 224 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) |
236 int16_t WebRtcSpl_MinValueW16Neon(const int16_t* vector, size_t length); | 225 int16_t WebRtcSpl_MinValueW16Neon(const int16_t* vector, size_t length); |
237 #endif | 226 #endif |
238 #if defined(MIPS32_LE) | 227 #if defined(MIPS32_LE) |
239 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, size_t length); | 228 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, size_t length); |
240 #endif | 229 #endif |
241 | 230 |
242 // Returns the minimum value of a 32-bit vector. | 231 // Returns the minimum value of a 32-bit vector. |
243 // | 232 // |
244 // Input: | 233 // Input: |
245 // - vector : 32-bit input vector. | 234 // - vector : 32-bit input vector. |
246 // - length : Number of samples in vector. | 235 // - length : Number of samples in vector. |
247 // | 236 // |
248 // Return value : Minimum sample value in |vector|. | 237 // Return value : Minimum sample value in |vector|. |
249 // If (vector == NULL || length == 0) WEBRTC_SPL_WORD32_MAX | |
250 // is returned. Note that WEBRTC_SPL_WORD32_MAX is a feasible | |
251 // value and we can't catch errors purely based on it. | |
252 typedef int32_t (*MinValueW32)(const int32_t* vector, size_t length); | 238 typedef int32_t (*MinValueW32)(const int32_t* vector, size_t length); |
253 extern MinValueW32 WebRtcSpl_MinValueW32; | 239 extern MinValueW32 WebRtcSpl_MinValueW32; |
254 int32_t WebRtcSpl_MinValueW32C(const int32_t* vector, size_t length); | 240 int32_t WebRtcSpl_MinValueW32C(const int32_t* vector, size_t length); |
255 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) | 241 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) |
256 int32_t WebRtcSpl_MinValueW32Neon(const int32_t* vector, size_t length); | 242 int32_t WebRtcSpl_MinValueW32Neon(const int32_t* vector, size_t length); |
257 #endif | 243 #endif |
258 #if defined(MIPS32_LE) | 244 #if defined(MIPS32_LE) |
259 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, size_t length); | 245 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, size_t length); |
260 #endif | 246 #endif |
261 | 247 |
262 // Returns the vector index to the largest absolute value of a 16-bit vector. | 248 // Returns the vector index to the largest absolute value of a 16-bit vector. |
263 // | 249 // |
264 // Input: | 250 // Input: |
265 // - vector : 16-bit input vector. | 251 // - vector : 16-bit input vector. |
266 // - length : Number of samples in vector. | 252 // - length : Number of samples in vector. |
267 // | 253 // |
268 // Return value : Index to the maximum absolute value in vector, or -1, | 254 // Return value : Index to the maximum absolute value in vector. |
269 // if (vector == NULL || length == 0). | |
270 // If there are multiple equal maxima, return the index of the | 255 // If there are multiple equal maxima, return the index of the |
271 // first. -32768 will always have precedence over 32767 (despite | 256 // first. -32768 will always have precedence over 32767 (despite |
272 // -32768 presenting an int16 absolute value of 32767); | 257 // -32768 presenting an int16 absolute value of 32767). |
273 int WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, size_t length); | 258 size_t WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, size_t length); |
274 | 259 |
275 // Returns the vector index to the maximum sample value of a 16-bit vector. | 260 // Returns the vector index to the maximum sample value of a 16-bit vector. |
276 // | 261 // |
277 // Input: | 262 // Input: |
278 // - vector : 16-bit input vector. | 263 // - vector : 16-bit input vector. |
279 // - length : Number of samples in vector. | 264 // - length : Number of samples in vector. |
280 // | 265 // |
281 // Return value : Index to the maximum value in vector (if multiple | 266 // Return value : Index to the maximum value in vector (if multiple |
282 // indexes have the maximum, return the first); | 267 // indexes have the maximum, return the first). |
283 // or -1, if (vector == NULL || length == 0). | 268 size_t WebRtcSpl_MaxIndexW16(const int16_t* vector, size_t length); |
284 int WebRtcSpl_MaxIndexW16(const int16_t* vector, size_t length); | |
285 | 269 |
286 // Returns the vector index to the maximum sample value of a 32-bit vector. | 270 // Returns the vector index to the maximum sample value of a 32-bit vector. |
287 // | 271 // |
288 // Input: | 272 // Input: |
289 // - vector : 32-bit input vector. | 273 // - vector : 32-bit input vector. |
290 // - length : Number of samples in vector. | 274 // - length : Number of samples in vector. |
291 // | 275 // |
292 // Return value : Index to the maximum value in vector (if multiple | 276 // Return value : Index to the maximum value in vector (if multiple |
293 // indexes have the maximum, return the first); | 277 // indexes have the maximum, return the first). |
294 // or -1, if (vector == NULL || length == 0). | 278 size_t WebRtcSpl_MaxIndexW32(const int32_t* vector, size_t length); |
295 int WebRtcSpl_MaxIndexW32(const int32_t* vector, size_t length); | |
296 | 279 |
297 // Returns the vector index to the minimum sample value of a 16-bit vector. | 280 // Returns the vector index to the minimum sample value of a 16-bit vector. |
298 // | 281 // |
299 // Input: | 282 // Input: |
300 // - vector : 16-bit input vector. | 283 // - vector : 16-bit input vector. |
301 // - length : Number of samples in vector. | 284 // - length : Number of samples in vector. |
302 // | 285 // |
303 // Return value : Index to the mimimum value in vector (if multiple | 286 // Return value : Index to the mimimum value in vector (if multiple |
304 // indexes have the minimum, return the first); | 287 // indexes have the minimum, return the first). |
305 // or -1, if (vector == NULL || length == 0). | 288 size_t WebRtcSpl_MinIndexW16(const int16_t* vector, size_t length); |
306 int WebRtcSpl_MinIndexW16(const int16_t* vector, size_t length); | |
307 | 289 |
308 // Returns the vector index to the minimum sample value of a 32-bit vector. | 290 // Returns the vector index to the minimum sample value of a 32-bit vector. |
309 // | 291 // |
310 // Input: | 292 // Input: |
311 // - vector : 32-bit input vector. | 293 // - vector : 32-bit input vector. |
312 // - length : Number of samples in vector. | 294 // - length : Number of samples in vector. |
313 // | 295 // |
314 // Return value : Index to the mimimum value in vector (if multiple | 296 // Return value : Index to the mimimum value in vector (if multiple |
315 // indexes have the minimum, return the first); | 297 // indexes have the minimum, return the first). |
316 // or -1, if (vector == NULL || length == 0). | 298 size_t WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length); |
317 int WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length); | |
318 | 299 |
319 // End: Minimum and maximum operations. | 300 // End: Minimum and maximum operations. |
320 | 301 |
321 | 302 |
322 // Vector scaling operations. Implementation in vector_scaling_operations.c. | 303 // Vector scaling operations. Implementation in vector_scaling_operations.c. |
323 // Description at bottom of file. | 304 // Description at bottom of file. |
324 void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector, | 305 void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector, |
325 size_t vector_length, | 306 size_t vector_length, |
326 const int16_t* in_vector, | 307 const int16_t* in_vector, |
327 int16_t right_shifts); | 308 int16_t right_shifts); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // calculated | 417 // calculated |
437 // | 418 // |
438 // Output: | 419 // Output: |
439 // - result : auto-correlation values (values should be seen | 420 // - result : auto-correlation values (values should be seen |
440 // relative to each other since the absolute values | 421 // relative to each other since the absolute values |
441 // might have been down shifted to avoid overflow) | 422 // might have been down shifted to avoid overflow) |
442 // | 423 // |
443 // - scale : The number of left shifts required to obtain the | 424 // - scale : The number of left shifts required to obtain the |
444 // auto-correlation in Q0 | 425 // auto-correlation in Q0 |
445 // | 426 // |
446 // Return value : | 427 // Return value : Number of samples in |result|, i.e. (order+1) |
447 // - -1, if |order| > |in_vector_length|; | 428 size_t WebRtcSpl_AutoCorrelation(const int16_t* in_vector, |
448 // - Number of samples in |result|, i.e. (order+1), otherwise. | 429 size_t in_vector_length, |
449 int WebRtcSpl_AutoCorrelation(const int16_t* in_vector, | 430 size_t order, |
450 size_t in_vector_length, | 431 int32_t* result, |
451 size_t order, | 432 int* scale); |
452 int32_t* result, | |
453 int* scale); | |
454 | 433 |
455 // A 32-bit fix-point implementation of the Levinson-Durbin algorithm that | 434 // A 32-bit fix-point implementation of the Levinson-Durbin algorithm that |
456 // does NOT use the 64 bit class | 435 // does NOT use the 64 bit class |
457 // | 436 // |
458 // Input: | 437 // Input: |
459 // - auto_corr : Vector with autocorrelation values of length >= |order|+1 | 438 // - auto_corr : Vector with autocorrelation values of length >= |order|+1 |
460 // - order : The LPC filter order (support up to order 20) | 439 // - order : The LPC filter order (support up to order 20) |
461 // | 440 // |
462 // Output: | 441 // Output: |
463 // - lpc_coef : lpc_coef[0..order] LPC coefficients in Q12 | 442 // - lpc_coef : lpc_coef[0..order] LPC coefficients in Q12 |
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 // This function multiply a 16-bit word by a 16-bit word, and accumulate this | 1636 // This function multiply a 16-bit word by a 16-bit word, and accumulate this |
1658 // value to a 32-bit integer. | 1637 // value to a 32-bit integer. |
1659 // | 1638 // |
1660 // Input: | 1639 // Input: |
1661 // - a : The value of the first 16-bit word. | 1640 // - a : The value of the first 16-bit word. |
1662 // - b : The value of the second 16-bit word. | 1641 // - b : The value of the second 16-bit word. |
1663 // - c : The value of an 32-bit integer. | 1642 // - c : The value of an 32-bit integer. |
1664 // | 1643 // |
1665 // Return Value: The value of a * b + c. | 1644 // Return Value: The value of a * b + c. |
1666 // | 1645 // |
OLD | NEW |