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