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