852bbf96e43487dd0e53a6554e640e2dfc5e8aa1
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / common_audio / signal_processing / include / signal_processing_library.h
1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11
12 /*
13  * This header file includes all of the fix point signal processing library (SPL) function
14  * descriptions and declarations.
15  * For specific function calls, see bottom of file.
16  */
17
18 #ifndef WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_
19 #define WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_
20
21 #include <string.h>
22 #include "webrtc/typedefs.h"
23
24 // Macros specific for the fixed point implementation
25 #define WEBRTC_SPL_WORD16_MAX       32767
26 #define WEBRTC_SPL_WORD16_MIN       -32768
27 #define WEBRTC_SPL_WORD32_MAX       (int32_t)0x7fffffff
28 #define WEBRTC_SPL_WORD32_MIN       (int32_t)0x80000000
29 #define WEBRTC_SPL_MAX_LPC_ORDER    14
30 #define WEBRTC_SPL_MAX_SEED_USED    0x80000000L
31 #define WEBRTC_SPL_MIN(A, B)        (A < B ? A : B)  // Get min value
32 #define WEBRTC_SPL_MAX(A, B)        (A > B ? A : B)  // Get max value
33 // TODO(kma/bjorn): For the next two macros, investigate how to correct the code
34 // for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN.
35 #define WEBRTC_SPL_ABS_W16(a) \
36     (((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a))
37 #define WEBRTC_SPL_ABS_W32(a) \
38     (((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a))
39
40 #ifdef WEBRTC_ARCH_LITTLE_ENDIAN
41 #define WEBRTC_SPL_GET_BYTE(a, nr)  (((int8_t *)a)[nr])
42 #define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \
43     (((int8_t *)d_ptr)[index] = (val))
44 #else
45 #define WEBRTC_SPL_GET_BYTE(a, nr) \
46     ((((int16_t *)a)[nr >> 1]) >> (((nr + 1) & 0x1) * 8) & 0x00ff)
47 #define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \
48     ((int16_t *)d_ptr)[index >> 1] = \
49     ((((int16_t *)d_ptr)[index >> 1]) \
50     & (0x00ff << (8 * ((index) & 0x1)))) | (val << (8 * ((index + 1) & 0x1)))
51 #endif
52
53 #define WEBRTC_SPL_MUL(a, b) \
54     ((int32_t) ((int32_t)(a) * (int32_t)(b)))
55 #define WEBRTC_SPL_UMUL(a, b) \
56     ((uint32_t) ((uint32_t)(a) * (uint32_t)(b)))
57 #define WEBRTC_SPL_UMUL_RSFT16(a, b) \
58     ((uint32_t) ((uint32_t)(a) * (uint32_t)(b)) >> 16)
59 #define WEBRTC_SPL_UMUL_16_16(a, b) \
60     ((uint32_t) (uint16_t)(a) * (uint16_t)(b))
61 #define WEBRTC_SPL_UMUL_16_16_RSFT16(a, b) \
62     (((uint32_t) (uint16_t)(a) * (uint16_t)(b)) >> 16)
63 #define WEBRTC_SPL_UMUL_32_16(a, b) \
64     ((uint32_t) ((uint32_t)(a) * (uint16_t)(b)))
65 #define WEBRTC_SPL_UMUL_32_16_RSFT16(a, b) \
66     ((uint32_t) ((uint32_t)(a) * (uint16_t)(b)) >> 16)
67 #define WEBRTC_SPL_MUL_16_U16(a, b) \
68     ((int32_t)(int16_t)(a) * (uint16_t)(b))
69 #define WEBRTC_SPL_DIV(a, b) \
70     ((int32_t) ((int32_t)(a) / (int32_t)(b)))
71 #define WEBRTC_SPL_UDIV(a, b) \
72     ((uint32_t) ((uint32_t)(a) / (uint32_t)(b)))
73
74 #ifndef WEBRTC_ARCH_ARM_V7
75 // For ARMv7 platforms, these are inline functions in spl_inl_armv7.h
76 #ifndef MIPS32_LE
77 // For MIPS platforms, these are inline functions in spl_inl_mips.h
78 #define WEBRTC_SPL_MUL_16_16(a, b) \
79     ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
80 #define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \
81     (WEBRTC_SPL_MUL_16_16(a, b >> 16) \
82      + ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15))
83 #define WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, b32) \
84     ((int32_t)(WEBRTC_SPL_MUL_16_32_RSFT16(a32a, b32) \
85     + (WEBRTC_SPL_MUL_16_32_RSFT16(a32b, b32) >> 16)))
86 #define WEBRTC_SPL_MUL_32_32_RSFT32BI(a32, b32) \
87     ((int32_t)(WEBRTC_SPL_MUL_16_32_RSFT16(( \
88     (int16_t)(a32 >> 16)), b32) + \
89     (WEBRTC_SPL_MUL_16_32_RSFT16(( \
90     (int16_t)((a32 & 0x0000FFFF) >> 1)), b32) >> 15)))
91 #endif
92 #endif
93
94 #define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \
95     ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 5) \
96     + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10))
97 #define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \
98     ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 2) \
99     + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13))
100 #define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \
101     ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 1) \
102     + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14))
103
104 #define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \
105     (WEBRTC_SPL_MUL_16_16(a, b) >> (c))
106
107 #define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \
108     ((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) \
109                                   (((int32_t)1) << ((c) - 1)))) >> (c))
110 #define WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(a, b) \
111     ((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) (1 << 14))) >> 15)
112
113 // C + the 32 most significant bits of A * B
114 #define WEBRTC_SPL_SCALEDIFF32(A, B, C) \
115     (C + (B >> 16) * A + (((uint32_t)(0x0000FFFF & B) * A) >> 16))
116
117 #define WEBRTC_SPL_ADD_SAT_W32(a, b)    WebRtcSpl_AddSatW32(a, b)
118 #define WEBRTC_SPL_SAT(a, b, c)         (b > a ? a : b < c ? c : b)
119 #define WEBRTC_SPL_MUL_32_16(a, b)      ((a) * (b))
120
121 #define WEBRTC_SPL_SUB_SAT_W32(a, b)    WebRtcSpl_SubSatW32(a, b)
122 #define WEBRTC_SPL_ADD_SAT_W16(a, b)    WebRtcSpl_AddSatW16(a, b)
123 #define WEBRTC_SPL_SUB_SAT_W16(a, b)    WebRtcSpl_SubSatW16(a, b)
124
125 // We cannot do casting here due to signed/unsigned problem
126 #define WEBRTC_SPL_IS_NEG(a)            ((a) & 0x80000000)
127 // Shifting with negative numbers allowed
128 // Positive means left shift
129 #define WEBRTC_SPL_SHIFT_W16(x, c) \
130     (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))
131 #define WEBRTC_SPL_SHIFT_W32(x, c) \
132     (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c))))
133
134 // Shifting with negative numbers not allowed
135 // We cannot do casting here due to signed/unsigned problem
136 #define WEBRTC_SPL_RSHIFT_W16(x, c)     ((x) >> (c))
137 #define WEBRTC_SPL_LSHIFT_W16(x, c)     ((x) << (c))
138 #define WEBRTC_SPL_RSHIFT_W32(x, c)     ((x) >> (c))
139 #define WEBRTC_SPL_LSHIFT_W32(x, c)     ((x) << (c))
140
141 #define WEBRTC_SPL_RSHIFT_U16(x, c)     ((uint16_t)(x) >> (c))
142 #define WEBRTC_SPL_LSHIFT_U16(x, c)     ((uint16_t)(x) << (c))
143 #define WEBRTC_SPL_RSHIFT_U32(x, c)     ((uint32_t)(x) >> (c))
144 #define WEBRTC_SPL_LSHIFT_U32(x, c)     ((uint32_t)(x) << (c))
145
146 #define WEBRTC_SPL_VNEW(t, n)           (t *) malloc (sizeof (t) * (n))
147 #define WEBRTC_SPL_FREE                 free
148
149 #define WEBRTC_SPL_RAND(a) \
150     ((int16_t)(WEBRTC_SPL_MUL_16_16_RSFT((a), 18816, 7) & 0x00007fff))
151
152 #ifdef __cplusplus
153 extern "C" {
154 #endif
155
156 #define WEBRTC_SPL_MEMCPY_W8(v1, v2, length) \
157   memcpy(v1, v2, (length) * sizeof(char))
158 #define WEBRTC_SPL_MEMCPY_W16(v1, v2, length) \
159   memcpy(v1, v2, (length) * sizeof(int16_t))
160
161 #define WEBRTC_SPL_MEMMOVE_W16(v1, v2, length) \
162   memmove(v1, v2, (length) * sizeof(int16_t))
163
164 // inline functions:
165 #include "webrtc/common_audio/signal_processing/include/spl_inl.h"
166
167 // Initialize SPL. Currently it contains only function pointer initialization.
168 // If the underlying platform is known to be ARM-Neon (WEBRTC_ARCH_ARM_NEON
169 // defined), the pointers will be assigned to code optimized for Neon; otherwise
170 // if run-time Neon detection (WEBRTC_DETECT_ARM_NEON) is enabled, the pointers
171 // will be assigned to either Neon code or generic C code; otherwise, generic C
172 // code will be assigned.
173 // Note that this function MUST be called in any application that uses SPL
174 // functions.
175 void WebRtcSpl_Init();
176
177 // Get SPL Version
178 int16_t WebRtcSpl_get_version(char* version, int16_t length_in_bytes);
179
180 int WebRtcSpl_GetScalingSquare(int16_t* in_vector,
181                                int in_vector_length,
182                                int times);
183
184 // Copy and set operations. Implementation in copy_set_operations.c.
185 // Descriptions at bottom of file.
186 void WebRtcSpl_MemSetW16(int16_t* vector,
187                          int16_t set_value,
188                          int vector_length);
189 void WebRtcSpl_MemSetW32(int32_t* vector,
190                          int32_t set_value,
191                          int vector_length);
192 void WebRtcSpl_MemCpyReversedOrder(int16_t* out_vector,
193                                    int16_t* in_vector,
194                                    int vector_length);
195 int16_t WebRtcSpl_CopyFromEndW16(const int16_t* in_vector,
196                                  int16_t in_vector_length,
197                                  int16_t samples,
198                                  int16_t* out_vector);
199 int16_t WebRtcSpl_ZerosArrayW16(int16_t* vector,
200                                 int16_t vector_length);
201 int16_t WebRtcSpl_ZerosArrayW32(int32_t* vector,
202                                 int16_t vector_length);
203 int16_t WebRtcSpl_OnesArrayW16(int16_t* vector,
204                                int16_t vector_length);
205 int16_t WebRtcSpl_OnesArrayW32(int32_t* vector,
206                                int16_t vector_length);
207 // End: Copy and set operations.
208
209
210 // Minimum and maximum operation functions and their pointers.
211 // Implementation in min_max_operations.c.
212
213 // Returns the largest absolute value in a signed 16-bit vector.
214 //
215 // Input:
216 //      - vector : 16-bit input vector.
217 //      - length : Number of samples in vector.
218 //
219 // Return value  : Maximum absolute value in vector;
220 //                 or -1, if (vector == NULL || length <= 0).
221 typedef int16_t (*MaxAbsValueW16)(const int16_t* vector, int length);
222 extern MaxAbsValueW16 WebRtcSpl_MaxAbsValueW16;
223 int16_t WebRtcSpl_MaxAbsValueW16C(const int16_t* vector, int length);
224 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
225 int16_t WebRtcSpl_MaxAbsValueW16Neon(const int16_t* vector, int length);
226 #endif
227 #if defined(MIPS32_LE)
228 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, int length);
229 #endif
230
231 // Returns the largest absolute value in a signed 32-bit vector.
232 //
233 // Input:
234 //      - vector : 32-bit input vector.
235 //      - length : Number of samples in vector.
236 //
237 // Return value  : Maximum absolute value in vector;
238 //                 or -1, if (vector == NULL || length <= 0).
239 typedef int32_t (*MaxAbsValueW32)(const int32_t* vector, int length);
240 extern MaxAbsValueW32 WebRtcSpl_MaxAbsValueW32;
241 int32_t WebRtcSpl_MaxAbsValueW32C(const int32_t* vector, int length);
242 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
243 int32_t WebRtcSpl_MaxAbsValueW32Neon(const int32_t* vector, int length);
244 #endif
245 #if defined(MIPS_DSP_R1_LE)
246 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, int length);
247 #endif
248
249 // Returns the maximum value of a 16-bit vector.
250 //
251 // Input:
252 //      - vector : 16-bit input vector.
253 //      - length : Number of samples in vector.
254 //
255 // Return value  : Maximum sample value in |vector|.
256 //                 If (vector == NULL || length <= 0) WEBRTC_SPL_WORD16_MIN
257 //                 is returned. Note that WEBRTC_SPL_WORD16_MIN is a feasible
258 //                 value and we can't catch errors purely based on it.
259 typedef int16_t (*MaxValueW16)(const int16_t* vector, int length);
260 extern MaxValueW16 WebRtcSpl_MaxValueW16;
261 int16_t WebRtcSpl_MaxValueW16C(const int16_t* vector, int length);
262 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
263 int16_t WebRtcSpl_MaxValueW16Neon(const int16_t* vector, int length);
264 #endif
265 #if defined(MIPS32_LE)
266 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, int length);
267 #endif
268
269 // Returns the maximum value of a 32-bit vector.
270 //
271 // Input:
272 //      - vector : 32-bit input vector.
273 //      - length : Number of samples in vector.
274 //
275 // Return value  : Maximum sample value in |vector|.
276 //                 If (vector == NULL || length <= 0) WEBRTC_SPL_WORD32_MIN
277 //                 is returned. Note that WEBRTC_SPL_WORD32_MIN is a feasible
278 //                 value and we can't catch errors purely based on it.
279 typedef int32_t (*MaxValueW32)(const int32_t* vector, int length);
280 extern MaxValueW32 WebRtcSpl_MaxValueW32;
281 int32_t WebRtcSpl_MaxValueW32C(const int32_t* vector, int length);
282 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
283 int32_t WebRtcSpl_MaxValueW32Neon(const int32_t* vector, int length);
284 #endif
285 #if defined(MIPS32_LE)
286 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, int length);
287 #endif
288
289 // Returns the minimum value of a 16-bit vector.
290 //
291 // Input:
292 //      - vector : 16-bit input vector.
293 //      - length : Number of samples in vector.
294 //
295 // Return value  : Minimum sample value in |vector|.
296 //                 If (vector == NULL || length <= 0) WEBRTC_SPL_WORD16_MAX
297 //                 is returned. Note that WEBRTC_SPL_WORD16_MAX is a feasible
298 //                 value and we can't catch errors purely based on it.
299 typedef int16_t (*MinValueW16)(const int16_t* vector, int length);
300 extern MinValueW16 WebRtcSpl_MinValueW16;
301 int16_t WebRtcSpl_MinValueW16C(const int16_t* vector, int length);
302 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
303 int16_t WebRtcSpl_MinValueW16Neon(const int16_t* vector, int length);
304 #endif
305 #if defined(MIPS32_LE)
306 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, int length);
307 #endif
308
309 // Returns the minimum value of a 32-bit vector.
310 //
311 // Input:
312 //      - vector : 32-bit input vector.
313 //      - length : Number of samples in vector.
314 //
315 // Return value  : Minimum sample value in |vector|.
316 //                 If (vector == NULL || length <= 0) WEBRTC_SPL_WORD32_MAX
317 //                 is returned. Note that WEBRTC_SPL_WORD32_MAX is a feasible
318 //                 value and we can't catch errors purely based on it.
319 typedef int32_t (*MinValueW32)(const int32_t* vector, int length);
320 extern MinValueW32 WebRtcSpl_MinValueW32;
321 int32_t WebRtcSpl_MinValueW32C(const int32_t* vector, int length);
322 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
323 int32_t WebRtcSpl_MinValueW32Neon(const int32_t* vector, int length);
324 #endif
325 #if defined(MIPS32_LE)
326 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, int length);
327 #endif
328
329 // Returns the vector index to the largest absolute value of a 16-bit vector.
330 //
331 // Input:
332 //      - vector : 16-bit input vector.
333 //      - length : Number of samples in vector.
334 //
335 // Return value  : Index to the maximum absolute value in vector, or -1,
336 //                 if (vector == NULL || length <= 0).
337 //                 If there are multiple equal maxima, return the index of the
338 //                 first. -32768 will always have precedence over 32767 (despite
339 //                 -32768 presenting an int16 absolute value of 32767);
340 int WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, int length);
341
342 // Returns the vector index to the maximum sample value of a 16-bit vector.
343 //
344 // Input:
345 //      - vector : 16-bit input vector.
346 //      - length : Number of samples in vector.
347 //
348 // Return value  : Index to the maximum value in vector (if multiple
349 //                 indexes have the maximum, return the first);
350 //                 or -1, if (vector == NULL || length <= 0).
351 int WebRtcSpl_MaxIndexW16(const int16_t* vector, int length);
352
353 // Returns the vector index to the maximum sample value of a 32-bit vector.
354 //
355 // Input:
356 //      - vector : 32-bit input vector.
357 //      - length : Number of samples in vector.
358 //
359 // Return value  : Index to the maximum value in vector (if multiple
360 //                 indexes have the maximum, return the first);
361 //                 or -1, if (vector == NULL || length <= 0).
362 int WebRtcSpl_MaxIndexW32(const int32_t* vector, int length);
363
364 // Returns the vector index to the minimum sample value of a 16-bit vector.
365 //
366 // Input:
367 //      - vector : 16-bit input vector.
368 //      - length : Number of samples in vector.
369 //
370 // Return value  : Index to the mimimum value in vector  (if multiple
371 //                 indexes have the minimum, return the first);
372 //                 or -1, if (vector == NULL || length <= 0).
373 int WebRtcSpl_MinIndexW16(const int16_t* vector, int length);
374
375 // Returns the vector index to the minimum sample value of a 32-bit vector.
376 //
377 // Input:
378 //      - vector : 32-bit input vector.
379 //      - length : Number of samples in vector.
380 //
381 // Return value  : Index to the mimimum value in vector  (if multiple
382 //                 indexes have the minimum, return the first);
383 //                 or -1, if (vector == NULL || length <= 0).
384 int WebRtcSpl_MinIndexW32(const int32_t* vector, int length);
385
386 // End: Minimum and maximum operations.
387
388
389 // Vector scaling operations. Implementation in vector_scaling_operations.c.
390 // Description at bottom of file.
391 void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector,
392                                  int16_t vector_length,
393                                  const int16_t* in_vector,
394                                  int16_t right_shifts);
395 void WebRtcSpl_VectorBitShiftW32(int32_t* out_vector,
396                                  int16_t vector_length,
397                                  const int32_t* in_vector,
398                                  int16_t right_shifts);
399 void WebRtcSpl_VectorBitShiftW32ToW16(int16_t* out_vector,
400                                       int vector_length,
401                                       const int32_t* in_vector,
402                                       int right_shifts);
403 void WebRtcSpl_ScaleVector(const int16_t* in_vector,
404                            int16_t* out_vector,
405                            int16_t gain,
406                            int16_t vector_length,
407                            int16_t right_shifts);
408 void WebRtcSpl_ScaleVectorWithSat(const int16_t* in_vector,
409                                   int16_t* out_vector,
410                                   int16_t gain,
411                                   int16_t vector_length,
412                                   int16_t right_shifts);
413 void WebRtcSpl_ScaleAndAddVectors(const int16_t* in_vector1,
414                                   int16_t gain1, int right_shifts1,
415                                   const int16_t* in_vector2,
416                                   int16_t gain2, int right_shifts2,
417                                   int16_t* out_vector,
418                                   int vector_length);
419
420 // The functions (with related pointer) perform the vector operation:
421 //   out_vector[k] = ((scale1 * in_vector1[k]) + (scale2 * in_vector2[k])
422 //        + round_value) >> right_shifts,
423 //   where  round_value = (1 << right_shifts) >> 1.
424 //
425 // Input:
426 //      - in_vector1       : Input vector 1
427 //      - in_vector1_scale : Gain to be used for vector 1
428 //      - in_vector2       : Input vector 2
429 //      - in_vector2_scale : Gain to be used for vector 2
430 //      - right_shifts     : Number of right bit shifts to be applied
431 //      - length           : Number of elements in the input vectors
432 //
433 // Output:
434 //      - out_vector       : Output vector
435 // Return value            : 0 if OK, -1 if (in_vector1 == NULL
436 //                           || in_vector2 == NULL || out_vector == NULL
437 //                           || length <= 0 || right_shift < 0).
438 typedef int (*ScaleAndAddVectorsWithRound)(const int16_t* in_vector1,
439                                            int16_t in_vector1_scale,
440                                            const int16_t* in_vector2,
441                                            int16_t in_vector2_scale,
442                                            int right_shifts,
443                                            int16_t* out_vector,
444                                            int length);
445 extern ScaleAndAddVectorsWithRound WebRtcSpl_ScaleAndAddVectorsWithRound;
446 int WebRtcSpl_ScaleAndAddVectorsWithRoundC(const int16_t* in_vector1,
447                                            int16_t in_vector1_scale,
448                                            const int16_t* in_vector2,
449                                            int16_t in_vector2_scale,
450                                            int right_shifts,
451                                            int16_t* out_vector,
452                                            int length);
453 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
454 int WebRtcSpl_ScaleAndAddVectorsWithRoundNeon(const int16_t* in_vector1,
455                                               int16_t in_vector1_scale,
456                                               const int16_t* in_vector2,
457                                               int16_t in_vector2_scale,
458                                               int right_shifts,
459                                               int16_t* out_vector,
460                                               int length);
461 #endif
462 #if defined(MIPS_DSP_R1_LE)
463 int WebRtcSpl_ScaleAndAddVectorsWithRound_mips(const int16_t* in_vector1,
464                                                int16_t in_vector1_scale,
465                                                const int16_t* in_vector2,
466                                                int16_t in_vector2_scale,
467                                                int right_shifts,
468                                                int16_t* out_vector,
469                                                int length);
470 #endif
471 // End: Vector scaling operations.
472
473 // iLBC specific functions. Implementations in ilbc_specific_functions.c.
474 // Description at bottom of file.
475 void WebRtcSpl_ReverseOrderMultArrayElements(int16_t* out_vector,
476                                              const int16_t* in_vector,
477                                              const int16_t* window,
478                                              int16_t vector_length,
479                                              int16_t right_shifts);
480 void WebRtcSpl_ElementwiseVectorMult(int16_t* out_vector,
481                                      const int16_t* in_vector,
482                                      const int16_t* window,
483                                      int16_t vector_length,
484                                      int16_t right_shifts);
485 void WebRtcSpl_AddVectorsAndShift(int16_t* out_vector,
486                                   const int16_t* in_vector1,
487                                   const int16_t* in_vector2,
488                                   int16_t vector_length,
489                                   int16_t right_shifts);
490 void WebRtcSpl_AddAffineVectorToVector(int16_t* out_vector,
491                                        int16_t* in_vector,
492                                        int16_t gain,
493                                        int32_t add_constant,
494                                        int16_t right_shifts,
495                                        int vector_length);
496 void WebRtcSpl_AffineTransformVector(int16_t* out_vector,
497                                      int16_t* in_vector,
498                                      int16_t gain,
499                                      int32_t add_constant,
500                                      int16_t right_shifts,
501                                      int vector_length);
502 // End: iLBC specific functions.
503
504 // Signal processing operations.
505
506 // A 32-bit fix-point implementation of auto-correlation computation
507 //
508 // Input:
509 //      - in_vector        : Vector to calculate autocorrelation upon
510 //      - in_vector_length : Length (in samples) of |vector|
511 //      - order            : The order up to which the autocorrelation should be
512 //                           calculated
513 //
514 // Output:
515 //      - result           : auto-correlation values (values should be seen
516 //                           relative to each other since the absolute values
517 //                           might have been down shifted to avoid overflow)
518 //
519 //      - scale            : The number of left shifts required to obtain the
520 //                           auto-correlation in Q0
521 //
522 // Return value            :
523 //      - -1, if |order| > |in_vector_length|;
524 //      - Number of samples in |result|, i.e. (order+1), otherwise.
525 int WebRtcSpl_AutoCorrelation(const int16_t* in_vector,
526                               int in_vector_length,
527                               int order,
528                               int32_t* result,
529                               int* scale);
530
531 // A 32-bit fix-point implementation of the Levinson-Durbin algorithm that
532 // does NOT use the 64 bit class
533 //
534 // Input:
535 //      - auto_corr : Vector with autocorrelation values of length >=
536 //                    |use_order|+1
537 //      - use_order : The LPC filter order (support up to order 20)
538 //
539 // Output:
540 //      - lpc_coef  : lpc_coef[0..use_order] LPC coefficients in Q12
541 //      - refl_coef : refl_coef[0...use_order-1]| Reflection coefficients in
542 //                    Q15
543 //
544 // Return value     : 1 for stable 0 for unstable
545 int16_t WebRtcSpl_LevinsonDurbin(int32_t* auto_corr,
546                                  int16_t* lpc_coef,
547                                  int16_t* refl_coef,
548                                  int16_t order);
549
550 // Converts reflection coefficients |refl_coef| to LPC coefficients |lpc_coef|.
551 // This version is a 16 bit operation.
552 //
553 // NOTE: The 16 bit refl_coef -> lpc_coef conversion might result in a
554 // "slightly unstable" filter (i.e., a pole just outside the unit circle) in
555 // "rare" cases even if the reflection coefficients are stable.
556 //
557 // Input:
558 //      - refl_coef : Reflection coefficients in Q15 that should be converted
559 //                    to LPC coefficients
560 //      - use_order : Number of coefficients in |refl_coef|
561 //
562 // Output:
563 //      - lpc_coef  : LPC coefficients in Q12
564 void WebRtcSpl_ReflCoefToLpc(const int16_t* refl_coef,
565                              int use_order,
566                              int16_t* lpc_coef);
567
568 // Converts LPC coefficients |lpc_coef| to reflection coefficients |refl_coef|.
569 // This version is a 16 bit operation.
570 // The conversion is implemented by the step-down algorithm.
571 //
572 // Input:
573 //      - lpc_coef  : LPC coefficients in Q12, that should be converted to
574 //                    reflection coefficients
575 //      - use_order : Number of coefficients in |lpc_coef|
576 //
577 // Output:
578 //      - refl_coef : Reflection coefficients in Q15.
579 void WebRtcSpl_LpcToReflCoef(int16_t* lpc_coef,
580                              int use_order,
581                              int16_t* refl_coef);
582
583 // Calculates reflection coefficients (16 bit) from auto-correlation values
584 //
585 // Input:
586 //      - auto_corr : Auto-correlation values
587 //      - use_order : Number of coefficients wanted be calculated
588 //
589 // Output:
590 //      - refl_coef : Reflection coefficients in Q15.
591 void WebRtcSpl_AutoCorrToReflCoef(const int32_t* auto_corr,
592                                   int use_order,
593                                   int16_t* refl_coef);
594
595 // The functions (with related pointer) calculate the cross-correlation between
596 // two sequences |seq1| and |seq2|.
597 // |seq1| is fixed and |seq2| slides as the pointer is increased with the
598 // amount |step_seq2|. Note the arguments should obey the relationship:
599 // |dim_seq| - 1 + |step_seq2| * (|dim_cross_correlation| - 1) <
600 //      buffer size of |seq2|
601 //
602 // Input:
603 //      - seq1           : First sequence (fixed throughout the correlation)
604 //      - seq2           : Second sequence (slides |step_vector2| for each
605 //                            new correlation)
606 //      - dim_seq        : Number of samples to use in the cross-correlation
607 //      - dim_cross_correlation : Number of cross-correlations to calculate (the
608 //                            start position for |vector2| is updated for each
609 //                            new one)
610 //      - right_shifts   : Number of right bit shifts to use. This will
611 //                            become the output Q-domain.
612 //      - step_seq2      : How many (positive or negative) steps the
613 //                            |vector2| pointer should be updated for each new
614 //                            cross-correlation value.
615 //
616 // Output:
617 //      - cross_correlation : The cross-correlation in Q(-right_shifts)
618 typedef void (*CrossCorrelation)(int32_t* cross_correlation,
619                                  const int16_t* seq1,
620                                  const int16_t* seq2,
621                                  int16_t dim_seq,
622                                  int16_t dim_cross_correlation,
623                                  int16_t right_shifts,
624                                  int16_t step_seq2);
625 extern CrossCorrelation WebRtcSpl_CrossCorrelation;
626 void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
627                                  const int16_t* seq1,
628                                  const int16_t* seq2,
629                                  int16_t dim_seq,
630                                  int16_t dim_cross_correlation,
631                                  int16_t right_shifts,
632                                  int16_t step_seq2);
633 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
634 void WebRtcSpl_CrossCorrelationNeon(int32_t* cross_correlation,
635                                     const int16_t* seq1,
636                                     const int16_t* seq2,
637                                     int16_t dim_seq,
638                                     int16_t dim_cross_correlation,
639                                     int16_t right_shifts,
640                                     int16_t step_seq2);
641 #endif
642 #if defined(MIPS32_LE)
643 void WebRtcSpl_CrossCorrelation_mips(int32_t* cross_correlation,
644                                      const int16_t* seq1,
645                                      const int16_t* seq2,
646                                      int16_t dim_seq,
647                                      int16_t dim_cross_correlation,
648                                      int16_t right_shifts,
649                                      int16_t step_seq2);
650 #endif
651
652 // Creates (the first half of) a Hanning window. Size must be at least 1 and
653 // at most 512.
654 //
655 // Input:
656 //      - size      : Length of the requested Hanning window (1 to 512)
657 //
658 // Output:
659 //      - window    : Hanning vector in Q14.
660 void WebRtcSpl_GetHanningWindow(int16_t* window, int16_t size);
661
662 // Calculates y[k] = sqrt(1 - x[k]^2) for each element of the input vector
663 // |in_vector|. Input and output values are in Q15.
664 //
665 // Inputs:
666 //      - in_vector     : Values to calculate sqrt(1 - x^2) of
667 //      - vector_length : Length of vector |in_vector|
668 //
669 // Output:
670 //      - out_vector    : Output values in Q15
671 void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t* in_vector,
672                                       int vector_length,
673                                       int16_t* out_vector);
674 // End: Signal processing operations.
675
676 // Randomization functions. Implementations collected in
677 // randomization_functions.c and descriptions at bottom of this file.
678 uint32_t WebRtcSpl_IncreaseSeed(uint32_t* seed);
679 int16_t WebRtcSpl_RandU(uint32_t* seed);
680 int16_t WebRtcSpl_RandN(uint32_t* seed);
681 int16_t WebRtcSpl_RandUArray(int16_t* vector,
682                              int16_t vector_length,
683                              uint32_t* seed);
684 // End: Randomization functions.
685
686 // Math functions
687 int32_t WebRtcSpl_Sqrt(int32_t value);
688 int32_t WebRtcSpl_SqrtFloor(int32_t value);
689
690 // Divisions. Implementations collected in division_operations.c and
691 // descriptions at bottom of this file.
692 uint32_t WebRtcSpl_DivU32U16(uint32_t num, uint16_t den);
693 int32_t WebRtcSpl_DivW32W16(int32_t num, int16_t den);
694 int16_t WebRtcSpl_DivW32W16ResW16(int32_t num, int16_t den);
695 int32_t WebRtcSpl_DivResultInQ31(int32_t num, int32_t den);
696 int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low);
697 // End: Divisions.
698
699 int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor);
700
701 // Calculates the dot product between two (int16_t) vectors.
702 //
703 // Input:
704 //      - vector1       : Vector 1
705 //      - vector2       : Vector 2
706 //      - vector_length : Number of samples used in the dot product
707 //      - scaling       : The number of right bit shifts to apply on each term
708 //                        during calculation to avoid overflow, i.e., the
709 //                        output will be in Q(-|scaling|)
710 //
711 // Return value         : The dot product in Q(-scaling)
712 int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
713                                       const int16_t* vector2,
714                                       int length,
715                                       int scaling);
716
717 // Filter operations.
718 int WebRtcSpl_FilterAR(const int16_t* ar_coef,
719                        int ar_coef_length,
720                        const int16_t* in_vector,
721                        int in_vector_length,
722                        int16_t* filter_state,
723                        int filter_state_length,
724                        int16_t* filter_state_low,
725                        int filter_state_low_length,
726                        int16_t* out_vector,
727                        int16_t* out_vector_low,
728                        int out_vector_low_length);
729
730 void WebRtcSpl_FilterMAFastQ12(int16_t* in_vector,
731                                int16_t* out_vector,
732                                int16_t* ma_coef,
733                                int16_t ma_coef_length,
734                                int16_t vector_length);
735
736 // Performs a AR filtering on a vector in Q12
737 // Input:
738 //      - data_in            : Input samples
739 //      - data_out           : State information in positions
740 //                               data_out[-order] .. data_out[-1]
741 //      - coefficients       : Filter coefficients (in Q12)
742 //      - coefficients_length: Number of coefficients (order+1)
743 //      - data_length        : Number of samples to be filtered
744 // Output:
745 //      - data_out           : Filtered samples
746 void WebRtcSpl_FilterARFastQ12(const int16_t* data_in,
747                                int16_t* data_out,
748                                const int16_t* __restrict coefficients,
749                                int coefficients_length,
750                                int data_length);
751
752 // The functions (with related pointer) perform a MA down sampling filter
753 // on a vector.
754 // Input:
755 //      - data_in            : Input samples (state in positions
756 //                               data_in[-order] .. data_in[-1])
757 //      - data_in_length     : Number of samples in |data_in| to be filtered.
758 //                               This must be at least
759 //                               |delay| + |factor|*(|out_vector_length|-1) + 1)
760 //      - data_out_length    : Number of down sampled samples desired
761 //      - coefficients       : Filter coefficients (in Q12)
762 //      - coefficients_length: Number of coefficients (order+1)
763 //      - factor             : Decimation factor
764 //      - delay              : Delay of filter (compensated for in out_vector)
765 // Output:
766 //      - data_out           : Filtered samples
767 // Return value              : 0 if OK, -1 if |in_vector| is too short
768 typedef int (*DownsampleFast)(const int16_t* data_in,
769                               int data_in_length,
770                               int16_t* data_out,
771                               int data_out_length,
772                               const int16_t* __restrict coefficients,
773                               int coefficients_length,
774                               int factor,
775                               int delay);
776 extern DownsampleFast WebRtcSpl_DownsampleFast;
777 int WebRtcSpl_DownsampleFastC(const int16_t* data_in,
778                               int data_in_length,
779                               int16_t* data_out,
780                               int data_out_length,
781                               const int16_t* __restrict coefficients,
782                               int coefficients_length,
783                               int factor,
784                               int delay);
785 #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
786 int WebRtcSpl_DownsampleFastNeon(const int16_t* data_in,
787                                  int data_in_length,
788                                  int16_t* data_out,
789                                  int data_out_length,
790                                  const int16_t* __restrict coefficients,
791                                  int coefficients_length,
792                                  int factor,
793                                  int delay);
794 #endif
795 #if defined(MIPS32_LE)
796 int WebRtcSpl_DownsampleFast_mips(const int16_t* data_in,
797                                   int data_in_length,
798                                   int16_t* data_out,
799                                   int data_out_length,
800                                   const int16_t* __restrict coefficients,
801                                   int coefficients_length,
802                                   int factor,
803                                   int delay);
804 #endif
805
806 // End: Filter operations.
807
808 // FFT operations
809
810 int WebRtcSpl_ComplexFFT(int16_t vector[], int stages, int mode);
811 int WebRtcSpl_ComplexIFFT(int16_t vector[], int stages, int mode);
812
813 // Treat a 16-bit complex data buffer |complex_data| as an array of 32-bit
814 // values, and swap elements whose indexes are bit-reverses of each other.
815 //
816 // Input:
817 //      - complex_data  : Complex data buffer containing 2^|stages| real
818 //                        elements interleaved with 2^|stages| imaginary
819 //                        elements: [Re Im Re Im Re Im....]
820 //      - stages        : Number of FFT stages. Must be at least 3 and at most
821 //                        10, since the table WebRtcSpl_kSinTable1024[] is 1024
822 //                        elements long.
823 //
824 // Output:
825 //      - complex_data  : The complex data buffer.
826
827 void WebRtcSpl_ComplexBitReverse(int16_t* __restrict complex_data, int stages);
828
829 // End: FFT operations
830
831 /************************************************************
832  *
833  * RESAMPLING FUNCTIONS AND THEIR STRUCTS ARE DEFINED BELOW
834  *
835  ************************************************************/
836
837 /*******************************************************************
838  * resample.c
839  *
840  * Includes the following resampling combinations
841  * 22 kHz -> 16 kHz
842  * 16 kHz -> 22 kHz
843  * 22 kHz ->  8 kHz
844  *  8 kHz -> 22 kHz
845  *
846  ******************************************************************/
847
848 // state structure for 22 -> 16 resampler
849 typedef struct {
850   int32_t S_22_44[8];
851   int32_t S_44_32[8];
852   int32_t S_32_16[8];
853 } WebRtcSpl_State22khzTo16khz;
854
855 void WebRtcSpl_Resample22khzTo16khz(const int16_t* in,
856                                     int16_t* out,
857                                     WebRtcSpl_State22khzTo16khz* state,
858                                     int32_t* tmpmem);
859
860 void WebRtcSpl_ResetResample22khzTo16khz(WebRtcSpl_State22khzTo16khz* state);
861
862 // state structure for 16 -> 22 resampler
863 typedef struct {
864   int32_t S_16_32[8];
865   int32_t S_32_22[8];
866 } WebRtcSpl_State16khzTo22khz;
867
868 void WebRtcSpl_Resample16khzTo22khz(const int16_t* in,
869                                     int16_t* out,
870                                     WebRtcSpl_State16khzTo22khz* state,
871                                     int32_t* tmpmem);
872
873 void WebRtcSpl_ResetResample16khzTo22khz(WebRtcSpl_State16khzTo22khz* state);
874
875 // state structure for 22 -> 8 resampler
876 typedef struct {
877   int32_t S_22_22[16];
878   int32_t S_22_16[8];
879   int32_t S_16_8[8];
880 } WebRtcSpl_State22khzTo8khz;
881
882 void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, int16_t* out,
883                                    WebRtcSpl_State22khzTo8khz* state,
884                                    int32_t* tmpmem);
885
886 void WebRtcSpl_ResetResample22khzTo8khz(WebRtcSpl_State22khzTo8khz* state);
887
888 // state structure for 8 -> 22 resampler
889 typedef struct {
890   int32_t S_8_16[8];
891   int32_t S_16_11[8];
892   int32_t S_11_22[8];
893 } WebRtcSpl_State8khzTo22khz;
894
895 void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, int16_t* out,
896                                    WebRtcSpl_State8khzTo22khz* state,
897                                    int32_t* tmpmem);
898
899 void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state);
900
901 /*******************************************************************
902  * resample_fractional.c
903  * Functions for internal use in the other resample functions
904  *
905  * Includes the following resampling combinations
906  * 48 kHz -> 32 kHz
907  * 32 kHz -> 24 kHz
908  * 44 kHz -> 32 kHz
909  *
910  ******************************************************************/
911
912 void WebRtcSpl_Resample48khzTo32khz(const int32_t* In, int32_t* Out,
913                                     int32_t K);
914
915 void WebRtcSpl_Resample32khzTo24khz(const int32_t* In, int32_t* Out,
916                                     int32_t K);
917
918 void WebRtcSpl_Resample44khzTo32khz(const int32_t* In, int32_t* Out,
919                                     int32_t K);
920
921 /*******************************************************************
922  * resample_48khz.c
923  *
924  * Includes the following resampling combinations
925  * 48 kHz -> 16 kHz
926  * 16 kHz -> 48 kHz
927  * 48 kHz ->  8 kHz
928  *  8 kHz -> 48 kHz
929  *
930  ******************************************************************/
931
932 typedef struct {
933   int32_t S_48_48[16];
934   int32_t S_48_32[8];
935   int32_t S_32_16[8];
936 } WebRtcSpl_State48khzTo16khz;
937
938 void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out,
939                                     WebRtcSpl_State48khzTo16khz* state,
940                                     int32_t* tmpmem);
941
942 void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state);
943
944 typedef struct {
945   int32_t S_16_32[8];
946   int32_t S_32_24[8];
947   int32_t S_24_48[8];
948 } WebRtcSpl_State16khzTo48khz;
949
950 void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out,
951                                     WebRtcSpl_State16khzTo48khz* state,
952                                     int32_t* tmpmem);
953
954 void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state);
955
956 typedef struct {
957   int32_t S_48_24[8];
958   int32_t S_24_24[16];
959   int32_t S_24_16[8];
960   int32_t S_16_8[8];
961 } WebRtcSpl_State48khzTo8khz;
962
963 void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out,
964                                    WebRtcSpl_State48khzTo8khz* state,
965                                    int32_t* tmpmem);
966
967 void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state);
968
969 typedef struct {
970   int32_t S_8_16[8];
971   int32_t S_16_12[8];
972   int32_t S_12_24[8];
973   int32_t S_24_48[8];
974 } WebRtcSpl_State8khzTo48khz;
975
976 void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out,
977                                    WebRtcSpl_State8khzTo48khz* state,
978                                    int32_t* tmpmem);
979
980 void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state);
981
982 /*******************************************************************
983  * resample_by_2.c
984  *
985  * Includes down and up sampling by a factor of two.
986  *
987  ******************************************************************/
988
989 void WebRtcSpl_DownsampleBy2(const int16_t* in, int16_t len,
990                              int16_t* out, int32_t* filtState);
991
992 void WebRtcSpl_UpsampleBy2(const int16_t* in, int16_t len,
993                            int16_t* out, int32_t* filtState);
994
995 /************************************************************
996  * END OF RESAMPLING FUNCTIONS
997  ************************************************************/
998 void WebRtcSpl_AnalysisQMF(const int16_t* in_data,
999                            int in_data_length,
1000                            int16_t* low_band,
1001                            int16_t* high_band,
1002                            int32_t* filter_state1,
1003                            int32_t* filter_state2);
1004 void WebRtcSpl_SynthesisQMF(const int16_t* low_band,
1005                             const int16_t* high_band,
1006                             int band_length,
1007                             int16_t* out_data,
1008                             int32_t* filter_state1,
1009                             int32_t* filter_state2);
1010
1011 #ifdef __cplusplus
1012 }
1013 #endif  // __cplusplus
1014 #endif  // WEBRTC_SPL_SIGNAL_PROCESSING_LIBRARY_H_
1015
1016 //
1017 // WebRtcSpl_AddSatW16(...)
1018 // WebRtcSpl_AddSatW32(...)
1019 //
1020 // Returns the result of a saturated 16-bit, respectively 32-bit, addition of
1021 // the numbers specified by the |var1| and |var2| parameters.
1022 //
1023 // Input:
1024 //      - var1      : Input variable 1
1025 //      - var2      : Input variable 2
1026 //
1027 // Return value     : Added and saturated value
1028 //
1029
1030 //
1031 // WebRtcSpl_SubSatW16(...)
1032 // WebRtcSpl_SubSatW32(...)
1033 //
1034 // Returns the result of a saturated 16-bit, respectively 32-bit, subtraction
1035 // of the numbers specified by the |var1| and |var2| parameters.
1036 //
1037 // Input:
1038 //      - var1      : Input variable 1
1039 //      - var2      : Input variable 2
1040 //
1041 // Returned value   : Subtracted and saturated value
1042 //
1043
1044 //
1045 // WebRtcSpl_GetSizeInBits(...)
1046 //
1047 // Returns the # of bits that are needed at the most to represent the number
1048 // specified by the |value| parameter.
1049 //
1050 // Input:
1051 //      - value     : Input value
1052 //
1053 // Return value     : Number of bits needed to represent |value|
1054 //
1055
1056 //
1057 // WebRtcSpl_NormW32(...)
1058 //
1059 // Norm returns the # of left shifts required to 32-bit normalize the 32-bit
1060 // signed number specified by the |value| parameter.
1061 //
1062 // Input:
1063 //      - value     : Input value
1064 //
1065 // Return value     : Number of bit shifts needed to 32-bit normalize |value|
1066 //
1067
1068 //
1069 // WebRtcSpl_NormW16(...)
1070 //
1071 // Norm returns the # of left shifts required to 16-bit normalize the 16-bit
1072 // signed number specified by the |value| parameter.
1073 //
1074 // Input:
1075 //      - value     : Input value
1076 //
1077 // Return value     : Number of bit shifts needed to 32-bit normalize |value|
1078 //
1079
1080 //
1081 // WebRtcSpl_NormU32(...)
1082 //
1083 // Norm returns the # of left shifts required to 32-bit normalize the unsigned
1084 // 32-bit number specified by the |value| parameter.
1085 //
1086 // Input:
1087 //      - value     : Input value
1088 //
1089 // Return value     : Number of bit shifts needed to 32-bit normalize |value|
1090 //
1091
1092 //
1093 // WebRtcSpl_GetScalingSquare(...)
1094 //
1095 // Returns the # of bits required to scale the samples specified in the
1096 // |in_vector| parameter so that, if the squares of the samples are added the
1097 // # of times specified by the |times| parameter, the 32-bit addition will not
1098 // overflow (result in int32_t).
1099 //
1100 // Input:
1101 //      - in_vector         : Input vector to check scaling on
1102 //      - in_vector_length  : Samples in |in_vector|
1103 //      - times             : Number of additions to be performed
1104 //
1105 // Return value             : Number of right bit shifts needed to avoid
1106 //                            overflow in the addition calculation
1107 //
1108
1109 //
1110 // WebRtcSpl_MemSetW16(...)
1111 //
1112 // Sets all the values in the int16_t vector |vector| of length
1113 // |vector_length| to the specified value |set_value|
1114 //
1115 // Input:
1116 //      - vector        : Pointer to the int16_t vector
1117 //      - set_value     : Value specified
1118 //      - vector_length : Length of vector
1119 //
1120
1121 //
1122 // WebRtcSpl_MemSetW32(...)
1123 //
1124 // Sets all the values in the int32_t vector |vector| of length
1125 // |vector_length| to the specified value |set_value|
1126 //
1127 // Input:
1128 //      - vector        : Pointer to the int16_t vector
1129 //      - set_value     : Value specified
1130 //      - vector_length : Length of vector
1131 //
1132
1133 //
1134 // WebRtcSpl_MemCpyReversedOrder(...)
1135 //
1136 // Copies all the values from the source int16_t vector |in_vector| to a
1137 // destination int16_t vector |out_vector|. It is done in reversed order,
1138 // meaning that the first sample of |in_vector| is copied to the last sample of
1139 // the |out_vector|. The procedure continues until the last sample of
1140 // |in_vector| has been copied to the first sample of |out_vector|. This
1141 // creates a reversed vector. Used in e.g. prediction in iLBC.
1142 //
1143 // Input:
1144 //      - in_vector     : Pointer to the first sample in a int16_t vector
1145 //                        of length |length|
1146 //      - vector_length : Number of elements to copy
1147 //
1148 // Output:
1149 //      - out_vector    : Pointer to the last sample in a int16_t vector
1150 //                        of length |length|
1151 //
1152
1153 //
1154 // WebRtcSpl_CopyFromEndW16(...)
1155 //
1156 // Copies the rightmost |samples| of |in_vector| (of length |in_vector_length|)
1157 // to the vector |out_vector|.
1158 //
1159 // Input:
1160 //      - in_vector         : Input vector
1161 //      - in_vector_length  : Number of samples in |in_vector|
1162 //      - samples           : Number of samples to extract (from right side)
1163 //                            from |in_vector|
1164 //
1165 // Output:
1166 //      - out_vector        : Vector with the requested samples
1167 //
1168 // Return value             : Number of copied samples in |out_vector|
1169 //
1170
1171 //
1172 // WebRtcSpl_ZerosArrayW16(...)
1173 // WebRtcSpl_ZerosArrayW32(...)
1174 //
1175 // Inserts the value "zero" in all positions of a w16 and a w32 vector
1176 // respectively.
1177 //
1178 // Input:
1179 //      - vector_length : Number of samples in vector
1180 //
1181 // Output:
1182 //      - vector        : Vector containing all zeros
1183 //
1184 // Return value         : Number of samples in vector
1185 //
1186
1187 //
1188 // WebRtcSpl_OnesArrayW16(...)
1189 // WebRtcSpl_OnesArrayW32(...)
1190 //
1191 // Inserts the value "one" in all positions of a w16 and a w32 vector
1192 // respectively.
1193 //
1194 // Input:
1195 //      - vector_length : Number of samples in vector
1196 //
1197 // Output:
1198 //      - vector        : Vector containing all ones
1199 //
1200 // Return value         : Number of samples in vector
1201 //
1202
1203 //
1204 // WebRtcSpl_VectorBitShiftW16(...)
1205 // WebRtcSpl_VectorBitShiftW32(...)
1206 //
1207 // Bit shifts all the values in a vector up or downwards. Different calls for
1208 // int16_t and int32_t vectors respectively.
1209 //
1210 // Input:
1211 //      - vector_length : Length of vector
1212 //      - in_vector     : Pointer to the vector that should be bit shifted
1213 //      - right_shifts  : Number of right bit shifts (negative value gives left
1214 //                        shifts)
1215 //
1216 // Output:
1217 //      - out_vector    : Pointer to the result vector (can be the same as
1218 //                        |in_vector|)
1219 //
1220
1221 //
1222 // WebRtcSpl_VectorBitShiftW32ToW16(...)
1223 //
1224 // Bit shifts all the values in a int32_t vector up or downwards and
1225 // stores the result as an int16_t vector. The function will saturate the
1226 // signal if needed, before storing in the output vector.
1227 //
1228 // Input:
1229 //      - vector_length : Length of vector
1230 //      - in_vector     : Pointer to the vector that should be bit shifted
1231 //      - right_shifts  : Number of right bit shifts (negative value gives left
1232 //                        shifts)
1233 //
1234 // Output:
1235 //      - out_vector    : Pointer to the result vector (can be the same as
1236 //                        |in_vector|)
1237 //
1238
1239 //
1240 // WebRtcSpl_ScaleVector(...)
1241 //
1242 // Performs the vector operation:
1243 //  out_vector[k] = (gain*in_vector[k])>>right_shifts
1244 //
1245 // Input:
1246 //      - in_vector     : Input vector
1247 //      - gain          : Scaling gain
1248 //      - vector_length : Elements in the |in_vector|
1249 //      - right_shifts  : Number of right bit shifts applied
1250 //
1251 // Output:
1252 //      - out_vector    : Output vector (can be the same as |in_vector|)
1253 //
1254
1255 //
1256 // WebRtcSpl_ScaleVectorWithSat(...)
1257 //
1258 // Performs the vector operation:
1259 //  out_vector[k] = SATURATE( (gain*in_vector[k])>>right_shifts )
1260 //
1261 // Input:
1262 //      - in_vector     : Input vector
1263 //      - gain          : Scaling gain
1264 //      - vector_length : Elements in the |in_vector|
1265 //      - right_shifts  : Number of right bit shifts applied
1266 //
1267 // Output:
1268 //      - out_vector    : Output vector (can be the same as |in_vector|)
1269 //
1270
1271 //
1272 // WebRtcSpl_ScaleAndAddVectors(...)
1273 //
1274 // Performs the vector operation:
1275 //  out_vector[k] = (gain1*in_vector1[k])>>right_shifts1
1276 //                  + (gain2*in_vector2[k])>>right_shifts2
1277 //
1278 // Input:
1279 //      - in_vector1    : Input vector 1
1280 //      - gain1         : Gain to be used for vector 1
1281 //      - right_shifts1 : Right bit shift to be used for vector 1
1282 //      - in_vector2    : Input vector 2
1283 //      - gain2         : Gain to be used for vector 2
1284 //      - right_shifts2 : Right bit shift to be used for vector 2
1285 //      - vector_length : Elements in the input vectors
1286 //
1287 // Output:
1288 //      - out_vector    : Output vector
1289 //
1290
1291 //
1292 // WebRtcSpl_ReverseOrderMultArrayElements(...)
1293 //
1294 // Performs the vector operation:
1295 //  out_vector[n] = (in_vector[n]*window[-n])>>right_shifts
1296 //
1297 // Input:
1298 //      - in_vector     : Input vector
1299 //      - window        : Window vector (should be reversed). The pointer
1300 //                        should be set to the last value in the vector
1301 //      - right_shifts  : Number of right bit shift to be applied after the
1302 //                        multiplication
1303 //      - vector_length : Number of elements in |in_vector|
1304 //
1305 // Output:
1306 //      - out_vector    : Output vector (can be same as |in_vector|)
1307 //
1308
1309 //
1310 // WebRtcSpl_ElementwiseVectorMult(...)
1311 //
1312 // Performs the vector operation:
1313 //  out_vector[n] = (in_vector[n]*window[n])>>right_shifts
1314 //
1315 // Input:
1316 //      - in_vector     : Input vector
1317 //      - window        : Window vector.
1318 //      - right_shifts  : Number of right bit shift to be applied after the
1319 //                        multiplication
1320 //      - vector_length : Number of elements in |in_vector|
1321 //
1322 // Output:
1323 //      - out_vector    : Output vector (can be same as |in_vector|)
1324 //
1325
1326 //
1327 // WebRtcSpl_AddVectorsAndShift(...)
1328 //
1329 // Performs the vector operation:
1330 //  out_vector[k] = (in_vector1[k] + in_vector2[k])>>right_shifts
1331 //
1332 // Input:
1333 //      - in_vector1    : Input vector 1
1334 //      - in_vector2    : Input vector 2
1335 //      - right_shifts  : Number of right bit shift to be applied after the
1336 //                        multiplication
1337 //      - vector_length : Number of elements in |in_vector1| and |in_vector2|
1338 //
1339 // Output:
1340 //      - out_vector    : Output vector (can be same as |in_vector1|)
1341 //
1342
1343 //
1344 // WebRtcSpl_AddAffineVectorToVector(...)
1345 //
1346 // Adds an affine transformed vector to another vector |out_vector|, i.e,
1347 // performs
1348 //  out_vector[k] += (in_vector[k]*gain+add_constant)>>right_shifts
1349 //
1350 // Input:
1351 //      - in_vector     : Input vector
1352 //      - gain          : Gain value, used to multiply the in vector with
1353 //      - add_constant  : Constant value to add (usually 1<<(right_shifts-1),
1354 //                        but others can be used as well
1355 //      - right_shifts  : Number of right bit shifts (0-16)
1356 //      - vector_length : Number of samples in |in_vector| and |out_vector|
1357 //
1358 // Output:
1359 //      - out_vector    : Vector with the output
1360 //
1361
1362 //
1363 // WebRtcSpl_AffineTransformVector(...)
1364 //
1365 // Affine transforms a vector, i.e, performs
1366 //  out_vector[k] = (in_vector[k]*gain+add_constant)>>right_shifts
1367 //
1368 // Input:
1369 //      - in_vector     : Input vector
1370 //      - gain          : Gain value, used to multiply the in vector with
1371 //      - add_constant  : Constant value to add (usually 1<<(right_shifts-1),
1372 //                        but others can be used as well
1373 //      - right_shifts  : Number of right bit shifts (0-16)
1374 //      - vector_length : Number of samples in |in_vector| and |out_vector|
1375 //
1376 // Output:
1377 //      - out_vector    : Vector with the output
1378 //
1379
1380 //
1381 // WebRtcSpl_IncreaseSeed(...)
1382 //
1383 // Increases the seed (and returns the new value)
1384 //
1385 // Input:
1386 //      - seed      : Seed for random calculation
1387 //
1388 // Output:
1389 //      - seed      : Updated seed value
1390 //
1391 // Return value     : The new seed value
1392 //
1393
1394 //
1395 // WebRtcSpl_RandU(...)
1396 //
1397 // Produces a uniformly distributed value in the int16_t range
1398 //
1399 // Input:
1400 //      - seed      : Seed for random calculation
1401 //
1402 // Output:
1403 //      - seed      : Updated seed value
1404 //
1405 // Return value     : Uniformly distributed value in the range
1406 //                    [Word16_MIN...Word16_MAX]
1407 //
1408
1409 //
1410 // WebRtcSpl_RandN(...)
1411 //
1412 // Produces a normal distributed value in the int16_t range
1413 //
1414 // Input:
1415 //      - seed      : Seed for random calculation
1416 //
1417 // Output:
1418 //      - seed      : Updated seed value
1419 //
1420 // Return value     : N(0,1) value in the Q13 domain
1421 //
1422
1423 //
1424 // WebRtcSpl_RandUArray(...)
1425 //
1426 // Produces a uniformly distributed vector with elements in the int16_t
1427 // range
1428 //
1429 // Input:
1430 //      - vector_length : Samples wanted in the vector
1431 //      - seed          : Seed for random calculation
1432 //
1433 // Output:
1434 //      - vector        : Vector with the uniform values
1435 //      - seed          : Updated seed value
1436 //
1437 // Return value         : Number of samples in vector, i.e., |vector_length|
1438 //
1439
1440 //
1441 // WebRtcSpl_Sqrt(...)
1442 //
1443 // Returns the square root of the input value |value|. The precision of this
1444 // function is integer precision, i.e., sqrt(8) gives 2 as answer.
1445 // If |value| is a negative number then 0 is returned.
1446 //
1447 // Algorithm:
1448 //
1449 // A sixth order Taylor Series expansion is used here to compute the square
1450 // root of a number y^0.5 = (1+x)^0.5
1451 // where
1452 // x = y-1
1453 //   = 1+(x/2)-0.5*((x/2)^2+0.5*((x/2)^3-0.625*((x/2)^4+0.875*((x/2)^5)
1454 // 0.5 <= x < 1
1455 //
1456 // Input:
1457 //      - value     : Value to calculate sqrt of
1458 //
1459 // Return value     : Result of the sqrt calculation
1460 //
1461
1462 //
1463 // WebRtcSpl_SqrtFloor(...)
1464 //
1465 // Returns the square root of the input value |value|. The precision of this
1466 // function is rounding down integer precision, i.e., sqrt(8) gives 2 as answer.
1467 // If |value| is a negative number then 0 is returned.
1468 //
1469 // Algorithm:
1470 //
1471 // An iterative 4 cylce/bit routine
1472 //
1473 // Input:
1474 //      - value     : Value to calculate sqrt of
1475 //
1476 // Return value     : Result of the sqrt calculation
1477 //
1478
1479 //
1480 // WebRtcSpl_DivU32U16(...)
1481 //
1482 // Divides a uint32_t |num| by a uint16_t |den|.
1483 //
1484 // If |den|==0, (uint32_t)0xFFFFFFFF is returned.
1485 //
1486 // Input:
1487 //      - num       : Numerator
1488 //      - den       : Denominator
1489 //
1490 // Return value     : Result of the division (as a uint32_t), i.e., the
1491 //                    integer part of num/den.
1492 //
1493
1494 //
1495 // WebRtcSpl_DivW32W16(...)
1496 //
1497 // Divides a int32_t |num| by a int16_t |den|.
1498 //
1499 // If |den|==0, (int32_t)0x7FFFFFFF is returned.
1500 //
1501 // Input:
1502 //      - num       : Numerator
1503 //      - den       : Denominator
1504 //
1505 // Return value     : Result of the division (as a int32_t), i.e., the
1506 //                    integer part of num/den.
1507 //
1508
1509 //
1510 // WebRtcSpl_DivW32W16ResW16(...)
1511 //
1512 // Divides a int32_t |num| by a int16_t |den|, assuming that the
1513 // result is less than 32768, otherwise an unpredictable result will occur.
1514 //
1515 // If |den|==0, (int16_t)0x7FFF is returned.
1516 //
1517 // Input:
1518 //      - num       : Numerator
1519 //      - den       : Denominator
1520 //
1521 // Return value     : Result of the division (as a int16_t), i.e., the
1522 //                    integer part of num/den.
1523 //
1524
1525 //
1526 // WebRtcSpl_DivResultInQ31(...)
1527 //
1528 // Divides a int32_t |num| by a int16_t |den|, assuming that the
1529 // absolute value of the denominator is larger than the numerator, otherwise
1530 // an unpredictable result will occur.
1531 //
1532 // Input:
1533 //      - num       : Numerator
1534 //      - den       : Denominator
1535 //
1536 // Return value     : Result of the division in Q31.
1537 //
1538
1539 //
1540 // WebRtcSpl_DivW32HiLow(...)
1541 //
1542 // Divides a int32_t |num| by a denominator in hi, low format. The
1543 // absolute value of the denominator has to be larger (or equal to) the
1544 // numerator.
1545 //
1546 // Input:
1547 //      - num       : Numerator
1548 //      - den_hi    : High part of denominator
1549 //      - den_low   : Low part of denominator
1550 //
1551 // Return value     : Divided value in Q31
1552 //
1553
1554 //
1555 // WebRtcSpl_Energy(...)
1556 //
1557 // Calculates the energy of a vector
1558 //
1559 // Input:
1560 //      - vector        : Vector which the energy should be calculated on
1561 //      - vector_length : Number of samples in vector
1562 //
1563 // Output:
1564 //      - scale_factor  : Number of left bit shifts needed to get the physical
1565 //                        energy value, i.e, to get the Q0 value
1566 //
1567 // Return value         : Energy value in Q(-|scale_factor|)
1568 //
1569
1570 //
1571 // WebRtcSpl_FilterAR(...)
1572 //
1573 // Performs a 32-bit AR filtering on a vector in Q12
1574 //
1575 // Input:
1576 //  - ar_coef                   : AR-coefficient vector (values in Q12),
1577 //                                ar_coef[0] must be 4096.
1578 //  - ar_coef_length            : Number of coefficients in |ar_coef|.
1579 //  - in_vector                 : Vector to be filtered.
1580 //  - in_vector_length          : Number of samples in |in_vector|.
1581 //  - filter_state              : Current state (higher part) of the filter.
1582 //  - filter_state_length       : Length (in samples) of |filter_state|.
1583 //  - filter_state_low          : Current state (lower part) of the filter.
1584 //  - filter_state_low_length   : Length (in samples) of |filter_state_low|.
1585 //  - out_vector_low_length     : Maximum length (in samples) of
1586 //                                |out_vector_low|.
1587 //
1588 // Output:
1589 //  - filter_state              : Updated state (upper part) vector.
1590 //  - filter_state_low          : Updated state (lower part) vector.
1591 //  - out_vector                : Vector containing the upper part of the
1592 //                                filtered values.
1593 //  - out_vector_low            : Vector containing the lower part of the
1594 //                                filtered values.
1595 //
1596 // Return value                 : Number of samples in the |out_vector|.
1597 //
1598
1599 //
1600 // WebRtcSpl_FilterMAFastQ12(...)
1601 //
1602 // Performs a MA filtering on a vector in Q12
1603 //
1604 // Input:
1605 //      - in_vector         : Input samples (state in positions
1606 //                            in_vector[-order] .. in_vector[-1])
1607 //      - ma_coef           : Filter coefficients (in Q12)
1608 //      - ma_coef_length    : Number of B coefficients (order+1)
1609 //      - vector_length     : Number of samples to be filtered
1610 //
1611 // Output:
1612 //      - out_vector        : Filtered samples
1613 //
1614
1615 //
1616 // WebRtcSpl_ComplexIFFT(...)
1617 //
1618 // Complex Inverse FFT
1619 //
1620 // Computes an inverse complex 2^|stages|-point FFT on the input vector, which
1621 // is in bit-reversed order. The original content of the vector is destroyed in
1622 // the process, since the input is overwritten by the output, normal-ordered,
1623 // FFT vector. With X as the input complex vector, y as the output complex
1624 // vector and with M = 2^|stages|, the following is computed:
1625 //
1626 //        M-1
1627 // y(k) = sum[X(i)*[cos(2*pi*i*k/M) + j*sin(2*pi*i*k/M)]]
1628 //        i=0
1629 //
1630 // The implementations are optimized for speed, not for code size. It uses the
1631 // decimation-in-time algorithm with radix-2 butterfly technique.
1632 //
1633 // Input:
1634 //      - vector    : In pointer to complex vector containing 2^|stages|
1635 //                    real elements interleaved with 2^|stages| imaginary
1636 //                    elements.
1637 //                    [ReImReImReIm....]
1638 //                    The elements are in Q(-scale) domain, see more on Return
1639 //                    Value below.
1640 //
1641 //      - stages    : Number of FFT stages. Must be at least 3 and at most 10,
1642 //                    since the table WebRtcSpl_kSinTable1024[] is 1024
1643 //                    elements long.
1644 //
1645 //      - mode      : This parameter gives the user to choose how the FFT
1646 //                    should work.
1647 //                    mode==0: Low-complexity and Low-accuracy mode
1648 //                    mode==1: High-complexity and High-accuracy mode
1649 //
1650 // Output:
1651 //      - vector    : Out pointer to the FFT vector (the same as input).
1652 //
1653 // Return Value     : The scale value that tells the number of left bit shifts
1654 //                    that the elements in the |vector| should be shifted with
1655 //                    in order to get Q0 values, i.e. the physically correct
1656 //                    values. The scale parameter is always 0 or positive,
1657 //                    except if N>1024 (|stages|>10), which returns a scale
1658 //                    value of -1, indicating error.
1659 //
1660
1661 //
1662 // WebRtcSpl_ComplexFFT(...)
1663 //
1664 // Complex FFT
1665 //
1666 // Computes a complex 2^|stages|-point FFT on the input vector, which is in
1667 // bit-reversed order. The original content of the vector is destroyed in
1668 // the process, since the input is overwritten by the output, normal-ordered,
1669 // FFT vector. With x as the input complex vector, Y as the output complex
1670 // vector and with M = 2^|stages|, the following is computed:
1671 //
1672 //              M-1
1673 // Y(k) = 1/M * sum[x(i)*[cos(2*pi*i*k/M) + j*sin(2*pi*i*k/M)]]
1674 //              i=0
1675 //
1676 // The implementations are optimized for speed, not for code size. It uses the
1677 // decimation-in-time algorithm with radix-2 butterfly technique.
1678 //
1679 // This routine prevents overflow by scaling by 2 before each FFT stage. This is
1680 // a fixed scaling, for proper normalization - there will be log2(n) passes, so
1681 // this results in an overall factor of 1/n, distributed to maximize arithmetic
1682 // accuracy.
1683 //
1684 // Input:
1685 //      - vector    : In pointer to complex vector containing 2^|stages| real
1686 //                    elements interleaved with 2^|stages| imaginary elements.
1687 //                    [ReImReImReIm....]
1688 //                    The output is in the Q0 domain.
1689 //
1690 //      - stages    : Number of FFT stages. Must be at least 3 and at most 10,
1691 //                    since the table WebRtcSpl_kSinTable1024[] is 1024
1692 //                    elements long.
1693 //
1694 //      - mode      : This parameter gives the user to choose how the FFT
1695 //                    should work.
1696 //                    mode==0: Low-complexity and Low-accuracy mode
1697 //                    mode==1: High-complexity and High-accuracy mode
1698 //
1699 // Output:
1700 //      - vector    : The output FFT vector is in the Q0 domain.
1701 //
1702 // Return value     : The scale parameter is always 0, except if N>1024,
1703 //                    which returns a scale value of -1, indicating error.
1704 //
1705
1706 //
1707 // WebRtcSpl_AnalysisQMF(...)
1708 //
1709 // Splits a 0-2*F Hz signal into two sub bands: 0-F Hz and F-2*F Hz. The
1710 // current version has F = 8000, therefore, a super-wideband audio signal is
1711 // split to lower-band 0-8 kHz and upper-band 8-16 kHz.
1712 //
1713 // Input:
1714 //      - in_data       : Wide band speech signal, 320 samples (10 ms)
1715 //
1716 // Input & Output:
1717 //      - filter_state1 : Filter state for first All-pass filter
1718 //      - filter_state2 : Filter state for second All-pass filter
1719 //
1720 // Output:
1721 //      - low_band      : Lower-band signal 0-8 kHz band, 160 samples (10 ms)
1722 //      - high_band     : Upper-band signal 8-16 kHz band (flipped in frequency
1723 //                        domain), 160 samples (10 ms)
1724 //
1725
1726 //
1727 // WebRtcSpl_SynthesisQMF(...)
1728 //
1729 // Combines the two sub bands (0-F and F-2*F Hz) into a signal of 0-2*F
1730 // Hz, (current version has F = 8000 Hz). So the filter combines lower-band
1731 // (0-8 kHz) and upper-band (8-16 kHz) channels to obtain super-wideband 0-16
1732 // kHz audio.
1733 //
1734 // Input:
1735 //      - low_band      : The signal with the 0-8 kHz band, 160 samples (10 ms)
1736 //      - high_band     : The signal with the 8-16 kHz band, 160 samples (10 ms)
1737 //
1738 // Input & Output:
1739 //      - filter_state1 : Filter state for first All-pass filter
1740 //      - filter_state2 : Filter state for second All-pass filter
1741 //
1742 // Output:
1743 //      - out_data      : Super-wideband speech signal, 0-16 kHz
1744 //
1745
1746 // int16_t WebRtcSpl_SatW32ToW16(...)
1747 //
1748 // This function saturates a 32-bit word into a 16-bit word.
1749 //
1750 // Input:
1751 //      - value32   : The value of a 32-bit word.
1752 //
1753 // Output:
1754 //      - out16     : the saturated 16-bit word.
1755 //
1756
1757 // int32_t WebRtc_MulAccumW16(...)
1758 //
1759 // This function multiply a 16-bit word by a 16-bit word, and accumulate this
1760 // value to a 32-bit integer.
1761 //
1762 // Input:
1763 //      - a    : The value of the first 16-bit word.
1764 //      - b    : The value of the second 16-bit word.
1765 //      - c    : The value of an 32-bit integer.
1766 //
1767 // Return Value: The value of a * b + c.
1768 //
1769
1770 // int16_t WebRtcSpl_get_version(...)
1771 //
1772 // This function gives the version string of the Signal Processing Library.
1773 //
1774 // Input:
1775 //      - length_in_bytes : The size of Allocated space (in Bytes) where
1776 //                          the version number is written to (in string format).
1777 //
1778 // Output:
1779 //      - version         : Pointer to a buffer where the version number is
1780 //                          written to.
1781 //