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