diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..e348552bd9bfe410b9684a5a834dba5a58f28c3d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,92 @@
+# GNU Makefile
+
+# Paths
+SRC_ENC = lib_enc lib_com basic_op basic_math lib_debug
+SRC_DEC = lib_dec lib_com basic_op basic_math lib_debug
+BUILD = build
+
+SRC_DIRS = $(sort -u $(SRC_ENC) $(SRC_DEC))
+
+# Name of CLI binaries
+CLI_ENC = EVS_cod
+CLI_DEC = EVS_dec
+
+# Default tool settings
+CC = gcc
+RM = rm -f
+
+ifndef VERBOSE
+QUIET_CC = @echo ' ' Compiling $<;
+QUIET_LINK= @echo ' ' Linking $@;
+QUIET = @
+endif
+
+# C compiler flags
+CFLAGS += -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \
+ -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
+ -Werror-implicit-function-declaration
+
+ifeq "$(RELEASE)" "1"
+CFLAGS += -DRELEASE
+DELIVERY = 1
+OPTIM ?= 2
+endif
+
+ifneq "$(DEBUG)" "0"
+CFLAGS += -g3
+LDFLAGS += -g3
+endif
+
+ifeq "$(WMOPS)" "1"
+CFLAGS += -DWMOPS=1
+endif
+
+OPTIM ?= 0
+CFLAGS += -O$(OPTIM)
+
+CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR))
+
+# Source file search paths
+VPATH = $(SRC_DIRS)
+
+###############################################################################
+
+SRCS_ENC = $(foreach DIR,$(SRC_ENC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
+SRCS_DEC = $(foreach DIR,$(SRC_DEC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
+
+OBJS_ENC = $(addprefix $(BUILD)/,$(SRCS_ENC:.c=.o))
+OBJS_DEC = $(addprefix $(BUILD)/,$(SRCS_DEC:.c=.o))
+
+DEPS = $(addprefix $(BUILD)/,$(SRCS_ENC:.c=.P) $(SRCS_DEC:.c=.P))
+
+###############################################################################
+
+.PHONY: all clean clean_all
+
+all: $(CLI_ENC) $(CLI_DEC)
+
+$(BUILD):
+ $(QUIET)mkdir -p $(BUILD)
+
+$(CLI_ENC): $(OBJS_ENC)
+ $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_ENC) -lm -o $(CLI_ENC)
+
+$(CLI_DEC): $(OBJS_DEC)
+ $(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_DEC) -lm -o $(CLI_DEC)
+
+clean:
+ $(QUIET)$(RM) $(OBJS_ENC) $(OBJS_DEC) $(DEPS)
+ $(QUIET)$(RM) $(DEPS:.P=.d)
+ $(QUIET)test ! -d $(BUILD) || rm -rf $(BUILD)
+
+clean_all: clean
+ $(QUIET)$(RM) $(CLI_ENC) $(CLI_DEC)
+
+$(BUILD)/%.o : %.c | $(BUILD)
+ $(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $<
+ @cp $(BUILD)/$*.d $(BUILD)/$*.P; \
+ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+ -e '/^$$/ d' -e 's/$$/ :/' < $(BUILD)/$*.d >> $(BUILD)/$*.P; \
+ $(RM) $(BUILD)/$*.d
+
+-include $(DEPS)
diff --git a/Workspace_msvc/Workspace_msvc.sln b/Workspace_msvc/Workspace_msvc.sln
new file mode 100644
index 0000000000000000000000000000000000000000..adee19143233f0c21fa87c502971a34331556240
--- /dev/null
+++ b/Workspace_msvc/Workspace_msvc.sln
@@ -0,0 +1,39 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26228.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "common.vcxproj", "{39EC200D-7795-4FF8-B214-B24EDA5526AE}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "evs_dec", "evs_dec.vcxproj", "{E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "evs_enc", "evs_enc.vcxproj", "{824DA4CF-06F0-45C9-929A-8792F0E19C3E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_fx", "lib_fx.vcxproj", "{52EF5F7B-DF20-4BA8-96E0-DCB4A9B3D200}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Debug|Win32.Build.0 = Debug|Win32
+ {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Release|Win32.ActiveCfg = Release|Win32
+ {39EC200D-7795-4FF8-B214-B24EDA5526AE}.Release|Win32.Build.0 = Release|Win32
+ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Debug|Win32.Build.0 = Debug|Win32
+ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Release|Win32.ActiveCfg = Release|Win32
+ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}.Release|Win32.Build.0 = Release|Win32
+ {824DA4CF-06F0-45C9-929A-8792F0E19C3E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {824DA4CF-06F0-45C9-929A-8792F0E19C3E}.Debug|Win32.Build.0 = Debug|Win32
+ {824DA4CF-06F0-45C9-929A-8792F0E19C3E}.Release|Win32.ActiveCfg = Release|Win32
+ {824DA4CF-06F0-45C9-929A-8792F0E19C3E}.Release|Win32.Build.0 = Release|Win32
+ {52EF5F7B-DF20-4BA8-96E0-DCB4A9B3D200}.Debug|Win32.ActiveCfg = Debug|Win32
+ {52EF5F7B-DF20-4BA8-96E0-DCB4A9B3D200}.Debug|Win32.Build.0 = Debug|Win32
+ {52EF5F7B-DF20-4BA8-96E0-DCB4A9B3D200}.Release|Win32.ActiveCfg = Release|Win32
+ {52EF5F7B-DF20-4BA8-96E0-DCB4A9B3D200}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Workspace_msvc/common.vcxproj b/Workspace_msvc/common.vcxproj
new file mode 100644
index 0000000000000000000000000000000000000000..946a2e096d8ec277e0b20e441e788c0dc92a6d85
--- /dev/null
+++ b/Workspace_msvc/common.vcxproj
@@ -0,0 +1,250 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {39EC200D-7795-4FF8-B214-B24EDA5526AE}
+ common
+ 10.0
+
+
+
+ StaticLibrary
+ v142
+ false
+ MultiByte
+
+
+ StaticLibrary
+ v142
+ false
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>15.0.26228.10
+
+
+ .\Debug_Common\
+ .\Debug_Common\
+
+
+ .\Release_Common\
+ .\Release_Common\
+
+
+
+ /MP %(AdditionalOptions)
+ Disabled
+ ..\lib_enc;..\lib_dec;..\lib_com;..\lib_debug;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+ EnableFastChecks
+ MultiThreadedDebug
+
+
+ $(IntDir)commonlib.pdb
+ Level4
+ true
+ OldStyle
+ Default
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ 0x0c0c
+
+
+ WS2_32.lib;%(AdditionalDependencies)
+ $(OutDir)$(TargetName)$(TargetExt)
+ true
+
+
+
+
+ MaxSpeed
+ OnlyExplicitInline
+ false
+ Speed
+ false
+ false
+ ..\lib_enc;..\lib_dec;..\lib_com;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;RELEASE;%(PreprocessorDefinitions)
+ true
+
+ Default
+ MultiThreaded
+ true
+
+
+ $(IntDir)commonlib.pdb
+ Level4
+ true
+
+ Default
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ 0x0c0c
+
+
+ WS2_32.lib;%(AdditionalDependencies)
+ $(OutDir)$(TargetName)$(TargetExt)
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {52ef5f7b-df20-4ba8-96e0-dcb4a9b3d200}
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Workspace_msvc/evs_dec.vcxproj b/Workspace_msvc/evs_dec.vcxproj
new file mode 100644
index 0000000000000000000000000000000000000000..410ecd8d252bcc100724131045cdd890b3d04742
--- /dev/null
+++ b/Workspace_msvc/evs_dec.vcxproj
@@ -0,0 +1,294 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {E822DDAF-0F5F-4CD0-A694-38AE69DE74D3}
+ evs_dec
+ 10.0
+
+
+
+ Application
+ v142
+ false
+ MultiByte
+
+
+ Application
+ v142
+ false
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>15.0.26228.10
+
+
+ ..\
+ .\Debug_Dec\
+ false
+ false
+ EVS_dec
+
+
+ ..\
+ .\Release_Dec\
+ false
+ false
+ EVS_dec
+
+
+
+
+
+
+ .\Debug/vbr_dec.tlb
+
+
+
+ /MP %(AdditionalOptions)
+ Disabled
+ ..\lib_enc;..\lib_dec;..\lib_com;..\lib_debug;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+ EnableFastChecks
+ MultiThreadedDebug
+ false
+
+
+ $(IntDir)evs_dec.pdb
+ Level4
+ true
+ OldStyle
+ Default
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ 0x0c0c
+
+
+
+ ..\EVS_dec.exe
+ true
+
+ true
+ .\Debug/evs_dec.pdb
+ Console
+ false
+
+ MachineX86
+
+
+
+
+ .\Release/vbr_dec.tlb
+
+
+
+ MaxSpeed
+ OnlyExplicitInline
+ false
+ Speed
+ false
+ false
+ ..\lib_enc;..\lib_dec;..\lib_com;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;RELEASE;%(PreprocessorDefinitions)
+ true
+
+ Default
+ MultiThreaded
+ true
+ false
+
+
+
+ $(IntDir)
+ $(IntDir)evs_dec.pdb
+ Level4
+ true
+
+ Default
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ 0x0c0c
+
+
+ Ws2_32.lib;%(AdditionalDependencies)
+ ..\EVS_dec.exe
+ true
+
+ false
+ .\Release/vbr_dec.pdb
+ Console
+ false
+
+ MachineX86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {39ec200d-7795-4ff8-b214-b24eda5526ae}
+ false
+
+
+ {52ef5f7b-df20-4ba8-96e0-dcb4a9b3d200}
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Workspace_msvc/evs_enc.vcxproj b/Workspace_msvc/evs_enc.vcxproj
new file mode 100644
index 0000000000000000000000000000000000000000..7da24732f846abf975d0a69885025ca1c86e89a5
--- /dev/null
+++ b/Workspace_msvc/evs_enc.vcxproj
@@ -0,0 +1,321 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {824DA4CF-06F0-45C9-929A-8792F0E19C3E}
+ evs_enc
+ 10.0
+
+
+
+ Application
+ v142
+ false
+ MultiByte
+
+
+ Application
+ v142
+ false
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>15.0.26228.10
+
+
+ ..\
+ .\Release_Enc\
+ false
+ false
+ EVS_cod
+
+
+ ..\
+ .\Debug_Enc\
+ false
+ false
+ EVS_cod
+
+
+
+
+
+
+ .\Release/vbr_enc.tlb
+
+
+
+ MaxSpeed
+ OnlyExplicitInline
+ false
+ Speed
+ false
+ false
+ ..\lib_enc;..\lib_dec;..\lib_com;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;RELEASE;%(PreprocessorDefinitions)
+ true
+
+ Default
+ MultiThreaded
+ true
+ Precise
+ false
+
+
+
+ $(IntDir)
+ $(IntDir)evs_enc.pdb
+ Level4
+ true
+
+ Default
+
+
+ NDEBUG;%(PreprocessorDefinitions)
+ 0x0c0c
+
+
+ Ws2_32.lib;%(AdditionalDependencies)
+ ..\EVS_cod.exe
+ true
+
+ false
+ .\Release/vbr_enc.pdb
+ Console
+ false
+
+ MachineX86
+
+
+
+
+
+
+
+ .\Debug/vbr_enc.tlb
+
+
+
+ /MP %(AdditionalOptions)
+ Disabled
+ ..\lib_enc;..\lib_dec;..\lib_com;..\lib_debug;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+
+ EnableFastChecks
+ MultiThreadedDebug
+ false
+
+
+ $(IntDir)evs_enc.pdb
+ true
+ Level4
+ true
+ OldStyle
+ Default
+
+
+ _DEBUG;%(PreprocessorDefinitions)
+ 0x0c0c
+
+
+
+ ..\EVS_cod.exe
+ true
+
+ false
+ true
+ .\Debug/evs_enc.pdb
+ Console
+
+ false
+
+ MachineX86
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {39ec200d-7795-4ff8-b214-b24eda5526ae}
+ false
+
+
+ {52ef5f7b-df20-4ba8-96e0-dcb4a9b3d200}
+ false
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Workspace_msvc/lib_fx.vcxproj b/Workspace_msvc/lib_fx.vcxproj
new file mode 100644
index 0000000000000000000000000000000000000000..c05eb8e87cbb298b1408362eff4ac6baf1f9ba40
--- /dev/null
+++ b/Workspace_msvc/lib_fx.vcxproj
@@ -0,0 +1,126 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {52EF5F7B-DF20-4BA8-96E0-DCB4A9B3D200}
+ lib_fx
+ 10.0
+
+
+
+ StaticLibrary
+ v142
+ MultiByte
+ true
+
+
+ StaticLibrary
+ v142
+ MultiByte
+
+
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>15.0.26228.10
+
+
+ .\Debug_Fx\
+ .\Debug_Fx\
+
+
+ .\Release_Fx\
+ .\Release_Fx\
+
+
+
+ /MP %(AdditionalOptions)
+ Disabled
+ ..\lib_enc;..\lib_dec;..\lib_com;..\lib_debug;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ EnableFastChecks
+ MultiThreadedDebug
+ $(IntDir)lib_fixlib.pdb
+ Level3
+ OldStyle
+ Default
+
+
+
+
+ MaxSpeed
+ false
+ false
+ ..\lib_enc;..\lib_dec;..\lib_com;..\basic_op;..\basic_math;%(AdditionalIncludeDirectories)
+ _CRT_SECURE_NO_WARNINGS;RELEASE;%(PreprocessorDefinitions)
+ true
+ Default
+ MultiThreaded
+ true
+ $(IntDir)lib_fixlib.pdb
+ Level3
+ ProgramDatabase
+ Default
+ Speed
+
+
+
+
+
+
\ No newline at end of file
diff --git a/basic_math/log2.c b/basic_math/log2.c
new file mode 100644
index 0000000000000000000000000000000000000000..57abb3352b34e9bb9fd50235cc1a805c41e4b313
--- /dev/null
+++ b/basic_math/log2.c
@@ -0,0 +1,211 @@
+/********************************************************************************
+*
+* File : log2.c
+* Purpose : Computes log2(L_x)
+*
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+* INCLUDE FILES
+********************************************************************************
+*/
+#include "stl.h"
+#include "math_op.h"
+#include
+#include "rom_basic_math.h"
+#include "options.h"
+
+#define LW_SIGN (Word32)0x80000000 /* sign bit */
+#define LW_MIN (Word32)0x80000000
+#define LW_MAX (Word32)0x7fffffff
+
+#define SW_SIGN (Word16)0x8000 /* sign bit for Word16 type */
+#define SW_MIN (Word16)0x8000 /* smallest Ram */
+#define SW_MAX (Word16)0x7fff /* largest Ram */
+
+
+/*
+********************************************************************************
+* PUBLIC PROGRAM CODE
+********************************************************************************
+*/
+
+/*************************************************************************
+ *
+ * FUNCTION: Log2_norm_lc()
+ *
+ * PURPOSE: Computes log2(L_x, exp), where L_x is positive and
+ * normalized, and exp is the normalisation exponent
+ * If L_x is negative or zero, the result is 0.
+ *
+ * DESCRIPTION:
+ * The function Log2(L_x) is approximated by a table and linear
+ * interpolation. The following steps are used to compute Log2(L_x)
+ *
+ * 1- exponent = 30-norm_exponent
+ * 2- i = bit25-b31 of L_x; 32<=i<=63 (because of normalization).
+ * 3- a = bit10-b24
+ * 4- i -=32
+ * 5- fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2
+ *
+ *************************************************************************/
+Word16 Log2_norm_lc ( /* (o) : Fractional part of Log2. (range: 0<=val<1) */
+ Word32 L_x /* (i) : input value (normalized) */
+)
+{
+ Word16 i, a;
+ Word16 y;
+
+ if (L_x <= 0)
+ L_x = L_deposit_h(0x4000);
+
+ L_x = L_shr (L_x, 9);
+ a = extract_l (L_x); /* Extract b10-b24 of fraction */
+ a = lshr(a, 1);
+
+ i = mac_r(L_x, -32*2-1, 16384); /* Extract b25-b31 minus 32 */
+
+ y = mac_r(L_table_Log2_norm_lc[i], table_diff_Log2_norm_lc[i], a); /* table[i] << 16 - diff*a*2 */
+
+ return y;
+}
+
+Word32 log10_fx(Word32 Linput)
+{
+ Word16 n1, frac, p1, p2, q1;
+ Word32 Ltemp1, Ltemp2;
+ Word32 L_tmp;
+
+ if (Linput<=0) return(LW_MIN);
+ n1=norm_l(Linput);
+ Ltemp1=(Word32)L_shl(Linput,n1);
+
+ Ltemp2=L_mult(extract_h(Ltemp1),0x40);
+ frac=extract_l(Ltemp2);
+
+ p1=log2_tab[sub(extract_h(Ltemp2),0x20)];
+ p2=log2_tab[sub(extract_h(Ltemp2),0x1F)];
+ Ltemp2=L_mult(n1,0x200);
+ n1=extract_l(Ltemp2);
+
+ Ltemp1=L_add(L_deposit_h(p1),0x8000); /* Add rounding bit */
+
+ IF(frac >= 0)
+ {
+ Ltemp1=L_sub(Ltemp1,(Word32)L_mult0(p1,frac));
+ Ltemp1=L_add(Ltemp1,(Word32)L_mult0(p2,frac));
+ }
+ ELSE
+ {
+ L_tmp = L_add(65536,frac);
+ L_tmp = L_tmp*p1;
+ Ltemp1=L_sub(Ltemp1,L_tmp);
+
+ L_tmp = L_add(65536,frac);
+ L_tmp = L_tmp*p2;
+ Ltemp1=L_add(Ltemp1,L_tmp);
+ }
+ q1=extract_h(Ltemp1);
+ Ltemp1=L_mult(q1,0x6054);
+ Ltemp1=L_msu(Ltemp1,0x6054,n1);
+ return(L_shr(Ltemp1,1));
+
+}
+
+Word32 pow_10(Word32 x , Word16 *Q)
+{
+ Word16 xl,xh, t1, t2, n;
+ Word32 Ltemp1;
+ Word32 Lacc;
+ Word32 L_tmp;
+ Word16 n1,i;
+ Word16 count = 0;
+
+ move16();;
+
+ xl=extract_l(x);
+ xh=extract_h(x);
+
+ IF(xl < 0)
+ {
+ L_tmp = L_add(65536,xl);
+ Ltemp1=(Word32) (0x6a4d*L_tmp );
+ }
+ ELSE
+ {
+ Ltemp1=L_mult0(0x6a4d,xl);
+ }
+ Ltemp1=L_add(L_shr(Ltemp1,16),L_shr(L_mult(xh,0x6a4d),1));
+
+
+ Lacc=L_sub(-1L, Ltemp1); /* Lacc=~Lacc, 1's complement */
+ t1=extract_l(L_shr(Lacc,7));
+
+ Ltemp1=L_shr(Ltemp1,7);
+ n1 = extract_h(Ltemp1);
+ n=sub(n1,14);
+ *Q = 14; move16();
+ IF(t1<0)
+ {
+ L_tmp = L_add(65536,t1);
+ t2=extract_h(L_tmp*L_tmp);
+ }
+ ELSE
+ {
+ t2=extract_h(L_mult0(t1,t1));
+ }
+
+ Lacc = L_deposit_h(0x1FEF);
+ IF(t2 < 0)
+ {
+ L_tmp = L_add(65536,t2);
+ Lacc = L_add(Lacc,(Word32)(L_tmp*0x057C));
+ }
+ ELSE
+ {
+ Lacc = L_add(Lacc,(Word32)L_mult0(t2,0x057C));
+ }
+
+ IF(t1 < 0)
+ {
+ L_tmp = L_add(65536,t1);
+ Lacc = L_sub(Lacc,(Word32)(L_tmp*0x155C));
+ }
+ ELSE
+ {
+ Lacc = L_sub(Lacc,(Word32)L_mult0(t1,0x155C));
+ }
+
+ L_tmp = Lacc;
+ FOR(i =1 ;i <= n ;i++)
+ {
+ Overflow = 0; move16();
+ L_tmp = L_shl(L_tmp,i);
+ IF(Overflow)
+ {
+ count = add(count,1);
+ }
+ }
+ *Q = sub(*Q,count); move16();
+
+ return(L_shl(Lacc,sub(n,count)));
+
+}
+
+Word16 Log2_lc( /* (o) : Fractional part of Log2. (range: 0<=val<1) */
+ Word32 L_x, /* (i) : input value */
+ Word16 *exponent /* (o) : Integer part of Log2. (range: 0<=val<=30) */
+)
+{
+ Word16 exp;
+
+ if (L_x <= 0)
+ L_x = L_deposit_l(0x1);
+
+ exp = norm_l (L_x);
+ *exponent = sub(30, exp); move16();
+
+ return Log2_norm_lc(L_shl(L_x, exp));
+}
diff --git a/basic_math/log2.h b/basic_math/log2.h
new file mode 100644
index 0000000000000000000000000000000000000000..a8ff32e657ffa5008e1dc24b51779acd94127dbc
--- /dev/null
+++ b/basic_math/log2.h
@@ -0,0 +1,40 @@
+/********************************************************************************
+*
+* File : log2.h
+* Purpose : Computes log2(L_x)
+*
+********************************************************************************
+*/
+#ifndef log2_h
+#define log2_h "$Id $"
+
+/*
+********************************************************************************
+* INCLUDE FILES
+********************************************************************************
+*/
+#include "typedef.h"
+#include "log2.h"
+
+/*
+********************************************************************************
+* DEFINITION OF DATA TYPES
+********************************************************************************
+*/
+
+/*
+********************************************************************************
+* DECLARATION OF PROTOTYPES
+********************************************************************************
+*/
+Word16 Log2_norm_lc ( /* (o) : Fractional part of Log2. (range: 0<=val<1) */
+ Word32 L_x /* (i) : input value (normalized) */
+);
+
+Word32 log10_fx(Word32 Linput);
+Word32 pow_10(Word32 x, Word16 *Q);
+Word16 Log2_lc( /* (o) : Fractional part of Log2. (range: 0<=val<1) */
+ Word32 L_x, /* (i) : input value */
+ Word16 *exponent /* (o) : Integer part of Log2. (range: 0<=val<=30) */
+);
+#endif
diff --git a/basic_math/math_32.h b/basic_math/math_32.h
new file mode 100644
index 0000000000000000000000000000000000000000..539284d5a28e25aee9cb74576ca9c14c35b7593c
--- /dev/null
+++ b/basic_math/math_32.h
@@ -0,0 +1,10 @@
+#ifndef _MATH_32_H_
+#define _MATH_32_H_
+
+#include "typedef.h"
+#include "basop32.h"
+#include "enh32.h"
+
+#define Mult_32_16(A,B) Mpy_32_16_1(A,B)
+#define Mult_32_32(A,B) Mpy_32_32(A,B)
+#endif /* #ifndef _MATH_32_H_ */
diff --git a/basic_math/math_op.c b/basic_math/math_op.c
new file mode 100644
index 0000000000000000000000000000000000000000..a5256a2af9156d59267cbf43509f2e4044f8a175
--- /dev/null
+++ b/basic_math/math_op.c
@@ -0,0 +1,359 @@
+/*___________________________________________________________________________
+ | |
+ | This file contains mathematic operations in fixed point. |
+ | |
+ | Isqrt() : inverse square root (16 bits precision). |
+ | Pow2() : 2^x (16 bits precision). |
+ | Log2() : log2 (16 bits precision). |
+ | Dot_product() : scalar product of |
+ | |
+ | In this file, the values use theses representations: |
+ | |
+ | Word32 L_32 : standard signed 32 bits format |
+ | Word16 hi, lo : L_32 = hi<<16 + lo<<1 (DPF - Double Precision Format) |
+ | Word32 frac, Word16 exp : L_32 = frac << exp-31 (normalised format) |
+ | Word16 int, frac : L_32 = int.frac (fractional format) |
+ |___________________________________________________________________________|
+*/
+
+#include "stl.h"
+#include "math_op.h"
+#include "rom_basic_math.h"
+
+#include
+#include
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : Isqrt |
+ | |
+ | Compute 1/sqrt(L_x). |
+ | if L_x is negative or zero, result is 1 (7fffffff). |
+ |---------------------------------------------------------------------------|
+ | Algorithm: |
+ | |
+ | 1- Normalization of L_x. |
+ | 2- call Isqrt_lc(L_x, exponant) |
+ | 3- L_y = L_x << exponant |
+ |___________________________________________________________________________|
+*/
+Word32 Isqrt( /* (o) Q31 : output value (range: 0<=val<1) */
+ Word32 L_x /* (i) Q0 : input value (range: 0<=val<=7fffffff) */
+)
+{
+ Word16 exp;
+ Word32 L_y;
+
+ exp = norm_l(L_x);
+ L_x = L_shl(L_x, exp); /* L_x is normalized */
+ exp = sub(31, exp);
+
+ L_x = Isqrt_lc(L_x, &exp);
+
+ L_y = L_shl(L_x, exp); /* denormalization */
+
+ return (L_y);
+}
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : Isqrt_lc |
+ | |
+ | Compute 1/sqrt(value). |
+ | if value is negative or zero, result is 1 (frac=7fffffff, exp=0). |
+ |---------------------------------------------------------------------------|
+ | Algorithm: |
+ | |
+ | The function 1/sqrt(value) is approximated by a table and linear |
+ | interpolation. |
+ | |
+ | 1- If exponant is odd then shift fraction right once. |
+ | 2- exponant = -((exponant-1)>>1) |
+ | 3- i = bit25-b30 of fraction, 16 <= i <= 63 ->because of normalization. |
+ | 4- a = bit10-b24 |
+ | 5- i -=16 |
+ | 6- fraction = table[i]<<16 - (table[i] - table[i+1]) * a * 2 |
+ |___________________________________________________________________________|
+*/
+Word32 Isqrt_lc(
+ Word32 frac, /* (i) Q31: normalized value (1.0 < frac <= 0.5) */
+ Word16 * exp /* (i/o) : exponent (value = frac x 2^exponent) */
+)
+{
+ Word16 i, a;
+ Word32 L_tmp;
+
+ IF (frac <= (Word32) 0)
+ {
+ *exp = 0; move16();
+ return 0x7fffffff; /*0x7fffffff*/
+ }
+
+ /* If exponant odd -> shift right by 10 (otherwise 9) */
+ L_tmp = L_shr(frac, shift_Isqrt_lc[s_and(*exp, 1)]);
+
+ /* 1) -16384 to shift left and change sign */
+ /* 2) 32768 to Add 1 to Exponent like it was divided by 2 */
+ /* 3) We let the mac_r add another 0.5 because it imitates */
+ /* the behavior of shr on negative number that should */
+ /* not be rounded towards negative infinity. */
+ /* It replaces: */
+ /* *exp = negate(shr(sub(*exp, 1), 1)); move16(); */
+ *exp = mac_r(32768, *exp, -16384); move16();
+
+ a = extract_l(L_tmp); /* Extract b10-b24 */
+ a = lshr(a, 1);
+
+ i = mac_r(L_tmp, -16*2-1, 16384); /* Extract b25-b31 minus 16 */
+
+ L_tmp = L_msu(L_table_isqrt[i], table_isqrt_diff[i], a);/* table[i] << 16 - diff*a*2 */
+
+ return L_tmp;
+}
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : Pow2() |
+ | |
+ | L_x = pow(2.0, exponant.fraction) (exponant = interger part) |
+ | = pow(2.0, 0.fraction) << exponant |
+ |---------------------------------------------------------------------------|
+ | Algorithm: |
+ | |
+ | The function Pow2(L_x) is approximated by a table and linear |
+ | interpolation. |
+ | |
+ | 1- i = bit10-b15 of fraction, 0 <= i <= 31 |
+ | 2- a = bit0-b9 of fraction |
+ | 3- L_x = table[i]<<16 - (table[i] - table[i+1]) * a * 2 |
+ | 4- L_x = L_x >> (30-exponant) (with rounding) |
+ |___________________________________________________________________________|
+*/
+
+Word32 Pow2( /* (o) Q0 : result (range: 0<=val<=0x7fffffff) */
+ Word16 exponant, /* (i) Q0 : Integer part. (range: 0<=val<=30) */
+ Word16 fraction /* (i) Q15 : Fractionnal part. (range: 0.0<=val<1.0) */
+)
+{
+ Word16 exp, i, a;
+ Word32 L_x;
+
+
+
+ i = mac_r(-32768, fraction, 32); /* Extract b10-b16 of fraction */
+ a = s_and(fraction, 0x3ff); /* Extract b0-b9 of fraction */
+
+ L_x = L_deposit_h(table_pow2[i]); /* table[i] << 16 */
+ L_x = L_mac(L_x, table_pow2_diff_x32[i], a);/* L_x -= diff*a*2 */
+
+ exp = sub(30, exponant);
+
+ L_x = L_shr_r(L_x, exp);
+
+
+ return L_x;
+}
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : Dot_product12() |
+ | |
+ | Compute scalar product of using accumulator. |
+ | |
+ | The result is normalized (in Q31) with exponent (0..30). |
+ |---------------------------------------------------------------------------|
+ | Algorithm: |
+ | |
+ | dot_product = sum(x[i]*y[i]) i=0..N-1 |
+ |___________________________________________________________________________|
+*/
+
+Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 12bits: x vector */
+ const Word16 y[], /* (i) 12bits: y vector */
+ const Word16 lg, /* (i) : vector length */
+ Word16 * exp /* (o) : exponent of result (0..+30) */
+)
+{
+ Word16 i, sft;
+ Word32 L_sum;
+
+ L_sum = L_mac(1, x[0], y[0]);
+ FOR (i = 1; i < lg; i++)
+ L_sum = L_mac(L_sum, x[i], y[i]);
+
+ /* Normalize acc in Q31 */
+
+ sft = norm_l(L_sum);
+ L_sum = L_shl(L_sum, sft);
+
+ *exp = sub(30, sft); move16(); /* exponent = 0..30 */
+
+ return L_sum;
+}
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : Energy_scale() |
+ | |
+ | Compute energy of signal (scaling the input if specified) |
+ | |
+ | The result is normalized (in Q31) with exponent (0..30). |
+ |___________________________________________________________________________|
+*/
+
+Word32 Energy_scale( /* (o) : Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) : input vector x */
+ const Word16 lg, /* (i) : vector length */
+ Word16 expi, /* (i) : exponent of input */
+ Word16 *exp /* (o) : exponent of result (0..+30) */
+)
+{
+ Word16 i, sft, tmp;
+ Word32 L_sum;
+
+
+ L_sum = 0; /* just to avoid superflous compiler warning about uninitialized use of L_sum */
+
+ IF (expi == 0)
+ {
+ L_sum = L_mac(1, x[0], x[0]);
+ FOR (i = 1; i < lg; i++)
+ {
+ L_sum = L_mac(L_sum, x[i], x[i]);
+ }
+ }
+ IF (expi < 0)
+ {
+ sft = lshl(-32768 /* 0x8000 */, expi);
+ tmp = mult_r(x[0], sft);
+ L_sum = L_mac(1, tmp, tmp);
+ FOR (i = 1; i < lg; i++)
+ {
+ tmp = mult_r(x[i], sft);
+ L_sum = L_mac(L_sum, tmp, tmp);
+ }
+ }
+ IF (expi > 0)
+ {
+ tmp = shl(x[0], expi);
+ L_sum = L_mac(1, tmp, tmp);
+ FOR (i = 1; i < lg; i++)
+ {
+ tmp = shl(x[i], expi);
+ L_sum = L_mac(L_sum, tmp, tmp);
+ }
+ }
+
+ /* Normalize acc in Q31 */
+
+ sft = norm_l(L_sum);
+ L_sum = L_shl(L_sum, sft);
+
+ *exp = sub(30, sft); move16(); /* exponent = 0..30 */
+
+
+ return L_sum;
+}
+
+Word32 Sqrt_l( /* o : output value, Q31 */
+ Word32 L_x, /* i : input value, Q31 */
+ Word16 *exp /* o : right shift to be applied to result, Q1 */
+)
+{
+ /*
+ y = sqrt(x)
+
+ x = f * 2^-e, 0.5 <= f < 1 (normalization)
+
+ y = sqrt(f) * 2^(-e/2)
+
+ a) e = 2k --> y = sqrt(f) * 2^-k (k = e div 2,
+ 0.707 <= sqrt(f) < 1)
+ b) e = 2k+1 --> y = sqrt(f/2) * 2^-k (k = e div 2,
+ 0.5 <= sqrt(f/2) < 0.707)
+ */
+
+ Word16 e, i, a, tmp;
+ Word32 L_y;
+
+ if (L_x <= 0)
+ {
+ *exp = 0; move16 ();
+ return L_deposit_l(0);
+ }
+
+ e = s_and(norm_l(L_x), 0x7FFE); /* get next lower EVEN norm. exp */
+ L_x = L_shl(L_x, e); /* L_x is normalized to [0.25..1) */
+ *exp = e; move16 (); /* return 2*exponent (or Q1) */
+
+ L_x = L_shr(L_x, 9);
+ a = extract_l(L_x); /* Extract b10-b24 */
+ a = lshr(a, 1);
+
+ i = mac_r(L_x, -16*2-1, 16384); /* Extract b25-b31 minus 16 */
+
+ L_y = L_deposit_h(sqrt_table[i]); /* table[i] << 16 */
+ tmp = sub(sqrt_table[i], sqrt_table[i + 1]); /* table[i] - table[i+1]) */
+ L_y = L_msu(L_y, tmp, a); /* L_y -= tmp*a*2 */
+
+ /* L_y = L_shr (L_y, *exp); */ /* denormalization done by caller */
+
+ return (L_y);
+}
+
+/*---------------------------------------------------------------------------*
+ * L_Frac_sqrtQ31
+ *
+ * Calculate square root from fractional values (Q31 -> Q31)
+ * Uses 32 bit internal representation for precision
+ *---------------------------------------------------------------------------*/
+Word32 L_Frac_sqrtQ31( /* o : Square root if input */
+ const Word32 x /* i : Input */
+)
+{
+ Word32 log2_work;
+ Word16 log2_int, log2_frac;
+
+ test();
+ if (x > 0)
+ {
+ log2_int = norm_l(x);
+ log2_frac = Log2_norm_lc(L_shl(x, log2_int));
+
+ log2_work = L_msu((31+30)*65536L/2, 16384, log2_int);
+ log2_work = L_mac0(log2_work, log2_frac, 1);
+
+ log2_frac = L_Extract_lc(log2_work, &log2_int);
+
+ return Pow2(log2_int, log2_frac);
+ }
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------*
+ * Frac_sqrt
+ *
+ * Calculate square root from fractional values (Q15 -> Q15)
+ *----------------------------------------------------------------------------------*/
+Word16 Frac_sqrt( /* o : Square root if input */
+ const Word16 x /* i : Input */
+)
+{
+ return round_fx(L_Frac_sqrtQ31(L_deposit_h(x)));
+}
+
+
+/*----------------------------------------------------------------------------------*
+ * i_mult2
+ *
+ * Faster Integer Multiplication
+ *----------------------------------------------------------------------------------*/
+
+Word16 i_mult2 (Word16 a, Word16 b)
+{
+ return extract_l(L_mult0(a, b));
+}
+
+
+
diff --git a/basic_math/math_op.h b/basic_math/math_op.h
new file mode 100644
index 0000000000000000000000000000000000000000..9a17485f44bf97100532c04ea68506b7c370b66e
--- /dev/null
+++ b/basic_math/math_op.h
@@ -0,0 +1,48 @@
+/*--------------------------------------------------------------------------*
+ * MATH_OP.H *
+ *--------------------------------------------------------------------------*
+ * Mathematical operations *
+ *--------------------------------------------------------------------------*/
+#include "oper_32b.h"
+#include "log2.h"
+
+Word32 Isqrt( /* (o) Q31 : output value (range: 0<=val<1) */
+ Word32 L_x /* (i) Q0 : input value (range: 0<=val<=7fffffff) */
+);
+Word32 Isqrt_lc(
+ Word32 frac, /* (i/o) Q31: normalized value (1.0 < frac <= 0.5) */
+ Word16 * exp /* (i/o) : exponent (value = frac x 2^exponent) */
+);
+
+Word32 Pow2( /* (o) Q0 : result (range: 0<=val<=0x7fffffff) */
+ Word16 exponant, /* (i) Q0 : Integer part. (range: 0<=val<=30) */
+ Word16 fraction /* (i) Q15 : Fractionnal part. (range: 0.0<=val<1.0) */
+);
+Word32 Dot_product12( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 12bits: x vector */
+ const Word16 y[], /* (i) 12bits: y vector */
+ const Word16 lg, /* (i) : vector length */
+ Word16 * exp /* (o) : exponent of result (0..+30) */
+);
+
+Word32 Energy_scale( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 12bits: x vector */
+ const Word16 lg, /* (i) : vector length */
+ Word16 expi, /* (i) : exponent of input */
+ Word16 *exp /* (o) : exponent of result (0..+30) */
+);
+
+Word32 Sqrt_l(Word32 L_x, Word16 *exp);
+
+Word32 L_Frac_sqrtQ31( /* o : Square root if input */
+ const Word32 x /* i : Input */
+);
+
+Word16 Frac_sqrt( /* o : Square root if input */
+ const Word16 x /* i : Input */
+);
+
+Word16 i_mult2 (Word16 a, Word16 b);
+
+#include "math_32.h"
+
diff --git a/basic_math/oper_32b.c b/basic_math/oper_32b.c
new file mode 100644
index 0000000000000000000000000000000000000000..1904cdd882a56674be5451ef68035e8cf1287aac
--- /dev/null
+++ b/basic_math/oper_32b.c
@@ -0,0 +1,381 @@
+/*****************************************************************************
+ * $Id: oper_32b.c 1094 2014-02-10 17:12:11Z jdr $
+ *
+ * This file contains operations in double precision. *
+ * These operations are not standard double precision operations. *
+ * They are used where single precision is not enough but the full 32 bits *
+ * precision is not necessary. For example, the function Div_32() has a *
+ * 24 bits precision which is enough for our purposes. *
+ * *
+ * The double precision numbers use a special representation: *
+ * *
+ * L_32 = hi<<16 + lo<<1 *
+ * *
+ * L_32 is a 32 bit integer. *
+ * hi and lo are 16 bit signed integers. *
+ * As the low part also contains the sign, this allows fast multiplication. *
+ * *
+ * 0x8000 0000 <= L_32 <= 0x7fff fffe. *
+ * *
+ * We will use DPF (Double Precision Format) in this file to specify *
+ * this special format. *
+ *****************************************************************************
+*/
+
+#include "stl.h"
+#include "math_op.h"
+
+/*****************************************************************************
+ * *
+ * Function L_Extract() *
+ * *
+ * Extract from a 32 bit integer two 16 bit DPF. *
+ * *
+ * Arguments: *
+ * *
+ * L_32 : 32 bit integer. *
+ * 0x8000 0000 <= L_32 <= 0x7fff ffff. *
+ * hi : b16 to b31 of L_32 *
+ * lo : (L_32 - hi<<16)>>1 *
+ *****************************************************************************
+*/
+
+void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo)
+{
+ *hi = extract_h (L_32);
+ *lo = extract_l (L_msu (L_shr (L_32, 1), *hi, 16384));
+ return;
+}
+
+/*****************************************************************************
+ * *
+ * Function L_Extract_lc() *
+ * *
+ * Extract from a 32 bit integer two 16 bit DPF. *
+ * (lo is returned, store to memory is not accounted for) *
+ * *
+ * Arguments: *
+ * *
+ * L_32 : 32 bit integer. *
+ * 0x8000 0000 <= L_32 <= 0x7fff ffff. *
+ * hi : b16 to b31 of L_32 *
+ * lo : (L_32 - hi<<16)>>1 *
+ *****************************************************************************
+*/
+
+Word16 L_Extract_lc (Word32 L_32, Word16 *hi)
+{
+ *hi = extract_h (L_32);
+
+ return lshr(extract_l(L_32), 1);
+}
+
+/*****************************************************************************
+ * *
+ * Function L_Comp() *
+ * *
+ * Compose from two 16 bit DPF a 32 bit integer. *
+ * *
+ * L_32 = hi<<16 + lo<<1 *
+ * *
+ * Arguments: *
+ * *
+ * hi msb *
+ * lo lsf (with sign) *
+ * *
+ * Return Value : *
+ * *
+ * 32 bit long signed integer (Word32) whose value falls in the *
+ * range : 0x8000 0000 <= L_32 <= 0x7fff fff0. *
+ * *
+ *****************************************************************************
+*/
+
+Word32 L_Comp (Word16 hi, Word16 lo)
+{
+ Word32 L_32;
+
+ L_32 = L_deposit_h (hi);
+ return (L_mac (L_32, lo, 1)); /* = hi<<16 + lo<<1 */
+}
+
+/*****************************************************************************
+ * Function Mpy_32() *
+ * *
+ * Multiply two 32 bit integers (DPF). The result is divided by 2**31 *
+ * *
+ * L_32 = (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 *
+ * *
+ * This operation can also be viewed as the multiplication of two Q31 *
+ * number and the result is also in Q31. *
+ * *
+ * Arguments: *
+ * *
+ * hi1 hi part of first number *
+ * lo1 lo part of first number *
+ * hi2 hi part of second number *
+ * lo2 lo part of second number *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
+{
+ Word32 L_32;
+
+ L_32 = L_mult (hi1, hi2);
+ L_32 = L_mac (L_32, mult (hi1, lo2), 1);
+ L_32 = L_mac (L_32, mult (lo1, hi2), 1);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * Function Mac_32() *
+ * *
+ * Multiply two 32 bit integers (DPF). The result is divided by 2**31 *
+ * Adds a 32 bit integer (non DFP) *
+ * *
+ * L_32 = L_num + (hi1*hi2)<<1 + ( (hi1*lo2)>>15 + (lo1*hi2)>>15 )<<1 *
+ * *
+ * This operation can also be viewed as the multiplication of two Q31 *
+ * number and the result is also in Q31. *
+ * *
+ * Arguments: *
+ * *
+ * hi1 hi part of first number *
+ * lo1 lo part of first number *
+ * hi2 hi part of second number *
+ * lo2 lo part of second number *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Mac_32 (Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2)
+{
+ Word32 L_32;
+
+ L_32 = L_mac (L_num, hi1, hi2);
+ L_32 = L_mac (L_32, mult (hi1, lo2), 1);
+ L_32 = L_mac (L_32, mult (lo1, hi2), 1);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * Function Sqr_32() *
+ * *
+ * Square one 32 bit integer (DPF). The result is divided by 2**31 *
+ * *
+ * L_32 = (hi*hi)<<1 + ( (hi*lo)>>15 *2)<<1 *
+ * *
+ * This operation can also be viewed as the square of one Q31 *
+ * number and the result is also in Q31. *
+ * *
+ * Arguments: *
+ * *
+ * hi1 hi part of first number *
+ * lo1 lo part of first number *
+ * hi2 hi part of second number *
+ * lo2 lo part of second number *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Sqr_32 (Word16 hi, Word16 lo)
+{
+ Word32 L_32;
+
+ L_32 = L_mult (hi, hi);
+ L_32 = L_mac (L_32, mult (hi, lo), 2);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * Function Sad_32() *
+ * *
+ * Square one 32 bit integer (DPF). The result is divided by 2**31 *
+ * Adds a 32 bit integer (non DFP) *
+ * *
+ * L_32 = L_num + (hi*hi)<<1 + ( (hi*lo)>>15 *2)<<1 *
+ * *
+ * This operation can also be viewed as the square of one Q31 *
+ * number and the result is also in Q31. *
+ * *
+ * Arguments: *
+ * *
+ * hi1 hi part of first number *
+ * lo1 lo part of first number *
+ * hi2 hi part of second number *
+ * lo2 lo part of second number *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Sad_32 (Word32 L_num, Word16 hi, Word16 lo)
+{
+ Word32 L_32;
+
+ L_32 = L_mac (L_num, hi, hi);
+ L_32 = L_mac (L_32, mult (hi, lo), 2);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * Function Mpy_32_16() *
+ * *
+ * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided *
+ * by 2**15 *
+ * *
+ * *
+ * L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 *
+ * *
+ * Arguments: *
+ * *
+ * hi hi part of 32 bit number. *
+ * lo lo part of 32 bit number. *
+ * n 16 bit number. *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n)
+{
+ Word32 L_32;
+
+ L_32 = L_mult (hi, n);
+ L_32 = L_mac (L_32, mult (lo, n), 1);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * Function Mac_32_16() *
+ * *
+ * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided *
+ * by 2**15 *
+ * Adds a 32 bit integer (non DFP) *
+ * *
+ * *
+ * L_32 = L_num + (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 *
+ * *
+ * Arguments: *
+ * *
+ * L_num 32 bit long signed integer (Word32) *
+ * hi hi part of 32 bit number. *
+ * lo lo part of 32 bit number. *
+ * n 16 bit number. *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Mac_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n)
+{
+ Word32 L_32;
+
+ L_32 = L_mac (L_num, hi, n);
+ L_32 = L_mac (L_32, mult (lo, n), 1);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * Function Msu_32_16() *
+ * *
+ * Substract a 32 bit integer (non DFP) *
+ * Multiply a 16 bit integer by a 32 bit (DPF). The result is divided *
+ * by 2**15 *
+ * *
+ * *
+ * L_32 = L_num - (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1 *
+ * *
+ * Arguments: *
+ * *
+ * L_num 32 bit long signed integer (Word32) *
+ * hi hi part of 32 bit number. *
+ * lo lo part of 32 bit number. *
+ * n 16 bit number. *
+ * *
+ *****************************************************************************
+*/
+
+Word32 Msu_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n)
+{
+ Word32 L_32;
+
+ L_32 = L_msu (L_num, hi, n);
+ L_32 = L_msu (L_32, mult (lo, n), 1);
+
+ return (L_32);
+}
+
+/*****************************************************************************
+ * *
+ * Function Name : Div_32 *
+ * *
+ * Purpose : *
+ * Fractional integer division of two 32 bit numbers. *
+ * L_num / L_denom. *
+ * L_num and L_denom must be positive and L_num < L_denom. *
+ * L_denom = denom_hi<<16 + denom_lo<<1 *
+ * denom_hi is a normalize number. *
+ * *
+ * Inputs : *
+ * *
+ * L_num *
+ * 32 bit long signed integer (Word32) whose value falls in the *
+ * range : 0x0000 0000 < L_num < L_denom *
+ * *
+ * L_denom = denom_hi<<16 + denom_lo<<1 (DPF) *
+ * *
+ * denom_hi *
+ * 16 bit positive normalized integer whose value falls in the *
+ * range : 0x4000 < hi < 0x7fff *
+ * denom_lo *
+ * 16 bit positive integer whose value falls in the *
+ * range : 0 < lo < 0x7fff *
+ * *
+ * Return Value : *
+ * *
+ * L_div *
+ * 32 bit long signed integer (Word32) whose value falls in the *
+ * range : 0x0000 0000 <= L_div <= 0x7fff ffff. *
+ * *
+ * Algorithm: *
+ * *
+ * - find = 1/L_denom. *
+ * First approximation: approx = 1 / denom_hi *
+ * 1/L_denom = approx * (2.0 - L_denom * approx ) *
+ * *
+ * - result = L_num * (1/L_denom) *
+ *****************************************************************************
+*/
+
+Word32 Div_32 (Word32 L_num, Word16 denom_hi, Word16 denom_lo)
+{
+ Word16 approx, hi, lo, n_hi, n_lo;
+ Word32 L_32;
+
+ /* First approximation: 1 / L_denom = 1/denom_hi */
+
+ approx = div_s ((Word16) 0x3fff, denom_hi);
+
+ /* 1/L_denom = approx * (2.0 - L_denom * approx) */
+
+ L_32 = Msu_32_16 ((Word32) 0x7fffffffL, denom_hi, denom_lo, approx);
+
+ lo = L_Extract_lc (L_32, &hi);
+ L_32 = Mpy_32_16 (hi, lo, approx);
+
+ /* L_num * (1/L_denom) */
+
+ lo = L_Extract_lc (L_32, &hi);
+ n_lo = L_Extract_lc (L_num, &n_hi);
+ L_32 = Mpy_32 (n_hi, n_lo, hi, lo);
+ L_32 = L_shl (L_32, 2);
+
+ return (L_32);
+}
+
diff --git a/basic_math/oper_32b.h b/basic_math/oper_32b.h
new file mode 100644
index 0000000000000000000000000000000000000000..70d1c59dbd989669878651ca1654d9311631bfdd
--- /dev/null
+++ b/basic_math/oper_32b.h
@@ -0,0 +1,18 @@
+/* Double precision operations */
+/* $Id: oper_32b.h 1094 2014-02-10 17:12:11Z jdr $ */
+#ifndef _OPER_32b_H
+#define _OPER_32b_H
+
+void L_Extract (Word32 L_32, Word16 *hi, Word16 *lo);
+Word16 L_Extract_lc (Word32 L_32, Word16 *hi);
+Word32 L_Comp (Word16 hi, Word16 lo);
+Word32 Mpy_32 (Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2);
+Word32 Mac_32 (Word32 L_num, Word16 hi1, Word16 lo1, Word16 hi2, Word16 lo2);
+Word32 Sqr_32 (Word16 hi, Word16 lo);
+Word32 Sad_32 (Word32 L_num, Word16 hi, Word16 lo);
+Word32 Mpy_32_16 (Word16 hi, Word16 lo, Word16 n);
+Word32 Mac_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n);
+Word32 Msu_32_16 (Word32 L_num, Word16 hi, Word16 lo, Word16 n);
+Word32 Div_32 (Word32 L_num, Word16 denom_hi, Word16 denom_lo);
+
+#endif
diff --git a/basic_math/rom_basic_math.c b/basic_math/rom_basic_math.c
new file mode 100644
index 0000000000000000000000000000000000000000..8c81378209d0a5f2b20c04eea2460d328b4fb2ce
--- /dev/null
+++ b/basic_math/rom_basic_math.c
@@ -0,0 +1,91 @@
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Decoder static structure */
+#include "stl.h"
+
+/* math_op.c */
+const Word32 L_table_isqrt[48] =
+{
+ 2147418112L, 2083389440L, 2024669184L, 1970667520L,
+ 1920794624L, 1874460672L, 1831403520L, 1791098880L,
+ 1753415680L, 1717960704L, 1684602880L, 1653145600L,
+ 1623326720L, 1595080704L, 1568276480L, 1542782976L,
+ 1518469120L, 1495334912L, 1473183744L, 1451950080L,
+ 1431633920L, 1412169728L, 1393491968L, 1375469568L,
+ 1358168064L, 1341521920L, 1325465600L, 1309933568L,
+ 1294991360L, 1280507904L, 1266548736L, 1252982784L,
+ 1239875584L, 1227161600L, 1214775296L, 1202847744L,
+ 1191182336L, 1179910144L, 1168965632L, 1158283264L,
+ 1147863040L, 1137770496L, 1127940096L, 1118306304L,
+ 1108934656L, 1099825152L, 1090912256L, 1082261504L
+};
+
+/* table of table_isqrt[i] - table_isqrt[i+1] */
+const Word16 table_isqrt_diff[48] =
+{
+ 977, 896, 824, 761, 707, 657, 615, 575,
+ 541, 509, 480, 455, 431, 409, 389, 371,
+ 353, 338, 324, 310, 297, 285, 275, 264,
+ 254, 245, 237, 228, 221, 213, 207, 200,
+ 194, 189, 182, 178, 172, 167, 163, 159,
+ 154, 150, 147, 143, 139, 136, 132, 130
+};
+
+const Word16 shift_Isqrt_lc[] = {9,10};
+
+const Word16 table_pow2[32] =
+{
+ 16384, 16743, 17109, 17484, 17867, 18258, 18658, 19066, 19484, 19911,
+ 20347, 20792, 21247, 21713, 22188, 22674, 23170, 23678, 24196, 24726,
+ 25268, 25821, 26386, 26964, 27554, 28158, 28774, 29405, 30048, 30706,
+ 31379, 32066
+};
+
+/* table of table_pow2[i+1] - table_pow2[i] */
+const Word16 table_pow2_diff_x32[32] =
+{
+ 11488, 11712, 12000, 12256, 12512, 12800, 13056, 13376, 13664, 13952,
+ 14240, 14560, 14912, 15200, 15552, 15872, 16256, 16576, 16960, 17344,
+ 17696, 18080, 18496, 18880, 19328, 19712, 20192, 20576, 21056, 21536,
+ 21984, 22432
+};
+
+const Word16 sqrt_table[49] =
+{
+ 16384, 16888, 17378, 17854, 18318, 18770, 19212,
+ 19644, 20066, 20480, 20886, 21283, 21674, 22058,
+ 22435, 22806, 23170, 23530, 23884, 24232, 24576,
+ 24915, 25249, 25580, 25905, 26227, 26545, 26859,
+ 27170, 27477, 27780, 28081, 28378, 28672, 28963,
+ 29251, 29537, 29819, 30099, 30377, 30652, 30924,
+ 31194, 31462, 31727, 31991, 32252, 32511, 32767
+};
+
+/* log2.c */
+const Word32 L_table_Log2_norm_lc[32] =
+{
+ -32768L, 95322112L, 187793408L, 277577728L,
+ 364871680L, 449740800L, 532381696L, 612859904L,
+ 691306496L, 767787008L, 842432512L, 915308544L,
+ 986546176L, 1056210944L, 1124302848L, 1190887424L,
+ 1256095744L, 1319993344L, 1382580224L, 1443921920L,
+ 1504083968L, 1563131904L, 1621000192L, 1677885440L,
+ 1733722112L, 1788510208L, 1842380800L, 1895399424L,
+ 1947435008L, 1998618624L, 2049015808L, 2098626560L
+};
+
+const Word16 table_diff_Log2_norm_lc[32] =
+{
+ 1455, 1411, 1370, 1332, 1295, 1261, 1228, 1197,
+ 1167, 1139, 1112, 1087, 1063, 1039, 1016, 995,
+ 975, 955, 936, 918, 901, 883, 868, 852,
+ 836, 822, 809, 794, 781, 769, 757, 744
+};
+
+const Word16 log2_tab[33]={
+ 0x7800, 0x782D, 0x785A, 0x7884, 0x78AE, 0x78D6, 0x78FE, 0x7924,
+ 0x794A, 0x796E, 0x7992, 0x79B4, 0x79D6, 0x79F8, 0x7A18, 0x7A38,
+ 0x7A57, 0x7A75, 0x7A93, 0x7AB1, 0x7ACD, 0x7AE9, 0x7B05, 0x7B20,
+ 0x7B3B, 0x7B55, 0x7B6F, 0x7B88, 0x7BA1, 0x7BB9, 0x7BD1, 0x7BE9,
+ 0x7C00
+};
+
diff --git a/basic_math/rom_basic_math.h b/basic_math/rom_basic_math.h
new file mode 100644
index 0000000000000000000000000000000000000000..f39ea84755f3878bcaf317d4d9d9f704dc3dc595
--- /dev/null
+++ b/basic_math/rom_basic_math.h
@@ -0,0 +1,26 @@
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Decoder static structure */
+#include "stl.h"
+
+
+/* math_op.c */
+extern const Word32 L_table_isqrt[48];
+
+/* table of table_isqrt[i] - table_isqrt[i+1] */
+extern const Word16 table_isqrt_diff[48];
+
+extern const Word16 shift_Isqrt_lc[];
+
+extern const Word16 table_pow2[32];
+
+/* table of table_pow2[i+1] - table_pow2[i] */
+extern const Word16 table_pow2_diff_x32[32];
+
+extern const Word16 sqrt_table[49];
+
+/* log2.c */
+extern const Word32 L_table_Log2_norm_lc[32];
+
+extern const Word16 table_diff_Log2_norm_lc[32];
+
+extern const Word16 log2_tab[33];
diff --git a/basic_op/README.md b/basic_op/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..47ff87ced765c8312fd0e96da124070d0bd841d8
--- /dev/null
+++ b/basic_op/README.md
@@ -0,0 +1,101 @@
+
+ Read-me for ITU-T/UGST Basic Operator Module V.2.3
+ (30.Nov.2009)
+
+ =============================================================
+ COPYRIGHT NOTE: This source code, and all of its derivations,
+ is subject to the "ITU-T General Public License". Please have
+ it read in the distribution disk, or in the ITU-T
+ Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO
+ CODING STANDARDS".
+ =============================================================
+
+# Changes v.2.2 --> v.2.3
+
+Modifications in `basop32.c` and `basop32.h`
+- Function `round()` is now named `round_fx()`, to avoid clashes with
+standard C library.
+- Function `saturate()` is made unreferencable from outside application.
+
+Added new functionalities:
+- Basic operator counter utility: `basop_cnt.c`
+- Complexity evaluation tool for floating-point: `flc.h`, `flc.c`
+
+# Changes v.2.1 --> v.2.2
+
+New functions in `count.c`:
+- `void setFrameRate(int samplingFreq, int frameLength);`
+
+ This function can overwrite the value of the frameRate variable
+ that is initialized by the `FRAME_RATE` constant.
+
+- `void WMOPS_output_avg (Word16 dtx_mode, Word32 *tot_wm, Word16 *num_frames);`
+
+ Same as `WMOPS_output` + returns the total wmops counter and the number of frames
+ to support the computation of advanced complexity results as the global average.
+
+An example of the use of `WMOPS_output_avg` is given below:
+
+In a decoder, the `spe1Id` was used for valid frames while the `spe2Id` counter was used for erased frames.
+Using the `WMOPS_output_avg` the global average complexity can be also displayed :
+
+ short spe1Id = getCounterId("Valid frames");
+ short spe2Id = getCounterId("Bad frames");
+ long tot_wm1;
+ short num_frames1;
+ long tot_wm2;
+ short num_frames2;
+
+ ...
+
+ setCounter(spe1Id);
+ fwc();
+ WMOPS_output_avg(0, &tot_wm1, &num_frames1);
+ setCounter(spe2Id);
+ fwc();
+ WMOPS_output_avg(0, &tot_wm2, &num_frames2);
+ printf("Global average %f WMOPS\n", (tot_wm1 + tot_wm2)/(float)(num_frames1 + num_frames2));
+
+ Modifications in count.c:
+ - L_mls() is weighted 5.
+ - div_l() is weighted 32.
+ - i_mult() is weighted 3.
+
+# Changes v.2.0 --> v.2.1
+
+Improved portability:
+- in header files `__inline` was changed to `static __inline`
+- `//` style comments were changed to `/* */`
+- Cygwin added in the supported compiler list (`typedef.h`)
+- Word40 definition was added for Sun and Unix (`typedef.h`)
+
+Corrections:
+- missing incrementations were added for `s_and`, `s_or` and `s_xor` (`enh1632.h`)
+
+# Original version: v.2.0
+
+The ITU-T/UGST Basic Operator module contains the following files:
+
+## C code: (`model` directory)
+
+ basop32.c: ....... 16/32 bit basic operators
+ basop32.h: ....... Prototypes for basop32.c
+ count.c: ......... Functions for WMOPS computation
+ count.h: ......... Prototypes for count.c
+ typedef.h: ....... Data type definitions
+ typedefs.h: ...... New data type definitions
+ move.h: .......... Move & miscellaneous legacy operators
+ control.c: ....... Control operator internal variable decl.
+ control.h: ....... Control operators
+ enh1632.c: ....... Enhanced 16/32 bit basic operators
+ enh1632.h: ....... Prototypes for enh1632.c
+ enh40.c: ......... 40 bit basic operators
+ enh40.h: ......... Prototypes for enh40.c
+ patch.h: ......... Backward compatibility for operator names
+ stl.h: ........... Main header file
+
+## Demos:
+
+Demo programs are not available for this module.
+
+--
diff --git a/basic_op/basop.rme b/basic_op/basop.rme
new file mode 100644
index 0000000000000000000000000000000000000000..361ebc40393e28697f5c385c722ca1b2fb36f9ce
--- /dev/null
+++ b/basic_op/basop.rme
@@ -0,0 +1,120 @@
+
+ Read-me for ITU-T/UGST Basic Operator Module V.2.3
+ (30.Nov.2009)
+
+ =============================================================
+ COPYRIGHT NOTE: This source code, and all of its derivations,
+ is subject to the "ITU-T General Public License". Please have
+ it read in the distribution disk, or in the ITU-T
+ Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO
+ CODING STANDARDS".
+ =============================================================
+
+Changes v.2.2 --> v.2.3
+***********************
+
+Modifications in basop32.c and basop32.h
+ - Function round() is now named round_fx(), to avoid clashes with
+ standard C library.
+ - Function saturate() is made unreferencable from outside application.
+
+Added new functionalities:
+ - Basic operator counter utility: basop_cnt.c
+ - Complexity evaluation tool for floating-point: flc.h, flc.c
+
+Changes v.2.1 --> v.2.2
+***********************
+
+New functions in count.c:
+ - void setFrameRate(int samplingFreq, int frameLength);
+ This function can overwrite the value of the frameRate variable
+ that is initialized by the FRAME_RATE constant.
+ - void WMOPS_output_avg (Word16 dtx_mode, Word32 *tot_wm, Word16 *num_frames);
+ same as WMOPS_output + returns the total wmops counter and the number of frames
+ to support the computation of advanced complexity results as the global average.
+
+An example of the use of WMOPS_output_avg is given below:
+
+In a decoder, the spe1Id was used for valid frames while the spe2Id counter was used for erased frames.
+Using the WMOPS_output_avg the global average complexity can be also displayed :
+
+short spe1Id = getCounterId("Valid frames");
+short spe2Id = getCounterId("Bad frames");
+long tot_wm1;
+short num_frames1;
+long tot_wm2;
+short num_frames2;
+
+...
+
+setCounter(spe1Id);
+fwc();
+WMOPS_output_avg(0, &tot_wm1, &num_frames1);
+setCounter(spe2Id);
+fwc();
+WMOPS_output_avg(0, &tot_wm2, &num_frames2);
+printf("Global average %f WMOPS\n", (tot_wm1 + tot_wm2)/(float)(num_frames1 + num_frames2));
+
+Modifications in count.c:
+ - L_mls() is weighted 5.
+ - div_l() is weighted 32.
+ - i_mult() is weighted 3.
+
+Changes v.2.0 --> v.2.1
+***********************
+
+Improved portability:
+ - in header files "__inline" was changed to "static __inline"
+ - // style comments were changed to /* */
+ - Cygwin added in the supported compiler list (typedef.h)
+ - Word40 definition was added for Sun and Unix (typedef.h)
+Corrections:
+ - missing incrementations were added for s_and, s_or and s_xor (enh1632.h)
+
+
+
+Original version: v.2.0
+***********************
+
+The ITU-T/UGST Basic Operator module contails the following files:
+
+General:
+~~~~~~~~
+ basop.rme: ....... Read-me file for Basic Operator module (this file)
+
+C code: ('model' directory)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ basop32.c: ....... 16/32 bit basic operators
+ basop32.h: ....... Prototypes for basop32.c
+ count.c: ......... Functions for WMOPS computation
+ count.h: ......... Prototypes for count.c
+ typedef.h: ....... Data type definitions
+ typedefs.h: ...... New data type definitions
+ move.h: .......... Move & miscellaneous legacy operators
+ control.c: ....... Control operator internal variable decl.
+ control.h: ....... Control operators
+ enh1632.c: ....... Enhanced 16/32 bit basic operators
+ enh1632.h: ....... Prototypes for enh1632.c
+ enh40.c: ......... 40 bit basic operators
+ enh40.h: ......... Prototypes for enh40.c
+ patch.h: ......... Backward compatibility for operator names
+ stl.h: ........... Main header file
+ enh64.c: ......... 64 bit basic operators
+ enh64.h: ......... Prototypes for enh64.c
+ enh32.c: ......... Extension to enhanced 32 bit operators
+ enh32.h: ......... Prototypes for enh32.c
+ complex_basop.c: ... 32/16 complex basic operators
+ complex_basop.h: ... Prototypes for complex_basop.c
+
+Demos:
+~~~~~~
+Demo programs are not available for this module.
+
+
+Makefiles
+~~~~~~~~~
+Make files are not available for this module.
+
+
+--
+
diff --git a/basic_op/basop32.c b/basic_op/basop32.c
new file mode 100644
index 0000000000000000000000000000000000000000..b83cd21ab78eaee7c66e6c884b6d3b2deeb79cf5
--- /dev/null
+++ b/basic_op/basop32.c
@@ -0,0 +1,2429 @@
+/* v.2.3 - 30.Nov.2009
+ =============================================================================
+
+ U U GGG SSSS TTTTT
+ U U G S T
+ U U G GG SSSS T
+ U U G G S T
+ UUU GG SSS T
+
+ ========================================
+ ITU-T - USER'S GROUP ON SOFTWARE TOOLS
+ ========================================
+
+ =============================================================
+ COPYRIGHT NOTE: This source code, and all of its derivations,
+ is subject to the "ITU-T General Public License". Please have
+ it read in the distribution disk, or in the ITU-T
+ Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND AUDIO
+ CODING STANDARDS".
+ =============================================================
+
+MODULE: BASOP32, BASIC OPERATORS
+
+ORIGINAL BY:
+ Incorporated from anonymous contributions for
+ ETSI Standards as well as G.723.1, G.729, and G.722.1
+
+DESCRIPTION:
+ This file contains the definition of 16- and 32-bit basic
+ operators to be used in the implementation of signal
+ processing algorithms. The basic operators try to resemble
+ assembly language instructions that are commonly found in
+ digital signal processor (DSP) CPUs, thus allowing algorithm
+ C-code implementations more directly mapeable to DSP assembly
+ code.
+
+ *********************************************************
+ NOTE: so far, this module does not have a demo program!
+ *********************************************************
+
+FUNCTIONS:
+ Defined in basop32.h. Self-documentation within each function.
+
+HISTORY:
+ 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729
+ basic operator library (based on basicop2.c) and
+ G.723.1's basop.c [L_mls(), div_l(), i_mult()]
+
+ 05.Jul.00 v1.1 Added 32-bit shiftless accumulation basic
+ operators (L_msu0, L_mac0, L_mult0). Improved
+ documentation for i_mult().
+
+ 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ norm_s() weight reduced from 15 to 1.
+ norm_l() weight reduced from 30 to 1.
+ L_abs() weight reduced from 2 to 1.
+ L_add() weight reduced from 2 to 1.
+ L_negate() weight reduced from 2 to 1.
+ L_shl() weight reduced from 2 to 1.
+ L_shr() weight reduced from 2 to 1.
+ L_sub() weight reduced from 2 to 1.
+ mac_r() weight reduced from 2 to 1.
+ msu_r() weight reduced from 2 to 1.
+ mult_r() weight reduced from 2 to 1.
+ L_deposit_h() weight reduced from 2 to 1.
+ L_deposit_l() weight reduced from 2 to 1.
+ L_mls() weight of 5.
+ div_l() weight of 32.
+ i_mult() weight of 3.
+
+ 30 Nov 09 v2.3 round() function is now round_fx().
+ saturate() is not referencable from outside application
+ =============================================================================
+*/
+
+
+/*___________________________________________________________________________
+ | |
+ | Basic arithmetic operators. |
+ | |
+ | $Id $ |
+ | |
+ | saturate() |
+ | add() |
+ | sub() |
+ | abs_s() |
+ | divide_s() |
+ | extract_h() |
+ | extract_l() |
+ | L_abs() |
+ | L_add() |
+ | L_deposit_h() |
+ | L_deposit_l() |
+ | L_mac() |
+ | L_msu() |
+ | L_mult() |
+ | L_negate() |
+ | L_shl() |
+ | L_shr() |
+ | L_sub() |
+ | mac_r() |
+ | msu_r() |
+ | mult() |
+ | mult_r() |
+ | negate() |
+ | norm_l() |
+ | norm_s() |
+ | round_fx() |
+ | shl() |
+ | shr() |
+ |___________________________________________________________________________|
+*/
+
+
+/*___________________________________________________________________________
+ | |
+ | Include-Files |
+ |___________________________________________________________________________|
+*/
+#include
+#include
+#include "stl.h"
+
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif
+
+
+/*___________________________________________________________________________
+ | |
+ | Local Functions |
+ |___________________________________________________________________________|
+*/
+static Word16 saturate (Word32 L_var1);
+
+
+/*___________________________________________________________________________
+ | |
+ | Constants and Globals |
+ |___________________________________________________________________________|
+*/
+Flag Overflow = 0;
+Flag Carry = 0;
+
+
+/*___________________________________________________________________________
+ | |
+ | Functions |
+ |___________________________________________________________________________|
+*/
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : saturate |
+ | |
+ | Purpose : |
+ | |
+ | Limit the 32 bit input to the range of a 16 bit word. Must NOT be |
+ | referenced from outside applications. |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+static Word16 saturate (Word32 L_var1) {
+ Word16 var_out;
+
+ if (L_var1 > 0X00007fffL) {
+ Overflow = 1;
+ var_out = MAX_16;
+ } else if (L_var1 < (Word32) 0xffff8000L) {
+ Overflow = 1;
+ var_out = MIN_16;
+ } else {
+ var_out = extract_l (L_var1);
+#if (WMOPS)
+ multiCounter[currCounter].extract_l--;
+#endif
+ }
+
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : add |
+ | |
+ | Purpose : |
+ | |
+ | Performs the addition (var1+var2) with overflow control and saturation;|
+ | the 16 bit result is set at +32767 when overflow occurs or at -32768 |
+ | when underflow occurs. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 add (Word16 var1, Word16 var2) {
+ Word16 var_out;
+ Word32 L_sum;
+
+ L_sum = (Word32) var1 + var2;
+ var_out = saturate (L_sum);
+
+#if (WMOPS)
+ multiCounter[currCounter].add++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : sub |
+ | |
+ | Purpose : |
+ | |
+ | Performs the subtraction (var1+var2) with overflow control and satu- |
+ | ration; the 16 bit result is set at +32767 when overflow occurs or at |
+ | -32768 when underflow occurs. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 sub (Word16 var1, Word16 var2) {
+ Word16 var_out;
+ Word32 L_diff;
+
+ L_diff = (Word32) var1 - var2;
+ var_out = saturate (L_diff);
+
+#if (WMOPS)
+ multiCounter[currCounter].sub++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : abs_s |
+ | |
+ | Purpose : |
+ | |
+ | Absolute value of var1; abs_s(-32768) = 32767. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 abs_s (Word16 var1) {
+ Word16 var_out;
+
+ if (var1 == (Word16) MIN_16) {
+ var_out = MAX_16;
+ } else {
+ if (var1 < 0) {
+ var_out = -var1;
+ } else {
+ var_out = var1;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].abs_s++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : shl |
+ | |
+ | Purpose : |
+ | |
+ | Arithmetically shift the 16 bit input var1 left var2 positions.Zero fill|
+ | the var2 LSB of the result. If var2 is negative, arithmetically shift |
+ | var1 right by -var2 with sign extension. Saturate the result in case of |
+ | underflows or overflows. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 shl (Word16 var1, Word16 var2) {
+ Word16 var_out;
+ Word32 result;
+
+ if (var2 < 0) {
+ if (var2 < -16)
+ var2 = -16;
+ var2 = -var2;
+ var_out = shr (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].shr--;
+#endif
+ } else {
+ result = (Word32) var1 *((Word32) 1 << var2);
+
+ if ((var2 > 15 && var1 != 0) || (result != (Word32) ((Word16) result))) {
+ Overflow = 1;
+ var_out = (var1 > 0) ? MAX_16 : MIN_16;
+ } else {
+ var_out = extract_l (result);
+
+#if (WMOPS)
+ multiCounter[currCounter].extract_l--;
+#endif
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].shl++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : shr |
+ | |
+ | Purpose : |
+ | |
+ | Arithmetically shift the 16 bit input var1 right var2 positions with |
+ | sign extension. If var2 is negative, arithmetically shift var1 left by |
+ | -var2 with sign extension. Saturate the result in case of underflows or |
+ | overflows. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 shr (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ if (var2 < 0) {
+ if (var2 < -16)
+ var2 = -16;
+ var2 = -var2;
+ var_out = shl (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].shl--;
+#endif
+ } else {
+ if (var2 >= 15) {
+ var_out = (var1 < 0) ? -1 : 0;
+ } else {
+ if (var1 < 0) {
+ var_out = ~((~var1) >> var2);
+ } else {
+ var_out = var1 >> var2;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].shr++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : mult |
+ | |
+ | Purpose : |
+ | |
+ | Performs the multiplication of var1 by var2 and gives a 16 bit result |
+ | which is scaled i.e.: |
+ | mult(var1,var2) = extract_l(L_shr((var1 times var2),15)) and |
+ | mult(-32768,-32768) = 32767. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 mult (Word16 var1, Word16 var2) {
+ Word16 var_out;
+ Word32 L_product;
+
+ L_product = (Word32) var1 *(Word32) var2;
+
+ L_product = (L_product & (Word32) 0xffff8000L) >> 15;
+
+ if (L_product & (Word32) 0x00010000L)
+ L_product = L_product | (Word32) 0xffff0000L;
+
+ var_out = saturate (L_product);
+
+#if (WMOPS)
+ multiCounter[currCounter].mult++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_mult |
+ | |
+ | Purpose : |
+ | |
+ | L_mult is the 32 bit result of the multiplication of var1 times var2 |
+ | with one shift left i.e.: |
+ | L_mult(var1,var2) = L_shl((var1 times var2),1) and |
+ | L_mult(-32768,-32768) = 2147483647. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_mult (Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = (Word32) var1 *(Word32) var2;
+
+ if (L_var_out != (Word32) 0x40000000L) {
+ L_var_out *= 2;
+ } else {
+ Overflow = 1;
+ L_var_out = MAX_32;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mult++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : negate |
+ | |
+ | Purpose : |
+ | |
+ | Negate var1 with saturation, saturate in the case where input is -32768:|
+ | negate(var1) = sub(0,var1). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 negate (Word16 var1) {
+ Word16 var_out;
+
+ var_out = (var1 == MIN_16) ? MAX_16 : -var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].negate++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : extract_h |
+ | |
+ | Purpose : |
+ | |
+ | Return the 16 MSB of L_var1. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32 ) whose value falls in the |
+ | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 extract_h (Word32 L_var1) {
+ Word16 var_out;
+
+ var_out = (Word16) (L_var1 >> 16);
+
+#if (WMOPS)
+ multiCounter[currCounter].extract_h++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : extract_l |
+ | |
+ | Purpose : |
+ | |
+ | Return the 16 LSB of L_var1. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32 ) whose value falls in the |
+ | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 extract_l (Word32 L_var1) {
+ Word16 var_out;
+
+ var_out = (Word16) L_var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].extract_l++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : round_fx |
+ | |
+ | Purpose : |
+ | |
+ | Round the lower 16 bits of the 32 bit input number into the MS 16 bits |
+ | with saturation. Shift the resulting bits right by 16 and return the 16 |
+ | bit number: |
+ | round_fx(L_var1) = extract_h(L_add(L_var1,32768)) |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32 ) whose value falls in the |
+ | range : 0x8000 0000 <= L_var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 round_fx (Word32 L_var1) {
+ Word16 var_out;
+ Word32 L_rounded;
+
+ L_rounded = L_add (L_var1, (Word32) 0x00008000L);
+ var_out = extract_h (L_rounded);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].round++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_mac |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit |
+ | result to L_var3 with saturation, return a 32 bit result: |
+ | L_mac(L_var3,var1,var2) = L_add(L_var3,L_mult(var1,var2)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+ Word32 L_product;
+
+ L_product = L_mult (var1, var2);
+ L_var_out = L_add (L_var3, L_product);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mult--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].L_mac++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_msu |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 |
+ | bit result from L_var3 with saturation, return a 32 bit result: |
+ | L_msu(L_var3,var1,var2) = L_sub(L_var3,L_mult(var1,var2)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+ Word32 L_product;
+
+ L_product = L_mult (var1, var2);
+ L_var_out = L_sub (L_var3, L_product);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mult--;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].L_msu++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_macNs |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit |
+ | result to L_var3 without saturation, return a 32 bit result. Generate |
+ | carry and overflow values : |
+ | L_macNs(L_var3,var1,var2) = L_add_c(L_var3,L_mult(var1,var2)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ | |
+ | Caution : |
+ | |
+ | In some cases the Carry flag has to be cleared or set before using |
+ | operators which take into account its value. |
+ |___________________________________________________________________________|
+*/
+Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = L_mult (var1, var2);
+ L_var_out = L_add_c (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mult--;
+ multiCounter[currCounter].L_add_c--;
+ multiCounter[currCounter].L_macNs++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_msuNs |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 |
+ | bit result from L_var3 without saturation, return a 32 bit result. Ge- |
+ | nerate carry and overflow values : |
+ | L_msuNs(L_var3,var1,var2) = L_sub_c(L_var3,L_mult(var1,var2)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ | |
+ | Caution : |
+ | |
+ | In some cases the Carry flag has to be cleared or set before using |
+ | operators which take into account its value. |
+ |___________________________________________________________________________|
+*/
+Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = L_mult (var1, var2);
+ L_var_out = L_sub_c (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mult--;
+ multiCounter[currCounter].L_sub_c--;
+ multiCounter[currCounter].L_msuNs++;
+
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_add |
+ | |
+ | Purpose : |
+ | |
+ | 32 bits addition of the two 32 bits variables (L_var1+L_var2) with |
+ | overflow control and saturation; the result is set at +2147483647 when |
+ | overflow occurs or at -2147483648 when underflow occurs. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | L_var2 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_add (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = L_var1 + L_var2;
+
+ if (((L_var1 ^ L_var2) & MIN_32) == 0) {
+ if ((L_var_out ^ L_var1) & MIN_32) {
+ L_var_out = (L_var1 < 0) ? MIN_32 : MAX_32;
+ Overflow = 1;
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_add++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_sub |
+ | |
+ | Purpose : |
+ | |
+ | 32 bits subtraction of the two 32 bits variables (L_var1-L_var2) with |
+ | overflow control and saturation; the result is set at +2147483647 when |
+ | overflow occurs or at -2147483648 when underflow occurs. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | L_var2 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_sub (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = L_var1 - L_var2;
+
+ if (((L_var1 ^ L_var2) & MIN_32) != 0) {
+ if ((L_var_out ^ L_var1) & MIN_32) {
+ L_var_out = (L_var1 < 0L) ? MIN_32 : MAX_32;
+ Overflow = 1;
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_sub++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_add_c |
+ | |
+ | Purpose : |
+ | |
+ | Performs 32 bits addition of the two 32 bits variables (L_var1+L_var2+C)|
+ | with carry. No saturation. Generate carry and Overflow values. The car- |
+ | ry and overflow values are binary variables which can be tested and as- |
+ | signed values. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | L_var2 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ | |
+ | Caution : |
+ | |
+ | In some cases the Carry flag has to be cleared or set before using |
+ | operators which take into account its value. |
+ |___________________________________________________________________________|
+*/
+Word32 L_add_c (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+ Word32 L_test;
+ Flag carry_int = 0;
+
+ L_var_out = L_var1 + L_var2 + Carry;
+
+ L_test = L_var1 + L_var2;
+
+ if ((L_var1 > 0) && (L_var2 > 0) && (L_test < 0)) {
+ Overflow = 1;
+ carry_int = 0;
+ } else {
+ if ((L_var1 < 0) && (L_var2 < 0)) {
+ if (L_test >= 0) {
+ Overflow = 1;
+ carry_int = 1;
+ } else {
+ Overflow = 0;
+ carry_int = 1;
+ }
+ } else {
+ if (((L_var1 ^ L_var2) < 0) && (L_test >= 0)) {
+ Overflow = 0;
+ carry_int = 1;
+ } else {
+ Overflow = 0;
+ carry_int = 0;
+ }
+ }
+ }
+
+ if (Carry) {
+ if (L_test == MAX_32) {
+ Overflow = 1;
+ Carry = carry_int;
+ } else {
+ if (L_test == (Word32) 0xFFFFFFFFL) {
+ Carry = 1;
+ } else {
+ Carry = carry_int;
+ }
+ }
+ } else {
+ Carry = carry_int;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L_add_c++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_sub_c |
+ | |
+ | Purpose : |
+ | |
+ | Performs 32 bits subtraction of the two 32 bits variables with carry |
+ | (borrow) : L_var1-L_var2-C. No saturation. Generate carry and Overflow |
+ | values. The carry and overflow values are binary variables which can |
+ | be tested and assigned values. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | L_var2 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ | |
+ | Caution : |
+ | |
+ | In some cases the Carry flag has to be cleared or set before using |
+ | operators which take into account its value. |
+ |___________________________________________________________________________|
+*/
+Word32 L_sub_c (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+ Word32 L_test;
+ Flag carry_int = 0;
+
+ if (Carry) {
+ Carry = 0;
+ if (L_var2 != MIN_32) {
+ L_var_out = L_add_c (L_var1, -L_var2);
+#if (WMOPS)
+ multiCounter[currCounter].L_add_c--;
+#endif
+ } else {
+ L_var_out = L_var1 - L_var2;
+ if (L_var1 > 0L) {
+ Overflow = 1;
+ Carry = 0;
+ }
+ }
+ } else {
+ L_var_out = L_var1 - L_var2 - (Word32) 0X00000001L;
+ L_test = L_var1 - L_var2;
+
+ if ((L_test < 0) && (L_var1 > 0) && (L_var2 < 0)) {
+ Overflow = 1;
+ carry_int = 0;
+ } else if ((L_test > 0) && (L_var1 < 0) && (L_var2 > 0)) {
+ Overflow = 1;
+ carry_int = 1;
+ } else if ((L_test > 0) && ((L_var1 ^ L_var2) > 0)) {
+ Overflow = 0;
+ carry_int = 1;
+ }
+ if (L_test == MIN_32) {
+ Overflow = 1;
+ Carry = carry_int;
+ } else {
+ Carry = carry_int;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L_sub_c++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_negate |
+ | |
+ | Purpose : |
+ | |
+ | Negate the 32 bit variable L_var1 with saturation; saturate in the case |
+ | where input is -2147483648 (0x8000 0000). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_negate (Word32 L_var1) {
+ Word32 L_var_out;
+
+ L_var_out = (L_var1 == MIN_32) ? MAX_32 : -L_var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_negate++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : mult_r |
+ | |
+ | Purpose : |
+ | |
+ | Same as mult with rounding, i.e.: |
+ | mult_r(var1,var2) = extract_l(L_shr(((var1 * var2) + 16384),15)) and |
+ | mult_r(-32768,-32768) = 32767. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x8000 <= var_out <= 0x7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 mult_r (Word16 var1, Word16 var2) {
+ Word16 var_out;
+ Word32 L_product_arr;
+
+ L_product_arr = (Word32) var1 *(Word32) var2; /* product */
+ L_product_arr += (Word32) 0x00004000L; /* round */
+ L_product_arr &= (Word32) 0xffff8000L;
+ L_product_arr >>= 15; /* shift */
+
+ if (L_product_arr & (Word32) 0x00010000L) { /* sign extend when necessary */
+ L_product_arr |= (Word32) 0xffff0000L;
+ }
+ var_out = saturate (L_product_arr);
+
+#if (WMOPS)
+ multiCounter[currCounter].mult_r++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_shl |
+ | |
+ | Purpose : |
+ | |
+ | Arithmetically shift the 32 bit input L_var1 left var2 positions. Zero |
+ | fill the var2 LSB of the result. If var2 is negative, arithmetically |
+ | shift L_var1 right by -var2 with sign extension. Saturate the result in |
+ | case of underflows or overflows. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_shl (Word32 L_var1, Word16 var2) {
+
+ Word32 L_var_out = 0L;
+
+ if (var2 <= 0) {
+ if (var2 < -32)
+ var2 = -32;
+ var2 = -var2;
+ L_var_out = L_shr (L_var1, var2);
+#if (WMOPS)
+ multiCounter[currCounter].L_shr--;
+#endif
+ } else {
+ for (; var2 > 0; var2--) {
+ if (L_var1 > (Word32) 0X3fffffffL) {
+ Overflow = 1;
+ L_var_out = MAX_32;
+ break;
+ } else {
+ if (L_var1 < (Word32) 0xc0000000L) {
+ Overflow = 1;
+ L_var_out = MIN_32;
+ break;
+ }
+ }
+ L_var1 *= 2;
+ L_var_out = L_var1;
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_shl++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_shr |
+ | |
+ | Purpose : |
+ | |
+ | Arithmetically shift the 32 bit input L_var1 right var2 positions with |
+ | sign extension. If var2 is negative, arithmetically shift L_var1 left |
+ | by -var2 and zero fill the -var2 LSB of the result. Saturate the result |
+ | in case of underflows or overflows. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_shr (Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ if (var2 < 0) {
+ if (var2 < -32)
+ var2 = -32;
+ var2 = -var2;
+ L_var_out = L_shl (L_var1, var2);
+#if (WMOPS)
+ multiCounter[currCounter].L_shl--;
+#endif
+ } else {
+ if (var2 >= 31) {
+ L_var_out = (L_var1 < 0L) ? -1 : 0;
+ } else {
+ if (L_var1 < 0) {
+ L_var_out = ~((~L_var1) >> var2);
+ } else {
+ L_var_out = L_var1 >> var2;
+ }
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_shr++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : shr_r |
+ | |
+ | Purpose : |
+ | |
+ | Same as shr(var1,var2) but with rounding. Saturate the result in case of|
+ | underflows or overflows : |
+ | - If var2 is greater than zero : |
+ | if (sub(shl(shr(var1,var2),1),shr(var1,sub(var2,1)))) |
+ | is equal to zero |
+ | then |
+ | shr_r(var1,var2) = shr(var1,var2) |
+ | else |
+ | shr_r(var1,var2) = add(shr(var1,var2),1) |
+ | - If var2 is less than or equal to zero : |
+ | shr_r(var1,var2) = shr(var1,var2). |
+ | |
+ | Complexity weight : 3 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 shr_r (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ if (var2 > 15) {
+ var_out = 0;
+ } else {
+ var_out = shr (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].shr--;
+#endif
+
+ if (var2 > 0) {
+ if ((var1 & ((Word16) 1 << (var2 - 1))) != 0) {
+ var_out++;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].shr_r++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : mac_r |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Add the 32 bit |
+ | result to L_var3 with saturation. Round the LS 16 bits of the result |
+ | into the MS 16 bits with saturation and shift the result right by 16. |
+ | Return a 16 bit result. |
+ | mac_r(L_var3,var1,var2) = round_fx(L_mac(L_var3,var1,var2)) |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ L_var3 = L_mac (L_var3, var1, var2);
+ L_var3 = L_add (L_var3, (Word32) 0x00008000L);
+ var_out = extract_h (L_var3);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mac--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].mac_r++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : msu_r |
+ | |
+ | Purpose : |
+ | |
+ | Multiply var1 by var2 and shift the result left by 1. Subtract the 32 |
+ | bit result from L_var3 with saturation. Round the LS 16 bits of the res-|
+ | ult into the MS 16 bits with saturation and shift the result right by |
+ | 16. Return a 16 bit result. |
+ | msu_r(L_var3,var1,var2) = round_fx(L_msu(L_var3,var1,var2)) |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff. |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 8000 <= L_var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ L_var3 = L_msu (L_var3, var1, var2);
+ L_var3 = L_add (L_var3, (Word32) 0x00008000L);
+ var_out = extract_h (L_var3);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_msu--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].msu_r++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_deposit_h |
+ | |
+ | Purpose : |
+ | |
+ | Deposit the 16 bit var1 into the 16 MS bits of the 32 bit output. The |
+ | 16 LS bits of the output are zeroed. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var_out <= 0x7fff 0000. |
+ |___________________________________________________________________________|
+*/
+Word32 L_deposit_h (Word16 var1) {
+ Word32 L_var_out;
+
+ L_var_out = (Word32) var1 << 16;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_deposit_h++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_deposit_l |
+ | |
+ | Purpose : |
+ | |
+ | Deposit the 16 bit var1 into the 16 LS bits of the 32 bit output. The |
+ | 16 MS bits of the output are sign extended. |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0xFFFF 8000 <= var_out <= 0x0000 7fff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_deposit_l (Word16 var1) {
+ Word32 L_var_out;
+
+ L_var_out = (Word32) var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_deposit_l++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_shr_r |
+ | |
+ | Purpose : |
+ | |
+ | Same as L_shr(L_var1,var2) but with rounding. Saturate the result in |
+ | case of underflows or overflows : |
+ | - If var2 is greater than zero : |
+ | if (L_sub(L_shl(L_shr(L_var1,var2),1),L_shr(L_var1,sub(var2,1))))|
+ | is equal to zero |
+ | then |
+ | L_shr_r(L_var1,var2) = L_shr(L_var1,var2) |
+ | else |
+ | L_shr_r(L_var1,var2) = L_add(L_shr(L_var1,var2),1) |
+ | - If var2 is less than or equal to zero : |
+ | L_shr_r(L_var1,var2) = L_shr(L_var1,var2). |
+ | |
+ | Complexity weight : 3 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var1 <= 0x7fff ffff. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_shr_r (Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ if (var2 > 31) {
+ L_var_out = 0;
+ } else {
+ L_var_out = L_shr (L_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_shr--;
+#endif
+ if (var2 > 0) {
+ if ((L_var1 & ((Word32) 1 << (var2 - 1))) != 0) {
+ L_var_out++;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L_shr_r++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_abs |
+ | |
+ | Purpose : |
+ | |
+ | Absolute value of L_var1; Saturate in case where the input is |
+ | -214783648 |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_abs (Word32 L_var1) {
+ Word32 L_var_out;
+
+ if (L_var1 == MIN_32) {
+ L_var_out = MAX_32;
+ } else {
+ if (L_var1 < 0) {
+ L_var_out = -L_var1;
+ } else {
+ L_var_out = L_var1;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L_abs++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_sat |
+ | |
+ | Purpose : |
+ | |
+ | 32 bit L_var1 is set to 2147483647 if an overflow occured or to |
+ | -2147483648 if an underflow occured on the most recent L_add_c, |
+ | L_sub_c, L_macNs or L_msuNs operations. The carry and overflow values |
+ | are binary values which can be tested and assigned values. |
+ | |
+ | Complexity weight : 4 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L_var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var_out <= 0x7fff ffff. |
+ |___________________________________________________________________________|
+*/
+Word32 L_sat (Word32 L_var1) {
+ Word32 L_var_out;
+
+ L_var_out = L_var1;
+
+ if (Overflow) {
+
+ if (Carry) {
+ L_var_out = MIN_32;
+ } else {
+ L_var_out = MAX_32;
+ }
+
+ Carry = 0;
+ Overflow = 0;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_sat++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : norm_s |
+ | |
+ | Purpose : |
+ | |
+ | Produces the number of left shift needed to normalize the 16 bit varia- |
+ | ble var1 for positive values on the interval with minimum of 16384 and |
+ | maximum of 32767, and for negative values on the interval with minimum |
+ | of -32768 and maximum of -16384; in order to normalize the result, the |
+ | following operation must be done : |
+ | norm_var1 = shl(var1,norm_s(var1)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x0000 000f. |
+ |___________________________________________________________________________|
+*/
+Word16 norm_s (Word16 var1) {
+ Word16 var_out;
+
+ if (var1 == 0) {
+ var_out = 0;
+ } else {
+ if (var1 == (Word16) 0xffff) {
+ var_out = 15;
+ } else {
+ if (var1 < 0) {
+ var1 = ~var1;
+ }
+ for (var_out = 0; var1 < 0x4000; var_out++) {
+ var1 <<= 1;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].norm_s++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : div_s |
+ | |
+ | Purpose : |
+ | |
+ | Produces a result which is the fractional integer division of var1 by |
+ | var2; var1 and var2 must be positive and var2 must be greater or equal |
+ | to var1; the result is positive (leading bit equal to 0) and truncated |
+ | to 16 bits. |
+ | If var1 = var2 then div(var1,var2) = 32767. |
+ | |
+ | Complexity weight : 18 |
+ | |
+ | Inputs : |
+ | |
+ | var1 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var1 <= var2 and var2 != 0. |
+ | |
+ | var2 |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : var1 <= var2 <= 0x0000 7fff and var2 != 0. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x0000 7fff. |
+ | It's a Q15 value (point between b15 and b14). |
+ |___________________________________________________________________________|
+*/
+Word16 div_s (Word16 var1, Word16 var2) {
+ Word16 var_out = 0;
+ Word16 iteration;
+ Word32 L_num;
+ Word32 L_denom;
+
+ if ((var1 > var2) || (var1 < 0) || (var2 < 0)) {
+ printf ("Division Error var1=%d var2=%d\n", var1, var2);
+ abort (); /* exit (0); */
+ }
+ if (var2 == 0) {
+ printf ("Division by 0, Fatal error \n");
+ abort (); /* exit (0); */
+ }
+ if (var1 == 0) {
+ var_out = 0;
+ } else {
+ if (var1 == var2) {
+ var_out = MAX_16;
+ } else {
+ L_num = L_deposit_l (var1);
+ L_denom = L_deposit_l (var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_deposit_l--;
+ multiCounter[currCounter].L_deposit_l--;
+#endif
+
+ for (iteration = 0; iteration < 15; iteration++) {
+ var_out <<= 1;
+ L_num <<= 1;
+
+ if (L_num >= L_denom) {
+ L_num = L_sub (L_num, L_denom);
+ var_out = add (var_out, 1);
+#if (WMOPS)
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].add--;
+#endif
+ }
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].div_s++;
+#endif
+ return (var_out);
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : norm_l |
+ | |
+ | Purpose : |
+ | |
+ | Produces the number of left shifts needed to normalize the 32 bit varia-|
+ | ble L_var1 for positive values on the interval with minimum of |
+ | 1073741824 and maximum of 2147483647, and for negative values on the in-|
+ | terval with minimum of -2147483648 and maximum of -1073741824; in order |
+ | to normalize the result, the following operation must be done : |
+ | norm_L_var1 = L_shl(L_var1,norm_l(L_var1)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L_var1 |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var1 <= 0x7fff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x0000 001f. |
+ |___________________________________________________________________________|
+*/
+Word16 norm_l (Word32 L_var1) {
+ Word16 var_out;
+
+ if (L_var1 == 0) {
+ var_out = 0;
+ } else {
+ if (L_var1 == (Word32) 0xffffffffL) {
+ var_out = 31;
+ } else {
+ if (L_var1 < 0) {
+ L_var1 = ~L_var1;
+ }
+ for (var_out = 0; L_var1 < (Word32) 0x40000000L; var_out++) {
+ L_var1 <<= 1;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].norm_l++;
+#endif
+ return (var_out);
+}
+
+/*
+ ******************************************************************************
+ * Additional operators extracted from the G.723.1 Library
+ * Adapted for WMOPS calculations
+ ******************************************************************************
+*/
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : L_mls |
+ | |
+ | Purpose : |
+ | |
+ | Multiplies a 16 bit word v by a 32 bit word Lv and returns a 32 bit |
+ | word (multiplying 16 by 32 bit words gives 48 bit word; the function |
+ | extracts the 32 MSB and shift the result to the left by 1). |
+ | |
+ | A 32 bit word can be written as |
+ | Lv = a + b * 2^16 |
+ | where a= unsigned 16 LSBs and b= signed 16 MSBs. |
+ | The function returns v * Lv / 2^15 which is equivalent to |
+ | a*v / 2^15 + b*v*2 |
+ | |
+ | Complexity weight : 5 |
+ | |
+ | Inputs : |
+ | |
+ | Lv |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var1 <= 0x7fff ffff. |
+ | v |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x8000 <= var1 <= 0x7fff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 32 bit long signed integer (Word32) whose value falls in the |
+ | range : 0x8000 0000 <= var_out <= 0x7fff ffff. |
+ | |
+ |___________________________________________________________________________|
+*/
+Word32 L_mls (Word32 Lv, Word16 v) {
+ Word32 Temp;
+
+ Temp = Lv & (Word32) 0x0000ffff;
+ Temp = Temp * (Word32) v;
+ Temp = L_shr (Temp, (Word16) 15);
+ Temp = L_mac (Temp, v, extract_h (Lv));
+
+#if (WMOPS)
+ multiCounter[currCounter].L_shr--;
+ multiCounter[currCounter].L_mac--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].L_mls++;
+#endif
+
+ return Temp;
+}
+
+
+/*__________________________________________________________________________
+| |
+| Function Name : div_l |
+| |
+| Purpose : |
+| |
+| Produces a result which is the fractional integer division of L_var1 by |
+| var2; L_var1 and var2 must be positive and var2 << 16 must be greater or|
+| equal to L_var1; the result is positive (leading bit equal to 0) and |
+| truncated to 16 bits. |
+| If L_var1 == var2 << 16 then div_l(L_var1,var2) = 32767. |
+| |
+| Complexity weight : 32 |
+| |
+| Inputs : |
+| |
+| L_var1 |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x0000 0000 <= var1 <= (var2 << 16) and var2 != 0. |
+| L_var1 must be considered as a Q.31 value |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : var1 <= (var2<< 16) <= 0x7fff0000 and var2 != 0. |
+| var2 must be considered as a Q.15 value |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| var_out |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0x0000 0000 <= var_out <= 0x0000 7fff. |
+| It's a Q15 value (point between b15 and b14). |
+|___________________________________________________________________________|
+*/
+Word16 div_l (Word32 L_num, Word16 den) {
+ Word16 var_out = (Word16) 0;
+ Word32 L_den;
+ Word16 iteration;
+
+#if (WMOPS)
+ multiCounter[currCounter].div_l++;
+#endif
+
+ if (den == (Word16) 0) {
+ printf ("Division by 0 in div_l, Fatal error \n");
+ exit (0);
+ }
+
+ if ((L_num < (Word32) 0) || (den < (Word16) 0)) {
+ printf ("Division Error in div_l, Fatal error \n");
+ exit (0);
+ }
+
+ L_den = L_deposit_h (den);
+#if (WMOPS)
+ multiCounter[currCounter].L_deposit_h--;
+#endif
+
+ if (L_num >= L_den) {
+ return MAX_16;
+ } else {
+ L_num = L_shr (L_num, (Word16) 1);
+ L_den = L_shr (L_den, (Word16) 1);
+#if (WMOPS)
+ multiCounter[currCounter].L_shr -= 2;
+#endif
+ for (iteration = (Word16) 0; iteration < (Word16) 15; iteration++) {
+ var_out = shl (var_out, (Word16) 1);
+ L_num = L_shl (L_num, (Word16) 1);
+#if (WMOPS)
+ multiCounter[currCounter].shl--;
+ multiCounter[currCounter].L_shl--;
+#endif
+ if (L_num >= L_den) {
+ L_num = L_sub (L_num, L_den);
+ var_out = add (var_out, (Word16) 1);
+#if (WMOPS)
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].add--;
+#endif
+ }
+ }
+
+ return var_out;
+ }
+}
+
+
+/*__________________________________________________________________________
+| |
+| Function Name : i_mult |
+| |
+| Purpose : |
+| |
+| Integer 16-bit multiplication with overflow control. |
+| No overflow protection is performed if ORIGINAL_G7231 is defined. |
+| |
+| Complexity weight : 3 (it is performing something equivalent to |
+| extract_h( L_shl( L_mult0( v1, v2), 16)) |
+| |
+| Inputs : |
+| |
+| a |
+| 16 bit short signed integer (Word16). |
+| |
+| b |
+| 16 bit short signed integer (Word16). |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| 16 bit short signed integer (Word16). No overflow checks |
+| are performed if ORIGINAL_G7231 is defined. |
+|___________________________________________________________________________|
+*/
+Word16 i_mult (Word16 a, Word16 b) {
+#ifdef ORIGINAL_G7231
+ return a * b;
+#else
+ Word32 /*register*/ c = a * b;
+#if (WMOPS)
+ multiCounter[currCounter].i_mult++;
+#endif
+ return saturate (c);
+#endif
+}
+
+
+/*
+ ******************************************************************************
+ * The following three operators are not part of the original
+ * G.729/G.723.1 set of basic operators and implement shiftless
+ * accumulation operation.
+ ******************************************************************************
+*/
+
+/*___________________________________________________________________________
+ |
+ | Function Name : L_mult0
+ |
+ | Purpose :
+ |
+ | L_mult0 is the 32 bit result of the multiplication of var1 times var2
+ | without one left shift.
+ |
+ | Complexity weight : 1
+ |
+ | Inputs :
+ |
+ | var1 16 bit short signed integer (Word16) whose value falls in the
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ |
+ | var2 16 bit short signed integer (Word16) whose value falls in the
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ |
+ | Return Value :
+ |
+ | L_var_out
+ | 32 bit long signed integer (Word32) whose value falls in the
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ |___________________________________________________________________________
+*/
+Word32 L_mult0 (Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = (Word32) var1 *(Word32) var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mult0++;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ |
+ | Function Name : L_mac0
+ |
+ | Purpose :
+ |
+ | Multiply var1 by var2 (without left shift) and add the 32 bit result to
+ | L_var3 with saturation, return a 32 bit result:
+ | L_mac0(L_var3,var1,var2) = L_add(L_var3,(L_mult0(var1,var2)).
+ |
+ | Complexity weight : 1
+ |
+ | Inputs :
+ |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff.
+ |
+ | var1 16 bit short signed integer (Word16) whose value falls in the
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ |
+ | var2 16 bit short signed integer (Word16) whose value falls in the
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ |
+ | Return Value :
+ |
+ | L_var_out
+ | 32 bit long signed integer (Word32) whose value falls in the
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ |___________________________________________________________________________
+*/
+Word32 L_mac0 (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+ Word32 L_product;
+
+ L_product = L_mult0 (var1, var2);
+ L_var_out = L_add (L_var3, L_product);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_mac0++;
+ multiCounter[currCounter].L_mult0--;
+ multiCounter[currCounter].L_add--;
+#endif
+ return (L_var_out);
+}
+
+
+/*___________________________________________________________________________
+ |
+ | Function Name : L_msu0
+ |
+ | Purpose :
+ |
+ | Multiply var1 by var2 (without left shift) and subtract the 32 bit
+ | result to L_var3 with saturation, return a 32 bit result:
+ | L_msu0(L_var3,var1,var2) = L_sub(L_var3,(L_mult0(var1,var2)).
+ |
+ | Complexity weight : 1
+ |
+ | Inputs :
+ |
+ | L_var3 32 bit long signed integer (Word32) whose value falls in the
+ | range : 0x8000 0000 <= L_var3 <= 0x7fff ffff.
+ |
+ | var1 16 bit short signed integer (Word16) whose value falls in the
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ |
+ | var2 16 bit short signed integer (Word16) whose value falls in the
+ | range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ |
+ | Return Value :
+ |
+ | L_var_out
+ | 32 bit long signed integer (Word32) whose value falls in the
+ | range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ |___________________________________________________________________________
+*/
+Word32 L_msu0 (Word32 L_var3, Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+ Word32 L_product;
+
+ L_product = L_mult0 (var1, var2);
+ L_var_out = L_sub (L_var3, L_product);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_msu0++;
+ multiCounter[currCounter].L_mult0--;
+ multiCounter[currCounter].L_sub--;
+#endif
+ return (L_var_out);
+}
+
+
+/* end of file */
diff --git a/basic_op/basop32.h b/basic_op/basop32.h
new file mode 100644
index 0000000000000000000000000000000000000000..a9d63775bd1251c0747e150e117923c47bd42880
--- /dev/null
+++ b/basic_op/basop32.h
@@ -0,0 +1,130 @@
+/*
+ ===========================================================================
+ File: BASOP32.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ GLOBAL FUNCTION PROTOTYPES
+
+ History:
+ 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729
+ basic operator library (based on basic_op.h) and
+ G.723.1's basop.h.
+ 05.Jul.00 v1.1 Added 32-bit shiftless mult/mac/msub operators
+
+ 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ norm_s() weight reduced from 15 to 1.
+ norm_l() weight reduced from 30 to 1.
+ L_abs() weight reduced from 2 to 1.
+ L_add() weight reduced from 2 to 1.
+ L_negate() weight reduced from 2 to 1.
+ L_shl() weight reduced from 2 to 1.
+ L_shr() weight reduced from 2 to 1.
+ L_sub() weight reduced from 2 to 1.
+ mac_r() weight reduced from 2 to 1.
+ msu_r() weight reduced from 2 to 1.
+ mult_r() weight reduced from 2 to 1.
+ L_deposit_h() weight reduced from 2 to 1.
+ L_deposit_l() weight reduced from 2 to 1.
+ L_mls() weight of 5.
+ div_l() weight of 32.
+ i_mult() weight of 3.
+
+ 30 Nov 09 v2.3 round() function is now round_fx().
+ saturate() is not referencable from outside application
+ ============================================================================
+*/
+
+
+#ifndef _BASIC_OP_H
+#define _BASIC_OP_H
+
+
+/*___________________________________________________________________________
+ | |
+ | Constants and Globals |
+ | $Id $
+ |___________________________________________________________________________|
+*/
+extern Flag Overflow;
+extern Flag Carry;
+
+#define BASOP_SATURATE_WARNING_ON
+#define BASOP_SATURATE_WARNING_OFF
+#define BASOP_SATURATE_ERROR_ON
+#define BASOP_SATURATE_ERROR_OFF
+#define BASOP_CHECK()
+
+#define MAX_32 (Word32)0x7fffffffL
+#define MIN_32 (Word32)0x80000000L
+
+#define MAX_16 (Word16)0x7fff
+#define MIN_16 (Word16)0x8000
+
+/*___________________________________________________________________________
+ | |
+ | Prototypes for basic arithmetic operators |
+ |___________________________________________________________________________|
+*/
+
+Word16 add (Word16 var1, Word16 var2); /* Short add, 1 */
+Word16 sub (Word16 var1, Word16 var2); /* Short sub, 1 */
+Word16 abs_s (Word16 var1); /* Short abs, 1 */
+Word16 shl (Word16 var1, Word16 var2); /* Short shift left, 1 */
+Word16 shr (Word16 var1, Word16 var2); /* Short shift right, 1 */
+Word16 mult (Word16 var1, Word16 var2); /* Short mult, 1 */
+Word32 L_mult (Word16 var1, Word16 var2); /* Long mult, 1 */
+Word16 negate (Word16 var1); /* Short negate, 1 */
+Word16 extract_h (Word32 L_var1); /* Extract high, 1 */
+Word16 extract_l (Word32 L_var1); /* Extract low, 1 */
+Word16 round_fx (Word32 L_var1); /* Round, 1 */
+Word32 L_mac (Word32 L_var3, Word16 var1, Word16 var2); /* Mac, 1 */
+Word32 L_msu (Word32 L_var3, Word16 var1, Word16 var2); /* Msu, 1 */
+Word32 L_macNs (Word32 L_var3, Word16 var1, Word16 var2); /* Mac without sat, 1 */
+Word32 L_msuNs (Word32 L_var3, Word16 var1, Word16 var2); /* Msu without sat, 1 */
+Word32 L_add (Word32 L_var1, Word32 L_var2); /* Long add, 1 */
+Word32 L_sub (Word32 L_var1, Word32 L_var2); /* Long sub, 1 */
+Word32 L_add_c (Word32 L_var1, Word32 L_var2); /* Long add with c, 2 */
+Word32 L_sub_c (Word32 L_var1, Word32 L_var2); /* Long sub with c, 2 */
+Word32 L_negate (Word32 L_var1); /* Long negate, 1 */
+Word16 mult_r (Word16 var1, Word16 var2); /* Mult with round, 1 */
+Word32 L_shl (Word32 L_var1, Word16 var2); /* Long shift left, 1 */
+Word32 L_shr (Word32 L_var1, Word16 var2); /* Long shift right, 1 */
+Word16 shr_r (Word16 var1, Word16 var2); /* Shift right with round, 2 */
+Word16 mac_r (Word32 L_var3, Word16 var1, Word16 var2); /* Mac with rounding, 1 */
+Word16 msu_r (Word32 L_var3, Word16 var1, Word16 var2); /* Msu with rounding, 1 */
+Word32 L_deposit_h (Word16 var1); /* 16 bit var1 -> MSB, 1 */
+Word32 L_deposit_l (Word16 var1); /* 16 bit var1 -> LSB, 1 */
+
+Word32 L_shr_r (Word32 L_var1, Word16 var2); /* Long shift right with round, 3 */
+Word32 L_abs (Word32 L_var1); /* Long abs, 1 */
+Word32 L_sat (Word32 L_var1); /* Long saturation, 4 */
+Word16 norm_s (Word16 var1); /* Short norm, 1 */
+Word16 div_s (Word16 var1, Word16 var2); /* Short division, 18 */
+Word16 norm_l (Word32 L_var1); /* Long norm, 1 */
+
+
+/*
+ * Additional G.723.1 operators
+*/
+Word32 L_mls (Word32, Word16); /* Weight FFS; currently assigned 5 */
+Word16 div_l (Word32, Word16); /* Weight FFS; currently assigned 32 */
+Word16 i_mult (Word16 a, Word16 b); /* Weight FFS; currently assigned 3 */
+
+/*
+ * New shiftless operators, not used in G.729/G.723.1
+*/
+Word32 L_mult0 (Word16 v1, Word16 v2); /* 32-bit Multiply w/o shift e 1 */
+Word32 L_mac0 (Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Mac w/o shift 1 */
+Word32 L_msu0 (Word32 L_v3, Word16 v1, Word16 v2); /* 32-bit Msu w/o shift 1 */
+
+
+#endif /* ifndef _BASIC_OP_H */
+
+
+/* end of file */
diff --git a/basic_op/complex_basop.c b/basic_op/complex_basop.c
new file mode 100644
index 0000000000000000000000000000000000000000..3a65d65a6eaeac6a9ce75edbea4d3544a6a82e3a
--- /dev/null
+++ b/basic_op/complex_basop.c
@@ -0,0 +1,457 @@
+/*****************************************************************************
+
+*
+
+* Complex arithmetic operators
+
+*
+
+*****************************************************************************/
+
+
+#include "typedef.h"
+#include "basop32.h"
+
+#include "complex_basop.h"
+
+#include "stl.h"
+
+
+
+#if (WMOPS)
+
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+
+extern int currCounter;
+
+#endif /* if WMOPS */
+
+
+
+#ifdef COMPLEX_OPERATOR
+
+/* ================================ New Complex Basops ========================= */
+
+cmplx CL_shr (cmplx inp, Word32 shift_val) {
+ cmplx out;
+ out.re = L_shr (inp.re, shift_val);
+ out.im = L_shr (inp.im, shift_val);
+#if (WMOPS)
+ multiCounter[currCounter].CL_shr++;
+ multiCounter[currCounter].L_shr--;
+ multiCounter[currCounter].L_shr--;
+#endif
+ return out;
+}
+
+cmplx CL_shl (cmplx inp, Word32 shift_val) {
+ cmplx out;
+ out.re = L_shl (inp.re, shift_val);
+ out.im = L_shl (inp.im, shift_val);
+#if (WMOPS)
+ multiCounter[currCounter].CL_shl++;
+ multiCounter[currCounter].L_shl--;
+ multiCounter[currCounter].L_shl--;
+#endif
+ return out;
+}
+
+cmplx CL_add (cmplx inp1, cmplx inp2) {
+ cmplx out;
+ out.re = L_add (inp1.re, inp2.re);
+ out.im = L_add (inp1.im, inp2.im);
+#if (WMOPS)
+ multiCounter[currCounter].CL_add++;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].L_add--;
+#endif
+ return out;
+}
+
+cmplx CL_sub (cmplx inp1, cmplx inp2) {
+ cmplx out;
+ out.re = L_sub (inp1.re, inp2.re);
+ out.im = L_sub (inp1.im, inp2.im);
+#if (WMOPS)
+ multiCounter[currCounter].CL_sub++;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].L_sub--;
+#endif
+ return out;
+}
+
+cmplx CL_scale(cmplx x, Word16 y) {
+ cmplx result;
+ result.re = Mpy_32_16_r (x.re, y);
+ result.im = Mpy_32_16_r (x.im, y);
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_r--;
+ multiCounter[currCounter].Mpy_32_16_r--;
+ multiCounter[currCounter].CL_scale++;
+#endif/* #if (WMOPS) */
+ return (result);
+}
+
+cmplx CL_dscale (cmplx x, Word16 y1, Word16 y2) {
+ cmplx result;
+ result.re = Mpy_32_16_r (x.re, y1);
+ result.im = Mpy_32_16_r (x.im, y2);
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_r--;
+ multiCounter[currCounter].Mpy_32_16_r--;
+ multiCounter[currCounter].CL_dscale++;
+#endif/* #if (WMOPS) */
+ return (result);
+}
+
+cmplx CL_msu_j (cmplx x, cmplx y) {
+ cmplx result;
+ result.re = L_add (x.re, y.im);
+ result.im = L_sub (x.im, y.re);
+#if (WMOPS)
+ multiCounter[currCounter].CL_msu_j++;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].L_sub--;
+#endif
+ return result;
+}
+
+cmplx CL_mac_j (cmplx x, cmplx y) {
+ cmplx result;
+ result.re = L_sub (x.re, y.im );
+ result.im = L_add (x.im, y.re );
+#if (WMOPS)
+ multiCounter[currCounter].CL_mac_j++;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].L_sub--;
+#endif
+ return result;
+}
+
+cmplx CL_move (cmplx x) {
+#if (WMOPS)
+ multiCounter[currCounter].CL_move++;
+#endif
+ return x;
+}
+
+Word32 CL_Extract_real (cmplx x) {
+#if (WMOPS)
+ multiCounter[currCounter].CL_Extract_real++;
+#endif
+ return x.re;
+}
+
+Word32 CL_Extract_imag (cmplx x) {
+#if (WMOPS)
+ multiCounter[currCounter].CL_Extract_imag++;
+#endif
+ return x.im;
+}
+
+cmplx CL_form (Word32 re, Word32 im) {
+ cmplx result;
+ result.re = re;
+ result.im = im;
+#if (WMOPS)
+ multiCounter[currCounter].CL_form++;
+#endif
+ return result;
+}
+
+cmplx CL_multr_32x16 (cmplx input, cmplx_s coeff) {
+ cmplx result;
+ result.re = W_round48_L (W_sub_nosat (W_mult_32_16 (input.re, coeff.re), W_mult_32_16 (input.im, coeff.im) ) );
+ result.im = W_round48_L (W_add_nosat (W_mult_32_16 (input.re, coeff.im), W_mult_32_16 (input.im, coeff.re) ) );
+#if (WMOPS)
+ multiCounter[currCounter].CL_multr_32x16++;
+ multiCounter[currCounter].W_mult_32_16--;
+ multiCounter[currCounter].W_mult_32_16--;
+ multiCounter[currCounter].W_mult_32_16--;
+ multiCounter[currCounter].W_mult_32_16--;
+ multiCounter[currCounter].W_sub_nosat--;
+ multiCounter[currCounter].W_add_nosat--;
+ multiCounter[currCounter].W_round48_L--;
+ multiCounter[currCounter].W_round48_L--;
+#endif
+ return result;
+}
+
+cmplx CL_negate(cmplx x) {
+ cmplx result;
+ result.re = L_negate (x.re);
+ result.im = L_negate (x.im);
+#if (WMOPS)
+ multiCounter[currCounter].CL_negate++;
+ multiCounter[currCounter].L_negate--;
+ multiCounter[currCounter].L_negate--;
+#endif
+ return result;
+}
+
+cmplx CL_conjugate (cmplx x) {
+ cmplx result;
+ result.re = x.re;
+ result.im = L_negate (x.im);
+#if (WMOPS)
+ multiCounter[currCounter].CL_conjugate++;
+ multiCounter[currCounter].L_negate--;
+#endif
+ return result;
+}
+
+
+cmplx CL_mul_j (cmplx input) {
+ cmplx temp, result;
+ temp = CL_negate (input);
+ result.re = temp.im;
+ result.im = input.re;
+#if (WMOPS)
+ multiCounter[currCounter].CL_mul_j++;
+ multiCounter[currCounter].CL_negate--;
+#endif
+ return result;
+}
+
+cmplx CL_swap_real_imag (cmplx input) {
+ cmplx result;
+ result.re = input.im;
+ result.im = input.re;
+#if (WMOPS)
+ multiCounter[currCounter].CL_swap_real_imag++;
+#endif
+ return result;
+}
+
+cmplx_s C_add (cmplx_s inp1, cmplx_s inp2) {
+ cmplx_s out;
+ out.re = add (inp1.re, inp2.re);
+ out.im = add (inp1.im, inp2.im);
+
+#if (WMOPS)
+ multiCounter[currCounter].C_add++;
+ multiCounter[currCounter].add--;
+ multiCounter[currCounter].add--;
+#endif
+ return out;
+}
+
+cmplx_s C_sub (cmplx_s inp1, cmplx_s inp2) {
+ cmplx_s out;
+ out.re = sub (inp1.re, inp2.re);
+ out.im = sub (inp1.im, inp2.im);
+
+#if (WMOPS)
+ multiCounter[currCounter].C_sub++;
+ multiCounter[currCounter].sub--;
+ multiCounter[currCounter].sub--;
+#endif
+ return out;
+}
+
+cmplx_s C_mul_j (cmplx_s input) {
+ cmplx_s result;
+ Word16 temp;
+ temp = negate(input.im);
+ result.re = temp;
+ result.im = input.re;
+
+#if (WMOPS)
+ multiCounter[currCounter].C_mul_j++;
+ multiCounter[currCounter].negate--;
+#endif
+ return result;
+}
+
+cmplx_s C_multr (cmplx_s x, cmplx_s c) {
+ cmplx_s result;
+ result.re = round_fx (W_sat_l (W_sub_nosat (W_mult_16_16 (x.re, c.re), W_mult_16_16 (x.im, c.im) ) ) );
+ result.im = round_fx (W_sat_l (W_add_nosat (W_mult_16_16 (x.im, c.re), W_mult_16_16 (x.re, c.im) ) ) );
+
+#if (WMOPS)
+ multiCounter[currCounter].C_multr++;
+ multiCounter[currCounter].W_mult_16_16--;
+ multiCounter[currCounter].W_mult_16_16--;
+ multiCounter[currCounter].W_mult_16_16--;
+ multiCounter[currCounter].W_mult_16_16--;
+ multiCounter[currCounter].W_sub_nosat--;
+ multiCounter[currCounter].W_add_nosat--;
+ multiCounter[currCounter].W_sat_l--;
+ multiCounter[currCounter].W_sat_l--;
+ multiCounter[currCounter].round--;
+ multiCounter[currCounter].round--;
+#endif
+ return result;
+}
+
+cmplx_s C_form ( Word16 re, Word16 im) {
+ cmplx_s result;
+ result.re = re;
+ result.im = im;
+#if (WMOPS)
+ multiCounter[currCounter].C_form++;
+#endif
+ return result;
+}
+
+cmplx C_scale(cmplx_s x, Word16 y) {
+ cmplx result;
+ result.re = L_mult(x.re, y);
+ result.im = L_mult(x.im, y);
+#if (WMOPS)
+ multiCounter[currCounter].L_mult--;
+ multiCounter[currCounter].L_mult--;
+ multiCounter[currCounter].C_scale++;
+#endif/* #if (WMOPS) */
+ return (result);
+}
+
+cmplx_s CL_round32_16 (cmplx x) {
+ cmplx_s result;
+ result.re = round_fx (x.re);
+ result.im = round_fx (x.im);
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_round32_16++;
+ multiCounter[currCounter].round--;
+ multiCounter[currCounter].round--;
+#endif
+ return result;
+}
+
+cmplx CL_scale_32 (cmplx x, Word32 y) {
+ cmplx result;
+ result.re = Mpy_32_32_r (x.re, y);
+ result.im = Mpy_32_32_r (x.im, y);
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_r--;
+ multiCounter[currCounter].Mpy_32_32_r--;
+ multiCounter[currCounter].CL_scale_32++;
+#endif/* #if (WMOPS) */
+ return (result);
+}
+
+cmplx CL_dscale_32 (cmplx x, Word32 y1, Word32 y2) {
+ cmplx result;
+ result.re = Mpy_32_32_r (x.re, y1);
+ result.im = Mpy_32_32_r (x.im, y2);
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_r--;
+ multiCounter[currCounter].Mpy_32_32_r--;
+ multiCounter[currCounter].CL_dscale_32++;
+#endif/* #if (WMOPS) */
+ return (result);
+}
+
+cmplx CL_multr_32x32 (cmplx x, cmplx y) {
+ cmplx result;
+ result.re = W_round64_L (W_sub (W_mult_32_32 (x.re, y.re), W_mult_32_32(x.im, y.im) ) ) ;
+ result.im = W_round64_L (W_add (W_mult_32_32 (x.im, y.re), W_mult_32_32(x.re, y.im) ) ) ;
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_multr_32x32++;
+ multiCounter[currCounter].W_mult_32_32--;
+ multiCounter[currCounter].W_mult_32_32--;
+ multiCounter[currCounter].W_mult_32_32--;
+ multiCounter[currCounter].W_mult_32_32--;
+ multiCounter[currCounter].W_round64_L--;
+ multiCounter[currCounter].W_round64_L--;
+ multiCounter[currCounter].W_sub--;
+ multiCounter[currCounter].W_add--;
+#endif
+ return result;
+}
+
+cmplx_s C_mac_r (cmplx x, cmplx_s y, Word16 c) {
+ cmplx_s result;
+ cmplx temp = CL_add (x, C_scale (y, c) );
+ result = CL_round32_16 (temp);
+
+#if (WMOPS)
+ multiCounter[currCounter].C_mac_r++;
+ multiCounter[currCounter].CL_add--;
+ multiCounter[currCounter].C_scale--;
+ multiCounter[currCounter].CL_round32_16--;
+#endif
+ return result;
+}
+
+cmplx_s C_msu_r (cmplx x, cmplx_s y, Word16 c) {
+ cmplx_s result;
+ cmplx temp = CL_sub (x, C_scale (y, c) );
+ result = CL_round32_16 (temp);
+
+#if (WMOPS)
+ multiCounter[currCounter].C_msu_r++;
+ multiCounter[currCounter].CL_sub--;
+ multiCounter[currCounter].C_scale--;
+ multiCounter[currCounter].CL_round32_16--;
+#endif
+ return result;
+}
+
+Word16 C_Extract_real (cmplx_s x) {
+#if (WMOPS)
+ multiCounter[currCounter].C_Extract_real++;
+#endif
+ return x.re;
+}
+
+Word16 C_Extract_imag (cmplx_s x) {
+#if (WMOPS)
+ multiCounter[currCounter].C_Extract_imag++;
+#endif
+ return x.im;
+}
+
+cmplx_s C_negate (cmplx_s x) {
+ cmplx_s result;
+ result.re = negate (x.re);
+ result.im = negate (x.im);
+#if (WMOPS)
+ multiCounter[currCounter].C_negate++;
+ multiCounter[currCounter].negate--;
+ multiCounter[currCounter].negate--;
+#endif
+ return result;
+}
+
+cmplx_s C_conjugate (cmplx_s x) {
+ cmplx_s result;
+ result.re = x.re;
+ result.im = negate (x.im);
+#if (WMOPS)
+ multiCounter[currCounter].C_conjugate++;
+ multiCounter[currCounter].negate--;
+#endif
+ return result;
+}
+
+cmplx_s C_shr (cmplx_s inp, Word16 shift_val) {
+ cmplx_s out;
+ out.re = shr (inp.re, shift_val);
+ out.im = shr (inp.im, shift_val);
+#if (WMOPS)
+ multiCounter[currCounter].C_shr++;
+ multiCounter[currCounter].shr--;
+ multiCounter[currCounter].shr--;
+#endif
+ return out;
+}
+
+cmplx_s C_shl (cmplx_s inp, Word16 shift_val) {
+ cmplx_s out;
+ out.re = shl (inp.re, shift_val);
+ out.im = shl (inp.im, shift_val);
+#if (WMOPS)
+ multiCounter[currCounter].C_shl++;
+ multiCounter[currCounter].shl--;
+ multiCounter[currCounter].shl--;
+#endif
+ return out;
+}
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+/* end of file */
+
diff --git a/basic_op/complex_basop.h b/basic_op/complex_basop.h
new file mode 100644
index 0000000000000000000000000000000000000000..c3deb1455737a515e47b18c2c1e76c51573646ff
--- /dev/null
+++ b/basic_op/complex_basop.h
@@ -0,0 +1,77 @@
+ /*****************************************************************************
+
+ *
+
+ * Complex arithmetic operators
+
+ *
+
+ *****************************************************************************/
+#ifndef _COMPLEX_BASIC_OP_H
+#define _COMPLEX_BASIC_OP_H
+
+#include "typedef.h"
+#include "basop32.h"
+#include "stl.h"
+
+#ifdef COMPLEX_OPERATOR
+
+typedef struct
+{
+ Word32 re;
+ Word32 im;
+}cmplx;
+
+typedef struct
+{
+ Word16 re;
+ Word16 im;
+}cmplx_s;
+
+/*___________________________________________________________________________
+ | |
+ | Prototypes for complex arithmetic operators |
+ |___________________________________________________________________________|
+*/
+
+cmplx CL_shr (cmplx inp, Word32 shift_val);
+cmplx CL_shl (cmplx inp, Word32 shift_val);
+cmplx CL_add (cmplx inp1, cmplx inp2);
+cmplx CL_sub (cmplx inp1, cmplx inp2);
+cmplx CL_scale (cmplx x, Word16 y);
+cmplx CL_dscale (cmplx x, Word16 y1, Word16 y2);
+cmplx CL_msu_j (cmplx x, cmplx y);
+cmplx CL_mac_j (cmplx x, cmplx y);
+cmplx CL_move (cmplx x);
+Word32 CL_Extract_real (cmplx x);
+Word32 CL_Extract_imag (cmplx x);
+cmplx CL_form (Word32 re, Word32 im);
+cmplx CL_multr_32x16 (cmplx input, cmplx_s coeff);
+cmplx CL_negate (cmplx x);
+cmplx CL_conjugate (cmplx x);
+cmplx CL_mul_j (cmplx input);
+cmplx CL_swap_real_imag (cmplx input);
+cmplx_s C_add (cmplx_s inp1, cmplx_s inp2);
+cmplx_s C_sub (cmplx_s inp1, cmplx_s inp2);
+cmplx_s C_mul_j (cmplx_s input);
+cmplx_s C_multr (cmplx_s x, cmplx_s c);
+cmplx_s C_form (Word16 re, Word16 im );
+
+cmplx C_scale (cmplx_s x, Word16 y);
+cmplx_s CL_round32_16 (cmplx x);
+cmplx CL_scale_32 (cmplx x, Word32 y);
+cmplx CL_dscale_32 (cmplx x, Word32 y1, Word32 y2);
+cmplx CL_multr_32x32 (cmplx x, cmplx y);
+cmplx_s C_mac_r (cmplx x, cmplx_s y, Word16 c);
+cmplx_s C_msu_r (cmplx x, cmplx_s y, Word16 c);
+Word16 C_Extract_real (cmplx_s x );
+Word16 C_Extract_imag (cmplx_s x );
+cmplx_s C_negate (cmplx_s x);
+cmplx_s C_conjugate (cmplx_s x);
+cmplx_s C_shr (cmplx_s inp, Word16 shift_val);
+cmplx_s C_shl (cmplx_s inp, Word16 shift_val);
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+#endif /* ifndef _COMPLEX_BASIC_OP_H */
+
diff --git a/basic_op/control.c b/basic_op/control.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d0a46c25a507116919306e55deb85c40e3772fe
--- /dev/null
+++ b/basic_op/control.c
@@ -0,0 +1,250 @@
+/*
+ ===========================================================================
+ File: CONTROL.C v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+
+ ============================================================================
+*/
+
+#include "stl.h"
+
+#ifdef WMOPS
+int funcId_where_last_call_to_else_occurred;
+long funcid_total_wmops_at_last_call_to_else;
+int call_occurred = 1;
+#endif
+
+#ifdef CONTROL_CODE_OPS
+
+Flag LT_16 (Word16 var1, Word16 var2) {
+ Flag F_ret = 0;
+
+ if( var1 < var2 )
+ {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].LT_16++;
+#endif
+ return F_ret;
+}
+
+Flag GT_16 (Word16 var1, Word16 var2) {
+ Flag F_ret = 0;
+
+ if( var1 > var2 )
+ {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].GT_16++;
+#endif
+ return F_ret;
+}
+
+Flag LE_16 (Word16 var1, Word16 var2) {
+ Flag F_ret = 0;
+
+ if (var1 <= var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].LE_16++;
+#endif
+ return F_ret;
+}
+
+Flag GE_16 (Word16 var1, Word16 var2) {
+ Flag F_ret = 0;
+
+ if (var1 >= var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].GE_16++;
+#endif
+ return F_ret;
+}
+
+Flag EQ_16 (Word16 var1, Word16 var2) {
+ Flag F_ret = 0;
+
+ if (var1 == var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].EQ_16++;
+#endif
+ return F_ret;
+}
+
+Flag NE_16 (Word16 var1, Word16 var2) {
+ Flag F_ret = 0;
+
+ if (var1 != var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].NE_16++;
+#endif
+ return F_ret;
+}
+
+Flag LT_32 (Word32 L_var1, Word32 L_var2) {
+ Flag F_ret = 0;
+
+ if (L_var1 < L_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].LT_32++;
+#endif
+ return F_ret;
+}
+
+Flag GT_32 (Word32 L_var1, Word32 L_var2) {
+ Flag F_ret = 0;
+
+ if (L_var1 > L_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].GT_32++;
+#endif
+ return F_ret;
+}
+
+Flag LE_32 (Word32 L_var1, Word32 L_var2) {
+ Flag F_ret = 0;
+
+ if (L_var1 <= L_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].LE_32++;
+#endif
+ return F_ret;
+}
+
+Flag GE_32 (Word32 L_var1, Word32 L_var2) {
+ Flag F_ret = 0;
+
+ if (L_var1 >= L_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].GE_32++;
+#endif
+ return F_ret;
+}
+
+Flag EQ_32 (Word32 L_var1, Word32 L_var2) {
+ Flag F_ret = 0;
+
+ if (L_var1 == L_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].EQ_32++;
+#endif
+ return F_ret;
+}
+
+Flag NE_32 (Word32 L_var1, Word32 L_var2) {
+ Flag F_ret = 0;
+
+ if (L_var1 != L_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].NE_32++;
+#endif
+ return F_ret;
+}
+
+Flag LT_64 (Word64 L64_var1, Word64 L64_var2) {
+ Flag F_ret = 0;
+
+ if (L64_var1 < L64_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].LT_64++;
+#endif
+ return F_ret;
+}
+
+Flag GT_64 (Word64 L64_var1, Word64 L64_var2) {
+ Flag F_ret = 0;
+
+ if (L64_var1 > L64_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].GT_64++;
+#endif
+ return F_ret;
+}
+
+Flag LE_64 (Word64 L64_var1, Word64 L64_var2) {
+ Flag F_ret = 0;
+
+ if (L64_var1 <= L64_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].LE_64++;
+#endif
+ return F_ret;
+}
+Flag GE_64 (Word64 L64_var1, Word64 L64_var2) {
+ Flag F_ret = 0;
+
+ if (L64_var1 >= L64_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].GE_64++;
+#endif
+ return F_ret;
+}
+
+Flag EQ_64 (Word64 L64_var1, Word64 L64_var2) {
+ Flag F_ret = 0;
+
+ if (L64_var1 == L64_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].EQ_64++;
+#endif
+ return F_ret;
+}
+Flag NE_64 (Word64 L64_var1, Word64 L64_var2) {
+ Flag F_ret = 0;
+
+ if (L64_var1 != L64_var2) {
+ F_ret = 1;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].NE_64++;
+#endif
+ return F_ret;
+}
+
+#endif /* #ifdef CONTROL_CODE_OPS */
+
+
+/* end of file */
diff --git a/basic_op/control.h b/basic_op/control.h
new file mode 100644
index 0000000000000000000000000000000000000000..4f406e25ba9a9158328f127e6a970c4aa226324d
--- /dev/null
+++ b/basic_op/control.h
@@ -0,0 +1,332 @@
+/*
+ ===========================================================================
+ File: CONTROL.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ CONTROL FLOW OPERATORS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+
+ ============================================================================
+*/
+
+#ifndef _CONTROL_H
+#define _CONTROL_H
+
+#include "stl.h"
+
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+
+ /* Technical note :
+ * The following 3 variables are only used for correct complexity
+ * evaluation of the following structure :
+ * IF{
+ * ...
+ * } ELSE IF {
+ * ...
+ * } ELSE IF {
+ * ...
+ * }
+ * ...
+ * } ELSE {
+ * ...
+ * }
+ */
+extern int funcId_where_last_call_to_else_occurred;
+extern long funcid_total_wmops_at_last_call_to_else;
+extern int call_occurred;
+#endif /* ifdef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Macros
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Function Name : FOR
+ *
+ * Purpose :
+ *
+ * The macro FOR should be used instead of the 'for' C statement.
+ * The complexity is independent of the number of loop iterations that are
+ * performed.
+ *
+ * Complexity weight : 3 (regardless of number of iterations).
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define FOR( a) for( a)
+
+#else /* ifndef WMOPS */
+#define FOR( a) if( incrFor(), 0); else for( a)
+
+static __inline void incrFor (void) {
+ multiCounter[currCounter].For++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : WHILE
+ *
+ * Purpose :
+ *
+ * The macro WHILE should be used instead of the 'while' C statement.
+ * The complexity is proportional to the number of loop iterations that
+ * are performed.
+ *
+ * Complexity weight : 4 x 'number of loop iterations'.
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define WHILE(a) while (a)
+
+#else /* ifndef WMOPS */
+#define WHILE(a) while (incrWhile(), a)
+
+static __inline void incrWhile (void) {
+ multiCounter[currCounter].While++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : DO
+ *
+ * Purpose :
+ *
+ * The macro DO should be used instead of the 'do' C statement.
+ *
+ * Complexity weight : 0 (complexity counted by WHILE macro).
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define DO do
+
+#else /* ifndef WMOPS */
+#define DO do
+
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : IF
+ *
+ * Purpose :
+ *
+ * The macro IF should :
+ *
+ * - not be used when :
+ * - the 'if' structure does not have any 'else if' nor 'else' statement
+ * - and it conditions only one DSP basic operations.
+ *
+ * - be used instead of the 'if' C statement in every other case :
+ * - when there is an 'else' or 'else if' statement,
+ * - or when the 'if' conditions several DSP basic operations,
+ * - or when the 'if' conditions a function call.
+ *
+ * Complexity weight : 4
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define IF(a) if (a)
+
+#else /* ifndef WMOPS */
+#define IF(a) if (incrIf (), a)
+
+static __inline void incrIf (void) {
+ /* Technical note :
+ * If the "IF" operator comes just after an "ELSE", its counter
+ * must not be incremented.
+ */
+ if ((currCounter != funcId_where_last_call_to_else_occurred)
+ || (TotalWeightedOperation () != funcid_total_wmops_at_last_call_to_else)
+ || (call_occurred == 1))
+ multiCounter[currCounter].If++;
+
+ call_occurred = 0;
+ funcId_where_last_call_to_else_occurred = MAXCOUNTERS;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : ELSE
+ *
+ * Purpose :
+ *
+ * The macro ELSE should be used instead of the 'else' C statement.
+ *
+ * Complexity weight : 4
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define ELSE else
+
+#else /* ifndef WMOPS */
+#define ELSE else if (incrElse (), 0) ; else
+
+static __inline void incrElse (void) {
+ multiCounter[currCounter].If++;
+
+ /* We keep track of the funcId of the last function which used ELSE {...} structure. */
+ funcId_where_last_call_to_else_occurred = currCounter;
+
+ /* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */
+ funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation ();
+
+ /* call_occurred is set to 0, in order to count the next IF (if necessary) */
+ call_occurred = 0;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : SWITCH
+ *
+ * Purpose :
+ *
+ * The macro SWITCH should be used instead of the 'switch' C statement.
+ *
+ * Complexity weight : 8
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define SWITCH(a) switch (a)
+
+#else /* ifndef WMOPS */
+#define SWITCH(a) switch (incrSwitch (), a)
+
+static __inline void incrSwitch (void) {
+ multiCounter[currCounter].Switch++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : CONTINUE
+ *
+ * Purpose :
+ *
+ * The macro CONTINUE should be used instead of the 'continue' C statement.
+ *
+ * Complexity weight : 4
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define CONTINUE continue
+
+#else /* ifndef WMOPS */
+#define CONTINUE if (incrContinue (), 0); else continue
+
+static __inline void incrContinue (void) {
+ multiCounter[currCounter].Continue++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : BREAK
+ *
+ * Purpose :
+ *
+ * The macro BREAK should be used instead of the 'break' C statement.
+ *
+ * Complexity weight : 4
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define BREAK break
+
+#else /* ifndef WMOPS */
+#define BREAK if (incrBreak (), 0); else break
+
+static __inline void incrBreak (void) {
+ multiCounter[currCounter].Break++;
+}
+#endif /* ifndef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Function Name : GOTO
+ *
+ * Purpose :
+ *
+ * The macro GOTO should be used instead of the 'goto' C statement.
+ *
+ * Complexity weight : 4
+ *
+ *****************************************************************************/
+#ifndef WMOPS
+#define GOTO goto
+
+#else /* ifndef WMOPS */
+#define GOTO if (incrGoto (), 0); else goto
+
+static __inline void incrGoto (void) {
+ multiCounter[currCounter].Goto++;
+}
+#endif /* ifndef WMOPS */
+
+
+
+/*
+ * New control code basops
+*/
+#ifdef CONTROL_CODE_OPS
+
+Flag LT_16 (Word16 var1, Word16 var2);
+Flag GT_16 (Word16 var1, Word16 var2);
+Flag LE_16 (Word16 var1, Word16 var2);
+Flag GE_16 (Word16 var1, Word16 var2);
+Flag EQ_16 (Word16 var1, Word16 var2);
+Flag NE_16 (Word16 var1, Word16 var2);
+
+Flag LT_32 (Word32 L_var1, Word32 L_var2);
+Flag GT_32 (Word32 L_var1, Word32 L_var2);
+Flag LE_32 (Word32 L_var1, Word32 L_var2);
+Flag GE_32 (Word32 L_var1, Word32 L_var2);
+Flag EQ_32 (Word32 L_var1, Word32 L_var2);
+Flag NE_32 (Word32 L_var1, Word32 L_var2);
+
+Flag LT_64 (Word64 L64_var1, Word64 L64_var2);
+Flag GT_64 (Word64 L64_var1, Word64 L64_var2);
+Flag LE_64 (Word64 L64_var1, Word64 L64_var2);
+Flag GE_64 (Word64 L64_var1, Word64 L64_var2);
+Flag EQ_64 (Word64 L64_var1, Word64 L64_var2);
+Flag NE_64 (Word64 L64_var1, Word64 L64_var2);
+
+
+#endif /* #ifdef CONTROL_CODE_OPS */
+
+#endif /* _CONTROL_H */
+
+
+/* end of file */
diff --git a/basic_op/count.c b/basic_op/count.c
new file mode 100644
index 0000000000000000000000000000000000000000..1fc839b6249b5100f4fcca179f4063bc0291cd0d
--- /dev/null
+++ b/basic_op/count.c
@@ -0,0 +1,772 @@
+/*
+ ===========================================================================
+ File: COUNT.C v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ COMPLEXITY EVALUATION FUNCTIONS
+
+ History:
+ 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ norm_s() weight reduced from 15 to 1.
+ norm_l() weight reduced from 30 to 1.
+ L_abs() weight reduced from 2 to 1.
+ L_add() weight reduced from 2 to 1.
+ L_negate() weight reduced from 2 to 1.
+ L_shl() weight reduced from 2 to 1.
+ L_shr() weight reduced from 2 to 1.
+ L_sub() weight reduced from 2 to 1.
+ mac_r() weight reduced from 2 to 1.
+ msu_r() weight reduced from 2 to 1.
+ mult_r() weight reduced from 2 to 1.
+ L_deposit_h() weight reduced from 2 to 1.
+ L_deposit_l() weight reduced from 2 to 1.
+ March 06 v2.1 Changed to improve portability.
+ Dec 06 v2.2 Changed to specify frame rate using setFrameRate()
+ Adding WMOPS_output_avg() for global average computation
+ L_mls() weight of 5.
+ div_l() weight of 32.
+ i_mult() weight of 3.
+ ============================================================================
+*/
+
+
+/*****************************************************************************
+ *
+ * This file contains functions for the automatic complexity calculation
+ *
+ *****************************************************************************/
+
+
+#include
+#include
+#include
+#include "stl.h"
+
+#ifdef WMOPS
+static double frameRate = FRAME_RATE; /* default value : 10 ms */
+#endif /* ifdef WMOPS */
+
+#ifdef WMOPS
+/* Global counter variable for calculation of complexity weight */
+BASIC_OP multiCounter[MAXCOUNTERS];
+int currCounter = 0; /* Zero equals global counter */
+#endif /* ifdef WMOPS */
+
+#ifdef WMOPS
+void setFrameRate (int samplingFreq, int frameLength) {
+ if (frameLength > 0) {
+ frameRate = samplingFreq / 1000000.0 / frameLength;
+ }
+ return;
+}
+
+#endif /* ifdef WMOPS */
+
+#ifdef WMOPS
+/*
+ * Below list is used for displaying the code profiling information in
+ * the file which name is defined by CODE_PROFILE_FILENAME.
+ * For further details see generic_WMOPS_output() function.
+ * Attention, the ordering in this table must be kept in synchronisation
+ * with the structure definition BASIC_OP.
+ */
+char *BasicOperationList[] = {
+ "add", "sub", "abs_s", "shl", "shr",
+ "extract_h", "extract_l", "mult", "L_mult", "negate",
+ "round", "L_mac", "L_msu", "L_macNs", "L_msuNs",
+ "L_add", "L_sub", "L_add_c", "L_sub_c", "L_negate",
+ "L_shl", "L_shr", "mult_r", "shr_r", "mac_r",
+
+ "msu_r", "L_deposit_h", "L_deposit_l", "L_shr_r", "L_abs",
+ "L_sat", "norm_s", "div_s", "norm_l", "move16",
+ "move32", "Logic16", "Logic32", "Test", "s_max",
+ "s_min", "L_max", "L_min", "L40_max", "L40_min",
+ "shl_r", "L_shl_r", "L40_shr_r", "L40_shl_r", "norm_L40",
+
+ "L40_shl", "L40_shr", "L40_negate", "L40_add", "L40_sub",
+ "L40_abs", "L40_mult", "L40_mac", "mac_r40",
+ "L40_msu", "msu_r40", "Mpy_32_16_ss", "Mpy_32_32_ss", "L_mult0",
+ "L_mac0", "L_msu0", "lshl", "lshr", "L_lshl",
+ "L_lshr", "L40_lshl", "L40_lshr", "s_and", "s_or",
+
+ "s_xor", "L_and", "L_or", "L_xor", "rotl",
+ "rotr", "L_rotl", "L_rotr", "L40_set", "L40_deposit_h",
+ "L40_deposit_l", "L40_deposit32", "Extract40_H", "Extract40_L", "L_Extract40",
+ "L40_round", "L_saturate40", "round40", "IF", "GOTO",
+ "BREAK", "SWITCH", "FOR", "WHILE", "CONTINUE",
+
+ "L_mls", "div_l", "i_mult"
+
+ /* New complex basops */
+ #ifdef COMPLEX_OPERATOR
+ , "CL_shr", "CL_shl", "CL_add"
+ , "CL_sub", "CL_scale", "CL_dscale"
+ , "CL_msu_j", "CL_mac_j", "CL_move"
+ , "CL_Extract_real", "CL_Extract_imag", "CL_form"
+ , "CL_multr_32x16", "CL_negate", "CL_conjugate"
+ , "CL_mul_j"
+ , "CL_swap_real_imag"
+ , "C_add"
+ , "C_sub"
+ , "C_mul_j"
+ , "C_multr"
+ , "C_form"
+
+ , "C_scale"
+ , "CL_round32_16", "CL_scale_32", "CL_dscale_32", "CL_multr_32x32"
+ , "C_mac_r", "C_msu_r", "C_Extract_real", "C_Extract_imag"
+ , "C_negate", "C_conjugate"
+ , "C_shr", "C_shl"
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+ /* New 64 bit basops */
+#ifdef ENH_64_BIT_OPERATOR
+ , "move64" , "W_add_nosat" ,"W_sub_nosat"
+ , "W_shl" , "W_shr"
+ , "W_shl_nosat" , "W_shr_nosat"
+ , "W_mac_32_16" , "W_msu_32_16" , "W_mult_32_16"
+ , "W_mult0_16_16" , "W_mac0_16_16" , "W_msu0_16_16"
+ , "W_mult_16_16" , "W_mac_16_16" , "W_msu_16_16"
+ , "W_shl_sat_l" , "W_sat_l"
+ , "W_sat_m" , "W_deposit32_l" ,"W_deposit32_h"
+ , "W_extract_l" , "W_extract_h"
+ , "W_round48_L" , "W_round32_s"
+ , "W_norm"
+ , "W_add" , "W_sub" ,"W_neg" ,"W_abs"
+ , "W_mult_32_32" , "W_mult0_32_32"
+ , "W_lshl" , "W_lshr" ,"W_round64_L"
+
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+#ifdef ENH_32_BIT_OPERATOR
+ , "Mpy_32_16_1"
+ , "Mpy_32_16_r"
+ , "Mpy_32_32"
+ , "Mpy_32_32_r"
+ , "Madd_32_16"
+ , "Madd_32_16_r"
+ , "Msub_32_16"
+ , "Msub_32_16_r"
+ , "Madd_32_32"
+ , "Madd_32_32_r"
+ , "Msub_32_32"
+ , "Msub_32_32_r"
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+#ifdef ENH_U_32_BIT_OPERATOR
+ , "UL_addNs"
+ , "UL_subNs"
+ , "UL_Mpy_32_32"
+ , "Mpy_32_32_uu"
+ , "Mpy_32_16_uu"
+ , "norm_ul"
+ , "UL_deposit_l"
+#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
+
+#ifdef CONTROL_CODE_OPS
+ , "LT_16"
+ , "GT_16"
+ , "LE_16"
+ , "GE_16"
+ , "EQ_16"
+ , "NE_16"
+ , "LT_32"
+ , "GT_32"
+ , "LE_32"
+ , "GE_32"
+ , "EQ_32"
+ , "NE_32"
+ , "LT_64"
+ , "GT_64"
+ , "LE_64"
+ , "GE_64"
+ , "EQ_64"
+ , "NE_64"
+#endif /* #ifdef CONTROL_CODE_OPS */
+
+};
+#endif /* ifdef WMOPS */
+
+
+#ifdef WMOPS
+const BASIC_OP op_weight = {
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 2, 2, 1,
+ 1, 1, 1, 2, 1,
+
+ 1, 1, 1, 2, 1,
+ 1, 1, 18, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 1,
+
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 2,
+ 1, 2, 2, 2, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 3,
+ 3, 3, 3, 1, 1,
+ 1, 1, 1, 1, 1,
+ 1, 1, 1, 3, 2,
+ 2, 6, 3, 3, 2,
+
+ 1, 32, 1
+
+/* New complex basops */
+ #ifdef COMPLEX_OPERATOR
+ , 1, 1, 1
+ , 1, 1, 1
+ , 1, 1, 1
+ , 1, 1, 1
+ , 2, 1, 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 2
+ , 1
+
+ , 1
+ , 1, 1, 1, 2
+ , 2, 2, 1, 1
+ , 1, 1
+ , 1, 1
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+#ifdef ENH_64_BIT_OPERATOR
+ /* Weights of new 64 bit basops */
+ , 1 , 1 ,1
+ , 1 , 1
+ , 1 , 1
+ , 1 , 1 , 1
+ , 1 , 1 , 1
+ , 1 , 1 , 1
+ , 1 , 1
+ , 1 , 1 , 1
+ , 1 , 1
+ , 1 , 1
+ , 1
+ , 1 , 1 , 1 , 1
+ , 1 , 1
+ , 1 , 1 , 1
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+#ifdef ENH_32_BIT_OPERATOR
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+#ifdef ENH_U_32_BIT_OPERATOR
+ , 1
+ , 1
+ , 1
+ , 2
+ , 2
+ , 1
+ , 1
+#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
+
+#ifdef CONTROL_CODE_OPS
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+ , 1
+#endif /* #ifdef CONTROL_CODE_OPS */
+};
+#endif /* ifdef WMOPS */
+
+
+Word32 TotalWeightedOperation (void);
+Word32 DeltaWeightedOperation (void);
+
+
+#ifdef WMOPS
+/* Counters for separating counting for different objects */
+
+
+static int maxCounter = 0;
+static char *objectName[MAXCOUNTERS + 1];
+
+static Word16 fwc_corr[MAXCOUNTERS + 1];
+static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1];
+
+#define NbFuncMax 1024
+
+static Word16 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS];
+static Word32 glob_wc[MAXCOUNTERS], wc[MAXCOUNTERS][NbFuncMax];
+static float total_wmops[MAXCOUNTERS];
+
+static Word32 LastWOper[MAXCOUNTERS];
+#endif /* ifdef WMOPS */
+
+
+#ifdef WMOPS
+static char *my_strdup (const char *s) {
+ /*
+ * duplicates UNIX function strdup() which is not ANSI standard:
+ * -- malloc() memory area big enough to hold the string s
+ * -- copy string into new area
+ * -- return pointer to new area
+ *
+ * returns NULL if either s==NULL or malloc() fails
+ */
+ char *dup;
+
+ if (s == NULL)
+ return NULL;
+
+ /* allocate memory for copy of ID string (including string terminator) */
+ /* NOTE: the ID strings will never be deallocated because there is no way to "destroy" a counter that is not longer needed */
+ if ((dup = (char *) malloc (strlen (s) + 1)) == NULL)
+ return NULL;
+
+ return strcpy (dup, s);
+}
+#endif /* ifdef WMOPS */
+
+
+int getCounterId (char *objectNameArg) {
+#if WMOPS
+ if (maxCounter >= MAXCOUNTERS - 1)
+ return 0;
+ objectName[++maxCounter] = my_strdup (objectNameArg);
+ return maxCounter;
+
+#else /* ifdef WMOPS */
+ (void)objectNameArg;
+ return 0; /* Dummy */
+
+#endif /* ifdef WMOPS */
+}
+
+
+#if WMOPS
+int readCounterId () {
+ return currCounter;
+}
+#endif /* ifdef WMOPS */
+
+
+#ifdef WMOPS
+char *readCounterIdName () {
+ return objectName[currCounter];
+}
+#endif /* ifdef WMOPS */
+
+void setCounter (int counterId) {
+#if WMOPS
+ if ((counterId > maxCounter)
+ || (counterId < 0)) {
+ currCounter = 0;
+ return;
+ }
+ currCounter = counterId;
+ call_occurred = 1;
+#else
+ (void)counterId;
+#endif /* ifdef WMOPS */
+}
+
+
+void incrementNbTimeObjectIsCalled (int counterId) {
+#if WMOPS
+ if ((counterId > maxCounter)
+ || (counterId < 0)) {
+ nbTimeObjectIsCalled[0]++;
+ return;
+ }
+ nbTimeObjectIsCalled[counterId]++;
+#else
+ (void)counterId;
+#endif /* ifdef WMOPS */
+}
+
+
+#if WMOPS
+static Word32 WMOPS_frameStat (void) {
+/* calculate the WMOPS seen so far and update the global
+ per-frame maximum (glob_wc)
+ */
+ Word32 tot;
+
+ tot = TotalWeightedOperation ();
+ if (tot > glob_wc[currCounter])
+ glob_wc[currCounter] = tot;
+
+ /* check if fwc() was forgotten at end of last frame */
+ if (tot > LastWOper[currCounter]) {
+ if (!fwc_corr[currCounter]) {
+ fprintf (stderr,
+ "count: operations counted after last fwc() for '%s'; " "-> fwc() called\n",
+ objectName[currCounter] ? objectName[currCounter] : "");
+ }
+ fwc ();
+ }
+
+ return tot;
+}
+#endif /* ifdef WMOPS */
+
+
+#ifdef WMOPS
+static void WMOPS_clearMultiCounter (void) {
+ Word16 i;
+
+ Word32 *ptr = (Word32 *) & multiCounter[currCounter];
+ for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) {
+ *ptr++ = 0;
+ }
+}
+#endif /* ifdef WMOPS */
+
+
+void ClearNbTimeObjectsAreCalled () {
+#if WMOPS
+ Word16 i;
+
+ for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) {
+ nbTimeObjectIsCalled[i] = 0;
+ }
+#endif /* ifdef WMOPS */
+}
+
+Word32 TotalWeightedOperation () {
+#if WMOPS
+ Word16 i;
+ Word32 tot, *ptr, *ptr2;
+
+ tot = 0;
+ ptr = (Word32 *) & multiCounter[currCounter];
+ ptr2 = (Word32 *) & op_weight;
+ for (i = 0; i < (Word16)(sizeof (multiCounter[currCounter]) / sizeof (Word32)); i++) {
+ tot += ((*ptr++) * (*ptr2++));
+ }
+
+ return ((Word32) tot);
+
+#else /* ifdef WMOPS */
+ return 0; /* Dummy */
+
+#endif /* ifdef WMOPS */
+
+}
+
+Word32 DeltaWeightedOperation () {
+#if WMOPS
+ Word32 NewWOper, delta;
+
+ NewWOper = TotalWeightedOperation ();
+ delta = NewWOper - LastWOper[currCounter];
+ LastWOper[currCounter] = NewWOper;
+ return (delta);
+
+#else /* ifdef WMOPS */
+ return 0; /* Dummy */
+
+#endif /* ifdef WMOPS */
+}
+
+
+void Init_WMOPS_counter (void) {
+#if WMOPS
+ Word16 i;
+
+ /* reset function weight operation counter variable */
+
+ for (i = 0; i < NbFuncMax; i++)
+ wc[currCounter][i] = (Word32) 0;
+ glob_wc[currCounter] = 0;
+ nbframe[currCounter] = 0;
+ total_wmops[currCounter] = 0.0;
+
+ /* initially clear all counters */
+ WMOPS_clearMultiCounter ();
+ LastWOper[currCounter] = 0;
+ funcid[currCounter] = 0;
+
+ /* Following line is useful for incrIf(), see control.h */
+ call_occurred = 1;
+ funcId_where_last_call_to_else_occurred = MAXCOUNTERS;
+#endif /* ifdef WMOPS */
+}
+
+
+void Reset_WMOPS_counter (void) {
+#if WMOPS
+ Word32 tot = WMOPS_frameStat ();
+
+ /* increase the frame counter --> a frame is counted WHEN IT BEGINS */
+ nbframe[currCounter]++;
+
+ /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */
+ total_wmops[currCounter] += (float) (tot * frameRate);
+
+ /* clear counter before new frame starts */
+ WMOPS_clearMultiCounter ();
+ LastWOper[currCounter] = 0;
+ funcid[currCounter] = 0; /* new frame, set function id to zero */
+#endif /* ifdef WMOPS */
+}
+
+
+Word32 fwc (void) {
+/* function worst case */
+#if WMOPS
+ Word32 tot;
+
+ tot = DeltaWeightedOperation ();
+ if (tot > wc[currCounter][funcid[currCounter]])
+ wc[currCounter][funcid[currCounter]] = tot;
+
+ funcid[currCounter]++;
+ return (tot);
+
+#else /* ifdef WMOPS */
+ return 0; /* Dummy */
+
+#endif /* ifdef WMOPS */
+}
+
+void WMOPS_output (Word16 dtx_mode) {
+#if WMOPS
+ Word16 i;
+ Word32 tot, tot_wm, tot_wc;
+
+ /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum)
+ so output CAN be called in each frame without problems. The frame counter is NOT updated! */
+ tot = WMOPS_frameStat ();
+ tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate);
+
+ fprintf (stdout,
+ "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "",
+ ((float) tot) * frameRate);
+
+ if (nbframe[currCounter] != 0) {
+ fprintf (stdout, " Average=%.3f", tot_wm / (float) nbframe[currCounter]);
+ }
+ fprintf (stdout, " WorstCase=%.3f", ((float) glob_wc[currCounter]) * frameRate);
+
+ /* Worst worst case printed only when not in DTX mode */
+ if (dtx_mode == 0) {
+ tot_wc = 0L;
+ for (i = 0; i < funcid[currCounter]; i++)
+ tot_wc += wc[currCounter][i];
+ fprintf (stdout, " WorstWC=%.3f", ((float) tot_wc) * frameRate);
+ }
+ fprintf (stdout, " (%d frames)\n", nbframe[currCounter]);
+#else
+ (void)dtx_mode;
+#endif /* ifdef WMOPS */
+}
+
+
+void WMOPS_output_avg (Word16 dtx_mode, Word32 * tot_wm, Word16 * num_frames) {
+#if WMOPS
+ Word16 i;
+ Word32 tot, tot_wc;
+
+ /* get operations since last reset (or init), but do not update the counters (except the glob_wc[] maximum)
+ so output CAN be called in each frame without problems. The frame counter is NOT updated! */
+ tot = WMOPS_frameStat ();
+ *tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate);
+ *num_frames = nbframe[currCounter];
+
+ fprintf (stdout, "%10s:WMOPS=%.3f", objectName[currCounter] ? objectName[currCounter] : "", ((float) tot) * frameRate);
+
+ if (nbframe[currCounter] != 0) {
+ fprintf (stdout, " Average=%.3f", *tot_wm / (float) nbframe[currCounter]);
+ }
+ fprintf (stdout, " WorstCase=%.3f", ((float) glob_wc[currCounter]) * frameRate);
+
+ /* Worst worst case printed only when not in DTX mode */
+ if (dtx_mode == 0) {
+ tot_wc = 0L;
+ for (i = 0; i < funcid[currCounter]; i++)
+ tot_wc += wc[currCounter][i];
+ fprintf (stdout, " WorstWC=%.3f", ((float) tot_wc) * frameRate);
+ }
+ fprintf (stdout, " (%d frames)\n", nbframe[currCounter]);
+#else
+ (void)dtx_mode;
+ (void)tot_wm;
+ (void)num_frames;
+#endif /* ifdef WMOPS */
+}
+
+void generic_WMOPS_output (Word16 dtx_mode, char *test_file_name) {
+#if WMOPS
+ int saved_value;
+ Word16 i;
+ Word32 tot, tot_wm, tot_wc, *ptr, *ptr2;
+ Word40 grand_total;
+ FILE *WMOPS_file;
+
+ saved_value = currCounter;
+
+ /* Count the grand_total WMOPS so that % ratio per function group can be displayed. */
+ grand_total = 0;
+ for (currCounter = 0; currCounter <= maxCounter; currCounter++) {
+ tot = WMOPS_frameStat ();
+ grand_total += tot;
+ }
+
+
+ if ((WMOPS_file = fopen (WMOPS_DATA_FILENAME, "a")) != NULL) {
+
+ printf ("opened file %s in order to print WMOPS for each function group.\n", WMOPS_DATA_FILENAME);
+
+ /* Print the file header line. */
+ fprintf (WMOPS_file, "Test file name\tFunction Name \tFrame\tNb Times Called\tWMOPS\t%% versus grand total");
+
+ if (nbframe[saved_value] != 0)
+ fprintf (WMOPS_file, "\tAverage");
+
+ fprintf (WMOPS_file, "\tWorstCase");
+
+ /* Worst worst case printed only when not in DTX mode */
+ if (dtx_mode == 0)
+ fprintf (WMOPS_file, "\tWorstWC");
+
+ fprintf (WMOPS_file, "\n");
+
+ /* Print the WMOPS for each Function Group by scanning all the function groups with currCounter index. */
+ for (currCounter = 0; currCounter <= maxCounter; currCounter++) {
+
+ fprintf (WMOPS_file, "%s", test_file_name);
+ fprintf (WMOPS_file, "\t%s", objectName[currCounter] ? objectName[currCounter] : "");
+ fprintf (WMOPS_file, "\t%d", nbframe[currCounter]);
+
+ tot = WMOPS_frameStat ();
+ tot_wm = (Word32) (total_wmops[currCounter] + ((float) tot) * frameRate);
+
+ fprintf (WMOPS_file, "\t\t%ld", nbTimeObjectIsCalled[currCounter]);
+ fprintf (WMOPS_file, "\t%.6f", ((float) tot) * frameRate);
+ fprintf (WMOPS_file, "\t%.3f", ((float) tot) / grand_total * 100);
+
+ if (nbframe[currCounter] != 0)
+ fprintf (WMOPS_file, "\t%.3f", tot_wm / (float) nbframe[currCounter]);
+
+ fprintf (WMOPS_file, "\t%.3f", ((float) glob_wc[currCounter]) * frameRate);
+
+ /* Worst worst case printed only when not in DTX mode */
+ if (dtx_mode == 0) {
+ tot_wc = 0L;
+ for (i = 0; i < funcid[currCounter]; i++)
+ tot_wc += wc[currCounter][i];
+ fprintf (WMOPS_file, "\t%.3f", ((float) tot_wc) * frameRate);
+ }
+ fprintf (WMOPS_file, "\n");
+
+ }
+
+ /* Print the file Grand Total line */
+ fprintf (WMOPS_file, "%s", test_file_name);
+ fprintf (WMOPS_file, "\tGrand Total");
+ fprintf (WMOPS_file, "\t%d", nbframe[saved_value]);
+ fprintf (WMOPS_file, "\t\t%.6f", ((float) grand_total) * frameRate);
+ fprintf (WMOPS_file, "\t100.000");
+ fprintf (WMOPS_file, "\n");
+ fclose (WMOPS_file);
+
+ } else
+ printf ("Can not open file %s for WMOPS editing\n", WMOPS_DATA_FILENAME);
+
+
+ if ((WMOPS_file = fopen (WMOPS_TOTAL_FILENAME, "a")) != NULL) {
+ printf ("opened file %s in order to print application's total WMOPS.\n", WMOPS_TOTAL_FILENAME);
+ fprintf (WMOPS_file, "%s", test_file_name);
+ fprintf (WMOPS_file, "\tframe=%d", nbframe[currCounter]);
+ fprintf (WMOPS_file, "\tWMOPS=%.6f", ((float) grand_total) * frameRate);
+ fprintf (WMOPS_file, "\n");
+ fclose (WMOPS_file);
+
+ } else
+ printf ("Can not open file %s for WMOPS editing.\n", WMOPS_TOTAL_FILENAME);
+
+
+ if ((WMOPS_file = fopen (CODE_PROFILE_FILENAME, "a")) != NULL) {
+
+ printf ("opened file %s in order to print basic operation distribution statistics.\n", CODE_PROFILE_FILENAME);
+
+ /* Print the file header line. */
+ fprintf (WMOPS_file, "Test file name\tBasic Operation Name\tframe\tWMOPS\t\t%% versus grand total\n");
+
+ /* Print the WMOPS for each Basic Operation across all the defined */
+ /* Function Groups. */
+ for (i = 0; i < (Word16)(sizeof (op_weight) / sizeof (Word32)); i++) {
+ fprintf (WMOPS_file, "%-16s", test_file_name);
+ fprintf (WMOPS_file, "\t%s", BasicOperationList[i]);
+ fprintf (WMOPS_file, "\t%d", nbframe[0]);
+
+ tot = 0;
+ ptr = (Word32 *) & multiCounter[0] + i;
+ ptr2 = (Word32 *) & op_weight + i;
+ for (currCounter = 0; currCounter <= maxCounter; currCounter++) {
+ tot += ((*ptr) * (*ptr2));
+ ptr += (sizeof (op_weight) / sizeof (Word32));
+ }
+
+ fprintf (WMOPS_file, "\t%.6f", ((float) tot) * frameRate);
+ fprintf (WMOPS_file, "\t%.3f", ((float) tot) / grand_total * 100);
+ fprintf (WMOPS_file, "\n");
+ }
+
+ /* Print the file Grand Total line */
+ fprintf (WMOPS_file, "%s", test_file_name);
+ fprintf (WMOPS_file, "\tGrand Total");
+ fprintf (WMOPS_file, "\t%d", nbframe[saved_value]);
+ fprintf (WMOPS_file, "\t%.6f", ((float) grand_total) * frameRate);
+ fprintf (WMOPS_file, "\t100.000");
+ fprintf (WMOPS_file, "\n");
+ fclose (WMOPS_file);
+
+ } else
+ printf ("Can not open file %s for basic operations distribution statistic editing\n", CODE_PROFILE_FILENAME);
+
+ currCounter = saved_value;
+
+#else
+ (void)dtx_mode;
+ (void)test_file_name;
+#endif /* ifdef WMOPS */
+}
+
+
+/* end of file */
diff --git a/basic_op/count.h b/basic_op/count.h
new file mode 100644
index 0000000000000000000000000000000000000000..e173de624f8db442f68d729c1db3713e591f471b
--- /dev/null
+++ b/basic_op/count.h
@@ -0,0 +1,542 @@
+/*
+ ===========================================================================
+ File: COUNT.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ PROTOTYPES & DEFINITION FOR COUNTING OPERATIONS
+
+ History
+ 09.Aug.1999 V1.0.0 Input to UGST from ETSI AMR (count.h);
+
+ 26.Jan.2000 V1.1.0 Added counter entries for G.723.1's
+ L_mls(), div_l(), i_mult() [from basop32.c]
+
+ 05.Jul.2000 V1.2.0 Added counter entries for 32bit shiftless
+ operators L_mult0(), L_mac0(), L_msu0()
+
+ 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+ Dec 06 v2.2 Changed to specify frame rate using setFrameRate()
+ Adding WMOPS_output_avg() for global average computation
+ L_mls() weight of 5.
+ div_l() weight of 32.
+ i_mult() weight of 3.
+ ============================================================================
+*/
+
+
+/******************************************************************************
+ * Functions for counting operations.
+ *
+ * These functions make it possible to measure the wMOPS of a codec.
+ *
+ * All functions in this file, and in other *.h files, update a structure so
+ * that it will be possible to track how many calls to add(), sub(), L_mult()
+ * ... was made by the code and to estimate the wMOPS (and MIPS) for a certain
+ * part of the code.
+ *
+ * It is also possible to measure the wMOPS separatly for different parts
+ * of the codec.
+ *
+ * This is done by creating a counter group (getCounterId) for each part of
+ * the code that one wants a seperate measure for. Before a part of the code
+ * is executed a call to the "setCounter" function is needed to identify
+ * which counter group to use.
+ *
+ * Currently there is a limit of 255 different counter groups.
+ *
+ * In the end of this file, there is a piece of code illustrating how the
+ * functions can be used.
+ *
+******************************************************************************/
+
+
+#ifndef _COUNT_H
+#define _COUNT_H "$Id$"
+#if 0
+#define WMOPS 1 /* enable WMOPS profiling features */
+#undef WMOPS /* disable WMOPS profiling features */
+#endif
+#define MAXCOUNTERS (256)
+
+
+#define BASOP_sub_start(label)
+#define BASOP_sub_end()
+#define SUB_WMOPS_INIT(label) BASOP_sub_start(label)
+#define END_SUB_WMOPS BASOP_sub_end()
+#define BASOP_push_wmops(label)
+#define BASOP_pop_wmops()
+#define BASOP_end_noprint
+#define BASOP_end
+#define BASOP_init
+
+int getCounterId (char *objectName);
+/*
+ * Create a counter group, the "objectname" will be used when printing
+ * statistics for this counter group.
+ *
+ * Returns 0 if no more counter groups are available.
+ */
+
+
+int readCounterId (void);
+/*
+ * Returns the current CounterId.
+ */
+
+
+void setCounter (int counterId);
+/*
+ * Defines which counter group to use, default is zero.
+ */
+
+
+char *readCounterIdName (void);
+/*
+ * Returns the current CounterId name.
+ */
+
+
+void incrementNbTimeObjectIsCalled (int counterId);
+/*
+ * This function enables to increment by 1 a counter
+ * tracking the number of times the application enters a groups of functions.
+ * If the counterId is not refering to a defined function counter group, then it is
+ * the default function group (0) which is impacted.
+ *
+ */
+
+
+void ClearNbTimeObjectsAreCalled (void);
+/*
+ * This function enables to clear to 0 all the counters enabling to
+ * track the number of times the application enters any groups of functions.
+ */
+
+
+void Init_WMOPS_counter (void);
+/*
+ * Initiates the current counter group.
+ */
+
+
+void Reset_WMOPS_counter (void);
+/*
+ * Resets the current counter group.
+ */
+
+
+void WMOPS_output (Word16 notPrintWorstWorstCase);
+/*
+ * Prints the statistics to the screen, if the argument is non zero
+ * the statistics for worst worst case will not be printed. This is typically
+ * done for dtx frames.
+ *
+ */
+
+void WMOPS_output_avg (Word16 dtx_mode, Word32 * tot_wm, Word16 * num_frames);
+/*
+ * same as WMOPS_output + returns the total wmops counter and the number of frames
+ * to support the computation of global average.
+ *
+ */
+
+
+Word32 fwc (void);
+/*
+ * worst worst case counter.
+ *
+ * This function calculates the worst possible case that can be reached.
+ *
+ * This is done by calling this function for each subpart of the calculations
+ * for a frame. This function then stores the maximum wMOPS for each part.
+ *
+ * The WMOPS_output function add together all parts and presents the sum.
+ */
+
+void setFrameRate (int samplingFreq, int frameLength);
+/*
+ * This function can overwrite the value of the frameRate variable that is
+ * initialized by the FRAME_RATE constant.
+ */
+
+
+#define WMOPS_DATA_FILENAME "wmops_data.txt"
+/*
+ * WMOPS_DATA_FILENAME is the macro defining the name of the file
+ * where the Weighted Million of Operations per Second (wMOPS)
+ * are appended, function group by function group.
+*/
+
+
+#define CODE_PROFILE_FILENAME "code_profile.txt"
+/*
+ * CODE_PROFILE_FILENAME is the macro defining the name of the file
+ * where the Weighted Million of Operations per Second (WMOPS)
+ * are appended, basic operation by basic operation.
+*/
+
+
+#define WMOPS_TOTAL_FILENAME "wmops_total.txt"
+/*
+ * WMOPS_TOTAL_FILENAME is the macro defining the name of the file
+ * where the Weighted Million of Operations per Second (WMOPS)
+ * are printed, globally for the application.
+*/
+
+
+#define FRAME_RATE (0.0001F) /* in this version frame_rate can be overwriten online by the new setFrameRate function */
+/* FRAME_RATE of 0.000025 is corresponding to 40ms frame.*/
+/* FRAME_RATE of 0.00005 is corresponding to 20ms frame.*/
+/* FRAME_RATE of 0.0001 is corresponding to 10ms frame.*/
+/*
+ * FRAME_RATE is the macro defining the calling rate of the
+ * application to benchmark.
+*/
+
+
+/* Global counter variable for calculation of complexity weight */
+typedef struct {
+ UWord32 add; /* Complexity Weight of 1 */
+ UWord32 sub; /* Complexity Weight of 1 */
+ UWord32 abs_s; /* Complexity Weight of 1 */
+ UWord32 shl; /* Complexity Weight of 1 */
+ UWord32 shr; /* Complexity Weight of 1 */
+
+ UWord32 extract_h; /* Complexity Weight of 1 */
+ UWord32 extract_l; /* Complexity Weight of 1 */
+ UWord32 mult; /* Complexity Weight of 1 */
+ UWord32 L_mult; /* Complexity Weight of 1 */
+ UWord32 negate; /* Complexity Weight of 1 */
+
+ UWord32 round; /* Complexity Weight of 1 */
+ UWord32 L_mac; /* Complexity Weight of 1 */
+ UWord32 L_msu; /* Complexity Weight of 1 */
+ UWord32 L_macNs; /* Complexity Weight of 1 */
+ UWord32 L_msuNs; /* Complexity Weight of 1 */
+
+ UWord32 L_add; /* Complexity Weight of 1 */
+ UWord32 L_sub; /* Complexity Weight of 1 */
+ UWord32 L_add_c; /* Complexity Weight of 2 */
+ UWord32 L_sub_c; /* Complexity Weight of 2 */
+ UWord32 L_negate; /* Complexity Weight of 1 */
+
+ UWord32 L_shl; /* Complexity Weight of 1 */
+ UWord32 L_shr; /* Complexity Weight of 1 */
+ UWord32 mult_r; /* Complexity Weight of 1 */
+ UWord32 shr_r; /* Complexity Weight of 3 */
+ UWord32 mac_r; /* Complexity Weight of 1 */
+
+ UWord32 msu_r; /* Complexity Weight of 1 */
+ UWord32 L_deposit_h; /* Complexity Weight of 1 */
+ UWord32 L_deposit_l; /* Complexity Weight of 1 */
+ UWord32 L_shr_r; /* Complexity Weight of 3 */
+ UWord32 L_abs; /* Complexity Weight of 1 */
+
+ UWord32 L_sat; /* Complexity Weight of 4 */
+ UWord32 norm_s; /* Complexity Weight of 1 */
+ UWord32 div_s; /* Complexity Weight of 18 */
+ UWord32 norm_l; /* Complexity Weight of 1 */
+ UWord32 move16; /* Complexity Weight of 1 */
+
+ UWord32 move32; /* Complexity Weight of 2 */
+ UWord32 Logic16; /* Complexity Weight of 1 */
+ UWord32 Logic32; /* Complexity Weight of 2 */
+ UWord32 Test; /* Complexity Weight of 2 */
+ UWord32 s_max; /* Complexity Weight of 1 */
+
+ UWord32 s_min; /* Complexity Weight of 1 */
+ UWord32 L_max; /* Complexity Weight of 1 */
+ UWord32 L_min; /* Complexity Weight of 1 */
+ UWord32 L40_max; /* Complexity Weight of 1 */
+ UWord32 L40_min; /* Complexity Weight of 1 */
+
+ UWord32 shl_r; /* Complexity Weight of 2 */
+ UWord32 L_shl_r; /* Complexity Weight of 2 */
+ UWord32 L40_shr_r; /* Complexity Weight of 2 */
+ UWord32 L40_shl_r; /* Complexity Weight of 2 */
+ UWord32 norm_L40; /* Complexity Weight of 1 */
+
+ UWord32 L40_shl; /* Complexity Weight of 1 */
+ UWord32 L40_shr; /* Complexity Weight of 1 */
+ UWord32 L40_negate; /* Complexity Weight of 1 */
+ UWord32 L40_add; /* Complexity Weight of 1 */
+ UWord32 L40_sub; /* Complexity Weight of 1 */
+
+ UWord32 L40_abs; /* Complexity Weight of 1 */
+ UWord32 L40_mult; /* Complexity Weight of 1 */
+ UWord32 L40_mac; /* Complexity Weight of 1 */
+ UWord32 mac_r40; /* Complexity Weight of 2 */
+
+ UWord32 L40_msu; /* Complexity Weight of 1 */
+ UWord32 msu_r40; /* Complexity Weight of 2 */
+ UWord32 Mpy_32_16_ss; /* Complexity Weight of 2 */
+ UWord32 Mpy_32_32_ss; /* Complexity Weight of 2 */
+ UWord32 L_mult0; /* Complexity Weight of 1 */
+
+ UWord32 L_mac0; /* Complexity Weight of 1 */
+ UWord32 L_msu0; /* Complexity Weight of 1 */
+ UWord32 lshl; /* Complexity Weight of 1 */
+ UWord32 lshr; /* Complexity Weight of 1 */
+ UWord32 L_lshl; /* Complexity Weight of 1 */
+
+ UWord32 L_lshr; /* Complexity Weight of 1 */
+ UWord32 L40_lshl; /* Complexity Weight of 1 */
+ UWord32 L40_lshr; /* Complexity Weight of 1 */
+ UWord32 s_and; /* Complexity Weight of 1 */
+ UWord32 s_or; /* Complexity Weight of 1 */
+
+ UWord32 s_xor; /* Complexity Weight of 1 */
+ UWord32 L_and; /* Complexity Weight of 1 */
+ UWord32 L_or; /* Complexity Weight of 1 */
+ UWord32 L_xor; /* Complexity Weight of 1 */
+ UWord32 rotl; /* Complexity Weight of 3 */
+
+ UWord32 rotr; /* Complexity Weight of 3 */
+ UWord32 L_rotl; /* Complexity Weight of 3 */
+ UWord32 L_rotr; /* Complexity Weight of 3 */
+ UWord32 L40_set; /* Complexity Weight of 1 */
+ UWord32 L40_deposit_h; /* Complexity Weight of 1 */
+
+ UWord32 L40_deposit_l; /* Complexity Weight of 1 */
+ UWord32 L40_deposit32; /* Complexity Weight of 1 */
+ UWord32 Extract40_H; /* Complexity Weight of 1 */
+ UWord32 Extract40_L; /* Complexity Weight of 1 */
+ UWord32 L_Extract40; /* Complexity Weight of 1 */
+
+ UWord32 L40_round; /* Complexity Weight of 1 */
+ UWord32 L_saturate40; /* Complexity Weight of 1 */
+ UWord32 round40; /* Complexity Weight of 1 */
+ UWord32 If; /* Complexity Weight of 3 */
+ UWord32 Goto; /* Complexity Weight of 2 */
+
+ UWord32 Break; /* Complexity Weight of 2 */
+ UWord32 Switch; /* Complexity Weight of 6 */
+ UWord32 For; /* Complexity Weight of 3 */
+ UWord32 While; /* Complexity Weight of 3 */
+ UWord32 Continue; /* Complexity Weight of 2 */
+
+ UWord32 L_mls; /* Complexity Weight of 1 */
+ UWord32 div_l; /* Complexity Weight of 32 */
+ UWord32 i_mult; /* Complexity Weight of 1 */
+
+/* New complex basic operators */
+#ifdef COMPLEX_OPERATOR
+ UWord32 CL_shr; /* Complexity Weight of 1 */
+ UWord32 CL_shl; /* Complexity Weight of 1 */
+ UWord32 CL_add; /* Complexity Weight of 1 */
+ UWord32 CL_sub; /* Complexity Weight of 1 */
+ UWord32 CL_scale; /* Complexity Weight of 1 */
+ UWord32 CL_dscale; /* Complexity Weight of 1 */
+ UWord32 CL_msu_j; /* Complexity Weight of 1 */
+ UWord32 CL_mac_j; /* Complexity Weight of 1 */
+ UWord32 CL_move; /* Complexity Weight of 1 */
+ UWord32 CL_Extract_real; /* Complexity Weight of 1 */
+ UWord32 CL_Extract_imag; /* Complexity Weight of 1 */
+ UWord32 CL_form; /* Complexity Weight of 1 */
+ UWord32 CL_multr_32x16; /* Complexity Weight of 2 */
+ UWord32 CL_negate; /* Complexity Weight of 1 */
+ UWord32 CL_conjugate; /* Complexity Weight of 1 */
+ UWord32 CL_mul_j; /* Complexity Weight of 1 */
+ UWord32 CL_swap_real_imag; /* Complexity Weight of 1 */
+ UWord32 C_add; /* Complexity Weight of 1 */
+ UWord32 C_sub; /* Complexity Weight of 1 */
+ UWord32 C_mul_j; /* Complexity Weight of 1 */
+ UWord32 C_multr; /* Complexity Weight of 2 */
+ UWord32 C_form; /* Complexity Weight of 1 */
+
+ UWord32 C_scale; /* Complexity Weight of 1 */
+ UWord32 CL_round32_16; /* Complexity Weight of 1 */
+ UWord32 CL_scale_32; /* Complexity Weight of 1 */
+ UWord32 CL_dscale_32; /* Complexity Weight of 1 */
+ UWord32 CL_multr_32x32; /* Complexity Weight of 2 */
+ UWord32 C_mac_r; /* Complexity Weight of 2 */
+ UWord32 C_msu_r; /* Complexity Weight of 2 */
+ UWord32 C_Extract_real; /* Complexity Weight of 1 */
+ UWord32 C_Extract_imag; /* Complexity Weight of 1 */
+ UWord32 C_negate; /* Complexity Weight of 1 */
+ UWord32 C_conjugate; /* Complexity Weight of 1 */
+ UWord32 C_shr; /* Complexity Weight of 1 */
+ UWord32 C_shl; /* Complexity Weight of 1 */
+
+#endif /* #ifdef COMPLEX_OPERATOR */
+
+/* New 64 bit basops */
+#ifdef ENH_64_BIT_OPERATOR
+ UWord32 move64; /* Complexity Weight of 1 */
+ UWord32 W_add_nosat; /* Complexity Weight of 1 */
+ UWord32 W_sub_nosat; /* Complexity Weight of 1 */
+ UWord32 W_shl; /* Complexity Weight of 1 */
+ UWord32 W_shr; /* Complexity Weight of 1 */
+ UWord32 W_shl_nosat; /* Complexity Weight of 1 */
+ UWord32 W_shr_nosat; /* Complexity Weight of 1 */
+ UWord32 W_mac_32_16; /* Complexity Weight of 1 */
+ UWord32 W_msu_32_16; /* Complexity Weight of 1 */
+ UWord32 W_mult_32_16; /* Complexity Weight of 1 */
+ UWord32 W_mult0_16_16; /* Complexity Weight of 1 */
+ UWord32 W_mac0_16_16; /* Complexity Weight of 1 */
+ UWord32 W_msu0_16_16; /* Complexity Weight of 1 */
+ UWord32 W_mult_16_16; /* Complexity Weight of 1 */
+ UWord32 W_mac_16_16; /* Complexity Weight of 1 */
+ UWord32 W_msu_16_16; /* Complexity Weight of 1 */
+ UWord32 W_shl_sat_l; /* Complexity Weight of 1 */
+ UWord32 W_sat_l; /* Complexity Weight of 1 */
+ UWord32 W_sat_m; /* Complexity Weight of 1 */
+ UWord32 W_deposit32_l; /* Complexity Weight of 1 */
+ UWord32 W_deposit32_h; /* Complexity Weight of 1 */
+ UWord32 W_extract_l; /* Complexity Weight of 1 */
+ UWord32 W_extract_h; /* Complexity Weight of 1 */
+ UWord32 W_round48_L; /* Complexity Weight of 1 */
+ UWord32 W_round32_s; /* Complexity Weight of 1 */
+ UWord32 W_norm; /* Complexity Weight of 1 */
+
+ UWord32 W_add; /* Complexity Weight of 1 */
+ UWord32 W_sub; /* Complexity Weight of 1 */
+ UWord32 W_neg; /* Complexity Weight of 1 */
+ UWord32 W_abs; /* Complexity Weight of 1 */
+ UWord32 W_mult_32_32; /* Complexity Weight of 1 */
+ UWord32 W_mult0_32_32; /* Complexity Weight of 1 */
+ UWord32 W_lshl; /* Complexity Weight of 1 */
+ UWord32 W_lshr; /* Complexity Weight of 1 */
+ UWord32 W_round64_L; /* Complexity Weight of 1 */
+
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+#ifdef ENH_32_BIT_OPERATOR
+ UWord32 Mpy_32_16_1; /* Complexity Weight of 1 */
+ UWord32 Mpy_32_16_r; /* Complexity Weight of 1 */
+ UWord32 Mpy_32_32; /* Complexity Weight of 1 */
+ UWord32 Mpy_32_32_r; /* Complexity Weight of 1 */
+ UWord32 Madd_32_16; /* Complexity Weight of 1 */
+ UWord32 Madd_32_16_r; /* Complexity Weight of 1 */
+ UWord32 Msub_32_16; /* Complexity Weight of 1 */
+ UWord32 Msub_32_16_r; /* Complexity Weight of 1 */
+ UWord32 Madd_32_32; /* Complexity Weight of 1 */
+ UWord32 Madd_32_32_r; /* Complexity Weight of 1 */
+ UWord32 Msub_32_32; /* Complexity Weight of 1 */
+ UWord32 Msub_32_32_r; /* Complexity Weight of 1 */
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+#ifdef ENH_U_32_BIT_OPERATOR
+ UWord32 UL_addNs; /* Complexity Weight of 1 */
+ UWord32 UL_subNs; /* Complexity Weight of 1 */
+ UWord32 UL_Mpy_32_32; /* Complexity Weight of 1 */
+ UWord32 Mpy_32_32_uu; /* Complexity Weight of 2 */
+ UWord32 Mpy_32_16_uu; /* Complexity Weight of 2 */
+ UWord32 norm_ul; /* Complexity Weight of 1 */
+ UWord32 UL_deposit_l; /* Complexity Weight of 1 */
+#endif /* #ifdef ENH_U_32_BIT_OPERATOR */
+
+#ifdef CONTROL_CODE_OPS
+ UWord32 LT_16; /* Complexity Weight of 1 */
+ UWord32 GT_16; /* Complexity Weight of 1 */
+ UWord32 LE_16; /* Complexity Weight of 1 */
+ UWord32 GE_16; /* Complexity Weight of 1 */
+ UWord32 EQ_16; /* Complexity Weight of 1 */
+ UWord32 NE_16; /* Complexity Weight of 1 */
+ UWord32 LT_32; /* Complexity Weight of 1 */
+ UWord32 GT_32; /* Complexity Weight of 1 */
+ UWord32 LE_32; /* Complexity Weight of 1 */
+ UWord32 GE_32; /* Complexity Weight of 1 */
+ UWord32 EQ_32; /* Complexity Weight of 1 */
+ UWord32 NE_32; /* Complexity Weight of 1 */
+ UWord32 LT_64; /* Complexity Weight of 1 */
+ UWord32 GT_64; /* Complexity Weight of 1 */
+ UWord32 LE_64; /* Complexity Weight of 1 */
+ UWord32 GE_64; /* Complexity Weight of 1 */
+ UWord32 EQ_64; /* Complexity Weight of 1 */
+ UWord32 NE_64; /* Complexity Weight of 1 */
+
+#endif /* #ifdef CONTROL_CODE_OPS */
+} BASIC_OP;
+
+
+Word32 TotalWeightedOperation (void);
+Word32 DeltaWeightedOperation (void);
+
+
+void generic_WMOPS_output (Word16 notPrintWorstWorstCase, char *test_file_name);
+/*
+ * This function enable to append :
+ * - to WMOPS_DATA_FILENAME file, the WMOPS information related
+ * to the execution of the application, function group by function
+ * group.
+ * - to CODE_PROFILE_FILENAME file, the WMOPS information related
+ * to the execution of the application, basic operation by basic
+ * operation.
+ * - to WMOPS_TOTAL_FILENAME file, the total WMOPS information related
+ * to the execution of the application.
+ *
+ * Note that :
+ * if the files exists, the data will be written at the end of file.
+ *
+ * test_file_name : Is a character string referencing each calls to
+ * generic_WMOPS_output(). Usually, it is the name of a test
+ * sequence file.
+ *
+ * notPrintWorstWorstCase : Same usage as in WMOPS_output().
+ */
+
+
+#if 0
+/*
+ * Example of how count.h could be used.
+ *
+ * In the example below it is assumed that the init_OBJECT functions
+ * does not use any calls to counter.h or basic_op.h. If this is the case
+ * a call to the function Reset_WMOPS_counter() must be done after each call
+ * to init_OBJECT if these operations is not to be included in the statistics.
+ */
+
+int main () {
+ int spe1Id, spe2Id, cheId;
+
+ /* initiate counters and objects */
+ spe1Id = getCounterId ("Spe 5k8");
+ setCounter (spe1Id);
+ Init_WMOPS_counter ();
+ init_spe1 ( ...);
+
+ spe2Id = getCounterId ("Spe 12k2");
+ setCounter (spe2Id);
+ Init_WMOPS_counter ();
+ init_spe2 ( ...);
+
+ cheId = getCounterId ("Channel encoder");
+ setCounter (cheId);
+ Init_WMOPS_counter ();
+ init_che ( ...);
+ ... while (data) {
+ test (); /* Note this call to test(); */
+ if (useSpe1)
+ setCounter (spe1Id);
+ else
+ setCounter (spe2Id);
+ Reset_WMOPS_counter ();
+ speEncode ( ...);
+ WMOPS_output (0); /* Normal routine for displaying WMOPS info */
+
+ setCounter (cheId);
+ Reset_WMOPS_counter ();
+ preChannelInter ( ...);
+ fwc (); /* Note the call to fwc() for each part */
+ convolve ( ...);
+ fwc (); /* of the channel encoder. */
+ interleave ( ...);
+ fwc ();
+ WMOPS_output (0); /* Normal routine for displaying WMOPS info */
+ }
+}
+#endif /* #if 0 */
+
+
+#endif /* _COUNT_H */
+
+
+/* end of file */
diff --git a/basic_op/enh1632.c b/basic_op/enh1632.c
new file mode 100644
index 0000000000000000000000000000000000000000..aa3d16b2f2316d81a3923eab730bc69d53c3678e
--- /dev/null
+++ b/basic_op/enh1632.c
@@ -0,0 +1,664 @@
+/*
+ ===========================================================================
+ File: ENH1632.C v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ ENHANCED 16-BIT & 32-BIT ARITHMETIC OPERATORS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+
+ ============================================================================
+*/
+
+
+ /*****************************************************************************
+ *
+ * Enhanced 16/32 bit operators :
+ * s_max()
+ * s_min()
+ * L_max()
+ * L_min()
+ * shl_r()
+ * L_shl_r()
+ * L_mac0()
+ * L_mult0()
+ * L_msu0()
+ * s_and()
+ * s_or()
+ * s_xor()
+ * L_and()
+ * L_or()
+ * lshl()
+ * lshr()
+ * L_lshl()
+ * L_lshr()
+ * rotr()
+ * rotl()
+ * L_rotr()
+ * L_rotl()
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Include-Files
+ *
+ *****************************************************************************/
+#include
+#include
+#include "stl.h"
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* ifdef WMOPS */
+
+
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Functions
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Function Name : lshl
+ *
+ * Purpose :
+ *
+ * Logically shifts left var1 by var2 positions.
+ * - If var2 is negative, var1 is shifted to the LSBits by (-var2)
+ * positions with insertion of 0 at the MSBit.
+ * - If var2 is positive, var1 is shifted to the MSBits by (var2)
+ * positions.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value:
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+Word16 lshl (Word16 var1, Word16 var2) {
+ Word16 var_out = 0;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ var_out = lshr (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].lshr--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ if (var2 == 0 || var1 == 0) {
+ var_out = var1;
+ } else if (var2 >= 16) {
+ var_out = 0;
+ } else {
+ var_out = var1 << var2;
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].lshl++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+/*****************************************************************************
+ *
+ * Function Name : lshr
+ *
+ * Purpose :
+ *
+ * Logically shifts right var1 by var2 positions.
+ * - If var2 is positive, var1 is shifted to the LSBits by (var2)
+ * positions with insertion of 0 at the MSBit.
+ * - If var2 is negative, var1 is shifted to the MSBits by (-var2)
+ * positions.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value:
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+Word16 lshr (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ var_out = lshl (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].lshl--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ if (var2 == 0 || var1 == 0) {
+ var_out = var1;
+ } else if (var2 >= 16) {
+ var_out = 0;
+ } else {
+ var_out = var1 >> 1;
+ var_out = var_out & 0x7fff;
+ var_out = var_out >> (var2 - 1);
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].lshr++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_lshl
+ *
+ * Purpose :
+ *
+ * Logically shifts left L_var1 by var2 positions.
+ * - If var2 is negative, L_var1 is shifted to the LSBits by (-var2)
+ * positions with insertion of 0 at the MSBit.
+ * - If var2 is positive, L_var1 is shifted to the MSBits by (var2)
+ * positions.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in
+ * the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value:
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in
+ * the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+Word32 L_lshl (Word32 L_var1, Word16 var2) {
+ Word32 L_var_out = 0;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L_var_out = L_lshr (L_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_lshr--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ if (var2 == 0 || L_var1 == 0) {
+ L_var_out = L_var1;
+ } else if (var2 >= 32) {
+ L_var_out = 0;
+ } else {
+ L_var_out = L_var1 << var2;
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_lshl++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_lshr
+ *
+ * Purpose :
+ *
+ * Logically shifts right L_var1 by var2 positions.
+ * - If var2 is positive, L_var1 is shifted to the LSBits by (var2)
+ * positions with insertion of 0 at the MSBit.
+ * - If var2 is negative, L_var1 is shifted to the MSBits by (-var2)
+ * positions.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in
+ * the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value:
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in
+ * the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+Word32 L_lshr (Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L_var_out = L_lshl (L_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_lshl--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ if (var2 == 0 || L_var1 == 0) {
+ L_var_out = L_var1;
+ } else if (var2 >= 32) {
+ L_var_out = 0;
+ } else {
+ L_var_out = L_var1 >> 1;
+ L_var_out = L_var_out & 0x7fffffff;
+ L_var_out = L_var_out >> (var2 - 1);
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L_lshr++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : shl_r
+ *
+ * Purpose :
+ *
+ * Identical to shl( var1, var2) but with rounding. Saturates the result
+ * in case of underflows or overflows.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+Word16 shl_r (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ if (var2 >= 0) {
+ var_out = shl (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].shl--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ var2 = -var2;
+ var_out = shr_r (var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].shr_r--;
+#endif /* ifdef WMOPS */
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].shl_r++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_shl_r
+ *
+ * Purpose :
+ *
+ * Same as L_shl( var1, var2) but with rounding. Saturates the result in
+ * case of underflows or overflows.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+Word32 L_shl_r (Word32 L_var1, Word16 var2) {
+ Word32 var_out;
+
+ if (var2 >= 0) {
+ var_out = L_shl (L_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_shl--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ var2 = -var2;
+ var_out = L_shr_r (L_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_shr_r--;
+#endif /* ifdef WMOPS */
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L_shl_r++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : rotr
+ *
+ * Purpose :
+ *
+ * Performs a 16-bit logical rotation of var1 by 1 bit to the LSBits. The
+ * MSBit is set to var2 bit 0. The LSBit of var1 is kept in *var3 bit 0.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value must be 0
+ * or 1.
+ *
+ * Outputs :
+ *
+ * *var3 Points on a 16 bit short signed integer (Word16) whose
+ * value will be 0 or 1.
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+Word16 rotr (Word16 var1, Word16 var2, Word16 * var3) {
+ Word16 var_out;
+
+ *var3 = s_and (var1, 0x1);
+ var_out = s_or (lshr (var1, 1), lshl (var2, 15));
+
+#if (WMOPS)
+ multiCounter[currCounter].s_and--;
+ multiCounter[currCounter].lshl--;
+ multiCounter[currCounter].lshr--;
+ multiCounter[currCounter].s_or--;
+ multiCounter[currCounter].rotr++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : rotl
+ *
+ * Purpose :
+ *
+ * Performs a 16-bit logical rotation of var1 by 1 bit to the MSBits. The
+ * LSBit is set to var2 bit 0. The MSBit of var1 is kept in *var3 bit 0.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value must be 0
+ * or 1.
+ *
+ * Outputs :
+ *
+ * *var3 Points on a 16 bit short signed integer (Word16) whose
+ * value will be 0 or 1.
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+Word16 rotl (Word16 var1, Word16 var2, Word16 * var3) {
+ Word16 var_out;
+
+ *var3 = lshr (var1, 15);
+
+ var_out = s_or (lshl (var1, 1), s_and (var2, 0x1));
+
+#if (WMOPS)
+ multiCounter[currCounter].lshr--;
+ multiCounter[currCounter].s_and--;
+ multiCounter[currCounter].lshl--;
+ multiCounter[currCounter].s_or--;
+ multiCounter[currCounter].rotl++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_rotr
+ *
+ * Purpose :
+ *
+ * Performs a 32-bit logical rotation of L_var1 by 1 bit to the LSBits. The
+ * MSBit is set to var2 bit 0. The LSBit of L_var1 is kept in *var3 bit 0.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value must be 0
+ * or 1.
+ *
+ * Outputs :
+ *
+ * *var3 Points on a 16 bit short signed integer (Word16) whose
+ * value will be 0 or 1.
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+Word32 L_rotr (Word32 L_var1, Word16 var2, Word16 * var3) {
+ Word32 L_var_out;
+
+ *var3 = s_and (extract_l (L_var1), 0x1);
+
+ L_var_out = L_or (L_lshr (L_var1, 1), L_lshl (L_deposit_l (var2), 31));
+
+#if (WMOPS)
+ multiCounter[currCounter].extract_l--;
+ multiCounter[currCounter].s_and--;
+ multiCounter[currCounter].L_deposit_l--;
+ multiCounter[currCounter].L_lshl--;
+ multiCounter[currCounter].L_lshr--;
+ multiCounter[currCounter].L_or--;
+ multiCounter[currCounter].L_rotr++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_rotl
+ *
+ * Purpose :
+ *
+ * Performs a 32-bit logical rotation of L_var1 by 1 bit to the MSBits. The
+ * LSBit is set to var2 bit 0. The MSBit of L_var1 is kept in *var3 bit 0.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value must be 0
+ * or 1.
+ *
+ * Outputs :
+ *
+ * *var3 Points on a 16 bit short signed integer (Word16) whose
+ * value will be 0 or 1.
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+Word32 L_rotl (Word32 L_var1, Word16 var2, Word16 * var3) {
+ Word32 L_var_out;
+
+ *var3 = extract_l (L_lshr (L_var1, 31));
+
+ L_var_out = L_or (L_lshl (L_var1, 1), L_deposit_l (s_and (var2, 0x1)));
+
+#if (WMOPS)
+ multiCounter[currCounter].L_lshr--;
+ multiCounter[currCounter].extract_l--;
+ multiCounter[currCounter].s_and--;
+ multiCounter[currCounter].L_deposit_l--;
+ multiCounter[currCounter].L_lshl--;
+ multiCounter[currCounter].L_or--;
+ multiCounter[currCounter].L_rotl++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* end of file */
diff --git a/basic_op/enh1632.h b/basic_op/enh1632.h
new file mode 100644
index 0000000000000000000000000000000000000000..1aee12b6430079becbe4f3602d738708c7d951bf
--- /dev/null
+++ b/basic_op/enh1632.h
@@ -0,0 +1,545 @@
+/*
+ ===========================================================================
+ File: ENH1632.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ ENHANCED 16-BIT & 32-BIT ARITHMETIC OPERATORS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+ Some counters incrementations were missing (s_and,
+ s_or, s_xor).
+ 30 Nov 09 v2.3 saturate() removed
+
+ ============================================================================
+*/
+
+
+#ifndef _ENH1632_H
+#define _ENH1632_H
+
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+
+
+#include "stl.h"
+
+
+#if (WMOPS)
+#include "count.h"
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* ifdef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Prototypes for enhanced 16/32 bit arithmetic operators
+ *
+ *****************************************************************************/
+Word16 shl_r (Word16 var1, Word16 var2);
+Word32 L_shl_r (Word32 L_var1, Word16 var2);
+
+
+Word16 lshl (Word16 var1, Word16 var2);
+Word16 lshr (Word16 var1, Word16 var2);
+Word32 L_lshl (Word32 L_var1, Word16 var2);
+Word32 L_lshr (Word32 L_var1, Word16 var2);
+
+Word16 rotr (Word16 var1, Word16 var2, Word16 * var3);
+Word16 rotl (Word16 var1, Word16 var2, Word16 * var3);
+Word32 L_rotr (Word32 var1, Word16 var2, Word16 * var3);
+Word32 L_rotl (Word32 var1, Word16 var2, Word16 * var3);
+
+
+
+/*****************************************************************************
+ *
+ * Functions
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Function Name : s_max
+ *
+ * Purpose :
+ *
+ * Compares var1 and var2 and returns the maximum value.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0x8000 <= var1 <= 0x7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0x8000 <= var2 <= 0x7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0x8000 <= L_var_out <= 0x7fff.
+ *
+ *****************************************************************************/
+static __inline Word16 s_max (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ if (var1 >= var2)
+ var_out = var1;
+ else
+ var_out = var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].s_max++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : s_min
+ *
+ * Purpose :
+ *
+ * Compares var1 and var2 and returns the minimum value.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0x8000 <= var1 <= 0x7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0x8000 <= var2 <= 0x7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0x8000 <= var_out <= 0x7fff.
+ *
+ *****************************************************************************/
+static __inline Word16 s_min (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ if (var1 <= var2)
+ var_out = var1;
+ else
+ var_out = var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].s_min++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_max
+ *
+ * Purpose :
+ *
+ * Compares L_var1 and L_var2 and returns the maximum value.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * L_var2 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var2 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+static __inline Word32 L_max (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ if (L_var1 >= L_var2)
+ L_var_out = L_var1;
+ else
+ L_var_out = L_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_max++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_min
+ *
+ * Purpose :
+ *
+ * Compares L_var1 and L_var2 and returns the minimum value.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * L_var2 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var2 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+static __inline Word32 L_min (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ if (L_var1 <= L_var2)
+ L_var_out = L_var1;
+ else
+ L_var_out = L_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_min++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+
+
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : s_and
+ *
+ * Purpose :
+ *
+ * Performs logical AND of the two 16 bit input variables.
+ * var_out = var1 & var2
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+static __inline Word16 s_and (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ var_out = var1 & var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].s_and++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_and
+ *
+ * Purpose :
+ *
+ * Performs logical AND of the two 32 bit input variables.
+ * L_var_out = L_var1 & L_var2
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * L_var2 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var2 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+static __inline Word32 L_and (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = L_var1 & L_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_and++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : s_or
+ *
+ * Purpose :
+ *
+ * Performs logical OR of the two 16 bit input variables.
+ * var_out = var1 | var2
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+static __inline Word16 s_or (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ var_out = var1 | var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].s_or++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_or
+ *
+ * Purpose :
+ *
+ * Performs logical OR of the two 32 bit input variables.
+ * L_var_out = L_var1 | L_var2
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * L_var2 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var2 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+static __inline Word32 L_or (Word32 L_var1, Word32 L_var2) {
+
+ Word32 L_var_out;
+
+ L_var_out = L_var1 | L_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_or++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : s_xor
+ *
+ * Purpose :
+ *
+ * Performs logical XOR of the two 16 bit input variables.
+ * var_out = var1 ^ var2
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var1 <= 0x0000 7fff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value
+ * falls in the range 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+static __inline Word16 s_xor (Word16 var1, Word16 var2) {
+ Word16 var_out;
+
+ var_out = var1 ^ var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].s_xor++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_xor
+ *
+ * Purpose :
+ *
+ * Performs logical OR of the two 32 bit input variables.
+ * L_var_out = L_var1 ^ L_var2
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * L_var2 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var2 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value
+ * falls in the range 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+static __inline Word32 L_xor (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = L_var1 ^ L_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_xor++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif /*_ENH1632_H*/
+
+/* end of file */
diff --git a/basic_op/enh32.c b/basic_op/enh32.c
new file mode 100644
index 0000000000000000000000000000000000000000..1f8a6f83cc5c53183b6207ed753c1f7779b8a131
--- /dev/null
+++ b/basic_op/enh32.c
@@ -0,0 +1,215 @@
+/*****************************************************************************
+ *
+ * Enhanced 32 bit operators :
+ *
+ * Mpy_32_16_1()
+ * Mpy_32_16_r()
+ * Mpy_32_32()
+ * Mpy_32_32_r()
+ * Madd_32_16()
+ * Msub_32_16()
+ * Madd_32_32()
+ * Msub_32_32()
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Include-Files
+ *
+ *****************************************************************************/
+#include
+#include
+#include "enh32.h"
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* if WMOPS */
+
+#ifdef ENH_32_BIT_OPERATOR
+/*****************************************************************************
+ *
+ * Local Functions
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Functions
+ *
+ *****************************************************************************/
+
+Word32 Mpy_32_16_1 (Word32 L_var1, Word16 var2) {
+ Word32 L_var_out = W_sat_m (W_mult_32_16 (L_var1, var2) );
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_1++;
+ multiCounter[currCounter].W_mult_32_16--;
+ multiCounter[currCounter].W_sat_m--;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Mpy_32_16_r (Word32 L_var1, Word16 var2) {
+ Word32 L_var_out = W_round48_L (W_mult_32_16 (L_var1, var2 ) );
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_r++;
+ multiCounter[currCounter].W_mult_32_16--;
+ multiCounter[currCounter].W_round48_L--;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Mpy_32_32 (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+ Word64 L64_var1;
+
+ L64_var1 = ((Word64)L_var1 * L_var2);
+ L64_var1 = W_shl (L64_var1, 1);
+ L_var_out = W_extract_h (L64_var1 );
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32++;
+ multiCounter[currCounter].W_shl--;
+ multiCounter[currCounter].W_extract_h--;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Mpy_32_32_r (Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+ Word64 L64_var1;
+
+ L64_var1 = ((Word64) L_var1 * L_var2);
+ L64_var1 = W_shr (L64_var1, 15);
+ L_var_out = W_round48_L (L64_var1 );
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_r++;
+ multiCounter[currCounter].W_shr--;
+ multiCounter[currCounter].W_round48_L--;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Madd_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_16_1 (L_var1, var2);
+ L_var_out = L_add (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].Madd_32_16++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Madd_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_16_r (L_var1, var2);
+ L_var_out = L_add (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_r--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].Madd_32_16_r++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Msub_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_16_1 (L_var1, var2);
+ L_var_out = L_sub(L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].Msub_32_16++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Msub_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_16_r (L_var1, var2);
+ L_var_out = L_sub (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_r--;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].Msub_32_16_r++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Madd_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_32 (L_var1, L_var2);
+ L_var_out = L_add (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].Madd_32_32++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Madd_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_32_r (L_var1, L_var2);
+ L_var_out = L_add (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_r--;
+ multiCounter[currCounter].L_add--;
+ multiCounter[currCounter].Madd_32_32_r++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Msub_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_32 (L_var1, L_var2);
+ L_var_out = L_sub (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32--;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].Msub_32_32++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+Word32 Msub_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2) {
+ Word32 L_var_out;
+
+ L_var_out = Mpy_32_32_r (L_var1, L_var2);
+ L_var_out = L_sub (L_var3, L_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_r--;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].Msub_32_32_r++;
+#endif /* if WMOPS */
+ return L_var_out;
+}
+
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+/* end of file */
diff --git a/basic_op/enh32.h b/basic_op/enh32.h
new file mode 100644
index 0000000000000000000000000000000000000000..a6e220c9512838e797b6add6dbe4d44e3c029d69
--- /dev/null
+++ b/basic_op/enh32.h
@@ -0,0 +1,38 @@
+
+#ifndef _ENH32_H
+#define _ENH32_H
+
+#include "stl.h"
+
+#ifndef Word64
+#define Word64 long long int
+#endif
+
+ /*****************************************************************************
+ *
+ * Prototypes for enhanced 32 bit arithmetic operators
+ *
+ *****************************************************************************/
+#ifdef ENH_32_BIT_OPERATOR
+
+Word32 Mpy_32_16_1 (Word32 L_var1, Word16 var2);
+Word32 Mpy_32_16_r (Word32 L_var1, Word16 var2);
+Word32 Mpy_32_32 (Word32 L_var1, Word32 L_var2);
+Word32 Mpy_32_32_r (Word32 L_var1, Word32 L_var2);
+Word32 Madd_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2);
+Word32 Madd_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2);
+Word32 Msub_32_16 (Word32 L_var3, Word32 L_var1, Word16 var2);
+Word32 Msub_32_16_r (Word32 L_var3, Word32 L_var1, Word16 var2);
+Word32 Madd_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2);
+Word32 Madd_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2);
+Word32 Msub_32_32 (Word32 L_var3, Word32 L_var1, Word32 L_var2);
+Word32 Msub_32_32_r (Word32 L_var3, Word32 L_var1, Word32 L_var2);
+
+#endif /* #ifdef ENH_32_BIT_OPERATOR */
+
+#endif /*_ENH32_H*/
+
+
+/* end of file */
+
+
diff --git a/basic_op/enh40.c b/basic_op/enh40.c
new file mode 100644
index 0000000000000000000000000000000000000000..a72a243b25fb9f356eb2328aeeaa9cca5d6ae1a9
--- /dev/null
+++ b/basic_op/enh40.c
@@ -0,0 +1,1045 @@
+/*
+ ===========================================================================
+ File: ENH40.C v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ 40-BIT ARITHMETIC OPERATORS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+
+ ============================================================================
+*/
+
+
+/*****************************************************************************
+ *
+ * Enhanced 40 bit operators :
+ *
+ * L40_add()
+ * L40_sub()
+ * L40_abs()
+ * L40_negate()
+ * L40_max()
+ * L40_min()
+ * L40_shr()
+ * L40_shr_r()
+ * L40_shl()
+ * L40_shl_r()
+ * norm_L40()
+ * L40_mult()
+ * L40_mac()
+ * L40_msu()
+ * mac_r40()
+ * msu_r40()
+ * Mpy_32_16_ss()
+ * Mpy_32_32_ss()
+ * L40_lshl()
+ * L40_lshr()
+ * L40_round()
+ * L_saturate40()
+ * L40_set()
+ * Extract40_H()
+ * Extract40_L()
+ * L_Extract40()
+ * L40_deposit_h()
+ * L40_deposit_l()
+ * L40_deposit32()
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Include-Files
+ *
+ *****************************************************************************/
+#include
+#include
+#include "stl.h"
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* ifdef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Local Functions
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Functions
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Function Name : L40_shl
+ *
+ * Purpose :
+ *
+ * Arithmetically shifts left L40_var1 by var2 positions.
+ * - If var2 is negative, L40_var1 is shifted to the LSBits by (-var2)
+ * positions with extension of the sign bit.
+ * - If var2 is positive, L40_var1 is shifted to the MSBits by (var2)
+ * positions.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_shl (Word40 L40_var1, Word16 var2) {
+
+ Word40 L40_var_out;
+ Word40 L40_constant = L40_set (0xc000000000);
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L40_var_out = L40_shr (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shr--;
+#endif /* ifdef WMOPS */
+ }
+
+ else {
+ L40_var_out = L40_var1;
+
+ for (; var2 > 0; var2--) {
+ if (L40_var_out > 0x003fffffffff) {
+ L40_var_out = L40_OVERFLOW_OCCURED (L40_var_out);
+ break;
+ }
+
+ else if (L40_var_out < L40_constant) {
+ L40_var_out = L40_UNDERFLOW_OCCURED (L40_var_out);
+ break;
+ }
+
+ else {
+ L40_var_out = L40_var_out << 1;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_set--;
+ multiCounter[currCounter].L40_shl++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_shr
+ *
+ * Purpose :
+ *
+ * Arithmetically shifts right L40_var1 by var2 positions.
+ * - If var2 is positive, L40_var1 is shifted to the LSBits by (var2)
+ * positions with extension of the sign bit.
+ * - If var2 is negative, L40_var1 is shifted to the MSBits by (-var2)
+ * positions.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_shr (Word40 L40_var1, Word16 var2) {
+ Word40 L40_var_out;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L40_var_out = L40_shl (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shl--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ L40_var_out = L40_var1 >> var2;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shr++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_negate
+ *
+ * Purpose :
+ *
+ * Negates L40_var1.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_negate (Word40 L40_var1) {
+ Word40 L40_var_out;
+
+ L40_var_out = L40_add (~L40_var1, 0x01);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_add--;
+ multiCounter[currCounter].L40_negate++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_add
+ *
+ * Purpose :
+ *
+ * Adds L40_var1 and L40_var2 and returns the 40-bit result.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * L40_var2 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var2 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_add (Word40 L40_var1, Word40 L40_var2) {
+ Word40 L40_var_out;
+
+ L40_var_out = L40_var1 + L40_var2;
+
+ if ((((L40_var1 & 0x8000000000) >> 39) != 0)
+ && (((L40_var2 & 0x8000000000) >> 39) != 0)
+ && (((L40_var_out & 0x8000000000) >> 39) == 0)) {
+ L40_var_out = L40_UNDERFLOW_OCCURED (L40_var_out);
+
+ } else if ((((L40_var1 & 0x8000000000) >> 39) == 0)
+ && (((L40_var2 & 0x8000000000) >> 39) == 0)
+ && (((L40_var_out & 0x8000000000) >> 39) != 0)) {
+ L40_var_out = L40_OVERFLOW_OCCURED (L40_var_out);
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L40_add++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_sub
+ *
+ * Purpose :
+ *
+ * Subtracts L40_var2 from L40_var1.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * L40_var2 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var2 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_sub (Word40 L40_var1, Word40 L40_var2) {
+ Word40 L40_var_out;
+
+ L40_var_out = L40_var1 - L40_var2;
+
+ if ((((L40_var1 & 0x8000000000) >> 39) != 0)
+ && (((L40_var2 & 0x8000000000) >> 39) == 0)
+ && (((L40_var_out & 0x8000000000) >> 39) == 0)) {
+ L40_var_out = L40_UNDERFLOW_OCCURED (L40_var_out);
+
+ } else if ((((L40_var1 & 0x8000000000) >> 39) == 0)
+ && (((L40_var2 & 0x8000000000) >> 39) != 0)
+ && (((L40_var_out & 0x8000000000) >> 39) != 0)) {
+ L40_var_out = L40_OVERFLOW_OCCURED (L40_var_out);
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L40_sub++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_abs
+ *
+ * Purpose :
+ *
+ * Returns the absolute value of L40_var1.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : 0x00 0000 0000 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_abs (Word40 L40_var1) {
+ Word40 L40_var_out;
+
+ if (L40_var1 < 0) {
+ L40_var_out = L40_negate (L40_var1);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_negate--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ L40_var_out = L40_var1;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_abs++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_max
+ *
+ * Purpose :
+ *
+ * Compares L40_var1 and L40_var2 and returns the maximum value.
+ *
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * L40_var2 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var2 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_max (Word40 L40_var1, Word40 L40_var2) {
+ Word40 L40_var_out;
+
+ if (L40_var1 < L40_var2)
+ L40_var_out = L40_var2;
+ else
+ L40_var_out = L40_var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_max++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_min
+ *
+ * Purpose :
+ *
+ * Compares L40_var1 and L40_var2 and returns the minimum value.
+ *
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * L40_var2 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var2 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_min (Word40 L40_var1, Word40 L40_var2) {
+ Word40 L40_var_out;
+
+ if (L40_var1 < L40_var2)
+ L40_var_out = L40_var1;
+ else
+ L40_var_out = L40_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_min++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_saturate40
+ *
+ * Purpose :
+ *
+ * If L40_var1 is greater than MAX_32, returns MAX_32.
+ * If L40_var1 is lower than MIN_32, returns MIN_32.
+ * If not, returns L_Extract40( L40_var1).
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var_out <= 0x7fff ffff.
+ *
+ *****************************************************************************/
+Word32 L_saturate40 (Word40 L40_var1) {
+ Word32 L_var_out;
+
+ Word40 UNDER_L40_var2 = (Word40) ~ ((((Word40) 1) << 31) - (Word40) 1);
+ Word40 OVER_L40_var2 = (Word40) ((((Word40) 1) << 31) - (Word40) 1);
+
+ if (L40_var1 < UNDER_L40_var2) {
+ L40_var1 = UNDER_L40_var2;
+ Overflow = 1;
+ }
+
+ if (L40_var1 > OVER_L40_var2) {
+ L40_var1 = OVER_L40_var2;
+ Overflow = 1;
+ }
+
+ L_var_out = L_Extract40 (L40_var1);
+
+#if (WMOPS)
+ multiCounter[currCounter].L_Extract40--;
+ multiCounter[currCounter].L_saturate40++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : Mpy_32_16_ss
+ *
+ * Purpose :
+ *
+ * Multiplies the 2 signed values L_var1 and var2 with saturation control
+ * on 48-bit. The operation is performed in fractional mode :
+ * - L_var1 is supposed to be in 1Q31 format.
+ * - var2 is supposed to be in 1Q15 format.
+ * - The result is produced in 1Q47 format : L_varout_h points to the
+ * 32 MSBits while varout_l points to the 16 LSBits.
+ *
+ * Complexity weight : 2
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * *L_varout_h 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_varout_h <= 0x7fff ffff.
+ *
+ * *varout_l 16 bit short unsigned integer (UWord16) whose value falls in
+ * the range : 0x0000 0000 <= varout_l <= 0x0000 ffff.
+ *
+ * Return Value :
+ *
+ * none
+ *
+ *****************************************************************************/
+void Mpy_32_16_ss (Word32 L_var1, Word16 var2, Word32 * L_varout_h, UWord16 * varout_l) {
+ Word16 var1_h;
+ UWord16 uvar1_l;
+ Word40 L40_var1;
+
+ if ((L_var1 == (Word32) 0x80000000)
+ && (var2 == (Word16) 0x8000)) {
+ *L_varout_h = 0x7fffffff;
+ *varout_l = (UWord16) 0xffff;
+
+ } else {
+ uvar1_l = extract_l (L_var1);
+ var1_h = extract_h (L_var1);
+
+ /* Below line can not overflow, so we can use << instead of L40_shl. */
+ L40_var1 = ((Word40) ((Word32) var2 * (Word32) uvar1_l)) << 1;
+
+ *varout_l = Extract40_L (L40_var1);
+
+ L40_var1 = L40_shr (L40_var1, 16);
+ L40_var1 = L40_mac (L40_var1, var2, var1_h);
+
+ *L_varout_h = L_Extract40 (L40_var1);
+
+#if(WMOPS)
+ multiCounter[currCounter].extract_l--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].Extract40_L--;
+ multiCounter[currCounter].L40_shr--;
+ multiCounter[currCounter].L40_mac--;
+ multiCounter[currCounter].L_Extract40--;
+#endif /* ifdef WMOPS */
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_ss++;
+#endif /* ifdef WMOPS */
+
+ return;
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : Mpy_32_32_ss
+ *
+ * Purpose :
+ *
+ * Multiplies the 2 signed values L_var1 and L_var2 with saturation control
+ * on 64-bit. The operation is performed in fractional mode :
+ * - L_var1 and L_var2 are supposed to be in 1Q31 format.
+ * - The result is produced in 1Q63 format : L_varout_h points to the
+ * 32 MSBits while L_varout_l points to the 32 LSBits.
+ *
+ * Complexity weight : 4
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * L_var2 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var2 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * *L_varout_h 32 bit long signed integer (Word32) whose value falls in
+ * the range : 0x8000 0000 <= L_varout_h <= 0x7fff ffff.
+ *
+ * *L_varout_l 32 bit short unsigned integer (UWord32) whose value falls in
+ * the range : 0x0000 0000 <= L_varout_l <= 0xffff ffff.
+ *
+ *
+ * Return Value :
+ *
+ * none
+ *
+ *****************************************************************************/
+void Mpy_32_32_ss (Word32 L_var1, Word32 L_var2, Word32 * L_varout_h, UWord32 * L_varout_l) {
+ UWord16 uvar1_l, uvar2_l;
+ Word16 var1_h, var2_h;
+ Word40 L40_var1;
+
+ if ((L_var1 == (Word32) 0x80000000)
+ && (L_var2 == (Word32) 0x80000000)) {
+ *L_varout_h = 0x7fffffff;
+ *L_varout_l = (UWord32) 0xffffffff;
+
+ } else {
+
+ uvar1_l = extract_l (L_var1);
+ var1_h = extract_h (L_var1);
+ uvar2_l = extract_l (L_var2);
+ var2_h = extract_h (L_var2);
+
+ /* Below line can not overflow, so we can use << instead of L40_shl. */
+ L40_var1 = ((Word40) ((UWord32) uvar2_l * (UWord32) uvar1_l)) << 1;
+
+ *L_varout_l = 0x0000ffff & L_Extract40 (L40_var1);
+
+ L40_var1 = L40_shr (L40_var1, 16);
+ L40_var1 = L40_add (L40_var1, ((Word40) ((Word32) var2_h * (Word32) uvar1_l)) << 1);
+ L40_var1 = L40_add (L40_var1, ((Word40) ((Word32) var1_h * (Word32) uvar2_l)) << 1);
+ *L_varout_l |= (L_Extract40 (L40_var1)) << 16;
+
+ L40_var1 = L40_shr (L40_var1, 16);
+ L40_var1 = L40_mac (L40_var1, var1_h, var2_h);
+
+ *L_varout_h = L_Extract40 (L40_var1);
+
+#if (WMOPS)
+ multiCounter[currCounter].extract_l -= 2;
+ multiCounter[currCounter].extract_h -= 2;
+ multiCounter[currCounter].L_Extract40 -= 3;
+ multiCounter[currCounter].L40_shr -= 2;
+ multiCounter[currCounter].L40_add -= 2;
+ multiCounter[currCounter].L40_mac--;
+#endif /* ifdef WMOPS */
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_ss++;
+#endif /* ifdef WMOPS */
+
+ return;
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_lshl
+ *
+ * Purpose :
+ *
+ * Logically shifts left L40_var1 by var2 positions.
+ * - If var2 is negative, L40_var1 is shifted to the LSBits by (-var2)
+ * positions with insertion of 0 at the MSBit.
+ * - If var2 is positive, L40_var1 is shifted to the MSBits by (var2)
+ * positions.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_lshl (Word40 L40_var1, Word16 var2) {
+ Word40 L40_var_out;
+
+ if (var2 <= 0) {
+ var2 = -var2;
+ L40_var_out = L40_lshr (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_lshr--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ if (var2 >= 40)
+ L40_var_out = 0x0000000000;
+ else
+ L40_var_out = L40_var1 << var2;
+
+ L40_var_out = L40_set (L40_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_set--;
+#endif /* ifdef WMOPS */
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_lshl++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_lshr
+ *
+ * Purpose :
+ *
+ * Logically shifts right L40_var1 by var2 positions.
+ * - If var2 is positive, L40_var1 is shifted to the LSBits by (var2)
+ * positions with insertion of 0 at the MSBit.
+ * - If var2 is negative, L40_var1 is shifted to the MSBits by (-var2)
+ * positions.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+*
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_lshr (Word40 L40_var1, Word16 var2) {
+ Word40 L40_var_out;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L40_var_out = L40_lshl (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_lshl--;
+#endif /* ifdef WMOPS */
+ } else {
+ if (var2 >= 40)
+ L40_var_out = 0x0000000000;
+ else
+ L40_var_out = (L40_var1 & 0xffffffffff) >> var2;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_lshr++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : norm_L40
+ *
+ * Purpose :
+ *
+ * Produces the number of left shifts needed to normalize in 32 bit format
+ * the 40 bit variable L40_var1. This returned value can be used to scale
+ * L_40_var1 into the following intervals :
+ * - [(MAX_32+1)/2 .. MAX_32 ] for positive values.
+ * - [ MIN_32 .. (MIN_32/2)+1 ] for negative values.
+ * - [ 0 .. 0 ] for null values.
+ * In order to normalize the result, the following operation must be done :
+ * normelized_L40_var1 = L40_shl( L40_var1, norm_L40( L40_var1))
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : -8 <= var_out <= 31.
+ *
+ *****************************************************************************/
+Word16 norm_L40 (Word40 L40_var1) {
+ Word16 var_out;
+
+ var_out = 0;
+
+ if (L40_var1 != 0) {
+ while ((L40_var1 > (Word32) 0x80000000L)
+ && (L40_var1 < (Word32) 0x7fffffffL)) {
+
+ L40_var1 = L40_shl (L40_var1, 1);
+ var_out++;
+
+#ifdef WMOPS
+ multiCounter[currCounter].L40_shl--;
+#endif /* ifdef WMOPS */
+ }
+
+ while ((L40_var1 < (Word32) 0x80000000L)
+ || (L40_var1 > (Word32) 0x7fffffffL)) {
+
+ L40_var1 = L40_shl (L40_var1, -1);
+ var_out--;
+
+#ifdef WMOPS
+ multiCounter[currCounter].L40_shl--;
+#endif /* ifdef WMOPS */
+ }
+ }
+#ifdef WMOPS
+ multiCounter[currCounter].norm_L40++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_shr_r
+ *
+ * Purpose :
+ *
+ * Arithmetically shifts right L40_var1 by var2 positions and rounds the
+ * result. It is equivalent to L40_shr( L40_var1, var2) except that if the
+ * last bit shifted out to the LSBit is 1, then the shifted result is
+ * incremented by 1.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_shr_r (Word40 L40_var1, Word16 var2) {
+ Word40 L40_var_out;
+
+ if (var2 > 39) {
+ L40_var_out = 0;
+
+ } else {
+ L40_var_out = L40_shr (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shr--;
+#endif /* ifdef WMOPS */
+
+ if (var2 > 0) {
+ if ((L40_var1 & ((Word40) 1 << (var2 - 1))) != 0) {
+ /* below line can not generate overflows on 40-bit */
+ L40_var_out++;
+ }
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shr_r++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_shl_r
+ *
+ * Purpose :
+ *
+ * Arithmetically shifts left L40_var1 by var2 positions and rounds the
+ * result. It is equivalent to L40_shl( L40_var1, var2) except if var2 is
+ * negative. In that case, it does the same as
+ * L40_shr_r( L40_var1, (-var2)).
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : 0xffff 8000 <= var2 <= 0x0000 7fff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+Word40 L40_shl_r (Word40 L40_var1, Word16 var2) {
+ Word40 L40_var_out;
+
+ if (var2 >= 0) {
+ L40_var_out = L40_shl (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shl--;
+#endif /* ifdef WMOPS */
+
+ } else {
+ var2 = -var2;
+ L40_var_out = L40_shr_r (L40_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_shr_r--;
+#endif /* ifdef WMOPS */
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L40_shl_r++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/* end of file */
diff --git a/basic_op/enh40.h b/basic_op/enh40.h
new file mode 100644
index 0000000000000000000000000000000000000000..69ab7fc58a837548055b4fabae01236c8bc605b9
--- /dev/null
+++ b/basic_op/enh40.h
@@ -0,0 +1,839 @@
+/*
+ ===========================================================================
+ File: ENH40.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ 40-BIT ARITHMETIC OPERATORS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+
+ ============================================================================
+*/
+
+
+#ifndef _ENH40_H
+#define _ENH40_H
+
+
+#include "stl.h"
+
+
+#ifdef WMOPS
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* ifdef WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+#ifdef _MSC_VER
+#define MAX_40 (0x0000007fffffffff)
+#define MIN_40 (0xffffff8000000000)
+#endif /* ifdef _MSC_VER */
+
+
+
+/*****************************************************************************
+ *
+ * Macros for 40 bit arithmetic overflow management :
+ * Upon 40-bit overflow beyond MAX_40 or underflow beyond MIN_40,
+ * the application will exit.
+ *
+ *****************************************************************************/
+#define L40_OVERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(1), L40_var1)
+#define L40_UNDERFLOW_OCCURED( L40_var1) (Overflow = 1, exit(2), L40_var1)
+
+
+
+ /*****************************************************************************
+ *
+ * Prototypes for enhanced 40 bit arithmetic operators
+ *
+ *****************************************************************************/
+Word40 L40_shr (Word40 L40_var1, Word16 var2);
+Word40 L40_shr_r (Word40 L40_var1, Word16 var2);
+Word40 L40_shl (Word40 L40_var1, Word16 var2);
+Word40 L40_shl_r (Word40 L40_var1, Word16 var2);
+
+static __inline Word40 L40_mult (Word16 var1, Word16 var2);
+
+static __inline Word40 L40_mac (Word40 L40_var1, Word16 var1, Word16 var2);
+static __inline Word16 mac_r40 (Word40 L40_var1, Word16 var1, Word16 var2);
+
+static __inline Word40 L40_msu (Word40 L40_var1, Word16 var1, Word16 var2);
+static __inline Word16 msu_r40 (Word40 L40_var1, Word16 var1, Word16 var2);
+
+
+void Mpy_32_16_ss (Word32 L_var1, Word16 var2, Word32 * L_varout_h, UWord16 * varout_l);
+void Mpy_32_32_ss (Word32 L_var1, Word32 L_var2, Word32 * L_varout_h, UWord32 * L_varout_l);
+
+
+Word40 L40_lshl (Word40 L40_var1, Word16 var2);
+Word40 L40_lshr (Word40 L40_var1, Word16 var2);
+
+static __inline Word40 L40_set (Word40 L40_var1);
+static __inline UWord16 Extract40_H (Word40 L40_var1);
+static __inline UWord16 Extract40_L (Word40 L40_var1);
+static __inline UWord32 L_Extract40 (Word40 L40_var1);
+
+static __inline Word40 L40_deposit_h (Word16 var1);
+static __inline Word40 L40_deposit_l (Word16 var1);
+static __inline Word40 L40_deposit32 (Word32 L_var1);
+
+static __inline Word40 L40_round (Word40 L40_var1);
+static __inline Word16 round40 (Word40 L40_var1);
+
+
+Word40 L40_add (Word40 L40_var1, Word40 L40_var2);
+Word40 L40_sub (Word40 L40_var1, Word40 L40_var2);
+Word40 L40_abs (Word40 L40_var1);
+Word40 L40_negate (Word40 L40_var1);
+Word40 L40_max (Word40 L40_var1, Word40 L40_var2);
+Word40 L40_min (Word40 L40_var1, Word40 L40_var2);
+Word32 L_saturate40 (Word40 L40_var1);
+Word16 norm_L40 (Word40 L40_var1);
+
+
+/*****************************************************************************
+ *
+ * Functions
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Function Name : L40_set
+ *
+ * Purpose :
+ *
+ * Assigns a 40 constant to a Word40 with adequate initialization depending
+ * on underlying architecture constraints (for example to keep consistency
+ * of sign bits). Current implementation only validated on MSVC++6.0.
+ *
+ * Complexity weight : 3
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+/*#ifdef _MSC_VER*/
+static __inline Word40 L40_set (Word40 L40_var1) {
+ Word40 L40_var_out;
+
+ L40_var_out = L40_var1 & 0x000000ffffffffff;
+
+ if (L40_var1 & 0x8000000000)
+ L40_var_out = L40_var_out | 0xffffff0000000000;
+
+#ifdef WMOPS
+ multiCounter[currCounter].L40_set++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+/* #endif */ /* ifdef _MSC_VER */
+
+
+/*****************************************************************************
+ *
+ * Function Name : Extract40_H
+ *
+ * Purpose :
+ *
+ * Returns the bits [31-16] of L40_var1.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short unsigned integer (UWord16) whose value falls in
+ * the range : MIN_U_16 <= var_out <= MAX_U_16.
+ *
+ *****************************************************************************/
+static __inline UWord16 Extract40_H (Word40 L40_var1) {
+ UWord16 var_out;
+
+ var_out = (UWord16) (L40_var1 >> 16);
+
+#if (WMOPS)
+ multiCounter[currCounter].Extract40_H++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : Extract40_L
+ *
+ * Purpose :
+ *
+ * Returns the bits [15-0] of L40_var1.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short unsigned integer (UWord16) whose value falls in
+ * the range : MIN_U_16 <= var_out <= MAX_U_16.
+ *
+ *****************************************************************************/
+static __inline UWord16 Extract40_L (Word40 L40_var1) {
+ UWord16 var_out;
+
+ var_out = (UWord16) (L40_var1);
+
+#if (WMOPS)
+ multiCounter[currCounter].Extract40_L++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L_Extract40
+ *
+ * Purpose :
+ *
+ * Returns the bits [31-0] of L40_var1.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L_var_out 32 bit long unsigned integer (UWord32) whose value falls in
+ * range : MIN_U_32 <= L_var_out <= MAX_U_32.
+ *
+ *****************************************************************************/
+static __inline UWord32 L_Extract40 (Word40 L40_var1) {
+ UWord32 L_var_out;
+
+ L_var_out = (UWord32) L40_var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].L_Extract40++;
+#endif /* ifdef WMOPS */
+
+ return (L_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_deposit_h
+ *
+ * Purpose :
+ *
+ * Deposits var1 in the bits [31-16] in a 40-bit number. The 16 LSBits of
+ * the output are zeroed and the 8 MSBits sign extend var1 sign bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var1 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_deposit_h (Word16 var1) {
+ Word40 L40_var_out;
+
+ L40_var_out = ((Word40) var1) << 16;
+
+ if (var1 & 0x8000) {
+ L40_var_out = L40_set (L40_var_out | 0xff00000000);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_set--;
+#endif /* ifdef WMOPS */
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L40_deposit_h++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_deposit_l
+ *
+ * Purpose :
+ *
+ * Deposits var1 in the bits [15-0] in a 40-bit number. The 24 MSBits sign
+ * extend var1 sign bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var1 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_deposit_l (Word16 var1) {
+ Word40 L40_var_out;
+
+ L40_var_out = var1;
+
+ if (var1 & 0x8000) {
+ L40_var_out = L40_set (L40_var_out | 0xffffff0000);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_set--;
+#endif /* ifdef WMOPS */
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L40_deposit_l++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_deposit32
+ *
+ * Purpose :
+ *
+ * Deposits L_var1 in the bits [31-0] in a 40-bit number. The 8 MSBits sign
+ * extend L_var1 sign bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L_var1 32 bit long signed integer (Word32) whose value falls in the
+ * range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_deposit32 (Word32 L_var1) {
+ Word40 L40_var_out;
+
+ L40_var_out = (Word40) L_var1;
+
+ if (L_var1 & 0x80000000) {
+ L40_var_out = L40_set (L40_var_out | 0xff00000000);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_set--;
+#endif /* ifdef WMOPS */
+ }
+#if (WMOPS)
+ multiCounter[currCounter].L40_deposit32++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_round
+ *
+ * Purpose :
+ *
+ * Rounds the lower 16 bits of the 40 bit input number. Returns the 40 bit
+ * result with bits 15-0 cleared.
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_round (Word40 L40_var1) {
+ Word40 L40_var_out;
+ Word40 L40_constant = L40_set (0xffffff0000);
+
+ L40_var_out = L40_add (0x8000, L40_var1);
+ L40_var_out = L40_var_out & L40_constant;
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_set--;
+ multiCounter[currCounter].L40_add--;
+ multiCounter[currCounter].L40_round++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : round40
+ *
+ * Purpose :
+ *
+ * Rounds the lower 16 bits of the 40 bit input number. Saturates the 40
+ * bit result to 32-bit and returns the resulting higher 16-bit.
+ * round40( L40_var1) = extract_h( L_saturate40( L40_round( L40_var1)))
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range 0xffff 8000 <= var_out <= 0x0000 7fff.
+ *
+ *****************************************************************************/
+static __inline Word16 round40 (Word40 L40_var1) {
+ Word16 var_out;
+
+ var_out = extract_h (L_saturate40 (L40_round (L40_var1)));
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_round--;
+ multiCounter[currCounter].L_saturate40--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].round40++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_mult
+ *
+ * Purpose :
+ *
+ * Multiplies var1 by var2 and shifts the result left by 1. Returns the
+ * full precision result on 40-bit.
+ * L40_mult( var1, var2) = shiftleft(( var1 times var2), 1)
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * var1 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var1 <= MAX_16.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_mult (Word16 var1, Word16 var2) {
+ Word32 L_var_out;
+ Word40 L40_var_out;
+
+ L_var_out = (Word32) var1 *(Word32) var2;
+ L40_var_out = (Word40) L_var_out;
+
+ /* Below line can not overflow, so we can use << instead of L40_shl. */
+ L40_var_out = L40_var_out << 1;
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_mult++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_mac
+ *
+ * Purpose :
+ *
+ * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and adds
+ * the result to L40_var1. Returns a 40 bit result.
+ * L40_mac( L40_var1, var2, var3)
+ * = L40_add( L40_var1, L40_mult( var2, var3))
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * var3 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var3 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_mac (Word40 L40_var1, Word16 var2, Word16 var3) {
+ Word40 L40_var_out;
+
+ L40_var_out = L40_mult (var2, var3);
+ L40_var_out = L40_add (L40_var1, L40_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_mult--;
+ multiCounter[currCounter].L40_add--;
+ multiCounter[currCounter].L40_mac++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : mac_r40
+ *
+ * Purpose :
+ *
+ * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and adds
+ * the result to L40_var1. Rounds the lower 16 bits of the 40 bit result.
+ * Saturates the 40 bit result to 32-bit and returns the resulting higher
+ * 16-bit.
+ * mac_r40( L40_var1, var2, var3)
+ * = round40( L40_mac( L40_var1, var2, var3))
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 2
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * var3 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var3 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var_out <= MAX_16.
+ *
+ *****************************************************************************/
+static __inline Word16 mac_r40 (Word40 L40_var1, Word16 var2, Word16 var3) {
+ Word40 L40_var_out;
+ Word16 var_out;
+
+ L40_var_out = L40_mac (L40_var1, var2, var3);
+ var_out = round40 (L40_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_mac--;
+ multiCounter[currCounter].round40--;
+ multiCounter[currCounter].mac_r40++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : L40_msu
+ *
+ * Purpose :
+ *
+ * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and
+ * subtracts the result from L40_var1. Returns a 40 bit result.
+ * L40_msu( L40_var1, var2, var3)
+ * = L40_sub( L40_var1, L40_mult( var2, var3))
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 1
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * var3 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var3 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * L40_var_out 40 bit long signed integer (Word40) whose value falls in
+ * the range : MIN_40 <= L40_var_out <= MAX_40.
+ *
+ *****************************************************************************/
+static __inline Word40 L40_msu (Word40 L40_var1, Word16 var2, Word16 var3) {
+ Word40 L40_var_out;
+
+ L40_var_out = L40_mult (var2, var3);
+ L40_var_out = L40_sub (L40_var1, L40_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_mult--;
+ multiCounter[currCounter].L40_sub--;
+ multiCounter[currCounter].L40_msu++;
+#endif /* ifdef WMOPS */
+
+ return (L40_var_out);
+}
+
+
+
+
+
+
+/*****************************************************************************
+ *
+ * Function Name : msu_r40
+ *
+ * Purpose :
+ *
+ * Multiplies var2 by var3. Shifts left the 40-bit result by 1 and
+ * subtracts the result from L40_var1. Rounds the lower 16 bits of the
+ * 40 bit result. Saturates the 40 bit result to 32-bit and returns the
+ * resulting higher 16-bit.
+ * msu_r40( L40_var1, var2, var3)
+ * = round40( L40_msu( L40_var1, var2, var3))
+ * Calls the macro L40_UNDERFLOW_OCCURED() in case of underflow on 40-bit.
+ * Calls the macro L40_OVERFLOW_OCCURED() in case of overflow on 40-bit.
+ *
+ * Complexity weight : 2
+ *
+ * Inputs :
+ *
+ * L40_var1 40 bit long signed integer (Word40) whose value falls in the
+ * range : MIN_40 <= L40_var1 <= MAX_40.
+ *
+ * var2 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var2 <= MAX_16.
+ *
+ * var3 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var3 <= MAX_16.
+ *
+ * Outputs :
+ *
+ * none
+ *
+ * Return Value :
+ *
+ * var_out 16 bit short signed integer (Word16) whose value falls in
+ * the range : MIN_16 <= var_out <= MAX_16.
+ *
+ *****************************************************************************/
+static __inline Word16 msu_r40 (Word40 L40_var1, Word16 var2, Word16 var3) {
+ Word40 L40_var_out;
+ Word16 var_out;
+
+ L40_var_out = L40_msu (L40_var1, var2, var3);
+ var_out = round40 (L40_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].L40_msu--;
+ multiCounter[currCounter].round40--;
+ multiCounter[currCounter].msu_r40++;
+#endif /* ifdef WMOPS */
+
+ return (var_out);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#endif /*_ENH40_H*/
+
+
+/* end of file */
diff --git a/basic_op/enh64.c b/basic_op/enh64.c
new file mode 100644
index 0000000000000000000000000000000000000000..4a365ee2c119d12f4e7515e4b0f2ddb0a51096ea
--- /dev/null
+++ b/basic_op/enh64.c
@@ -0,0 +1,1665 @@
+/*****************************************************************************
+*
+* Enhanced 64 bit operators :
+*
+* W_mac_32_16()
+* W_mac0_16_16()
+* W_msu0_16_16()
+*
+*****************************************************************************/
+
+
+/*****************************************************************************
+*
+* Include-Files
+*
+*****************************************************************************/
+#include
+#include
+#include "enh64.h"
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* if WMOPS */
+
+
+/*****************************************************************************
+*
+* Local Functions
+*
+*****************************************************************************/
+
+/*****************************************************************************
+*
+* Constants and Globals
+*
+*****************************************************************************/
+
+
+/*****************************************************************************
+*
+* Functions
+*
+*****************************************************************************/
+
+#ifdef ENH_64_BIT_OPERATOR
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_add_nosat |
+| |
+| Purpose : |
+| |
+| 64 bits addition of the two 64 bits variables (L64_var1+L64_var2) |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| L64_var2 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|___________________________________________________________________________|
+*/
+Word64 W_add_nosat (Word64 L64_var1, Word64 L64_var2) {
+ Word64 L64_var_out;
+
+ L64_var_out = L64_var1 + L64_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].W_add_nosat++;
+#endif
+
+ return L64_var_out;
+}
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_sub_nosat |
+| |
+| Purpose : |
+| |
+| 64 bits subtraction of the two 64 bits variables (L64_var1-L64_var2) |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| L64_var2 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|___________________________________________________________________________|
+*/
+Word64 W_sub_nosat (Word64 L64_var1, Word64 L64_var2) {
+ Word64 L64_var_out;
+
+ L64_var_out = L64_var1 - L64_var2;
+
+#if (WMOPS)
+ multiCounter[currCounter].W_sub_nosat++;
+#endif
+
+ return L64_var_out;
+}
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_shl |
+| |
+| Purpose : |
+| |
+| Arithmetically shift the 64 bit input L64_var1 left var2 positions. Zero|
+| fill the var2 LSB of the result. If var2 is negative, arithmetically |
+| shift L64_var1 right by -var2 with sign extension. Saturate the result |
+| in case of underflows or overflows. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the|
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|___________________________________________________________________________|
+*/
+Word64 W_shl (Word64 L64_var1, Word16 var2) {
+
+ Word64 L64_var_out = 0LL;
+
+ if (var2 <= 0) {
+ if (var2 < -64)
+ var2 = -64;
+ var2 = -var2;
+ L64_var_out = L64_var1 >> var2;
+ }
+ else {
+ for (; var2 > 0; var2--) {
+ if (L64_var1 > (Word64) 0X3fffffffffffffffLL) {
+ Overflow = 1;
+ L64_var_out = (Word64) 0X7fffffffffffffffLL;
+ break;
+ }
+ else {
+ if (L64_var1 < (Word64) 0xc000000000000000LL) {
+ Overflow = 1;
+ L64_var_out = (Word64)0x8000000000000000LL;
+ break;
+ }
+ }
+ L64_var1 *= 2;
+ L64_var_out = L64_var1;
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].W_shl++;
+#endif
+
+/* BASOP_CHECK();*/
+
+ return (L64_var_out);
+}
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_shr |
+| |
+| Purpose : |
+| |
+| Arithmetically shift the 64 bit input L64_var1 right var2 positions. |
+| Zero fill the var2 LSB of the result. If var2 is negative, |
+| arithmetically shift L64_var1 left by -var2 with sign extension. |
+| Saturate the result in case of underflows or overflows. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the|
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|___________________________________________________________________________|
+*/
+Word64 W_shr (Word64 L64_var1, Word16 var2) {
+ Word64 L64_var_out;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L64_var_out = W_shl (L64_var1, var2);
+
+#if (WMOPS)
+ multiCounter[currCounter].W_shl--;
+#endif /* if WMOPS */
+
+ } else {
+ L64_var_out = L64_var1 >> var2;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_shr++;
+#endif /* if WMOPS */
+
+ return (L64_var_out);
+}
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_shl_nosat |
+| |
+| Purpose : |
+| |
+| Arithmetically shifts left the 64-bit variable W_var1 by var2 positions. |
+| if var2 is negative, W_var1 is shifted to the least significant bits by |
+| (�var2) positions with extension of the sign bit . |
+| if var2 is positive, W_var1 is shifted to the most significant bits by |
+| (var2) positions without saturation control on 64 bits. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the|
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|___________________________________________________________________________|
+*/
+Word64 W_shl_nosat (Word64 L64_var1, Word16 var2) {
+
+ Word64 L64_var_out = 0LL;
+
+ if (var2 <= 0) {
+ var2 = -var2;
+ L64_var_out = L64_var1 >> var2;
+ }
+ else {
+ L64_var_out = L64_var1 << var2;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].W_shl_nosat++;
+#endif
+
+/* BASOP_CHECK();*/
+
+ return (L64_var_out);
+}
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_shr_nosat |
+| |
+| Purpose : |
+| |
+| Arithmetically shifts right the 64-bit variable W_var1 by var2 positions. |
+| if var2 is negative, W_var1 is shifted to the most significant bits by |
+| (�var2) positions without saturation control on 64 bits. |
+| if var2 is positive, W_var1 is shifted to the least significant bits by |
+| (var2) positions with extension of the sign bit . |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the|
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|___________________________________________________________________________|
+*/
+Word64 W_shr_nosat (Word64 L64_var1, Word16 var2) {
+ Word64 L64_var_out;
+
+ if (var2 < 0) {
+ var2 = -var2;
+ L64_var_out = L64_var1 << var2;
+
+ } else {
+ L64_var_out = L64_var1 >> var2;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_shr_nosat++;
+#endif /* if WMOPS */
+
+ return (L64_var_out);
+}
+
+
+/*_________________________________________________________________________________________________
+| |
+| Function Name : W_mac_32_16 |
+| |
+| Purpose : |
+| |
+| Multiply L_var2 by var3 and shift the result left by 1. Add the 64 bit |
+| result to L64_var1, return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| L_var2 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var2 <= 0x7fff ffff |
+| |
+| var3 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var3 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mac_32_16 (Word64 L64_var1, Word32 L_var2, Word16 var3) {
+ Word64 L64_var_out = ((Word64) L_var2*var3) << 1;
+ L64_var_out += L64_var1;
+#if (WMOPS)
+ multiCounter[currCounter].W_mac_32_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+
+/*_________________________________________________________________________________________________
+| |
+| Function Name : W_msu_32_16 |
+| |
+| Purpose : |
+| |
+| Multiply L_var2 by var3 and shift the result left by 1. Subtract the 64 bit |
+| result from L64_var1, return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| L_var2 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var2 <= 0x7fff ffff |
+| |
+| var3 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var3 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_msu_32_16(Word64 L64_var1, Word32 L_var2, Word16 var3) {
+ Word64 L64_var_out = ((Word64 )L_var2*var3) << 1;
+ L64_var_out = L64_var1 - L64_var_out;
+#if (WMOPS)
+ multiCounter[currCounter].W_msu_32_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+
+/*_________________________________________________________________________________________________
+| |
+| Function Name : W_mult_32_16 |
+| |
+| Purpose : |
+| |
+| Multiply L_var1 by var2 and shift the result left by 1. Return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L_var1 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var2 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mult_32_16(Word32 L_var1, Word16 var2) {
+ Word64 L64_var_out = ((Word64 )L_var1*var2) << 1;
+#if (WMOPS)
+ multiCounter[currCounter].W_mult_32_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_mult0_16_16 |
+| |
+| Purpose : |
+| |
+| Multiply var1 by var2 and return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| var1 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mult0_16_16(Word16 var1, Word16 var2) {
+ Word64 L64_var_out = (Word64 )var1*var2;
+#if (WMOPS)
+ multiCounter[currCounter].W_mult0_16_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_mac0_16_16 |
+| |
+| Purpose : |
+| |
+| Multiply var2 by var3 and add the 64 bit result to L64_var1, return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var2 <= 0x0000 7fff. |
+| |
+| var3 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var3 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mac0_16_16(Word64 L64_var1, Word16 var2, Word16 var3) {
+ Word64 L64_var_out = (Word64 )var2*var3;
+ L64_var_out += L64_var1;
+#if (WMOPS)
+ multiCounter[currCounter].W_mac0_16_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_msu0_16_16 |
+| |
+| Purpose : |
+| |
+| Multiply var2 by var3 and subtract the 64 bit result from L64_var1, return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var2 <= 0x0000 7fff. |
+| |
+| var3 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var3 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_msu0_16_16 (Word64 L64_var1, Word16 var2, Word16 var3) {
+ Word64 L64_var_out = (Word64) var2*var3;
+ L64_var_out = L64_var1 - L64_var_out;
+#if (WMOPS)
+ multiCounter[currCounter].W_msu0_16_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+
+
+/*_____________________________________________________________________________________
+| |
+| Function Name : W_sat_l |
+| |
+| Purpose : |
+| |
+| Saturate the lower 32 bits of the 64 bit input number L64_var into 32 bits. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_var_out |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. |
+|_____________________________________________________________________________________|
+*/
+Word32 W_sat_l (Word64 L64_var) {
+ Word32 L_var_out;
+
+ if (L64_var > 0x7FFFFFFF) {
+ L_var_out = 0x7FFFFFFF;
+ }
+ else if (L64_var < (int)0x80000000) {
+ L_var_out = 0x80000000;
+ }
+ else {
+ L_var_out = (Word32)L64_var;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_sat_l++;
+#endif /* if WMOPS */
+
+ return L_var_out;
+}
+
+
+
+/*___________________________________________________________________________________
+| |
+| Function Name : W_sat_m |
+| |
+| Purpose : |
+| |
+| Truncates the lower 16 bits of the 64 bit input L64_var |
+| and saturates the number into 32 bits. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_var_out |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. |
+|_____________________________________________________________________________________|
+*/
+Word32 W_sat_m (Word64 L64_var) {
+ Word32 L_var_out;
+
+ L64_var = L64_var >> 16;
+ L_var_out = W_sat_l (L64_var);
+
+#if (WMOPS)
+ multiCounter[currCounter].W_sat_l--;
+ multiCounter[currCounter].W_sat_m++;
+#endif /* if WMOPS */
+
+ return L_var_out;
+}
+
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_deposit32_l |
+| |
+| Purpose : |
+| |
+| Deposit the 32 bit L_var1 into the 32 LS bits of the 64 bit output. The |
+| 32 MS bits of the output are sign extended. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L_var1 |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= var_out <= 0x7fff 0000. | |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|__________________________________________________________________________________|
+*/
+Word64 W_deposit32_l (Word32 L_var1) {
+ Word64 L64_var_out;
+
+ L64_var_out = (Word64) L_var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].W_deposit32_l++;
+#endif
+
+ return (L64_var_out);
+}
+
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_deposit32_h |
+| |
+| Purpose : |
+| |
+| Deposit the 32 bit L_var1 into the 32 MS bits of the 64 bit output. The |
+| 32 LS bits of the output are zeroed. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L_var1 |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= var_out <= 0x7fff 0000. | |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|__________________________________________________________________________________|
+*/
+Word64 W_deposit32_h (Word32 L_var1) {
+ Word64 L64_var_out;
+
+ L64_var_out = (Word64) L_var1 << 32;
+
+#if (WMOPS)
+ multiCounter[currCounter].W_deposit32_h++;
+#endif
+
+ return (L64_var_out);
+}
+
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_extract_l |
+| |
+| Purpose : |
+| |
+| Return the 32 LSB of L64_var1. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_var_out |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. |
+|__________________________________________________________________________________|
+*/
+Word32 W_extract_l (Word64 L64_var1) {
+ Word32 L_var_out;
+
+ L_var_out = (Word32) L64_var1;
+
+#if (WMOPS)
+ multiCounter[currCounter].W_extract_l++;
+#endif /* if WMOPS */
+
+ return (L_var_out);
+}
+
+
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_extract_h |
+| |
+| Purpose : |
+| |
+| Return the 32 MSB of L64_var1. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_var_out |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var_out <= 0x7fff 0000. |
+|__________________________________________________________________________________|
+*/
+Word32 W_extract_h (Word64 L64_var1) {
+ Word32 L_var_out;
+
+ L_var_out = (Word32) (L64_var1 >> 32);
+
+#if (WMOPS)
+ multiCounter[currCounter].W_extract_h++;
+#endif /* if WMOPS */
+
+ return (L_var_out);
+}
+
+
+
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_mult_16_16 |
+| |
+| Purpose : |
+| |
+| Multiply var1 by var2 and shift the result left by 1. Return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| var1 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mult_16_16 (Word16 var1, Word16 var2) {
+ Word64 L64_var_out = ((Word64) var1*var2) << 1;
+#if (WMOPS)
+ multiCounter[currCounter].W_mult_16_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_mac_16_16 |
+| |
+| Purpose : |
+| |
+| Multiply var1 by var2 and shift the result left by 1 and add the 64 bit result to L64_acc, |
+| return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_acc |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_acc <= 0x7fffffff ffffffffLL. |
+| |
+| var1 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var2 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mac_16_16 (Word64 L64_acc, Word16 var1, Word16 var2) {
+ Word64 L64_var_out = ((Word64) var1*var2) << 1;
+ L64_acc = L64_acc + L64_var_out;
+
+#if (WMOPS)
+ multiCounter[currCounter].W_mac_16_16++;
+#endif /* if WMOPS */
+ return L64_acc;
+}
+
+
+
+/*________________________________________________________________________________________________
+| |
+| Function Name : W_msu_16_16 |
+| |
+| Purpose : |
+| |
+| Multiply var2 by var3 and shift the result left by1 and subtract the 64 bit result |
+| from L64_var1, return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var2 <= 0x0000 7fff. |
+| |
+| var3 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var3 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_msu_16_16 (Word64 L64_var1, Word16 var2, Word16 var3) {
+ Word64 L64_var_out = ((Word64)var2*var3) << 1;
+ L64_var_out = L64_var1 - L64_var_out;
+#if (WMOPS)
+ multiCounter[currCounter].W_msu_16_16++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+
+/*___________________________________________________________________________
+| |
+| Function Name : W_shl_sat_l |
+| |
+| Purpose : |
+| |
+| Arithmetically shift the 64 bit input L64_var left by n positions with |
+| lower 32 bit saturation and return the 32 LSB of 64 bit result |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var <= 0x7fffffff ffffffffLL. |
+| |
+| n |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= n <= 0x7fff 0000. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_result |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_result <= 0x7fff 0000. |
+|___________________________________________________________________________|
+*/
+Word32 W_shl_sat_l (Word64 L64_var, Word32 n) {
+ Word32 L_result;
+ Word64 d_var_64;
+
+ d_var_64 = W_shl (L64_var, n);
+ L_result = W_sat_l (d_var_64);
+
+#if (WMOPS)
+ multiCounter[currCounter].W_shl_sat_l++;
+ multiCounter[currCounter].W_shl--;
+ multiCounter[currCounter].W_sat_l--;
+#endif /* if WMOPS */
+
+ return L_result;
+}
+
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_round48_L |
+| |
+| Purpose : |
+| |
+| Round asymmetrically lower 16 bits, and |
+| saturate the 17.47-bit values to 1.31-bit values |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_var_out |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+|__________________________________________________________________________________|
+*/
+Word32 W_round48_L (Word64 L64_var1) {
+ Word64 L64_var_out;
+ Word32 L_result;
+
+ Word64 L64_var2 = 0x80000000;
+ Word64 L64_MIN = 0x8000000000000000LL;
+ Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL;
+
+ L64_var1 = W_shl (L64_var1, 16);
+
+ L64_var_out = L64_var1 + L64_var2;
+
+ if ( ( (L64_var1 ^ L64_var2) & L64_MIN) == 0) {
+ if ( (L64_var_out ^ L64_var1) & L64_MIN) {
+ L64_var_out = (L64_var1 < 0) ? L64_MIN : L64_MAX;
+ Overflow = 1;
+ }
+ }
+ L_result = W_extract_h (L64_var_out);
+#if (WMOPS)
+ multiCounter[currCounter].W_round48_L++;
+ multiCounter[currCounter].W_extract_h--;
+ multiCounter[currCounter].W_shl--;
+#endif /* if WMOPS */
+
+ return (L_result);
+}
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_round32_s |
+| |
+| Purpose : |
+| |
+| Round asymmetrically lower 32 bits, and |
+| saturate the 17.47-bit values to 1.15-bit values |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| var_out |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var_out <= 0x0000 7fff. |
+|__________________________________________________________________________________|
+*/
+Word16 W_round32_s (Word64 L64_var1) {
+ Word64 L64_var_out;
+ Word32 L_var;
+ Word16 var_out;
+
+
+ Word64 L64_var2 = 0x800000000000LL;
+ Word64 L64_MIN = 0x8000000000000000LL;
+ Word64 L64_MAX = 0x7FFFFFFFFFFFFFFFLL;
+
+ L64_var1 = W_shl (L64_var1, 16);
+ L64_var_out = L64_var1 + L64_var2;
+
+ if (((L64_var1 ^ L64_var2) & L64_MIN) == 0) {
+ if ((L64_var_out ^ L64_var1) & L64_MIN) {
+ L64_var_out = (L64_var1 < 0) ? L64_MIN : L64_MAX;
+ Overflow = 1;
+ }
+ }
+ L_var = W_extract_h (L64_var_out);
+ var_out = extract_h (L_var);
+#if (WMOPS)
+ multiCounter[currCounter].W_round32_s ++;
+ multiCounter[currCounter].W_extract_h--;
+ multiCounter[currCounter].extract_h--;
+ multiCounter[currCounter].W_shl--;
+#endif /* if WMOPS */
+
+ return (var_out);
+}
+/*___________________________________________________________________________
+| |
+| Function Name : W_norm |
+| |
+| Purpose : |
+| |
+| Produces the number of left shifts needed to normalize the 64 bit varia-|
+| ble L64_var1.
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| var_out |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0x0000 0000 <= var_out <= 0x0000 003f. |
+|___________________________________________________________________________|
+*/
+Word16 W_norm (Word64 L64_var1) {
+ Word16 var_out;
+ if (L64_var1 == 0) {
+ var_out = 0;
+ }
+ else {
+ if (L64_var1 == (Word64) 0xffffffffffffffffLL) {
+ var_out = 63;
+ }
+ else {
+ if (L64_var1 < 0) {
+ L64_var1 = ~L64_var1;
+ }
+ for (var_out = 0; L64_var1 < (Word64) 0x4000000000000000LL; var_out++) {
+ L64_var1 <<= 1;
+ }
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].W_norm ++;
+#endif /* if WMOPS */
+ return (var_out);
+}
+
+
+
+/*______________________________________________________________________________
+| |
+| Function Name : W_add |
+| |
+| Purpose : |
+| |
+| 64 bits addition of the two 64 bits variables (L64_var1+L64_var2) with |
+| overflow control and saturation; the result is set at 0x7fffffffffffffffLL |
+| when overflow occurs or at 0x8000000000000000LL when underflow occurs. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| L64_var2 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|_______________________________________________________________________________|
+*/
+Word64 W_add (Word64 L64_var1, Word64 L64_var2) {
+ Word64 L64_var_out;
+
+ L64_var_out = L64_var1 + L64_var2;
+
+ if (((L64_var1 ^ L64_var2) & MIN_64) == 0) {
+ if ((L64_var_out ^ L64_var1) & MIN_64) {
+ L64_var_out = (L64_var1 < 0) ? MIN_64 : MAX_64;
+ Overflow = 1;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_add++;
+#endif
+ return L64_var_out;
+}
+
+/*______________________________________________________________________________
+| |
+| Function Name : W_sub |
+| |
+| Purpose : |
+| |
+| 64 bits subtraction of the two 64 bits variables (L64_var1-L64_var2) with |
+| overflow control and saturation; the result is set at 0x7fffffffffffffffLL |
+| when overflow occurs or at 0x8000000000000000LL when underflow occurs. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| L64_var2 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|_______________________________________________________________________________|
+*/
+Word64 W_sub (Word64 L64_var1, Word64 L64_var2) {
+ Word64 L64_var_out;
+
+ L64_var_out = L64_var1 - L64_var2;
+
+ if (((L64_var1 ^ L64_var2) & MIN_64) != 0) {
+ if ((L64_var_out ^ L64_var1) & MIN_64) {
+ L64_var_out = (L64_var1 < 0) ? MIN_64 : MAX_64;
+ Overflow = 1;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_add++;
+#endif
+ return L64_var_out;
+}
+
+
+/*______________________________________________________________________________
+| |
+| Function Name : W_neg |
+| |
+| Purpose : |
+| |
+| Negate the 64 bit variable L64_var1 with overflow control and saturation; |
+| Saturate and set overflow in the case where input is 0x8000000000000000LL. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+|_______________________________________________________________________________|
+*/
+Word64 W_neg (Word64 L64_var1) {
+ Word64 L64_var_out;
+
+ if (L64_var1 == MIN_64) {
+ L64_var_out = MAX_64;
+ Overflow = 1;
+ }
+ else {
+ L64_var_out = -L64_var1;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_neg++;
+#endif
+
+ return (L64_var_out);
+
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : W_abs |
+ | |
+ | Purpose : |
+ | |
+ | Absolute value of L64_var1; Saturate in case where the input is |
+ | 0x8000000000000000LL |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | L64_var1 64 bit long signed integer (Word64) whose value falls in the |
+ | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | L64_var_out |
+ | 64 bit long signed integer (Word64) whose value falls in the |
+ | range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+ |___________________________________________________________________________|
+*/
+Word64 W_abs (Word64 L64_var1) {
+ Word64 L64_var_out;
+
+ if (L64_var1 == MIN_64) {
+ L64_var_out = MAX_64;
+ Overflow = 1;
+ }
+ else {
+ if (L64_var1 < 0) {
+ L64_var_out = -L64_var1;
+ }
+ else {
+ L64_var_out = L64_var1;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_abs++;
+#endif
+
+ return (L64_var_out);
+}
+
+/*_________________________________________________________________________________________________
+| |
+| Function Name : W_mult_32_32 |
+| |
+| Purpose : |
+| |
+| Multiply L_var1 by L_var2 and shift the result left by 1.Saturate and set overflow in case |
+| where both inputs are 0x80000000 . Return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L_var1 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| L_var2 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mult_32_32(Word32 L_var1, Word32 L_var2) {
+ Word64 L64_var_out;
+
+ if ((L_var1 == MIN_32) && (L_var2 == MIN_32)) {
+ L64_var_out = MAX_64;
+ Overflow = 1;
+ }
+ else {
+ L64_var_out = ((Word64 )L_var1*L_var2) << 1;
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].W_mult_32_32++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+/*_________________________________________________________________________________________________
+| |
+| Function Name : W_mult0_32_32 |
+| |
+| Purpose : |
+| |
+| Multiply L_var1 by L_var2. Return a 64 bit result. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L_var1 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| L_var2 |
+| 32 bit signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var1 <= 0x7fff ffff |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long long signed integer (Word64) whose value falls in the |
+| range : 0x80000000 00000000LL <= L64_var_out <= 0x7fffffff ffffffffLL. |
+|_________________________________________________________________________________________________|
+*/
+Word64 W_mult0_32_32 (Word32 L_var1, Word32 L_var2) {
+ Word64 L64_var_out;
+
+ L64_var_out = (Word64) L_var1*L_var2;
+
+
+#if (WMOPS)
+ multiCounter[currCounter].W_mult0_32_32++;
+#endif /* if WMOPS */
+ return L64_var_out;
+}
+
+
+/*_____________________________________________________________________________
+| |
+| Function Name : W_lshl |
+| |
+| Purpose : |
+| |
+| Logically shift the 64 bit unsigned input L64_var1 left by var2 positions. |
+| Zero fill the var2 LSB of the result. If var2 is negative, logically shift |
+| L64_var1 right by -var2 with zero fill in the MSB. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long unsigned signed integer (UWord64) whose value falls |
+| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long unsigned signed integer (UWord64) whose value falls |
+| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. |
+|______________________________________________________________________________|
+*/
+UWord64 W_lshl (UWord64 L64_var1, Word16 var2) {
+
+ UWord64 L64_var_out = 0LL;
+
+ if (var2 < 0) {
+ L64_var_out = L64_var1 >> (-var2);
+ }
+ else {
+ L64_var_out = L64_var1 << var2 ;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].W_lshl++;
+#endif
+
+ return (L64_var_out);
+}
+
+/*_____________________________________________________________________________
+| |
+| Function Name : W_lshr |
+| |
+| Purpose : |
+| |
+| Logically shift the 64 bit unsigned input L64_var1 right by var2 positions.|
+| Zero fill the var2 MSB of the result. If var2 is negative, logically shift |
+| L64_var1 left by -var2 with zero fill in the LSB. |
+| |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 64 bit long unsigned signed integer (UWord64) whose value falls |
+| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. |
+| |
+| var2 |
+| 16 bit short signed integer (Word16) whose value falls in the |
+| range : 0xffff 8000 <= var1 <= 0x0000 7fff. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L64_var_out |
+| 64 bit long unsigned signed integer (UWord64) whose value falls |
+| in the range : 0LL <= L64_var1 <= 0xffffffff ffffffffLL. |
+|______________________________________________________________________________|
+*/
+UWord64 W_lshr (UWord64 L64_var1, Word16 var2) {
+
+ UWord64 L64_var_out = 0LL;
+
+ if (var2 < 0) {
+ L64_var_out = L64_var1 << (-var2);
+ }
+ else {
+ L64_var_out = L64_var1 >> var2 ;
+ }
+#if (WMOPS)
+ multiCounter[currCounter].W_lshr++;
+#endif
+
+ return (L64_var_out);
+}
+
+
+/*__________________________________________________________________________________
+| |
+| Function Name : W_round64_L |
+| |
+| Purpose : |
+| |
+| Round asymmetrically lower 32 bits, and |
+| saturate the 1.63-bit values to 1.31-bit values |
+| Complexity weight : 1 |
+| |
+| Inputs : |
+| |
+| L64_var1 |
+| 64 bit long long signed integer (Word64) whose value falls in |
+| range : 0x80000000 00000000LL <= L64_var1 <= 0x7fffffff ffffffffLL. |
+| |
+| Outputs : |
+| |
+| none |
+| |
+| Return Value : |
+| |
+| L_var_out |
+| 32 bit long signed integer (Word32) whose value falls in the |
+| range : 0x8000 0000 <= L_var_out <= 0x7fff ffff. |
+|__________________________________________________________________________________|
+*/
+Word32 W_round64_L (Word64 L64_var1) {
+ Word64 L64_var_out;
+ Word32 L_result;
+
+
+ Word64 L64_tmp = 0x80000000;
+ L64_var_out = W_add (L64_var1, L64_tmp);
+ L_result = W_extract_h (L64_var_out);
+
+#if (WMOPS)
+ multiCounter[currCounter].W_round64_L++;
+ multiCounter[currCounter].W_extract_h--;
+ multiCounter[currCounter].W_add--;
+#endif /* if WMOPS */
+
+ return (L_result);
+}
+
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+/* end of file */
diff --git a/basic_op/enh64.h b/basic_op/enh64.h
new file mode 100644
index 0000000000000000000000000000000000000000..ac15ffdcd98da585c2aa55d3e933056ebcf436f2
--- /dev/null
+++ b/basic_op/enh64.h
@@ -0,0 +1,73 @@
+
+#ifndef _ENH64_H
+#define _ENH64_H
+
+#include "stl.h"
+
+#ifndef Word64
+#define Word64 long long int
+#endif
+
+#ifndef UWord64
+#define UWord64 unsigned long long int
+#endif
+
+#define MAX_64 (Word64)0x7fffffffffffffffLL
+#define MIN_64 (Word64)0x8000000000000000LL
+
+ /*****************************************************************************
+ *
+ * Prototypes for enhanced 64 bit arithmetic operators
+ *
+ *****************************************************************************/
+#ifdef ENH_64_BIT_OPERATOR
+Word64 W_add_nosat (Word64 L64_var1, Word64 L64_var2);
+Word64 W_sub_nosat (Word64 L64_var1, Word64 L64_var2);
+Word64 W_shl (Word64 L64_var1, Word16 var2);
+Word64 W_shr (Word64 L64_var1, Word16 var2);
+Word64 W_shl_nosat (Word64 L64_var1, Word16 var2);
+Word64 W_shr_nosat (Word64 L64_var1, Word16 var2);
+Word64 W_mult_32_16 (Word32 L_var1, Word16 var2);
+Word64 W_mac_32_16 (Word64 L64_acc, Word32 L_var1, Word16 var2);
+Word64 W_msu_32_16 (Word64 L64_acc, Word32 L_var1, Word16 var2);
+Word64 W_mult0_16_16 (Word16 var1, Word16 var2);
+Word64 W_mac0_16_16 (Word64 L64_acc, Word16 var1, Word16 var2);
+Word64 W_msu0_16_16 (Word64 L64_acc, Word16 var1, Word16 var2);
+Word64 W_mult_16_16 (Word16 var1, Word16 var2);
+Word64 W_mac_16_16 (Word64 L64_acc, Word16 var1, Word16 var2);
+Word64 W_msu_16_16 (Word64 L64_acc, Word16 var1, Word16 var2);
+
+Word64 W_deposit32_l (Word32 L_var1);
+Word64 W_deposit32_h (Word32 L_var1);
+
+Word32 W_sat_l (Word64 L64_var);
+Word32 W_sat_m (Word64 L64_var);
+Word32 W_shl_sat_l (Word64 L64_var, Word32 n);
+
+Word32 W_extract_l (Word64 L64_var1);
+Word32 W_extract_h (Word64 L64_var1);
+
+Word32 W_round48_L (Word64 L64_var1);
+Word16 W_round32_s (Word64 L64_var1);
+
+Word16 W_norm (Word64 L_var1);
+
+
+Word64 W_add (Word64 L64_var1, Word64 L64_var2);
+Word64 W_sub (Word64 L64_var1, Word64 L64_var2);
+Word64 W_neg (Word64 L64_var1);
+Word64 W_abs (Word64 L64_var1);
+Word64 W_mult_32_32 (Word32 L_var1, Word32 L_var2);
+Word64 W_mult0_32_32 (Word32 L_var1, Word32 L_var2);
+UWord64 W_lshl (UWord64 L64_var1, Word16 var2);
+UWord64 W_lshr (UWord64 L64_var1, Word16 var2);
+Word32 W_round64_L (Word64 L64_var1) ;
+
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+#endif /*_ENH64_H*/
+
+
+/* end of file */
+
+
diff --git a/basic_op/enhUL32.c b/basic_op/enhUL32.c
new file mode 100644
index 0000000000000000000000000000000000000000..9f82d044348b8cefcfdfb443e182457a16e9655c
--- /dev/null
+++ b/basic_op/enhUL32.c
@@ -0,0 +1,409 @@
+/*
+ ============================================================================
+ File: ENHUL32.C v.1.0 - 01.July.2018
+ ============================================================================
+
+ ENHANCED UNSIGNED 32-BIT ARITHMETIC OPERATORS
+ History:
+ v.0.5 - 21.March.2014
+
+ ============================================================================
+*/
+
+ /*****************************************************************************
+ *
+ * Enhanced Unsigned 32 bit operators :
+ * see complete list in .h file
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Include-Files
+ *
+ *****************************************************************************/
+#include
+#include
+#include "stl.h"
+#include "enhUL32.h"
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* if WMOPS */
+
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *
+ * Functions
+ *
+ *****************************************************************************/
+#ifdef ENH_U_32_BIT_OPERATOR
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : UL_deposit_l |
+ | |
+ | Purpose : |
+ | |
+ | Deposit the 16 bit var1 into the 16 LS bits of the 32 bit output. The |
+ | 16 MS bits of the output are not sign extended. |
+ |___________________________________________________________________________|
+*/
+
+UWord32 UL_deposit_l (UWord16 uvar) {
+ UWord32 UL_result;
+ UL_result = (UWord32) uvar; /* no sign extension*/
+#if (WMOPS)
+ multiCounter[currCounter].UL_deposit_l++;
+#endif
+ return (UL_result);
+}
+
+/*_____________________________________________________________________________
+ | |
+ | Function Name : norm_ul |
+ | |
+ | Purpose : |
+ | |
+ | Produces the number of left shifts needed to normalize the 32 bit varia- |
+ | ble UL_var1 for positive values on the interval with minimum of |
+ | 0 and maximum of 0xffffffff, ; in order to normalize the |
+ | result, the following operation must be done : |
+ | |
+ | norm_UL_var1 = UL_lshl(UL_var1, norm_ul(UL_var1)). |
+ | |
+ | Complexity weight : 1 |
+ | |
+ | Inputs : |
+ | |
+ | UL_var1 |
+ | 32 bit long unsigned integer (UWord32) whose value falls in the |
+ | range : 0x0000 0000 <= var1 <= 0xffff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | |
+ | var_out |
+ | 16 bit short signed integer (Word16) whose value falls in the |
+ | range : 0x0000 0000 <= var_out <= 0x0000 001f. (0..31d) |
+ |_____________________________________________________________________________|
+*/
+Word16 norm_ul (UWord32 UL_var1) {
+ Word16 var_out;
+
+ if (UL_var1 == 0) {
+ var_out = 0;
+ }
+ else {
+ /* simply test shift up until highest bit is set */
+ for (var_out = 0; UL_var1 < (UWord32) 0x80000000U; var_out++) {
+ UL_var1 <<= 1;
+ }
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].norm_ul++;
+#endif
+
+ return (var_out);
+}
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : UL_addNs |
+ | |
+ | Purpose : |
+ | |
+ | 32 bits addition of the two unsigned 32 bits variables |
+ | (L_var1+L_var2) with overflow control, but without saturation |
+ | |
+ | Outputs : |
+ | |
+ | *wrap = 1 if wrap occured, otherwize 0 |
+ | |
+ | Return Value : |
+ | |
+ | UL_var3 = modulo(UL_var1+UL_var2,32) |
+ |___________________________________________________________________________|
+*/
+
+UWord32 UL_addNs (UWord32 UL_var1, UWord32 UL_var2, UWord16 * wrap) {
+ UWord32 UL_var3;
+
+ /* STL Overflow flag is not updated */
+ UL_var3 = UL_var1 + UL_var2; /* 32-bit wrap may occur, like in C */
+
+ if (((UWord64) UL_var1 + (UWord64) UL_var2) > 0xFFFFFFFFU) {
+ *wrap = 1; /* wrapped output */
+ }
+ else {
+ *wrap = 0;
+ }
+
+#if WMOPS
+ multiCounter[currCounter].UL_addNs++;
+#endif
+
+ return UL_var3;
+}
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : UL_subNs |
+ | |
+ | Purpose : |
+ | |
+ | 32 bits subtraction of the two unsigned 32 bits variables |
+ | (L_var1-L_var2) with overflow control, but without saturation |
+ | |
+ | Outputs : |
+ | |
+ | *sgn = 1 if wrap (to "negative" occured, otherwise 0) |
+ | |
+ | Return Value : |
+ | |
+ | UL_var3 = modulo(UL_var1-UL_var2,32) |
+ |___________________________________________________________________________|
+*/
+
+UWord32 UL_subNs (UWord32 UL_var1, UWord32 UL_var2, UWord16 * sgn) {
+ UWord32 UL_var3;
+
+ UL_var3 = UL_var1 - UL_var2; /*wrap may occur, like in C */
+ if (UL_var1 >= UL_var2) {
+ *sgn = 0;
+ }
+ else {
+ *sgn = 1; /* "negative", wrapped output */
+ }
+
+#if WMOPS
+ multiCounter[currCounter].UL_subNs++;
+#endif
+ return UL_var3;
+}
+
+/*________________________________________________________________________________
+ | |
+ | Function Name : Mpy_32_16_uu |
+ | |
+ | Purpose : |
+ | |
+ | Multiplies the 2 unsigned values UL_var1 and uvar2. |
+ | The operation is performed in fractional mode : |
+ | - UL_var1 is supposed to be in Q32 format. |
+ | - var2 is supposed to be in Q16 format. |
+ | - The result is produced in Q48 format : UL_varout_h points to the |
+ | 32 MSBits while varout_l points to the 16 LSBits. |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in |
+ | the range : 0x0000 0000 <= L_var1 <= 0xffff ffff. |
+ | |
+ | var2 16 bit short unsigned integer (UWord16) whose value falls in |
+ | the range : 0x0000 <= var2 <= 0x0000 ffff. |
+ | |
+ | Outputs : |
+ | |
+ | *UL_varout_h 32 bit long unsigned integer (UWord32) whose value falls in |
+ | the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. |
+ | |
+ | *varout_l 16 bit short unsigned integer (UWord16) whose value falls in |
+ | the range : 0x0000 0000 <= varout_l <= 0x0000 ffff. |
+ | |
+ | Return Value : |
+ | |
+ | none |
+ |________________________________________________________________________________|
+*/
+void Mpy_32_16_uu (UWord32 UL_var1, UWord16 uvar2, UWord32 *UL_varout_h, UWord16 *varout_l) {
+ UWord64 UL64_var1;
+
+ /* 4294967295 * 65535 < 281474976710655 */
+ /* (uint64(2)^16-1 )*(uint64(2)^32-1) < (uint64(2)^(16+32)-1) */
+ UL64_var1 = ((UWord64) UL_var1)*((UWord64) uvar2);
+ *varout_l = (UWord16) UL64_var1;
+ *UL_varout_h = (UWord32) (UL64_var1>>16);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_uu++;
+#endif /* if WMOPS */
+
+ return;
+}
+
+/*__________________________________________________________________________________
+ | |
+ | Function Name : Mpy_32_32_uu |
+ | |
+ | Purpose : |
+ | |
+ | Multiplies the 2 unsigned values UL_var1 and UL_var2. |
+ | The operation is performed in fractional mode : |
+ | - UL_var1 and UL_var2 are supposed to be in Q32 format. |
+ | - The result is produced in Q64 format : UL_varout_h points to the |
+ | 32 MSBits while UL_varout_l points to the 32 LSBits. |
+ | |
+ | Complexity weight : 4 |
+ | |
+ | Inputs : |
+ | |
+ | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the |
+ | range : 0x0000 0000 <= L_var1 <= 0xffff ffff. |
+ | |
+ | UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the |
+ | range : 0x0000 0000 <= L_var2 <= 0xffff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | *UL_varout_h 32 bit long signed integer (Word32) whose value falls in |
+ | the range : 0x0000 0000 <= UL_varout_h <= 0xffff ffff. |
+ | |
+ | *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in |
+ | the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. |
+ | |
+ | Return Value : |
+ | |
+ | none |
+ |__________________________________________________________________________________|
+ */
+void Mpy_32_32_uu (UWord32 UL_var1, UWord32 UL_var2, UWord32 *UL_varout_h, UWord32 *UL_varout_l) {
+ UWord64 UL64_var1;
+ /* (uint64(2)^32-1 )*(uint64(2)^32-1) < (uint64(2)^(32+32)-1) */
+ UL64_var1 = ((UWord64) UL_var1)*((UWord64) UL_var2);
+ *UL_varout_h = (UWord32)(UL64_var1>>32);
+ *UL_varout_l = (UWord32)(UL64_var1);
+
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_32_uu++;
+#endif /* if WMOPS */
+
+ return;
+}
+
+/*_____________________________________________________________________________________
+ | |
+ | Function Name : UL_Mpy_32_32 |
+ | |
+ | Purpose : |
+ | |
+ | Multiplies the 2 unsigned values UL_var1 and UL_var2 |
+ | and returns the lower 32 bits, without saturation control. |
+ | |
+ | - UL_var1 and UL_var2 are supposed to be in Q32 format. |
+ | - The result is produced in Q64 format, the 32 LSBits. |
+ | |
+ | operates like a regular 32-by-32 bit unsigned int multiplication in ANSI-C. |
+ | UWord32) = (unsigned int)*(unsigned int); |
+ | |
+ | |
+ | Complexity weight : 2 |
+ | |
+ | Inputs : |
+ | |
+ | UL_var1 32 bit long unsigned integer (UWord32) whose value falls in the |
+ | range : 0x0000 0000 <= UL_var1 <= 0xffff ffff. |
+ | |
+ | UL_var2 32 bit long unsigned integer (UWord32) whose value falls in the |
+ | range : 0x0000 0000 <= UL_var2 <= 0xffff ffff. |
+ | |
+ | Outputs : |
+ | |
+ | none |
+ | |
+ | Return Value : |
+ | *UL_varout_l 32 bit short unsigned integer (UWord32) whose value falls in |
+ | the range : 0x0000 0000 <= UL_varout_l <= 0xffff ffff. |
+ | |
+ |_____________________________________________________________________________________|
+*/
+UWord32 UL_Mpy_32_32 (UWord32 UL_var1, UWord32 UL_var2) {
+ UWord32 UL_varout_l;
+
+#define MASK32 0xFFFFFFFFU
+ /* MASK32 may be needed in case Hardware is using larger than 32 bits for UWord32 type */
+ UL_varout_l = (UL_var1&MASK32)*(UL_var2&MASK32);
+ UL_varout_l = UL_varout_l&MASK32;
+#undef MASK32
+
+#if (WMOPS)
+ multiCounter[currCounter].UL_Mpy_32_32++;
+#endif /* if WMOPS */
+
+ return UL_varout_l;
+}
+
+
+#ifdef STL_TYPECASTS
+/* (Reuse of existing signed STL "L" operators) with
+ typecasting to make the resulting "UL" code a lot cleaner and more readable. */
+
+UWord32 UL_lshl( UWord32 UL_var1, Word16 var2) {
+ return( (UWord32)L_lshl( (Word32) UL_var1, var2));
+}
+
+UWord32 UL_lshr( UWord32 UL_var1, Word16 var2) {
+ return( (UWord32)L_lshr( (Word32) UL_var1, var2) );
+}
+
+UWord32 UL_and(UWord32 UL_var1, UWord32 UL_var2 )
+{
+ return (UWord32) L_and((Word32)UL_var1,(Word32) UL_var2);
+}
+
+UWord32 UL_or(UWord32 UL_var1, UWord32 UL_var2 )
+{
+ return (UWord32) L_or((Word32)UL_var1,(Word32) UL_var2);
+}
+
+UWord32 UL_xor(UWord32 UL_var1, UWord32 UL_var2 )
+{
+ return (UWord32) L_xor((Word32)UL_var1,(Word32) UL_var2);
+}
+
+UWord32 UL_deposit_h(UWord16 uvar1)
+{
+ return (UWord32) L_deposit_h((Word32)uvar1);
+}
+
+UWord16 u_extract_h(UWord32 UL_var1)
+{
+ return (UWord16) extract_h((Word32)UL_var1);
+}
+
+UWord16 u_extract_l(UWord32 UL_var1)
+{
+ return (UWord32)extract_l((Word32)UL_var1);
+}
+
+/* enable convenient reuse of Non-saturating UL_subNs , UL_addNs while "D"iscarding the sgn/wrap output flags */
+UWord32 UL_subNsD(UWord32 UL_var1, UWord32 UL_var2 )
+{
+ UWord16 dummy_sign;
+ return UL_subNs(UL_var1,UL_var2,&dummy_sign );
+}
+
+UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2 )
+{
+ UWord16 dummy_wrap;
+ return UL_addNs(UL_var1,UL_var2,&dummy_wrap );
+}
+#endif
+
+#endif /* ENH_U_32_BIT_OPERATOR */
+
+/* end of file */
diff --git a/basic_op/enhUL32.h b/basic_op/enhUL32.h
new file mode 100644
index 0000000000000000000000000000000000000000..a89b2489b20ef5b55ec2fb1d1de3bc15e3b48834
--- /dev/null
+++ b/basic_op/enhUL32.h
@@ -0,0 +1,76 @@
+/*
+ ============================================================================
+ File: ENHUL32.H v.1.0 - 01.July.2018
+ ============================================================================
+
+
+ ============================================================================
+*/
+
+#ifndef _ENHUL32_H
+#define _ENHUL32_H
+
+/*****************************************************************************
+ *
+ * Constants and Globals
+ *
+ *****************************************************************************/
+#define STL_TYPECASTS /* logical shift and bitwise manipulation functions */
+ /* algorithmically exact to existing signed L_lshr and L_lshr */
+
+#include "stl.h"
+
+#ifndef UWord64
+#define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */
+#endif
+
+#if (WMOPS)
+#include "count.h"
+extern BASIC_OP multiCounter[MAXCOUNTERS]; /* existing signed counters are reused for unsigedn operators */
+extern int currCounter;
+#endif /* if WMOPS */
+
+/*****************************************************************************
+ *
+ * Prototypes for enhanced unsigned 32 bit arithmetic operators
+ *
+ *****************************************************************************/
+#ifdef ENH_U_32_BIT_OPERATOR
+UWord32 UL_addNs (UWord32 a, UWord32 b, UWord16* wrap);
+UWord32 UL_subNs (UWord32 a, UWord32 b, UWord16* sgn);
+
+UWord32 UL_Mpy_32_32 (UWord32 a, UWord32 b);
+void Mpy_32_32_uu (UWord32 a, UWord32 b, UWord32 *c_h, UWord32 *c_l); /* does not saturate */
+void Mpy_32_16_uu (UWord32 a, UWord16 b, UWord32 *c_h, UWord16 *c_l); /* does not saturate */
+
+Word16 norm_ul (UWord32 UL_var1);
+UWord32 UL_deposit_l (UWord16); /* deposit low without sign extension */
+#endif /* ENH_U_32_BIT_OPERATOR */
+
+/*****************************************************************************
+ *
+ * Inline Functions
+ *
+ *****************************************************************************/
+
+#ifdef STL_TYPECASTS
+/* (Reuse of existing signed STL "L" operators) with
+ typecasting to make the resulting "UL" code a lot cleaner and more readable. */
+UWord32 UL_lshl( UWord32 UL_var1, Word16 var2);
+UWord32 UL_lshr( UWord32 UL_var1, Word16 var2);
+UWord32 UL_and(UWord32 UL_var1, UWord32 UL_var2 );
+UWord32 UL_or(UWord32 UL_var1, UWord32 UL_var2 );
+UWord32 UL_xor(UWord32 UL_var1, UWord32 UL_var2 );
+UWord32 UL_deposit_h(UWord16 uvar1);
+UWord16 u_extract_h(UWord32 UL_var1);
+UWord16 u_extract_l(UWord32 UL_var1);
+
+/* enable convenient reuse of Non-saturating UL_subNs , UL_addNs
+ while "D"iscarding the sgn/wrap output flags */
+UWord32 UL_subNsD(UWord32 UL_var1, UWord32 UL_var2 );
+UWord32 UL_addNsD(UWord32 UL_var1, UWord32 UL_var2 );
+#endif
+
+#endif /*_ENHUL32_H*/
+
+/* end of file */
diff --git a/basic_op/move.h b/basic_op/move.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a02bd99c9e0d4eb41c0d6e4a2e8239678ce6953
--- /dev/null
+++ b/basic_op/move.h
@@ -0,0 +1,95 @@
+/*
+ ===========================================================================
+ File: MOVE.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ MOVE & MISC LEGACY OPERATORS
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+
+ ============================================================================
+*/
+
+
+#ifndef _MOVE_H
+#define _MOVE_H
+
+
+#include "stl.h"
+
+#if (WMOPS)
+extern BASIC_OP multiCounter[MAXCOUNTERS];
+extern int currCounter;
+#endif /* ifdef WMOPS */
+
+
+static __inline void move16 (void) {
+#if WMOPS
+ multiCounter[currCounter].move16++;
+#endif /* ifdef WMOPS */
+}
+
+
+
+
+
+
+static __inline void move32 (void) {
+#if WMOPS
+ multiCounter[currCounter].move32++;
+#endif /* ifdef WMOPS */
+}
+
+
+#ifdef ENH_64_BIT_OPERATOR
+static __inline void move64 (void) {
+#if WMOPS
+ multiCounter[currCounter].move64++;
+#endif /* if WMOPS */
+}
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+
+
+
+static __inline void test (void) {
+#if WMOPS
+ multiCounter[currCounter].Test++;
+#endif /* ifdef WMOPS */
+}
+
+
+static __inline void logic16 (void) {
+#if WMOPS
+ multiCounter[currCounter].Logic16++;
+#endif /* ifdef WMOPS */
+}
+
+
+static __inline void logic32 (void) {
+#if WMOPS
+ multiCounter[currCounter].Logic32++;
+#endif /* ifdef WMOPS */
+}
+
+
+/*-------- legacy ----------*/
+#define data_move () move16 ()
+#define L_data_move () move32 ()
+#define data_move_external () move16 ()
+#define compare_zero () test ()
+/*-------- end legacy ----------*/
+
+
+#endif /* _MOVE_H */
+
+
+/* end of file */
diff --git a/basic_op/patch.h b/basic_op/patch.h
new file mode 100644
index 0000000000000000000000000000000000000000..c843cb78bf069494e8ee897309c869ec8e70d077
--- /dev/null
+++ b/basic_op/patch.h
@@ -0,0 +1,51 @@
+/*
+ ===========================================================================
+ File: PATCH.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ OPERATOR NAME PATCHING
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+
+ ============================================================================
+*/
+
+
+#ifndef _PATCH_H
+#define _PATCH_H
+
+
+#if 1
+/*****************************************************************************
+ * start of Patch1 :
+ * It is enabled.
+ *
+ * This patch enables to keep compatibility with old ITU DSP operator names
+ * following naming conventions as proposed to ITU-T Standard Tool Library
+ * definition group in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ * TD 11 document.
+ *
+ *****************************************************************************/
+#define shift_r( var1, var2) shl_r( var1, var2)
+#define L_shift_r( L_var1, var2) L_shl_r( L_var1, var2)
+
+
+#endif /* end of Patch1 */
+
+
+
+
+
+
+
+
+
+
+#endif /* end of _PATCH_H */
diff --git a/basic_op/stl.h b/basic_op/stl.h
new file mode 100644
index 0000000000000000000000000000000000000000..0ba4c3ff353b059179c8da826aea3b76f209d000
--- /dev/null
+++ b/basic_op/stl.h
@@ -0,0 +1,69 @@
+/*
+ ===========================================================================
+ File: STL.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ MAIN HEADER FILE
+
+ History:
+ 07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+
+ ============================================================================
+*/
+
+
+#ifndef _STL_H
+#define _STL_H
+
+
+#include /* for size_t */
+
+#define ENH_U_32_BIT_OPERATOR
+#define COMPLEX_OPERATOR
+#define CONTROL_CODE_OPS
+#define ENH_32_BIT_OPERATOR
+
+#include "patch.h"
+/* both ALLOW_40bits and ALLOW_ENH_UL32 shall be enabled for the EVS codec. */
+#define ALLOW_40bits /* allow 32x16 and 32x32 multiplications */
+#define ALLOW_ENH_UL32 /* allow enhanced unsigned 32bit operators */
+#include "typedef.h"
+#include "basop32.h"
+#include "count.h"
+#include "move.h"
+#include "control.h"
+#include "enh1632.h"
+#include "oper_32b.h"
+#include "math_op.h"
+#include "log2.h"
+
+#include "enh40.h"
+
+
+#ifdef ENH_64_BIT_OPERATOR
+#include "enh64.h"
+#endif
+
+#ifdef ENH_32_BIT_OPERATOR
+#include "enh32.h"
+#endif
+
+#ifdef COMPLEX_OPERATOR
+#include "complex_basop.h"
+#endif
+
+#ifdef ENH_U_32_BIT_OPERATOR
+#include "enhUL32.h"
+#endif
+
+#endif /* ifndef _STL_H */
+
+
+/* end of file */
diff --git a/basic_op/typedef.h b/basic_op/typedef.h
new file mode 100644
index 0000000000000000000000000000000000000000..cd031a3a6e3a7964d9ddacfb6291779c2147b394
--- /dev/null
+++ b/basic_op/typedef.h
@@ -0,0 +1,102 @@
+/*
+ ===========================================================================
+ File: TYPEDEF.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ TYPE DEFINITION PROTOTYPES
+
+ History:
+ 26.Jan.00 v1.0 Incorporated to the STL from updated G.723.1/G.729
+ basic operator library (based on basic_op.h)
+
+ 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+ March 06 v2.1 Changed to improve portability.
+
+ ============================================================================
+*/
+
+
+/*_____________________
+ | |
+ | Basic types. |
+ |_____________________|
+*/
+
+
+#ifndef _TYPEDEF_H
+#define _TYPEDEF_H "$Id $"
+
+#define ORIGINAL_TYPEDEF_H /* Define to get "original" version of typedef.h (this file). */
+#undef ORIGINAL_TYPEDEF_H /* Undefine to get the "new" version of typedef.h (see typedefs.h). */
+
+
+#ifdef ORIGINAL_TYPEDEF_H
+/*
+ * This is the original code from the file typedef.h
+ */
+
+#if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__ZTC__)
+typedef signed char Word8;
+typedef short Word16;
+typedef long Word32;
+typedef __int64 Word40;
+typedef unsigned short UWord16;
+typedef unsigned long UWord32;
+typedef int Flag;
+
+#elif defined(__CYGWIN__)
+typedef signed char Word8;
+typedef short Word16;
+typedef long Word32;
+typedef long long Word40;
+typedef unsigned short UWord16;
+typedef unsigned long UWord32;
+typedef int Flag;
+
+#elif defined(__sun)
+typedef signed char Word8;
+typedef short Word16;
+typedef long Word32;
+/*#error "The 40-bit operations have not been tested on __sun : need to define Word40"*/
+typedef long long Word40;
+typedef unsigned short UWord16;
+typedef unsigned long UWord32;
+typedef int Flag;
+
+#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
+typedef signed char Word8;
+typedef short Word16;
+typedef int Word32;
+/*#error "The 40-bit operations have not been tested on unix : need to define Word40"*/
+typedef long long Word40;
+typedef unsigned short UWord16;
+typedef unsigned int UWord32;
+typedef int Flag;
+#endif
+
+
+#else /* ifdef ORIGINAL_TYPEDEF_H */ /* not original typedef.h */
+
+
+
+
+/*
+ * Use (improved) type definition file typdefs.h and add a "Flag" type.
+ */
+#include "typedefs.h"
+typedef int Flag;
+
+
+#endif /* ifdef ORIGINAL_TYPEDEF_H */
+
+
+#endif /* ifndef _TYPEDEF_H */
+
+
+/* end of file */
diff --git a/basic_op/typedefs.h b/basic_op/typedefs.h
new file mode 100644
index 0000000000000000000000000000000000000000..c0e7645a706bbbc90c4bc34adcf8d58db0035f26
--- /dev/null
+++ b/basic_op/typedefs.h
@@ -0,0 +1,218 @@
+/*
+ ===========================================================================
+ File: TYPEDEFS.H v.2.3 - 30.Nov.2009
+ ===========================================================================
+
+ ITU-T STL BASIC OPERATORS
+
+ NEW TYPE DEFINITION PROTOTYPES
+
+ History:
+ 03 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
+ operators for the ITU-T Standard Tool Library as
+ described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
+ TD 11 document and subsequent discussions on the
+ wp3audio@yahoogroups.com email reflector.
+
+ Editor comment :
+ This file is not yet used or validated since
+ ORIGINAL_TYPEDEF_H compilation flag is defined in
+ typedef.h. This file is incorporated for future
+ reference / usage.
+
+ ============================================================================
+*/
+
+
+/******************************************************************************
+ *
+ * File : typedefs.h
+ * Description : Definition of platform independent data
+ * types and constants
+ *
+ *
+ * The following platform independent data types and corresponding
+ * preprocessor (#define) constants are defined:
+ *
+ * defined type meaning corresponding constants
+ * ----------------------------------------------------------
+ * Char character (none)
+ * Bool boolean true, false
+ * Word8 8-bit signed minWord8, maxWord8
+ * UWord8 8-bit unsigned minUWord8, maxUWord8
+ * Word16 16-bit signed minWord16, maxWord16
+ * UWord16 16-bit unsigned minUWord16, maxUWord16
+ * Word32 32-bit signed minWord32, maxWord32
+ * UWord32 32-bit unsigned minUWord32, maxUWord32
+ * Float floating point minFloat, maxFloat
+ *
+ *
+ * The following compile switches are #defined:
+ *
+ * PLATFORM string indicating platform progam is compiled on
+ * possible values: "OSF", "PC", "SUN"
+ *
+ * OSF only defined if the current platform is an Alpha
+ * PC only defined if the current platform is a PC
+ * SUN only defined if the current platform is a Sun
+ *
+ * LSBFIRST is defined if the byte order on this platform is
+ * "least significant byte first" -> defined on DEC Alpha
+ * and PC, undefined on Sun
+ *
+ *****************************************************************************/
+
+
+#ifndef _TYPEDEFS_H
+#define _TYPEDEFS_H "$Id $"
+
+/*****************************************************************************
+ * INCLUDE FILES
+ *****************************************************************************/
+#include
+#include
+
+#define ENH_64_BIT_OPERATOR
+
+/*****************************************************************************
+ * DEFINITION OF CONSTANTS
+ *****************************************************************************/
+/*
+ ********* define char type
+ */
+typedef char Char;
+
+typedef unsigned short int UNS_Word16; /* 16 bit "register" (sw*) */
+#ifdef UNS_Word16
+#pragma message ("UNS_Word16 is defined but not officially part of STL2009@")
+#endif
+
+/*
+ ********* define 8 bit signed/unsigned types & constants
+ */
+#if SCHAR_MAX == 127
+typedef signed char Word8;
+#define minWord8 SCHAR_MIN
+#define maxWord8 SCHAR_MAX
+
+typedef unsigned char UWord8;
+#define minUWord8 0
+#define maxUWord8 UCHAR_MAX
+#else
+#error cannot find 8-bit type
+#endif
+
+
+/*
+ ********* define 16 bit signed/unsigned types & constants
+ */
+#if INT_MAX == 32767
+typedef int Word16;
+#define minWord16 INT_MIN
+#define maxWord16 INT_MAX
+typedef unsigned int UWord16;
+#define minUWord16 0
+#define maxUWord16 UINT_MAX
+#elif SHRT_MAX == 32767
+typedef short Word16;
+#define minWord16 SHRT_MIN
+#define maxWord16 SHRT_MAX
+typedef unsigned short UWord16;
+#define minUWord16 0
+#define maxUWord16 USHRT_MAX
+#else
+#error cannot find 16-bit type
+#endif
+
+/* Definition of Word64 */
+#ifdef ENH_64_BIT_OPERATOR
+#define Word64 long long int
+#endif /* #ifdef ENH_64_BIT_OPERATOR */
+
+/* Definition of Word40 was missing 10/06/2013 */
+#define Word40 long long
+
+/*
+ ********* define 32 bit signed/unsigned types & constants
+ */
+#if INT_MAX == 2147483647
+typedef int Word32;
+#define minWord32 INT_MIN
+#define maxWord32 INT_MAX
+typedef unsigned int UWord32;
+#define minUWord32 0
+#define maxUWord32 UINT_MAX
+#elif LONG_MAX == 2147483647
+typedef long Word32;
+#define minWord32 LONG_MIN
+#define maxWord32 LONG_MAX
+typedef unsigned long UWord32;
+#define minUWord32 0
+#define maxUWord32 ULONG_MAX
+#else
+#error cannot find 32-bit type
+#endif
+
+/*
+ ********* define floating point type & constants
+ */
+/* use "if 0" below if Float should be double;
+ use "if 1" below if Float should be float
+ */
+#if 0
+typedef float Float;
+#define maxFloat FLT_MAX
+#define minFloat FLT_MIN
+#else
+typedef double Float;
+#define maxFloat DBL_MAX
+#define minFloat DBL_MIN
+#endif
+
+/*
+ ********* define complex type
+ */
+typedef struct {
+ Float r; /* real part */
+ Float i; /* imaginary part */
+} CPX;
+
+/*
+ ********* define boolean type
+ */
+typedef int Bool;
+#define false 0
+#define true 1
+
+/*
+ ********* Check current platform
+ */
+#if defined (__MSDOS__)
+#define PC
+#define PLATFORM "PC"
+#define LSBFIRST
+#elif defined (__osf__)
+#define OSF
+#define PLATFORM "OSF"
+#define LSBFIRST
+#elif defined (__sun__) || defined (__sun)
+#define SUN
+#define PLATFORM "SUN"
+#undef LSBFIRST
+#elif defined (linux) && defined (i386)
+#define PC
+#define PLATFORM "PC"
+#define LSBFIRST
+#else
+/*#error "can't determine architecture; adapt typedefs.h to your platform"*/
+/* for MSVC 2008 10/06/2013 */
+#define PC
+#define PLATFORM "PC"
+#define LSBFIRST
+#endif
+
+
+#endif /* ifndef _TYPEDEFS_H */
+
+
+/* end of file */
diff --git a/lib_com/ACcontextMapping.c b/lib_com/ACcontextMapping.c
new file mode 100644
index 0000000000000000000000000000000000000000..154618f6a3a5a8743ad987ee0226ffcf5ade3c22
--- /dev/null
+++ b/lib_com/ACcontextMapping.c
@@ -0,0 +1,81 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include
+#include
+#include "options.h"
+#include "basop_util.h"
+#include "cnst_fx.h"
+#include "prot_fx.h"
+#include "rom_com_fx.h"
+#include "stl.h"
+
+/* Returns: index of next coefficient */
+Word16 get_next_coeff_mapped(
+ Word16 ii[2], /* i/o: coefficient indexes */
+ Word16 *pp, /* o : peak(1)/hole(0) indicator */
+ Word16 *idx, /* o : index in unmapped domain */
+ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
+)
+{
+ Word16 p;
+
+ p = s_and(sub(ii[1], hm_cfg->numPeakIndices), sub(hm_cfg->indexBuffer[ii[1]], hm_cfg->indexBuffer[ii[0]]));
+ if (p > 0)
+ {
+ p = 0;
+ move16();
+ }
+ if (p < 0)
+ {
+ p = 1;
+ move16();
+ }
+ *pp = p;
+ move16();
+ *idx = ii[p];
+ move16();
+ ii[p] = add(ii[p], 1);
+ move16();
+ return hm_cfg->indexBuffer[*idx];
+}
+
+/* Returns: index of next coefficient */
+Word16 get_next_coeff_unmapped(
+ Word16 ii[2], /* i/o: coefficient indexes */
+ Word16 *pp, /* o : peak(1)/hole(0) indicator */
+ Word16 *idx, /* o : index in unmapped domain */
+ CONTEXT_HM_CONFIG *hm_cfg /* i : HM configuration */
+)
+{
+ (void)pp;
+ (void)hm_cfg;
+
+ *idx = ii[0];
+ move16();
+ ii[0] = add(ii[0], 1);
+ move16();
+ return *idx;
+}
+
+Word16 update_mixed_context(Word16 ctx, Word16 a)
+{
+ Word32 t32;
+ Word16 t=0; /* initialize just to avoid compiler warning */
+
+ t32 = L_mac0(1-13, s_and(a, ~1), add(shr(a, 2), 1));
+ if (t32 <= 0)
+ {
+ t = extract_l(t32);
+ }
+ a = shr(a, 3);
+ if (t32 > 0)
+ {
+ t = s_min(a, 2);
+ }
+ return add(shl(s_and(ctx, 0xf), 4), add(t, 13));
+}
+
diff --git a/lib_com/ari.c b/lib_com/ari.c
new file mode 100644
index 0000000000000000000000000000000000000000..edf6e473c1c234b4c281e5e68a8d4850e785f8aa
--- /dev/null
+++ b/lib_com/ari.c
@@ -0,0 +1,57 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "assert.h"
+#include "prot_fx.h"
+#include "basop_mpy.h"
+#include "cnst_fx.h"
+#include "stl.h"
+
+/**
+ * \brief 31x16 Bit multiply (x*y)
+ *
+ * \param[i] xh high part, bit [30..15]
+ * \param[i] xl low part, 15 LSBits
+ * \param[i] y
+ *
+ * \return x*y
+ */
+Word32 L_multi31x16_X2(Word16 xh, Word16 xl, Word16 y)
+{
+ Word32 z;
+
+ z = L_shl(L_mult0(xh,y),15);
+ z = L_mac0(z,xl,y);
+
+ return z;
+}
+
+/*---------------------------------------------------------------
+ Ari 14 bits common routines
+ -------------------------------------------------------------*/
+
+/**
+ * \brief Integer Multiply
+ *
+ * \param[i] r
+ * \param[i] c
+ *
+ * \return r*c
+ */
+Word32 mul_sbc_14bits(Word32 r, Word16 c)
+{
+ Word32 ret;
+
+
+ /*
+ temp = (((int32) r)*((int32) c))>>stat_bitsnew;
+ */
+ assert(stat_bitsnew == 14);
+ ret = Mpy_32_16_1(L_shl(r,15-stat_bitsnew), c);
+
+ /*assert( (((int) r)*((int) c))>>stat_bitsnew == ret);*/
+
+ return (ret);
+}
diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c
new file mode 100644
index 0000000000000000000000000000000000000000..80f2d70c6e5c064a5f978777fddb94442720eeae
--- /dev/null
+++ b/lib_com/ari_hm.c
@@ -0,0 +1,292 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+#include
+#include
+#include
+#include
+#include "stl.h"
+#include "cnst_fx.h"
+#include "basop_util.h"
+#include "rom_com_fx.h"
+#include "prot_fx.h"
+
+void UnmapIndex(
+ Word16 PeriodicityIndex,
+ Word16 Bandwidth,
+ Word16 LtpPitchLag,
+ Word8 SmallerLags,
+ Word16 *FractionalResolution,
+ Word32 *Lag)
+{
+ Word16 LtpPitchIndex, Multiplier;
+ Word16 Lag16;
+
+ test();
+ IF ((LtpPitchLag > 0) && (s_and(PeriodicityIndex, kLtpHmFlag) != 0))
+ {
+ LtpPitchIndex = shr(PeriodicityIndex, 9);
+ Multiplier = s_and(PeriodicityIndex, 0xff);
+
+ assert(0 <= LtpPitchIndex && LtpPitchIndex <= 16);
+ assert(1 <= Multiplier && Multiplier <= (1 << NumRatioBits[Bandwidth][LtpPitchIndex]));
+
+ *FractionalResolution = kLtpHmFractionalResolution;
+ move16();
+ *Lag = L_shr(L_mult0(LtpPitchLag, Ratios[Bandwidth][LtpPitchIndex][Multiplier-1]), 8);
+ move32();
+ }
+ ELSE
+ {
+ IF (LT_16(PeriodicityIndex, 16))
+ {
+ *FractionalResolution = 3;
+ move16();
+ Lag16 = add(PeriodicityIndex, GET_ADJ2(0, 6, 3));
+ }
+ ELSE IF (LT_16(PeriodicityIndex, 80))
+ {
+ *FractionalResolution = 4;
+ move16();
+ Lag16 = add(PeriodicityIndex, GET_ADJ2(16, 8, 4));
+ }
+ ELSE IF (LT_16(PeriodicityIndex, 208))
+ {
+ *FractionalResolution = 3;
+ move16();
+ Lag16 = add(PeriodicityIndex, GET_ADJ2(80, 12, 3));
+ }
+ ELSE {
+ test();
+ IF (LT_16(PeriodicityIndex, 224)||SmallerLags!=0)
+ {
+ *FractionalResolution = 1;
+ move16();
+ Lag16 = add(PeriodicityIndex, GET_ADJ2(208, 28, 1));
+ }
+ ELSE {
+ *FractionalResolution = 0;
+ move16();
+ Lag16 = add(PeriodicityIndex, GET_ADJ2(224, 188, 0));
+ }
+ }
+ *Lag = L_deposit_l(Lag16);
+ }
+}
+
+
+void ConfigureContextHm(
+ Word16 NumCoeffs, /* (I) Number of coefficients */
+ Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) */
+ Word16 PeriodicityIndex, /* (I) Pitch related index */
+ Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. */
+ CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */
+)
+{
+ Word8 Bandwidth, SmallerLags;
+ Word32 i, Limit, Lag;
+ Word16 j, Index, FractionalResolution;
+ Word16 *tmp;
+
+
+ Bandwidth = 0;
+ move16();
+ if (GE_16(NumCoeffs, 256))
+ {
+ Bandwidth = 1;
+ move16();
+ }
+
+ SmallerLags = 0;
+ move16();
+ test();
+ if ((LE_16(TargetBits, kSmallerLagsTargetBitsThreshold))||(Bandwidth==0))
+ {
+ SmallerLags = 1;
+ move16();
+ }
+
+ UnmapIndex(PeriodicityIndex,
+ Bandwidth,
+ LtpPitchLag,
+ SmallerLags,
+ &FractionalResolution, &Lag);
+
+ /* Set up and fill peakIndices */
+ hm_cfg->peakIndices = hm_cfg->indexBuffer;
+ tmp = hm_cfg->peakIndices;
+ Limit = L_shl(L_deposit_l(sub(NumCoeffs, 1)), FractionalResolution);
+ IF (LT_32(Lag, Limit))
+ {
+ FOR (i=Lag; inumPeakIndices = (Word16)(tmp - hm_cfg->indexBuffer);
+
+ /* Set up and fill holeIndices */
+ hm_cfg->holeIndices = hm_cfg->indexBuffer + hm_cfg->numPeakIndices;
+ tmp = hm_cfg->holeIndices;
+ Index = 0;
+ move16();
+ IF (hm_cfg->numPeakIndices > 0)
+ {
+ FOR (j=0; jnumPeakIndices; j+=3)
+ {
+ FOR (; IndexpeakIndices[j]; ++Index)
+ {
+ *tmp++ = Index;
+ move16();
+ }
+ Index = add(Index, 3); /* Skip the peak */
+ }
+ }
+ IF (LT_16(Index, NumCoeffs))
+ {
+ FOR (; IndexnumHoleIndices = (Word16)(tmp - hm_cfg->holeIndices);
+ *tmp++ = NumCoeffs;
+ move16(); /* Add extremal element signaling the end of the buffer */
+
+}
+
+Word16 CountIndexBits(
+ Word16 Bandwidth,
+ Word16 PeriodicityIndex)
+{
+ Word16 result;
+ Word16 PeriodicityIndexS;
+
+ result = 8;
+ move16();
+ PeriodicityIndexS = shr(PeriodicityIndex, 9);
+
+ if (s_and(PeriodicityIndex, kLtpHmFlag) != 0)
+ {
+ result = NumRatioBits[Bandwidth][PeriodicityIndexS];
+ move16();
+ }
+
+ return result;
+}
+
+
+
+int tcx_hm_render(
+ Word32 lag, /* i: pitch lag Q0 */
+ Word16 fract_res, /* i: fractional resolution of the lag Q0 */
+ Word16 p[] /* o: harmonic model Q13 */
+)
+{
+ Word16 k, tmp, height;
+ Word16 PeakDeviation;
+ Word32 f0, tmp32;
+
+ /* Set up overall shape */
+ f0 = L_shl(lag, sub(15, fract_res)); /* Q31 */
+
+ tmp32 = Mpy_32_16_1(f0, -26474);
+ tmp32 = L_shr_r(BASOP_Util_InvLog2(L_shl(tmp32, 7)), 2);
+ tmp32 = L_sub(603979776L, tmp32);
+ tmp32 = L_add(L_add(tmp32, tmp32), Mpy_32_16_1(tmp32, 26214));
+ height = round_fx(tmp32); /* Q13 */
+
+ tmp32 = Mpy_32_16_1(f0, -18910);
+ tmp32 = L_shr_r(BASOP_Util_InvLog2(L_shl(tmp32, 7)), 2);
+ tmp32 = L_sub(1395864371L, tmp32);
+ PeakDeviation = round_fx(tmp32); /* Q14 */
+
+ IF( GT_16(13915,PeakDeviation))
+ {
+ /* A bit error was encountered */
+ return 1;
+ }
+ ELSE
+ {
+ tmp = div_s(13915, PeakDeviation);
+ tmp = mult_r(tmp, tmp); /* Q15 */
+ }
+
+ tmp = div_s(13915, PeakDeviation);
+ tmp = mult_r(tmp, tmp); /* Q15 */
+
+ /* Render the prototype peak */
+ p[kTcxHmParabolaHalfWidth] = height;
+ move16();
+
+ FOR (k=1; k<=kTcxHmParabolaHalfWidth; ++k)
+ {
+ p[kTcxHmParabolaHalfWidth+k] = round_fx(Mpy_32_16_1(BASOP_Util_InvLog2(L_shl(L_mult0(i_mult2(negate(k),k), tmp),10)), height));
+ }
+ /* Mirror */
+ FOR (k=-kTcxHmParabolaHalfWidth; k<0; ++k)
+ {
+ p[kTcxHmParabolaHalfWidth+k] = p[kTcxHmParabolaHalfWidth-k];
+ move16();
+ }
+
+ return 0;
+}
+
+void tcx_hm_modify_envelope(
+ Word16 gain, /* i: HM gain Q11 */
+ Word32 lag, /* i: pitch lag Q0 */
+ Word16 fract_res, /* i: fractional resolution of the lag Q0 */
+ Word16 p[], /* i: harmonic model Q13 */
+ Word32 env[], /* i/o: envelope Q16 */
+ Word16 L_frame /* i: number of spectral lines Q0 */
+)
+{
+ Word16 k, h, x, l1,l2, L_frame_m1, L_frame_for_loop;
+ Word16 inv_shape[2*kTcxHmParabolaHalfWidth+1];
+
+ IF ( gain == 0 )
+ {
+ return;
+ }
+
+ FOR (k=0; k<2*kTcxHmParabolaHalfWidth+1; ++k)
+ {
+ /* Q24 = Q11 * Q13; 512 = 1.0 in Q24 format */
+ inv_shape[k] = div_s(512, add(512, mult_r(gain, p[k])));
+ move16();
+ }
+
+ h = 1;
+ move16();
+ k = extract_l(L_shr(lag,fract_res));
+
+ L_frame_m1 = sub(L_frame,1);
+ L_frame_for_loop = add(L_frame,kTcxHmParabolaHalfWidth - 1);
+
+ WHILE ( LE_16(k,L_frame_for_loop))
+ {
+ l1 = s_max(0, sub(k,kTcxHmParabolaHalfWidth));
+ l2 = s_min(add(k,kTcxHmParabolaHalfWidth), L_frame_m1);
+ FOR (x=l1; x<=l2; ++x)
+ {
+ env[x] = Mpy_32_16_1(env[x], inv_shape[x-k+kTcxHmParabolaHalfWidth]);
+ move32();
+ }
+
+ h = add(h,1);
+ k = extract_l(L_shr(imult3216(lag,h),fract_res));
+ }
+
+}
+
+
diff --git a/lib_com/arith_coder.c b/lib_com/arith_coder.c
new file mode 100644
index 0000000000000000000000000000000000000000..6c4739da2df8628997f6dbcbe92eeec2c2dae82a
--- /dev/null
+++ b/lib_com/arith_coder.c
@@ -0,0 +1,471 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include
+#include
+
+#include "prot_fx.h"
+#include "basop_util.h"
+#include "options.h"
+#include "cnst_fx.h"
+#include "stl.h"
+
+/* Fixed point implementation of exp(negate()) */
+Word32 expfp( /* o: Q31 */
+ Word16 x, /* i: mantissa Q-e */
+ Word16 x_e) /* i: exponent Q0 */
+{
+ Word16 xi, xf, tmp;
+ Word16 b0, b1, b2, b3;
+ Word32 y, L_tmp;
+
+
+ assert(x > 0);
+
+ L_tmp = L_shl(L_deposit_h(x), x_e);
+
+ /* split into integer and fractional parts */
+ xi = round_fx(L_tmp);
+ xf = extract_l(L_tmp);
+
+ BASOP_SATURATE_WARNING_OFF;
+ xf = negate(xf);
+ BASOP_SATURATE_WARNING_ON;
+
+ /* Fractional part */
+ /* y = 65536
+ + xf
+ + ((xf*xf) / (2*65536))
+ + ((((((xf*xf) / (2*65536))*xf) / 65536)*65536/3) / 65536)
+ + ((((((((xf*xf) / (2*65536))*xf) / 65536)*65536/3) / 65536)*xf) / (4*65536)); */
+ y = L_mac0(65536, xf, 1);
+ tmp = shr(mult(xf, xf), 2);
+ y = L_mac0(y, tmp, 1);
+ tmp = shr(mult(shr(mult(tmp, xf), 1), 65536/3), 1);
+ y = L_mac0(y, tmp, 1);
+ tmp = shr(mult(tmp, xf), 3);
+ y = L_mac0(y, tmp, 1);
+
+ /* Integer part */
+ b0 = s_and(xi, 1);
+ b1 = s_and(xi, 2);
+ b2 = s_and(xi, 4);
+ b3 = s_and(xi, 8);
+
+ if (b0 != 0) y = Mpy_32_16_1(y, 24109); /* exp(-1) in -1Q16 */
+ if (b1 != 0) y = Mpy_32_16_1(y, 17739); /* exp(-2) in -2Q17 */
+ if (b2 != 0) y = Mpy_32_16_1(y, 19205); /* exp(-4) in -5Q20 */
+ if (b3 != 0) y = Mpy_32_16_1(y, 22513); /* exp(-8) in -11Q26 */
+
+ /* scaling: -1*b0 - 2*b1 -5*b2 -11*b3 */
+ y = L_shr(y, add(add(xi, shr(xi, 2)), shr(b3, 3)));
+
+ /* zero for xi >= 16 */
+ if (shr(xi, 4) > 0)
+ {
+ y = L_deposit_l(0);
+ }
+
+
+ return L_shl(y, 15);
+}
+
+/* Fixed point implementation of pow(), where base is fixed point (16/16) and exponent a small *odd* integer
+ *
+ * Returns: *pout1 = ( (base/65536)^(2*exp - 1) ) * 65536
+ * *pout2 = ( (base/65536)^(2*exp + 1) ) * 65536
+ *
+ * NOTE: This function must be in sync with ari_decode_14bits_pow() */
+void powfp_odd2(Word16 base, /* Q15 */
+ Word16 exp, /* Q0 */
+ Word16 *pout1, /* Q15 */
+ Word16 *pout2) /* Q15 */
+{
+ /* this version is in sync with ari_enc_14bits_pow()
+ * that is, we have to start multiplication from the largest power-of-two, in order to
+ * get the rounding errors to appear at the same places */
+ Word16 pows[12]; /* powers of two exponents*/
+ Word16 exp2;
+ Word16 out, out2;
+ Word16 k, h, maxk;
+
+ assert(exp >= 0);
+
+ out = base;
+ move16();
+ out2 = 0x7FFF;
+ move16();
+ IF (exp != 0)
+ {
+ exp2 = sub(exp, 1);
+ maxk = sub(15, norm_s(exp));
+ assert(maxk < 12);
+
+ pows[0] = base;
+ move16();
+ FOR (k = 0; k < maxk; k++)
+ {
+ pows[k+1] = mult_r(pows[k], pows[k]);
+ move16();
+ }
+ k = sub(k, 1);
+ h = shl(1, k); /* highest bit of exp2 */
+ out2 = base;
+ move16();
+ out = mult_r(out, pows[k+1]); /* we already know that "exp" has the highest bit set to one since we calculated .. */
+ /* .. the effective length of "exp" earlier on, thus we omit the branch for out2 */
+ if (s_and(exp2, h) != 0)
+ {
+ out2 = mult_r(out2, pows[k+1]);
+ }
+
+ h = shr(h, 1);
+ FOR (k = sub(k, 1); k >= 0; k--)
+ {
+ if (s_and(exp, h) != 0)
+ {
+ out = mult_r(out, pows[k+1]);
+ }
+
+ if (s_and(exp2, h) != 0)
+ {
+ out2 = mult_r(out2, pows[k+1]);
+ }
+
+ h = shr(h, 1);
+ }
+ }
+
+ *pout1 = out2;
+ move16();
+ *pout2 = out;
+ move16();
+
+}
+
+/*------------------------------------------------------------------------
+ * Function: tcx_arith_scale_envelope
+ *
+ * For optimal performance of the arithmetic coder, the envelope shape must
+ * be scaled such that the expected bit-consumption of a signal that
+ * follows the scaled shape coincides with the target bitrate.
+ * This function calculates a first-guess scaling and then uses the bi-section
+ * search to find the optimal scaling.
+ *
+ * We assume that lines follow the Laplacian distribution, whereby the expected
+ * bit-consumption would be log2(2*e*s[k]), where s[k] is the envelope value
+ * for the line in question. However, this theoretical formula assumes that
+ * all lines are encoded with magnitude+sign. Since the sign is unnecessary
+ * for 0-values, that estimate of bit-consumption is biased when s[k] is small.
+ * Analytical solution of the expectation for small s[k] is difficult, whereby
+ * we use the approximation log2(2*e*s[k] + 0.15 + 0.035 / s[k]) which is accurate
+ * on the range 0.08 to 1.0.
+ *
+ * NOTE: This function must be bit-exact on all platforms such that encoder
+ * and decoder remain synchronized.
+ *-------------------------------------------------------------------------*/
+void tcx_arith_scale_envelope(
+ Word16 L_spec_core, /* i: number of lines to scale Q0 */
+ Word16 L_frame, /* i: number of lines Q0 */
+ Word32 env[], /* i: unscaled envelope Q16 */
+ Word16 target_bits, /* i: number of available bits Q0 */
+ Word16 low_complexity, /* i: low-complexity flag Q0 */
+ Word16 s_env[], /* o: scaled envelope Q15-e */
+ Word16 *s_env_e /* o: scaled envelope exponent Q0 */
+)
+{
+ Word32 ienv[N_MAX_ARI];
+ Word16 scale, iscale, iscale_e, a_e, b, b_e;
+ Word16 lob, hib, adjust;
+ Word16 k, iter, max_iter, lob_bits, hib_bits;
+ Word16 statesi, bits;
+ Word32 mean, a, s, L_tmp;
+ Word16 mean_e, tmp, tmp2;
+
+
+
+ lob_bits = 0;
+ move16();
+ hib_bits = 0;
+ move16();
+
+ /* Boosting to account for expected spectrum truncation (kMax) */
+ /* target_bits = (int)(target_bits * (1.2f - 0.00045f * target_bits + 0.00000025f * target_bits * target_bits)); */
+ L_tmp = L_shr(Mpy_32_16_1(L_mult0(target_bits, target_bits), 17180), 6); /* Q15; 17180 -> 0.00000025f (Q36) */
+ L_tmp = L_sub(L_tmp, L_shr(L_mult0(target_bits, 30199), 11)); /* Q15; 30199 -> 0.00045f (Q26) */
+ L_tmp = L_add(L_tmp, 39322); /* Q15; 39322 -> 1.2f (Q15) */
+ L_tmp = Mpy_32_16_1(L_tmp, target_bits); /* Q0 */
+ assert(L_tmp < 32768);
+ target_bits = extract_l(L_tmp);
+
+ /* Calculate inverse envelope and find initial scale guess based on mean */
+ mean = L_deposit_l(0);
+ FOR (k = 0; k < L_frame; k++)
+ {
+ /* ienv[k] = 1.0f / env[k];
+ mean += ienv[k]; */
+
+ tmp = norm_l(env[k]);
+ tmp2 = sub(15, tmp);
+ tmp = Inv16(round_fx(L_shl(env[k], tmp)), &tmp2);
+ ienv[k] = L_shl(L_deposit_h(tmp), sub(tmp2, 15)); /* Q16 */ move32();
+ mean = L_add(mean, ienv[k]);
+ }
+ tmp = norm_s(L_frame);
+ tmp = shl(div_s(8192, shl(L_frame, tmp)), sub(tmp, 7));
+ mean = L_shr(Mpy_32_16_1(mean, tmp), 6); /* Q16 */
+
+ /* Rate dependent compensation to get closer to the target on average */
+ /* mean = (float)pow(mean, (float)L_frame / (float)target_bits * 0.357f); */
+ tmp = BASOP_Util_Divide1616_Scale(L_frame, target_bits, &tmp2);
+ tmp = mult_r(tmp, 11698/*0.357f Q15*/);
+ mean = BASOP_Util_fPow(mean, 15, L_deposit_h(tmp), tmp2, &mean_e);
+
+ /* Find first-guess scaling coefficient "scale" such that if "mean" is the
+ * mean of the envelope, then the mean bit-consumption is approximately
+ *
+ * log2(2*e*mean*scale + 0.15 + 0.035/(mean*scale)) * L_frame = target_bits
+ */
+ /* a = 2*2.71828183f*mean*mean; */
+ tmp = round_fx(mean);
+ a = L_mult(mult_r(tmp, 22268/*2.71828183f Q13*/), tmp);
+ a_e = add(shl(mean_e, 1), 3);
+
+ /* b = (0.15f - (float)pow(2.0f, target_bits/(float)L_frame)) * mean; */
+ tmp = BASOP_Util_Divide1616_Scale(target_bits, L_frame, &tmp2);
+ tmp = round_fx(BASOP_util_Pow2(L_deposit_h(tmp), tmp2, &tmp2));
+ b_e = BASOP_Util_Add_MantExp(4915/*0.15f Q15*/, 0, negate(tmp), tmp2, &b);
+ b = mult_r(b, round_fx(mean));
+ b_e = add(b_e, mean_e);
+
+ /* scale = (-b + (float)sqrt(b*b - 4.0f*a*0.035f)) / (2.0f * a); */
+ tmp = round_fx(BASOP_Util_Add_Mant32Exp(L_mult(b, b), shl(b_e, 1), Mpy_32_16_1(a, -4588/*-4.0f*0.035f Q15*/), a_e, &tmp2));
+
+ IF( tmp <= 0 )
+ {
+ tmp = 0;
+ set16_fx(s_env, 0, L_frame);
+ }
+ ELSE
+ {
+ tmp = Sqrt16(tmp, &tmp2);
+ }
+
+ tmp2 = BASOP_Util_Add_MantExp(negate(b), b_e, tmp, tmp2, &scale);
+ scale = BASOP_Util_Divide1616_Scale(scale, round_fx(a), &tmp);
+ scale = shl(scale, sub(sub(add(tmp, tmp2), a_e), 1)); /* Q15 */
+
+ /* iscale = 1.0f / scale; */
+ iscale_e = 0;
+ move16();
+ iscale = Inv16(s_max(1, scale), &iscale_e);
+
+ lob = 0;
+ move16();
+ hib = 0;
+ move16();
+
+ max_iter = 2;
+ move16();
+ if(low_complexity)
+ {
+ max_iter = 1;
+ move16();
+ }
+
+ FOR (iter = 0; iter < max_iter; iter++)
+ {
+ statesi = 0x7FFF;
+ move16();
+ bits = 0;
+ move16();
+
+ FOR (k = 0; k < L_frame; k++)
+ {
+ s = Mpy_32_16_1(ienv[k], scale); /* Q16 */
+
+ IF (LE_32(s, 5243l/*0.08f Q16*/))
+ {
+ /* If s = 0.08, the expected bit-consumption is log2(1.0224). Below 0.08, the bit-consumption
+ estimate function becomes inaccurate, so use log2(1.0224) for all values below 0.08. */
+ /* round(state * 1.0224 * 32768) */
+ statesi = mult_r(statesi, 16751/*1.0224 Q14*/);
+ tmp = norm_s(statesi);
+ statesi = shl(statesi, tmp);
+ bits = add(bits, sub(1, tmp));
+ }
+ ELSE IF (LE_32(s, 16711680l/*255.0 Q16*/))
+ {
+ /* a = 5.436564f * s + 0.15f + 0.035f * env[k] * iscale; */
+ L_tmp = L_shl(Mpy_32_16_1(s, 22268/*5.436564f Q12*/), 3);
+ L_tmp = L_add(L_tmp, 9830l/*0.15f Q16*/);
+ L_tmp = L_add(L_tmp, L_shl(Mpy_32_16_1(env[k], mult_r(1147/*0.035f Q15*/, iscale)), iscale_e));
+
+ tmp = norm_l(L_tmp);
+ statesi = mult_r(statesi, round_fx(L_shl(L_tmp, tmp)));
+ bits = add(bits, sub(15, tmp));
+
+ tmp = norm_s(statesi);
+ statesi = shl(statesi, tmp);
+ bits = sub(bits, tmp);
+ }
+ ELSE
+ {
+ /* for large envelope values, s > 255, bit consumption is approx log2(2*e*s)
+ * further, we use round(log2(x)) = floor(log2(x)+0.5) = floor(log2(x*sqrt(2))) */
+ /* a = 5.436564f * s; */
+ L_tmp = Mpy_32_16_1(s, 31492/*5.436564f * 1.4142f Q12*/); /* Q13 */
+ bits = add(bits, sub(17, norm_l(L_tmp)));
+ }
+ }
+
+ IF (LE_16(bits, target_bits)) /* Bits leftover => scale is too small */
+ {
+ lob = scale;
+ move16();
+ lob_bits = bits;
+ move16();
+
+ IF (hib > 0) /* Bisection search */
+ {
+ adjust = div_s(sub(hib_bits, target_bits), sub(hib_bits, lob_bits));
+ scale = add(mult_r(sub(lob, hib), adjust), hib);
+ }
+ ELSE /* Initial scale adaptation */
+ {
+ /* adjust = 1.05f * target_bits / (float)bits;
+ scale *= adjust; */
+ adjust = mult_r(17203/*1.05f Q14*/, target_bits);
+ adjust = BASOP_Util_Divide1616_Scale(adjust, bits, &tmp);
+ scale = shl(mult_r(scale, adjust), add(1, tmp));
+ }
+ }
+ ELSE /* Ran out of bits => scale is too large */
+ {
+ hib = scale;
+ move16();
+ hib_bits = bits;
+ move16();
+
+ IF (lob > 0) /* Bisection search */
+ {
+ adjust = div_s(sub(hib_bits, target_bits), sub(hib_bits, lob_bits));
+ scale = add(mult_r(sub(lob, hib), adjust), hib);
+ }
+ ELSE { /* Initial scale adaptation */
+ test();
+ IF( target_bits <= 0 || bits <= 0 ) /* safety check in case of bit errors */
+ {
+ adjust = 0;
+ move16();
+ set16_fx( s_env, 0, L_frame );
+ }
+ ELSE
+ {
+ adjust = div_s(mult_r(31130/*0.95f Q15*/, target_bits), bits);
+ }
+ scale = mult_r(scale, adjust);
+ }
+ }
+ iscale_e = 0;
+ move16();
+
+ IF( scale == 0 ) /* safety check in case of bit errors */
+ {
+ iscale = 0;
+ move16();
+ set16_fx( s_env, 0, L_frame );
+ }
+ ELSE
+ {
+ iscale = Inv16(scale, &iscale_e);
+ }
+ }
+ L_frame = L_spec_core;
+ move16();
+
+ tmp = getScaleFactor32(env, L_frame);
+ *s_env_e = sub(add(15, iscale_e), tmp);
+ move16();
+ BASOP_SATURATE_WARNING_OFF;
+ a = L_shl(1265000, sub(15, *s_env_e));
+ BASOP_SATURATE_WARNING_ON;
+
+ FOR (k = 0; k < L_frame; k++)
+ {
+ L_tmp = Mpy_32_16_1(L_shl(env[k], tmp), iscale);
+ L_tmp = L_min(L_tmp, a);
+ s_env[k] = round_fx(L_tmp);
+ }
+
+}
+
+/*------------------------------------------------------------------------
+ * Function: tcx_arith_render_envelope
+ *
+ * Calculate the envelope of the spectrum based on the LPC shape. The
+ * envelope is used in a perceptual domain, whereby the LPC shape has to
+ * be multiplied by the perceptual model.
+ * Operations that are performed on the spectrum, which change the magnitude
+ * expectation of lines, such as low-frequency emphasis, are included in the
+ * envelope shape.
+ * NOTE: This function must be bit-exact on all platforms such that encoder
+ * and decoder remain synchronized.
+ *-------------------------------------------------------------------------*/
+void tcx_arith_render_envelope(
+ const Word16 A_ind[], /* i: LPC coefficients of signal envelope */
+ Word16 L_frame, /* i: number of spectral lines */
+ Word16 L_spec,
+ Word16 preemph_fac, /* i: pre-emphasis factor */
+ Word16 gamma_w, /* i: A_ind -> weighted envelope factor */
+ Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor */
+ Word32 env[] /* o: shaped signal envelope */
+)
+{
+ Word16 k;
+ Word16 tmpA[M+2];
+ Word16 signal_env[FDNS_NPTS], signal_env_e[FDNS_NPTS];
+ Word16 gainlpc[FDNS_NPTS], gainlpc_e[FDNS_NPTS];
+
+
+
+ /* Compute perceptual LPC envelope, transform it into freq.-domain gains */
+ weight_a_fx( A_ind, tmpA, gamma_w, M );
+ lpc2mdct( tmpA, M, NULL, NULL, gainlpc, gainlpc_e );
+
+ /* Add pre-emphasis tilt to LPC envelope, transform LPC into MDCT gains */
+ E_LPC_a_weight_inv(A_ind, signal_env, gamma_uw, M);
+ E_LPC_a_add_tilt(signal_env, tmpA, preemph_fac, M);
+ lpc2mdct(tmpA, M+1, signal_env, signal_env_e, NULL, NULL);
+
+ /* Compute weighted signal envelope in perceptual domain */
+ FOR (k = 0; k < FDNS_NPTS; k++)
+ {
+ signal_env[k] = mult_r(signal_env[k], gainlpc[k]);
+ move16();
+ signal_env_e[k] = add(signal_env_e[k], gainlpc_e[k]);
+ move16();
+ }
+
+ /* Adaptive low frequency emphasis */
+ set32_fx(env, 0x10000, L_frame);
+
+ AdaptLowFreqDeemph(env, 15,
+ 1,
+ gainlpc, gainlpc_e,
+ L_frame, NULL);
+
+ /* Scale from FDNS_NPTS to L_frame and multiply LFE gains */
+ mdct_noiseShaping_interp(env, L_frame, signal_env, signal_env_e);
+
+ FOR (k=L_frame; k
+#include
+
+#include "stl.h"
+
+#define DOT12_SUBDIV_LD 2 /* log2(number of dot product sub divisions) */
+
+#define HP20_COEF_SCALE 2
+#define INV_BANDS10 3277 /* 1/10 in Q15 */
+#define INV_BANDS9 3641 /* 1/9 in Q15 */
+
+extern const Word32 SqrtTable[32];
+extern const Word16 SqrtDiffTable[32];
+
+extern const Word32 ISqrtTable[32];
+extern const Word16 ISqrtDiffTable[32];
+
+extern const Word32 InvTable[32];
+extern const Word16 InvDiffTable[32];
+
+
+Word32 BASOP_Util_Log2(Word32 x)
+{
+ Word32 exp;
+ Word16 exp_e;
+ Word16 nIn;
+ Word16 accuSqr;
+ Word32 accuRes;
+
+
+
+ assert(x >= 0);
+
+ if (x == 0)
+ {
+
+ return ((Word32)MIN_32);
+ }
+
+ /* normalize input, calculate integer part */
+ exp_e = norm_l(x);
+ x = L_shl(x,exp_e);
+ exp = L_deposit_l(exp_e);
+
+ /* calculate (1-normalized_input) */
+ nIn = extract_h(L_sub(MAX_32,x));
+
+ /* approximate ln() for fractional part (nIn *c0 + nIn^2*c1 + nIn^3*c2 + ... + nIn^8 *c7) */
+
+ /* iteration 1, no need for accumulation */
+ accuRes = L_mult(nIn,ldCoeff[0]); /* nIn^i * coeff[0] */
+ accuSqr = mult(nIn,nIn); /* nIn^2, nIn^3 .... */
+
+ /* iteration 2 */
+ accuRes = L_mac(accuRes,accuSqr,ldCoeff[1]); /* nIn^i * coeff[1] */
+ accuSqr = mult(accuSqr,nIn); /* nIn^2, nIn^3 .... */
+
+ /* iteration 3 */
+ accuRes = L_mac(accuRes,accuSqr,ldCoeff[2]); /* nIn^i * coeff[2] */
+ accuSqr = mult(accuSqr,nIn); /* nIn^2, nIn^3 .... */
+
+ /* iteration 4 */
+ accuRes = L_mac(accuRes,accuSqr,ldCoeff[3]); /* nIn^i * coeff[3] */
+ accuSqr = mult(accuSqr,nIn); /* nIn^2, nIn^3 .... */
+
+ /* iteration 5 */
+ accuRes = L_mac(accuRes,accuSqr,ldCoeff[4]); /* nIn^i * coeff[4] */
+ accuSqr = mult(accuSqr,nIn); /* nIn^2, nIn^3 .... */
+
+ /* iteration 6 */
+ accuRes = L_mac(accuRes,accuSqr,ldCoeff[5]); /* nIn^i * coeff[5] */
+ accuSqr = mult(accuSqr,nIn); /* nIn^2, nIn^3 .... */
+
+ /* iteration 7, no need to calculate accuSqr any more */
+ accuRes = L_mac(accuRes,accuSqr,ldCoeff[6]); /* nIn^i * coeff[6] */
+
+ /* ld(fractional part) = ln(fractional part)/ln(2), 1/ln(2) = (1 + 0.44269504) */
+ accuRes = L_mac0(L_shr(accuRes,1),extract_h(accuRes),14506);
+
+ accuRes = L_shr(accuRes,LD_DATA_SCALE-1); /* fractional part/LD_DATA_SCALE */
+ exp = L_shl(exp,(31-LD_DATA_SCALE)); /* integer part/LD_DATA_SCALE */
+ accuRes = L_sub(accuRes,exp); /* result = integer part + fractional part */
+
+
+ return (accuRes);
+}
+
+Word32 BASOP_Util_InvLog2(Word32 x)
+{
+ Word16 frac;
+ Word16 exp;
+ Word32 retVal;
+ UWord32 index3;
+ UWord32 index2;
+ UWord32 index1;
+ UWord32 lookup3f;
+ UWord32 lookup12;
+ UWord32 lookup;
+
+
+
+ if ( x < -1040187392l/*-31.0/64.0 Q31*/ )
+ {
+
+ return 0;
+ }
+ test();
+ if ( (GE_32(x,1040187392l/*31.0/64.0 Q31*/))||(x==0))
+ {
+
+ return 0x7FFFFFFF;
+ }
+
+ frac = extract_l(L_and(x,0x3FF));
+
+ index3 = L_and(L_shr(x,10),0x1F);
+ index2 = L_and(L_shr(x,15),0x1F);
+ index1 = L_and(L_shr(x,20),0x1F);
+
+ exp = extract_l(L_shr(x,25));
+ if ( x > 0 )
+ {
+ exp = sub(31,exp);
+ }
+ if ( x < 0 )
+ {
+ exp = negate(exp);
+ }
+
+ lookup3f = L_add(exp2x_tab_long[index3],L_shr(Mpy_32_16_1(0x0016302F,frac),1));
+ lookup12 = Mpy_32_32(exp2_tab_long[index1],exp2w_tab_long[index2]);
+ lookup = Mpy_32_32(lookup12, lookup3f);
+
+ retVal = L_shr(lookup,sub(exp,3));
+
+
+ return retVal;
+}
+
+
+Word16 BASOP_Util_Add_MantExp /*!< Exponent of result */
+(Word16 a_m, /*!< Mantissa of 1st operand a */
+ Word16 a_e, /*!< Exponent of 1st operand a */
+ Word16 b_m, /*!< Mantissa of 2nd operand b */
+ Word16 b_e, /*!< Exponent of 2nd operand b */
+ Word16 *ptrSum_m) /*!< Mantissa of result */
+{
+ Word32 L_lm, L_hm;
+ Word16 shift;
+
+
+
+ /* Compare exponents: the difference is limited to +/- 15
+ The Word16 mantissa of the operand with higher exponent is moved into the low
+ part of a Word32 and shifted left by the exponent difference. Then, the
+ unshifted mantissa of the operand with the lower exponent is added to the lower
+ 16 bits. The addition result is normalized and the upper Word16 of the result represents
+ the mantissa to return. The returned exponent takes into account all shift operations
+ including the final 16-bit extraction.
+ Note: The resulting mantissa may be inaccurate in the case, where the mantissa of the operand
+ with higher exponent is not really left-aligned, while the mantissa of the operand with
+ lower exponent is so. If in such a case, the difference in exponents is more than 15,
+ an inaccuracy is introduced.
+ Example:
+ A: a_e = 20, a_m = 0x0001
+ B: b_e = 0, b_m = 0x4000
+ correct: A+B=1*2^20+1*2^14=0x0010.0000+0x0000.4000=0x0010.4000=0x4100*2^6
+ previously: A+B=1*2^20+1*2^14=0x0001+0x0000=0x0001*2^20
+ this version: A+B=1*2^20+1*2^14=0x0000.8000+0x0000.4000=0x6000*2^6
+ */
+
+ shift = sub(a_e, b_e);
+ if (shift >= 0)
+ shift = s_min( 15,shift);
+
+ if (shift < 0)
+ shift = s_max(-15,shift);
+ a_e = s_max(a_e,b_e);
+ L_hm = L_deposit_l(a_m); /* mantissa belonging to higher exponent */
+ L_lm = L_deposit_l(a_m); /* mantissa belonging to lower exponent */
+ if (shift >= 0)
+ L_lm = L_deposit_l(b_m);
+ if (shift < 0)
+ L_hm = L_deposit_l(b_m);
+
+ if (shift > 0)
+ shift = negate(shift);
+
+ L_hm = L_shr(L_hm,shift); /* shift left due to negative shift parameter */
+ a_e = add(a_e, shift);
+ L_hm = L_add(L_hm, L_lm);
+ shift = norm_l(L_hm);
+ L_hm = L_shl(L_hm,shift);
+ *ptrSum_m = extract_h(L_hm);
+ move16();
+
+ a_e = sub(a_e,shift);
+ if (L_hm)
+ a_e = add(a_e,16);
+ return (a_e);
+}
+
+
+void BASOP_Util_Divide_MantExp (Word16 a_m, /*!< Mantissa of dividend a */
+ Word16 a_e, /*!< Exponent of dividend a */
+ Word16 b_m, /*!< Mantissa of divisor b */
+ Word16 b_e, /*!< Exponent of divisor b */
+ Word16 *ptrResult_m, /*!< Mantissa of quotient a/b */
+ Word16 *ptrResult_e /*!< Exponent of quotient a/b */
+ )
+{
+ Word16 index, frac;
+ Word16 preShift, postShift;
+ Word16 m;
+ Word32 m32;
+
+
+
+ assert(b_m != 0);
+
+ /* normalize b */
+ preShift = norm_s(b_m);
+ m = shl(b_m, preShift);
+
+ /* make b positive */
+ BASOP_SATURATE_WARNING_OFF;
+ if (m < 0) m = negate(m);
+ BASOP_SATURATE_WARNING_ON;
+
+ /* get table index (upper 6 bits minus 16) */
+ /* index = (m >> 9) - 32; */
+ index = mac_r(-32768 - (32 << 16), m, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = shl(s_and(m, 0x1FF), 1); /* Q10 */
+
+ /* interpolate 1/b */
+ m = msu_r(InvTable[index], InvDiffTable[index], frac);
+
+ /* restore sign */
+ if (b_m < 0) m = negate(m);
+
+ /* multiply with a */
+ m32 = L_mult(a_m, m);
+
+ /* normalize result */
+ postShift = norm_l(m32);
+ m = round_fx(L_shl(m32, postShift));
+
+ /* exponent */
+ *ptrResult_e = sub(add(add(a_e, sub(1, b_e)), preShift), postShift);
+ move16();
+
+ *ptrResult_m = m;
+ move16();
+
+}
+
+
+/* local function for Sqrt16 and Sqrt16norm */
+static Word16 Sqrt16_common(Word16 m,
+ Word16 e)
+{
+ Word16 index, frac;
+
+ assert((m >= 0x4000) || (m == 0));
+
+ /* get table index (upper 6 bits minus 32) */
+ /* index = (m >> 9) - 32; */
+ index = mac_r(-32768 - (32 << 16), m, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = s_and(m, 0x1FF); /* Q9 */
+
+ /* interpolate */
+ if (m != 0)
+ {
+ BASOP_SATURATE_WARNING_OFF;
+ m = mac_r(SqrtTable[index], SqrtDiffTable[index], frac);
+ BASOP_SATURATE_WARNING_ON;
+ }
+
+ /* handle odd exponents */
+ if (s_and(e, 1) != 0) m = mult_r(m, 0x5a82);
+
+ return m;
+}
+
+/* local function for Sqrt32 and Sqrt32norm */
+static Word32 Sqrt32_common(Word32 m,
+ Word16 e)
+{
+ Word16 m16, index, frac;
+
+ assert((m >= 0x40000000) || (m == 0));
+
+ m16 = round_fx(m);
+
+ /* get table index (upper 6 bits minus 32) */
+ /* index = (m16 >> 9) - 32; */
+ index = mac_r(-32768 - (32 << 16), m16, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = s_and(m16, 0x1FF); /* Q9 */
+
+ /* interpolate */
+ if (m != 0)
+ {
+ BASOP_SATURATE_WARNING_OFF;
+ m = L_mac(SqrtTable[index], SqrtDiffTable[index], frac);
+ BASOP_SATURATE_WARNING_ON;
+ }
+
+ /* handle odd exponents */
+ if (s_and(e, 1) != 0) m = Mpy_32_16_1(m, 0x5a82);
+
+ return m;
+}
+
+/* local function for ISqrt16 and ISqrt16norm */
+static Word16 ISqrt16_common(Word16 m,
+ Word16 e)
+{
+ Word16 index, frac;
+
+ assert(m >= 0x4000);
+
+ /* get table index (upper 6 bits minus 32) */
+ /* index = (m >> 9) - 32; */
+ index = mac_r(-32768 - (32 << 16), m, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = s_and(m, 0x1FF); /* Q9 */
+
+ /* interpolate */
+ m = msu_r(ISqrtTable[index], ISqrtDiffTable[index], frac);
+
+ /* handle even exponents */
+ if (s_and(e, 1) == 0) m = mult_r(m, 0x5a82);
+
+ return m;
+}
+
+/* local function for ISqrt32 and ISqrt32norm */
+static Word32 ISqrt32_common(Word32 m,
+ Word16 e)
+{
+ Word16 m16, index, frac;
+
+ assert(m >= 0x40000000);
+
+ m16 = round_fx(m);
+
+ /* get table index (upper 6 bits minus 32) */
+ /* index = (m16 >> 25) - 32; */
+ index = mac_r(-32768 - (32 << 16), m16, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = s_and(m16, 0x1FF); /* Q9 */
+
+ /* interpolate */
+ m = L_msu(ISqrtTable[index], ISqrtDiffTable[index], frac);
+
+ /* handle even exponents */
+ if (s_and(e, 1) == 0) m = Mpy_32_16_1(m, 0x5a82);
+
+ return m;
+}
+
+
+Word16 Sqrt16( /*!< output mantissa */
+ Word16 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+ Word16 preShift, e;
+
+ assert(mantissa >= 0);
+
+ /* normalize */
+ preShift = norm_s(mantissa);
+
+ e = sub(*exponent, preShift);
+ mantissa = shl(mantissa, preShift);
+
+ /* calc mantissa */
+ mantissa = Sqrt16_common(mantissa, e);
+
+ /* e = (e + 1) >> 1 */
+ *exponent = mult_r(e, 1 << 14);
+ move16();
+
+ return mantissa;
+}
+
+Word16 Sqrt16norm( /*!< output mantissa */
+ Word16 mantissa, /*!< normalized input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+
+ assert((mantissa >= 0x4000) || (mantissa == 0));
+
+ /* calc mantissa */
+ mantissa = Sqrt16_common(mantissa, *exponent);
+
+ /* e = (e + 1) >> 1 */
+ *exponent = mult_r(*exponent, 1 << 14);
+ move16();
+
+ return mantissa;
+}
+
+
+Word16 ISqrt16( /*!< output mantissa */
+ Word16 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+ Word16 preShift, e;
+
+ assert(mantissa > 0);
+
+ /* normalize */
+ preShift = norm_s(mantissa);
+
+ e = sub(*exponent, preShift);
+ mantissa = shl(mantissa, preShift);
+
+ /* calc mantissa */
+ mantissa = ISqrt16_common(mantissa, e);
+
+ /* e = (2 - e) >> 1 */
+ *exponent = msu_r(1L << 15, e, 1 << 14);
+ move16();
+
+ return mantissa;
+}
+
+
+Word32 Sqrt32( /*!< output mantissa */
+ Word32 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+ Word16 preShift, e;
+
+ assert(mantissa >= 0);
+
+ /* normalize */
+ preShift = norm_l(mantissa);
+
+ e = sub(*exponent, preShift);
+ mantissa = L_shl(mantissa, preShift);
+
+ /* calc mantissa */
+ mantissa = Sqrt32_common(mantissa, e);
+
+ /* e = (e + 1) >> 1 */
+ *exponent = mult_r(e, 1 << 14);
+ move16();
+
+ return mantissa;
+}
+
+
+Word32 ISqrt32( /*!< output mantissa */
+ Word32 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+ Word16 preShift, e;
+
+ assert(mantissa > 0);
+
+ /* normalize */
+ preShift = norm_l(mantissa);
+
+ e = sub(*exponent, preShift);
+ mantissa = L_shl(mantissa, preShift);
+
+ /* calc mantissa */
+ mantissa = ISqrt32_common(mantissa, e);
+
+ /* e = (2 - e) >> 1 */
+ *exponent = msu_r(1L << 15, e, 1 << 14);
+ move16();
+
+ return mantissa;
+}
+
+Word32 ISqrt32norm( /*!< output mantissa */
+ Word32 mantissa, /*!< normalized input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+
+ assert(mantissa >= 0x40000000);
+
+ /* calc mantissa */
+ mantissa = ISqrt32_common(mantissa, *exponent);
+
+ /* e = (2 - e) >> 1 */
+ *exponent = msu_r(1L << 15, *exponent, 1 << 14);
+ move16();
+
+ return mantissa;
+}
+
+
+Word16 Inv16( /*!< output mantissa */
+ Word16 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+)
+{
+ Word16 index, frac;
+ Word16 preShift;
+ Word16 m, e;
+
+
+
+ assert(mantissa != 0);
+
+ /* absolute */
+ BASOP_SATURATE_WARNING_OFF;
+ m = abs_s(mantissa);
+ BASOP_SATURATE_WARNING_ON;
+
+ /* normalize */
+ preShift = norm_s(m);
+
+ e = sub(*exponent, preShift);
+ m = shl(m, preShift);
+
+ /* get table index (upper 6 bits minus 32) */
+ /* index = (m >> 9) - 32; */
+ index = mac_r(-32768 - (32 << 16), m, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = shl(s_and(m, 0x1FF), 1); /* Q10 */
+
+ /* interpolate */
+ m = msu_r(InvTable[index], InvDiffTable[index], frac);
+
+ /* restore sign */
+ if (mantissa < 0) m = negate(m);
+
+ /* e = 1 - e */
+ *exponent = sub(1, e);
+ move16();
+
+ return m;
+}
+
+
+void BASOP_Util_Sqrt_InvSqrt_MantExp (Word16 mantissa, /*!< mantissa */
+ Word16 exponent, /*!< expoinent */
+ Word16 *sqrt_mant, /*!< Pointer to sqrt mantissa */
+ Word16 *sqrt_exp, /*!< Pointer to sqrt exponent */
+ Word16 *isqrt_mant, /*!< Pointer to 1/sqrt mantissa */
+ Word16 *isqrt_exp /*!< Pointer to 1/sqrt exponent */
+ )
+{
+ Word16 index, frac;
+ Word16 preShift;
+ Word16 m, mi, e_odd;
+
+
+
+ assert(mantissa > 0);
+
+ /* normalize */
+ preShift = norm_s(mantissa);
+
+ exponent = sub(exponent, preShift);
+ mantissa = shl(mantissa, preShift);
+
+ /* get table index (upper 6 bits minus 32) */
+ /* index = (m >> 9) - 32; */
+ index = mac_r(-32768 - (32 << 16), mantissa, 1 << 6);
+
+ /* get fractional part for interpolation (lower 9 bits) */
+ frac = s_and(mantissa, 0x1FF); /* Q9 */
+
+ /* interpolate */
+ BASOP_SATURATE_WARNING_OFF;
+ m = mac_r(SqrtTable[index], SqrtDiffTable[index], frac);
+ mi = msu_r(ISqrtTable[index], ISqrtDiffTable[index], frac);
+ BASOP_SATURATE_WARNING_ON;
+
+ /* handle even/odd exponents */
+ e_odd = s_and(exponent, 1);
+ if (e_odd != 0) m = mult_r(m, 0x5a82);
+ if (e_odd == 0) mi = mult_r(mi, 0x5a82);
+
+ /* e = (e + 1) >> 1 */
+ *sqrt_exp = mult_r(exponent, 1 << 14);
+ move16();
+
+ /* e = (2 - e) >> 1 */
+ *isqrt_exp = msu_r(1L << 15, exponent, 1 << 14);
+ move16();
+
+ /* Write result */
+ *sqrt_mant = m;
+ move16();
+ *isqrt_mant = mi;
+ move16();
+
+}
+
+/********************************************************************/
+/*!
+ \brief Calculates the scalefactor needed to normalize input array
+
+ The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x
+*/
+
+Word16 getScaleFactor16( /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */
+ const Word16 *x, /* i: array containing 16-bit data */
+ const Word16 len_x) /* i: length of the array to scan */
+{
+ Word16 i, i_min, i_max;
+ Word16 x_min, x_max;
+
+
+
+ x_max = 0;
+ move16();
+ x_min = 0;
+ move16();
+ FOR (i = 0; i < len_x; i++)
+ {
+ if (x[i] >= 0)
+ x_max = s_max(x_max,x[i]);
+ if (x[i] < 0)
+ x_min = s_min(x_min,x[i]);
+ }
+
+ i_max = 0x10;
+ move16();
+ i_min = 0x10;
+ move16();
+
+ if (x_max != 0)
+ i_max = norm_s(x_max);
+
+ if (x_min != 0)
+ i_min = norm_s(x_min);
+
+ i = s_and(s_min(i_max, i_min),0xF);
+
+
+ return i;
+}
+
+
+/********************************************************************/
+/*!
+ \brief Calculates the scalefactor needed to normalize input array
+
+ The scalefactor needed to normalize the Word32 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 1073741824 <= x <= 2147483647 for positive x
+ and -2147483648 <= x <= -1073741824 for negative x
+*/
+
+Word16 getScaleFactor32( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */
+ const Word32 *x, /* i: array containing 32-bit data */
+ const Word16 len_x) /* i: length of the array to scan */
+{
+ Word16 i, i_min, i_max;
+ Word32 x_min, x_max;
+
+
+
+ x_max = 0; move32();
+ x_min = 0; move32();
+ FOR (i = 0; i < len_x; i++)
+ {
+ if (x[i] >= 0)
+ x_max = L_max(x_max,x[i]);
+ if (x[i] < 0)
+ x_min = L_min(x_min,x[i]);
+ }
+
+ i_max = 0x20;
+ move16();
+ i_min = 0x20;
+ move16();
+
+ if (x_max != 0)
+ i_max = norm_l(x_max);
+
+ if (x_min != 0)
+ i_min = norm_l(x_min);
+
+ i = s_and(s_min(i_max, i_min),0x1F);
+
+
+ return i;
+}
+
+Word16 normalize16(Word16 mantissa, Word16 *pexponent)
+{
+ Word16 tmp;
+
+ tmp = norm_s(mantissa);
+ mantissa = shl(mantissa, tmp);
+ move16();
+ *pexponent = sub(*pexponent, tmp);
+
+
+ return mantissa;
+}
+Word16 divide3216(Word32 x, Word16 y)
+{
+ Word16 z;
+
+
+ z = 0;
+ move16();
+ if (0 == y)
+ {
+ return 0x7fff;
+ }
+
+ IF (x != 0)
+ {
+ Word16 den, sign;
+ Word32 num;
+ num = L_abs(x);
+ den = abs_s(y);
+
+ sign = s_and(s_xor(extract_h(x),y),-32768 /* 0x8000 */);
+
+ z = div_l(num,den);
+ if (0 != sign)
+ {
+ z = negate(z);
+ }
+ }
+
+
+ return z;
+}
+
+Word16 divide1616(Word16 x, Word16 y)
+{
+ Word16 z, num, den, sign;
+
+
+ num = abs_s(x);
+ den = abs_s(y);
+
+ sign = s_and(s_xor(x,y),-32768 /* 0x8000 */);
+
+ move16();
+ z = 0x7fff;
+ if ( LT_16(num, den))
+ z = div_s(num,den);
+
+ if (0 != sign)
+ {
+ z = negate(z);
+ }
+
+
+ return z;
+}
+
+Word16 divide3232(Word32 L_num, Word32 L_denom)
+{
+ Word16 z;
+ Word32 sign;
+
+
+ sign = L_and(L_xor(L_num,L_denom),0x80000000);
+
+ L_num = L_abs(L_num);
+ L_denom = L_abs(L_denom);
+
+ /* limit the range of denominator to Word16 */
+ z = s_min(norm_l(L_num),norm_l(L_denom));
+ L_num = L_shl(L_num,z);
+ L_denom = L_shl(L_denom,z);
+
+ /* round_fx instead of extract_h improves spectral distortion in E_UTIL_lev_dur (schur version). */
+ z = div_l(L_num,round_fx(L_denom));
+ if (0 != sign)
+ {
+ z = negate(z);
+ }
+
+
+ return z;
+}
+
+Word16 BASOP_Util_Divide3232_uu_1616_Scale(Word32 x, Word32 y, Word16 *s)
+{
+ Word16 z;
+ Word16 sx;
+ Word16 sy;
+ Word16 x16;
+ Word16 y16;
+
+
+
+ assert(x >= 0);
+ assert(y > 0);
+
+ if ( x == 0 )
+ {
+ *s = 0;
+ move16();
+
+
+ return (0);
+ }
+
+ sx = norm_l(x);
+ sy = norm_l(y);
+
+ x16 = extract_h(L_shl(x,sx));
+ y16 = extract_h(L_shl(y,sy));
+
+ if(GT_16(x16,y16))
+ {
+ sx = sub(sx,1);
+ }
+
+ if(LT_16(y16,x16))
+ {
+ x16 = mult_r(x16,0x4000);
+ }
+
+
+ z = div_s(x16,y16);
+ move16();
+ *s = sub(sy,sx);
+
+
+ return (z);
+}
+
+Word16 BASOP_Util_Divide3232_Scale(Word32 x, Word32 y, Word16 *s)
+{
+ Word16 z;
+ Word16 sy;
+
+
+
+ sy = norm_l(y);
+ if (sy > 0)
+ {
+ sy = sub(sy,1);
+ }
+ y = L_shl(y,sy);
+
+ z = BASOP_Util_Divide3216_Scale(x, extract_h(y), s);
+ move16();
+ *s = add(*s,sy);
+
+
+ return (z);
+}
+
+Word16 BASOP_Util_Divide3216_Scale( /* o: result of division x/y, not normalized */
+ Word32 x, /* i: numerator, signed */
+ Word16 y, /* i: denominator, signed */
+ Word16 *s) /* o: scaling, 0, if x==0 */
+{
+ Word16 z;
+ Word16 sx;
+ Word16 sy;
+ Word16 sign;
+
+
+
+ /*assert (x > (Word32)0);
+ assert (y >= (Word16)0);*/
+
+ /* check, if numerator equals zero, return zero then */
+ IF ( x == (Word32)0 )
+ {
+ move16();
+ *s = 0;
+
+
+ return ((Word16)0);
+ }
+
+ sign = s_xor(extract_h(x),y); /* just to exor the sign bits */
+ BASOP_SATURATE_WARNING_OFF
+ x = L_abs(x);
+ y = abs_s(y);
+ BASOP_SATURATE_WARNING_ON
+ sx = sub(norm_l(x),1);
+ x = L_shl(x,sx);
+ sy = norm_s(y);
+ y = shl(y,sy);
+ *s = sub(sy,sx);
+ move16();
+
+ z = div_s(round_fx(x),y);
+
+ if ( sign < 0 ) /* if sign bits differ, negate the result */
+ {
+ z = negate(z);
+ }
+
+
+ return z;
+}
+
+Word16 BASOP_Util_Divide1616_Scale(Word16 x, Word16 y, Word16 *s)
+{
+ Word16 z;
+ Word16 sx;
+ Word16 sy;
+ Word16 sign;
+
+
+
+ /* assert (x >= (Word16)0); */
+ assert (y != (Word16)0);
+
+ sign = 0;
+ move16();
+
+ IF ( x < 0 )
+ {
+ x = negate(x);
+ sign = s_xor(sign,1);
+ }
+
+ IF ( y < 0 )
+ {
+ y = negate(y);
+ sign= s_xor(sign,1);
+ }
+
+ IF ( x == (Word16)0 )
+ {
+ move16();
+ *s = 0;
+
+
+ return ((Word16)0);
+ }
+
+ sx = norm_s(x);
+ x = shl(x,sx);
+ x = shr(x,1);
+ move16();
+ *s = sub(1,sx);
+
+ sy = norm_s(y);
+ y = shl(y,sy);
+ move16();
+ *s = add(*s,sy);
+
+ z = div_s(x,y);
+
+ if ( sign != 0 )
+ {
+ z = negate(z);
+ }
+
+
+ return z;
+}
+
+void copyWord8(const Word8 *src, Word8 *dst, const Word32 n)
+{
+ Word32 i;
+
+
+ FOR (i=0; i= 0)
+ {
+ /* Yes */
+ temp = temp2;
+ move16();
+ }
+ return temp;
+}
+Word16 findIndexOfMinWord32(Word32 *x, const Word16 len)
+{
+ Word16 i, indx;
+
+
+ indx = 0;
+ move16();
+ FOR (i = 1; i < len; i++)
+ {
+ if (LT_32(x[i],x[indx]))
+ {
+ indx = i;
+ move16();
+ }
+ }
+
+
+ return indx;
+}
+
+
+Word16 imult1616(Word16 x, Word16 y)
+{
+ assert((int)x * (int)y < 32768 && (int)x * (int)y >= -32768);
+ return extract_l(L_mult0(x, y));
+}
+
+Word32 imult3216(Word32 x, Word16 y)
+{
+ Word32 mh;
+ UWord16 ml;
+
+ Mpy_32_16_ss(x, y, &mh, &ml);
+
+ mh = L_shl(mh, 15);
+ ml = lshr(ml, 1);
+
+ return L_or(mh, L_deposit_l(ml));
+}
+
+
+Word16 idiv1616U(Word16 x, Word16 y)
+{
+ Word16 sx, sy;
+
+ /* make y > x to meet the requirements for div_s parameters */
+ sx = norm_s(x);
+ sy = norm_s(y);
+ x = shl(x, sx);
+ y = shl(y, sy);
+
+ if (x >= y)
+ {
+ x = shr(x,1);
+ sx = sub(sx,1);
+ }
+
+ /* divide and shift */
+ y = shr(div_s(x, y), sub(15, sub(sy,sx)));
+
+ return y;
+}
+
+
+Word16 idiv1616(Word16 x, Word16 y)
+{
+ Word16 s, num, den, sign;
+
+
+ num = abs_s(x);
+ den = abs_s(y);
+
+ sign = s_and(s_xor(x,y),-32768 /* 0x8000 */);
+
+ /* make num > den */
+ s = add(sub(norm_s(den), norm_s(num)), 1);
+ s = s_max(s, 0);
+
+ den = shl(den, s);
+
+ /* divide and shift */
+ y = shr(div_s(num, den), sub(15, s));
+
+ if (0 != sign)
+ {
+ y = negate(y);
+ }
+
+
+ return y;
+}
+
+Word32 norm_llQ31( /* o : normalized result Q31 */
+ Word32 L_c, /* i : upper bits of accu Q-1 */
+ Word32 L_sum, /* i : lower bits of accu, unsigned Q31 */
+ Word16 * exp /* o : exponent of result in [-32,31] Q0 */
+)
+{
+ Word16 i;
+ Word32 L_tmp;
+
+ /* Move MSBit of L_sum into L_c */
+ Carry = 0;
+ L_tmp = L_add_c(L_sum, L_sum); /* L_tmp = L_sum << 1 */
+ L_c = L_add_c(L_c,L_c);
+ L_add(0,0);
+ test();
+ IF ((L_c != (Word32) 0L) && (L_c != (Word32) 0xFFFFFFFFL))
+ {
+ i = norm_l(L_c);
+ L_c = L_shl(L_c,i);
+ i = sub(31,i); /* positive exponent */
+ L_sum = L_lshr(L_tmp, 1); /* L_sum with MSBit=0 */
+ L_sum = L_lshr(L_sum, i);
+ L_sum = L_add(L_c,L_sum);
+ }
+ ELSE
+ {
+ i = -32;
+ move16(); /* default exponent, if total sum=0 */
+ IF (L_sum)
+ {
+ i = norm_l(L_sum);
+ L_sum = L_shl(L_sum,i);
+ i = negate(i); /* negative or zero exponent */
+ }
+ }
+ *exp = i;
+ move16();
+ return L_sum;
+}
+
+Word32 w_norm_llQ31( Word64 L_sum, Word16 * exp );
+Word32 w_norm_llQ31( /* o : normalized result Q31 */
+ Word64 L_sum, /* i : upper and lower bits of accu, unsigned Q31 */
+ Word16 * exp /* o : exponent of result in [-32,31] Q0 */
+)
+{
+ Word32 L_tmp;
+ Word16 exp_val;
+ Word64 L64_inp64 = L_sum; move64();
+
+ L64_inp64 = W_shl( L64_inp64, 1);
+ exp_val = W_norm( L64_inp64 );
+ L64_inp64 = W_shl( L64_inp64, exp_val );
+ exp_val = sub( 31, exp_val );
+ if(EQ_64(L_sum , 0))
+ {
+ exp_val = -32; move16();
+ }
+ *exp = exp_val; move16();
+
+ L_tmp = W_extract_h( L64_inp64 );
+ return L_tmp;
+}
+
+Word32 Dot_product16HQ( /* o : normalized result Q31 */
+ const Word32 L_off, /* i : initial sum value Qn */
+ const Word16 x[], /* i : x vector Qn */
+ const Word16 y[], /* i : y vector Qn */
+ const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */
+ Word16 * exp /* o : exponent of result in [-32,31] Q0 */
+)
+{
+ Word16 i;
+ Word32 L_sum;
+ Word64 L_sum64;
+
+ L_sum64 = W_deposit32_l( L_off );
+
+ FOR (i=0; i < lg; i++)
+ {
+ L_sum64 = W_mac_16_16(L_sum64,x[i], y[i]);
+ }
+
+ L_sum = w_norm_llQ31(L_sum64,exp);
+ return L_sum;
+}
+
+Word32 Norm32Norm(const Word32 *x, const Word16 headroom, const Word16 length, Word16 *result_e)
+{
+ Word32 L_tmp, L_tmp2;
+ Word16 i, shift, tmp;
+
+ move16();
+ shift = headroom;
+
+ L_tmp = L_deposit_l(0);
+
+ FOR (i=0; i= 0) shift = sub(shift,1);
+ if (L_tmp2 >= 0) L_tmp = L_shr(L_tmp, 2);
+
+ tmp = round_fx(L_shl(x[i], shift));
+ L_tmp = L_mac0(L_tmp, tmp, tmp); /* exponent = (1-shift*2) , Q(30+shift*2) */
+ }
+
+ move16();
+ *result_e = sub(1, shl(shift,1));
+
+ return L_tmp;
+}
+
+Word32 Dot_productSq16HQ( /* o : normalized result Q31 */
+ const Word32 L_off, /* i : initial sum value Qn */
+ const Word16 x[], /* i : x vector Qn */
+ const Word16 lg, /* i : vector length, range [0..7FFF] Q0 */
+ Word16 * exp /* o : exponent of result in [-32,31] Q0 */
+)
+{
+ Word16 i;
+ Word32 L_sum;
+ Word64 L_sum64;
+
+ L_sum64 = W_deposit32_l( L_off );
+
+ FOR (i=0; i < lg; i++)
+ {
+ L_sum64 = W_mac_16_16(L_sum64, x[i], x[i]);
+ }
+ L_sum = w_norm_llQ31(L_sum64,exp);
+
+ return L_sum;
+}
+
+Word32 dotp_s_fx(const Word16 *x, const Word16 *y, const Word16 n, Word16 s)
+{
+ Word16 i;
+ Word16 n2;
+ Word32 L_tmp;
+ Word32 L_sum;
+
+
+ L_sum = 0;
+ move32();
+
+ n2 = shr(n,1);
+
+ s = sub(s,1);
+
+ FOR (i=0; i < n2; i++)
+ {
+ L_tmp = L_mult0(x[2*i], y[2*i]);
+ L_tmp = L_mac0(L_tmp, x[2*i+1], y[2*i+1]);
+ L_sum = L_add(L_sum, L_shr(L_tmp, s));
+ }
+
+ IF ( s_and(n,1) )
+ {
+ L_tmp = L_mult0(x[n-1], y[n-1]);
+ L_sum = L_add(L_sum, L_shr(L_tmp, s));
+ }
+
+
+ return L_sum;
+}
+
+Word32 BASOP_util_Pow2(
+ const Word32 exp_m, const Word16 exp_e,
+ Word16 *result_e
+)
+{
+ static const Word16 pow2Coeff[8] =
+ {
+ 22713/*0.693147180559945309417232121458177 Q15*/, /* ln(2)^1 /1! */
+ 7872/*0.240226506959100712333551263163332 Q15*/, /* ln(2)^2 /2! */
+ 1819/*0.0555041086648215799531422637686218 Q15*/, /* ln(2)^3 /3! */
+ 315/*0.00961812910762847716197907157365887 Q15*/, /* ln(2)^4 /4! */
+ 44/*0.00133335581464284434234122219879962 Q15*/, /* ln(2)^5 /5! */
+ 5/*1.54035303933816099544370973327423e-4 Q15*/, /* ln(2)^6 /6! */
+ 0/*1.52527338040598402800254390120096e-5 Q15*/, /* ln(2)^7 /7! */
+ 0/*1.32154867901443094884037582282884e-6 Q15*/ /* ln(2)^8 /8! */
+ };
+
+ Word32 frac_part, tmp_frac, result_m;
+ Word16 int_part;
+
+ int_part = 0; /* to avoid compilation warnings */
+ frac_part = 0; /* to avoid compilation warnings */
+
+ IF (exp_e > 0)
+ {
+ /* "+ 1" compensates L_shr(,1) of the polynomial evaluation at the loop end. */
+
+ int_part = add(1,extract_l(L_shr(exp_m, sub(31, exp_e))));
+ frac_part = L_lshl(exp_m, exp_e);
+ frac_part = L_and(0x7FFFFFFF, frac_part);
+ }
+ if (exp_e <= 0)
+ frac_part = L_shl(exp_m, exp_e);
+ if (exp_e <= 0)
+ {
+ int_part = 1;
+ move16();
+ }
+
+ /* Best accuracy is around 0, so try to get there with the fractional part. */
+ IF( (tmp_frac = L_sub(frac_part,1073741824l/*0.5 Q31*/)) >= 0)
+ {
+ int_part = add(int_part, 1);
+ frac_part = L_sub(tmp_frac,1073741824l/*0.5 Q31*/);
+ }
+ ELSE IF( (tmp_frac = L_add(frac_part,1073741824l/*0.5 Q31*/)) < 0)
+ {
+ int_part = sub(int_part, 1);
+ frac_part = L_add(tmp_frac,1073741824l/*0.5 Q31*/);
+ }
+
+ /* Evaluate taylor polynomial which approximates 2^x */
+ {
+ Word32 p;
+ Word16 i;
+
+
+ /* First taylor series coefficient a_0 = 1.0, scaled by 0.5 due to L_shr(,1). */
+ result_m = L_add(1073741824l/*1.0/2.0 Q31*/,L_shr(Mpy_32_16_1(frac_part, pow2Coeff[0]), 1));
+ p = Mpy_32_32(frac_part, frac_part);
+ FOR (i = 1; i < 7; i++)
+ {
+ /* next taylor series term: a_i * x^i, x=0 */
+ result_m = L_add(result_m, L_shr(Mpy_32_16_1(p, pow2Coeff[i]), 1));
+ p = Mpy_32_32(p, frac_part);
+ }
+ result_m = L_add(result_m, L_shr(Mpy_32_16_1(p, pow2Coeff[i]), 1));
+ }
+ *result_e = int_part;
+ move16();
+ return result_m;
+}
+Word16 findIndexOfMaxWord32(Word32 *x, const Word16 len)
+{
+ Word16 i, indx;
+
+
+ indx = 0;
+ move16();
+ FOR (i = 1; i < len; i++)
+ {
+ if (GT_32(x[i],x[indx]))
+ {
+ indx = i;
+ move16();
+ }
+ }
+
+
+ return indx;
+}
+
+
+Word16 getNormReciprocalWord16(Word16 x)
+{
+
+ assert(x < (Word16)(sizeof(BASOP_util_normReciprocal)/sizeof(BASOP_util_normReciprocal[0])));
+
+ return extract_h(BASOP_util_normReciprocal[x]);
+}
+Word16 getNormReciprocalWord16Scale(Word16 x, Word16 s)
+{
+
+ assert(x < (Word16)(sizeof(BASOP_util_normReciprocal)/sizeof(BASOP_util_normReciprocal[0])));
+
+ return round_fx(L_shl(BASOP_util_normReciprocal[x],s));
+}
+
+Word32 BASOP_Util_fPow(
+ Word32 base_m, Word16 base_e,
+ Word32 exp_m, Word16 exp_e,
+ Word16 *result_e
+)
+{
+
+ Word16 ans_lg2_e, base_lg2_e;
+ Word32 base_lg2_m, ans_lg2_m, result_m;
+ Word16 shift;
+
+
+ test();
+ IF ((base_m == 0) && (exp_m != 0))
+ {
+ *result_e = 0;
+ move16();
+ return 0;
+ }
+ /* Calc log2 of base */
+ shift = norm_l(base_m);
+ base_m = L_shl(base_m, shift);
+ base_e = sub(base_e, shift);
+ base_lg2_m = BASOP_Util_Log2(base_m);
+
+ /* shift: max left shift such that neither base_e or base_lg2_m saturate. */
+ shift = sub(s_min(norm_s(base_e), WORD16_BITS-1-LD_DATA_SCALE), 1);
+ /* Compensate shift into exponent of result. */
+ base_lg2_e = sub(WORD16_BITS-1, shift);
+ base_lg2_m = L_add(L_shr(base_lg2_m, sub(WORD16_BITS-1-LD_DATA_SCALE, shift)), L_deposit_h(shl(base_e, shift)));
+
+ /* Prepare exp */
+ shift = norm_l(exp_m);
+ exp_m = L_shl(exp_m, shift);
+ exp_e = sub(exp_e, shift);
+
+ /* Calc base pow exp */
+ ans_lg2_m = Mpy_32_32(base_lg2_m, exp_m);
+ ans_lg2_e = add(exp_e, base_lg2_e);
+
+ /* Calc antilog */
+ result_m = BASOP_util_Pow2(ans_lg2_m, ans_lg2_e, result_e);
+
+ return result_m;
+}
+
+
+/*___________________________________________________________________________
+ | |
+ | Function Name : Dot_product12_offs() |
+ | |
+ | Compute scalar product of using accumulator. |
+ | The parameter 'L_off' is added to the accumulation result. |
+ | The result is normalized (in Q31) with exponent (0..30). |
+ | Notes: |
+ | o data in x[],y[] must provide enough headroom for accumulation |
+ | o L_off must correspond in format with product of x,y |
+ | Example: 0.01f for Q9 x Q9: 0x0000147B in Q19 |
+ | means: L_off = FL2WORD32_SCALE(0.01,31-19) |
+ |---------------------------------------------------------------------------|
+ | Algorithm: |
+ | |
+ | dot_product = L_off + sum(x[i]*y[i]) i=0..N-1 |
+ |___________________________________________________________________________|
+*/
+Word32 Dot_product12_offs( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 12bits: x vector */
+ const Word16 y[], /* (i) 12bits: y vector */
+ const Word16 lg, /* (i) : vector length in range [1..256] */
+ Word16 * exp, /* (o) : exponent of result (0..+30) */
+ Word32 L_off /* (i) initial summation offset / 2 */
+)
+{
+ Word16 i, sft;
+ Word32 L_sum;
+
+ Word64 L_sum64;
+
+ L_sum64 = W_deposit32_l( L_off );
+ FOR (i = 0; i < lg; i++)
+ {
+ L_sum64 = W_mac0_16_16(L_sum64, x[i], y[i]);
+ }
+ L_sum = W_sat_l( L_sum64 );
+
+ /* Normalize acc in Q31 */
+
+ sft = norm_l(L_sum);
+ if (exp != NULL)
+ {
+ L_sum = L_shl(L_sum, sft);
+ }
+
+ /* exponent = 0..30, when L_sum != 0 */
+ if (L_sum != 0)
+ {
+ sft = sub(31,sft);
+ }
+
+ if (exp != NULL)
+ {
+ *exp = sft;
+ move16();
+ }
+
+ return L_sum;
+}
+
+Word32 Dot_product15_offs( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 15bits: x vector */
+ const Word16 y[], /* (i) 15bits: y vector */
+ const Word16 lg, /* (i) : vector length in range [1..256] */
+ Word16 *exp, /* (o) : exponent of result (0..+30) */
+ Word32 L_off /* (i) initial summation offset */
+)
+{
+ Word16 i, sft, fac, ld;
+ Word32 L_sum;
+
+ ld = sub(14,norm_s(lg));
+ fac = shr(-32768,ld);
+ L_sum = L_shr(L_off,ld);
+
+ FOR (i = 0; i < lg; i++)
+ {
+ L_sum = L_add(L_sum, Mpy_32_16_1(L_msu(0, y[i],fac),x[i]));
+ }
+
+ /* Avoid returning 0 */
+ if (L_sum == 0)
+ {
+ L_sum = L_add(L_sum, 1);
+ }
+
+ /* Normalize acc in Q31 */
+ sft = norm_l(L_sum);
+ L_sum = L_shl(L_sum, sft);
+
+ /* exponent = 0..30, when L_sum != 0 */
+ if (L_sum != 0)
+ {
+ sft = add(ld, sub(30,sft));
+ }
+
+ *exp = sft;
+ move16();
+
+ return L_sum;
+}
+
+
+/*
+
+ precondition: headroom in Y is sufficient for n accumulations
+*/
+Word32 BASOP_Util_Add_Mant32Exp /*!< o: normalized result mantissa */
+(Word32 a_m, /*!< i: Mantissa of 1st operand a */
+ Word16 a_e, /*!< i: Exponent of 1st operand a */
+ Word32 b_m, /*!< i: Mantissa of 2nd operand b */
+ Word16 b_e, /*!< i: Exponent of 2nd operand b */
+ Word16 *ptr_e) /*!< o: exponent of result */
+{
+ Word32 L_tmp;
+ Word16 shift;
+
+
+
+ /* Compare exponents: the difference is limited to +/- 30
+ The Word32 mantissa of the operand with lower exponent is shifted right by the exponent difference.
+ Then, the unshifted mantissa of the operand with the higher exponent is added. The addition result
+ is normalized and the result represents the mantissa to return. The returned exponent takes into
+ account all shift operations.
+ */
+
+ if (!a_m)
+ {
+ a_e = b_e;
+ move16();
+ }
+
+ if (!b_m)
+ {
+ b_e = a_e;
+ move16();
+ }
+
+ shift = sub(a_e, b_e);
+ shift = s_max(-31,shift);
+ shift = s_min(31, shift);
+ if (shift < 0)
+ {
+ /* exponent of b is greater than exponent of a, shr a_m */
+ a_m = L_shl(a_m,shift);
+ }
+ if (shift > 0)
+ {
+ /* exponent of a is greater than exponent of b */
+ b_m = L_shr(b_m,shift);
+ }
+ a_e = add(s_max(a_e,b_e),1);
+ L_tmp = L_add(L_shr(a_m,1),L_shr(b_m,1));
+ shift = norm_l(L_tmp);
+ if (shift)
+ L_tmp = L_shl(L_tmp,shift);
+ if (L_tmp == 0)
+ {
+ a_e = 0;
+ move16();
+ }
+ if (L_tmp != 0)
+ a_e = sub(a_e,shift);
+ *ptr_e = a_e;
+
+ return (L_tmp);
+}
+
+
+Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */
+/* 0, if a == b */
+/* 1, if a > b */
+/* -1, if a < b */
+(Word32 a_m, /*!< i: Mantissa of 1st operand a */
+ Word16 a_e, /*!< i: Exponent of 1st operand a */
+ Word32 b_m, /*!< i: Mantissa of 2nd operand b */
+ Word16 b_e) /*!< i: Exponent of 2nd operand b */
+
+{
+ Word32 diff_m;
+ Word16 diff_e, shift, result;
+
+
+
+ /*
+ This function compares two input parameters, both represented by a 32-bit mantissa and a 16-bit exponent.
+ If both values are identical, 0 is returned.
+ If a is greater b, 1 is returned.
+ If a is less than b, -1 is returned.
+ */
+
+ /* Check, if both mantissa and exponents are identical, when normalized: return 0 */
+ shift = norm_l(a_m);
+ if (shift)
+ a_m = L_shl(a_m, shift);
+ if (shift)
+ a_e = sub(a_e, shift);
+
+ shift = norm_l(b_m);
+ if (shift)
+ b_m = L_shl(b_m, shift);
+ if (shift)
+ b_e = sub(b_e, shift);
+
+ /* align exponent, if any mantissa is zero */
+ if (!a_m)
+ {
+ a_e = b_e;
+ move16();
+ }
+ if (!b_m)
+ {
+ b_e = a_e;
+ move16();
+ }
+
+ BASOP_SATURATE_WARNING_OFF
+ diff_m = L_sub(a_m,b_m);
+ BASOP_SATURATE_WARNING_ON
+ diff_e = sub(a_e,b_e);
+
+ test();
+ IF(diff_m == 0 && diff_e == 0)
+ {
+ return 0;
+ }
+
+ /* Check sign, exponent and mantissa to identify, whether a is greater b or not */
+ result = sub(0,1);
+
+ IF (a_m >= 0)
+ {
+ /* a is positive */
+ if (b_m < 0)
+ {
+ result = 1;
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ if ((b_m >= 0) && ((diff_e > 0) || (diff_e == 0 && diff_m > 0)))
+ {
+ result = 1;
+ move16();
+ }
+ }
+ ELSE
+ {
+ /* a is negative */
+ test();
+ test();
+ test();
+ if ((b_m < 0) && ((diff_e < 0) || (diff_e == 0 && diff_m > 0)))
+ {
+ result = 1;
+ move16();
+ }
+ }
+ return result;
+}
+
+/*
+
+ headroom is introduced into acc
+*/
+
+
+
+void bufferCopyFx(
+ Word16* src, /*old_exc, exc_buf, st->old_exc_len);*/
+ tmp_16 = sub(sub(Qf_src,Qf_dest),sub(Q_src,Q_dest));
+ IF (tmp_16>0) /*if value will be shifted right, do a multiplication with rounding ->preserves more accuracy*/
+ {
+ tmp_16 = shl(1,sub(15,tmp_16));
+ FOR (i = 0 ; i < length ; i++)
+ {
+ *(dest+i) = mult_r(*(src+i),tmp_16);
+ move16();
+ }
+ }
+ ELSE IF (tmp_16 <0)/*leftshift - no accuracy preservation needed*/
+ {
+ FOR (i = 0 ; i < length ; i++)
+ {
+ *(dest+i) = shr(*(src+i),tmp_16);
+ move16();
+ }
+ }
+ ELSE /*no shift, simply copy*/
+ {
+ FOR (i = 0 ; i < length ; i++)
+ {
+ *(dest+i) = *(src+i);
+ move16();
+ }
+ }
+}
+
+Word32 dotWord32_16_Mant32Exp(const Word32 *bufX32,/* i: 32-bit buffer with unknown headroom */
+ Word16 bufX32_exp, /* i: exponent of buffer bufX32 */
+ const Word16 *bufY16,/* i: 16-bit buffer quite right-aligned */
+ Word16 bufY16_exp, /* i: exponent of buffer bufY16 */
+ Word16 len, /* i: buffer len to process */
+ Word16 *exp) /* o: result exponent */
+{
+ Word32 L_sum;
+ Word16 shift, shift1, i;
+
+
+
+ shift = getScaleFactor32(bufX32, len); /* current available headroom */
+ shift = sub(shift, sub(14,norm_s(len))); /* reduced required headroom */
+ L_sum = 0; /* Clear accu */
+ move32();
+ FOR(i=0; i < len; i++)
+ {
+ L_sum = L_mac0(L_sum, round_fx(L_shl(bufX32[i], shift)), bufY16[i]);
+ }
+ shift1 = norm_l(L_sum);
+ L_sum = L_shl(L_sum, shift1); /* return value */
+
+ shift = sub(add(bufX32_exp, bufY16_exp), add(shift, shift1));
+ shift = add(shift, 1); /* compensate for factor of 2 introduced by L_mac0 */
+ /* In case of NULL result, we want to have a 0 exponent too */
+ if (L_sum == 0)
+ shift = 0;
+ *exp = shift;
+ move16();
+
+
+ return L_sum;
+
+}
+
+Word16 BASOP_Util_lin2dB(Word32 x, Word16 x_e, Word16 fEnergy)
+{
+ assert(x >= 0);
+
+ /* log2 */
+ x = L_shr(BASOP_Util_Log2(x), 25-16); /* Q16 */
+
+ /* add exponent */
+ x = L_msu(x, x_e, -32768 /* 0x8000 */);
+
+ /* convert log2 to 20*log10 */
+ x = Mpy_32_16_1(x, 24660/*6.0206f Q12*/); /* Q13 */
+
+ /* if energy divide by 2 (->10*log10) */
+ if (fEnergy != 0) x = L_shr(x, 1);
+
+ /* return dB as 7Q8 */
+ return round_fx(L_shl(x, 8-13+16)); /* Q8 */
+}
+
+/* --- fixp_atan() ---- */
+#define Q_ATANINP (25) /* Input in q25, Output in q14 */
+#define Q_ATANOUT (14)
+#define ATI_SF ((32-1)-Q_ATANINP) /* 6 */
+#define ATO_SF ((16-1)-Q_ATANOUT) /* 1 ] -pi/2 .. pi/2 [ */
+/* --- fixp_atan2() --- */
+#define Q_ATAN2OUT (13)
+#define AT2O_SF ((16-1)-Q_ATAN2OUT) /* 2 ] -pi .. pi ] */
+
+
+Word16 BASOP_util_atan2( /* o: atan2(y,x) [-pi,pi] Q13 */
+ Word32 y, /* i: */
+ Word32 x, /* i: */
+ Word16 e /* i: exponent difference (exp_y - exp_x) */
+)
+{
+ Word16 q;
+ Word32 at;
+ Word16 ret = -32768/*-1.0f Q15*/;
+ Word16 sf,sfo,stf;
+ Word32 L_sign;
+
+ if(L_or(y,x) == 0)
+ {
+ return 0;
+ }
+
+ IF(x == 0)
+ {
+ ret = 12868/*+EVS_PI/2 Q13*/;
+ move16();
+ if ( y < 0 )
+ {
+ ret = negate(ret);
+ }
+
+ return ret;
+ }
+
+ /* --- division */
+ L_sign = L_and(L_xor(x,y), 0x80000000 );
+
+ q = 32767/*1.0f Q15*/; /* y/x = neg/zero = -Inf */
+ sf = 0;
+ BASOP_SATURATE_WARNING_OFF
+ q = BASOP_Util_Divide3232_uu_1616_Scale(L_abs(y),L_abs(x), &sf);
+ BASOP_SATURATE_WARNING_ON
+
+ BASOP_SATURATE_WARNING_OFF
+ if(L_sign < 0)
+ q = negate(q);
+ BASOP_SATURATE_WARNING_ON
+
+ sfo = add(sf,e);
+
+ /* --- atan() */
+ IF ( GT_16(sfo,ATI_SF))
+ {
+ /* --- could not calc fixp_atan() here bec of input data out of range
+ ==> therefore give back boundary values */
+
+ sfo = s_min(sfo, MAXSFTAB);
+
+ /*q = FL2WORD16( 0.0f ); move16();*/
+
+ if( q > 0 )
+ {
+ move16();
+ q = +f_atan_expand_range[sfo-ATI_SF-1];
+ }
+ if( q < 0 )
+ {
+ move16();
+ q = -f_atan_expand_range[sfo-ATI_SF-1];
+ }
+ }
+ ELSE
+ {
+ /* --- calc of fixp_atan() is possible; input data within range
+ ==> set q on fixed scale level as desired from fixp_atan() */
+ stf = sub(sfo, ATI_SF);
+
+ at = L_deposit_h(q);
+ if (stf < 0) at = L_shl(at,stf);
+
+ q = BASOP_util_atan(at); /* ATO_SF*/
+ }
+
+
+ /* --- atan2() */
+
+ ret = shr(q,(AT2O_SF - ATO_SF)); /* now AT2O_SF for atan2 */
+ IF ( x < 0 )
+ {
+ if ( y >= 0 )
+ {
+ ret = add(ret, 25736/*EVS_PI Q13*/);
+ }
+ if(y < 0)
+ {
+ ret = sub(ret, 25736/* EVS_PI Q13*/);
+ }
+ }
+
+ return ret;
+}
+
+/* SNR of fixp_atan() = 56 dB*/
+#define ONEBY3P56 0x26800000 /* 1.0/3.56 in q31*/
+#define P281 0x00026000 /* 0.281 in q19*/
+#define ONEP571 0x6487 /* 1.571 in q14*/
+
+Word16 BASOP_util_atan( /* o: atan(x) [-pi/2;pi/2] 1Q14 */
+ Word32 x /* i: input data (-64;64) 6Q25 */
+)
+{
+ Word16 sign, result, exp;
+ Word16 res_e;
+ Word16 tmp, xx;
+
+
+
+ sign = 0;
+ move16();
+ if (x < 0)
+ {
+ sign = 1;
+ move16();
+ }
+ x = L_abs(x);
+
+ /* calc of arctan */
+ IF(LT_32(x, 1509950l/*0.045f/64.0f Q31*/))
+ {
+ result = round_fx(L_shl(x,5)); /*Q14*/
+ /*BASOP_util_atan_16(0.0444059968): max error 0.0000567511, mean 0.000017, abs mean 0.000017*/
+ }
+ ELSE
+ IF(LT_32(x,( L_shl(1,Q_ATANINP)-8482560l/*0.00395 Q31*/)))
+ {
+ xx =round_fx(L_shl(x,6));
+ tmp = mult_r(xx, xx); /* q15 * q15 - (16-1) = q15*/
+ tmp = mult_r(tmp, 0x1340); /* 15 * (ONEBY3P56) q14 - (16-1) = q14*/
+ tmp = add(tmp, 0x4000); /*L_shl(1,14) = 524288*/ /* q14 + q14 = q14 */
+ res_e=Q_ATANOUT-15+14-16+1;
+ move16();
+ if(GT_16(xx,tmp))
+ {
+ res_e = add(res_e,1);
+ }
+ if(GT_16(xx,tmp))
+ {
+ xx = shr(xx,1);
+ }
+ result = div_s(xx, tmp);
+ result = msu_r(0, result, shl(-32768,res_e));
+ /*BASOP_util_atan_16(0.7471138239): max error 0.0020029545, mean 0.000715, abs mean 0.000715*/
+ }
+ ELSE IF( LT_32(x,42949673l/*1.28/64.0 Q31*/))
+ {
+ Word16 delta_fix;
+ Word32 PI_BY_4 = 1686629684l/*3.1415926/4.0 Q31*//2; /* pi/4 in q30 */
+
+ delta_fix = round_fx(L_shl(L_sub(x,33554432l/*1.0/64.0 Q31*/), 5)); /* q30 */
+ result = round_fx(L_sub(L_add(PI_BY_4, L_msu(0,delta_fix,-16384)),(L_mult0(delta_fix, delta_fix))));
+ /* BASOP_Util_fPow(0.7472000122): max error 0.0020237688, mean 0.000026, abs mean 0.000520 */
+ }
+ ELSE
+ {
+ exp = sub(norm_l(x),1);
+ xx = round_fx(L_shl(x,exp));
+ /* q25+exp * q25+exp - (16-1) = q19+2*exp*/
+ tmp = mac_r(L_shl(P281,shl(exp,1)),xx, xx); /* q19+2*exp + q19+2*exp = q19+2*exp*/
+ res_e = norm_s(tmp);
+ result = div_s(xx, shl(tmp,res_e));
+ result = shl(result, add(add(Q_ATANOUT-Q_ATANINP/*-exp*/+19/*+2*exp*/-16+1, res_e ),exp));
+ result = sub(ONEP571,result); /* q14 + q14 = q14*/
+ /*BASOP_Util_fPow(1.2799999714): max error 0.0020168927, mean 0.000066, abs mean 0.000072*/
+ }
+
+ if (sign)
+ {
+ result = negate(result);
+ }
+
+ return(result);
+}
+
+/* compare two positive normalized 16 bit mantissa/exponent values */
+/* return value: positive if first value greater, negative if second value greater, zero if equal */
+Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2)
+{
+ Word16 tmp;
+
+ assert((m1 >= 0x4000) && (m2 >= 0x4000)); /* comparisons below work only for normalized mantissas */
+
+ tmp = sub(e1, e2);
+ if (tmp == 0) tmp = sub(m1, m2);
+
+ return tmp;
+}
+
+cmplx CL_scale_t(cmplx x, Word16 y)
+{
+ cmplx result;
+ result.re = Mpy_32_16_1(x.re, y);
+ result.im = Mpy_32_16_1(x.im, y);
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].CL_scale++;
+#endif
+ return (result);
+}
+
+cmplx CL_dscale_t(cmplx x, Word16 y1, Word16 y2)
+{
+ cmplx result;
+ result.re = Mpy_32_16_1(x.re, y1);
+ result.im = Mpy_32_16_1(x.im, y2);
+#if (WMOPS)
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].CL_dscale++;
+#endif/* #if (WMOPS) */
+ return (result);
+}
+
+cmplx CL_mult_32x16(cmplx input, cmplx_s coeff)
+{
+ cmplx result;
+ result.re = L_sub(Mpy_32_16_1(input.re,coeff.re), Mpy_32_16_1(input.im, coeff.im));
+ result.im = L_add(Mpy_32_16_1(input.re,coeff.im), Mpy_32_16_1(input.im, coeff.re));
+#if (WMOPS)
+ multiCounter[currCounter].CL_multr_32x16++;
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].Mpy_32_16_1--;
+ multiCounter[currCounter].L_sub--;
+ multiCounter[currCounter].L_add--;
+#endif
+ return result;
+}
diff --git a/lib_com/basop_util.h b/lib_com/basop_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..b52e70cd68699682f9ef7c605005b27d136aa921
--- /dev/null
+++ b/lib_com/basop_util.h
@@ -0,0 +1,816 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#ifndef __BASOP_UTIL_H__
+#define __BASOP_UTIL_H__
+
+#include "stl.h"
+#include "typedef.h"
+#include "basop32.h"
+#include "basop_mpy.h"
+
+
+#define _LONG long
+#define _SHORT short
+#ifdef _WIN32
+#define _INT64 __int64
+#else
+#define _INT64 long long
+#endif
+
+#define WORD32_BITS 32
+#define MAXVAL_WORD32 ((signed)0x7FFFFFFF)
+#define MINVAL_WORD32 ((signed)0x80000000)
+#define WORD32_FIX_SCALE ((_INT64)(1)<<(WORD32_BITS-1))
+
+#define WORD16_BITS 16
+#define MAXVAL_WORD16 (((signed)0x7FFFFFFF)>>16)
+#define MINVAL_WORD16 (((signed)0x80000000)>>16)
+#define WORD16_FIX_SCALE ((_INT64)(1)<<(WORD16_BITS-1))
+
+/*!
+ \def Macro converts a Word32 fixed point to Word16 fixed point <1 with saturation
+*/
+#define WORD322WORD16(val) \
+ ( ( ((((val) >> (WORD32_BITS-WORD16_BITS-1)) + 1) > (((_LONG)1< 0) ) ? \
+ (Word16)(_SHORT)(((_LONG)1<<(WORD16_BITS-1))-1):(Word16)(_SHORT)((((val) >> (WORD32_BITS-WORD16_BITS-1)) + 1) >> 1) )
+
+
+/* Word16 Packed Type */
+typedef struct
+{
+ struct
+ {
+ Word16 re;
+ Word16 im;
+ } v;
+} PWord16;
+
+#define cast16 move16
+
+
+#define LD_DATA_SCALE (6)
+#define LD_DATA_SHIFT_I5 (7)
+
+#define modDiv2(x) sub(x,shl(shr(x,1),1))
+#define modDiv8(x) L_sub(x,L_shl(L_shr(x,3),3))
+
+static __inline Word16 limitScale16( Word16 s)
+{
+ /* It is assumed, that s is calculated just before, therefore we can switch upon sign */
+ if (s >= 0)
+ s = s_min(s,WORD16_BITS-1);
+ if (s < 0)
+ s = s_max(s,1-WORD16_BITS);
+ return (s);
+}
+
+static __inline Word16 limitScale32( Word16 s)
+{
+ /* It is assumed, that s is calculated just before, therefore we can switch upon sign */
+ if (s >= 0)
+ s = s_min(s, WORD32_BITS-1);
+ if (s < 0)
+ s = s_max(s, 1-WORD32_BITS);
+ return (s);
+}
+
+/*!**********************************************************************
+ \brief Add two values given by mantissa and exponent.
+
+ Mantissas are in 16-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+
+************************************************************************/
+Word16 BASOP_Util_Add_MantExp /*!< Exponent of result */
+(Word16 a_m, /*!< Mantissa of 1st operand a */
+ Word16 a_e, /*!< Exponent of 1st operand a */
+ Word16 b_m, /*!< Mantissa of 2nd operand b */
+ Word16 b_e, /*!< Exponent of 2nd operand b */
+ Word16 *ptrSum_m); /*!< Mantissa of result */
+
+/************************************************************************/
+/*!
+ \brief Divide two values given by mantissa and exponent.
+
+ Mantissas are in 16-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+
+ For performance reasons, the division is based on a table lookup
+ which limits accuracy.
+*/
+void BASOP_Util_Divide_MantExp (Word16 a_m, /*!< Mantissa of dividend a */
+ Word16 a_e, /*!< Exponent of dividend a */
+ Word16 b_m, /*!< Mantissa of divisor b */
+ Word16 b_e, /*!< Exponent of divisor b */
+ Word16 *ptrResult_m, /*!< Mantissa of quotient a/b */
+ Word16 *ptrResult_e /*!< Exponent of quotient a/b */
+ );
+
+/************************************************************************/
+/*!
+ \brief Calculate the squareroot of a number given by mantissa and exponent
+
+ Mantissa is in 16/32-bit-fractional format with values between 0 and 1.
+ For *norm versions mantissa has to be between 0.5 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ The exponent is addressed via pointers and will be overwritten with the result.
+*/
+Word16 Sqrt16( /*!< output mantissa */
+ Word16 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+
+Word16 Sqrt16norm( /*!< output mantissa */
+ Word16 mantissa, /*!< normalized input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+
+Word32 Sqrt32( /*!< output mantissa */
+ Word32 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+
+
+/* deprecated, use Sqrt16! */
+void BASOP_Util_Sqrt_MantExp (Word16 *mantissa, /*!< Pointer to mantissa */
+ Word16 *exponent /*!< Pointer to exponent */
+ );
+
+/* deprecated, use Sqrt16norm! */
+void BASOP_Util_Sqrt_MantExpNorm (Word16 *mantissa, /*!< Pointer to normalized mantissa */
+ Word16 *exponent /*!< Pointer to exponent */
+ );
+
+/****************************************************************************/
+/*!
+ \brief Calculate the inverse of the squareroot of a number given by mantissa and exponent
+
+ Mantissa is in 16/32-bit-fractional format with values between 0 and 1.
+ For *norm versions mantissa has to be between 0.5 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ The exponent is addressed via pointers and will be overwritten with the result.
+*/
+Word16 ISqrt16( /*!< output mantissa */
+ Word16 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+
+Word32 ISqrt32( /*!< output mantissa */
+ Word32 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+
+Word32 ISqrt32norm( /*!< output mantissa */
+ Word32 mantissa, /*!< normalized input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+
+/* deprecated, use ISqrt16! */
+void BASOP_Util_InvSqrt_MantExp (Word16 *mantissa, /*!< Pointer to mantissa */
+ Word16 *exponent /*!< Pointer to exponent */
+ );
+
+/*****************************************************************************/
+/*!
+ \brief Calculate the inverse of a number given by mantissa and exponent
+
+ Mantissa is in 16-bit-fractional format with values between 0 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+ The operand is addressed via pointers and will be overwritten with the result.
+
+ The function uses a table lookup and a newton iteration.
+*/
+Word16 Inv16( /*!< output mantissa */
+ Word16 mantissa, /*!< input mantissa */
+ Word16 *exponent /*!< pointer to exponent */
+);
+/******************************************************************************/
+/*!
+ \brief Calculate the squareroot and inverse of squareroot of a number given by mantissa and exponent
+
+ Mantissa is in 16-bit-fractional format with values between 0 and 1.
+ The base for the exponent is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+*/
+void BASOP_Util_Sqrt_InvSqrt_MantExp (Word16 mantissa, /*!< mantissa */
+ Word16 exponent, /*!< expoinent */
+ Word16 *sqrt_mant, /*!< Pointer to sqrt mantissa */
+ Word16 *sqrt_exp, /*!< Pointer to sqrt exponent */
+ Word16 *isqrt_mant, /*!< Pointer to 1/sqrt mantissa */
+ Word16 *isqrt_exp /*!< Pointer to 1/sqrt exponent */
+ );
+
+/********************************************************************/
+/*!
+ \brief Calculates the scalefactor needed to normalize input array
+
+ The scalefactor needed to normalize the Word16 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 16384 <= x <= 32767 for positive x
+ and -32768 <= x <= -16384 for negative x
+*/
+
+Word16 getScaleFactor16( /* o: measured headroom in range [0..15], 0 if all x[i] == 0 */
+ const Word16 *x, /* i: array containing 16-bit data */
+ const Word16 len_x); /* i: length of the array to scan */
+
+/********************************************************************/
+/*!
+ \brief Calculates the scalefactor needed to normalize input array
+
+ The scalefactor needed to normalize the Word32 input array is returned
+ If the input array contains only '0', a scalefactor 0 is returned
+ Scaling factor is determined wrt a normalized target x: 1073741824 <= x <= 2147483647 for positive x
+ and -2147483648 <= x <= -1073741824 for negative x
+*/
+
+Word16 getScaleFactor32( /* o: measured headroom in range [0..31], 0 if all x[i] == 0 */
+ const Word32 *x, /* i: array containing 32-bit data */
+ const Word16 len_x); /* i: length of the array to scan */
+
+/**
+ * \brief normalize mantissa and update the exponent accordingly.
+ * \param mantissa the mantissa to be normalized
+ * \param pexponent pointer to the exponent.
+ * \return the normalized mantissa.
+ */
+Word16 normalize16(Word16 mantissa, Word16 *pexponent);
+/****************************************************************************/
+/*!
+ \brief Does fractional integer division of Word32 arg1 by Word16 arg2
+
+ both input arguments may be positive or negative
+ the result is truncated to Word16
+
+ \return fractional integer Word16 result of arg1/arg2
+*/
+Word16 divide3216( Word32 x, /*!< Numerator*/
+ Word16 y); /*!< Denominator*/
+
+
+/****************************************************************************/
+/*!
+ \brief Does fractional integer division of Word16 arg1 by Word16 arg2
+
+ both input arguments may be positive or negative
+ the result is truncated to Word16
+
+ \return fractional integer Word16 result of arg1/arg2
+*/
+Word16 divide1616( Word16 x, /*!< Numerator*/
+ Word16 y); /*!< Denominator*/
+
+
+/****************************************************************************/
+/*!
+ \brief Does fractional integer division of Word32 arg1 by Word32 arg2
+
+ this function makes both the numerator and the denominator positive integers,
+ and scales up both values to avoid losing the accuracy of the outcome
+ too much
+
+ WARNING: it should be arg1 < arg2 because of the maximum degree of scaling for the mantissa!
+
+ \return fractional Word16 integer z = arg1(32bits)/arg2(32bits)
+*/
+Word16 divide3232( Word32 x, /*!< Numerator*/
+ Word32 y); /*!< Denominator*/
+
+
+/****************************************************************************/
+/*!
+ \brief Does fractional integer division of UWord32 arg1 by UWord32 arg2
+
+ This function ensures both the numerator and the denominator are positive integers,
+ and scales up both values to avoid losing the accuracy of the outcome
+ too much.
+
+ CAUTION: Arg 3 is a Word16 pointer which will point to the scalefactor difference
+ s_diff = sub(s2,s1), where s1 and s2 are the scalefactors of the arguments, which
+ were shifted in order to e.g. preserve accuracy.
+ I.e. the result has to be scaled due to shifting it
+ s_diff to the right to obtain the real result of the division.
+
+ \return fractional Word16 integer z = arg1(32bits)/arg2(32bits)
+*/
+Word16 BASOP_Util_Divide3232_uu_1616_Scale( Word32 x, /*!< i : Numerator*/
+ Word32 y, /*!< i : Denominator*/
+ Word16 *s); /*!< o : Additional scalefactor difference*/
+
+
+/****************************************************************************/
+/*!
+ \brief Does fractional integer division of Word32 arg1 by Word32 arg2
+
+ This function scales up both values to avoid losing the accuracy of the outcome
+ too much.
+
+ CAUTION: Arg 3 is a Word16 pointer which will point to the scalefactor difference
+ s_diff = sub(s2,s1), where s1 and s2 are the scalefactors of the arguments, which
+ were shifted in order to e.g. preserve accuracy.
+ I.e. the result has to be scaled due to shifting it
+ s_diff to the right to obtain the real result of the division.
+
+ \return fractional Word16 integer z = arg1(32bits)/arg2(32bits)
+*/
+Word16 BASOP_Util_Divide3232_Scale( Word32 x, /*!< i : Numerator*/
+ Word32 y, /*!< i : Denominator*/
+ Word16 *s); /*!< o : Additional scalefactor difference*/
+
+
+/****************************************************************************/
+/*!
+ \brief Does fractional integer division of Word32 arg1 by Word16 arg2
+
+
+ \return fractional Word16 integer z = arg1(32bits)/arg2(16bits) , z not normalized
+*/
+Word16 BASOP_Util_Divide3216_Scale( Word32 x, /*!< i : Numerator */
+ Word16 y, /*!< i : Denominator*/
+ Word16 *s); /*!< o : Additional scalefactor difference*/
+
+
+/****************************************************************************/
+/*!
+ \brief Does fractional division of Word16 arg1 by Word16 arg2
+
+
+ \return fractional Q15 Word16 z = arg1(Q15)/arg2(Q15) with scaling s
+*/
+Word16 BASOP_Util_Divide1616_Scale( Word16 x, /*!< i : Numerator*/
+ Word16 y, /*!< i : Denominator*/
+ Word16 *s); /*!< o : Additional scalefactor difference*/
+
+/************************************************************************/
+/*!
+ \brief Binary logarithm with 7 iterations
+
+ \param x
+
+ \return log2(x)/64
+ */
+/************************************************************************/
+Word32 BASOP_Util_Log2(Word32 x);
+
+
+/************************************************************************/
+/*!
+ \brief Binary power
+
+ Date: 06-JULY-2012 Arthur Tritthart, IIS Fraunhofer Erlangen
+
+ Version with 3 table lookup and 1 linear interpolations
+
+ Algorithm: compute power of 2, argument x is in Q7.25 format
+ result = 2^(x/64)
+ We split exponent (x/64) into 5 components:
+ integer part: represented by b31..b25 (exp)
+ fractional part 1: represented by b24..b20 (lookup1)
+ fractional part 2: represented by b19..b15 (lookup2)
+ fractional part 3: represented by b14..b10 (lookup3)
+ fractional part 4: represented by b09..b00 (frac)
+ => result = (lookup1*lookup2*(lookup3+C1*frac)<<3)>>exp
+
+ Due to the fact, that all lookup values contain a factor 0.5
+ the result has to be shifted by 3 to the right also.
+ Table exp2_tab_long contains the log2 for 0 to 1.0 in steps
+ of 1/32, table exp2w_tab_long the log2 for 0 to 1/32 in steps
+ of 1/1024, table exp2x_tab_long the log2 for 0 to 1/1024 in
+ steps of 1/32768. Since the 2-logarithm of very very small
+ negative value is rather linear, we can use interpolation.
+
+ Limitations:
+
+ For x <= 0, the result is fractional positive
+ For x > 0, the result is integer in range 1...7FFF.FFFF
+ For x < -31/64, we have to clear the result
+ For x = 0, the result is ~1.0 (0x7FFF.FFFF)
+ For x >= 31/64, the result is 0x7FFF.FFFF
+
+ \param x
+
+ \return pow(2,(x/64))
+ */
+/************************************************************************/
+Word32 BASOP_Util_InvLog2(Word32 x);
+
+Word16 BASOP_util_norm_s_bands2shift (Word16 x);
+
+/***********************************************************************/
+/*!
+ \brief Calculate the headroom of the complex data in a 2 dimensional array
+
+ \return number of headroom bits
+ */
+Word16 BASOP_util_norm_l_dim2_cplx (const Word32 * const *re, /*!< Real part of 32 Bit input */
+ const Word32 * const *im, /*!< Imag part if 32 Bit input */
+ Word16 startBand, /*!< start band of cplx data */
+ Word16 stopBand, /*!< stop band of cplx data */
+ Word16 startSlot, /*!< start slot of cplx data */
+ Word16 stopSlot /*!< stop slot of cplx data */
+ );
+/****************************************************************************/
+/*!
+ \brief Does a data copy of Word8 *arg1 to Word8 *arg2 with Word16 arg3 number of moves
+*/
+void copyWord8( const Word8 *src, /*!< i : Source address */
+ Word8 *dst, /*!< i : Destination address */
+ const Word32 n); /*!< i : Number of elements to copy */
+
+
+/****************************************************************************/
+/*!
+ \brief Sets Word8 array arg1[] to zero for a length of Word16 arg2 elements
+*/
+void set_zero_Word8( Word8 X[], /*!< i : Address of array */
+ Word32 n); /*!< i : Number of elements to set to zero */
+
+/****************************************************************************/
+/*!
+ \brief Does a multiplication of Word32 * Word16 input values
+
+ \return z32 = x32 * y16
+*/
+Word32 L_mult0_3216( Word32 x, /*!< : Multiplier */
+ Word16 y); /*!< : Multiplicand */
+
+/* Calculate sin/cos. Angle in 2Q13 format, result has exponent = 1 */
+Word16 getCosWord16(Word16 theta);
+Word32 getCosWord32(Word32 theta);
+/**
+ * \brief calculate cosine of angle. Tuned for ISF domain.
+ * \param theta Angle normalized to radix 2, theta = (angle in radians)*2.0/pi
+ * \return result with exponent 0.
+ */
+Word16 getCosWord16R2(Word16 theta);
+
+/****************************************************************************/
+/*!
+ \brief square root abacus algorithm
+
+ \return integer sqrt(x)
+ */
+Word16 getSqrtWord32(Word32 x);
+
+/****************************************************************************/
+/*!
+ \brief finds index of min Word16 in array
+
+ \return index of min Word16
+ */
+Word16 findIndexOfMinWord16(Word16 *x, const Word16 len);
+
+/****************************************************************************/
+/*!
+ \brief finds index of min Word32 in array
+
+ \return index of min Word32
+ */
+Word16 findIndexOfMinWord32(Word32 *x, const Word16 len);
+
+/****************************************************************************/
+/*!
+ \brief finds index of max Word16 in array
+
+ \return index of max Word16
+ */
+Word16 findIndexOfMaxWord16(Word16 *x, const Word16 len);
+
+/****************************************************************************/
+/*!
+ \brief finds index of max Word32 in array
+
+ \return index of max Word32
+ */
+Word16 findIndexOfMaxWord32(Word32 *x, const Word16 len);
+
+/****************************************************************************/
+/*!
+ \brief 16x16->16 integer multiplication without overflow control
+
+ \return 16x16->16 integer
+ */
+Word16 imult1616(Word16 x, Word16 y);
+
+/****************************************************************************/
+/*!
+ \brief 32x16->32 integer multiplication with overflow control
+
+ \return 32x16->32 integer
+ */
+Word32 imult3216(Word32 x, Word16 y);
+
+/****************************************************************************/
+/*!
+ \brief 16/16->16 unsigned integer division
+
+ x and y have to be positive, x has to be < 16384
+
+ \return 16/16->16 integer
+ */
+
+Word16 idiv1616U(Word16 x, Word16 y);
+
+/****************************************************************************/
+/*!
+ \brief 16/16->16 signed integer division
+
+ x and y have to be positive, x has to be < 16384
+
+ \return 16/16->16 integer
+ */
+
+Word16 idiv1616(Word16 x, Word16 y);
+
+/*------------------------------------------------------------------*
+ * Dot_product16HQ:
+ *
+ * \brief Compute scalar product of using 64-bit accumulator.
+ *
+ * Performs normalization of the result, returns the exponent
+ * Note: In contrast to dotWord32, no headroom is required for data
+ * in x[] and y[], means, they may have any format Qn
+ *------------------------------------------------------------------*/
+Word32 Dot_product16HQ( /* using 64-bit accumulator.
+ *
+ * Performs normalization of the result, returns the exponent
+ * Note: In contrast to dotWord32, no headroom is required for data
+ * in x[], means, they may have any format Qn
+ *------------------------------------------------------------------*/
+Word32 Dot_productSq16HQ( /* using 64-bit accumulator.
+ *
+ * Performs no normalization of the result
+ *------------------------------------------------------------------*/
+Word32 dotp_s_fx( /* using accumulator. |
+ | The parameter 'L_off' is added to the accumulation result. |
+ | The result is normalized (in Q31) with exponent (0..30). |
+ | Notes: |
+ | o data in x[],y[] must provide enough headroom for accumulation |
+ | o L_off must correspond in format with product of x,y |
+ | Example: 0.01f for Q9 x Q9: 0x0000147B in Q19 |
+ | means: L_off = FL2WORD32_SCALE(0.01f,31-19) |
+ |---------------------------------------------------------------------------|
+ | Algorithm: |
+ | |
+ | dot_product = L_off + sum(x[i]*y[i]) i=0..N-1 |
+ |___________________________________________________________________________|
+*/
+
+Word32 Dot_product12_offs( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 12bits: x vector */
+ const Word16 y[], /* (i) 12bits: y vector */
+ const Word16 lg, /* (i) : vector length in range [1..256] */
+ Word16 * exp, /* (o) : exponent of result (0..+30) */
+ Word32 L_off /* (i) initial summation offset /2 */
+);
+
+Word32 Dot_product15_offs( /* (o) Q31: normalized result (1 < val <= -1) */
+ const Word16 x[], /* (i) 15bits: x vector */
+ const Word16 y[], /* (i) 15bits: y vector */
+ const Word16 lg, /* (i) : vector length in range [1..256] */
+ Word16 *exp, /* (o) : exponent of result (0..+30) */
+ Word32 L_off /* (i) initial summation offset */
+);
+
+/*!**********************************************************************
+ \brief Add two values given by mantissa and exponent.
+
+ Mantissas are in 32-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+
+************************************************************************/
+Word32 BASOP_Util_Add_Mant32Exp /*!< o: normalized result mantissa */
+(Word32 a_m, /*!< i: Mantissa of 1st operand a */
+ Word16 a_e, /*!< i: Exponent of 1st operand a */
+ Word32 b_m, /*!< i: Mantissa of 2nd operand b */
+ Word16 b_e, /*!< i: Exponent of 2nd operand b */
+ Word16 *ptr_e); /*!< o: exponent of result */
+/*!**********************************************************************
+ \brief Returns the comparison result of two normalized values given by mantissa and exponent.
+ return value: -1: a < b, 0: a == b, 1; a > b
+
+ Mantissas are in 32-bit-fractional format with values between 0 and 1.
+ The base for exponents is 2. Example: \f$ a = a\_m * 2^{a\_e} \f$
+
+************************************************************************/
+Word16 BASOP_Util_Cmp_Mant32Exp /*!< o: flag: result of comparison */
+(Word32 a_m, /*!< i: Mantissa of 1st operand a */
+ Word16 a_e, /*!< i: Exponent of 1st operand a */
+ Word32 b_m, /*!< i: Mantissa of 2nd operand b */
+ Word16 b_e); /*!< i: Exponent of 2nd operand b */
+
+/********************************************************************
+ * bufferCopyFx
+ *
+ * \brief copies buffer while preserving Format of destination buffer
+*********************************************************************
+*/
+void bufferCopyFx(
+ Word16* src, /*
+ The base for exponent x_e is 2.
+
+************************************************************************/
+Word16 BASOP_Util_lin2dB( /*!< o: dB value (7Q8) */
+ Word32 x, /*!< i: mantissa */
+ Word16 x_e, /*!< i: exponent */
+ Word16 fEnergy); /*!< i: flag indicating if x is energy */
+
+/*!**********************************************************************
+ \brief Calculates atan(x).
+************************************************************************/
+Word16 BASOP_util_atan( /*!< o: atan(x) [-pi/2;pi/2] 1Q14 */
+ Word32 x /*!< i: input data (-64;64) 6Q25 */
+);
+
+/*!**********************************************************************
+ \brief Calculates atan2(y,x).
+************************************************************************/
+Word16 BASOP_util_atan2( /*!< o: atan2(y,x) [-pi,pi] Q13 */
+ Word32 y, /*!< i: */
+ Word32 x, /*!< i: */
+ Word16 e /*!< i: exponent difference (exp_y - exp_x) */
+);
+/*!**********************************************************************
+ \brief norm_llQ31 returns Word32 with scalingfactor, with 2 32bit accus as input
+
+************************************************************************/
+Word32 norm_llQ31( /* o : normalized result Q31 */
+ Word32 L_c, /* i : upper bits of accu Q-1 */
+ Word32 L_sum, /* i : lower bits of accu, unsigned Q31 */
+ Word16 * exp /* o : exponent of result in [-32,31] Q0 */
+);
+
+/* compare two positive normalized 16 bit mantissa/exponent values */
+/* return value: positive if first value greater, negative if second value greater, zero if equal */
+Word16 compMantExp16Unorm(Word16 m1, Word16 e1, Word16 m2, Word16 e2);
+
+
+cmplx CL_scale_t(cmplx x, Word16 y);
+cmplx CL_dscale_t(cmplx x, Word16 y1, Word16 y2);
+cmplx CL_mult_32x16(cmplx input, cmplx_s coeff);
+
+#endif /* __BASOP_UTIL_H__ */
diff --git a/lib_com/bitalloc_fx.c b/lib_com/bitalloc_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..e875265f99d80e8261c59748cd0ff56ee64349c2
--- /dev/null
+++ b/lib_com/bitalloc_fx.c
@@ -0,0 +1,1029 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+
+void bitalloc_fx (
+ Word16 *y, /* i : reordered norm of sub-vectors Q0 */
+ Word16 *idx, /* i : reordered sub-vector indices Q0 */
+ Word16 sum, /* i : number of available bits Q0 */
+ Word16 N, /* i : number of norms Q0 */
+ Word16 K, /* i : maximum number of bits per dimension Q0 */
+ Word16 *r, /* o : bit-allacation vector Q0 */
+ const Word16 *sfmsize, /* i : band length Q0 */
+ const Word16 hqswb_clas /* i : signal classification flag Q0 */
+)
+{
+ Word16 i, j, k, n, m, v, im;
+ Word16 diff, temp;
+ Word16 fac;
+ Word16 ii;
+ Word16 SFM_thr = SFM_G1G2;
+ move16();
+
+ N = sub(N, 1);
+
+ if ( EQ_16(hqswb_clas, HQ_HARMONIC))
+ {
+ SFM_thr = 22;
+ move16();
+ }
+
+ fac = 3;
+ move16();
+ K = sub(K,2);
+ im = 1;
+ move16();
+ diff = sum;
+ move16();
+ n = shr(sum,3);
+ FOR ( i=0; i 0)
+ {
+ n = add(n,Nb[i]);
+ Rsubband_w32_fx[i] = Mult_32_16(Rsubband_w32_fx[i], tmp);
+ move32();/*exp1 - 15*/
+ Rsubband_w32_fx[i] = L_shl(Rsubband_w32_fx[i], sub(30, exp1));/*Q15*/
+
+ t_fx = L_add(t_fx, Rsubband_w32_fx[i]);/*Q0*/
+ }
+ ELSE
+ {
+ Rsubband_w32_fx[i] = L_deposit_l(0);
+ }
+ }
+ }
+ ELSE
+ {
+ /* Initial bits distribution */
+ L_tmp1 = 0;
+ move16();
+ m_fx = 0;
+ move16();
+ FOR ( i = 0; i < N ; i++)
+ {
+ L_tmp1 = L_mac0(L_tmp1, Nb[i], y[i]);
+ }
+ L_tmp1 = L_msu0(L_tmp1, fac, B);
+
+
+ t_fx = L_deposit_l(0);
+ n = 0;
+ move16();
+ tmp = add(band_end_HQ[N-1], shl(band_end_HQ[N-1], 1));
+ exp1 = norm_s(tmp);
+ tmp = div_s(16384, shl(tmp, exp1));/*15 + 14 - exp1*/
+ exp2 = norm_s(tmp);
+ tmp = shl(tmp, exp2);
+ exp1 = add(29, sub(exp2, exp1));
+ FOR ( i = 0; i < N; i++)
+ {
+ L_tmp2 = L_sub(L_mult0(y[i], band_end_HQ[N-1]), L_tmp1);
+ Rsubband_w32_fx[i] = L_mult0(extract_l(L_tmp2), Nb[i]);
+ move32();/*Q0*/
+ IF (Rsubband_w32_fx[i] > 0)
+ {
+ n = add(n,Nb[i]);
+ L_tmp3 = Mult_32_16(Rsubband_w32_fx[i], tmp); /*exp1 - 15*/
+ Rsubband_w32_fx[i] = L_shl(L_tmp3, sub(30, exp1)); /*Q15*/ move32();
+
+ t_fx = L_add(t_fx, Rsubband_w32_fx[i]);/*Q0*/
+ }
+ ELSE
+ {
+ Rsubband_w32_fx[i] = L_deposit_l(0);
+ }
+ }
+ }
+
+ /* Distribute the remaining bits to subbands with non-zero bits */
+ B_fx = L_shl(B, 15);
+ WHILE (NE_32(L_shr(L_add(t_fx, 16384), 15) , B))
+ {
+ L_tmp1 = L_sub(t_fx, B_fx);
+ exp1 = sub(norm_l(L_tmp1), 1);
+ exp2 = norm_s(n);
+ tmp = div_s(extract_h(L_shl(L_tmp1, exp1)), shl(n, exp2));/*15 + 15 + exp1 - 16 - exp2*/
+ m_fx = shl(tmp, sub(exp2, exp1));/*Q14*/
+
+ t_fx = L_deposit_l(0);
+ n = 0;
+ move16();
+ FOR ( i = 0; i < N; i++)
+ {
+ IF (Rsubband_w32_fx[i] > 0)
+ {
+ Rsubband_w32_fx[i] = L_msu(Rsubband_w32_fx[i], m_fx, Nb[i]);
+ move32();
+
+ IF (Rsubband_w32_fx[i] > 0)
+ {
+ n = add(n,Nb[i]);
+
+ t_fx = L_add(t_fx, Rsubband_w32_fx[i]);
+ }
+ ELSE
+ {
+ Rsubband_w32_fx[i] = L_deposit_l(0);
+ }
+ }
+ }
+ }
+ Bits = B;
+ move16();
+
+ /* Impose bit-constraints to subbands with less than minimum bits*/
+ t_fx = L_deposit_l(0);
+ n = 0;
+ move16();
+ FOR ( i = 0; i < N; i++)
+ {
+ IF (Rsubband_w32_fx[i] > 0)
+ {
+ test();
+ IF ((LT_32(Rsubband_w32_fx[i] , L_shl(add(bs, LNb[i]), 15)))&&(EQ_16(low_rate,1)))
+ {
+ Rsubband_w32_fx[i] = L_deposit_l(0);
+ }
+ ELSE IF ( LE_32(Rsubband_w32_fx[i] , L_shl(Nb[i], 15)))
+ {
+ B = sub(B,Nb[i]);
+ Rsubband_w32_fx[i] = L_shl(Nb[i], 15);
+ move32();
+ }
+ ELSE
+ {
+ n = add(n,Nb[i]);
+ t_fx = L_add(t_fx, Rsubband_w32_fx[i]);
+ }
+ }
+ }
+
+ /* Distribute the remaining bits to subbands with more than 1-bit per sample */
+ WHILE (NE_32(L_shr(L_add(t_fx, 16384), 15) ,B))
+ {
+ L_tmp1 = L_sub(t_fx, L_shl(B, 15));
+ L_tmp2 = L_abs(L_tmp1);
+
+ if (n>0)
+ {
+ exp1 = sub(norm_l(L_tmp2), 1);
+ exp2 = norm_s(n);
+ tmp = div_s(extract_h(L_shl(L_tmp2, exp1)), shl(n, exp2));/*15 + 15 + exp1 - 16 - exp2*/
+ m_fx = shl(tmp, sub(exp2, exp1));/*Q14*/
+ if (L_tmp1 < 0)
+ {
+ m_fx = negate(m_fx);
+ }
+
+ t_fx = L_deposit_l(0);
+ n = 0;
+ move16();
+ FOR( i = 0; i < N; i++)
+ {
+ IF (GT_32(Rsubband_w32_fx[i] , L_shl(Nb[i], 15)))
+ {
+ Rsubband_w32_fx[i] = L_msu(Rsubband_w32_fx[i], m_fx, Nb[i]);
+ move32();
+ IF (GT_32(Rsubband_w32_fx[i] ,L_shl(Nb[i], 15)))
+ {
+ n = add(n,Nb[i]);
+
+ t_fx = L_add(t_fx, Rsubband_w32_fx[i]);
+ }
+ ELSE
+ {
+ B = sub(B,Nb[i]);
+
+ Rsubband_w32_fx[i] = L_shl(Nb[i], 15);
+ move32();
+ }
+ }
+ }
+ }
+ /*In case no subband has enough bits more than 1-bit per sample, take bits off the higher subbands */
+ IF (t_fx == 0)
+ {
+ FOR ( i = N-1; i >= 0; i--)
+ {
+ IF (Rsubband_w32_fx[i] > 0)
+ {
+ B = add( B, Nb[i] );
+ Rsubband_w32_fx[i] = L_deposit_l(0);
+ IF ( B >= 0)
+ {
+ BREAK;
+ }
+ }
+ }
+ BREAK;
+ }
+ }
+
+ /* fine redistribution of over-allocated or under-allocated bits */
+ tmp = 0;
+ move16();
+ FOR ( i = 0; i < N; i++)
+ {
+ Rsubband_fx[i] = extract_l(L_shr(Rsubband_w32_fx[i], 12));
+ tmp = add(tmp, Rsubband_fx[i]);
+ }
+
+ B = Bits;
+ B_w16_fx = shl(B, 3);
+ IF (GT_16(tmp ,B_w16_fx))
+ {
+ tmp = sub(tmp, B_w16_fx);
+ FOR ( i = 0; i < N; i++)
+ {
+ IF (GE_16(Rsubband_fx[i], add(shl(Nb[i], 3), tmp)))
+ {
+ Rsubband_fx[i] = sub(Rsubband_fx[i], tmp);
+ move16();
+ BREAK;
+ }
+ }
+ }
+ ELSE
+ {
+ tmp = sub(tmp, B_w16_fx);
+ FOR ( i = 0; i < N; i++)
+ {
+ IF (Rsubband_fx[i] > 0)
+ {
+ Rsubband_fx[i] = sub(Rsubband_fx[i], tmp);
+ move16();
+ BREAK;
+ }
+ }
+ }
+
+ /* Calcuate total used bits and initialize R to be used for Noise Filling */
+ tmp = 0;
+ move16();
+ FOR ( i = 0; i < N; i++)
+ {
+ tmp = add(tmp, Rsubband_fx[i]);
+ R[i] = shr(Rsubband_fx[i], 3);
+ move16();
+ }
+ return shr(tmp, 3);
+}
+/*-------------------------------------------------------------------*
+ * Bit_group()
+ *
+ * bit allocation in group
+ *-------------------------------------------------------------------*/
+static
+void Bit_group_fx (
+ Word16 *y, /* i : norm of sub-band Q0*/
+ Word16 start_band, /* i : start band indices Q0*/
+ Word16 end_band, /* i : end band indices Q0*/
+ Word16 Bits, /* i : number of allocation bits in group Q0*/
+ Word16 thr, /* i : smallest bit number for allocation in group Q0*/
+ Word32 *Rsubband_fx, /* o : bit allocation of sub-band Q21*/
+ Word16 *fac_fx /* i : weight factor for norm of sub-band Q13*/
+)
+{
+ Word16 i, j, k, m, y_index[16], index[16], bit_band, band_num, norm_sum;
+ Word16 tmp,exp;
+ Word16 factor_fx;
+ Word32 R_temp_fx[16], R_sum_fx = 0, R_sum_org_fx = 0, Bits_avg_fx = 0;
+ Word32 L_tmp;
+
+ /* initialization for bit allocation in one group*/
+ tmp = 6554;
+ move16(); /*Q15 1/5 */
+ if(EQ_16(thr,5))
+ {
+ tmp = 6554;
+ move16(); /*Q15 1/5 */
+ }
+ if(EQ_16(thr,6))
+ {
+ tmp = 5462;
+ move16();/*Q15 1/6 */
+ }
+ if(EQ_16(thr,7))
+ {
+ tmp = 4682;
+ move16();/*Q15 1/7 */
+ }
+ bit_band = mult(tmp, Bits); /*0+15-15=0, Q0 */
+ band_num = sub(end_band,start_band);
+
+ FOR( i = 0; i < band_num; i++ )
+ {
+ y_index[i] = y[add(i,start_band)];
+ move16();
+ index[i] = i;
+ move16();
+ }
+
+ /* Rearrange norm vector in decreasing order */
+ reordvct_fx(y_index, band_num, index);
+ /* norm vector modification */
+
+ factor_fx = div_s(1, band_num);/*Q15 */
+ IF ( GT_16(thr,5))
+ {
+ FOR ( i = 0; i < band_num; i++ )
+ {
+ L_tmp = L_mult(i,factor_fx);/*Q16 */
+ tmp = extract_h(L_shl(L_tmp, 13)); /*Q13 */
+ tmp = sub(fac_fx[1],tmp);/*Q13 */
+ L_tmp = L_mult(y_index[i],tmp);/*Q14 */
+ y_index[i] = extract_h(L_shl(L_tmp, 2));/*Q0 */
+ }
+ }
+ ELSE
+ {
+ FOR ( i = 0; i < band_num; i++ )
+ {
+ L_tmp = L_mult(i,factor_fx);/*Q16 */
+ tmp = extract_h(L_shl(L_tmp, 13)); /*Q13 */
+ tmp = sub(fac_fx[0],tmp);/*Q13 */
+ L_tmp = L_mult(y_index[i],tmp);/*Q14 */
+ y_index[i] = extract_h(L_shl(L_tmp, 2));/*Q0 */
+ }
+ }
+
+ /* bit allocation based on modified norm */
+ L_tmp = L_mult(band_num,24576);/*Q16 */
+ tmp = extract_h(L_shl(L_tmp,7));/*Q7 */
+ IF ( GE_16(shl(bit_band,7),tmp))
+ {
+ FOR ( j = 0; j < band_num; j++)
+ {
+ if ( y_index[j] < 0 )
+ {
+ y_index[j] = 0;
+ move16();
+ }
+ R_temp_fx[j] = 2097152;
+ move16();/*Q21 = 1 move16(); */
+ }
+
+ i = sub(band_num,1);
+ norm_sum = 0;/*Q0 */
+ FOR (k = 0; k <= i; k++)
+ {
+ norm_sum = add(norm_sum,y_index[k]);
+ }
+
+ FOR (j = 0; j < band_num; j++)
+ {
+ IF(norm_sum == 0)
+ {
+ FOR (k = 0; k <= i; k++)
+ {
+ R_temp_fx[k] = L_deposit_h(0);/*Q21 */
+ }
+ }
+ ELSE
+ {
+ exp = norm_s(norm_sum);
+ tmp = shl(norm_sum, exp);/*Q(exp) */
+ tmp = div_s(16384,tmp); /*Q(15+14-exp) */
+ Bits_avg_fx = L_mult(tmp, Bits);/*Q(30-exp) */
+
+ FOR (k = 0; k <= i; k++)
+ {
+ L_tmp = L_shl(L_deposit_l(y_index[k]),24);
+ L_tmp = Mult_32_32(Bits_avg_fx,L_tmp);/*Q(23-exp) */
+
+ R_temp_fx[k] = L_shl(L_tmp,sub(exp,2));
+ move32();/*Q21 */
+ }
+ }
+
+ L_tmp = L_shl(L_deposit_l(thr),21);/*Q21 */
+ IF ( LT_32(R_temp_fx[i],L_tmp))
+ {
+ R_temp_fx[i] = L_deposit_h(0);
+ norm_sum = sub(norm_sum,y_index[i]);
+ i--;
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+ }
+ ELSE
+ {
+ FOR ( j = 0; j < bit_band; j++ )
+ {
+ if ( y_index[j] < 0 )
+ {
+ y_index[j] = 0;
+ move16();
+ }
+ R_temp_fx[j] = 2097152;
+ move32();/*Q21 = 1 */
+ }
+
+ FOR ( j = bit_band; j < band_num; j++ )
+ {
+ R_temp_fx[j] = L_deposit_l(0);
+ }
+
+ norm_sum = 0;
+ FOR (k = 0; k < bit_band; k++)
+ {
+ norm_sum = add(norm_sum,y_index[k]);
+ }
+
+ i = bit_band;
+ FOR (j = 0; j < bit_band; j++)
+ {
+ IF(norm_sum == 0)
+ {
+ FOR (k = 0; k < i; k++)
+ {
+ R_temp_fx[k] = L_deposit_l(0); /*Q21 */
+ }
+ }
+ ELSE
+ {
+ exp = norm_s(norm_sum);
+ tmp = shl(norm_sum, exp);/*Q(exp) */
+ tmp = div_s(16384,tmp); /*Q(15+14-exp) */
+ Bits_avg_fx = L_mult(tmp, Bits);/*Q(30-exp) */
+ FOR (k = 0; k < i; k++)
+ {
+ L_tmp = L_shl(L_deposit_l(y_index[k]),24);
+ L_tmp = Mult_32_32(Bits_avg_fx,L_tmp);/*Q(23-exp) */
+
+ R_temp_fx[k] = L_shl(L_tmp,sub(exp,2));
+ move32();/*Q21 */
+ }
+ }
+ R_sum_fx = 0;
+ L_tmp = L_shl(L_deposit_l(thr),21);/*Q21 */
+ FOR (k = 0; k < i; k++)
+ {
+ IF (LT_32(R_temp_fx[k],L_tmp))
+ {
+ FOR(m = k; m < i; m++)
+ {
+ norm_sum = sub(norm_sum,y_index[m]);
+ R_temp_fx[m] = L_deposit_l(0); /*Q21 */
+ }
+ i = k;
+ BREAK;
+ }
+ ELSE
+ {
+ R_sum_fx = L_add(R_sum_fx,R_temp_fx[k]);
+ }
+ }
+ IF (EQ_32(R_sum_fx,R_sum_org_fx))
+ {
+ BREAK;
+ }
+
+ R_sum_org_fx = R_sum_fx;
+ }
+ }
+
+ /* index comeback */
+ FOR ( k = 0 ; k < band_num; k++ )
+ {
+ j = index[k];
+ move16();
+ Rsubband_fx[add(j,start_band)] = R_temp_fx[k];
+ move32();
+ }
+
+ return;
+
+}
+
+/*-------------------------------------------------------------------*
+ * BitAllocWB()
+ *
+ * WB bit allocation
+ *-------------------------------------------------------------------*/
+
+Word16 BitAllocWB_fx( /* o : t Q0*/
+ Word16 *y, /* i : norm of sub-vectors Q0*/
+ Word16 B, /* i : number of available bits Q0*/
+ Word16 N, /* i : number of sub-vectors Q0*/
+ Word16 *R, /* o : bit-allocation indicator Q0*/
+ Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/
+)
+{
+ Word16 t_fx;
+ Word16 i, j, k, B1, B2, B3, B_saved;
+ Word16 Rsum_fx, Rsum_sub_fx[3];
+ Word32 Ravg_sub_32_fx[3], R_diff_32_fx[2];
+ Word16 factor_fx[2];/*Q13 */
+ Word16 BANDS;
+ Word16 tmp,exp;
+ Word16 Rsum_sub_fx_tmp=0; /* initialize just to avoid compiler warning */
+ Word32 L_tmp,L_tmp1;
+ Word32 Rsubband_buf[NB_SFM];
+
+ BANDS = N;
+ move16();
+ if( GT_16(BANDS,SFM_N))
+ {
+ BANDS = SFM_N;
+ move16();
+ }
+ /* Init Rsubband to non-zero values for bands to be allocated bits */
+ FOR (k = 0; k < BANDS; k++)
+ {
+ Rsubband_buf[k] = 2097152;
+ move32();/*Q21 */
+ }
+ /* Calculate the norm sum and average of sub-band */
+ Rsum_sub_fx[0] = 0;
+ move16();
+ FOR ( j = 0; j < SFM_G1; j++ )
+ {
+ if ( y[j] > 0 )
+ {
+ Rsum_sub_fx_tmp = add(Rsum_sub_fx[0],y[j]); /*Q0 */
+ }
+ if (y[j] > 0)
+ {
+ Rsum_sub_fx[0] = Rsum_sub_fx_tmp;
+ move16(); /*Q0 */
+ }
+ }
+ Ravg_sub_32_fx[0] = L_mult(Rsum_sub_fx[0], 2048);
+ move32();/*Q16 0+15+1 //q15 1/16 =2048 */
+
+ Rsum_sub_fx[1] = 0;
+ move16();
+ FOR ( j = SFM_G1; j < SFM_G1G2; j++ )
+ {
+ if ( y[j] > 0 )
+ {
+ Rsum_sub_fx_tmp = add(Rsum_sub_fx[1],y[j]); /*Q0 */
+ }
+ if ( y[j] > 0 )
+ {
+ Rsum_sub_fx[1] = Rsum_sub_fx_tmp;
+ move16();/*Q0 */
+ }
+ }
+ Ravg_sub_32_fx[1] = L_mult(Rsum_sub_fx[1], 4096); /*16 0+15+1 //q15 1/8 =4096 */
+
+ Rsum_sub_fx[2] = 0;
+ move16();
+ FOR ( j = SFM_G1G2; j < BANDS; j++ )
+ {
+ if ( y[j] > 0 )
+ {
+ Rsum_sub_fx_tmp = add(Rsum_sub_fx[2],y[j]); /*Q0 */
+ }
+ if ( y[j] > 0 )
+ {
+ Rsum_sub_fx[2] = Rsum_sub_fx_tmp;
+ move16();/*Q0 */
+ }
+ }
+ tmp = div_s(1, BANDS-SFM_G1G2); /*Q15 */
+ Ravg_sub_32_fx[2] = L_mult(Rsum_sub_fx[2], tmp);
+ move32();/*Q16 */
+
+ /* Bit allocation for every group */
+ tmp = add(Rsum_sub_fx[0],Rsum_sub_fx[1]);
+ Rsum_fx = add(tmp,Rsum_sub_fx[2]);/*Q0 */
+
+ factor_fx[0] = 16384;/*Q13 move16(); */
+ factor_fx[1] = 24576;/*Q13 move16(); */
+ {
+ R_diff_32_fx[0] = L_sub(Ravg_sub_32_fx[0], Ravg_sub_32_fx[1]);
+ move32();/*Q16 */
+ R_diff_32_fx[1] = L_sub(Ravg_sub_32_fx[1], Ravg_sub_32_fx[2]);
+ move32();/*Q16 */
+
+ test();
+ IF ( LT_32(R_diff_32_fx[0],393216)&<_32(R_diff_32_fx[1],245760))
+ {
+ IF(Rsum_fx == 0)
+ {
+ B1 = 0;
+ move16();
+ B2 = 0;
+ move16();
+ B3 = 0;
+ move16();
+ }
+ ELSE
+ {
+ exp = norm_s(Rsum_fx);
+ tmp = shl(Rsum_fx,exp);/*Q(exp) */
+ tmp = div_s(16384,tmp);/*Q(15+14-exp) */
+ L_tmp1 = L_mult(B,Rsum_sub_fx[0]);/*Q1 */
+ L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */
+ B1 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */
+ test();
+ if(GT_32(L_tmp1,L_mult(B1,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B1,1),Rsum_fx)))
+ {
+ B1 = add(B1,1);
+ }
+ L_tmp1 = L_mult(B,Rsum_sub_fx[1]);/*Q1 */
+ L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */
+ B2 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */
+ test();
+ if(GT_32(L_tmp1,L_mult(B2,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B2,1),Rsum_fx)))
+ {
+ B2 = add(B2,1);
+ }
+ L_tmp1 = L_mult(B,Rsum_sub_fx[2]);/*Q1 */
+ L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */
+ B3 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */
+ test();
+ if(GT_32(L_tmp1,L_mult(B3,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B3,1),Rsum_fx)))
+ {
+ B3 = add(B3,1);
+ }
+ }
+ IF ( GT_32(Ravg_sub_32_fx[2],786432))
+ {
+ B_saved = 0;
+ move16();
+ IF ( GT_16(B1,288))
+ {
+ B_saved = sub(B1,288);
+ B1 = 288;
+ move16();
+ }
+
+ IF ( GT_16(B2,256))
+ {
+ tmp = sub(B2,256);
+ B_saved = add(B_saved,tmp);
+ B2 = 256;
+ move16();
+ }
+
+ IF ( GT_16(B3,96))
+ {
+ tmp = sub(B3,96);
+ B_saved = add(B_saved,tmp);
+ B3 = 96;
+ move16();
+ }
+
+ IF ( B_saved > 0 )
+ {
+ IF ( EQ_16(B1,288))
+ {
+ tmp = shr(B_saved,1);
+ B2 = add(B2,tmp);
+ tmp = sub(B,B1);
+ B3 = sub(tmp,B2);
+ }
+ ELSE
+ {
+ tmp = shr(B_saved,1);
+ B1 = add(B1,tmp);
+ IF ( EQ_16(B2,256))
+ {
+ tmp = sub(B,B1);
+ B3 = sub(tmp,B2);
+ }
+ ELSE
+ {
+ tmp = sub(B,B1);
+ B2 = sub(tmp,B3);
+ }
+ }
+ }
+ }
+
+ factor_fx[0] = 16384;
+ move16();/*Q13 */
+ factor_fx[1] = 12288;
+ move16();/*Q13 */
+ }
+ ELSE
+ {
+ IF(Rsum_fx == 0)
+ {
+ B1 = 0;
+ move16();
+ B2 = 0;
+ move16();
+ B3 = B;
+ move16();
+ }
+ ELSE
+ {
+ exp = norm_s(Rsum_fx);
+ tmp = shl(Rsum_fx,exp);/*Q(exp) */
+ tmp = div_s(16384,tmp);/*Q(15+14-exp) */
+ L_tmp1 = L_mult(B,Rsum_sub_fx[0]);/*Q1 */
+ L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(15-exp) */
+ B1 = extract_h(L_shl(L_tmp,add(exp,1)));/*Q0 */
+ test();
+ if(GT_32(L_tmp1,L_mult(B1,Rsum_fx))&&GE_32(L_tmp1,L_mult(add(B1,1),Rsum_fx)))
+ {
+ B1 = add(B1,1);
+ }
+ L_tmp1 = Mult_32_16(1975684956,shl(B,5));/*Q(31+5-15=21) */
+ L_tmp1 = Mult_32_16(L_tmp1,shl(Rsum_sub_fx[1],7));/*Q(21+7-15=13) */
+ L_tmp = Mult_32_16(L_tmp1,tmp);/*Q(27-exp) */
+ B2 = extract_h(L_shl(L_tmp,sub(exp,11)));/*Q0 */
+ test();
+ if(GT_32(L_tmp1,L_shl(L_mult(B2,Rsum_fx),12))&&GE_32(L_add(L_tmp1,2),L_shl(L_mult(add(B2,1),Rsum_fx),12)))
+ {
+ B2 = add(B2,1);
+ }
+ tmp = sub(B,B1);
+ B3 = sub(tmp,B2);
+ }
+ }
+ }
+
+ IF ( LT_16(Rsum_sub_fx[2],3))
+ {
+ B2 = add(B2,B3);
+ B3 = 0;
+ move16();
+ }
+
+ /* Bit allocation in group */
+ Bit_group_fx( y, 0, SFM_G1, B1, 5, Rsubband_buf, factor_fx);
+ Bit_group_fx( y, SFM_G1, SFM_G1G2, B2, 6, Rsubband_buf, factor_fx);
+ Bit_group_fx( y, SFM_G1G2, BANDS, B3, 7, Rsubband_buf, factor_fx);
+ FOR (i = 0; i < BANDS; i++)
+ {
+ Rsubband_fx[i] = extract_l(L_shr(Rsubband_buf[i], 18));
+ }
+
+ /* Calcuate total used bits and initialize R to be used for Noise Filling */
+ L_tmp = L_deposit_l(0);
+ FOR( i = 0; i < N; i++)
+ {
+ L_tmp = L_add(L_tmp,Rsubband_buf[i]);/*Q21 */
+ R[i] = extract_h(L_shr(Rsubband_buf[i],5));/*Q0 */
+ }
+ t_fx = extract_h(L_shr(L_tmp, 5)); /*Q0 */
+
+ return (Word16)t_fx;
+
+}
diff --git a/lib_com/bitallocsum_fx.c b/lib_com/bitallocsum_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..cb8cf09a15ef902c3f9f7e38a78cbd7d3a36f164
--- /dev/null
+++ b/lib_com/bitallocsum_fx.c
@@ -0,0 +1,63 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* Common constants */
+
+/*--------------------------------------------------------------------------
+ * bitallocsum_fx()
+ *
+ * Calculate the total number of bits allocated over frame
+ *--------------------------------------------------------------------------*/
+void bitallocsum_fx(
+ Word16 *R, /* i : bit-allocation vector Q0 */
+ const Word16 nb_sfm, /* i : number of sub-vectors Q0 */
+ Word16 *sum, /* o : total number of bits allocated Q0 */
+ Word16 *Rsubband, /* o : rate per subband Q3 */
+ const Word16 v, /* i : bit rate Q0 */
+ const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */
+ const Word16 *sfmsize /* i : band length Q0 */
+)
+{
+ Word16 i;
+ Word16 total, tmp;
+ Word16 diff;
+
+ total = (Word16)0;
+ move16();
+ FOR (i = 0; i < nb_sfm; i++)
+ {
+ tmp = extract_l(L_mult0(R[i], sfmsize[i]));
+ Rsubband[i] = shl(tmp, 3);
+ move16();
+ total = add(total, tmp);
+ }
+ *sum = total;
+
+ IF ( LE_16(length, L_FRAME32k))
+ {
+ diff = sub(v, *sum);
+ i = (Word16)0;
+ move16();
+ WHILE ( diff > 0 )
+ {
+ IF ( R[i] > 0 )
+ {
+ Rsubband[i] = add(Rsubband[i], 8);
+ move16();
+ diff = sub(diff, 1);
+ *sum = add(*sum, 1);
+ }
+ i = add(i, 1);
+ if ( GE_16(i, nb_sfm))
+ {
+ i = (Word16)0;
+ move16();
+ }
+ }
+ }
+ return;
+}
diff --git a/lib_com/bits_alloc.c b/lib_com/bits_alloc.c
new file mode 100644
index 0000000000000000000000000000000000000000..69b71c6b49ee344f997da4b8af16d08268461463
--- /dev/null
+++ b/lib_com/bits_alloc.c
@@ -0,0 +1,384 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include "options.h"
+#include "prot_fx.h"
+#include "basop_util.h"
+#include "stl.h"
+#include "options.h"
+#include "rom_com_fx.h"
+
+
+/*
+ * function BITS_ALLOC_init_config_acelp()
+ *
+ * description: initial configuration for ACELP
+ *
+ * return: void
+ */
+void BITS_ALLOC_init_config_acelp(
+ const Word32 bit_rate,
+ const Word8 narrowBand,
+ const Word16 nb_subfr,
+ ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/
+)
+{
+ Word8 rate_mode_index;
+
+
+ move16();
+ move16();
+ move16();
+ rate_mode_index=(bit_rate > ACELP_9k60);
+
+ pConfigAcelp->mode_index=rate_mode_index;
+
+
+ /*LPC: midLpc should be swithced off?*/
+ pConfigAcelp->midLpc_enable = 1;
+ move16();
+
+ /*ACELP ICB config*/
+ test();
+ IF( (rate_mode_index==0) || narrowBand != 0 )
+ {
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ pConfigAcelp->pre_emphasis = 1;
+ pConfigAcelp->formant_enh = 1;
+ pConfigAcelp->formant_enh_num = FORMANT_SHARPENING_G1;
+ pConfigAcelp->formant_enh_den = FORMANT_SHARPENING_G2;
+ pConfigAcelp->formant_tilt = 0;
+ pConfigAcelp->voice_tilt = 0;
+ }
+ ELSE
+ {
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ pConfigAcelp->pre_emphasis = 0;
+ pConfigAcelp->formant_enh = 1;
+ pConfigAcelp->formant_enh_num = FORMANT_SHARPENING_G1;
+ pConfigAcelp->formant_enh_den = FORMANT_SHARPENING_G2;
+ pConfigAcelp->formant_tilt = 1;
+ pConfigAcelp->voice_tilt = 1;
+ }
+
+ /*Wide band @ 16kHz*/
+ IF ( EQ_16(nb_subfr,NB_SUBFR16k))
+ {
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ pConfigAcelp->pre_emphasis = 1;
+ pConfigAcelp->formant_enh = 1;
+ pConfigAcelp->formant_enh_num = FORMANT_SHARPENING_G1_16k;
+ pConfigAcelp->formant_enh_den = FORMANT_SHARPENING_G2_16k;
+ pConfigAcelp->formant_tilt = 0;
+ pConfigAcelp->voice_tilt = 2;
+ }
+
+}
+
+
+/*
+ * function BITS_ALLOC_config_acelp()
+ *
+ * description: configure all acelp modes and allocate the bits
+ *
+ * return: bit demand
+ */
+Word16 BITS_ALLOC_config_acelp(
+ const Word16 bits_frame, /*i: remaining bit budget for the frame*/
+ const Word16 coder_type, /*i: acelp coder type*/
+ ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/
+ const Word16 narrowBand,
+ const Word16 nb_subfr
+)
+{
+ Word16 mode_index;
+ Word16 band_index;
+ Word16 i;
+ Word16 remaining_bits, bits;
+
+
+
+ move16();
+ move16();
+ move16();
+ mode_index = pConfigAcelp->mode_index;
+ band_index = (narrowBand==0);
+ bits=0;
+
+ IF ( band_index==0 )
+ {
+ move16();
+ pConfigAcelp->formant_enh = 1;
+ if(EQ_16(coder_type,INACTIVE))
+ {
+ move16();
+ pConfigAcelp->formant_enh = 0;
+ }
+ }
+
+ IF ( s_and((Word16)EQ_16(band_index,1),(Word16)EQ_16(nb_subfr,4)))
+ {
+ IF(EQ_16(coder_type,INACTIVE))
+ {
+ pConfigAcelp->pre_emphasis = 0;
+ move16();
+ pConfigAcelp->formant_enh = 0;
+ move16();
+ pConfigAcelp->formant_enh_num = FORMANT_SHARPENING_G1_16k;
+ move16();
+ pConfigAcelp->voice_tilt = 1;
+ move16();
+ pConfigAcelp->formant_tilt = 1;
+ move16();
+ }
+ ELSE
+ {
+ pConfigAcelp->pre_emphasis = 1;
+ move16();
+ pConfigAcelp->formant_enh = 1;
+ move16();
+ pConfigAcelp->formant_enh_num = FORMANT_SHARPENING_G1;
+ move16();
+ pConfigAcelp->voice_tilt = 0;
+ move16();
+ pConfigAcelp->formant_tilt = 0;
+ move16();
+ }
+ }
+ IF (EQ_16(coder_type,UNVOICED))
+ {
+ IF(EQ_16(ACELP_GAINS_MODE[mode_index][band_index][coder_type], 6))
+ {
+ pConfigAcelp->pitch_sharpening = 0;
+ move16();
+ pConfigAcelp->phase_scrambling = 1;
+ move16();
+ }
+ ELSE
+ {
+ pConfigAcelp->pitch_sharpening = 0;
+ move16();
+ pConfigAcelp->phase_scrambling = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ pConfigAcelp->pitch_sharpening = 1;
+ move16();
+ pConfigAcelp->phase_scrambling = 0;
+ move16();
+ }
+
+ IF(GT_16(coder_type,ACELP_MODE_MAX)) /* keep pitch sharpening for RF_ALLPRED mode */
+ {
+ pConfigAcelp->pitch_sharpening = 0;
+ pConfigAcelp->phase_scrambling = 0;
+ }
+
+ /*Allocate bits and different modes*/
+ move16();
+ pConfigAcelp->bpf_mode=ACELP_BPF_MODE[mode_index][band_index][coder_type];
+ bits = add(bits, ACELP_BPF_BITS[pConfigAcelp->bpf_mode]);
+
+ move16();
+ move16();
+ pConfigAcelp->nrg_mode=ACELP_NRG_MODE[mode_index][band_index][coder_type];
+ pConfigAcelp->nrg_bits=ACELP_NRG_BITS[pConfigAcelp->nrg_mode];
+ bits = add(bits, pConfigAcelp->nrg_bits);
+
+ move16();
+ pConfigAcelp->ltp_mode=ACELP_LTP_MODE[mode_index][band_index][coder_type];
+
+ move16();
+ pConfigAcelp->ltp_bits=0;
+
+ move16();
+ pConfigAcelp->ltf_mode=ACELP_LTF_MODE[mode_index][band_index][coder_type];
+
+ move16();
+ pConfigAcelp->ltf_bits=ACELP_LTF_BITS[pConfigAcelp->ltf_mode];
+ if ( s_and((Word16)EQ_16(nb_subfr,5),(Word16)EQ_16(pConfigAcelp->ltf_bits,4)))
+ {
+ pConfigAcelp->ltf_bits = add(pConfigAcelp->ltf_bits,1);
+ }
+ bits = add(bits,pConfigAcelp->ltf_bits);
+
+
+ FOR ( i=0; igains_mode[i] = ACELP_GAINS_MODE[mode_index][band_index][coder_type];
+ move16();
+
+ /* skip subframe 1, 3 gain encoding, and use from subframe 0, and 3, respectively */
+ test();
+ test();
+ IF(GE_16(coder_type,ACELP_MODE_MAX)&&(EQ_16(i,1)||EQ_16(i,3)))
+ {
+ pConfigAcelp->gains_mode[i] = 0;
+ }
+
+ bits = add(bits, ACELP_GAINS_BITS[pConfigAcelp->gains_mode[i]]);
+
+ move16();
+ bits = add(bits, ACELP_LTP_BITS_SFR[pConfigAcelp->ltp_mode][i]);
+ pConfigAcelp->ltp_bits= add( pConfigAcelp->ltp_bits,ACELP_LTP_BITS_SFR[pConfigAcelp->ltp_mode][i]);
+ }
+
+ /*Innovation*/
+
+ if ( LT_16(bits_frame,bits))
+ {
+ printf("Warning: bits per frame too low\n");
+ return -1;
+ }
+
+ IF( EQ_16(coder_type,RF_ALLPRED))
+ {
+ set16_fx(pConfigAcelp->fixed_cdk_index, -1, nb_subfr);
+ }
+ ELSE IF ( EQ_16(coder_type,RF_GENPRED))
+ {
+ pConfigAcelp->fixed_cdk_index[0] = 0; /* 7 bits */
+ pConfigAcelp->fixed_cdk_index[1] = -1;
+ pConfigAcelp->fixed_cdk_index[2] = 0; /* 7 bits */
+ pConfigAcelp->fixed_cdk_index[3] = -1;
+ pConfigAcelp->fixed_cdk_index[4] = -1;
+ bits = add(bits,14);
+ }
+ ELSE IF( EQ_16(coder_type,RF_NOPRED))
+ {
+ set16_fx(pConfigAcelp->fixed_cdk_index, 0, nb_subfr);
+ bits = add(bits,28);
+ }
+ ELSE
+ {
+ bits = add(bits, BITS_ALLOC_adjust_acelp_fixed_cdk(sub(bits_frame,bits), pConfigAcelp->fixed_cdk_index, nb_subfr ));
+ }
+
+ remaining_bits = sub(bits_frame, bits);
+
+ /*Sanity check*/
+ if (remaining_bits<0)
+ {
+ move16();
+ bits = -1;
+ }
+
+
+ return(bits);
+}
+
+
+static
+Word16 BITS_ALLOC_adjust_generic(
+ const Word16 bits_frame, /*i: bit budget*/
+ Word16 *fixed_cdk_index,
+ const Word16 nb_subfr,
+ const Word16 *pulseconfigbits,
+ const Word16 pulseconfig_size
+)
+{
+ Word16 bits_subframe2, inb_subfr;
+ Word16 sfr, k, bitsused, bits_currsubframe;
+
+ bits_subframe2 = bits_frame;
+ move16();
+ inb_subfr = 8192/*1.0f/NB_SUBFR Q15*/;
+ move16();
+ if ( EQ_16(nb_subfr,NB_SUBFR16k))
+ {
+ inb_subfr = 6554/*1.0f/NB_SUBFR16k Q15*/;
+ move16();
+ }
+
+ IF ( LT_16(bits_subframe2, i_mult2(pulseconfigbits[0], nb_subfr))) /* not in final code - not instrumented */
+ {
+ return add(bits_frame,1); /* Not enough bits for lowest mode. -> trigger alarm*/
+ }
+
+ /* search cdk-index for first subframe */
+ FOR (k=0; k bits_subframe2)
+ {
+ k = sub(k,1); /* previous mode did not exceed bit-budget */
+ BREAK;
+ }
+ }
+
+ if (i_mult2(pulseconfigbits[k], nb_subfr) > bits_subframe2)
+ {
+ k = sub(k,1); /* previous mode did not exceed bit-budget */
+ }
+
+ move16();
+ fixed_cdk_index[0] = k;
+ bitsused = i_mult2(pulseconfigbits[k], nb_subfr);
+
+ FOR (sfr=1; sfr < nb_subfr; sfr++)
+ {
+ /*bits_currsubframe = (int)(((float)sfr+1.0f)*bits_subframe) - bitsused;*/
+ bits_currsubframe = sub(add(i_mult2(sfr, bits_subframe2), bits_subframe2), bitsused);
+
+ /* try increasing mode while below threshold */
+ WHILE ( (LT_16(k, pulseconfig_size-1))&&(LE_16(i_mult2(pulseconfigbits[add(k,1)],nb_subfr),bits_currsubframe)))
+ {
+ test();
+ k = add(k,1);
+ }
+
+ /* try decreasing mode until below threshold */
+ WHILE (i_mult2(pulseconfigbits[k], nb_subfr) > bits_currsubframe)
+ {
+ k = sub(k,1);
+
+ IF (k == 0)
+ {
+ BREAK;
+ }
+ }
+
+ /* store mode */
+ move16();
+ fixed_cdk_index[sfr] = k;
+ bitsused = add(bitsused, i_mult2(pulseconfigbits[k], nb_subfr));
+ }
+
+ return mult_r(bitsused, inb_subfr);
+}
+
+Word16 BITS_ALLOC_adjust_acelp_fixed_cdk(
+ const Word16 bits_frame, /*i: bit budget*/
+ Word16 *fixed_cdk_index,
+ const Word16 nb_subfr
+)
+{
+ Word16 bitsused;
+
+
+ bitsused = BITS_ALLOC_adjust_generic(bits_frame, fixed_cdk_index, nb_subfr, ACELP_CDK_BITS, ACELP_FIXED_CDK_NB);
+
+
+ return bitsused;
+}
+
diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..c734eb4ceac70c80e02ddcbe1a558e8068dc2fdb
--- /dev/null
+++ b/lib_com/bitstream_fx.c
@@ -0,0 +1,2589 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include "stl.h"
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "options.h"
+#include "basop_util.h"
+#include "rom_com_fx.h"
+#include "mime.h"
+#ifdef DEBUGGING
+ /*-------------------------------------------------------------------*
+ * Global variables
+ *--------------------------------------------------------------------*/
+
+int16_t FEC_seed = 12558; /* Seed for random FEC generator */
+float FEC_random = 0; /* FEC rate in percent (for simulation of FEC) */
+FILE* FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */
+/*-------------------------------------------------------------------*
+ * file_read_FECpattern()
+ *
+ * Simulate packet losses by reading FEC pattern from external file
+ *-------------------------------------------------------------------*/
+
+static int16_t file_read_FECpattern(void)
+{
+ int16_t bfi = 0;
+
+ /* FEC pattern file provided */
+ if (FEC_pattern != NULL)
+ {
+ int16_t tmp = 0;
+ if (fread(&tmp, sizeof(int16_t), 1, FEC_pattern) != 1)
+ {
+ if (feof(FEC_pattern) != 0)
+ {
+ tmp = 0;
+ fseek(FEC_pattern, 0L, SEEK_SET);
+ }
+ else
+ {
+ fprintf(stderr, "\nError reading the FEC pattern file !");
+ exit(-1);
+ }
+ }
+
+ if (tmp == 2609 || tmp == 1 || tmp == SYNC_BAD_FRAME)
+ {
+ bfi = 1;
+ }
+ else
+ {
+ bfi = 0;
+ }
+ }
+
+ /* random FEC simulation requested */
+ else if (FEC_random > 0)
+ {
+ float ftmp = (float)/*own_random*/Random(&FEC_seed) + 32768.0f;
+ if (ftmp <= FEC_random / 100.0f * 65535.0f)
+ {
+ bfi = 1;
+ }
+ else
+ {
+ bfi = 0;
+ }
+ }
+
+ return bfi;
+}
+#endif
+/*-------------------------------------------------------------------*
+* pack_bit()
+*
+* insert a bit into packed octet
+*-------------------------------------------------------------------*/
+static void pack_bit(
+ const Word16 bit, /* i: bit to be packed */
+ UWord8 **pt, /* i/o: pointer to octet array into which bit will be placed */
+ UWord8 *omask /* i/o: output mask to indicate where in the octet the bit is to be written */
+)
+{
+ if (*omask == 0x80)
+ {
+ **pt = 0;
+ }
+ if (bit != 0)
+ {
+ **pt = **pt | *omask;
+ }
+ *omask >>= 1;
+ if (*omask == 0)
+ {
+ *omask = 0x80;
+ (*pt)++;
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+* unpack_bit()
+*
+* unpack a bit from packed octet
+*-------------------------------------------------------------------*/
+static Word16 unpack_bit(
+ UWord8 **pt, /* i/o: pointer to octet array from which bit will be read */
+ UWord8 *mask /* i/o: mask to indicate the bit in the octet */
+)
+{
+ Word16 bit;
+
+ bit = (**pt & *mask) != 0;
+ *mask >>= 1;
+ if (*mask == 0)
+ {
+ *mask = 0x80;
+ (*pt)++;
+ }
+ return bit;
+}
+
+/*-------------------------------------------------------------------*
+* rate2AMRWB_IOmode()
+*
+* lookup AMRWB IO mode
+*-------------------------------------------------------------------*/
+static Word16 rate2AMRWB_IOmode(
+ Word32 rate /* i: bit rate */
+)
+{
+ switch ( rate )
+ {
+ /* EVS AMR-WB IO modes */
+ case SID_1k75 :
+ return AMRWB_IO_SID;
+ case ACELP_6k60 :
+ return AMRWB_IO_6600;
+ case ACELP_8k85 :
+ return AMRWB_IO_8850;
+ case ACELP_12k65 :
+ return AMRWB_IO_1265;
+ case ACELP_14k25 :
+ return AMRWB_IO_1425;
+ case ACELP_15k85 :
+ return AMRWB_IO_1585;
+ case ACELP_18k25 :
+ return AMRWB_IO_1825;
+ case ACELP_19k85 :
+ return AMRWB_IO_1985;
+ case ACELP_23k05 :
+ return AMRWB_IO_2305;
+ case ACELP_23k85 :
+ return AMRWB_IO_2385;
+ default:
+ return -1;
+ }
+}
+
+/*-------------------------------------------------------------------*
+* rate2EVSmode()
+*
+* lookup EVS mode
+*-------------------------------------------------------------------*/
+static Word16 rate2EVSmode(
+ Word32 rate /* i: bit rate */
+)
+{
+ switch ( rate )
+ {
+ /* EVS Primary modes */
+ case FRAME_NO_DATA :
+ return NO_DATA_TYPE;
+ case SID_2k40 :
+ return PRIMARY_SID;
+ case PPP_NELP_2k80 :
+ return PRIMARY_2800;
+ case ACELP_7k20 :
+ return PRIMARY_7200;
+ case ACELP_8k00 :
+ return PRIMARY_8000;
+ case ACELP_9k60 :
+ return PRIMARY_9600;
+ case ACELP_13k20 :
+ return PRIMARY_13200;
+ case ACELP_16k40 :
+ return PRIMARY_16400;
+ case ACELP_24k40 :
+ return PRIMARY_24400;
+ case ACELP_32k :
+ return PRIMARY_32000;
+ case ACELP_48k :
+ return PRIMARY_48000;
+ case ACELP_64k :
+ return PRIMARY_64000;
+ case HQ_96k :
+ return PRIMARY_96000;
+ case HQ_128k :
+ return PRIMARY_128000;
+ default :
+ return rate2AMRWB_IOmode(rate);
+ }
+}
+
+/*-------------------------------------------------------------------*
+ * push_indice_fx( )
+ *
+ * Push a new indice into the buffer
+ *-------------------------------------------------------------------*/
+
+void push_indice_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 id, /* i : ID of the indice */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+)
+{
+ Word16 i;
+
+
+ IF ( EQ_16(st_fx->last_ind_fx, id))
+ {
+ /* indice with the same name as the previous one */
+ i = st_fx->next_ind_fx;
+ }
+ ELSE
+ {
+ /* new indice - find an empty slot in the list */
+ i = id;
+ move16();
+ WHILE (NE_16(st_fx->ind_list_fx[i].nb_bits, -1))
+ {
+ i = add(i, 1);
+ }
+ }
+
+ /* store the values in the list */
+ st_fx->ind_list_fx[i].value = value;
+ move16();
+ st_fx->ind_list_fx[i].nb_bits = nb_bits;
+ move16();
+
+ /* updates */
+ st_fx->next_ind_fx = add(i, 1);
+ st_fx->last_ind_fx = id;
+ move16();
+ st_fx->nb_bits_tot_fx = add(st_fx->nb_bits_tot_fx, nb_bits);
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * push_next_indice_fx() *
+ * Push a new indice into the buffer at the next position
+ *-------------------------------------------------------------------*/
+
+void push_next_indice_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+)
+{
+
+ /* store the values in the list */
+ st_fx->ind_list_fx[st_fx->next_ind_fx].value = value;
+ move16();
+ st_fx->ind_list_fx[st_fx->next_ind_fx].nb_bits = nb_bits;
+ move16();
+ st_fx->next_ind_fx = add(st_fx->next_ind_fx, 1);
+
+
+ /* update the total number of bits already written */
+ st_fx->nb_bits_tot_fx = add(st_fx->nb_bits_tot_fx, nb_bits);
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * push_next_bits_fx()
+ * Push a bit buffer into the buffer at the next position
+ *-------------------------------------------------------------------*/
+
+void push_next_bits_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 bits[], /* i : bit buffer to pack, sequence of single bits */
+ Word16 nb_bits /* i : number of bits to pack */
+)
+{
+ UWord16 code;
+ Word16 i, nb_bits_m15;
+ Indice_fx *ptr;
+
+ ptr = &st_fx->ind_list_fx[st_fx->next_ind_fx];
+ nb_bits_m15 = sub(nb_bits, 15);
+ i = 0;
+ move16();
+ IF (nb_bits_m15 > 0)
+ {
+ FOR (; ivalue = code;
+ move16();
+ ptr->nb_bits = 16;
+ move16();
+ ++ptr;
+ }
+ }
+ IF (LT_16(i, nb_bits))
+ {
+ FOR (; ivalue = bits[i];
+ move16();
+ ptr->nb_bits = 1;
+ move16();
+ ++ptr;
+ }
+ }
+ st_fx->next_ind_fx = (Word16)(ptr - st_fx->ind_list_fx);
+ st_fx->nb_bits_tot_fx = add(st_fx->nb_bits_tot_fx, nb_bits);
+}
+
+/*-------------------------------------------------------------------*
+ * get_next_indice_fx( )
+ *
+ * Get the next indice from the buffer
+ *-------------------------------------------------------------------*/
+
+UWord16 get_next_indice_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
+)
+{
+ UWord16 value;
+ Word16 i;
+
+ assert(nb_bits <= 16);
+ value = 0;
+ move16();
+
+ /* detect corrupted bitstream */
+ IF( GT_16(add(st_fx->next_bit_pos_fx,nb_bits),st_fx->total_num_bits))
+ {
+ st_fx->BER_detect = 1;
+ move16();
+ return(0);
+ }
+
+ FOR (i = 0; i < nb_bits; i++)
+ {
+ value = lshl(value, 1);
+ value = add(value, st_fx->bit_stream_fx[st_fx->next_bit_pos_fx+i]);
+ }
+
+ /* update the position in the bitstream */
+ st_fx->next_bit_pos_fx = add(st_fx->next_bit_pos_fx, nb_bits);
+ return value;
+}
+
+/*-------------------------------------------------------------------*
+ * get_next_indice_1_fx( )
+ *
+ * Get the next 1-bit indice from the buffer
+ *-------------------------------------------------------------------*/
+
+UWord16 get_next_indice_1_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+)
+{
+ /* detect corrupted bitstream */
+ test();
+ test();
+ test();
+ IF( ( GT_16(add(st_fx->next_bit_pos_fx,1),st_fx->total_num_bits)&&EQ_16(st_fx->codec_mode,MODE1))||
+ ( GT_16(add(st_fx->next_bit_pos_fx,1),add(st_fx->total_num_bits,2*8)) && EQ_16(st_fx->codec_mode,MODE2)) /* add two zero bytes for arithmetic coder flush */
+ )
+ {
+ st_fx->BER_detect = 1;
+ move16();
+ return(0);
+ }
+
+ return st_fx->bit_stream_fx[st_fx->next_bit_pos_fx++];
+}
+
+/*-------------------------------------------------------------------*
+ * get_next_indice_tmp()
+ *
+ * update the total number of bits and the position in the bitstream
+ *-------------------------------------------------------------------*/
+
+void get_next_indice_tmp_fx(
+ Decoder_State_fx *st_fx, /* o : decoder state structure */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
+)
+{
+ /* update the position in the bitstream */
+ st_fx->next_bit_pos_fx = add(st_fx->next_bit_pos_fx, nb_bits);
+}
+
+/*-------------------------------------------------------------------*
+ * get_indice_fx( )
+ *
+ * Get indice at specific position in the buffer
+ *-------------------------------------------------------------------*/
+
+UWord16 get_indice_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 pos, /* i : absolute position in the bitstream (update after the read) */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
+)
+{
+ UWord16 value;
+ Word16 i;
+
+ assert(nb_bits <= 16);
+
+ /* detect corrupted bitstream */
+ IF( GT_16(add(pos,nb_bits),st_fx->total_num_bits))
+ {
+ st_fx->BER_detect = 1;
+ move16();
+ return(0);
+ }
+
+ value = 0;
+ move16();
+ FOR (i = 0; i < nb_bits; i++)
+ {
+ value = lshl(value, 1);
+ value = add(value, st_fx->bit_stream_fx[pos+i]);
+ }
+
+ return value;
+}
+
+/*-------------------------------------------------------------------*
+ * get_indice_1_fx( )
+ *
+ * Get a 1-bit indice at specific position in the buffer
+ *-------------------------------------------------------------------*/
+
+UWord16 get_indice_1_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 pos /* i : absolute position in the bitstream (update after the read) */
+)
+{
+ /* detect corrupted bitstream */
+ IF( GT_16(add(pos,1),st_fx->total_num_bits))
+ {
+ st_fx->BER_detect = 1;
+ move16();
+ return(0);
+ }
+
+ return st_fx->bit_stream_fx[pos];
+}
+
+/*-------------------------------------------------------------------*
+ * reset_indices_enc_fx()
+ *
+ * Reset the buffer of indices
+ *-------------------------------------------------------------------*/
+
+void reset_indices_enc_fx(
+ Encoder_State_fx *st_fx
+)
+{
+ Word16 i;
+
+ st_fx->nb_bits_tot_fx = 0;
+ move16();
+ st_fx->next_ind_fx = 0;
+ move16();
+ st_fx->last_ind_fx = -1;
+ move16();
+
+ FOR (i=0; iind_list_fx[i].nb_bits = -1;
+ move16();
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * reset_indices_dec_fx()
+ *
+ * Reset the buffer of decoder indices
+ *-------------------------------------------------------------------*/
+
+void reset_indices_dec_fx(
+ Decoder_State_fx *st_fx
+)
+{
+ st_fx->next_bit_pos_fx = 0;
+ move16();
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * write_indices_fx()
+ *
+ * Write the buffer of indices to a file
+ *-------------------------------------------------------------------*/
+
+void write_indices_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ FILE *file /* i : output bitstream file */
+ , UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */
+ Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */
+)
+{
+ Word16 i, k;
+ Word16 stream[2+MAX_BITS_PER_FRAME], *pt_stream;
+ Word32 mask;
+ UWord8 header;
+
+ if( st_fx->bitstreamformat == G192 )
+ {
+ /*-----------------------------------------------------------------*
+ * Encode Sync Header and Frame Length
+ *-----------------------------------------------------------------*/
+ pt_stream = stream;
+ for (i=0; i<(2 + MAX_BITS_PER_FRAME); ++i)
+ {
+ stream[i] = 0;
+ }
+ *pt_stream++ = (Word16)SYNC_GOOD_FRAME;
+ *pt_stream++ = st_fx->nb_bits_tot_fx;
+
+ /*----------------------------------------------------------------*
+ * Bitstream packing (conversion of individual indices into a serial stream)
+ * Writing the serial stream into file
+ *----------------------------------------------------------------*/
+
+ for (i=0; iind_list_fx[i].nb_bits != -1)
+ {
+ /* mask from MSB to LSB */
+ mask = 1 << (st_fx->ind_list_fx[i].nb_bits - 1);
+
+ /* write bit by bit */
+ for (k=0; k < st_fx->ind_list_fx[i].nb_bits; k++)
+ {
+ if ( st_fx->ind_list_fx[i].value & mask )
+ {
+ *pt_stream++ = G192_BIN1;
+ }
+ else
+ {
+ *pt_stream++ = G192_BIN0;
+ }
+
+ mask >>= 1;
+ }
+ }
+ }
+
+ }
+ else
+ {
+ /* Create and write ToC header */
+ /* qbit always set to 1 on encoder side for AMRWBIO , no qbit in use for EVS, but set to 0(bad) */
+ header = (UWord8)(st_fx->Opt_AMR_WB_fx << 5 | st_fx->Opt_AMR_WB_fx << 4 | rate2EVSmode(st_fx->nb_bits_tot_fx * 50));
+ fwrite( &header, sizeof(UWord8), 1, file );
+ /* Write speech bits */
+ fwrite( pFrame, sizeof(UWord8), (pFrame_size + 7)>>3, file );
+ }
+
+ /* Clearing of indices */
+ FOR (i=0; iind_list_fx[i].nb_bits = -1;
+ move16();
+ }
+
+
+ if( st_fx->bitstreamformat == G192 )
+ {
+ /* write the serial stream into file */
+ fwrite( stream, sizeof(unsigned short), 2+stream[1], file );
+ }
+ /* reset index pointers */
+ st_fx->nb_bits_tot_fx = 0;
+ st_fx->next_ind_fx = 0;
+ st_fx->last_ind_fx = -1;
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * indices_to_serial()
+ *
+ * pack indices into serialized payload format
+ *-------------------------------------------------------------------*/
+
+void indices_to_serial(
+ const Encoder_State_fx *st_fx, /* i: encoder state structure */
+ UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */
+ Word16 *pFrame_size /* o: size of the binary encoded access unit [bits] */
+)
+{
+ Word16 i, k, j;
+ Word16 cmi = 0, core_mode=0;
+ Word32 mask;
+ Word16 amrwb_bits[(ACELP_23k85 / 50)];
+ UWord8 omask= 0x80;
+ UWord8 *pt_pFrame=pFrame;
+
+ if ( st_fx->Opt_AMR_WB_fx )
+ {
+ cmi = rate2EVSmode(st_fx->total_brate_fx);
+ core_mode = rate2EVSmode(st_fx->nb_bits_tot_fx * 50);
+
+ j=0;
+ for (i=0; iind_list_fx[i].nb_bits != -1)
+ {
+ /* mask from MSB to LSB */
+ mask = 1 << (st_fx->ind_list_fx[i].nb_bits - 1);
+
+ /* temporarily save bit */
+ for (k=0; k < st_fx->ind_list_fx[i].nb_bits; k++)
+ {
+ amrwb_bits[j++] = (st_fx->ind_list_fx[i].value & mask) > 0;
+ mask >>= 1;
+ }
+ }
+ }
+ }
+
+ *pFrame_size = st_fx->nb_bits_tot_fx;
+
+ /*----------------------------------------------------------------*
+ * Bitstream packing (conversion of individual indices into a serial stream)
+ *----------------------------------------------------------------*/
+ j=0;
+ for (i=0; iind_list_fx[i].nb_bits != -1)
+ {
+ /* mask from MSB to LSB */
+ mask = 1 << (st_fx->ind_list_fx[i].nb_bits - 1);
+
+ /* write bit by bit */
+ for (k=0; k < st_fx->ind_list_fx[i].nb_bits; k++)
+ {
+ if (st_fx->Opt_AMR_WB_fx )
+ {
+ pack_bit(amrwb_bits[sort_ptr[core_mode][j++]], &pt_pFrame, &omask);
+ }
+ else
+ {
+ pack_bit(st_fx->ind_list_fx[i].value & mask, &pt_pFrame, &omask);
+ j++;
+ }
+ mask >>= 1;
+ }
+ }
+ }
+
+ if ( st_fx->Opt_AMR_WB_fx && core_mode == AMRWB_IO_SID) /* SID UPD frame always written now .... */
+ {
+ /* insert STI bit and CMI */
+ pack_bit(1, &pt_pFrame, &omask);
+ for (mask=0x08; mask>0; mask >>= 1)
+ {
+ pack_bit(cmi & mask, &pt_pFrame, &omask);
+ }
+ }
+}
+
+
+/*-------------------------------------------------------------------*
+ * indices_to_serial_generic()
+ *
+ * pack indices into serialized payload format
+ *-------------------------------------------------------------------*/
+
+void indices_to_serial_generic(
+ const Indice_fx *ind_list, /* i: indices list */
+ const Word16 num_indices, /* i: number of indices to write */
+ UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */
+ Word16 *pFrame_size /* i/o: number of bits in the binary encoded access unit [bits] */
+)
+{
+ Word16 i, k, j;
+ Word32 mask;
+ UWord8 omask;
+ UWord8 *pt_pFrame = pFrame;
+ Word16 nb_bits_tot;
+
+ nb_bits_tot = 0;
+ move16();
+ omask = (0x80 >> (*pFrame_size & 0x7));
+ pt_pFrame += shr(*pFrame_size, 3);
+
+ /*----------------------------------------------------------------*
+ * Bitstream packing (conversion of individual indices into a serial stream)
+ *----------------------------------------------------------------*/
+ j=0;
+ move16();
+ for (i=0; i>= 1;
+ }
+ nb_bits_tot = add(nb_bits_tot, ind_list[i].nb_bits);
+ }
+ }
+
+ *pFrame_size = add(*pFrame_size, nb_bits_tot);
+
+ return;
+}
+
+
+static void decoder_selectCodec(
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ const Word32 total_brate, /* i : total bitrate */
+ const Word16 bit0
+)
+{
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ /* check if we are in AMR-WB IO mode */
+ IF( EQ_32(total_brate, SID_1k75)||
+ EQ_32(total_brate, ACELP_6k60) || EQ_32(total_brate, ACELP_8k85) || EQ_32(total_brate, ACELP_12k65) ||
+ EQ_32(total_brate, ACELP_14k25) || EQ_32(total_brate, ACELP_15k85) || EQ_32(total_brate, ACELP_18k25) ||
+ EQ_32(total_brate, ACELP_19k85) || EQ_32(total_brate, ACELP_23k05) || EQ_32(total_brate, ACELP_23k85) )
+ {
+ st->Opt_AMR_WB_fx = 1;
+ move16();
+ }
+ ELSE IF ( NE_32(total_brate, FRAME_NO_DATA))
+ {
+ st->Opt_AMR_WB_fx = 0;
+ move16();
+ }
+
+ /* select MODE1 or MODE2 */
+ IF (st->Opt_AMR_WB_fx)
+ {
+ st->codec_mode = MODE1;
+ move16();/**/
+ }
+ ELSE
+ {
+ SWITCH ( total_brate )
+ {
+ case 0:
+ st->codec_mode = st->last_codec_mode;
+ move16();
+ BREAK;
+ case 2400:
+ st->codec_mode = st->last_codec_mode;
+ move16();
+ BREAK;
+ case 2800:
+ st->codec_mode = MODE1;
+ move16();
+ BREAK;
+ case 7200:
+ st->codec_mode = MODE1;
+ move16();
+ BREAK;
+ case 8000:
+ st->codec_mode = MODE1;
+ move16();
+ BREAK;
+ case 9600:
+ st->codec_mode = MODE2;
+ move16();
+ BREAK;
+ case 13200:
+ st->codec_mode = MODE1;
+ move16();
+ BREAK;
+ case 16400:
+ st->codec_mode = MODE2;
+ move16();
+ BREAK;
+ case 24400:
+ st->codec_mode = MODE2;
+ move16();
+ BREAK;
+ case 32000:
+ st->codec_mode = MODE1;
+ move16();
+ BREAK;
+ case 48000:
+ st->codec_mode = MODE2;
+ move16();
+ BREAK;
+ case 64000:
+ st->codec_mode = MODE1;
+ move16();
+ BREAK;
+ case 96000:
+ st->codec_mode = MODE2;
+ move16();
+ BREAK;
+ case 128000:
+ st->codec_mode = MODE2;
+ move16();
+ BREAK;
+ default :
+ /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */
+ st->codec_mode = st->last_codec_mode;
+ st->bfi_fx = 1;
+ move16();
+ move16();
+ BREAK;
+ }
+ }
+
+ IF ( st->ini_frame_fx == 0 )
+ {
+ IF(EQ_16(st->codec_mode,-1))
+ {
+ st->codec_mode = MODE1;
+ move16();
+ }
+ st->last_codec_mode = st->codec_mode;
+ move16();
+ }
+
+ /* set SID/CNG type */
+ IF ( EQ_32(total_brate,SID_2k40))
+ {
+ IF ( bit0 == G192_BIN0 )
+ {
+ st->cng_type_fx = LP_CNG;
+ move16();
+
+ /* force MODE1 when selecting LP_CNG */
+ st->codec_mode = MODE1;
+ move16();
+ }
+ ELSE
+ {
+ st->cng_type_fx = FD_CNG;
+ test();
+ if ( EQ_16(st->last_codec_mode, MODE2)&&EQ_32(st->last_total_brate_fx,13200))
+ {
+ st->codec_mode = MODE1;
+ move16();
+ }
+ }
+ st->last_cng_type_fx = st->cng_type_fx; /* CNG type switching at the first correctly received SID frame */
+ }
+
+
+ return;
+}
+
+
+
+
+void dec_prm_core(Decoder_State_fx *st)
+{
+ Word16 n, frame_size_index, num_bits;
+ UWord16 lsb;
+ Word32 L_tmp;
+
+ frame_size_index = -1;
+ move16();
+ st->core_fx = -1;
+ move16();
+
+ IF (EQ_32(st->total_brate_fx, FRAME_NO_DATA))
+ {
+ st->m_frame_type = ZERO_FRAME;
+ move16();
+ }
+ ELSE IF (EQ_32(st->total_brate_fx, SID_2k40))
+ {
+ st->m_frame_type = SID_FRAME;
+ move16();
+ }
+ ELSE
+ {
+ st->m_frame_type = ACTIVE_FRAME;
+ move16();
+ Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */
+ num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */
+ assert(num_bits == st->total_brate_fx/50);
+ FOR (n=0; nbwidth_fx = get_next_indice_fx(st, FrameSizeConfig[frame_size_index].bandwidth_bits);
+
+ st->bwidth_fx = add(st->bwidth_fx, FrameSizeConfig[frame_size_index].bandwidth_min);
+
+ if (GT_16(st->bwidth_fx, FB))
+ {
+ st->bwidth_fx = FB;
+ move16();
+ st->BER_detect = 1;
+ move16();
+ }
+
+ if (GT_16(st->bwidth_fx, SWB)&<_32(st->total_brate_fx,ACELP_16k40))
+ {
+ st->bwidth_fx = SWB;
+ move16();
+ st->BER_detect = 1;
+ move16();
+ }
+
+ /* Skip reserved bit */
+ get_next_indice_tmp_fx(st, FrameSizeConfig[frame_size_index].reserved_bits);
+
+ IF (get_next_indice_1_fx(st) != 0) /* TCX */
+ {
+ st->core_fx = TCX_20_CORE;
+ move16();
+ if (get_next_indice_1_fx(st) != 0)
+ {
+ st->core_fx = HQ_CORE;
+ move16();
+ }
+ }
+ ELSE /* ACELP */
+ {
+ st->core_fx = ACELP_CORE;
+ move16();
+ }
+ }
+}
+
+/*-----------------------------------------------------------------*
+ * decision_matrix_core_dec()
+ *
+ * Read core mode signalling bits from the bitstream
+ * Set st->core, and st->bwidth if signalled together with the core.
+ *-----------------------------------------------------------------*/
+
+void decision_matrix_core_dec(
+ Decoder_State_fx *st /* i/o: decoder state structure */
+)
+{
+ Word16 start_idx;
+ Word32 ind;
+ Word16 nBits;
+
+ assert(st->bfi_fx != 1);
+
+ st->core_fx = -1;
+ move16();
+ st->bwidth_fx = -1;
+ move16();
+
+ test();
+ IF ( EQ_32(st->total_brate_fx, FRAME_NO_DATA)||EQ_32(st->total_brate_fx,SID_2k40))
+ {
+ st->core_fx = ACELP_CORE;
+ move16();
+ }
+ /* SC-VBR */
+ ELSE IF ( st->total_brate_fx == PPP_NELP_2k80 )
+ {
+ st->core_fx = ACELP_CORE;
+ move16();
+ return;
+ }
+
+ /*---------------------------------------------------------------------*
+ * ACELP/HQ core selection
+ *---------------------------------------------------------------------*/
+
+ test();
+ IF ( LT_32(st->total_brate_fx, ACELP_24k40))
+ {
+ st->core_fx = ACELP_CORE;
+ move16();
+ }
+ ELSE IF ( GE_32(st->total_brate_fx, ACELP_24k40)&&LE_32(st->total_brate_fx,ACELP_64k))
+ {
+ /* read the ACELP/HQ core selection bit */
+ st->core_fx = imult1616(get_next_indice_fx( st, 1 ), HQ_CORE);
+ }
+ ELSE
+ {
+ st->core_fx = HQ_CORE;
+ move16();
+ }
+
+ /*-----------------------------------------------------------------*
+ * Read ACELP signalling bits from the bitstream
+ *-----------------------------------------------------------------*/
+
+ IF ( EQ_16(st->core_fx, ACELP_CORE))
+ {
+ /* find the section in the ACELP signalling table corresponding to bitrate */
+ start_idx = 0;
+ move16();
+ WHILE ( NE_32(acelp_sig_tbl[start_idx], st->total_brate_fx))
+ {
+ start_idx = add(start_idx, 1);
+ }
+
+ /* skip the bitrate */
+ start_idx = add(start_idx, 1);
+
+ /* retrieve the number of bits */
+ nBits = extract_l(acelp_sig_tbl[start_idx]);
+ start_idx = add(start_idx, 1);
+
+ /* retrieve the signalling indice */
+ ind = acelp_sig_tbl[add(start_idx, get_next_indice_fx( st, nBits ))];
+ st->bwidth_fx = extract_l(L_and(L_shr(ind, 3), 0x7));
+
+ /* convert signalling indice into signalling information */
+ if ( EQ_32(L_and(ind, 0x7), LR_MDCT))
+ {
+ st->core_fx = HQ_CORE;
+ move16();
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Read HQ signalling bits from the bitstream
+ * Set HQ core type
+ *-----------------------------------------------------------------*/
+
+ IF ( EQ_16(st->core_fx, HQ_CORE))
+ {
+ /* read the HQ/TCX core switching flag */
+ if ( get_next_indice_fx( st, 1 ) != 0 )
+ {
+ st->core_fx = TCX_20_CORE;
+ move16();
+ }
+
+ /* For TCX: read/set band-width (needed for different I/O sampling rate support) */
+ test();
+ IF( EQ_16(st->core_fx, TCX_20_CORE)&>_32(st->total_brate_fx,ACELP_16k40))
+ {
+ ind = get_next_indice_fx( st, 2 );
+
+ IF( ind == 0 )
+ {
+ st->bwidth_fx = NB;
+ move16();
+ }
+ ELSE IF( EQ_32(ind, 1))
+ {
+ st->bwidth_fx = WB;
+ move16();
+ }
+ ELSE IF( EQ_32(ind, 2))
+ {
+ st->bwidth_fx = SWB;
+ move16();
+ }
+ ELSE
+ {
+ st->bwidth_fx = FB;
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * mdct_switching_dec()
+ *
+ * Set up MDCT core switching if indicated in the bit stream
+ *-------------------------------------------------------------------*/
+
+static void mdct_switching_dec(
+ Decoder_State_fx *st /* i/o: decoder state structure */
+)
+{
+ IF (st->Opt_AMR_WB_fx != 0)
+ {
+ return;
+ }
+
+ test();
+ test();
+ IF (EQ_32(st->total_brate_fx, ACELP_13k20)||EQ_32(st->total_brate_fx,ACELP_32k))
+ {
+ st->mdct_sw_enable = MODE1;
+ move16();
+ }
+ ELSE IF (LE_32(ACELP_16k40, st->total_brate_fx)&&LE_32(st->total_brate_fx,ACELP_24k40))
+ {
+ st->mdct_sw_enable = MODE2;
+ move16();
+ }
+
+ test();
+ test();
+ IF ( EQ_16(st->codec_mode, MODE1)&&EQ_16(st->mdct_sw_enable,MODE1))
+ {
+ /* Read ahead core mode signaling */
+ Word16 next_bit_pos_save;
+ Word16 core_save;
+ Word16 bwidth_save;
+
+ next_bit_pos_save = st->next_bit_pos_fx;
+ move16();
+ core_save = st->core_fx;
+ move16();
+ bwidth_save = st->bwidth_fx;
+ move16();
+
+ decision_matrix_core_dec(st); /* sets st->core */
+
+ IF (EQ_16(st->core_fx, TCX_20_CORE))
+ {
+ /* Trigger TCX */
+ st->codec_mode = MODE2;
+ move16();
+ st->mdct_sw = MODE1;
+ move16();
+ }
+ ELSE
+ {
+ /* Rewind bitstream */
+ st->next_bit_pos_fx = next_bit_pos_save;
+ move16();
+ IF (st->bfi_fx != 0)
+ {
+ st->core_fx = core_save;
+ move16();
+ st->bwidth_fx = bwidth_save;
+ move16();
+ }
+ }
+ }
+ ELSE IF (EQ_16(st->codec_mode, MODE2)&&EQ_16(st->mdct_sw_enable,MODE2))
+ {
+ /* Read ahead core mode signaling */
+ Word16 next_bit_pos_save;
+ Word16 core_save;
+ Word16 bwidth_save;
+
+ next_bit_pos_save = st->next_bit_pos_fx;
+ move16();
+ core_save = st->core_fx;
+ move16();
+ bwidth_save = st->bwidth_fx;
+ move16();
+
+ dec_prm_core(st); /* sets st->core */
+
+ IF (EQ_16(st->core_fx, HQ_CORE))
+ {
+ /* Trigger HQ_CORE */
+ st->codec_mode = MODE1;
+ move16();
+ st->mdct_sw = MODE2;
+ move16();
+ }
+ ELSE
+ {
+ /* Rewind bitstream */
+ st->next_bit_pos_fx = next_bit_pos_save;
+ move16();
+ IF (st->bfi_fx != 0)
+ {
+ st->core_fx = core_save;
+ move16();
+ }
+ /* always reset bwidth, to not interfere with BER logic */
+ st->bwidth_fx = bwidth_save;
+ move16();
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*
+ * BRATE2IDX_fx()
+ *
+ * Convert Bitrate to Index Value
+ *-------------------------------------------------------------------*/
+
+Word16 BRATE2IDX_fx(Word32 brate)
+{
+ Word32 L_temp;
+ Word32 L_idx;
+#define START 9
+ extern const Word16 bit_rates_div50[];
+
+ /* This is a Fast Bit Rate Value to Index Value Binary Search */
+ L_temp = L_msu0(brate, bit_rates_div50[START], 50);
+ L_temp = L_min(6, L_max(-6, L_temp));
+ L_idx = L_add(L_temp, START);
+ L_temp = L_msu0(brate, bit_rates_div50[L_idx], 50);
+ L_temp = L_min(3, L_max(-3, L_temp));
+ L_idx = L_add(L_temp, L_idx);
+ L_temp = L_msu0(brate, bit_rates_div50[L_idx], 50);
+ L_temp = L_min(1, L_max(-2, L_temp));
+ L_idx = L_add(L_temp, L_idx);
+ L_temp = L_msu0(brate, bit_rates_div50[L_idx], 50);
+ if (L_temp != 0) L_idx = L_add(L_idx, 1);
+ return (Word16)L_idx;
+}
+
+
+/*-------------------------------------------------------------------*
+ * BRATE2IDX16k_fx()
+ *
+ * Convert Bitrate to Index Value
+ *-------------------------------------------------------------------*/
+
+Word16 BRATE2IDX16k_fx(Word32 brate)
+{
+ Word32 L_temp, L_idx;
+#define START_16K 5
+ extern const Word16 bit_rates_16k_div50[];
+
+ if(EQ_32(brate,ACELP_16k40))
+ {
+ brate=ACELP_14k80;
+ }
+
+ /* This is a Fast Bit Rate Value to Index Value Binary Search */
+ L_temp = L_msu0(brate, bit_rates_16k_div50[START_16K], 50);
+ L_temp = L_min(3, L_max(-3, L_temp));
+ L_idx = L_add(L_temp, START_16K);
+ L_temp = L_msu0(brate, bit_rates_16k_div50[L_idx], 50);
+ L_temp = L_min(2, L_max(-2, L_temp));
+ L_idx = L_add(L_temp, L_idx);
+ L_temp = L_msu0(brate, bit_rates_16k_div50[L_idx], 50);
+ L_temp = L_min(1, L_max(-1, L_temp));
+ L_idx = L_add(L_temp, L_idx);
+
+ return (Word16)L_idx;
+}
+
+/*-------------------------------------------------------------------*
+ * BIT_ALLOC_IDX_fx()
+ *-------------------------------------------------------------------*/
+
+Word32 BIT_ALLOC_IDX_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc)
+{
+ Word32 L_temp;
+ Word16 temp;
+ if (ctype == INACTIVE) /* no sub(ctype, INACTIVE) because it is '0' */
+ ctype = GENERIC;
+ move16();
+ L_temp = L_mac0(-1l*256, 1*256, ctype);
+
+ temp = BRATE2IDX_fx(brate);
+ L_temp = L_mac0(L_temp, 4*256, temp);
+ if (tc >= 0)
+ L_temp = L_mac0(L_temp, (10-4)*256, temp);
+ /* So either 'temp' x 4 when 'tc < 0', 'temp' x 10 otherwise */
+
+ L_temp = L_mac0(L_temp, 1*256, s_max(0, tc));
+
+ L_temp = L_mac0(L_temp, s_max(0, sfrm), 1);
+ if (sfrm < 0)
+ L_temp = L_shr(L_temp, 2);
+ L_temp = L_shr(L_temp, 6);
+
+ return L_temp;
+}
+
+/*-------------------------------------------------------------------*
+ * BIT_ALLOC_IDX_16KHZ_fx()
+ *-------------------------------------------------------------------*/
+
+Word32 BIT_ALLOC_IDX_16KHZ_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc)
+{
+ Word32 L_temp;
+ Word16 temp;
+ /* 'ctype' =
+ TRANSITION => 2
+ GENERIC => 1
+ ALL Other => 0
+ */
+ L_temp = L_and(shr(0x0240l, shl(ctype, 1)), 3);
+
+ temp = BRATE2IDX16k_fx(brate);
+ L_temp = L_mac0(L_temp, 3, temp);
+ if (tc >= 0)
+ L_temp = L_mac0(L_temp, (7-3), temp);
+ /* So either 'temp' x 3 when 'tc < 0', 'temp' x 7 otherwise */
+
+ L_temp = L_mac0(L_temp, 1, s_max(0, tc));
+
+ IF (sfrm >= 0)
+ {
+ /* Mult by 5 */
+ L_temp = L_add(L_temp, L_shl(L_temp, 2));
+ L_temp = L_mac0(L_temp, shr(sfrm, 6), 1);
+ }
+
+ return L_temp;
+}
+
+
+/*-------------------------------------------------------------------*
+ * read_indices_fx()
+ *
+ * Read indices from an ITU-T G.192 bitstream to the buffer
+ * Simulate packet losses by inserting frame erasures
+ *-------------------------------------------------------------------*/
+
+Word16 read_indices_fx( /* o : 1 = reading OK, 0 = problem */
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ FILE *file, /* i : bitstream file */
+ Word16 rew_flag /* i : rewind flag (rewind file after reading)*/
+)
+{
+ Word16 k;
+ UWord16 utmp, stream[2+MAX_BITS_PER_FRAME], *pt_stream, *bit_stream_ptr;
+ Word16 num_bits;
+ Word32 total_brate;
+ Word32 L_tmp;
+ Word16 curr_ft_good_sp, curr_ft_bad_sp;
+ Word16 g192_sid_first,sid_upd_bad, sid_update;
+ Word16 speech_bad, speech_lost;
+ Word16 num_bits_read;
+
+ st->bfi_fx = 0;
+ st->BER_detect = 0;
+ st->mdct_sw_enable = 0;
+ st->mdct_sw = 0;
+ reset_indices_dec_fx( st );
+
+ /* read the Sync Header field from the bitstream */
+ /* in case rew_flag is set, read until first good frame is encountered */
+ do
+ {
+ /* read the Sync header */
+ if ( fread( &utmp, sizeof(unsigned short), 1, file ) != 1 )
+ {
+ if( ferror( file ) )
+ {
+ /* error during reading */
+ fprintf(stderr, "\nError reading the bitstream !");
+ exit(-1);
+ }
+ else
+ {
+ /* end of file reached */
+ return 0;
+ }
+ }
+
+ /* set the BFI indicator according the value of Sync Header */
+ if ( EQ_16(utmp, SYNC_BAD_FRAME))
+ {
+ st->bfi_fx = 1;
+ }
+
+
+ else
+ {
+ st->bfi_fx = 0;
+ }
+
+ /* read the Frame Length field from the bitstream */
+ if ( fread( &num_bits, sizeof(unsigned short), 1, file ) != 1 )
+ {
+ if( ferror( file ) )
+ {
+ /* error during reading */
+ fprintf(stderr, "\nError reading the bitstream !");
+ exit(-1);
+ }
+ else
+ {
+ /* end of file reached */
+ return 0;
+ }
+ }
+ /* convert the frame length to total bitrate */
+ total_brate = (long)(num_bits* 50);
+
+ /* read ITU-T G.192 serial stream of indices from file to the local buffer */
+ /* Validate that the G.192 length is within the defined bit rate range
+ to not allow writing past the end of the "stream" buffer */
+ if( num_bits > MAX_BITS_PER_FRAME )
+ {
+ fprintf(stderr, "\nError, too large G.192 frame (size(%d))! Exiting ! \n", num_bits);
+ exit(-1);
+ }
+
+ /* verify that a valid num bits value is present in the G.192 file */
+ /* only AMRWB or EVS bit rates or 0(NO DATA) are allowed in G.192 file frame reading */
+ if( rate2EVSmode(total_brate) < 0 ) /* negative value means that a valid rate was not found */
+ {
+ fprintf(stderr, "\nError, illegal bit rate (%d) in the G.192 frame ! Exiting ! \n", total_brate);
+ exit(-1);
+ }
+ pt_stream = stream;
+
+ num_bits_read = (Word16) fread( pt_stream, sizeof(unsigned short), num_bits, file );
+
+ if( num_bits_read != num_bits )
+ {
+ fprintf(stderr, "\nError, invalid number of bits read ! Exiting ! \n");
+ exit(-1);
+ }
+
+ }
+ while ( rew_flag && (st->bfi_fx || LT_32(total_brate,2800)));
+
+ /* G.192 RX DTX handler*/
+ if( !rew_flag )
+ {
+ /* handle SID_FIRST, SID_BAD, SPEECH_LOST, NO_DATA as properly as possible for the ITU-T G.192 format */
+
+ /* (total_brate, bfi , st_CNG) = rx_handler(received frame type, [previous frame type], past CNG state, past core) */
+ curr_ft_good_sp = 0;
+ curr_ft_bad_sp = 0;
+
+ if( total_brate > SID_2k40 )
+ {
+ if( st->bfi_fx == 0 )
+ {
+ curr_ft_good_sp = 1;
+ }
+ else
+ {
+ curr_ft_bad_sp = 1;
+ }
+ }
+ sid_update = 0;
+ sid_upd_bad = 0;
+
+ if( total_brate == SID_1k75 || total_brate == SID_2k40 )
+ {
+ if( st->bfi_fx == 0 )
+ {
+ sid_update = 1;
+ }
+ else
+ {
+ sid_upd_bad = 1; /* may happen in CS , corrupt but detected sid frame */
+ }
+ }
+
+ /* all zero indeces/bits iSP AMRWB SID_update results in a valid LP filter with extremely high LP-filter-gain */
+ /* all zero indeces/bits may be a result of CS bit errors and/or erroneously injected by gateways or by a bad dejitter handlers */
+ if (total_brate == SID_1k75 && sid_update == 1)
+ {
+ /* valid sid_update received, check for very risky but formally valid content */
+ Word16 sum = 0;
+ for (k = 0; k < num_bits; ++k)
+ {
+ sum += (pt_stream[k] == G192_BIN1);/* check of 35 zeroes, 35 ones */
+ }
+ if( sum == 0 )
+ { /* all zeros */
+ sid_upd_bad = 1; /* initial signal as corrupt (BER likley) */
+ }
+ }
+
+ /* AMRWB 26.173 G.192 file reader (read_serial) does not declare/use SID_BAD ft,
+ it declares every bad synch marked frame initially as a lost_speech frame,
+ and then the RXDTX handler CNG state decides the decoding mode CNG/SPEECH.
+ While In the AMRWB ETSI/3GPP format eid a CRC error in a detected SID_UPDATE frame triggers SID_UPD_BAD.
+
+ Here we inhibit use of the SID-length info, even though it is available in the G.192 file format after STL/EID-XOR .
+ */
+ if ( sid_upd_bad )
+ {
+ sid_upd_bad = 0;
+ total_brate = FRAME_NO_DATA ; /* treat SID_BAD as a stolen signaling frame --> SPEECH LOST */
+
+ }
+
+ g192_sid_first = 0;
+ if( st->core_fx == AMR_WB_CORE && st->prev_ft_speech_fx && total_brate == FRAME_NO_DATA && st->bfi_fx == 0 )
+ {
+ g192_sid_first = 1; /* SID_FIRST detected for previous AMRWB/AMRWBIO active frames only */
+ /*
+ It is not possible to perfectly simulate rate switching conditions EVS->AMRWBIO where:
+ the very first SID_FIRST detection is based on a past EVS active frame
+ and a good length 0 "SID_FIRST"(NO_DATA) frame is sent in AMRWBIO,
+ , due to the one frame state memory in the AMRWB legacy G.192 SID_FIRST encoding
+ */
+ }
+
+ speech_bad = 0;
+ if( total_brate > SID_2k40 && st->bfi_fx != 0 ) /* CS-type of CRC failure frame */
+ {
+ speech_bad = 1; /* initial assumption, CNG_state decides what to do */
+ }
+
+ speech_lost = 0;
+ if( total_brate == 0 && st->bfi_fx != 0 ) /* unsent NO_DATA or stolen NO_DATA/signaling frame */
+ {
+ speech_lost = 1; /* initial assumption, CNG_state decides what to do */
+ }
+
+ /* Do not allow decoder to enter CNG-synthesis for any instantly received GOOD+LENGTH==0 frame
+ as this frame was never transmitted, one can not know it is good and has a a length of zero ) */
+
+ if( st->CNG_fx != 0 )
+ {
+ /* We were in CNG synthesis */
+ if( curr_ft_good_sp != 0 )
+ {
+ /* only a good speech frame makes you leave CNG synthesis */
+ st->CNG_fx = 0;
+ }
+ }
+ else
+ {
+ /* We were in SPEECH synthesis */
+ /* only a received SID frame can make the decoder enter into CNG synthsis */
+ if( g192_sid_first || sid_update || sid_upd_bad )
+ {
+ st->CNG_fx = 1;
+ }
+ }
+
+ /* handle the g.192 _simulated_ untransmitted frame, setting for decoder SPEECH synthesis */
+ if ( (st->CNG_fx==0) && (total_brate==0 && st->bfi_fx == 0 ) )
+ {
+ st->bfi_fx = 1;
+ move16(); /* SPEECH PLC code will now become active as in a real system */
+ /* total_brate= 0 */
+ }
+
+ /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
+ if( ((st->CNG_fx != 0) && ( (speech_bad != 0) || (speech_lost != 0) )) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
+ ( sid_upd_bad != 0 )) /* SID_UPD_BAD --> start CNG */
+ {
+ st->bfi_fx = 0;
+ total_brate = 0;
+ }
+ /* update for next frame's G.192 file format's SID_FIRST detection (primarily for AMRWBIO) */
+ st->prev_ft_speech_fx = ((curr_ft_good_sp != 0) || (curr_ft_bad_sp != 0));
+
+ /* st->total brate= total_brate ; updated in a good frame below */
+ } /* rew_flag */
+#ifdef DEBUGGING
+ st->bfi_fx |= file_read_FECpattern();
+#endif
+ /* get total bit-rate */
+ if ( st->bfi_fx == 0 && !rew_flag )
+ {
+ /* select MODE1 or MODE2 */
+ decoder_selectCodec( st, total_brate, *pt_stream );
+ }
+
+ Mpy_32_16_ss(total_brate, 5243, &L_tmp, &utmp); /* 5243 is 1/50 in Q18. (0+18-15=3) */
+ st->total_num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */
+
+ /* in case rew_flag is set, rewind the file and return */
+ /* (used in io_enc() to print out info about technologies and to initialize the codec) */
+ if ( rew_flag )
+ {
+ rewind( file );
+ st->total_brate_fx = total_brate;
+ move16();
+ return 1;
+ }
+
+ /* GOOD frame */
+ if ( st->bfi_fx == 0 )
+ {
+ /* GOOD frame - convert ITU-T G.192 words to short values */
+ bit_stream_ptr = st->bit_stream_fx;
+
+ for( k = 0; k< num_bits; ++k)
+ {
+ *bit_stream_ptr++ = (*pt_stream++ == G192_BIN1 );
+ }
+
+ /*add two zero bytes for arithmetic coder flush*/
+ for(k=0; k< 2*8; ++k)
+ {
+ *bit_stream_ptr++ = 0;
+ }
+ /*a change of the total bitrate should not be
+ known to the decoder, if the received frame was lost*/
+ st->total_brate_fx = total_brate ;
+
+ mdct_switching_dec(st);
+ }
+
+ return 1;
+}
+
+
+/*-------------------------------------------------------------------*
+ * read_indices_mime_handle_dtx()
+ *
+ * Handle DTX for MIME and RTP_DUMP decoding.
+ * Returns the actual total_brate.
+ *-------------------------------------------------------------------*/
+
+static Word32 read_indices_mime_handle_dtx(
+ Decoder_State_fx *st,
+ Word16 isAMRWB_IOmode,
+ Word16 core_mode,
+ Word32 total_brate,
+ Word16 sti,
+ Word16 speech_lost,
+ Word16 no_data
+)
+{
+ Word16 curr_ft_good_sp = 0;
+ Word16 speech_bad = 0;
+ Word16 sid_upd_bad = 0, sid_update = 0;
+ Word16 amrwb_sid_first = 0; /* derived from sti SID_FIRST indicator in AMRWB payload */
+
+ /* keep st->CNG , st_bfi and total_brate updated for proper synthesis in DTX and FER */
+ if( GT_32(total_brate, SID_2k40) )
+ {
+ if( st->bfi_fx != 1 ) /* so far derived from q bit in AMRWB/AMRWBIO cases */
+ {
+ curr_ft_good_sp = 1;
+ }
+ }
+
+ /* handle q_bit and lost_sp clash , assume worst case */
+ if( speech_lost != 0 ) /* overrides a good q_bit */
+ {
+ curr_ft_good_sp = 0;
+ st->bfi_fx = 1; /* override qbit */
+ }
+
+ /* now_bfi_fx has been set based on q_bit and ToC fields */
+
+
+ /* SID_UPDATE check */
+ if( total_brate == SID_1k75 || total_brate == SID_2k40 )
+ {
+ if( st->bfi_fx == 0 )
+ {
+ /* typically from q bit */
+ sid_update = 1;
+ }
+ else
+ {
+ sid_upd_bad = 1; /* may happen in saving from e.g. a CS-connection */
+ }
+ }
+
+ if( isAMRWB_IOmode && total_brate == 0 && sti == 0 )
+ {
+ if( st->bfi_fx )
+ {
+ sid_upd_bad = 1; /* corrupt sid_first, signaled as bad sid */
+ }
+ else
+ {
+ amrwb_sid_first = 1; /* 1-sti */
+ }
+ }
+
+ if ( sid_upd_bad != 0 && (
+ (isAMRWB_IOmode != 0 && st->Opt_AMR_WB_fx==0 ) || /* switch to AMRWBIO */
+ (isAMRWB_IOmode != 1 && st->Opt_AMR_WB_fx==1) /* switch from AMRWBIO */
+ ) )
+ {
+ /* do not allow a normal start of CNG synthesis if this SID(with BER or FER) is a switch to/from AMRWBIO */
+ sid_upd_bad = 0; /* revert this detection due to AMRWBIO/EVS mode switch */
+ total_brate = 0;
+ no_data = 1;
+ assert( st->bfi_fx==1); /* bfi stays 1 */
+ }
+
+ if( GT_32(total_brate, SID_2k40) && st->bfi_fx == 1 ) /* typically from q bit */
+ {
+ speech_bad = 1; /* initial assumption, CNG synt state decides what to actually do */
+ }
+ /* all frame types decoded */
+
+ /* update CNG synthesis state */
+ /* Decoder can only enter CNG-synthesis for CNG frame types (sid_upd, sid_bad, sid_first) */
+ if( st->CNG_fx != 0 )
+ {
+ /* We were in CNG synthesis */
+ if( curr_ft_good_sp != 0 )
+ {
+ /* only a good speech frame makes decoder leave CNG synthesis */
+ st->CNG_fx = 0;
+ }
+ }
+ else
+ {
+ /* We were in SPEECH synthesis */
+ /* only a received SID frame can make the decoder enter into CNG synthesis */
+ if( amrwb_sid_first || sid_update || sid_upd_bad )
+ {
+ st->CNG_fx = 1;
+ }
+ }
+
+ /* Now modify bfi flag for the decoder's SPEECH/CNG synthesis logic */
+ /* in SPEECH synthesis, make sure to activate speech plc for a received no_data frame,
+ no_data frames may be injected by the network or by the dejitter buffer */
+ /* modify bfi_flag to stay/move into the correct decoder PLC section */
+ if ( (st->CNG_fx == 0) && ( no_data != 0 ) )
+ {
+ /* treat no_data received in speech synthesis as SP_LOST frames, SPEECH PLC code will now become active */
+ st->bfi_fx = 1;
+ /* total_brate= 0; always zero for no_data */
+ }
+
+ /* in CNG */
+ /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */
+ if( ( st->CNG_fx != 0 && ( speech_bad || speech_lost || no_data )) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */
+ sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */
+ {
+ st->bfi_fx = 0; /* mark as good to not start speech PLC */
+ total_brate = 0; /* this zeroing needed for speech_bad, sid_bad frames */
+ }
+
+
+ /* now bfi, total_brate are set by RX-DTX handler::
+ bfi==0, total_brate!=0 cng or speech pending bitrate
+ bfi==0, total_brate==0 cng will continue or start(sid_first, sid_bad)
+ bfi==1, total_brate!=0 speech plc
+ bfi==1, total_brate==0 , speech plc
+ */
+
+
+ /* handle available AMRWB/AMRWBIO MIME header ToC rate-info at startup */
+ if( ( st->bfi_fx == 1 && st->ini_frame_fx == 0) &&
+ ( (st->amrwb_rfc4867_flag != 0) || (st->amrwb_rfc4867_flag == 0 && isAMRWB_IOmode != 0 )) ) /*AMRWB ToC */
+ {
+ Word32 init_rate;
+
+ init_rate = total_brate; /* default , may have been modified from original ToC value */
+ if (speech_lost !=0 || no_data != 0 )
+ {
+ init_rate = ACELP_12k65; /* make sure the decoder starts up in a selected AMRWB mode */
+ }
+ else if( speech_bad !=0 )
+ {
+ init_rate = AMRWB_IOmode2rate[core_mode]; /* read from from ToC */
+ }
+ st->total_brate_fx = init_rate; /* not updated on bfi as decoderSelectCodec is not called below */
+ st->core_brate_fx = init_rate;
+ }
+
+ return total_brate;
+}
+
+
+/*-------------------------------------------------------------------*
+ * read_indices_mime_handle_sti_and_all_zero_bits()
+ *
+ * Handle STI and frames with all zero bits for MIME and RTP_DUMP decoding.
+ *-------------------------------------------------------------------*/
+
+static void read_indices_mime_handle_sti_and_all_zero_bits(
+ Decoder_State_fx *st,
+ Word32 *total_brate,
+ Word16 sti
+)
+{
+ Word16 k;
+
+ if( sti == 0 )
+ {
+ *total_brate = 0; /* signal received SID_FIRST as a good frame with no bits */
+ for(k=0; k<35; k++)
+ {
+ st->bfi_fx |= st->bit_stream_fx[k] ; /* partity check of 35 zeroes, any single 1 gives BFI */
+ }
+ }
+ /* all zero bit SID_update results in a valid LP filter with extremely high LP-filter-gain */
+ /* all zero bits signal may be a result of CS bit errors or erronesouly injected by gateways or bad dejitter handlers */
+ if (sti == 1)
+ { /*sid_update received */
+ Word16 sum = 0;
+ for (k = 0; k < 35; k++)
+ {
+ sum += st->bit_stream_fx[k]; /* check of 35 zeroes */
+ }
+
+ if ( sum == 0 )
+ {
+ st->bfi_fx = 1; /* eventually becomes SID_UPD_BAD */
+ }
+ }
+}
+
+
+/*------------------------------------------------------------------------------------------*
+* read_indices_mime()
+*
+* Read indices from MIME formatted bitstream to the buffer
+* The magic word and number of channnels should be consumed before calling this function
+*-------------------------------------------------------------------------------------------*/
+
+Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ FILE *file, /* i : bitstream file */
+ Word16 rew_flag /* i : rewind flag (rewind file after reading) */
+)
+{
+ Word16 k, isAMRWB_IOmode, cmi, core_mode = -1, qbit,sti;
+ UWord8 header;
+ UWord8 pFrame[(MAX_BITS_PER_FRAME + 7) >> 3];
+ UWord8 mask= 0x80, *pt_pFrame=pFrame;
+ UWord16 *bit_stream_ptr;
+ Word16 num_bits;
+ Word32 total_brate;
+ UWord16 utmp;
+ Word32 L_tmp;
+ Word16 speech_lost = 0, no_data = 0;
+ Word16 num_bytes_read;
+
+ st->BER_detect = 0;
+ st->bfi_fx = 0;
+ st->mdct_sw_enable = 0;
+ st->mdct_sw = 0;
+ reset_indices_dec_fx( st );
+
+ /* read the FT Header field from the bitstream */
+ if ( fread( &header, sizeof(UWord8), 1, file ) != 1 )
+ {
+ if( ferror( file ) )
+ {
+ /* error during reading */
+ fprintf(stderr, "\nError reading the bitstream !");
+ exit(-1);
+ }
+ else
+ {
+ /* end of file reached */
+ return 0;
+ }
+ }
+
+ /* init local RXDTX flags */
+ sti = -1;
+
+ if( st->amrwb_rfc4867_flag != 0 )
+ {
+ /* RFC 4867
+ 5.3 ....
+ Each stored speech frame starts with a one-octet frame header with
+ the following format:
+ 0 1 2 3 4 5 6 7
+ +-+-+-+-+-+-+-+-+
+ |P| FT |Q|P|P|
+ +-+-+-+-+-+-+-+-+
+ The FT field and the Q bit are defined in the same way as in
+ Section 4.3.2. The P bits are padding and MUST be set to 0, and MUST be ignored. */
+
+ isAMRWB_IOmode = 1;
+ qbit = (header>>2)&0x01 ; /* b2 bit (b7 is the F bit ) */
+ st->bfi_fx = !qbit;
+ core_mode = ((header>>3) & 0x0F); /* b6..b3 */
+ total_brate = AMRWB_IOmode2rate[core_mode]; /* get the frame length from the header */
+ }
+ else
+ {
+ /*0 1 2 3 4 5 6 7 MS-bit ---> LS-bit
+ +-+-+-+-+-+-+-+-+
+ |H|F|E|x| brate |
+ +-+-+-+-+-+-+-+-+
+ where :
+ "E|x| brate " is the 6 bit "FT" -field
+ x is unused if E=0, (should be 0 )
+ x is the q-bit if E=1, q==1(good), Q==0(bad, maybe bit errors in payload )
+ H,F always 0 in RTP format.
+ */
+ isAMRWB_IOmode = (header & 0x20) > 0; /* get EVS mode-from header */ /* b2 */
+ core_mode = (header & 0x0F); /* b4,b5,b6,b7 */
+
+ if( isAMRWB_IOmode )
+ {
+ qbit = (header & 0x10) > 0; /* get Q bit, valid for IO rates */ /* b3 */
+ total_brate = AMRWB_IOmode2rate[core_mode];
+ }
+ else
+ {
+ qbit = 1; /* assume good q_bit for the unused EVS-mode bit, complete ToC validity checked later */
+ total_brate = PRIMARYmode2rate[ core_mode ];
+ }
+ st->bfi_fx = !qbit;
+ }
+
+
+
+
+ /* set up RX-DTX-handler input */
+ if( core_mode == 14 )
+ {
+ /* SP_LOST */
+ speech_lost=1;
+ }
+ if ( core_mode == 15)
+ {
+ /* NO_DATA unsent CNG frame OR any frame marked or injected as no_data by e.g a signaling layer or dejitter buffer */
+ no_data=1;
+ }
+
+ Mpy_32_16_ss(total_brate, 5243, &L_tmp, &utmp); /* 5243 is 1/50 in Q18. (0+18-15=3) */
+ num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */
+ st->total_num_bits = num_bits;
+
+ if( total_brate < 0 )
+ {
+ /* validate that total_brate (derived from RTP packet or a file header) is one of the defined bit rates */
+ fprintf(stderr, "\n Error. Illegal total bit rate (= %d) in MIME ToC header \n", total_brate );
+ /* num_bits = -1; not needed as BASOP multiplication preserves sign */
+ }
+
+ /* Check correctness of ToC headers */
+ if( st->amrwb_rfc4867_flag == 0 )
+ {
+ /* EVS ToC header (FT field(b2-b7), H bit (b0), F bit (b1) , (EVS-modebit(b2)=0 unused(Qbit)(b3)==0) */
+ if ( (isAMRWB_IOmode == 0) && ((num_bits < 0) || ((header & 0x80) > 0) || ((header & 0x40) > 0) || (header & 0x30) != 0x00 ) )
+ {
+ /* incorrect FT header */
+ fprintf(stderr, "\nError in EVS FT ToC header(%02x) ! ",header);
+ exit(-1);
+ }
+ else if( (isAMRWB_IOmode != 0) && ( (num_bits < 0) || ((header & 0x80) > 0) || ((header & 0x40) > 0) ) ) /* AMRWBIO */
+ {
+ /* incorrect IO FT header */
+ fprintf(stderr, "\nError in EVS(AMRWBIO) FT ToC header(%02x) ! ",header);
+ exit(-1);
+ }
+ }
+ else
+ {
+ /* legacy AMRWB ToC, is only using Padding bits which MUST be ignored */
+ if ( num_bits < 0 )
+ {
+ /* incorrect FT header */
+ fprintf(stderr, "\nError in AMRWB RFC4867 Toc(FT) header(%02x) !", header);
+ exit(-1);
+ }
+ }
+
+ /* read serial stream of indices from file to the local buffer */
+ num_bytes_read = (Word16) fread( pFrame, sizeof(UWord8), (num_bits + 7)>>3, file );
+ if( num_bytes_read != (num_bits + 7)>>3 )
+ {
+ fprintf(stderr, "\nError, invalid number of bytes read ! Exiting ! \n");
+ exit(-1);
+ }
+
+ /* in case rew_flag is set, rewind the file and return */
+ /* (used in io_dec() to attempt print out info about technologies and to initialize the codec ) */
+ if ( rew_flag )
+ {
+ st->total_brate_fx = total_brate; /* used for the codec banner output */
+ if( st->bfi_fx == 0 && speech_lost == 0 && no_data == 0 )
+ {
+ decoder_selectCodec( st, total_brate, unpack_bit(&pt_pFrame,&mask) ? G192_BIN1 : G192_BIN0);
+ }
+ return 1;
+ }
+
+
+
+ /* unpack speech data */
+ bit_stream_ptr = st->bit_stream_fx;
+ for (k=0; kbit_stream_fx[sort_ptr[core_mode][k]] = unpack_bit(&pt_pFrame,&mask);
+ bit_stream_ptr++;
+ }
+ else
+ {
+ *bit_stream_ptr++ = unpack_bit(&pt_pFrame,&mask);
+ }
+ }
+
+ /* unpack auxiliary bits */
+ /* Note: the cmi bits are unpacked for demo purposes; */
+ if (isAMRWB_IOmode && total_brate == SID_1k75)
+ {
+ sti = unpack_bit(&pt_pFrame,&mask);
+ cmi = unpack_bit(&pt_pFrame,&mask) << 3;
+ cmi |= unpack_bit(&pt_pFrame,&mask) << 2;
+ cmi |= unpack_bit(&pt_pFrame,&mask) << 1;
+ cmi |= unpack_bit(&pt_pFrame,&mask);
+
+ read_indices_mime_handle_sti_and_all_zero_bits( st, &total_brate, sti );
+ }
+
+ /*add two zero bytes for arithmetic coder flush*/
+ for(k=0; k< 2*8; ++k)
+ {
+ *bit_stream_ptr++ = 0;
+ }
+
+ /* MIME RX_DTX handler */
+ if( !rew_flag )
+ {
+ total_brate = read_indices_mime_handle_dtx( st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data );
+ }
+
+ if( st->bfi_fx == 0 )
+ {
+ /* select MODE1 or MODE2 in MIME */
+ decoder_selectCodec( st, total_brate, *st->bit_stream_fx ? G192_BIN1 : G192_BIN0);
+
+ /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
+ st->total_brate_fx = total_brate;
+ mdct_switching_dec(st);
+ }
+ /* else{ bfi stay in past synthesis mode(SP,CNG) } */
+
+ return 1;
+}
+
+/*-------------------------------------------------------------------*
+* berCheck()
+*
+* Check for bit errors in channel aware signalling.
+*-------------------------------------------------------------------*/
+
+static void berCheck(
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ Word16 *coder_type /* i/o: coder type */
+)
+{
+ /* In case of RF flag = 1, and valid RF packet with primary and partial copy */
+ if ( ( EQ_16( st->bwidth_fx, NB)||EQ_16(st->bwidth_fx,FB))
+ || (GE_16(*coder_type,TRANSITION) )
+ )
+ {
+ if( EQ_16( st->use_partial_copy, 1 ))
+ {
+ st->use_partial_copy = 0;
+ move16();
+ }
+
+ st->bfi_fx = 1;
+ move16();
+ st->bwidth_fx = st->last_bwidth_fx;
+ move16();
+ st->BER_detect = 1;
+ move16();
+ *coder_type = GENERIC;
+ move16();
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+* getPartialCopyInfo()
+*
+* Check if the frame includes a partial copy for channel aware processing.
+*-------------------------------------------------------------------*/
+
+void getPartialCopyInfo(
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ Word16 *coder_type,
+ Word16 *sharpFlag
+)
+{
+ Word16 nBits;
+ Word16 ind;
+ /* check the rf flag in the packet */
+ get_rfFlag( st, &(st->rf_flag), &nBits , &ind);
+
+ /* get rf frame type info */
+ get_rfFrameType( st, &(st->rf_frame_type) );
+
+ /* Get the FEC offset info */
+ get_rf_fec_offset( st, &(st->rf_fec_offset) );
+
+ /* reset number of target bits in case of rate switching */
+ st->rf_target_bits = 0;
+
+ /* Get the number of bits used for RF*/
+ IF( EQ_16(st->rf_flag,1))
+ {
+ *coder_type = s_and(ind,0x7);
+ st->bwidth_fx = s_and(shr(ind,3), 0x7);
+ *sharpFlag = s_and(shr(ind,6), 0x1);
+ st->codec_mode = MODE2;
+ move16();
+ get_rfTargetBits( st->rf_frame_type, &(st->rf_target_bits) );
+
+ IF( EQ_16(st->bfi_fx,FRAMEMODE_FUTURE))
+ {
+ st->use_partial_copy = 1;
+ /* now set the frame mode to normal mode */
+ test();
+ IF(GE_16(st->rf_frame_type,RF_TCXFD)&&LE_16(st->rf_frame_type,RF_TCXTD2))
+ {
+ st->bfi_fx = 1;
+ st->core_fx = 1;
+ }
+ ELSE
+ {
+ st->bfi_fx = FRAMEMODE_NORMAL;
+ st->core_fx = 0;
+ }
+ }
+
+ /* check for bit errors */
+ berCheck( st, coder_type );
+
+ get_next_indice_tmp_fx(st, nBits);
+
+ }
+}
+
+/*-------------------------------------------------------------------*
+* get_rfFlag()
+*
+* Check if rf flag is present in the bitstream
+*-------------------------------------------------------------------*/
+
+void get_rfFlag(
+ Decoder_State_fx *st, /* i: decoder state structure */
+ Word16 *rf_flag, /* o : check for the RF flag */
+ Word16 *nBits,
+ Word16 *ind
+)
+{
+ Word16 start_idx, nBits_tmp;
+ Word16 ind_tmp;
+
+ /* Init */
+ *rf_flag = 0;
+
+ /* check for rf_flag in the packet and extract the rf_frame_type and rf_fec_offset */
+ test();
+ test();
+ IF( EQ_32(st->total_brate_fx,ACELP_13k20)&&(EQ_16(st->bfi_fx,FRAMEMODE_NORMAL)||EQ_16(st->bfi_fx,FRAMEMODE_FUTURE)))
+ {
+ /* find the section in the ACELP signalling table corresponding to bitrate */
+ start_idx = 0;
+ WHILE ( NE_32(acelp_sig_tbl[start_idx], st->total_brate_fx))
+ {
+ start_idx++;
+ assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n");
+ }
+
+ /* skip the bitrate */
+ start_idx = add(start_idx,1);
+
+ /* retrieve the number of bits */
+ nBits_tmp = (Word16) acelp_sig_tbl[start_idx++];
+
+ /* retrieve the signalling indice */
+ ind_tmp = (Word16) acelp_sig_tbl[start_idx + get_indice_fx( st, 0, nBits_tmp )];
+
+ /* convert signalling indice into RF flag. */
+ *rf_flag = s_and(shr(ind_tmp, 7), 0x1);
+
+ if( ind )
+ {
+ *ind = ind_tmp;
+ }
+
+ if( nBits )
+ {
+ *nBits = nBits_tmp;
+ }
+ }
+}
+
+/*-------------------------------------------------------------------*
+* get_rfFrameType()
+*
+* Extract the rf frame type
+*-------------------------------------------------------------------*/
+
+void get_rfFrameType(
+ Decoder_State_fx *st, /* i : decoder state structure */
+ Word16 *rf_frame_type /* o : RF frame type */
+)
+{
+ Word16 num_bits = 0;
+
+ IF( EQ_16(st->rf_flag, 1))
+ {
+ /*num_bits = st->total_brate_fx/50;*/
+ if( EQ_32(st->total_brate_fx, ACELP_13k20))
+ {
+ num_bits = 264;
+ move16(); /* @13.2kbps */
+ }
+ else
+ {
+ UWord16 lsb;
+ Word32 L_tmp;
+ Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */
+ num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */
+ }
+
+ /* the last three bits in a packet is the RF frame type */
+ *rf_frame_type = get_indice_fx( st, num_bits - 3, 3 );
+ }
+ ELSE
+ {
+ *rf_frame_type = 0;
+ }
+}
+
+/*-------------------------------------------------------------------*
+* get_rf_fec_offset()
+*
+* Extract the FEC offset
+*-------------------------------------------------------------------*/
+
+void get_rf_fec_offset(
+ Decoder_State_fx *st, /* i : decoder state structure */
+ Word16 *rf_fec_offset /* o : RF fec offset */
+)
+{
+ Word16 num_bits, tmp;
+
+ IF( EQ_16(st->rf_flag,1))
+ {
+ /*num_bits = st->total_brate_fx/50;*/
+ if( EQ_32(st->total_brate_fx, ACELP_13k20))
+ {
+ num_bits = 264;
+ move16(); /* @13.2kbps */
+ }
+ else
+ {
+ UWord16 lsb;
+ Word32 L_tmp;
+ Mpy_32_16_ss(st->total_brate_fx, 5243, &L_tmp, &lsb); /* 5243 is 1/50 in Q18. (0+18-15=3) */
+ num_bits = extract_l(L_shr(L_tmp, 3)); /* Q0 */
+ }
+
+ /* the two bits before the rf frame type contain the fec offset */
+ tmp = get_indice_fx( st, num_bits - 5, 2 );
+
+ if( tmp == 0 )
+ {
+ *rf_fec_offset = 2;
+ move16();
+ }
+ else
+ {
+ *rf_fec_offset = add(shl(tmp, 1), 1);
+ }
+ }
+ ELSE
+ {
+ *rf_fec_offset = 0;
+ move16();
+ }
+}
+
+/*-------------------------------------------------------------------*
+* get_rfTargetBits()
+*
+* Return the number of RF target bits
+*-------------------------------------------------------------------*/
+
+void get_rfTargetBits(
+ Word16 rf_frame_type, /* i : RF frame type */
+ Word16 *rf_target_bits /* o : Number of RF target bits */
+)
+{
+
+ /* Number of RF bits for different RF coder types */
+
+ SWITCH (rf_frame_type)
+ {
+ case RF_NO_DATA:
+ *rf_target_bits = 5;
+ BREAK;
+ case RF_TCXFD:
+ *rf_target_bits = 27;
+ BREAK;
+ case RF_TCXTD1:
+ *rf_target_bits = 16;
+ BREAK;
+ case RF_TCXTD2:
+ *rf_target_bits = 16;
+ BREAK;
+ case RF_ALLPRED:
+ /* Es_pred bits 3 bits, LTF: 1, pitch: 8,5,5,5, FCB: 0, gain: 7,0,7,0, Diff GFr: 4*/
+ *rf_target_bits = 63;
+ BREAK;
+ case RF_NOPRED:
+ /* Es_pred bits 3 bits, LTF: 0, pitch: 0, FCB: 7,7,7,7, gain: 6,0,6,0, Diff GFr: 2*/
+ *rf_target_bits = 66;
+ BREAK;
+ case RF_GENPRED:
+ /* Es_pred bits 3 bits, LTF: 1, pitch: 8,0,8,0, FCB: 6,7,5,5, gain: 5,0,5,0, Diff GFr: 0*/
+ *rf_target_bits = 70;
+ BREAK;
+ case RF_NELP:
+ /* gain: 19, Diff GFr: 5 */
+ *rf_target_bits = 45;
+ BREAK;
+ }
+}
+
+
+/*-------------------------------------------------------------------*
+ * get_NextCoderType_fx()
+ *
+ * Extract the coder type of next frame
+ *-------------------------------------------------------------------*/
+
+void get_NextCoderType_fx(
+ UWord8 *bitsteam, /* i : bitstream */
+ Word16 *next_coder_type /* o : next coder type */
+)
+{
+ Word16 k;
+ Word16 start_idx;
+ Word16 nBits_tmp;
+ Word8 bit_stream[ACELP_13k20/50];
+ UWord16 tmp;
+
+
+ FOR( k = 0; k < ACELP_13k20/50; k++ )
+ {
+ bit_stream[k] = (bitsteam[k / 8] >> (7 - (k % 8))) & 0x1;
+ }
+ start_idx = 0;
+ WHILE ( NE_32(acelp_sig_tbl[start_idx], ACELP_13k20))
+ {
+ start_idx = add(start_idx,1);
+ assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n");
+ }
+
+ /* skip the bitrate */
+ start_idx = add(start_idx,1);
+
+ tmp = 0;
+ move16();
+ nBits_tmp = (Word16) acelp_sig_tbl[start_idx++];
+ FOR (k = 0; k < nBits_tmp; k++)
+ {
+ tmp = lshl(tmp, 1);
+ tmp = add(tmp, bit_stream[k]);
+ }
+ /* retrieve the signalling indice */
+ *next_coder_type = s_and((Word16)acelp_sig_tbl[start_idx + tmp],0x7);
+}
+
+/*-------------------------------------------------------------------*
+ * read_indices_from_djb_fx()
+ *
+ * Read indices from the de-jitter buffer payload (works also for AMR-WB IO mode)
+ *-------------------------------------------------------------------*/
+
+void read_indices_from_djb_fx(
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ UWord8 *pt_stream, /* i : bitstream file */
+ Word16 num_bits, /* i : input frame length in bits */
+ Word16 isAMRWB_IOmode,
+ Word16 core_mode,
+ Word16 qbit,
+ Word16 partialframe, /* i : partial frame information */
+ Word16 next_coder_type /* i : next coder type information */
+)
+{
+ Word16 k;
+ UWord8 mask = 0x80;
+ Word16 no_data = 0;
+ Word16 sti = -1;
+ UWord16 *bit_stream_ptr;
+ Word32 total_brate;
+ Word16 speech_lost = 0;
+
+ st->bfi_fx = 0;
+ st->BER_detect = 0;
+ st->mdct_sw_enable = 0;
+ st->mdct_sw = 0;
+ reset_indices_dec_fx(st);
+
+ st->bfi_fx = !qbit;
+ total_brate = (Word32)(num_bits) * 50;
+ st->total_num_bits = num_bits;
+
+ if( num_bits == 0 ) /* guess type of missing frame for SP_LOST and NO_DATA */
+ {
+ speech_lost = st->CNG_fx == 0;
+ no_data = st->CNG_fx != 0;
+ }
+
+ if( partialframe || st->prev_use_partial_copy)
+ {
+ st->next_coder_type = next_coder_type;
+ }
+ else
+ {
+ st->next_coder_type = INACTIVE;
+ }
+
+ if (partialframe == 1)
+ {
+ st->bfi_fx = 2;
+ }
+
+ /* unpack speech data */
+ bit_stream_ptr = st->bit_stream_fx;
+ /* convert bitstream from compact bytes to short values and store it in decoder state */
+ for( k = 0; k < num_bits; k++ )
+ {
+ if( st->bitstreamformat == VOIP_RTPDUMP && isAMRWB_IOmode )
+ {
+ st->bit_stream_fx[sort_ptr[core_mode][k]] = unpack_bit(&pt_stream, &mask);
+ bit_stream_ptr++;
+ }
+ else
+ {
+ *bit_stream_ptr++ = unpack_bit(&pt_stream, &mask);
+ }
+ }
+
+ /* unpack auxiliary bits */
+ if( isAMRWB_IOmode && total_brate == SID_1k75 )
+ {
+ if( st->bitstreamformat == VOIP_RTPDUMP )
+ {
+ /* A.2.2.1.3: AMR-WB SID_1k75 frame is followed by STI bit and CMI bits */
+ sti = unpack_bit(&pt_stream, &mask);
+ }
+ else
+ {
+ /* VOIP_G192_RTP does not contain STI and CMI */
+ sti = 1;
+ }
+ read_indices_mime_handle_sti_and_all_zero_bits(st, &total_brate, sti);
+
+ }
+
+ /* add two zero bytes for arithmetic coder flush */
+ for( k=0; k < 8*2; ++k )
+ {
+ *bit_stream_ptr++ = 0;
+ }
+
+ total_brate = read_indices_mime_handle_dtx(st, isAMRWB_IOmode, core_mode, total_brate, sti, speech_lost, no_data);
+ /* st->CNG_fx set inside */
+
+ if ( st->bfi_fx != 1 )
+ {
+ /* select Mode 1 or Mode 2 */
+ decoder_selectCodec( st, total_brate, *st->bit_stream_fx ? G192_BIN1 : G192_BIN0);
+
+ /* a change of the total bitrate should not be known to the decoder, if the received frame was truly lost */
+ st->total_brate_fx = total_brate;
+
+ mdct_switching_dec(st);
+ }
+}
+
+
+
+/*-------------------------------------------------------------------*
+ * get_indice_preview()
+ *
+ * Indices preview to parse for the presence of partial copy
+ *-------------------------------------------------------------------*/
+static UWord16 get_indice_preview(
+ UWord8 *bitstream,
+ Word16 bitstreamSize,
+ Word16 pos,
+ Word16 nb_bits
+)
+{
+ UWord16 value;
+ Word16 i;
+ UWord16 bitstreamShort[MAX_BITS_PER_FRAME+16];
+ UWord16 *bitstreamShortPtr;
+
+ /* convert bitstream from compact bytes to short values */
+ bitstreamShortPtr = bitstreamShort;
+ FOR( i = 0; i < bitstreamSize; i++ )
+ {
+ *bitstreamShortPtr++ = (bitstream[i / 8] >> (7 - (i % 8))) & 0x1;
+ }
+
+ assert(nb_bits <= 16);
+ value = 0;
+ FOR (i = 0; i < nb_bits; i++)
+ {
+ value = shl(value,1);
+ value = add(value,bitstreamShort[pos+i]);
+ }
+ return value;
+}
+
+/*-------------------------------------------------------------------*
+ * evs_dec_previewFrame()
+ *
+ * Signalling index preview
+ *-------------------------------------------------------------------*/
+void evs_dec_previewFrame(
+ UWord8 *bitstream,
+ Word16 bitstreamSize,
+ Word16 *partialCopyFrameType,
+ Word16 *partialCopyOffset
+)
+{
+ Word32 total_brate;
+ Word16 start_idx, nBits;
+ Word32 ind;
+ Word16 rf_flag;
+
+ rf_flag = 0;
+ *partialCopyFrameType = 0;
+ *partialCopyOffset = 0;
+ total_brate = bitstreamSize * 50;
+
+ IF( EQ_32(total_brate,ACELP_13k20))
+ {
+ /* find the section in the ACELP signalling table corresponding to bitrate */
+ start_idx = 0;
+ WHILE ( NE_32(acelp_sig_tbl[start_idx], total_brate))
+ {
+ start_idx = add(start_idx,1);
+ assert((start_idx < MAX_ACELP_SIG) && "ERROR: start_idx larger than acelp_sig_tbl[].\n");
+ }
+
+ /* skip the bitrate */
+ start_idx = add(start_idx,1);
+ /* retrieve the number of bits */
+ nBits = (Word16) acelp_sig_tbl[start_idx++];
+
+ /* retrieve the signalling indice */
+ ind = acelp_sig_tbl[start_idx + get_indice_preview( bitstream, bitstreamSize, 0, nBits )];
+
+ /* convert signalling indice into RF flag. */
+ rf_flag = s_and(extract_l(L_shr(ind, 7)), 0x1);
+ assert(rf_flag == ((ind >> 7) & 0x1));
+ IF(rf_flag != 0)
+ {
+ /* read the fec offset at which the partial copy is received */
+ ind = get_indice_preview( bitstream, bitstreamSize, (bitstreamSize-5), 2 );
+ IF(ind== 0) *partialCopyOffset = 2;
+ ELSE IF(EQ_32(ind,1))*partialCopyOffset=3;
+ ELSE IF(EQ_32(ind,2))*partialCopyOffset=5;
+ ELSE IF(EQ_32(ind,3))*partialCopyOffset=7;
+
+ /* the last three bits in a packet is the RF frame type */
+ *partialCopyFrameType = get_indice_preview( bitstream, bitstreamSize, bitstreamSize - 3, 3 );
+ }
+ }
+}
+
+
diff --git a/lib_com/cb_shape_fx.c b/lib_com/cb_shape_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..b4751363bffdcb913b704c639b727b6a9dedbc8d
--- /dev/null
+++ b/lib_com/cb_shape_fx.c
@@ -0,0 +1,134 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* */
+
+#include "stl.h"
+
+/*
+ * E_GAIN_f_pitch_sharpening
+ *
+ * Parameters:
+ * x I/O: impulse response (or algebraic code)
+ * pit_lag I: pitch lag
+ *
+ * Function:
+ * Performs Pitch sharpening routine for one subframe.
+ * pitch sharpening factor is 0.85
+ *
+ * Returns:
+ * void
+ */
+static void E_GAIN_f_pitch_sharpening(Word16 *x, Word16 pit_lag, Word16 L_subfr)
+{
+ Word16 i, tmp;
+
+ FOR (i = pit_lag; i < L_subfr; i++)
+ {
+ /*x[i] += x[i - pit_lag] * F_PIT_SHARP;*/
+ tmp = mult_r(x[i - pit_lag], 27853/*F_PIT_SHARP Q15*/);
+ x[i] = add(x[i],tmp);
+ move16();
+ }
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * cb_shape()
+ *
+ * pre-emphasis, pitch sharpening and formant sharpening of the algebraic codebook
+ *-------------------------------------------------------------------*/
+
+void cb_shape_fx(
+ const Word16 preemphFlag, /* i : flag for pre-emphasis */
+ const Word16 pitchFlag, /* i : flag for pitch sharpening */
+ const Word16 scramblingFlag, /* i : flag for phase scrambling */
+ const Word16 sharpFlag, /* i : flag for formant sharpening */
+ const Word16 formantTiltFlag, /* i : flag for formant tilt */
+ const Word16 g1, /* i : formant sharpening numerator weighting */
+ const Word16 g2, /* i : formant sharpening denominator weighting */
+ const Word16 *p_Aq, /* i : LP filter coefficients */
+ Word16 *code, /* i/o: signal to shape */
+ const Word16 tilt_code, /* i : tilt of code */
+ const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */
+ const Word16 shift
+)
+{
+ Word16 tmp, buff[L_SUBFR+M], A_num[M+1], A_den[M+1];
+ Word16 i;
+ Word32 L_tmp;
+ Word16 tilt, mu;
+ tmp = 0;
+ move16();
+
+ /* Pre-emphasis */
+ IF( preemphFlag )
+ {
+ preemph_copy_fx(code, code, tilt_code, L_SUBFR, &tmp);
+ }
+
+ /* pitch sharpening */
+ IF( pitchFlag )
+ {
+ E_GAIN_f_pitch_sharpening( code, pt_pitch, L_SUBFR );
+ }
+
+ /* phase scrambling filter */
+ IF( scramblingFlag )
+ {
+ buff[0] = code[0];
+ move16();
+ FOR (i = 1; i < L_SUBFR; i++)
+ {
+ buff[i]=code[i];
+ move16();
+ /*code[i] = 0.7f*buff[i] + buff[i-1] - 0.7f*code[i-1]; */
+ L_tmp = L_mult(22938, buff[i]);
+ tmp = mac_r(L_tmp,-22938, code[i-1]);
+ code[i] = add(tmp,buff[i-1]);
+ move16();
+ }
+ }
+
+ test();
+ IF ( sharpFlag || formantTiltFlag )
+ {
+ weight_a_fx( p_Aq, A_num, g1, M );
+ weight_a_fx( p_Aq, A_den, g2, M );
+ set16_fx(buff, 0, M+L_SUBFR);
+ IF( formantTiltFlag )
+ {
+ Copy(A_num, buff+M, M+1);
+
+ E_UTIL_synthesis(1, A_den, buff+M, buff+M, L_SUBFR, buff, 0, M);
+
+ /*Compute tilt of formant enhancement*/
+ tilt = extract_l(L_shr(get_gain(buff+M+1, buff+M, L_SUBFR-1),1));
+
+ /*Combine tilt of code and fe*/
+ tmp = 0;
+ move16();
+ /*mu = 0.5f*tilt_code-0.25f*tilt;*/
+ mu = sub(shr(tilt_code,1),shr(tilt,2));
+ preemph_copy_fx(code, code, mu, L_SUBFR, &tmp);
+ }
+ ELSE
+ {
+ Copy( code, buff, L_SUBFR );
+
+ Overflow = 0;
+ move16();
+ Residu3_lc_fx(A_num, M, buff, code, L_SUBFR, shift);
+ {
+ syn_filt_s_lc_fx(shift, A_den, code, code, L_SUBFR);
+ }
+ }
+ }
+
+ return;
+}
+
diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c
new file mode 100644
index 0000000000000000000000000000000000000000..a05236eb85670703cc1da268d1b371d434289ba3
--- /dev/null
+++ b/lib_com/cldfb.c
@@ -0,0 +1,1661 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+/*!
+ \file
+ \brief Complex cldfb analysis/synthesis, $Revision: 1214 $
+ This module contains the cldfb filterbank for analysis [ cplxAnalysisCldfbFiltering() ] and
+ synthesis [ cplxSynthesisCldfbFiltering() ]. It is a polyphase implementation of a complex
+ exponential modulated filter bank. The analysis part usually runs at half the sample rate
+ than the synthesis part. (So called "dual-rate" mode.)
+
+ \anchor PolyphaseFiltering About polyphase filtering
+ The polyphase implementation of a filterbank requires filtering at the input and output.
+ This is implemented as part of cplxAnalysisCldfbFiltering() and cplxSynthesisCldfbFiltering().
+
+*/
+
+#include "stl.h"
+#include "cnst_fx.h"
+#include "stat_com.h"
+#include "rom_com_fx.h"
+#include "basop_util.h"
+#include "prot_fx.h"
+#include
+
+#define STATE_BUFFER_SIZE ( 9+16 )
+
+#define CLDFB_NO_POLY ( 5 )
+#define SYN_FILTER_HEADROOM ( 1 )
+
+#define CLDFB_LDCLDFB_PFT_SCALE ( 0 )
+#define CLDFB_CLDFB80_O24_PFT_SCALE ( 1 )
+#define CLDFB_CLDFB80_O5_PFT_SCALE ( 1 )
+#define CLDFB_CLDFB80_PFT_SCALE ( 1 )
+
+
+
+#define SYN_FILTER_HEADROOM_1MS ( 2 )
+#define SYN_FILTER_HEADROOM_2MS ( 2 )
+#define SYN_FILTER_HEADROOM_2_5MS ( 2 )
+#define SYN_FILTER_HEADROOM_8MS ( 1 )
+
+#define N8 ( 4 )
+#define N10 ( 5 )
+#define N16 ( 8 )
+#define N20 ( 10 )
+#define N30 ( 15 )
+#define N32 ( 16 )
+#define N40 ( 20 )
+#define N60 ( 30 )
+
+static void
+cldfb_init_proto_and_twiddles(HANDLE_CLDFB_FILTER_BANK hs);
+
+#define cplxMpyS(yr,yi,xr,xi,cr,ci,syr,syi,sxr,sxi,CL_x,CL_z,C_c) CL_x = CL_form( *xr, *xi ); \
+ C_c = C_form( *cr, *ci ); \
+ CL_z = CL_mult_32x16( CL_x, C_c ); \
+ *yr = CL_Extract_real( CL_z ); \
+ *yi = CL_Extract_imag( CL_z ); \
+ yr+=syr, yi+=syi, xr+=sxr, xi+=sxi, cr++, ci++
+
+#define cplxMpy(ryr,ryi,iyr,iyi,rxr,rxi,ixr,ixi,cr,ci,g,sx,sr,CL_x,CL_ry,CL_iy,C_c) CL_x = CL_form( *rxr, *rxi ); \
+ C_c = C_form( *cr, *ci ); \
+ CL_ry = CL_mult_32x16( CL_x, C_c ); \
+ CL_x = CL_form( *ixr, *ixi ); \
+ CL_iy = CL_mult_32x16( CL_x, C_c ); \
+ CL_ry = CL_scale_t( CL_ry, g ); \
+ CL_iy = CL_scale_t( CL_iy, g ); \
+ ryr = CL_Extract_real( CL_ry ); \
+ ryi = CL_Extract_imag( CL_ry ); \
+ iyr = CL_Extract_real( CL_iy ); \
+ iyi = CL_Extract_imag( CL_iy ); \
+ rxr+=sx, rxi+=sx, ixr+=sx, ixi+=sx, cr+=sr, ci+=sr
+
+#define add1(y1,y2,y3,y4,rr12,ri12,ir12,ii12,s) *y1 = round_fx(L_shl(L_negate(L_add(rr12,ii12)),s)); \
+ *y2 = round_fx(L_shl(L_negate(L_add(ri12,ir12)),s)); \
+ *y3 = round_fx(L_shl(L_sub(rr12,ii12),s)); \
+ *y4 = round_fx(L_shl(L_sub(ir12,ri12),s)); \
+ y1+=2, y2-=2, y3-=2, y4+=2
+
+
+#define add2(y1,y2,y3,y4,rr12,ri12,ir12,ii12,s) *y1 = round_fx(L_shl(L_add(ri12,ir12),s)); \
+ *y2 = round_fx(L_shl(L_add(rr12,ii12),s)); \
+ *y3 = round_fx(L_shl(L_sub(ir12,ri12),s)); \
+ *y4 = round_fx(L_shl(L_sub(rr12,ii12),s)); \
+ y1+=2, y2-=2, y3-=2, y4+=2
+
+#define ptrUpdate16(y11,y12,y13,y14,r11,x11,x12,x13,x14,r12,y21,y22,y23,y24,r21,x21,x22,x23,x24,r22) \
+ y11 += 2*N8, y12 -= 2*N8, y13 -= 2*N8, y14 += 2*N8, r11 -= 1*N8; \
+ x11 -= 2*N8, x12 -= 2*N8, x13 -= 2*N8, x14 -= 2*N8, r12 -= 1*N8; \
+ y21 += 2*N8, y22 -= 2*N8, y23 -= 2*N8, y24 += 2*N8, r21 += 1*N8; \
+ x21 += 2*N8, x22 += 2*N8, x23 += 2*N8, x24 += 2*N8, r22 += 1*N8
+
+#define ptrUpdate20(y11,y12,y13,y14,r11,x11,x12,x13,x14,r12,y21,y22,y23,y24,r21,x21,x22,x23,x24,r22) \
+ y11 += 2*N10, y12 -= 2*N10, y13 -= 2*N10, y14 += 2*N10, r11 -= 1*N10; \
+ x11 -= 2*N10, x12 -= 2*N10, x13 -= 2*N10, x14 -= 2*N10, r12 -= 1*N10; \
+ y21 += 2*N10, y22 -= 2*N10, y23 -= 2*N10, y24 += 2*N10, r21 += 1*N10; \
+ x21 += 2*N10, x22 += 2*N10, x23 += 2*N10, x24 += 2*N10, r22 += 1*N10
+
+
+
+
+static void cplxMultAdd10_1(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4,
+ Word32 *rXR, Word32 *rXI, Word32 *iXR, Word32 *iXI,
+ const Word16 *cr, const Word16 *ci, Word16 gv, Word16 s,
+ Word16 sx, Word16 sr)
+{
+ Word32 rr12, ri12, ir12, ii12;
+ cmplx CL_x,CL_ry, CL_iy;
+ cmplx_s C_c;
+
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr,CL_x,CL_ry, CL_iy,C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr,CL_x,CL_ry, CL_iy,C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+
+}
+
+static void cplxMultAdd10_2(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4,
+ Word32 *rXR, Word32 *rXI, Word32 *iXR, Word32 *iXI,
+ const Word16 *cr, const Word16 *ci, Word16 gv, Word16 s,
+ Word16 sx, Word16 sr)
+{
+ Word32 rr12, ri12, ir12, ii12;
+ cmplx CL_x,CL_ry, CL_iy;
+ cmplx_s C_c;
+
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+
+}
+
+
+static void cplxMultAdd20_1(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4,
+ Word32 *rXR, Word32 *rXI, Word32 *iXR, Word32 *iXI,
+ const Word16 *cr, const Word16 *ci, Word16 gv, Word16 s,
+ Word16 sx, Word16 sr)
+{
+ Word32 rr12, ri12, ir12, ii12;
+ cmplx CL_x,CL_ry, CL_iy;
+ cmplx_s C_c;
+
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add1(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+
+
+}
+
+static void cplxMultAdd20_2(Word16 *rY1, Word16 *rY2, Word16 *rY3, Word16 *rY4,
+ Word32 *rXR, Word32 *rXI, Word32 *iXR, Word32 *iXI,
+ const Word16 *cr, const Word16 *ci, Word16 gv, Word16 s,
+ Word16 sx, Word16 sr)
+{
+ Word32 rr12, ri12, ir12, ii12;
+ cmplx CL_x,CL_ry, CL_iy;
+ cmplx_s C_c;
+
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+ cplxMpy(rr12, ri12, ir12, ii12, rXR, rXI, iXR, iXI, cr, ci, gv, sx, sr, CL_x, CL_ry, CL_iy, C_c);
+ add2(rY1, rY2, rY3, rY4, rr12, ri12, ir12, ii12, s);
+
+}
+
+/* calcModulation
+
+ Parameters:
+ *rYR O: pointer to real output samples (DST)
+ *rYI O: pointer to imaginary output samples (DST)
+ *rXR I: pointer to real input samples (DST)
+ *rXI I: pointer to imaginary input samples (DST)
+ srYR I: offset for update of pointer to real output samples (DST)
+ srYI I: offset for update of pointer to imaginary output samples (DST)
+ srXR I: offset for update of pointer to real input samples (DST)
+ srXI I: offset for update of pointer to imaginary input samples (DST)
+ *iYR O: pointer to real output samples (DCT)
+ *iYI O: pointer to imaginary output samples (DCT)
+ *iXR I: pointer to real input samples (DCT)
+ *iXI I: pointer to imaginary input samples (DCT)
+ siYR I: offset for update of pointer to real output samples (DCT)
+ siYI I: offset for update of pointer to imaginary output samples (DCT)
+ siXR I: offset for update of pointer to real input samples (DCT)
+ siXI I: offset for update of pointer to imaginary input samples (DCT)
+ m I: processed cldfb bands
+
+ Function:
+ The function applies for each cldfb length a unrolled complex modulation
+
+ Returns:
+ void
+*/
+static void calcModulation( Word32 *rYR,
+ Word32 *rYI,
+ Word32 *rXR,
+ Word32 *rXI,
+ Word16 srYR,
+ Word16 srYI,
+ Word16 srXR,
+ Word16 srXI,
+ Word32 *iYR,
+ Word32 *iYI,
+ Word32 *iXR,
+ Word32 *iXI,
+ Word16 siYR,
+ Word16 siYI,
+ Word16 siXR,
+ Word16 siXI,
+ const Word16 *rRotVctr,
+ const Word16 *iRotVctr,
+ Word16 m
+ )
+{
+ cmplx CL_x,CL_z;
+ cmplx_s C_c;
+ int i;
+ int lc = m >> 1;
+
+ const Word16 *cr = rRotVctr;
+ const Word16 *ci = iRotVctr;
+
+ for(i=0;ino_channels;
+ move16();
+ L2 = shl(m,1);
+ m2 = shr(m,1);
+ M4 = shr(m,2);
+ M4 = sub(m2,M4);
+
+ L3 = sub(L2,m2);
+ L4 = add(L2,m2);
+
+ M0M2 = sub(0,m2);
+ M2M1 = sub(m2,1);
+ L3M1 = sub(L3,1);
+ L4M1 = sub(L4,1);
+
+ rBuffer = &pWorkBuffer[0];
+ iBuffer = &pWorkBuffer[m];
+
+ rRotVctr = cldfbBank->rRotVctr;
+ iRotVctr = cldfbBank->iRotVctr;
+
+ pStates = cldfbBank->FilterStates;
+ pStates1 = &pStates[L3M1];
+ pStates2 = &pStates[L3];
+ pStates3 = &pStates[m2];
+ pStates4 = &pStates[M2M1];
+ pStates5 = &pStates[L4M1];
+ pStates6 = &pStates[M0M2];
+
+ p_stride = CLDFB_NO_POLY;
+ pFilter = &cldfbBank->p_filter[p_stride - CLDFB_NO_POLY];
+ pFilter1 = &pFilter[p_stride*L3M1];
+ pFilter2 = &pFilter[p_stride*L3];
+ pFilter3 = &pFilter[p_stride*m2];
+ pFilter4 = &pFilter[p_stride*M2M1];
+ pFilter5 = &pFilter[p_stride*L4M1];
+ pFilter6 = &pFilter[p_stride*M0M2];
+
+ nSamples = i_mult(nTimeSlots, cldfbBank->no_channels);
+ nSamplesUpd = i_mult(cldfbBank->no_col, cldfbBank->no_channels);
+ offset = sub(sub(cldfbBank->p_filter_length, cldfbBank->no_channels),cldfbBank->zeros);
+
+ /* Determine states scale */
+ scale = -15;
+ move16();
+ k = 0;
+ move16();
+ FOR (i=0; ino_channels)
+ {
+ cldfbBank->FilterStates_e[k] = cldfbBank->FilterStates_e[k+cldfbBank->no_col];
+ move16();
+ assert((size_t)k < sizeof(cldfbBank->FilterStates_e)/sizeof(cldfbBank->FilterStates_e[0]));
+ scale = s_max(scale, cldfbBank->FilterStates_e[k]);
+ k = add(k,1);
+ }
+ FOR (i=0; ino_channels)
+ {
+ cldfbBank->FilterStates_e[k] = timeIn_e;
+ move16();
+ assert((size_t)k < sizeof(cldfbBank->FilterStates_e)/sizeof(cldfbBank->FilterStates_e[0]));
+ scale = s_max(scale, cldfbBank->FilterStates_e[k]);
+ k = add(k,1);
+ }
+ i = s_max(scale, timeIn_e);
+ scale = sub(cldfbBank->FilterStates_eg, i);
+ cldfbBank->FilterStates_eg = i;
+ move16();
+
+ /* if nTimeSlots==0, make sure we have a value. */
+ scaleFactor->lb_scale = add(cldfbBank->anaScalefactor, add(cldfbBank->FilterStates_eg, 5));
+ move16();
+
+ /* move and scale filter states */
+ FOR (i=0; iFilterStates_eg);
+ FOR (i=0; ilb_scale = add(cldfbBank->anaScalefactor, add(cldfbBank->FilterStates_eg, scale));
+ move16();
+
+ /* FFT of DCT IV */
+ BASOP_cfft((cmplx *)iBuffer, m2, &scale, workBuffer);
+
+ /* post modulation of DST IV and DCT IV */
+ calcModulation(&rAnalysis[k][m-1], &rAnalysis[k][0], &rBuffer[0], &rBuffer[1],-2, 2, 2, 2,
+ &iAnalysis[k][0], &iAnalysis[k][m-1], &iBuffer[0], &iBuffer[1], 2,-2, 2, 2,
+ rRotVctr, iRotVctr, m);
+
+
+ /* update states pointer */
+ pStates1 = &pStates1[cldfbBank->no_channels];
+ pStates2 = &pStates2[cldfbBank->no_channels];
+ pStates3 = &pStates3[cldfbBank->no_channels];
+ pStates5 = &pStates5[cldfbBank->no_channels];
+ pStates4 = &pStates4[cldfbBank->no_channels];
+ pStates6 = &pStates6[cldfbBank->no_channels];
+ }
+
+}
+
+
+/* cldfbSynthesisFiltering
+
+ Parameters:
+ cldfbBank I/O: handle to analysis CLDFB filter struct
+ **rAnalysis I: matrix holding the real part of the subband samples
+ **iAnalysis I: matrix holding the imaginary part of the subband samples
+ *scaleFactor I: pointer to cldfb scalefactor struct
+ ov_len I: determines overlapping area in time slots (obsolete)
+ *timeOut O: pointer to time domain data
+ stride I: stride for time domain data
+ *pWorkBuffer I: pointer to scratch buffer, needed for buffer of size 2*cldfbbands*Word32 + 2*cldfbbands*Word16
+
+ Function:
+ Performs inverse complex-valued subband filtering of the subband samples in rAnalysis and iAnalysis
+ and stores the time domain data in timeOut
+
+ Returns:
+ void
+*/
+void
+cldfbSynthesisFiltering( HANDLE_CLDFB_FILTER_BANK cldfbBank,
+ Word32 **rAnalysis,
+ Word32 **iAnalysis,
+ const CLDFB_SCALE_FACTOR *scaleFactor,
+ Word16 *timeOut,
+ const Word16 timeOut_e,
+ const Word16 nTimeSlots,
+ Word32 *pWorkBuffer
+ )
+{
+ Word16 i;
+ Word16 k;
+ Word16 L2;
+ Word16 m;
+ Word16 m2;
+ Word16 Lz;
+ Word16 Mz;
+ Word32 acc;
+ Word16 offset1;
+ Word16 offset2;
+ Word16 channels0;
+ Word16 channels1;
+ Word16 channels2;
+ Word16 channels3;
+ Word16 channels4;
+ Word16 statesSizeM1;
+ Word16 statesSizeM2;
+ Word16 stride;
+
+ Word16 scale, scaleMod;
+ Word16 outScale;
+ Word16 scaleLB;
+ Word16 scaleHB;
+
+ Word32 *rAnalysisS;
+ Word32 *iAnalysisS;
+
+ Word32 *rBuffer;
+ Word32 *iBuffer;
+ Word16 *nBuffer;
+
+ Word16 *pStates;
+ Word16 *pStatesI;
+ Word16 *pStatesR;
+
+ const Word16 *pFilterS;
+ const Word16 *pFilterM;
+
+ const Word16 *rRotVctr;
+ const Word16 *iRotVctr;
+ Word32 workBuffer[2*BASOP_CFFT_MAX_LENGTH];
+
+ m = cldfbBank->no_channels;
+ move16();
+ L2 = shl(m,1);
+ m2 = shr(m,1);
+ Lz = s_min(cldfbBank->lsb, sub(m,cldfbBank->bandsToZero));
+ Mz = s_min(cldfbBank->usb, sub(m,cldfbBank->bandsToZero));
+ stride = 1; /* constant */
+
+ channels0 = sub(m,cldfbBank->zeros);
+ channels1 = sub(m,1);
+ channels2 = shl(m,1);
+ channels3 = add(m,channels2);
+ channels4 = shl(channels2,1);
+
+ statesSizeM1 = sub(shl(cldfbBank->p_filter_length,1),m);
+ statesSizeM2 = sub(statesSizeM1,m);
+
+ offset1 = sub(channels1,cldfbBank->zeros);
+ offset2 = add(offset1,cldfbBank->no_channels);
+
+ rBuffer = &pWorkBuffer[0];
+ iBuffer = &pWorkBuffer[m];
+ nBuffer = (Word16*)(&pWorkBuffer[L2]);
+
+ rAnalysisS = &pWorkBuffer[3*m];
+ iAnalysisS = &pWorkBuffer[4*m];
+
+ rRotVctr = cldfbBank->rRotVctr;
+ iRotVctr = cldfbBank->iRotVctr;
+
+ scale = scaleFactor->lb_scale;
+ move16();
+ if ( NE_16(Lz, Mz))
+ {
+ scale = s_max(scale, scaleFactor->hb_scale);
+ }
+ scaleLB = limitScale32(sub(scale, scaleFactor->lb_scale));
+ scaleHB = limitScale32(sub(scale, scaleFactor->hb_scale));
+
+ outScale = cldfbBank->synFilterHeadroom;
+ move16();
+
+ scaleMod = sub(add(scale, cldfbBank->outScalefactor), outScale);
+
+ /* Increase CLDFB synthesis states for low level signals */
+ IF ( LT_16(scale, 8))
+ {
+ scaleMod = add(scaleMod, 2);
+ outScale = sub(outScale, 2);
+ }
+ scaleMod = sub(scaleMod, timeOut_e);
+ scale = add(outScale, timeOut_e);
+ IF ( NE_16(scale, cldfbBank->FilterStates_eg))
+ {
+ Scale_sig(cldfbBank->FilterStates, statesSizeM2, sub(cldfbBank->FilterStates_eg, scale));
+ cldfbBank->FilterStates_eg = scale;
+ move16();
+ }
+
+ FOR (k=0; k < nTimeSlots; k++)
+ {
+ {
+ FOR (i=0; i < Lz; i+=2)
+ {
+ rAnalysisS[i] = L_shr(rAnalysis[k][i],scaleLB);
+ move32();
+ iAnalysisS[i] = L_negate(L_shr(iAnalysis[k][i],scaleLB));
+ move32();
+ }
+
+ IF ( LT_16(i,Mz))
+ {
+ FOR ( ; i < Mz; i+=2)
+ {
+ rAnalysisS[i] = L_shr(rAnalysis[k][i],scaleHB);
+ move32();
+ iAnalysisS[i] = L_negate(L_shr(iAnalysis[k][i],scaleHB));
+ move32();
+ }
+ }
+
+ IF ( LT_16(i,m))
+ {
+ FOR ( ; i < m; i+=2)
+ {
+ rAnalysisS[i] = L_deposit_l(0);
+ iAnalysisS[i] = L_deposit_l(0);
+ }
+ }
+
+ FOR (i=1; i < Lz; i+=2)
+ {
+ rAnalysisS[i] = L_shr(rAnalysis[k][i],scaleLB);
+ move32();
+ iAnalysisS[i] = L_shr(iAnalysis[k][i],scaleLB);
+ move32();
+ }
+
+ IF ( LT_16(i,Mz))
+ {
+ FOR ( ; i < Mz; i+=2)
+ {
+ rAnalysisS[i] = L_shr(rAnalysis[k][i],scaleHB);
+ move32();
+ iAnalysisS[i] = L_shr(iAnalysis[k][i],scaleHB);
+ move32();
+ }
+ }
+
+ IF ( LT_16(i,m))
+ {
+ FOR ( ; i < m; i+=2)
+ {
+ rAnalysisS[i] = L_deposit_l(0);
+ iAnalysisS[i] = L_deposit_l(0);
+ }
+ }
+ }
+
+ /* pre modulation */
+ calcModulation(&rBuffer[0], &rBuffer[1], &rAnalysisS[0], &rAnalysisS[m-1], 2, 2, 2,-2,
+ &iBuffer[0], &iBuffer[1], &iAnalysisS[0], &iAnalysisS[m-1], 2, 2, 2,-2,
+ rRotVctr, iRotVctr, m);
+
+
+ /* FFT of DST IV */
+ scale = 0;
+ move16();
+ BASOP_cfft((cmplx *)rBuffer, m2, &scale, workBuffer);
+
+ /* FFT of DCT IV */
+ scale = scaleMod;
+ move16();
+ BASOP_cfft((cmplx *)iBuffer, m2, &scale, workBuffer);
+
+ /* post modulation and folding */
+ calcModulationAndFolding(nBuffer, rBuffer, iBuffer, rRotVctr, iRotVctr, cldfbBank->synGain, scale, m, m2);
+
+ /* prototype filter */
+ pStates = &cldfbBank->FilterStates[k*L2];
+ pFilterS = &cldfbBank->p_filter[0];
+ pFilterM = &cldfbBank->p_filter[shr(cldfbBank->p_filter_length,1)];
+
+ FOR (i=0; i < channels0; i++)
+ {
+ pStatesI = &pStates[i];
+ pStatesR = &pStates[i+channels3];
+
+ acc = L_mult( *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesR += channels4;
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesR += channels4;
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesR += channels4;
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, nBuffer[channels1-i], *pFilterM++);
+
+ BASOP_SATURATE_WARNING_OFF
+ timeOut[(offset1-i)*stride] = round_fx(L_shl(acc,outScale));
+ BASOP_SATURATE_WARNING_ON
+ }
+
+ FOR ( ; ino_channels; i++)
+ {
+ pStatesI = &pStates[i+channels2];
+ pStatesR = &pStates[i+channels2+channels3];
+
+ acc = L_mult( *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesR += channels4;
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesR += channels4;
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+ pStatesR += channels4;
+ pStatesI += channels4;
+
+ acc = L_mac(acc, *pStatesI, *pFilterS++);
+ acc = L_mac(acc, *pStatesR, *pFilterM++);
+
+ acc = L_mac(acc, nBuffer[channels1+m-i], *pFilterS++);
+ pFilterM++;
+
+ BASOP_SATURATE_WARNING_OFF
+ timeOut[(offset2-i)*stride] = round_fx(L_shl(acc,outScale));
+ BASOP_SATURATE_WARNING_ON
+ }
+
+ FOR (i=0; ino_channels; i++)
+ {
+ pStates[statesSizeM1+i] = nBuffer[channels1-i];
+ move16();
+ pStates[statesSizeM2+i] = nBuffer[channels1+m-i];
+ move16();
+ }
+
+ timeOut = &timeOut[m*stride];
+ }
+
+ /* move filter states */
+ Copy(&cldfbBank->FilterStates[i_mult(nTimeSlots,L2)], cldfbBank->FilterStates, statesSizeM2);
+ set16_fx(&cldfbBank->FilterStates[statesSizeM2],0,L2);
+
+}
+
+
+/*-------------------------------------------------------------------*
+ * configureClfdb()
+ *
+ * configures a CLDFB handle
+ *--------------------------------------------------------------------*/
+
+void configureCldfb ( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< Returns handle */
+ const Word16 no_channels, /*!< Number of channels (bands) */
+ const Word16 frameSize /*!< FrameSize */
+ )
+{
+
+ h_cldfb->no_channels = no_channels;
+ move16();
+ assert(h_cldfb->no_channels >= 10);
+ h_cldfb->no_col = div_l(frameSize,shr(h_cldfb->no_channels,1));
+
+ /* was cldfbInitFilterBank()*/
+ h_cldfb->anaScalefactor = 0;
+ move16();
+ h_cldfb->synScalefactor = 0;
+ move16();
+ h_cldfb->bandsToZero = 0;
+ move16();
+ h_cldfb->filtermode = 0;
+ move16();
+ h_cldfb->memory = 0;
+ move16();
+ h_cldfb->memory_length = 0;
+ move16();
+
+ h_cldfb->p_filter_length = i_mult(10,h_cldfb->no_channels);
+ move16();
+
+ h_cldfb->flags = s_or(h_cldfb->flags,CLDFB_FLAG_2_5MS_SETUP);
+ h_cldfb->filterScale = CLDFB_CLDFB80_PFT_SCALE;
+ move16();
+
+ h_cldfb->zeros = 0;
+ move16();
+ h_cldfb->synFilterHeadroom = SYN_FILTER_HEADROOM_2_5MS;
+ move16();
+
+ cldfb_init_proto_and_twiddles (h_cldfb);
+
+ h_cldfb->lsb = no_channels;
+ move16();
+ h_cldfb->usb = s_min(no_channels, h_cldfb->no_channels); /* Does this make any sense? in the previous implemenatation lsb, usb and no_channels are all maxCldfbBands */ move16();
+
+ h_cldfb->FilterStates = (void*)h_cldfb->FilterStates;
+ h_cldfb->outScalefactor = h_cldfb->synScalefactor;
+ move16();
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * openClfdb()
+ *
+ * open and configures a CLDFB handle
+ *--------------------------------------------------------------------*/
+void openCldfb ( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< Returns handle */
+ const Word16 type, /*!< analysis or synthesis */
+ const Word16 maxCldfbBands, /*!< number of cldfb bands */
+ const Word16 frameSize /*!< FrameSize */
+ )
+{
+ HANDLE_CLDFB_FILTER_BANK hs;
+
+ hs = (HANDLE_CLDFB_FILTER_BANK) calloc(1, sizeof (struct CLDFB_FILTER_BANK));
+
+
+ hs->type = type;
+ move16();
+
+ IF (type == CLDFB_ANALYSIS)
+ {
+ hs->FilterStates = (Word16 *) calloc(STATE_BUFFER_SIZE*maxCldfbBands, sizeof (Word16));
+ }
+ ELSE
+ {
+ hs->FilterStates = (Word16 *) calloc( 2 * STATE_BUFFER_SIZE * maxCldfbBands, sizeof (Word16));
+ }
+ hs->flags &= ~CLDFB_FLAG_KEEP_STATES;
+
+ configureCldfb (hs, maxCldfbBands, frameSize );
+
+ hs->memory = NULL;
+ hs->memory_length = 0;
+ move16();
+
+ IF( hs->type == CLDFB_ANALYSIS)
+ {
+ test();
+ IF ( (s_and(hs->flags,CLDFB_FLAG_KEEP_STATES) == 0) && (hs->FilterStates != 0) )
+ {
+ set16_fx(hs->FilterStates, 0, i_mult(STATE_BUFFER_SIZE,hs->no_channels));
+ set16_fx(hs->FilterStates_e, 0, sizeof(hs->FilterStates_e)/sizeof(hs->FilterStates_e[0]));
+
+ hs->FilterStates_eg = 0;
+ move16();
+ }
+ }
+ ELSE IF (hs->type == CLDFB_SYNTHESIS )
+ {
+ IF ( hs->FilterStates != 0 )
+ {
+ IF ( s_and(hs->flags,CLDFB_FLAG_KEEP_STATES) == 0 )
+ {
+ set16_fx(hs->FilterStates, 0, i_mult( shl(STATE_BUFFER_SIZE,1), hs->no_channels));
+ }
+ }
+ hs->FilterStates_eg = 0;
+ move16();
+ }
+
+ if (h_cldfb != NULL)
+ {
+ *h_cldfb = hs;
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+* resampleCldfb()
+*
+* Change sample rate of filter bank
+*--------------------------------------------------------------------*/
+void resampleCldfb (HANDLE_CLDFB_FILTER_BANK hs,
+ const Word16 newCldfbBands,
+ const Word16 frameSize,
+ const Word8 firstFrame
+ )
+
+{
+ Word16 timeOffset;
+ Word16 timeOffsetOld;
+ Word16 noChannelsOld;
+
+ noChannelsOld = hs->no_channels;
+ move16();
+ timeOffsetOld = sub(sub(hs->p_filter_length,hs->no_channels),hs->zeros);
+
+ /* change all CLDFB bank parameters that depend on the no of channels */
+ hs->flags = s_or(hs->flags,CLDFB_FLAG_KEEP_STATES);
+ move16();
+
+ /* new settings */
+ configureCldfb (hs, newCldfbBands, frameSize);
+
+ /* resample cldfb state buffer */
+ timeOffset = sub(sub(hs->p_filter_length,hs->no_channels),hs->zeros);
+
+ IF( firstFrame == 0 )
+ {
+ /*low complexity-resampling only stored previous samples that are needed for next frame modulation */
+ lerp(hs->FilterStates+(noChannelsOld*hs->no_col), hs->FilterStates+(noChannelsOld*hs->no_col), timeOffset, timeOffsetOld);
+ Copy(hs->FilterStates+(noChannelsOld*hs->no_col), hs->FilterStates+frameSize, timeOffset);
+ }
+
+ return;
+}
+
+/*
+ AnalysisPostSpectrumScaling_Fx
+
+ Parameters:
+ cldfbBank I: CLDFB handle
+ **rSubband32 I: matrix holding real part of the CLDFB subsamples
+ **iSubband32 I: matrix holding imaginary part of the CLDFB subsamples
+ **rSubband16 O: matrix holding real part of the CLDFB subsamples
+ **iSubband16 O: matrix holding imaginary part of the CLDFB subsamples
+ *cldfbScale O: cldfb lowband scalefactor
+
+ Function:
+ performs dynamic spectrum scaling for all subband
+
+ Returns:
+ headroom
+*/
+Word16
+AnalysisPostSpectrumScaling_Fx (HANDLE_CLDFB_FILTER_BANK cldfbBank, /*!< Handle of cldfbBank */
+ Word32 **rSubband32, /*!< Real bands */
+ Word32 **iSubband32, /*!< Imaginary bands */
+ Word16 **rSubband16, /*!< Real bands */
+ Word16 **iSubband16, /*!< Imaginary bands */
+ Word16 *cldfbScale /*!< CLDFB lowband scalefactor */
+ )
+{
+ Word16 i;
+ Word16 j;
+ Word16 headRoom;
+
+
+
+ headRoom = BASOP_util_norm_l_dim2_cplx (
+ (const Word32 * const*) rSubband32,
+ (const Word32 * const*) iSubband32,
+ 0,
+ cldfbBank->no_channels,
+ 0,
+ cldfbBank->no_col
+ );
+
+ FOR (i=0; i < cldfbBank->no_col; i++)
+ {
+ FOR (j=0; j < cldfbBank->no_channels; j++)
+ {
+ rSubband16[i][j] = round_fx(L_shl(rSubband32[i][j], headRoom));
+ iSubband16[i][j] = round_fx(L_shl(iSubband32[i][j], headRoom));
+ }
+ }
+
+ *cldfbScale = add(*cldfbScale,headRoom);
+ move16();
+
+
+ return headRoom;
+}
+
+
+/*-------------------------------------------------------------------*
+* analysisCLDFBEncoder()
+*
+* Encoder CLDFB analysis + energy stage
+*--------------------------------------------------------------------*/
+
+void analysisCldfbEncoder_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *timeIn,
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX],
+ Word16 *enerBuffSum_exp,
+ CLDFB_SCALE_FACTOR * scale
+)
+{
+ Word16 i;
+ CLDFB_SCALE_FACTOR enerScale;
+ Word32 *ppBuf_Real[CLDFB_NO_COL_MAX];
+ Word32 *ppBuf_Imag[CLDFB_NO_COL_MAX];
+ Word16 *ppBuf_Real16[CLDFB_NO_COL_MAX];
+ Word16 *ppBuf_Imag16[CLDFB_NO_COL_MAX];
+ Word32 workBuffer[256];
+ Word16 num_slots = 1;
+
+ FOR (i=0; icldfbAna_Fx,
+ ppBuf_Real,
+ ppBuf_Imag,
+ scale,
+ timeIn,
+ 0,
+ CLDFB_NO_COL_MAX,
+ workBuffer
+ );
+
+ enerScale.lb_scale = negate(scale->lb_scale);
+ enerScale.lb_scale16 = negate(scale->lb_scale);
+
+ /* get 16bit respresentation */
+ AnalysisPostSpectrumScaling_Fx (
+ st_fx->cldfbAna_Fx,
+ ppBuf_Real,
+ ppBuf_Imag,
+ ppBuf_Real16,
+ ppBuf_Imag16,
+ &enerScale.lb_scale16
+ );
+
+ /* get the energy */
+ GetEnergyCldfb( &st_fx->energyCoreLookahead_Fx,
+ &st_fx->sf_energyCoreLookahead_Fx,
+ num_slots,
+ ppBuf_Real16,
+ ppBuf_Imag16,
+ enerScale.lb_scale16,
+ st_fx->cldfbAna_Fx->no_channels,
+ st_fx->cldfbAna_Fx->no_col,
+ &st_fx->currEnergyHF_fx,
+ &st_fx->currEnergyHF_e_fx,
+ enerBuffSum,
+ enerBuffSum_exp,
+ &st_fx->tecEnc
+ );
+
+ return;
+}
+
+void
+GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q(*sf_energyLookahead) | pointer to the result in the core look-ahead slot */
+ Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot */
+ const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */
+ Word16 **realValues, /*!< i: Q(sf_Values) | the real part of the CLDFB subsamples */
+ Word16 **imagValues, /*!< i: Q(sf_Values) | the imaginary part of the CLDFB subsamples */
+ Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */
+ Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */
+ Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */
+ Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */
+ Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */
+ Word32 *energyValuesSum, /*!< o: Q(2*sf_Values-4) | pointer to sum array of energy values, not initialized*/
+ Word16 *energyValuesSum_Exp,/*!< o: pointer to exponents of energyValuesSum, not initialized */
+ HANDLE_TEC_ENC_FX hTecEnc
+ )
+{
+ Word16 j;
+ Word16 k;
+ Word16 s;
+ Word16 sm;
+ Word32 nrg;
+ Word16 numberColsL;
+ Word16 numberBandsM;
+ Word16 numberBandsM20;
+ Word32 energyValues[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX];
+ Word16 energyValuesSumE[CLDFB_NO_CHANNELS_MAX];
+ Word16 freqTable[2] = {20, 40};
+
+
+ FOR (k=0; kloBuffer,
+ hTecEnc->hiTempEnv,
+ ScaleX2
+ );
+ }
+
+ FOR (j=0; j< numberBands; j++)
+ {
+ energyValuesSum[j] = L_deposit_l(0);
+ energyValuesSumE[j] = 31;
+ move16();
+ FOR (k=0; k value 0x40000000, scale 44 */
+ *energyLookahead = L_add(L_shr(nrg, sub(s, sm)),
+ L_shr(0x40000000, s_max(-31, s_min(31, sub(44, sm)))));
+ move32();
+ BASOP_SATURATE_WARNING_ON
+ *sf_energyLookahead = sm;
+ move16();
+
+ return;
+ }
+
+
+
+ *energyHF = 0x40000000;
+ move32();
+ *energyHF_Exp = 17;
+ move16();
+
+
+}
+
+
+Word16
+CLDFB_getNumChannels(Word32 sampleRate)
+{
+
+ Word16 nChannels = 0;
+
+
+ SWITCH (sampleRate)
+ {
+ case 48000:
+ move16();
+ nChannels = 60;
+ BREAK;
+ case 32000:
+ move16();
+ nChannels = 40;
+ BREAK;
+ case 25600:
+ move16();
+ nChannels = 32;
+ BREAK;
+ case 16000:
+ move16();
+ nChannels = 20;
+ BREAK;
+ case 12800:
+ move16();
+ nChannels = 16;
+ BREAK;
+ case 8000:
+ move16();
+ nChannels = 10;
+ BREAK;
+ }
+
+ return (nChannels);
+}
+
+/*-------------------------------------------------------------------*
+* cldfb_get_memory_length()
+*
+* Return length of filter state for recovery
+*--------------------------------------------------------------------*/
+static Word16
+cldfb_get_memory_length (HANDLE_CLDFB_FILTER_BANK hs)
+{
+ IF (EQ_16(hs->type,CLDFB_ANALYSIS))
+ {
+ return (i_mult(hs->no_channels,STATE_BUFFER_SIZE));
+ }
+ ELSE
+ {
+ return (i_mult(hs->no_channels,(9*2)) );
+ }
+}
+
+/*-------------------------------------------------------------------*
+* GetEnergyCldfb()
+*
+* Remove handle
+*--------------------------------------------------------------------*/
+void
+deleteCldfb (HANDLE_CLDFB_FILTER_BANK * h_cldfb) /* i: cldfb handle */
+{
+ IF ( *h_cldfb != NULL )
+ {
+ IF ( (*h_cldfb)->FilterStates != NULL )
+ {
+ free((*h_cldfb)->FilterStates);
+ }
+ free(*h_cldfb);
+ }
+ *h_cldfb = NULL;
+}
+
+
+/*-------------------------------------------------------------------*
+* cldfb_init_proto_and_twiddles()
+*
+* Initializes rom pointer
+*--------------------------------------------------------------------*/
+static void
+cldfb_init_proto_and_twiddles(HANDLE_CLDFB_FILTER_BANK hs) /* i: cldfb handle */
+{
+
+ /*find appropriate set of rotVecs*/
+ SWITCH(hs->no_channels)
+ {
+ case 10:
+
+ hs->rRotVctr = rRotVectr_10;
+ hs->iRotVctr = iRotVectr_10;
+ hs->synGain = cldfb_synGain[0];
+ move16();
+ hs->p_filter = cldfb_protoFilter_2_5ms[0];
+ hs->scale = cldfb_scale_2_5ms[0];
+ move16();
+ IF (hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add(cldfb_synScale[0],hs->filterScale);
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add(cldfb_anaScale[0],hs->filterScale);
+ move16();
+ }
+ break;
+
+ case 16:
+ hs->rRotVctr = rRotVectr_16;
+ hs->iRotVctr = iRotVectr_16;
+ hs->synGain = cldfb_synGain[1];
+ move16();
+ hs->p_filter = cldfb_protoFilter_2_5ms[1];
+ hs->scale = cldfb_scale_2_5ms[1];
+ move16();
+ {
+ hs->anaScalefactor = add(cldfb_anaScale[1],hs->filterScale);
+ move16();
+ }
+ break;
+
+ case 20:
+ hs->rRotVctr = rRotVectr_20;
+ hs->iRotVctr = iRotVectr_20;
+ hs->synGain = cldfb_synGain[2];
+ move16();
+ hs->p_filter = cldfb_protoFilter_2_5ms[2];
+ hs->scale = cldfb_scale_2_5ms[2];
+ move16();
+ IF (hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add(cldfb_synScale[2],hs->filterScale);
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add(cldfb_anaScale[2],hs->filterScale);
+ move16();
+ }
+ break;
+
+ case 32:
+ hs->rRotVctr = rRotVectr_32;
+ hs->iRotVctr = iRotVectr_32;
+ hs->synGain = cldfb_synGain[3];
+ move16();
+ hs->p_filter = cldfb_protoFilter_2_5ms[3];
+ hs->scale = cldfb_scale_2_5ms[3];
+ move16();
+ {
+ hs->anaScalefactor = add(cldfb_anaScale[3],hs->filterScale);
+ move16();
+ }
+ break;
+
+ case 40:
+ hs->rRotVctr = rRotVectr_40;
+ hs->iRotVctr = iRotVectr_40;
+ hs->synGain = cldfb_synGain[4];
+ move16();
+ hs->p_filter = cldfb_protoFilter_2_5ms[4];
+ hs->scale = cldfb_scale_2_5ms[4];
+ move16();
+ IF (hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add(cldfb_synScale[4],hs->filterScale);
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add(cldfb_anaScale[4],hs->filterScale);
+ move16();
+ }
+ break;
+
+ case 60:
+ hs->rRotVctr = rRotVectr_60;
+ hs->iRotVctr = iRotVectr_60;
+ hs->synGain = cldfb_synGain[5];
+ move16();
+ hs->p_filter = cldfb_protoFilter_2_5ms[5];
+ hs->scale = cldfb_scale_2_5ms[5];
+ move16();
+ IF (hs->type == CLDFB_SYNTHESIS )
+ {
+ hs->synScalefactor = add(cldfb_synScale[5],hs->filterScale);
+ move16();
+ }
+ ELSE
+ {
+ hs->anaScalefactor = add(cldfb_anaScale[5],hs->filterScale);
+ move16();
+ }
+ break;
+
+ }
+}
+
+
+#define CLDFB_MEM_EXPONENTS (CLDFB_NO_COL_MAX+9)
+
+/*-------------------------------------------------------------------*
+* cldfb_save_memory()
+*
+* Save the memory of filter; to be restored with cldfb_restore_memory()
+*--------------------------------------------------------------------*/
+void
+cldfb_save_memory (HANDLE_CLDFB_FILTER_BANK hs) /* i: cldfb handle */
+{
+
+ hs->memory_length = cldfb_get_memory_length(hs);
+ hs->memory = (Word16 *) calloc( hs->memory_length + CLDFB_MEM_EXPONENTS + 1, sizeof (Word16));
+
+
+ /* save the memory */
+ Copy (hs->FilterStates, hs->memory, hs->memory_length);
+ Copy (hs->FilterStates_e, hs->memory+hs->memory_length, CLDFB_MEM_EXPONENTS);
+ hs->memory[hs->memory_length+CLDFB_MEM_EXPONENTS] = hs->FilterStates_eg;
+ move16();
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+* cldfb_restore_memory()
+*
+* Restores the memory of filter; memory to be save by cldfb_save_memory()
+*--------------------------------------------------------------------*/
+void
+cldfb_restore_memory (HANDLE_CLDFB_FILTER_BANK hs) /* i/o: cldfb handle */
+
+{
+ Word16 size;
+
+
+ size = cldfb_get_memory_length(hs);
+
+ /* read the memory */
+ Copy (hs->memory, hs->FilterStates, hs->memory_length);
+ Copy (hs->memory+hs->memory_length, hs->FilterStates_e, CLDFB_MEM_EXPONENTS);
+ hs->FilterStates_eg = hs->memory[hs->memory_length+CLDFB_MEM_EXPONENTS];
+ move16();
+
+ /* adjust sample rate if it was changed in the meanwhile */
+ IF (NE_16 (hs->memory_length,size))
+ {
+ lerp(hs->FilterStates, hs->FilterStates, size, hs->memory_length);
+ }
+
+ hs->memory_length = 0;
+ free(hs->memory);
+ hs->memory = NULL;
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+* cldfb_reset_memory()
+*
+* Resets the memory of filter.
+*--------------------------------------------------------------------*/
+void
+cldfb_reset_memory (HANDLE_CLDFB_FILTER_BANK hs) /* i/o: cldfb handle */
+{
+ Word16 length;
+
+ length = cldfb_get_memory_length(hs);
+ /* erase the memory */
+ set16_fx (hs->FilterStates, 0, length);
+ set16_fx (hs->FilterStates_e, 0, sizeof(hs->FilterStates_e)/sizeof(hs->FilterStates_e[0]));
+ hs->FilterStates_eg = 0;
+ move16();
+}
+
diff --git a/lib_com/cng_exc_fx.c b/lib_com/cng_exc_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..b0249f69ef874f5474c4b54106511726ab22b2e5
--- /dev/null
+++ b/lib_com/cng_exc_fx.c
@@ -0,0 +1,890 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+#include "rom_com_fx.h"
+
+/*---------------------------------------------------------------------*
+ * Local constants
+ *---------------------------------------------------------------------*/
+#define A2 6554
+#define OmA2 (32768-A2)
+#define GAIN_VAR 11811 /* in Q31 divided by 2 (Q30) */
+
+/*-------------------------------------------------------*
+ * CNG_exc()
+ *
+ * Comfort noise generation routine
+ *-------------------------------------------------------*/
+
+void CNG_exc_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 L_frame, /* i : length of the frame */
+ Word32 *Enew, /* i/o: decoded SID energy Q6 */
+ Word16 *seed, /* i/o: random generator seed */
+ Word16 exc[], /* o : current non-enhanced excitation Q_new */
+ Word16 exc2[], /* o : current enhanced excitation Q_new */
+ Word32 *lp_ener, /* i/o: LP filtered E */
+ const Word32 last_core_brate, /* i : previous frame core bitrate */
+ Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */
+ Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */
+ Word16 bwe_exc[], /* o : excitation for SWB TBE */
+ const Word16 allow_cn_step, /* i : allow CN step */
+ Word16 *last_allow_cn_step, /* i/o: last allow step */
+ const Word16 OldQ_exc, /* i : Old excitation scaling */
+ const Word16 Q_exc /* i : excitation scaling */
+ , const Word16 num_ho /* i : number of selected hangover frames */
+ ,Word32 q_env[]
+ ,Word32 *lp_env
+ ,Word32 *old_env
+ ,Word16 *exc_mem
+ ,Word16 *exc_mem1
+ ,Word16 *sid_bw
+ ,Word16 *cng_ener_seed1
+ ,Word16 exc3[]
+ ,Word16 Opt_AMR_WB
+)
+{
+ Word16 i, tmp, tmp2, exp, exp2, Q_ener;
+ Word32 L_tmp_ener, L_tmp;
+ Word16 i_subfr;
+ Word16 pit_max;
+ Word16 ftmp,j;
+ Word16 *ptR,*ptI;
+ Word16 fft_io[L_FRAME16k];
+ Word32 itmp[129];
+ Word32 env[NUM_ENV_CNG];
+ Word32 enr1;
+ Word32 denv[NUM_ENV_CNG];
+ Word16 fra;
+ Word16 temp_lo_fx, temp_hi_fx;
+ Word16 exp_pow;
+ Word32 L_tmp2;
+ Word16 *pt_fft_io;
+
+ /*------------------------------------------------------------------*
+ * Initializations
+ *------------------------------------------------------------------*/
+
+ pit_max = PIT16k_MAX;
+ move16();
+ if( EQ_16(L_frame,L_FRAME))
+ {
+ pit_max = PIT_MAX;
+ move16();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Initialization of CNG energy for the first CNG frame
+ *---------------------------------------------------------------------*/
+
+ IF(*first_CNG == 0 )
+ {
+ IF(EQ_32(core_brate,FRAME_NO_DATA))
+ {
+ /* needed only in decoder when the very first SID frame was erased and this frame is FRAME_NO_DATA frame */
+ /*fenew = dotp( fexc, fexc, pit_max )/pit_max;*/
+ L_tmp_ener = Calc_Energy_Autoscaled(exc-pit_max, OldQ_exc, pit_max, &Q_ener);
+ L_tmp_ener = Mult_32_16(L_tmp_ener, 9079); /* divide by PIT_MAX (in Q15 + Q6 to get output in Q6)*/
+ L_tmp_ener = L_shr(L_tmp_ener, Q_ener); /* -> If we want ener in Q6 */
+
+ if(EQ_16(L_frame, L_FRAME16k))
+ {
+ L_tmp_ener = Mult_32_16(L_tmp_ener, 26214); /* Compensate for 16kHz */
+ }
+ *Enew = L_tmp_ener;
+ move32();
+ }
+
+ *lp_ener = *Enew;
+ move32();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Update CNG energy
+ *---------------------------------------------------------------------*/
+ test();
+ test();
+ IF( NE_32(last_core_brate,SID_1k75)&&NE_32(last_core_brate,FRAME_NO_DATA)&&NE_32(last_core_brate,SID_2k40))
+ {
+ /* Partially reset CNG energy after active speech period */
+ test();
+ IF ( allow_cn_step == 0 && *last_allow_cn_step == 0 )
+ {
+ test();
+ IF( LT_16(num_ho,3)||LT_32(Mult_32_16(*Enew,21845/*1/1.5f, Q15*/),*lp_ener))
+ {
+ /**lp_ener = 0.8f * *lp_ener + 0.2f * *Enew;*/
+ L_tmp_ener = Mult_32_16(*lp_ener, 26214);
+ L_tmp_ener = Madd_32_16(L_tmp_ener, *Enew, 6554);
+
+ }
+ ELSE
+ {
+ /**lp_ener = 0.95f * *lp_ener + 0.05f * *Enew;*/
+ L_tmp_ener = Mult_32_16(*lp_ener, 31130);
+ L_tmp_ener = Madd_32_16(L_tmp_ener, *Enew, 1638);
+ }
+ }
+ ELSE
+ {
+ L_tmp_ener = *Enew;
+ move32();
+ *last_allow_cn_step = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ /* normal CNG update */
+ IF ( *last_allow_cn_step == 0 )
+ {
+ /**lp_ener = (float)(A2 * *Enew + (1-A2) * *lp_ener);*/
+ L_tmp_ener = Mult_32_16(*Enew, A2);
+ L_tmp_ener = Madd_32_16(L_tmp_ener, *lp_ener, OmA2);
+ }
+ ELSE
+ {
+ test();
+ if ( EQ_32(core_brate,SID_1k75)||EQ_32(core_brate,SID_2k40))
+ {
+ *last_allow_cn_step = 0;
+ move16();
+ }
+
+ L_tmp_ener = *Enew;
+ move32();
+
+ }
+ }
+ *lp_ener = L_max(L_tmp_ener,1);
+ move32(); /*To avoid / per 0*/
+
+ if ( EQ_16(allow_cn_step,1))
+ {
+ *last_allow_cn_step = 1;
+ move16();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Generate white noise vector
+ *---------------------------------------------------------------------*/
+
+ /*for ( i=0; i Q_exc +16 */
+ exc2[i_subfr+i] = round_fx(L_shl(L_tmp, exp));
+ }
+ }
+ IF ( NE_16(Opt_AMR_WB,1))
+ {
+ Copy( exc2, exc3, L_FRAME16k);
+
+ /* enr1 = (float)log10( *Enew*L_frame + 0.1f ) / (float)log10( 2.0f ); */
+ exp = norm_l(*Enew);
+ L_tmp = L_shl(*Enew,exp); /* Q(exp+6) */
+ L_tmp = Mult_32_16(L_tmp,shl(L_frame,5)); /* Q(exp+6+5-15=exp-4) */
+ L_tmp = L_shr(L_tmp,sub(exp,10)); /* Q6 */
+
+ exp = norm_l(L_tmp);
+ fra = Log2_norm_lc(L_shl(L_tmp,exp));
+ exp = sub(sub(30,exp),6);
+ L_tmp = L_Comp(exp,fra);
+ /* enr1 = round_fx(L_shl(L_tmp,8)); */ /*Q8 */
+ enr1 = L_shr(L_tmp,10);/* Q6 */
+
+
+ IF ( EQ_32(core_brate,SID_2k40))
+ {
+ IF ( *sid_bw == 0 )
+ {
+ FOR ( i=0; iHQ switching gap in ms */
+#define HQ_DELAY_COMP NS2SA(8000, DELAY_CLDFB_NS)
+#define HQ_DELTA_MAX 6 /* maximum multiplication factor (==48kHz/8kHz) for core switching modules */
+
+#define N_ZERO_MDCT_NS 5625000L /* Number of zeros in ms for MDCT */
+#define NL_BUFF_OFFSET 12
+
+#define N_WS2N_FRAMES 40 /* number of frames for attenuation during the band-width switching */
+#define N_NS2W_FRAMES 20 /* number of frames for attenuation during the band-width switching */
+
+/*----------------------------------------------------------------------------------*
+ * Coder types (only for ACELP core when not running in AMR-WB IO mode)
+ *----------------------------------------------------------------------------------*/
+
+#define INACTIVE 0 /* inactive */
+#define UNVOICED 1 /* unvoiced */
+#define VOICED 2 /* purely voiced */
+#define GENERIC 3 /* generic */
+#define TRANSITION 4 /* transition */
+#define AUDIO 5 /* audio (GSC) */
+#define LR_MDCT 6 /* low-rate MDCT core */
+
+
+/*--------------------------------------------------*
+ * Partial copy frame types (only for ACELP core )
+ *--------------------------------------------------*/
+
+/* TCX partial copy frame types */
+#define RF_NO_DATA 0
+#define RF_TCXFD 1
+#define RF_TCXTD1 2
+#define RF_TCXTD2 3
+/* ACELP partial copy frame types */
+#define RF_ALLPRED ACELP_MODE_MAX
+#define RF_NOPRED ACELP_MODE_MAX + 1
+#define RF_GENPRED ACELP_MODE_MAX + 2
+#define RF_NELP ACELP_MODE_MAX + 3
+
+
+/*--------------------------------------------------------------*
+ * MODE2 Frame length constants
+ *---------------------------------------------------------------*/
+
+#define L_FRAME_MAX 960 /* Max 20ms frame size @48kHz */
+#define L_FRAME_PLUS 1200 /* Max frame size (long TCX frame) */
+#define L_MDCT_OVLP_MAX NS2SA(48000,ACELP_LOOK_NS) /* = Max mdct overlap */
+#define N_TCX10_MAX 480 /* Max size of TCX10 MDCT size */
+#define BITS_TEC 1 /* number of bits for TEC */
+#define BITS_TFA 1 /* number of bits for TTF */
+#define N_TEC_TFA_SUBFR 16 /* number of subframes of TEC/TFA */
+#define L_TEC_TFA_SUBFR16k (L_FRAME16k/N_TEC_TFA_SUBFR) /* TEC/TFA subframe size @ 16kHz*/
+#define MAX_TEC_SMOOTHING_DEG 6 /* max degree of smoothing for TEC */
+#define N_MAX 1200 /* Max size of MDCT spectrum = 25ms @ 48kHz */
+#define N_MAX_TCX 1000 /* Max size of MDCT spectrum = 25ms @ 48kHz */
+#define IGF_START_MN 164 /* MDCT lines not used by IGF*/
+#define IGF_START_MX 800 /* max. MDCT lines used by IGF*/
+
+#define L_FRAME_12k8 256 /* Frame size at 12k8Hz: 20ms = 256 samples */
+#define L_FRAME_16k 320 /* Frame size at 16kHz: 20ms = 320 samples */
+#define L_NEXT_MAX_12k8 112 /* maximum encoder lookahead at 12k8Hz */
+#define L_PAST_MAX_12k8 144 /* maximum encoder past samples at 12k8Hz */
+#define L_DIV 256 /* 20ms frame size (ACELP or short TCX frame) */
+#define L_DIV_MAX 320
+#define NB_DIV 2 /* number of division (frame) per 20ms frame */
+#define NB_SUBFR 4 /* number of 5ms subframe per 20ms frame */
+
+#define L_NEXT_MAX_16k 140 /* maximum encoder lookahead at 16kHz */
+#define L_NEXT_MAX_32k 280 /* maximum encoder lookahead at 32kHz */
+#define L_PAST_MAX_32k 360 /* maximum encoder past samples at 32kHz */
+
+#define MIDLSF_NBITS 5
+#define ENDLSF_NBITS 31
+
+/*----------------------------------------------------------------------------------*
+ * ACELP core constants
+ *----------------------------------------------------------------------------------*/
+
+#define SAFETY_NET 0
+#define MOVING_AVERAGE 1
+#define AUTO_REGRESSIVE 2
+
+#define ACELP_MODE_MAX 4
+
+#define RF_MODE_MAX 4
+
+#define M 16 /* order of the LP filter @ 12.8kHz */
+#define L_FRAME 256 /* frame size at 12.8kHz */
+#define NB_SUBFR 4 /* number of subframes per frame */
+#define L_SUBFR (L_FRAME/NB_SUBFR) /* subframe size */
+#define L_SUBFR_Q6 ((L_FRAME/NB_SUBFR)*64) /* subframe size */
+#define L_SUBFR_Q16 ((L_FRAME/NB_SUBFR)*65536) /* subframe size */
+
+#define L_INP_MEM (L_LOOK_16k + ((L_LP_16k - (NS2SA(INT_FS_16k, ACELP_LOOK_NS) + L_SUBFR16k/2)) - 3*L_SUBFR16k/2)) /* length of memory of input signal, given by the Look-Ahead + the past memory (max needed for the LP window at 16 kHz) */
+#define L_INP_12k8 (L_INP_MEM + L_FRAME) /* length of input signal buffer @12.8kHz */
+#define L_INP (L_INP_MEM + L_FRAME32k) /* length of input signal buffer */
+
+#define L_EXC_MEM L_FRAME16k /*(PIT16k_MAX + L_INTERPOL)*/ /* length of memory of excitation signal */
+#define L_EXC_MEM_12k8 (PIT_MAX + L_INTERPOL) /* length of memory of excitation signal @12.8kHz */
+#define L_EXC_MEM_DEC (3*L_FRAME16k/2) /*Half-frame needed for MODE2 PLC in case of TCX->ACELP*/
+#define L_EXC (L_EXC_MEM + L_FRAME16k + 1) /* length of excitation signal buffer */
+#define L_EXC_DEC (L_EXC_MEM_DEC + L_FRAME16k + 1 + L_SUBFR) /* length of decoder excitation signal buffer @16kHz*/
+#define L_SYN_MEM NS2SA(48000,DELAY_CLDFB_NS) /* synthesis memory length, 1.25ms @ 48kHz */
+#define L_SYN (L_SYN_MEM + L_FRAME16k) /* length of synthesis signal buffer */
+#define L_WSP_MEM (PIT_MAX + L_INTERPOL) /* length of memory for weighted input signal */
+#define L_WSP (L_WSP_MEM + L_FRAME + L_LOOK_12k8) /* length of weighted input signal buffer */
+
+#define OLD_SYNTH_SIZE_DEC (2*L_FRAME_MAX) /* decoder past synthesis; needed for LTP, PLC and rate switching*/
+#define OLD_SYNTH_INTERNAL_DEC (2*L_FRAME32k) /* decoder past synthesis @ internal sampling rate; needed for LTP, PLC and rate switching*/
+#define OLD_SYNTH_SIZE_ENC L_FRAME32k+L_FRAME32k/4 /* Frame size in samples at 25.6 kHz */
+#define OLD_EXC_SIZE_DEC (3*L_FRAME_MAX/2+2*L_FIR_FER2) /*old excitation needed for decoder for PLC*/
+
+#define TILT_CODE 9830 /* ACELP code preemphasis factor ~=0.3f (0Q15) (=0.299987792968750) */
+
+#define L_SUBFR16k (L_FRAME16k/NB_SUBFR) /* subframe size at 16kHz */
+#define L_HALFR16k (2*L_SUBFR16k) /* half-frame size at 16kHz */
+
+#define L_INTERPOL2 16 /* Length of filter for interpolation */
+#define L_INTERPOL (L_INTERPOL2+1) /* Length of filter for interpolation */
+#define TILT_FAC_FX 22282 /* tilt factor (denominator) fixed-point*/
+#define M16k 20 /* order of the LP filter @ 16kHz */
+#define PIT_SHARP_fx 27853 /* pitch sharpening factor */
+#define F_PIT_SHARP 0.85F /* pitch sharpening factor */
+#define PIT_UP_SAMP 4
+#define UP_SAMP 4 /* upsampling factor for 1/4 interpolation filter */
+#define PIT_L_INTERPOL2 16
+#define PIT_FIR_SIZE2 (PIT_UP_SAMP*PIT_L_INTERPOL2+1)
+#define PIT_UP_SAMP6 6
+#define PIT_L_INTERPOL6_2 17
+#define PIT_FIR_SIZE6_2 (PIT_UP_SAMP6*PIT_L_INTERPOL6_2+1)
+#define E_MIN_FX 1 /* QSCALE (Q7)*/
+#define STEP_DELTA_FX 11
+#define FORMANT_SHARPENING_NOISE_THRESHOLD_FX 5376 /* 21 (!8)lp_noise level above which formant sharpening is deactivated - at this level most of 20 dB SNR office noisy speech still uses sharpening */
+#define LP_NOISE_THRESH 167772160l/*20.f Q23*/
+#define LFAC 160 /* FAC maximum frame length */
+
+#define L_FILT_UP8k 24 /* Resampling - delay of filter for 8 kHz output signals (at 12.8 kHz sampling rate) */
+#define LEN_WIN_SSS 120
+#define L_FILT 12 /* Delay of the low-pass filter in the BPF */
+#define L_FILT8k 16 /* Resampling - delay of filter for 8 kHz input signals (at 8kHz sampling rate) */
+#define L_FILT16k 15 /* Resampling - delay of filter for 16 kHz input signals (at 16kHz sampling rate) */
+#define L_FILT32k 30 /* Resampling - delay of filter for 32 kHz input signals (at 32kHz sampling rate) */
+#define L_FILT48k 45 /* Resampling - delay of filter for 48 kHz input signals (at 48kHz sampling rate) */
+#define L_FILT_UP16k 12 /* Resampling - delay of filter for 16 kHz output signals (at 12.8 kHz sampling rate) */
+#define L_FILT_UP32k 12 /* Resampling - delay of filter for 32 kHz output signals (at 12.8 kHz sampling rate) */
+#define L_FILT_UP48k 12 /* Resampling - delay of filter for 48 kHz output signals (at 12.8 kHz sampling rate) */
+#define L_FILT_MAX L_FILT48k /* Resampling - maximum length of all filters - for memories */
+#define RS_INV_FAC 0x8000 /* Resampling - flag needed in rom_com and modif_fs to allow pre-scaled and non pre-scaled filters */
+
+#define CLDFB_NO_CHANNELS_MAX 60 /* CLDFB resampling - max number of CLDFB channels */
+#define CLDFB_NO_COL_MAX 16 /* CLDFB resampling - max number of CLDFB col. */
+#define CLDFB_NO_COL_MAX_SWITCH 6 /* CLDFB resampling - max number of CLDFB col. for switching */
+#define CLDFB_NO_COL_MAX_SWITCH_BFI 8 /* CLDFB resampling - max number of CLDFB col. for switching */
+
+#define CLDFB_ANALYSIS 0
+#define CLDFB_SYNTHESIS 1
+
+#define L_FFT 256 /* Spectral analysis - length of the FFT */
+#define LOG2_L_FFT 8 /* Spectral analysis - log2 of L_FFT */
+
+
+#define BIN (INT_FS_FX/L_FFT)/* Spectral analysis - Width of one frequency bin in Hz */
+#define NB_BANDS 20 /* Spectral analysis - number of frequency bands */
+#define VOIC_BINS 74 /* Spectral analysis - max number of frequency bins considered as voiced (related to VOIC_BAND and L_FFT) */
+#define VOIC_BAND 17 /* Spectral analysis - number of critical bands considered as voiced (related to VOIC_BINS) */
+#define VOIC_BINS_8k 115 /* Spectral analysis - max number of frequency bins considered as voiced in NB (related to VOIC_BAND_8k and L_FFT) */
+#define VOIC_BAND_8k 17 /* Spectral analysis - number of critical bands considered as voiced in NB (related to VOIC_BINS_8k) */
+#define N_SPEC (L_FFT/2) /* number of spectral bins */
+
+#define M_GAMMA_FX 32440 /* Q15 - forgetting factor of active speech decision predictor */
+#define M_ALPHA_FX 29491 /* Q15 - forgetting factor of LT correlation map */
+#define ONE_MINUS_M_ALPHA 3277 /* Q15 - one minus forgetting factor of LT correlation map */
+#define THR_CORR_INIT_FX (56<<9 ) /* Q9 - starting threshold of multi-harm. correlation */
+#define THR_NCHAR_WB_FX 2048 /* Q11 threshold for noise character (WB) */
+#define THR_NCHAR_NB_FX 2048 /* Q11 threshold for noise character (NB) */
+
+#define L_LP 320 /* LP analysis - LP window size */
+#define L_LP_16k 400 /* LP analysis @16kHz - LP window size for 16kHz */
+#define L_LP_AMR_WB 384 /* LP analysis - windows size (only for AMR-WB IO mode) */
+#define GRID100_POINTS 100 /* LP analysis - number of points to evaluate Chebyshev polynomials */
+#define GRID80_POINTS 80 /* LP analysis - number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */
+
+#define GRID50_POINTS 51 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */
+#define GRID40_POINTS 41 /* LP analysis - half-number of points to evaluate Chebyshev polynomials used in the LP coefs. conversion */
+
+#define PIT_MIN 34 /* OL pitch analysis - Minimum pitch lag */
+#define PIT_MAX 231 /* OL pitch analysis - Maximum pitch lag */
+#define PIT_MIN_EXTEND 20 /* OL pitch analysis - Minimum pitch lag of extended range */
+#define PIT_MIN_DOUBLEEXTEND 17 /* OL pitch analysis - Minimum pitch lag of double-extended range */
+#define OPL_DECIM 2 /* OL pitch analysis - decimation factor */
+#define L_INTERPOL1 4 /* OL pitch analysis - interval to compute normalized correlation */
+#define FIR_SIZE1 (UP_SAMP*L_INTERPOL1+1) /* OL pitch analysis - total length of the 1/4 interpolation filter */
+
+#define PIT_MIN_SHORTER 29 /* OL pitch analysis - minimum for wider pitch, MODE2 specific constant */
+
+#define PIT_MIN_12k8 29 /* Minimum pitch lag with resolution 1/4 */
+#define PIT_FR2_12k8 121 /* Minimum pitch lag with resolution 1/2 */
+#define PIT_FR1_12k8 154 /* Minimum pitch lag with resolution 1 */
+#define PIT_MAX_12k8 231 /* Maximum pitch lag */
+#define PIT_FR1_8b_12k8 82 /* Minimum pitch lag with resolution 1 for low bit-rate pitch delay codings*/
+#define PIT_MIN_16k 36
+#define PIT_FR2_16k 36
+#define PIT_FR1_16k 165
+#define PIT_FR1_8b_16k 165
+#define PIT_MIN_25k6 58
+#define PIT_FR2_25k6 58
+#define PIT_FR1_25k6 164
+#define PIT_MAX_25k6 463
+#define PIT_FR1_8b_25k6 164
+#define PIT_MIN_32k 72
+#define PIT_FR2_32k 72
+#define PIT_FR1_32k 75
+#define PIT_MAX_32k 577
+#define PIT_FR1_8b_32k 75
+#define PIT_MAX_MAX PIT_MAX_32k
+#define PIT_MAX_16k 289
+
+#define PIT_FR1_8b 92 /* Pitch encoding - Minimum pitch lag with resolution 1 */
+#define PIT_FR2_9b 128 /* Pitch encoding - Minimum pitch lag with resolution 1/2 */
+#define PIT_FR1_9b 160 /* Pitch encoding - Minimum pitch lag with resolution 1 */
+#define PIT_FR1_EXTEND_8b 64 /* Pitch encoding - Minimum pitch lag with resolution 1 of extended range */
+#define PIT_FR2_EXTEND_9b 116 /* Pitch encoding - Minimum pitch lag with resolution 1/2 of extended range */
+#define PIT_FR1_EXTEND_9b 128 /* Pitch encoding - Minimum pitch lag with resolution 1 of extended range */
+#define PIT_FR1_DOUBLEEXTEND_8b 58 /* Pitch encoding - Minimum pitch lag with resolution 1 of double-extended range */
+#define PIT_FR2_DOUBLEEXTEND_9b 112 /* Pitch encoding - Minimum pitch lag with resolution 1/2 of double-extended range */
+#define PIT_FR1_DOUBLEEXTEND_9b 124 /* Pitch encoding - Minimum pitch lag with resolution 1 of double-extended range */
+
+#define LOW_PASS 0 /* LP filtering - flag for low-pass filtering of the excitation */
+#define FULL_BAND 1 /* LP filtering - flag for no low-pass filtering of the excitation */
+#define NORMAL_OPERATION 2 /* LP filtering - flag for selecting the best of the two above */
+
+#define NB_TRACK_FCB_2T 2 /* Algebraic codebook - number of tracks in algebraic fixed codebook search with 2 tracks */
+#define NB_POS_FCB_2T 32 /* Algebraic codebook - number of positions in algebraic fixed codebook search with 2 tracks */
+#define NB_TRACK_FCB_4T 4 /* Algebraic codebook - number of tracks in algebraic fixed codebook search with 4 tracks */
+#define NB_POS_FCB_4T 16 /* Algebraic codebook - number of positions in algebraic fixed codebook search with 4 tracks */
+#define NB_PULSE_MAX 36
+#define NPMAXPT ((NB_PULSE_MAX+NB_TRACK_FCB_4T-1)/NB_TRACK_FCB_4T)
+
+#define GAIN_PRED_ORDER 4 /* Gain quantization - prediction order for gain quantizer (only for AMR-WB IO mode) */
+#define MEAN_ENER 30 /* Gain quantization - average innovation energy */
+
+#define DTX_HIST_SIZE 8 /* CNG & DTX - number of last signal frames used for CNG averaging */
+#define CNG_ISF_FACT_FX 29491 /* Q15(0.9), CNG & DTX - CNG spectral envelope smoothing factor*/
+#define STEP_AMR_WB_SID_FX 10752 /* Q12 */
+#define HO_HIST_SIZE 8 /* CNG & DTX - maximal number of hangover frames used for averaging */
+
+#define NUM_ENV_CNG 20
+#define BUF_L_NRG_FX 22938 /* Q15(0.7), CNG & DTX - lower threshold offset for hangover updates */
+#define ONE_OVER_BUF_H_NRG_FX 31814 /* Q15(1/1.03), CNG & DTX - inverse of higher threshold offset for hangover updates */
+#define HO_ATT_FAC_FX 3277 /* Q15(0.1), CNG & DTX - Hangover frame attenuation rate factor */
+
+#define BUF_DEC_RATE 25 /* CNG & DTX - buffer size decrease rate for active frames */
+#define STEP_SID_FX 21504 /* Q12 */
+#define ISTEP_SID_FX 6242 /* Inverse of CNG & DTX - CNG energy quantization step in Q15(1/5.25 in Q15)*/
+#define ISTEP_AMR_WB_SID_FX 12483 /* Q15(1/2.625) Inverse of CNG & DTX - CNG energy quantization step */
+
+#define MIN_ACT_CNG_UPD 20 /* DTX - Minimum number of consecutive active frames for CNG mode update */
+#define FIXED_SID_RATE 8 /* DTX SID rate */
+
+#define TOTALNOISE_HIST_SIZE 4
+
+/************************************************************************/
+
+/************************************************************************/
+#define SUBFFT_QIN 10
+#define DATAFFT_Q 5
+#define SUBFFT_QOUT SUBFFT_QIN-DATAFFT_Q
+#define SPECAMP_Q SUBFFT_QIN
+
+#define CLDFBVAD_NB_ID 1
+#define CLDFBVAD_WB_ID 2
+#define CLDFBVAD_SWB_ID 3
+#define CLDFBVAD_FB_ID 4
+#define SP_CENTER_NUM 4
+#define TONA_NUM 3
+#define PRE_SNR_NUM 32
+#define PRE_FLAG_NUM 64
+#define POWER_NUM 56
+#define PRE_SPEC_DIF_NUM 56
+#define CLDFBVAD_VAD_ON 1
+#define COM_VAD_ON 2
+
+#define MAX_SUBBAND_NUM 12 /* max number of sub-band divided non-uniformly*/
+#define BG_ENG_NUM MAX_SUBBAND_NUM /* number of energy of sub-band divided non-uniformly*/
+#define MIN_AMP_ID 5
+#define MAX_AMP_ID 64
+#define SPEC_AMP_NUM (MAX_AMP_ID-MIN_AMP_ID+1)
+#define STABLE_NUM 4 /* number of time-domain stable rate*/
+#define SFM_NUM 3 /* number of spectral flatness */
+
+
+
+#define MAX_CORR_SHIFT_FX 16384 /* corrshift limit, 0.5 in Q15 */
+
+
+#define START_NG 5 /* Stationary noise UV modification */
+#define FULL_NG 10 /* Stationary noise UV modification */
+#define ISP_SMOOTHING_QUANT_A1_FX 29491 /* 0.9f in Q15 */ /* Stationary noise UV modification */
+
+#define KP559016994_FX 18318 /* EDCT & EMDCT constants */
+#define KP951056516_FX 31164 /* EDCT & EMDCT constants */
+#define KP587785252_FX 19261 /* EDCT & EMDCT constants */
+#define KP866025403_FX 28378 /* EDCT & EMDCT constants */
+#define KP250000000_FX 8192 /* EDCT & EMDCT constants */
+
+#define FEC_BITS_CLS 2 /* FEC - number of bits for clas information */
+#define FEC_BITS_ENR 5 /* FEC - number of bits for energy information */
+#define FEC_ENR_STEP (96.0f/(1< 1! For dividing spectrum into multiple ranges, define NOISE_FILL_RANGES > 1. For each region one noise filling level will be transmited */
+#define NBITS_NOISE_FILL_LEVEL 3 /* Number of bits used for coding noise filling level for each range */
+#define MIN_NOISE_FILLING_HOLE 8
+#define HOLE_SIZE_FROM_LTP(gain) (add(4, extract_h(L_shr(L_mult0(gain, 0x6666), 10)))) /* 0x6666 -> 2.0*(4.0/0.625) (4Q11) */
+#define FDNS_NPTS 64
+#define AVG_TCX20_LSF_BITS 40
+#define AVG_TCX10_LSF_BITS 59
+#define LTPSIZE 3
+#define TCXLTP_DELAY_NS 250000
+#define TCXLTP_MAX_DELAY NS2SA(48000,TCXLTP_DELAY_NS)
+#define TCXLTP_LTP_ORDER 24
+#define TCX_RES_Q_BITS_GAIN 3
+
+#define LPC_SHAPED_ARI_MAX_RATE ACELP_9k60
+
+#define N_MAX_ARI 800
+
+#define SPEC_EXP_DEC 20 /* initial decoder spectrum exponent */
+
+/*----------------------------------------------------------------------------------*
+ * TNS constants
+ *----------------------------------------------------------------------------------*/
+
+#define R1_48 690
+#define R2_48 420
+#define R1_16 230
+#define R2_16 140
+#define R1_25 368
+#define R2_25 224
+
+#define TNS_MAX_NUM_OF_FILTERS 2 /* TNS maximum number of filters */
+#define TNS_MAX_FILTER_ORDER 8 /* TNS maximum filter order */
+#define ITF_MAX_FILTER_ORDER 16 /* ITF maximum filter order */
+#define NPRM_TNS (2+TNS_MAX_NUM_OF_FILTERS*(3+TNS_MAX_FILTER_ORDER)) /* TNS total number of quantized parameters */
+#define NPRM_RESQ 100 /* Maximum number of parameter for residual Q in TCX */
+#define NPRM_CTX_HM 3 /* Number of Parameters for Context HM : flag+index */
+#define NPRM_DIV (2+NPRM_TNS+N_MAX/2+NPRM_RESQ+NPRM_CTX_HM) /* Total number of quantized parameter in 1 division */
+#define DEC_NPRM_DIV NPRM_DIV /* Total number of quantized parameter in 1 division (decoder side) */
+#define NPRM_LPC_NEW 2*(4+2*NB_SPHERE) /* LPC total number of quantized parameters */
+
+#define BITBUFSIZE (128000/50)
+
+#define TNS_COEF_RES 4 /* Bit resolution of the coefficients. */
+#define INDEX_SHIFT (1 << (TNS_COEF_RES-1)) /* For shifting the index so that index 0 points to 0. */
+
+/*----------------------------------------------------------------------------------*
+ * LSF quantization constants
+ *----------------------------------------------------------------------------------*/
+
+#define GENERIC_MA_LIMIT 9600
+
+#define SPC_FX 770 /* q15 */
+#define SPC_PLUS_FX 771
+
+#define LSF_GAP_FX 128 /*50.0f x 2.56*/
+#define MODE1_LSF_GAP_FX 179 /* MODE1_LSF_GAP*2.56 */ /* Minimum LSF separation for end-frame ISFs */
+#define FREQ_MAX 16384 /*6400Hz in 14Q1*1.28 */
+#define FREQ_DIV 800 /*400.0f in 14Q1 */
+
+#define LSF_BITS_CNG 29
+
+#define ISF_GAP_FX 128 /* Minimum ISF separation for end-frame ISFs (only in AMR-WB IO mode) */
+#define LSF_GAP_MID_FX 205 /* 80.0 * 2.56 */ /* Minimum LSF separation for mid-frame LSFs */
+#define PREFERSFNET_FX 1638 /* 0.05 in Q16*/
+#define SFNETLOWLIMIT_WB 3670016 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, WB case */
+#define SFNETLOWLIMIT_NB 3984589 /* 2.56x2.56*Q4 LSF quantizer - new sampling rate dependent thresholds used in LSF codebook decision logic, NB case */
+#define LSFMBEST 2 /* number of survivors from one stage to another */
+#define STREAKLEN 3 /* Allow this many predictive frames, before starting limiting, For voiced +3 frames allowed */
+#define STREAKMULT_FX 26214 /* Exponential limiting multiplier */
+
+#define LSFMBEST_MAX 16
+
+#define TCXLPC_NUMSTAGES 3
+#define TCXLPC_NUMBITS 13
+#define TCXLPC_IND_NUMSTAGES 1
+#define TCXLPC_IND_NUMBITS 2
+#define TCXLPC_LSF_GAP 204 /* 80 in 14Q1*1.28 */
+#define kMaxC 8
+
+#define MAX_VQ_STAGES 4 /* Maximum number of LSF VQ (3 trained and 1 LVQ) stages allowed */
+#define MAX_VQ_STAGES_USED 9 /*this is the maximum number of stages currently used and changing this will affect the memory allocated MAX_VQ_STAGES is also used as offset for addressing some arrays, so this should NOT be changed*/
+
+#define LEN_INDICE 15
+#define LATTICE_DIM 8
+#define NO_LEADERS 49
+#define MAX_NO_BR_LVQ 28
+#define MAX_NO_SCALES 3
+#define MAX_NO_VALS 4
+#define CNG_LVQ_MODES 16
+#define MAX_NO_MODES 128
+#define START_CNG 112
+#define MAX_NO_MODES_p 145
+#define NO_CODING_MODES 6
+#define LVQ_COD_MODES 18
+/* BC-TCQ */
+#define N_STAGE_VQ 8
+#define N_DIM 2
+#define NUM_SUBSET 8
+#define OP_LOOP_THR_HVO 1550146 /* 80% : Open-loop Threshold 2.56*2.56/16 */
+#define NUM_STATE 16 /* BC-TCQ - Number of state of the Trellis */
+#define N_STAGE 16 /* BC-TCQ - Smaple number in a frame */
+
+#define SIZE_BK1 256
+#define SIZE_BK2 256
+#define SIZE_BK21 64
+#define SIZE_BK22 128
+#define SIZE_BK23 128
+#define SIZE_BK24 32
+#define SIZE_BK25 32
+#define SIZE_BK21_36b 128
+#define SIZE_BK22_36b 128
+#define SIZE_BK23_36b 64
+
+#define NB_QUA_GAIN5B 32 /* Number of quantization level */
+#define NB_QUA_GAIN6B 64 /* Number of quantization level */
+#define NB_QUA_GAIN7B 128 /* Number of quantization level */
+
+/*----------------------------------------------------------------------------------*
+ * Transient detection
+ *----------------------------------------------------------------------------------*/
+
+#define NSUBBLOCKS 8 /* Number of subblocks per frame, one transient per a sub-block can be found */
+#define MAX_TD_DELAY 2*NSUBBLOCKS /* Maximum allowed delay (in number of subblocks) of the transient detection, affects required memory */
+
+#define NO_TCX 0
+#define TCX_20 1
+#define TCX_10 2
+#define TCX_5 3
+
+#define TRANSITION_OVERLAP (-2)
+#define RECTANGULAR_OVERLAP (-1)
+#define FULL_OVERLAP 0
+#define NOT_SUPPORTED 1
+#define MIN_OVERLAP 2
+#define HALF_OVERLAP 3
+
+/*----------------------------------------------------------------------------------*
+ * FEC constants
+ *----------------------------------------------------------------------------------*/
+
+#define UNVOICED_CLAS 0 /* Unvoiced, silence, noise, voiced offset */
+#define UNVOICED_TRANSITION 1 /* Transition from unvoiced to voiced components - possible onset, but too small */
+#define VOICED_TRANSITION 2 /* Transition from voiced - still voiced, but with very weak voiced characteristics */
+#define VOICED_CLAS 3 /* Voiced frame, previous frame was also voiced or ONSET */
+#define ONSET 4 /* Voiced onset sufficiently well built to follow with a voiced concealment */
+#define SIN_ONSET 5 /* Artificial harmonic+noise onset (used only in decoder) */
+#define INACTIVE_CLAS 6 /* Inactive frame (used only in decoder) */
+#define AUDIO_CLAS 7 /* Audio frame (used only in AMR-WB IO mode) */
+
+#define BETA_FEC_FX 24576 /* FEC - weighting factor for LSF estimation in FER */
+#define STAB_FAC_LIMIT_FX 8192 /* FEC - limit at which safety net is forced for next frame */
+
+#define MODE1_L_FIR_FER 5 /* FEC - impulse response length for low- and high-pass filters in FEC */
+#define L_FIR_FER 3 /* FEC - impulse response length for low- & high-pass filters in FER concealment*/
+#define L_FIR_FER2 11 /* FEC - new filter tuning: 11*/
+#define MAX_UPD_CNT 5 /* FEC - maximum number of frames since last pitch update */
+
+/* attenuation strategy in case of FER */
+#define _ALPHA_S_FX 19661
+#define _ALPHA_V_FX 32767
+#define _ALPHA_VT_FX 13107
+#define _ALPHA_UT_FX 26214
+#define _ALPHA_U_FX 13107
+#define _ALPHA_U_FX_X_2 26214
+#define _ALPHA_UU_FX 32767
+
+#define PLC_MIN_CNG_LEV 328/*0.01f Q15*/
+#define PLC_MIN_STAT_BUFF_SIZE 50 /* buffer size for minimum statistics */
+#define G_LPC_RECOVERY_BITS 1
+
+/*----------------------------------------------------------------------------------*
+ * Transition mode (TC) constants
+ *----------------------------------------------------------------------------------*/
+/* Conversion of tc_subfr to index */
+#define TC_SUBFR2IDX_16KHZ_fx(x) mac_r(1024L, (x), 512) /* -1 => 0, 0 => 0, 64 => 1, 128 => 2, 192 => 3, 256 => 4 */
+
+#define TC_SUBFR2IDX_fx(x) add(s_min(3, s_max(0, sub((x), 1))), TC_SUBFR2IDX_16KHZ_fx(x))
+
+#define L_IMPULSE 17 /* TC - length of one prototype impulse */
+#define L_IMPULSE2 8 /* TC - half-length of one prototype impulse == floor(L_IMPULSE/2) */
+#define NUM_IMPULSE 8 /* TC - number of prototype impulses */
+#define N_GAIN_CODE_TC 8 /* TC - number of levels for gain_code quantization for subrames without glot. impulse(s) - */
+#define N_GAIN_TC 8 /* TC - number of levels for gain_trans quantization */
+/* TC - attention: DO NOT CHANGE the following constants - needed for correct bit-allocations */
+#define TC_0_0 1 /* TC - subframe ID for TC: first glottal impulse in the 1st subframe, second in the 1st subframe */
+#define TC_0_64 2 /* TC - subframe ID for TC: first glottal impulse in the 1st subframe, second in the 2nd subframe */
+#define TC_0_128 3 /* TC - subframe ID for TC: first glottal impulse in the 1st subframe, second in the 3rd subframe */
+#define TC_0_192 4 /* TC - subframe ID for TC: first glottal impulse in the 1st subframe, second in the 4th subframe */
+
+/*----------------------------------------------------------------------------------*
+ * AVQ constants
+ *----------------------------------------------------------------------------------*/
+
+#define NB_LDQ3 9 /* RE8 constants */
+#define NB_LDQ4 27
+#define NB_SPHERE 32
+#define NB_LEADER 36
+
+#define NSV_MAX 34 /* maximal number of sub-vectors used by the AVQ */
+
+/*----------------------------------------------------------------------------------*
+ * Arithmetic coder
+ *----------------------------------------------------------------------------------*/
+#define A_THRES_SHIFT 2
+#define A_THRES (1<0 */
+#define GAMMA3_MINUS_FX 29491 /* NB post-filter - tilt weighting factor when k1<0 */
+#define GAMMA3_PLUS_WB_FX 21299 /* WB post-filter */
+#define GAMMA3_MINUS_WB_FX 27853 /* WB post-filter */
+#define AGC_FAC_WB_FX 27853 /* WB post-filter - gain adjustment factor */
+#define AGC_FAC1_WB_FX (Word16)(32768L-AGC_FAC_WB_FX) /* WB post-filter - gain adjustment factor complement */
+
+/* SWB TBE, FX only constants */
+#define NOISE_QFAC 6
+#define NOISE_QADJ (15-NOISE_QFAC)
+
+/*----------------------------------------------------------------------------------*
+ * SWB BWE constants
+ *----------------------------------------------------------------------------------*/
+
+#define INV_L_SUBFR16k_FX 410 /*Q15 */
+#define SWB_L_SUBFR 160
+#define FB_L_SUBFR 240
+#define SWB_FENV 14
+#define WB_FENV 2
+#define FB_GAIN_QLOW_FX 0
+#define FB_GAIN_QDELTA_FX 512 /*Q14 */
+
+#define NUM_BITS_FB_FRAMEGAIN 4 /* Number of bits for framegain for FB */
+#define FB_BAND_BEGIN 620
+#define FB_BAND_END 800
+#define FB_BAND_WIDTH 180
+#define N_CAND 2
+#define N_CB11 32 /* 5bits */
+#define N_CB1ST 128 /* 7bits */
+#define N_CB2ND 64 /* 6bits */
+#define N_CB3RD 32 /* 5bits */
+#define N_CB4TH 64 /* 6bits */
+#define DIM1ST 3
+#define DIM2ND 4
+#define DIM3RD 3
+#define DIM4TH 4
+#define DIM11 (DIM1ST+DIM2ND)
+#define DIM12 (DIM3RD+DIM4TH)
+#define N_CAND_TR 3
+#define N_CB_TR1 128
+#define N_CB_TR2 64
+#define DIM_TR1 2
+#define DIM_TR2 2
+#define SWB_FENV_TRANS 4
+#define SWB_TENV 4
+#define NUM_SHARP 9
+#define SHARP_WIDTH 32
+
+#define HARMONIC 3
+#define NORMAL 2
+#define TRANSIENT 1
+#define NOISE 0
+
+/*----------------------------------------------------------------------------------*
+ * HR SWB BWE constants
+ *----------------------------------------------------------------------------------*/
+
+#define NSV_OVERLAP 2 /* number of sub-bands overlaping with lower-band (0-8kHz) */ /* note that NSV_MAX >= END_FREQ_BWE_FULL/(8*50) + NSV_OVERLAP ! */
+#define N_BANDS_BWE_HR 4 /* number of frequency bands in non-transient frame */
+#define N_BANDS_TRANS_BWE_HR 2 /* number of frequency bands in transient frame */
+#define END_FREQ_BWE 14400 /* maximum frequency coded by AVQ */
+#define END_FREQ_BWE_FULL 16000 /* maximum frequency coded by HR SWB BWE */
+#define END_FREQ_BWE_FULL_FB 20000 /* maximum frequency coded by HR FB BWE */
+
+#define NBITS_GLOB_GAIN_BWE_HR 5 /* number of bits of the global gain quantizer */
+#define MIN_GLOB_GAIN_BWE_HR 3 /* minimum value of the global gain quantizer */
+#define MAX_GLOB_GAIN_BWE_HR 500 /* maximum value of the global gain quantizer */
+
+#define NBITS_ENVELOPE_BWE_HR1 6 /* number of bits for envelope VQ - first two subbands in non-transient frame */
+#define NBITS_ENVELOPE_BWE_HR2 5 /* number of bits for envelope VQ - second two subbands in non-transient frame */
+#define NBITS_ENVELOPE_BWE_HR_TR 4 /* number of bits for envelope VQ - two subbands in transient frame */
+#define NUM_ENVLOPE_CODE_HR1 64 /* dimension of envelope VQ - first two subbands in non-transient frame */
+#define NUM_ENVLOPE_CODE_HR2 32 /* dimension of envelope VQ - second two subbands in non-transient frame */
+#define NUM_ENVLOPE_CODE_HR_TR 16 /* dimension of envelope VQ - two subbands in transient frame */
+#define NUM_ENVLOPE_CODE_HR_TR2 8 /* dimension of envelope VQ - two subbands in transient frame */
+
+#define NUM_NONTRANS_START_FREQ_COEF (L_FRAME32k/2 - NSV_OVERLAP*WIDTH_BAND) /* start frequency coefficient (==7.6kHz) in non-transient frame */
+#define NUM_NONTRANS_END_FREQ_COEF (L_FRAME32k*END_FREQ_BWE/END_FREQ_BWE_FULL) /* end frequency coefficient (==14.4kHz) in non-transient frame */
+#define NUM_TRANS_START_FREQ_COEF (NUM_NONTRANS_START_FREQ_COEF/NUM_TIME_SWITCHING_BLOCKS) /* start frequency coefficient (==7.6kHz) in transient frame */
+#define NUM_TRANS_END_FREQ_COEF (NUM_NONTRANS_END_FREQ_COEF/NUM_TIME_SWITCHING_BLOCKS) /* end frequency coefficient (==14.4kHz) in transient frame */
+#define NUM_TRANS_END_FREQ_COEF_EFF 140
+#define WIDTH_NONTRANS_FREQ_COEF ((NUM_NONTRANS_END_FREQ_COEF - NUM_NONTRANS_START_FREQ_COEF)/N_BANDS_BWE_HR) /* number of coefficients per band in non-transient frame */
+#define WIDTH_TRANS_FREQ_COEF ((NUM_TRANS_END_FREQ_COEF - NUM_TRANS_START_FREQ_COEF)/N_BANDS_TRANS_BWE_HR) /* number of coefficients per band in transient frame */
+
+#define NBITS_THRESH_BWE_HR 400 /* BWE HR number of bits threshold */
+
+#define NBITS_HF_GAIN_BWE_HR 2 /* number of bits for HF (noncoded) energy estimation */
+#define BWE_HR_TRANS_EN_LIMIT1_FX_Q16 6554
+#define BWE_HR_TRANS_EN_LIMIT2_FX_Q16 19661
+#define BWE_HR_TRANS_EN_LIMIT3_FX_Q16 32767
+#define BWE_HR_NONTRANS_EN_LIMIT1_FX_Q15 16384 /* 0.5 */
+#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q14 19661 /* 1.2 */
+#define BWE_HR_NONTRANS_EN_LIMIT2_FX_Q15 16384
+#define BWE_HR_NONTRANS_EN_LIMIT3_FX_Q15 26214 /* 0.8 */
+
+/*----------------------------------------------------------------------------------*
+ * FD CNG
+ *----------------------------------------------------------------------------------*/
+#define DELTA 1e-20f
+#define DELTA_MANTISSA_W16 0x5e73
+#define DELTA_MANTISSA_W32 0x5e728433
+#define DELTA_EXPONENT (-66)
+
+#define CLDFB_SCALING 24576/*1.5 Q14*/ /* Q 2.14 */
+
+#define FFTLEN 640
+#define FFTLEN2 (FFTLEN/2)
+#define CORECLDFBLEN 20
+#define TOTCLDFBLEN 40
+#define FFTCLDFBLEN (FFTLEN2+TOTCLDFBLEN-CORECLDFBLEN)
+#define PERIODOGLEN (FFTLEN2-2)
+#define NPART 24
+#define NPARTCLDFB 10
+#define NPART_SHAPING 62
+
+#define MSSUBFRLEN 12
+#define MSNUMSUBFR 6
+#define MSBUFLEN 5
+
+#define NOISE_HEADROOM 5 /* headroom of noise in generate_masking_noise */
+
+#define MSALPHACORALPHA 22938/*0.7f Q15*/
+#define MSALPHACORALPHA2 9830/*0.3f Q15*/
+#define MSALPHACORMAX 9830/*0.3f Q15*/
+#define MSALPHAMAX 31457/*0.96f Q15*/
+#define MSALPHAHATMIN 107374184l/*0.05f Q31*/
+#define MSQEQINVMAX 6554/*1.f/5.f Q15*/
+#define MSAV 17367/*2.12f Q13*/
+#define MSAV_EXP 2
+#define MSBETAMAX 1717986944l/*0.8f Q31*/
+#define MSBETAMAX_SQRT 1920767767l/*0.894427191 Q31*/ /* sqrt(MSBETAMAX) */
+#define MSSNREXP -10240/*-0.02f/0.064f Q15*/
+
+#define NB_LAST_BAND_SCALE 26214/*0.8f Q15*/
+#define SWB_13k2_LAST_BAND_SCALE 26214/*0.8f Q15*/
+
+#define M_MAX 32
+#define NSTAGES_MAX 9
+#define MBEST_MAX 8
+#define N_GAIN_MIN 4
+#define N_GAIN_MAX 17
+
+#define numSlots_inv_EXP (-3)
+#define PREEMPH_COMPENSATION_EXP 4
+
+#define CLDFBscalingFactor_EXP (-15)
+#define CLDFBinvScalingFactor_EXP ( 16)
+
+#define CNG_NORM_RECIPROCAL_RANGE_SHIFT 2
+#define CNG_RAND_GAUSS_SHIFT 2
+
+#define CNA_MAX_BRATE 13200
+
+/*----------------------------------------------------------------------------------*
+ * Bass post-filter constants
+ *----------------------------------------------------------------------------------*/
+
+#define NBPSF_PIT_MAX (PIT16k_MAX+1) /* maximum pitch value for bass post-filter */
+#define L_TRACK_HIST 10
+
+/*----------------------------------------------------------------------------------*
+ * NB post-filter constants
+ *----------------------------------------------------------------------------------*/
+
+#define LONG_H_ST 20 /* NB post-filter - impulse response length */
+#define GAMMA1_PST12K_FX 24576 /* denominator weighting factor 12K (0.75 in Q15) */
+#define GAMMA2_PST12K_FX 22938 /* numerator weighting factor 12K (0.7 in Q15) */
+#define POST_G1_FX GAMMA1_PST12K_FX /* 12 kbps default */
+#define POST_G2_FX GAMMA2_PST12K_FX /* 12 kbps default */
+#define GAMMA1_PST12K_MIN_FX 21299 /* 0.65 in Q15 */
+#define GAMMA2_PST12K_MIN_FX 18022 /* 0.55 in Q15 */
+#define GAMMA1_PST12K_NOIS_FX 4915 /* 0.15 in Q15 */
+#define GAMMA2_PST12K_NOIS_FX 3277 /* 0.10 in Q15 */
+#define F_UP_PST 8 /* NB post-filter - resolution for fractionnal delay */
+#define LH2_S 4 /* NB post-filter - length of INT16 interp. subfilters */
+#define LH2_L 16 /* NB post-filter - length of long interp. subfilters */
+#define LH_UP_S (LH2_S/2)
+#define LH_UP_L (LH2_L/2)
+#define LH2_L_P1 (LH2_L + 1)
+#define DECMEM_RES2 (PIT16k_MAX + 2 + LH_UP_L)
+#define SIZ_RES2 (DECMEM_RES2 + L_SUBFR)
+#define SIZ_Y_UP ((F_UP_PST-1) * (L_SUBFR+1))
+#define SIZ_TAB_HUP_L ((F_UP_PST-1) * LH2_L)
+#define SIZ_TAB_HUP_S ((F_UP_PST-1) * LH2_S)
+#define BG1_FX -328 /* -0.01 in Q15 */
+#define BG2_FX -1638 /* -0.05 in Q15 */
+#define CG1_FX 29491 /* 0.9 in Q15 */
+#define CG2_FX 47514L /* 1.45 in Q15 */
+#define C_LP_NOISE_FX 819 /* 0.1/4.0 in Q15 */
+#define CK_LP_NOISE_FX 6291456L /* 15.0 * 0.1/4 in Q8 * 65536 */
+#define LP_NOISE_THR_FX 6400 /* 25.0 in Q8 */
+
+/*----------------------------------------------------------------------------------*
+ * Stability estimation
+ *----------------------------------------------------------------------------------*/
+
+#define NB_BFI_THR 2 /* threshold for counter of last bad frames */
+#define MAX_LT 40
+
+#define TH_0_MIN_FX 5120 /* 2.5f in Q11 */
+#define TH_1_MIN_FX 3840 /* 1.875f in Q11 */
+#define TH_2_MIN_FX 3200 /* 1.5625f in Q11 */
+#define TH_3_MIN_FX 2688 /* 1.3125f in Q11 */
+
+/*----------------------------------------------------------------------------------*
+ * Speech/music classifier constants
+ *----------------------------------------------------------------------------------*/
+
+#define N_FEATURES 12 /* number of features */
+#define N_MIXTURES 6 /* number of mixtures */
+#define M_LSP_SPMUS 6 /* number of LSPs used in speech/music classifier */
+#define NB_BANDS_SPMUS 15
+#define START_BAND_SPMUS 2
+#define N_OLD_BIN_E 42
+
+#define LOWEST_FBIN 3 /* lowest frequency bin for feature vector preparation */
+#define HIGHEST_FBIN 70 /* highest frequency bin for feature vector preparation */
+#define HANG_LEN_INIT 8 /* number of frames for hang-over (causes delay of decision) */
+#define HANG_LEN 8
+#define BUF_LEN 60
+#define L_OVR 8
+
+#define N_FEATURES_2 3 /* number of features */
+
+/*----------------------------------------------------------------------------------*
+ * LD music post-filter constants
+ *----------------------------------------------------------------------------------*/
+
+#define TH_0_MIN2_FX 3840 /* Q11 -> 1.875 */
+#define TH_1_MIN2_FX 2560 /* Q11 -> 1.25 */
+#define TH_2_MIN2_FX 1920 /* Q11 -> 0.9375 */
+#define TH_3_MIN2_FX 1280 /* Q11 -> 0.625 */
+
+#define DCT_L_POST 640
+#define OFFSET2 192
+
+#define VOIC_BINS_HR 640
+#define BIN_16kdct (6400/DCT_L_POST)
+#define NB_LIMIT_BAND 16
+#define MBANDS_GN_LD 20 /* number of bands for gain coding in the postfilter */
+
+/*----------------------------------------------------------------------------------*
+ * AC mode (GSC) constants
+ *----------------------------------------------------------------------------------*/
+
+#define NOISE_LEVEL_SP0 8
+#define NOISE_LEVEL_SP1a 9
+#define NOISE_LEVEL_SP1 10
+#define NOISE_LEVEL_SP2 12
+#define NOISE_LEVEL_SP3 14
+
+#define MAX_DYNAMIC 82
+#define MIN_DYNAMIC 50
+#define DYNAMIC_RANGE (MAX_DYNAMIC-MIN_DYNAMIC)
+#define MAX_GSC_NF_BITS 3
+#define GSC_NF_STEPS (1 << MAX_GSC_NF_BITS)
+
+#define CRIT_NOIS_BAND 23
+
+#define SSF 32 /* Sub-subframe length for energy estimation in UC decision */
+#define NB_SSF (L_FRAME / SSF) /* number of sub-subframes per frame */
+
+
+#define MBANDS_GN 16 /* Number of band for gain coding in GSC */
+#define BAND1k2 3
+
+#define MBANDS_LOC (MBANDS_GN-1)
+#define SWNB_SUBFR 1
+
+#define VAR_COR_LEN 10
+
+#define CFREQ_BITRATE ACELP_11k60
+
+#define LT_UV_THR 100
+#define LT_UV_THRMID 70
+
+#define PIT_EXC_L_SUBFR L_FRAME
+#define LOCAL_CT VOICED
+
+#define Q_PVQ_OUT 10
+
+/*----------------------------------------------------------------------------------*
+ * Core Switching constants
+ *----------------------------------------------------------------------------------*/
+
+#define SWITCH_MAX_GAP 360 /* 6.25 + 1.25 of filter mem max */
+
+/*----------------------------------------------------------------------------------*
+ * HQ core constants
+ *----------------------------------------------------------------------------------*/
+
+#define HQ_NORMAL 0
+#define HQ_TRANSIENT 1
+#define HQ_HARMONIC 2
+#define HQ_HVQ 3
+#define HQ_GEN_SWB 4
+#define HQ_GEN_FB 5
+
+#define PREECHO_SMOOTH_LEN 20
+
+#define MAX16B 32767
+#define MIN16B (-32768)
+
+#define ALDO_WINDOW 4
+#define WINDECAY48 1230
+#define WINDECAY48_256 656
+#define WINDECAY16 410
+#define N16_CORE_SW 90
+#define N_ZERO_8 45
+
+#define SWITCH_OVERLAP_8k 15
+#define SWITCH_GAP_LENGTH_8k 50
+
+#define MAX_SEGMENT_LENGTH 480
+#define NUM_TIME_SWITCHING_BLOCKS 4
+#define NUM_MAP_BANDS 20
+#define NUM_MAP_BANDS_HQ_24k4 17
+#define NUM_MAP_BANDS_HQ_32k 18
+#define FREQ_LENGTH 800
+
+#define STOP_BAND 800
+
+#define SFM_G1 16
+#define SFM_G1G2 24
+#define SFM_N_NB 18
+#define SFM_N_WB 26
+#define SFM_N_STA_8k 27
+#define SFM_N_STA_10k 30
+#define SFM_N_ENV_STAB SFM_N_STA_8k /* Number of bands for env_stab stability measure */
+#define SFM_N_ENV_STAB_WB SFM_N_WB /* Number of bands for env_stab stability measure used in HQPLC decision for WB signals */
+#define SFM_N_HARMONIC 39
+#define SFM_N 36
+
+#define L_HQ_WB_BWE 20 /* == band_end_wb[SFM_N_WB-1] - (band_start_wb[SFM_N_WB-1]+12) */
+#define N_INTL_GRP_16 2 /* Number of interleaving band groups at 16kHz samplerate */
+#define N_INTL_GRP_32 2 /* Number of interleaving band groups at 32kHz samplerate */
+#define N_INTL_GRP_48 3 /* Number of interleaving band groups at 48kHz samplerate */
+#define SFM_N_SWB 39
+#define SFM_N_HARM 31
+#define SFM_N_HARM_FB 33
+#define NB_SFM 44
+#define NB_SFM_MAX 58
+#define WID_G1 8
+#define WID_G2 16
+#define WID_G3 24
+#define WID_GX 32
+#define NUMC_N 544
+#define HQ_MAX_BAND_LEN 96 /* Largest bandwidth in HQ mode (band_len_harm[32]) */
+#define HVQ_PVQ_BUF_LEN (HVQ_PVQ_COEFS*(MAX_PVQ_BANDS-1) + HQ_MAX_BAND_LEN) /* 24*7+96 = 216 */
+
+#define QBIT_MAX2 9
+
+#define FLAGN_BITS 1
+#define GAIN0_BITS 5
+#define GAINI_BITS 5
+
+#define FLAGS_BITS 2
+#define FLAGS_BITS_FB 3
+#define NORM0_BITS 5
+#define NORMI_BITS 5
+#define NUMNRMIBITS_SWB_STA_8k 5*(SFM_N_STA_8k-1)
+#define NUMNRMIBITS_SWB_STA_10k 5*(SFM_N_STA_10k-1)
+#define NUMNRMIBITS_SWB_HARMONIC 185
+#define NUMNRMIBITS_SWB 190
+#define NUMNRMIBITS 215
+#define NUMNRMIBITS_WB 125
+
+#define NOHUFCODE 0
+#define HUFCODE 1
+#define HUFF_THR 10
+#define NOSUPERPOSITION 40
+
+#define MAXVALUEOFFIRSTGAIN_FX 20480 /*2.5f in Q13 */
+#define MINVALUEOFFIRSTGAIN_FX -20480
+#define NOOFGAINBITS1 6
+
+#define AUDIODELAYBITS 6
+#define DELTAOFFIRSTGAIN_FX 2601 /*Q15 */
+
+#define MAX_D1M_16k ((L_FRAME16k>>1) - NS2SA(16000,SWITCH_GAP_LENGTH_NS) - 16)
+#define MAX_D1M_12k8 ((L_FRAME16k>>1) - NS2SA(16000,SWITCH_GAP_LENGTH_NS) - 20)
+
+#define MAX_P_ATT 40 /* Maximum number of pulses for gain attenuation factor */
+#define NB_G 4 /* Number of band groups */
+#define MAX_GAIN_BITS 5 /* Maximum number of gain bits */
+
+#define ENV_ADJ_START 6 /* Number of consecutive bands for which the attenuation is maximum */
+#define ENV_ADJ_INCL 5 /* Inclination for mapping between attenuation region width and attenuation limit */
+
+#define L_STAB_TBL 10 /* Number of elements in stability transition table */
+#define LUMPED_ENV_SMOOTH_FAC_FX ((Word16)10089) /* Q19 (no typo error), 0.1/sqrt(27) */
+#define CMPLMNT_ENV_SMOOTH_FAC_FX ((Word16)29491) /* Q15 0.9 */
+#define M_STAB_TBL_FX ((Word16)21068) /* Q13, 2.571756 */
+#define HALF_D_STAB_TBL_FX ((Word16) 422) /* Q13 0.1013138/2.0 */
+#define D_STAB_TBL_FX ((Word16) 845) /* Q13 0.1013138 */
+#define NUM_ENV_STAB_PLC_STATES 2 /* Number of states of markov model */
+#define INV_NUM_ENV_STAB_PLC_STATES 16384 /* Q15 */
+#define INV_STAB_TRANS_FX 16497 /* Q14. Equal to 1.0f/(1-2*stab_trans_fx[L_STAB_TBL-1]) */
+
+#define ATT_LIM_HANGOVER 150 /* Number of hangover frames for disabling stability dependent attenuation */
+
+#define START_EXC 60
+#define L_HARMONIC_EXC 202
+
+#define HQ_GENERIC_OFFSET 2
+#define HQ_GENERIC_END_FREQ 560
+
+#define HQ_GENERIC_FOFFSET_24K4 80
+#define HQ_GENERIC_FOFFSET_32K 144
+#define HQ_GENERIC_SWB_NBITS 31
+#define HQ_GENERIC_SWB_NBITS2 30
+#define HQ_GENERIC_FB_NBITS 5
+
+#define HQ_GENERIC_ST_FREQ 224
+#define HQ_GENERIC_LOW0 80
+#define HQ_GENERIC_HIGH0 240
+#define HQ_GENERIC_HIGH1 368
+#define HQ_GENERIC_HIGH2 496
+#define HQ_GENERIC_LEN0 128
+#define HQ_GENERIC_NVQIDX 6
+
+#define HQ_GENERIC_EXC0 0
+#define HQ_GENERIC_EXC1 1
+#define HQ_GENERIC_SP_EXC 2
+
+
+#define DIM_FB 3
+#define HQ_FB_FENV SWB_FENV + DIM_FB
+#define N_CB_FB 32
+
+#define HVQ_THRES_BIN_24k 224
+#define HVQ_THRES_SFM_24k 22
+#define HVQ_THRES_BIN_32k 320
+#define HVQ_THRES_SFM_32k 25
+#define HVQ_MIN_PEAKS 2
+#define HVQ_MAX_PEAKS_32k 23
+#define HVQ_MAX_PEAKS_24k 17
+#define HVQ_MAX_PEAKS_24k_CLAS 20 /* Limit for HVQ mode */
+#define HVQ_MAX_PEAKS HVQ_MAX_PEAKS_32k + 1
+#define HVQ_NUM_SFM_24k (SFM_N_HARMONIC - 1 - HVQ_THRES_SFM_24k)
+#define HVQ_NUM_SFM_32k (SFM_N_HARMONIC - 1 - HVQ_THRES_SFM_32k)
+
+#define HVQ_MAX_RATE 32000
+
+
+
+#define NUMNRMIBITS_SWB_HVQ_24k 35
+#define NUMNRMIBITS_SWB_HVQ_32k 25
+
+#define MAX_PVQ_BANDS 8
+#define HVQ_MAX_PVQ_WORDS ((HVQ_MAX_RATE/50)/16 + MAX_PVQ_BANDS)
+#define HVQ_MAX_POS_WORDS 40
+#define HVQ_PVQ_COEFS 24
+#define HVQ_BAND_MIN_PULSES 2
+#define HVQ_BAND_MAX_BITS_24k 80
+#define HVQ_BAND_MAX_BITS_32k 95
+#define HVQ_NEW_BAND_BIT_THR 30
+
+#define HVQ_NF_GROUPS 2
+#define HVQ_NF_WEIGHT1_FX 31385 /* Q15 0.9578 - HVQ Classifier - Noise floor estimate weight 1 */
+#define HVQ_NF_WEIGHT1B 1383 /* Q15, 1 - HVQ_NF_WEIGHT1_FX */
+#define HVQ_NF_WEIGHT2_FX 21207 /* Q15 0.6472 - HVQ Classifier - Noise floor estimate weight 2 */
+#define HVQ_NF_WEIGHT2B 11561 /* Q15 1 - HVQ_NF_WEIGHT2_FX */
+#define HVQ_PE_WEIGHT1_FX 13840 /* Q15 0.42237 - HVQ Classifier - Peak envelope estimate weight 1 */
+#define HVQ_PE_WEIGHT1B 18928 /* Q15, 1 - HVQ_PE_WEIGHT1_FX */
+#define HVQ_PE_WEIGHT2_FX 26308 /* Q15 0.80285 - HVQ Classifier - Peak envelope estimate weight 2 */
+#define HVQ_PE_WEIGHT2B 6460 /* Q15, 1 - HVQ_PE_WEIGHT2_FX */
+#define HVQ_SHARP_THRES_FX 576 /*9 in Q6 */
+
+#define HVQ_PA_FAC_FX 23170 /* Q15 0.7071 - HVQ Classifier peak allocation factor */
+#define HVQ_PA_PEAKS_SHARP1 9 /* HVQ Classifier - Maximum number of peaks for band with high sharpness */
+#define HVQ_PA_PEAKS_SHARP2 3 /* HVQ Classifier - Maximum number of peaks for band with medium sharpness */
+#define HVQ_PA_PEAKS_SHARP3 2 /* HVQ Classifier - Maximum number of peaks for band with low sharpness */
+#define HVQ_PA_SHARP_THRES2_FX 1024 /* Q6 16.0 - HVQ Classifier - Sharpness threshold for band with medium sharpness */
+#define HVQ_PA_SHARP_THRES3_FX 768 /* Q6 12.0 - HVQ Classifier - Sharpness threshold for band with low sharpness */
+
+#define HVQ_BW 32 /* HVQ Classifier subband bandwidth */
+#define HVQ_NSUB_32k 10
+#define HVQ_NSUB_24k 7 /* HVQ Classifier number of subbands */
+
+#define HVQ_BWE_NOISE_BANDS 2 /* Number of BWE noise bands */
+#define HVQ_BWE_WEIGHT1_FX ((Word16)31130) /* 0.95 in Q15 */
+#define HVQ_BWE_WEIGHT2_FX ((Word16)6554) /* 0.2 in Q15 */
+#define HVQ_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 6.4^3 in Q6 */
+#define HVQ_LB_NFPE_FACTOR_CUBE_FX ((Word16)16777) /* 3.2^3 in Q9 */
+
+#define HVQ_VQ_DIM 5 /* HVQ peak VQ dimension */
+#define HVQ_PVQ_GAIN_BITS 5 /* Number of bits to encode PVQ gains in HVQ */
+#define HVQ_NUM_CLASS 4 /* Number of codebook classes */
+#define HVQ_CB_SIZE 256
+
+#define NUM_PG_HUFFLEN 9 /* Number of Huffman codewords for peak gains */
+#define MAX_PG_HUFFLEN 12 /* Length of the longest codeword for peak gain Huffman coding */
+
+#define HVQ_CP_HUFF_OFFSET 3 /* HVQ Code Pos - Delta offset */
+#define HVQ_CP_HUFF_MAX 51 /* HVQ Code Pos - Maximum delta for huffman coding */
+#define HVQ_CP_HUFF_MAX_CODE 13 /* HVQ Code Pos - Size of largest code word */
+#define HVQ_CP_HUFF_NUM_LEN 11 /* HVQ Code Pos - Number of different huffman lengths */
+#define HVQ_CP_L2_MAX 64 /* HVQ Code Pos - Layer 2 maximum size */
+#define HVQ_CP_L1_LEN 5 /* HVQ Code Pos - Layer 1 block size */
+#define HVQ_CP_MAP_LEN 8 /* HVQ Code Pos - Mapping table size */
+#define HVQ_CP_MAP_IDX_LEN 3 /* HVQ Code Pos - Mapping index size */
+#define HVQ_CP_DELTA 0 /* HVQ Code Pos - Use Delta coding */
+#define HVQ_CP_SPARSE 1 /* HVQ Code Pos - Use Sparse coding */
+
+#define MAX_SPLITS 10 /* Maximum number of PVQ band splits */
+
+#define QUANTAQ3OFFSET 1
+enum QuantaMode { NEAREST = 0, CONS };
+#define PYR_OFFSET 1
+#define RCF_INIT_SHIFT 14
+
+#define THR_ADD_SPLIT 7 /* Threshold for using additional split */
+#define PVQ_MAX_BAND_SIZE 64 /* Maxiumum supported band size for PVQ search */
+#define MIN_BAND_SIZE 1 /* Minimum supported band size for PVQ search */
+#define RC_BITS_RESERVED 1
+#define MAX_PVQ_BITS_PER_COEFFICIENT 80 /* Maximum bits per coefficient allocated per PVQ band. Q3. */
+
+/* index_pvq constants */
+#define KMAX_FX 512
+
+#define KMAX_NON_DIRECT_FX 96 /* max K for non-direct indexing recursion rows is 1+KMAX_NON_DIRECT +1 */
+#define ODD_DIV_SIZE_FX 48 /* ind0=1/1 ind1 =1/3 ... ind47=1/95 */
+
+
+/* TCQ */
+#define TCQ_MAX_BAND_SIZE 120 /* Maxiumum supported band size for TCQ+USQ search */
+#define STATES 8
+#define MAX_AR_FREQ 16383
+#define AR_BITS 16
+#define STATES_LSB 4
+#define TCQ_LSB_SIZE 24
+#define TCQ_AMP 10
+
+#define AR_TOP ( ( 1 << AR_BITS ) - 1 )
+#define AR_FIRST ( AR_TOP / 4 + 1 )
+#define AR_HALF ( 2 * AR_FIRST )
+#define AR_THIRD ( 3 * AR_FIRST )
+
+#define MAX_SIZEBUF_PBITSTREAM 1024
+
+/*----------------------------------------------------------------------------------*
+ * SWB BWE for LR MDCT core
+ *----------------------------------------------------------------------------------*/
+/* Q value */
+#define SWB_BWE_LR_Qs 12 /* Q value of spectra (Word32) */
+#define SWB_BWE_LR_Qbe 14 /* Q value of band_energy (Word32) */
+#define SWB_BWE_LR_QRk 16 /* Q value of Rk, Rcalc (Word32) */
+#define SWB_BWE_LR_QsEn 4 /* Q value of smoothed sqrt band energy */
+
+#define G1_RANGE 4
+#define G1G2_RANGE 15
+#define GRP_SB 4 /*Maximum subband groups*/
+#define THR1 4 /* Bit allocation threshold value */
+#define THR2 5 /* Bit allocation threshold value */
+#define THR3 6 /* Bit allocation threshold value */
+
+#define NB_SWB_SUBBANDS 4 /* maximum number of subbands in normal2 subband coding */
+
+#define SWB_SB_LEN0_12KBPS 55/* length of subband number X in lowest bit rate operation */
+#define SWB_SB_LEN1_12KBPS 68
+#define SWB_SB_LEN2_12KBPS 84
+#define SWB_SB_LEN3_12KBPS 105
+
+#define SWB_HIGHBAND_12KBPS (SWB_SB_LEN0_12KBPS+SWB_SB_LEN1_12KBPS+SWB_SB_LEN2_12KBPS+SWB_SB_LEN3_12KBPS)
+#define SWB_LOWBAND_12KBPS (HQ_GENERIC_END_FREQ - SWB_HIGHBAND_12KBPS)
+#define SWB_HIGHBAND_MAX SWB_HIGHBAND_12KBPS
+#define SWB_LOWBAND_MAX SWB_LOWBAND_12KBPS
+
+#define SWB_SB_OFF0_12KBPS 0 /* subband offsets are based on the subband lengths */
+#define SWB_SB_OFF1_12KBPS (SWB_SB_OFF0_12KBPS + SWB_SB_LEN0_12KBPS)
+#define SWB_SB_OFF2_12KBPS (SWB_SB_OFF1_12KBPS + SWB_SB_LEN1_12KBPS)
+#define SWB_SB_OFF3_12KBPS (SWB_SB_OFF2_12KBPS + SWB_SB_LEN2_12KBPS)
+#define SWB_SB_OFF4_12KBPS (SWB_SB_OFF3_12KBPS + SWB_SB_LEN3_12KBPS)
+
+/* 16.4 kbps */
+#define SWB_SB_LEN0_16KBPS 59/* length of subband number X in lowest bit rate operation */
+#define SWB_SB_LEN1_16KBPS 74
+#define SWB_SB_LEN2_16KBPS 92
+#define SWB_SB_LEN3_16KBPS 115
+
+#define SWB_HIGHBAND_16KBPS (SWB_SB_LEN0_16KBPS+SWB_SB_LEN1_16KBPS+SWB_SB_LEN2_16KBPS+SWB_SB_LEN3_16KBPS)
+#define SWB_LOWBAND_16KBPS (HQ_GENERIC_END_FREQ - SWB_HIGHBAND_16KBPS)
+
+#define SWB_SB_OFF0_16KBPS 0 /* subband offsets are based on the subband lengths */
+#define SWB_SB_OFF1_16KBPS (SWB_SB_OFF0_16KBPS + SWB_SB_LEN0_16KBPS)
+#define SWB_SB_OFF2_16KBPS (SWB_SB_OFF1_16KBPS + SWB_SB_LEN1_16KBPS)
+#define SWB_SB_OFF3_16KBPS (SWB_SB_OFF2_16KBPS + SWB_SB_LEN2_16KBPS)
+#define SWB_SB_OFF4_16KBPS (SWB_SB_OFF3_16KBPS + SWB_SB_LEN3_16KBPS)
+
+/* SpectrumSmoothing */
+#define L_SB 12 /* subband length for SpectrumSmoothing */
+
+/* SpectrumSmoothing for NSS */
+#define L_SB_NSS 8
+#define L_SB_NSS_HALF (L_SB_NSS/2)
+#define NUM_SUBBAND_SMOOTH_MAX (L_FRAME32k/L_SB_NSS+1)
+#define MA_LEN 7
+
+/* Harmonic mode */
+#define NB_SWB_SUBBANDS_HAR_SEARCH_SB 2 /* search number of subbands in harmonic subband coding */
+#define NB_SWB_SUBBANDS_HAR 4 /* maximum number of subbands in harmonic subband coding */
+
+
+#define N_NBIGGEST_PULSEARCH 18
+#define N_NBIGGEST_SEARCH_LRG_B 32
+
+
+/* 13.2 kbps */
+#define SWB_SB_BW_LEN0_12KBPS_HAR 56 /* Group 1 length for BWE */
+#define SWB_SB_BW_LEN1_12KBPS_HAR 100 /* Group 2 Length for BWE */
+#define SWB_SB_BW_LEN2_12KBPS_HAR SWB_SB_BW_LEN1_12KBPS_HAR
+#define SWB_SB_BW_LEN3_12KBPS_HAR SWB_SB_BW_LEN0_12KBPS_HAR
+
+/* 16.4 kbps */
+#define SWB_SB_BW_LEN0_16KBPS_HAR 60 /* Group 1 length for BWE */
+#define SWB_SB_BW_LEN1_16KBPS_HAR 110 /* Group 2 Length for BWE */
+#define SWB_SB_BW_LEN2_16KBPS_HAR SWB_SB_BW_LEN1_16KBPS_HAR
+#define SWB_SB_BW_LEN3_16KBPS_HAR SWB_SB_BW_LEN0_16KBPS_HAR
+
+#define SWB_SB_OFF0_SUB5_12KBPS_HAR 0 /* subband offsets are based on the subband lengths */
+#define SWB_SB_OFF1_SUB5_12KBPS_HAR (SWB_SB_OFF0_SUB5_12KBPS_HAR + SWB_SB_BW_LEN0_12KBPS_HAR)
+#define SWB_SB_OFF2_SUB5_12KBPS_HAR (SWB_SB_OFF1_SUB5_12KBPS_HAR + SWB_SB_BW_LEN1_12KBPS_HAR)
+#define SWB_SB_OFF3_SUB5_12KBPS_HAR (SWB_SB_OFF2_SUB5_12KBPS_HAR + SWB_SB_BW_LEN2_12KBPS_HAR)
+
+#define SWB_SB_OFF0_SUB5_16KBPS_HAR 0 /* subband offsets are based on the subband lengths */
+#define SWB_SB_OFF1_SUB5_16KBPS_HAR (SWB_SB_OFF0_SUB5_16KBPS_HAR + SWB_SB_BW_LEN0_16KBPS_HAR)
+#define SWB_SB_OFF2_SUB5_16KBPS_HAR (SWB_SB_OFF1_SUB5_16KBPS_HAR + SWB_SB_BW_LEN1_16KBPS_HAR)
+#define SWB_SB_OFF3_SUB5_16KBPS_HAR (SWB_SB_OFF2_SUB5_16KBPS_HAR + SWB_SB_BW_LEN2_16KBPS_HAR)
+
+#define LR_BLK_LEN 16
+#define LR_HLF_PK_BLK_LEN 8
+#define LR_LOWBAND_DIF_PK_LEN 10
+#define SWB_HAR_RAN1 80
+#define SWB_HAR_RAN2 140
+#define SWB_HAR_RAN3 200
+#define SPT_SHORTEN_SBNUM 4
+
+/*----------------------------------------------------------------------------------*
+ * FEC for HQ core
+ *----------------------------------------------------------------------------------*/
+
+#define MAX_PGF 7
+#define MAX_ROW 2
+
+#define MINIMUM_RATE_TO_ENCODE_VOICING_FLAG 45000
+#define FRAMECTTOSTART_MDCT 3
+
+/*----------------------------------------------------------------------------------*
+ * Channel-aware mode (FEC)
+ *----------------------------------------------------------------------------------*/
+
+#define FEC_OFFSET 3
+#define MAX_RF_FEC_OFFSET 9
+
+/*----------------------------------------------------------------------------------*
+ * HQ FEC
+ *----------------------------------------------------------------------------------*/
+
+#define MAXDELAY_FEC 224
+
+#define PH_ECU_ALDO_OLP2_NS (ACELP_LOOK_NS/2) /* half the aldo window overlap */
+#define PH_ECU_LOOKAHEAD_NS (11*ACELP_LOOK_NS/(7*2)) /* Number of nanoseconds look-ahead ahead from the end of the past synthesized frame */
+#define PH_ECU_MEM_NS ((Lprot48k/48 - 20)*1000000-PH_ECU_LOOKAHEAD_NS) /* Number of nanoseconds memory for Phase ECU before the old_synthFB_fx pointer */
+#define POST_HQ_DELAY_NS DELAY_BWE_TOTAL_NS /* delay of post processing after core HQ coding */
+#define MAX_PLOCS Lprot48k/4+1 /* maximum number of spectral peaks to be searched */
+#define Lprot32k 1024 /* HQ phase ECU prototype frame length */
+#define Lprot32k_2 Lprot32k/2
+#define Quot_Lpr_Ltr 4
+#define Lgw_max 9 /* maximum number frequency group widths */
+#define BETA_MUTE_FAC_INI 16384 /* Q15, initial noise attenuation factor */
+#define Ltrana32k (Lprot32k/Quot_Lpr_Ltr) /* transient analysis frame length */
+#define Ltrana16k Ltrana32k/2
+#define pfind_sens 0.9f /* peakfinder sensitivity - tuning parameter */
+#define Lprot_hamm_len2_48k NS2SA(48000,6000000L)
+#define Lprot_hamm_len2_32k NS2SA(32000,6000000L)
+#define Lprot_hamm_len2_16k NS2SA(16000,6000000L)
+#define Lprot48k Lprot32k * 3/2 /* HQ phase ECU prototype frame length */
+#define Lprot48k_2 Lprot48k/2
+#define Ltrana48k (Lprot48k/Quot_Lpr_Ltr) /* transient analysis frame length */
+#define PH_ECU_SPEC_SIZE Lprot48k
+#define T_SIN_PI_2 PH_ECU_SPEC_SIZE/4
+#define RANDOM_START 1
+#define HQ_FEC_SIGN_SFM 16
+#define HQ_FEC_SIGN_THRES 6
+#define HQ_FEC_SIGN_THRES_TRANS 3
+#define HQ_FEC_BAND_SIZE 4
+
+/*--------------------------------------------------------------*
+ * Tonal MDCT PLC constants
+ *---------------------------------------------------------------*/
+#define SPEC_EXP_DEC 20
+
+#define MAX_NUMBER_OF_IDX 30
+#define GROUP_LENGTH 7
+#define MAX_PEAKS_FROM_PITCH 10
+#define LAST_HARMONIC_POS_TO_CHECK 128 /* 128 because we check harmonics only up to 3.2 kHz */
+#define FILTLEN 15
+#define ALLOWED_SIDE_LOBE_FLUCTUATION 24576/*3.0f Q13*/ /* 4.8 dB */
+#define ALLOWED_SIDE_LOBE_FLUCTUATION_EXP 2
+#define LEVEL_ABOVE_ENVELOPE 7.59f /* 8.8 dB */
+#define UNREACHABLE_THRESHOLD 16384/*16.0f Q10*/ /* 12 dB Increase of LEVEL_ABOVE_ENVELOPE so that the threshold is not reached */
+#define SMALL_THRESHOLD 1126/*1.10f Q10*/ /* 0.41 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a definitive peak in the estimated spectrum */
+#define BIG_THRESHOLD 1536/*1.5f Q10*/ /* 1.76 dB Increase of LEVEL_ABOVE_ENVELOPE for the peak detection at a probable peak in the estimated spectrum */
+
+#define kSmallerLagsTargetBitsThreshold 150
+
+#define kLtpHmGainThr 0x3AE1 /* 0.46f */
+#define kCtxHmOlRSThr 0x5333 /* 2.6f (2Q13) */
+
+#define kTcxHmSnrOffsetGc 8/*0.03125f Q8*/
+#define kTcxHmSnrOffsetVc 0
+
+#define kTcxHmNumGainBits 2 /* Number of bits for the gain index */
+#define kTcxHmParabolaHalfWidth 4 /* Parabola half width */
+#define kLtpHmGainThr 0x3AE1 /* 0.46f */ /* Use the LTP pitch lag in the harmonic model? */
+
+#define kSmallerLagsTargetBitsThreshold 150
+
+#define TCX_LPC_OFFSET_SNR
+
+#define kTcxSnrOffsetGc 0x08 /* 0.03125f (7Q8) */
+#define kTcxSnrOffsetVc 0x20 /* 0.125f (7Q8) */
+
+#define LOWRATE_TCXLPC_MAX_BR ACELP_9k60
+
+/*--------------------------------------------------------------*
+ * Waveform-adjustment MDCT PLC
+ *---------------------------------------------------------------*/
+
+#define DEC_STATE_LEN 10
+#define MAX_POST_LEN 3
+#define TCX_TONALITY_INIT_CNT 7
+
+#define TCX_NONTONAL 0
+#define TCX_TONAL 1
+
+/*---------------------------------------------------------------*
+ * IGF *
+ *---------------------------------------------------------------*/
+#define IGF_MAX_TILES 5
+#define IGF_MAX_GRANULE_LEN 1200
+#define IGF_TRANS_FAK 2
+#define IGF_MAX_SFB 23
+#define IGF_NOF_GRIDS 3
+#define IGF_MAX_SUBFRAMES 2
+
+#define IGF_MODE_WB 1
+#define IGF_MODE_SWB 2
+#define IGF_MODE_FB 3
+
+
+#define IGF_BITRATE_WB_9600 0
+#define IGF_BITRATE_RF_WB_13200 1
+#define IGF_BITRATE_SWB_9600 2
+#define IGF_BITRATE_SWB_13200 3
+#define IGF_BITRATE_RF_SWB_13200 4
+#define IGF_BITRATE_SWB_16400 5
+#define IGF_BITRATE_SWB_24400 6
+#define IGF_BITRATE_SWB_32000 7
+#define IGF_BITRATE_SWB_48000 8
+#define IGF_BITRATE_FB_16400 9
+#define IGF_BITRATE_FB_24400 10
+#define IGF_BITRATE_FB_32000 11
+#define IGF_BITRATE_FB_48000 12
+#define IGF_BITRATE_FB_96000 13
+#define IGF_BITRATE_FB_128000 14
+#define IGF_BITRATE_UNKNOWN 15
+
+
+#define IGF_WHITENING_OFF 0
+#define IGF_WHITENING_MID 1
+#define IGF_WHITENING_STRONG 2
+
+#define IGF_GRID_LB_NORM 0
+#define IGF_GRID_LB_TRAN 1
+#define IGF_GRID_LB_SHORT 2
+
+/* constants for IGFSCFDecoder and IGFSCFEncoder */
+#define IGF_CTX_OFFSET 3 /* offset added to make the context values nonnegative, for array indexing */
+#define IGF_CTX_COUNT (2 * IGF_CTX_OFFSET + 1) /* number of contexts for the AC statistical model */
+#define IGF_MIN_ENC_SEPARATE -12 /* minimum residual value coded separately, without escape coding */
+#define IGF_MAX_ENC_SEPARATE +12 /* maximum residual value coded separately, without escape coding */
+#define IGF_SYMBOLS_IN_TABLE (1 + (IGF_MAX_ENC_SEPARATE - IGF_MIN_ENC_SEPARATE + 1) + 1) /* alphabet size */
+
+/*----------------------------------------------------------------------------------*
+ * SC-VBR
+ *----------------------------------------------------------------------------------*/
+
+#define UVG1_CBSIZE 32 /* NELP unvoiced gain-1 codebook size */
+#define UVG2_CBSIZE 64 /* NELP unvoiced gain-2 codebook size */
+
+/* PPP constants */
+
+#define NUM_ERB_WB 24 /* Number of ERB bands in wideband */
+#define NUM_ERB_NB 22 /* Number of ERB bands in narrowband */
+
+#define MAXLAG 180
+
+#define PPP_LAG_THRLD_Q6 180*64
+#define PPP_LAG_THRLD 180
+#define SNR_THLD_FX_Q8 17152 /* Threshold is upscaled to Q8 to compared with st->vadsnr*/
+
+#define MAXLAG_WI (PPP_LAG_THRLD/2 + 12) /* Maximum lag used in waveform interpolation */
+#define MAX_LAG_PIT (PPP_LAG_THRLD + 21)
+
+#define WI_FX_phase_fx 512
+
+#define VBR_ADR_MAX_TARGET_x10_Q1 123 /* VBR_ADR_MAX_TARGET(6.15f)*10 in Q1 */
+
+#define Q_SCALE 7
+
+#define CONST_1_16_Q14 19005 /* 1.16*16384 */
+#define CONST_1_37_Q14 22446 /* 1.37*16384 */
+#define SCALE_DOWN_ERAS_Q15 26214 /* 0.8*32768 */
+#define SHAPE1_COEF_QF 15 /* shape1 num and den coeffcient Q format */
+#define SHAPE2_COEF_QF 15 /* shape2 num and den coeffcient Q format */
+#define SHAPE3_COEF_QF 15 /* shape3 num and den coeffcient Q format */
+#define BP1_COEF_WB_QF 14 /* wb num and den coeffcient Q format */
+#define BP1_COEF_NB_QF_ORDER7 13 /* nb num and den coeffcient Q format */
+
+/*----------------------------------------------------------------------------------*
+ * JBM
+ *----------------------------------------------------------------------------------*/
+
+#define MAX_JBM_SLOTS 100 /* every primary copy and partial copy stored in JBM needs one slot */
+#define MAX_AU_SIZE (128000/50/8) /* max frame size in bytes */
+
+#define ACTIVE 4
+#define BACKGROUND 1
+#define LOST 14
+#define SIZE_UNDERFLOW_ARRAY 10000
+#define TIME_WARP_SPACING 4
+#define FLAG_DECREASING_BUFFER_DEPTH 1
+#define TIME_WARP_SPACING_EXPAND 1
+#define PREALLOCATE_OUTPUT_SIZE 1000
+
+#define TSM_LOST 1
+#define TSM_AUDIO 2
+#define TSM_ONSET 3
+#define TSM_UNVOICED 4
+#define TSM_VOICED 5
+#define TSM_TRANSITION 6
+#define TSM_GENERIC 7
+#define TSM_BACKGROUND 8
+
+/*------------------------------------------------------------------------------------*
+FEC_clas_estim constants
+*-------------------------------------------------------------------------------------*/
+#define Q_MAX 12
+#define LG10 24660 /* 10*log10(2) in Q13 */
+#define L_Q_MEM 5
+
+#define GE_SHIFT 6
+#define LSF_1_OVER_256SQ 5000
+#define LSF_1_OVER_256SQSQ 763
+
+#define G_CODE_MIN_TC_Q15 655 /*0.02 Q15*/
+#define G_CODE_MAX_TC_Q0 5
+
+#define G_PITCH_MIN_Q14 0 /* SQ of gains: pitch gain lower limit (0.0 in Q13) */
+#define G_PITCH_MAX_MINUS_MIN_Q13 9994 /* SQ of gains: pitch gain upper limit (1.22-0 in Q13) */
+
+/* higher ACELP constants */
+#define G_AVQ_MIN_32kbps_Q15 2621 /* lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */
+#define G_AVQ_MIN_Q15 26214 /* lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */
+#define G_AVQ_MAX_Q0 96 /* upper limit for gain Q in higher-rate ACELP contribtuion */
+
+#define LG10_G_AVQ_MIN_32kbps_Q14 (-17972) /* log10(0.08) lower limit for gain Q in higher-rate ACELP contribtuion @32kbps (0.08 in Q15) */
+#define LG10_G_AVQ_MIN_Q14 (-1588) /* log10(0.8) lower limit for gain Q in higher-rate ACELP contribtuion (0.8 in Q15) */
+#define LG10_G_AVQ_MAX_Q13 16239 /* log10(96) upper limit for gain Q in higher-rate ACELP contribtuion */
+#define LG10_G_CODE_MIN_TC192_Q14 (-3635) /* log10(0.6) */
+#define LG10_G_CODE_MAX_TC192_Q13 13212 /* log10(41) */
+#define LG10_G_CODE_MAX_Q13 5726 /* log10(5) SQ of gains: code gain upper limit */
+#define LG10_G_CODE_MIN_Q14 (-27836) /* log10(0.02) SQ of gains: code gain lower limit */
+#define LG10_G_CODE_MIN_TC_Q14 LG10_G_CODE_MIN_Q14 /* log10(0.02) Q15*/
+#define LG10_G_CODE_MAX_TC_Q13 LG10_G_CODE_MAX_Q13
+
+
+/* AVQ (RE8) related consatnts */
+#define QR 32768
+#define Q_AVQ_OUT 6 /* AVQ_output scaling currently Q9, but may change */
+#define Q_AVQ_OUT_DEC 10
+
+
+#define PIT_DECODE_2XL_SUBFR (2*L_SUBFR)
+#define PIT_FR1_8b_MINUS_PIT_MIN_X2 ((PIT_FR1_8b-PIT_MIN)*2)
+#define PIT_FR1_8b_MINUS_PIT_FR1_8b_MINUS_PIT_MIN_X2 (PIT_FR1_8b-PIT_FR1_8b_MINUS_PIT_MIN_X2)
+#define PIT_FR2_9b_MINUS_PIT_MIN_X4 ((PIT_FR2_9b-PIT_MIN)*4)
+#define PIT_FR1_EXT8b_MINUS_PIT_MIN_EXT_X2 ((PIT_FR1_EXTEND_8b-PIT_MIN_EXTEND)*2)
+#define PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4 ((PIT_FR2_EXTEND_9b-PIT_MIN_EXTEND)*4)
+#define PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2 ((PIT_FR1_EXTEND_9b-PIT_FR2_EXTEND_9b)*2)
+#define PIT_FR1_DEXT8b_MINUS_PIT_MIN_DEXT_X2 ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2 )
+#define PIT_FR2_DEXT9b_MINUS_PIT_MIN_DEXT_X4 ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 )
+
+#define PIT_DECODE_1 ((PIT_FR2_9b-PIT_MIN)*4 + (PIT_FR1_9b-PIT_FR2_9b)*2)
+#define PIT_DECODE_2 ((PIT_FR2_9b-PIT_MIN)*4)
+#define PIT_DECODE_3 (PIT_FR1_9b - ((PIT_FR2_9b-PIT_MIN)*4) - ((PIT_FR1_9b-PIT_FR2_9b)*2))
+#define PIT_DECODE_7 (PIT_FR1_EXTEND_9b - (PIT_FR2_EXT9b_MINUS_PIT_MIN_EXT_X4) - (PIT_FR1_EXT9b_MINUS_PIT_FR2_EXT9b_X2))
+#define PIT_DECODE_8 (PIT_FR1_DOUBLEEXTEND_8b - ((PIT_FR1_DOUBLEEXTEND_8b-PIT_MIN_DOUBLEEXTEND)*2))
+#define PIT_DECODE_9 (( (PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4 + (PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2))
+#define PIT_DECODE_10 (PIT_FR1_DOUBLEEXTEND_9b - ((PIT_FR2_DOUBLEEXTEND_9b-PIT_MIN_DOUBLEEXTEND)*4) - ((PIT_FR1_DOUBLEEXTEND_9b-PIT_FR2_DOUBLEEXTEND_9b)*2))
+
+#define BIN4_FX 800
+#define TH_COR_FX 19661 /* Q15 Minimum correlation for per bin processing */
+#define TH_D_FX 800 /* 50 (Q4) Difference limit between nearest harmonic and a frequency bin */
+#define TH_PIT_FX 128 /* (Fs / (2.0f * TH_D)) Maximum pitch for per bin processing */
+
+#define GUESS_TBL_SZ 256
+#define INT_FS_FX 12800 /* internal sampling frequency */
+#define INT_FS_16k_FX 16000 /* CELP core internal sampling frequency @16kHz */
+
+#define WB_LIMIT_LSF_FX 16256
+#define Fs_2 16384 /* lsf max value (Use in reorder_fx.c) */
+#define Fs_2_16k 20480 /* lsf max value (Use in reorder_fx.c) */
+
+#define LG10 24660 /* 10*log10(2) in Q13 */
+#define LG10_s3_0 16440 /* 10*log10(2)/1.55 = 1.00343331 in Q14 */
+
+#define MU_MA_FX 10923 /* original prediction factor for the AMR WB tables (Q15) */
+
+#define E_MIN_FXQ15 115 /* Q15*/
+
+#define MAX_DYNAMIC_FX (82*128)
+#define MIN_DYNAMIC_FX (50*128)
+#define DYNAMIC_RANGE_FX (MAX_DYNAMIC_FX-MIN_DYNAMIC_FX)
+#define MAX_GSC_NF_BITS 3
+#define GSC_NF_STEPS (1 << MAX_GSC_NF_BITS)
+#define GSF_NF_DELTA_FX (DYNAMIC_RANGE_FX/GSC_NF_STEPS)
+
+/*----------------------------------------------------------------------------------*
+ * DTC/iDCT constants
+ *----------------------------------------------------------------------------------*/
+
+/* DCT related */
+#define KP559016994_16FX 1200479845 /* EDCT & EMDCT constants */
+#define KP951056516_16FX 2042378325 /* EDCT & EMDCT constants */
+#define KP587785252_16FX 1262259213 /* EDCT & EMDCT constants */
+
+/*----------------------------------------------------------------------------------*
+ * AVQ constants
+ *----------------------------------------------------------------------------------*/
+
+#define MIN_GLOB_GAIN_BWE_HR_FX 24576 /* Q13 */
+#define MAX_GLOB_GAIN_BWE_HR_FX 32000 /* Q6 */
+
+#define LG10_MIN_GLOB_GAIN_BWE_HR_Q14 7817
+#define LG10_MAX_GLOB_GAIN_BWE_HR_Q13 22110
+
+
+/*----------------------------------------------------------------------------------*
+ * LD music post-filter constants
+ *----------------------------------------------------------------------------------*/
+
+#define BIN_16kdct_fx (6400/DCT_L_POST)
+#define E_MIN_Q15 14680 /* 0.0035 -> Q22 */
+
+#define QSCALE 7
+#define MODE2_E_MIN 4/*0.03f Q0*/ /* 0.03f in QSCALE */
+#define MODE2_E_MIN_Q15 983/*0.03f Q15*/ /* 0.03f in Q15*/
+
+/* long term pst parameters : */
+#define L2_LH2_L 4 /* log2(LH2_L) */
+#define MIN_GPLT_FX 21845 /* LT gain minimum 1/1.5 (Q15) */
+
+#define AGC_FAC_FX 32358 /* gain adjustment factor 0.9875 (Q15) */
+#define AGC_FAC1_FX (Word16)(32768L - AGC_FAC_FX)
+
+#define DOWNMIX_12k8_FX 1850
+
+/*----------------------------------------------------------------------------------*
+ * HQ Constants
+ *----------------------------------------------------------------------------------*/
+
+#define INV2POWHALF 23170 /* Q15, sqrt(2)/2 */
+#define EPSILLON_FX (Word16) 1
+#define MAX_SFM_LEN_FX 96
+#define MAX_P_ATT_FX (Word16) 40 /* Maximum number of pulses for gain attenuation factor */
+#define MAX_PHG_FX (Word16) 10 /* Q0, Maximum number of pulses for which to apply pulse height dependent gain */
+#define PHG_START_FX (Word16) 3277 /* Q15, 0.1f */
+#define PHG_DELTA_FX (Word16) 2621 /* Q15, ((PHG_END-PHG_START)/MAX_PHG) */
+#define ENV_ADJ_START_FX (Word16) 6 /* Q0, Number of consecutive bands for which the attenuation is maximum */
+#define ENV_ADJ_INV_INCL_FX (Word16) 6554 /* Q15, 1/5.0f, Inverse inclination for mapping between attenuation region width and attenuation limit */
+
+#define INV_HVQ_THRES_BIN_24k 9362 /* 1/224 in Q21 */
+#define INV_HVQ_THRES_BIN_32k 6554 /* 1/320 in Q21 */
+#define INV_BANDS_PER_SUBFRAMES 14564 /* 1/9 in Q17 */
+#define NUM_SUBFRAMES 4
+#define BANDS_PER_SUBFRAMES 9
+#define ENERGY_TH_NUM_SUBFRAMES 1638400L /* 400 in Q12 */
+#define INV_SFM_N_ENV_STAB 19418 /* 1/27 in Q19 */
+#define ENERGY_TH_FX 819200L /* 100 in Q13 */
+#define ENERGY_LT_BETA_FX 30474 /* 0.93 in Q15 - Smoothing factor for long-term energy measure */
+#define ENERGY_LT_BETA_1_FX 2294 /* 0.07 i Q15 - (1 - ENERGY_LT_BETA_FX) */
+#define INV_DELTA_TH 13107 /* 1/5 in Q16 - Inverse Delta energy threshold for transient detection for envelope stability */
+
+#define ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX ((Word16) 410) /* Q15, 1/80 = 0.0125 */
+#define ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX ((Word16) 345) /* Q15, 1/95 = 0.010526315 */
+
+#define INV_PREECHO_SMOOTH_LENP1_FX 1560 /*(32768 / (PREECHO_SMOOTH_LEN + 1.0));*/
+
+#define INV_HVQ_BW 1024 /* Q15 1/32 */
+
+#define ACELP_48k_BITS 960 /* Q0 - ACELP_48k / 50 */
+
+
+/*--------------------------------------
+ * FEC_HQ_phase_ecu
+ *-------------------------------------*/
+
+#define OFF_FRAMES_LIMIT 30 /* Hard limit the variable "time_offs" to 30 */
+
+/*----------------------------------------------------------------------------------*
+ * FEC for HQ core
+ *----------------------------------------------------------------------------------*/
+
+
+#define MAX_SB_NB 3
+
+
+#define NELP_LP_ORDER 8
+#define NUM_NELP_GAINS 10
+
+#define N_LEAD_NB 70 /* (N_LEAD_MDCT*(L_FRAME8k/20)) */
+#define N_ZERO_NB 45 /* (N_ZERO_MDCT*(L_FRAME8k/20)) */
+#define N_LEAD_O_NB 90 /* (20.f-N_LEAD_MDCT)*(L_FRAME8k/20) */
+#define N_ZERO_O_NB 35 /* (10.f-N_ZERO_MDCT)*(L_FRAME8k/20) */
+#define N_Z_L_NB 115 /* (N_Z_L_MDCT*(float)(L/20)) = N_ZERO_NB + N_LEAD_NB*/
+#define N_Z_L_O_NB 205 /* (N_Z_L_O_MDCT*(float)(L/20)) = N_ZERO_NB + N_LEAD_NB + N_LEAD_O_NB */
+
+#define ED_THRES_12P_fx 66
+#define ED_THRES_50P_fx 326
+#define ED_THRES_90P_fx 1091
+
+/*----------------------------------------------------------------------------------*
+ * ISF quantizer constants
+ *----------------------------------------------------------------------------------*/
+
+/*qlpc_avq, lsf_msvq_ma*/
+#define W_MODE0 0x1333 /*60.0f/FREQ_DIV in 0Q15*/
+#define W_MODE1 0x14CD /*65.0f/FREQ_DIV in 0Q15*/
+#define W_MODE2 0x147B /*64.0f/FREQ_DIV in 0Q15*/
+#define W_MODE_ELSE 0x1429 /*60.0f/FREQ_DIV in 0Q15*/
+
+
+enum TRACKPOS
+{
+ TRACKPOS_FIXED_FIRST =0, /* Fill tracks from left */
+ TRACKPOS_FIXED_EVEN =1, /* Even tracks */
+ TRACKPOS_FIXED_FIRST_TWO =2, /* One track of 32 */
+ TRACKPOS_FIXED_TWO =3, /* Two tracks of 32 instead of four of 16 */
+ TRACKPOS_FREE_ONE =4, /* One freely moving track with extra pulse */
+ TRACKPOS_FREE_THREE =5 /* Three freely moving tracks with single extra pulses */
+};
+
+#define ALP_E 2
+
+/* Lag window strengths */
+enum
+{
+ LAGW_WEAK, /* weak lag window */
+ LAGW_MEDIUM, /* medium strength lag window */
+ LAGW_STRONG, /* strong lag window */
+
+ NUM_LAGW_STRENGTHS
+};
+
+/* qmc_cng_common.h */
+/* codec side */
+#define SCALE_TABLE_SHIFT_FACTOR (31-23)
+
+/* parameter_bitmapping.h */
+#define NPARAMS_MAX 10
+
+/*tns_tables.h*/
+
+#define TRUE 1
+#define FALSE 0
+
+#define PRED_GAIN_E 8
+
+/* Flags for CLDFB intialization */
+/* Flag indicating that the states should be kept. */
+#define CLDFB_FLAG_KEEP_STATES 8
+/* Flag indicating 2.5 ms setup */
+#define CLDFB_FLAG_2_5MS_SETUP 128
+
+
+/* bits_alloc.h */
+#define RATE_MODE_MAX 2 /*Number of rate mode*/
+#define BANDWIDTH_MODE_MAX 2 /*Number of different bandwidth modes (NB/WB-FB)*/
+
+
+typedef enum SIGNAL_CLASSIFER_MODE
+{
+ CLASSIFIER_ACELP,
+ CLASSIFIER_TCX
+} SIGNAL_CLASSIFIER_MODE;
+
+
+#define NRG_CHANGE_E 8
+#define AVG_FLAT_E 8
+
+#define FRAME_SIZE_NB 13
+
+/* RTP Payload Header Info */
+#define ACTIVE_FRAME 0xFF
+#define SID_FRAME 0xFA
+#define ZERO_FRAME 0xF0
+
+
+/************************************************************************/
+
+/************************************************************************/
+#define UNKNOWN_NOISE 0
+#define SILENCE 1
+
+#define CNT0P1 1717986918 /* 0.1*2^34 */
+#define CNT0P001 1099511627 /* 0.001*2^40 */
+#define CNT0P0001 1759218604 /* 0.0001*2^44 */
+
+#define CNT0P05 1717986918 /* 0.05*2^35 */
+
+#define CNT1DIV28 1227133513 /* (1/28)*2^35 */
+#define CNT1DIV14 1227133513 /* (1/14)*2^34 */
+#define CNT1DIV8 1073741824 /* (1/8)*2^33 */
+
+#define SP_CENTER_Q 10
+#define ITD_STABLE_RATE_Q 15
+#define SPEC_AMP_Q 14
+#define SFM_Q 15
+#define TONA_Q 14
+#define lt_bg_highf_eng_Q 16
+
+/************************************************************************/
+/* TEC/TFA */
+/************************************************************************/
+#define DELAY_TEMP_ENV_BUFF_TEC 9
+#define EXT_DELAY_HI_TEMP_ENV 2
+
+
+/************************************************************************/
+/* CLDFB */
+/************************************************************************/
+
+#define SCALE_MODULATION ( 1 )
+
+#define SCALE_GAIN_ANA_10 ( 4 )
+#define SCALE_GAIN_ANA_16 ( 3 )
+#define SCALE_GAIN_ANA_20 ( 3 )
+#define SCALE_GAIN_ANA_32 ( 2 )
+#define SCALE_GAIN_ANA_40 ( 2 )
+#define SCALE_GAIN_ANA_60 ( 1 )
+
+#define SCALE_GAIN_SYN (-6 )
+
+#define SCALE_CLDFB_ANA_10 ( SCALE_MODULATION + SCALE_GAIN_ANA_10 )
+#define SCALE_CLDFB_ANA_16 ( SCALE_MODULATION + SCALE_GAIN_ANA_16 )
+#define SCALE_CLDFB_ANA_20 ( SCALE_MODULATION + SCALE_GAIN_ANA_20 )
+#define SCALE_CLDFB_ANA_32 ( SCALE_MODULATION + SCALE_GAIN_ANA_32 )
+#define SCALE_CLDFB_ANA_40 ( SCALE_MODULATION + SCALE_GAIN_ANA_40 )
+#define SCALE_CLDFB_ANA_60 ( SCALE_MODULATION + SCALE_GAIN_ANA_60 )
+
+#define SCALE_CLDFB_SYN_10 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+#define SCALE_CLDFB_SYN_16 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+#define SCALE_CLDFB_SYN_20 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+#define SCALE_CLDFB_SYN_32 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+#define SCALE_CLDFB_SYN_40 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+#define SCALE_CLDFB_SYN_60 ( SCALE_MODULATION + SCALE_GAIN_SYN )
+
+/************************************************************************/
+/* FFT */
+/************************************************************************/
+
+#define SCALEFACTORN2 ( 3)
+#define SCALEFACTOR2 ( 2)
+#define SCALEFACTOR3 ( 3)
+#define SCALEFACTOR4 ( 3)
+#define SCALEFACTOR5 ( 4)
+#define SCALEFACTOR8 ( 4)
+#define SCALEFACTOR10 ( 5)
+#define SCALEFACTOR12 ( 5)
+#define SCALEFACTOR15 ( 5)
+#define SCALEFACTOR16 ( 5)
+#define SCALEFACTOR20 ( 5)
+#define SCALEFACTOR24 ( 6)
+#define SCALEFACTOR30 ( 6)
+#define SCALEFACTOR30_1 ( 5)
+#define SCALEFACTOR30_2 ( 1)
+#define SCALEFACTOR32 ( 6)
+#define SCALEFACTOR32_1 ( 5)
+#define SCALEFACTOR32_2 ( 1)
+#define SCALEFACTOR40 ( 7)
+#define SCALEFACTOR60 ( 7)
+#define SCALEFACTOR64 ( 7)
+#define SCALEFACTOR80 ( 8)
+#define SCALEFACTOR100 (10)
+#define SCALEFACTOR120 ( 8)
+#define SCALEFACTOR128 ( 8)
+#define SCALEFACTOR160 ( 8)
+#define SCALEFACTOR192 (10)
+#define SCALEFACTOR200 (10)
+#define SCALEFACTOR240 ( 9)
+#define SCALEFACTOR256 ( 9)
+#define SCALEFACTOR320 (10)
+#define SCALEFACTOR400 (10)
+#define SCALEFACTOR480 (11)
+#define SCALEFACTOR600 (10)
+
+#define BASOP_CFFT_MAX_LENGTH 600
+
+enum
+{
+ PRIMARY_2800,
+ PRIMARY_7200,
+ PRIMARY_8000,
+ PRIMARY_9600,
+ PRIMARY_13200,
+ PRIMARY_16400,
+ PRIMARY_24400,
+ PRIMARY_32000,
+ PRIMARY_48000,
+ PRIMARY_64000,
+ PRIMARY_96000,
+ PRIMARY_128000,
+ PRIMARY_SID,
+ PRIMARY_FUT1,
+ SPEECH_LOST,
+ NO_DATA_TYPE
+};
+
+enum
+{
+ AMRWB_IO_6600,
+ AMRWB_IO_8850,
+ AMRWB_IO_1265,
+ AMRWB_IO_1425,
+ AMRWB_IO_1585,
+ AMRWB_IO_1825,
+ AMRWB_IO_1985,
+ AMRWB_IO_2305,
+ AMRWB_IO_2385,
+ AMRWB_IO_SID
+ /*, AMRWB_IO_FUT1,
+ AMRWB_IO_FUT2,
+ AMRWB_IO_FUT3,
+ AMRWB_IO_FUT4,
+ SPEECH_LOST,
+ NO_DATA_TYPE */
+};
+
+enum
+{
+ G192,
+ MIME
+ , VOIP_G192_RTP
+ , VOIP_RTPDUMP
+};
+
+#endif /* CNST_FX_H */
diff --git a/lib_com/codec_tcx_common.c b/lib_com/codec_tcx_common.c
new file mode 100644
index 0000000000000000000000000000000000000000..5f5f1db1bf0cca57579ef9bf3200e8d9890a4a7b
--- /dev/null
+++ b/lib_com/codec_tcx_common.c
@@ -0,0 +1,288 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "prot_fx.h"
+#include "options.h"
+
+#include "stl.h"
+#include "prot_fx.h"
+#include "basop_util.h"
+#include "rom_basop_util.h"
+#define inv_int InvIntTable
+
+
+
+Word16 tcxGetNoiseFillingTilt(Word16 A[], Word16 lpcorder, Word16 L_frame, Word16 mode, Word16 *noiseTiltFactor)
+{
+ Word16 firstLine;
+ Word32 tmp;
+ Word16 As[M+1];
+
+
+ IF (mode != 0)
+ {
+ firstLine = idiv1616U(L_frame, 6);
+ *noiseTiltFactor = 18432/*0.5625f Q15*/;
+ move16();
+ }
+ ELSE
+ {
+ firstLine = shr(L_frame, 3);
+
+ Copy_Scale_sig( A, As, lpcorder+1, sub(norm_s(A[0]),2) );
+ tmp = get_gain(As+1, As, lpcorder);
+ BASOP_SATURATE_WARNING_OFF;
+ *noiseTiltFactor = add(round_fx(L_shl(tmp, 15)), 3072/*0.09375f Q15*/);
+ move16();
+ BASOP_SATURATE_WARNING_ON;
+ }
+
+
+ return firstLine;
+}
+
+
+void tcxFormantEnhancement(
+ Word16 xn_buf[],
+ Word16 gainlpc[], Word16 gainlpc_e[],
+ Word32 spectrum[], Word16 *spectrum_e,
+ Word16 L_frame,
+ Word16 L_frameTCX
+)
+{
+ Word16 i, j, k, l, n;
+ Word16 fac, fac0, fac1, fac_e, d, tmp;
+ Word16 xn_buf_e, xn_one, m, e;
+
+
+ k = shr(L_frame, 6); /* FDNS_NPTS = 64 */
+ l = 0;
+ move16();
+
+ /* get exponent */
+ xn_buf_e = 0;
+ move16();
+ FOR (i = 0; i < FDNS_NPTS; i++)
+ {
+ xn_buf_e = s_max(xn_buf_e, gainlpc_e[i]);
+ }
+ xn_buf_e = shr(add(xn_buf_e, 1), 1); /* max exponent after sqrt */
+ xn_one = shr(0x4000, sub(xn_buf_e, 1)); /* 1.0 scaled to xn_buf_e */
+
+ /* Formant enhancement via square root of the LPC gains */
+ e = gainlpc_e[0];
+ move16();
+ m = Sqrt16(gainlpc[0], &e);
+ xn_buf[0] = shl(m, sub(e, xn_buf_e));
+ move16();
+
+ e = gainlpc_e[1];
+ move16();
+ m = Sqrt16(gainlpc[1], &e);
+ xn_buf[1] = shl(m, sub(e, xn_buf_e));
+ move16();
+
+ fac0 = s_min(xn_buf[0], xn_buf[1]);
+ fac_e = xn_buf_e;
+ move16();
+ fac0 = Inv16(fac0, &fac_e);
+
+ FOR (i = 1; i < FDNS_NPTS-1; i++)
+ {
+ e = gainlpc_e[i+1];
+ move16();
+ m = Sqrt16(gainlpc[i+1], &e);
+ xn_buf[i+1] = shl(m, sub(e, xn_buf_e));
+ move16();
+
+ test();
+ IF ((LE_16(xn_buf[i-1], xn_buf[i]))&&(LE_16(xn_buf[i+1],xn_buf[i])))
+ {
+ m = s_max(xn_buf[i-1], xn_buf[i+1]);
+ e = xn_buf_e;
+ move16();
+ m = Inv16(m, &e);
+
+ fac1 = m;
+ move16();
+ tmp = sub(e, fac_e);
+
+ if (tmp > 0) fac0 = shr(fac0, tmp);
+ if (tmp < 0) fac1 = shl(fac1, tmp);
+
+ if (tmp > 0)
+ {
+ fac_e = e;
+ move16();
+ }
+
+ d = sub(fac1, fac0);
+ n = sub(i, l);
+ assert(n <= 64);
+
+ xn_buf[l] = xn_one;
+ move16();
+ FOR (j = 1; j < n; j++)
+ {
+ fac = add(fac0, mult(d, extract_l(L_mult0(j, inv_int[n]))));
+ BASOP_SATURATE_WARNING_OFF;
+ xn_buf[l+j] = s_min(xn_one, shl(mult(xn_buf[l+j], fac), fac_e));
+ move16();
+ BASOP_SATURATE_WARNING_ON;
+ }
+
+ l = i;
+ move16();
+
+ fac0 = m;
+ move16();
+ fac_e = e;
+ move16();
+ }
+ }
+ /* i = FDNS_NPTS - 1; Completing changes to gains */
+ m = s_min(xn_buf[i-1], xn_buf[i]);
+ e = xn_buf_e;
+ move16();
+ m = Inv16(m, &e);
+
+ fac1 = m;
+ move16();
+ tmp = sub(e, fac_e);
+
+ if (tmp > 0) fac0 = shr(fac0, tmp);
+ if (tmp < 0) fac1 = shl(fac1, tmp);
+
+ if (tmp > 0)
+ {
+ fac_e = e;
+ move16();
+ }
+
+ d = sub(fac1, fac0);
+ n = sub(i, l);
+ assert(n <= 64);
+
+ xn_buf[l] = xn_one;
+ move16();
+ FOR (j = 1; j < n; j++)
+ {
+ fac = add(fac0, mult(d, extract_l(L_mult0(j, inv_int[n]))));
+ BASOP_SATURATE_WARNING_OFF;
+ xn_buf[l+j] = s_min(xn_one, shl(mult(xn_buf[l+j], fac), fac_e));
+ move16();
+ BASOP_SATURATE_WARNING_ON;
+ }
+
+ xn_buf[i] = xn_one;
+ move16();
+
+ /* Application of changed gains onto decoded MDCT lines */
+ FOR (i = 0; i < L_frame; i += k)
+ {
+ FOR (l = 0; l < k; l++)
+ {
+ *spectrum = Mpy_32_16_1(*spectrum, *xn_buf);
+ move32();
+ spectrum++;
+ }
+ xn_buf++;
+ }
+
+ tmp = sub(L_frameTCX, L_frame);
+ FOR (i = 0; i < tmp; i++)
+ {
+ spectrum[i] = L_shr(spectrum[i], xn_buf_e);
+ move32();
+ }
+ *spectrum_e = add(*spectrum_e, xn_buf_e);
+ move16();
+
+}
+
+void tcxInvertWindowGrouping(TCX_config *tcx_cfg,
+ Word32 xn_buf[],
+ Word32 spectrum[],
+ Word16 L_frame,
+ Word8 fUseTns,
+ Word16 last_core,
+ Word16 index,
+ Word16 frame_cnt,
+ Word16 bfi)
+{
+ Word16 i, L_win, L_spec;
+ Word32 *p;
+
+
+ L_win = shr(L_frame, 1);
+ L_spec = tcx_cfg->tnsConfig[0][0].iFilterBorders[0];
+ move16();
+
+ test();
+ test();
+ if ((frame_cnt != 0) && (bfi == 0) && (last_core != ACELP_CORE)) /* fix sub-window overlap */
+ {
+ tcx_cfg->tcx_last_overlap_mode = tcx_cfg->tcx_curr_overlap_mode;
+ move16();
+ }
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF (((bfi==0) &&((tcx_cfg->tcx_last_overlap_mode != FULL_OVERLAP) ||
+ ((tcx_cfg->tcx_curr_overlap_mode == FULL_OVERLAP) && (frame_cnt == 0) && (index == 0))))
+ ||
+ ((bfi!=0) &&((tcx_cfg->tcx_last_overlap_mode != FULL_OVERLAP) &&
+ !(tcx_cfg->tcx_curr_overlap_mode == FULL_OVERLAP))))
+ {
+ /* ungroup sub-windows: deinterleave MDCT bins into separate windows */
+ p = xn_buf;
+ FOR (i = 1; i < L_win; i += 2)
+ {
+ *p++ = spectrum[i];
+ move32();
+ }
+
+ p = spectrum;
+ FOR (i = 0; i < L_frame; i += 2)
+ {
+ *p++ = spectrum[i];
+ move32();
+ }
+
+ p = spectrum + L_frame - 1;
+ FOR (i = sub(L_frame, 1); i > L_win; i -= 2)
+ {
+ *p-- = spectrum[i];
+ move32();
+ }
+ Copy32(xn_buf, spectrum + L_win, shr(L_win, 1));
+
+ test();
+ test();
+ IF ((tcx_cfg->fIsTNSAllowed != 0) && (bfi == 0) && (fUseTns != 0))
+ {
+ /* rearrange LF sub-window lines prior to TNS synthesis filtering */
+ IF (LT_16(L_spec, L_frame))
+ {
+ Copy32(spectrum+8, spectrum+16, sub(shr(L_spec,1),8));
+ Copy32(spectrum+L_frame/2, spectrum+8, 8);
+ Copy32(spectrum+L_frame/2+8, spectrum+L_spec/2+8, sub(shr(L_spec,1),8));
+ }
+ ELSE
+ {
+ Copy32(spectrum+L_win, xn_buf, 8);
+ Copy32(spectrum+8, spectrum+16, sub(L_win, 8));
+ Copy32(xn_buf, spectrum+8, 8);
+ }
+ }
+ }
+
+}
+
+
diff --git a/lib_com/core_com_config_fx.c b/lib_com/core_com_config_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..a287157d950b9c214353b44f8c238d36ffc30b73
--- /dev/null
+++ b/lib_com/core_com_config_fx.c
@@ -0,0 +1,471 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include
+#include
+
+#include "options.h"
+#include "stl.h"
+#include "basop_util.h"
+#include "prot_fx.h"
+#include "rom_com_fx.h"
+
+
+Word8 getTcxonly(const Word32 bitrate)
+{
+
+ Word8 tcxonly;
+
+ tcxonly = 0;
+ move16();
+ if( GT_32(bitrate,32000))
+ {
+ tcxonly = 1;
+ move16();
+ }
+
+ return tcxonly;
+}
+
+Word8 getCtxHm(const Word32 bitrate, const Word16 rf_flag)
+{
+
+ Word8 ctx_hm;
+
+ ctx_hm = 0;
+ move16();
+ test();
+ if( (bitrate > LPC_SHAPED_ARI_MAX_RATE) && (bitrate <= 64000) && !rf_flag)
+ {
+
+ ctx_hm = 1;
+ move16();
+ }
+
+
+ return ctx_hm;
+}
+
+
+Word8 getResq(const Word32 bitrate)
+{
+
+ Word8 resq;
+
+ resq = 0;
+ move16();
+ if (LE_32(bitrate,64000))
+ {
+ resq = 1;
+ move16();
+ }
+
+ return resq;
+}
+
+
+Word8 getTnsAllowed(const Word32 bitrate
+ ,const Word16 igf
+ )
+{
+ Word8 tnsAllowed;
+
+ tnsAllowed = 0;
+ move16();
+ IF ( igf != 0 )
+ {
+ if( GT_32(bitrate, HQ_16k40))
+ {
+ tnsAllowed = 1;
+ move16();
+ }
+ }
+ ELSE
+ {
+ if( GT_32(bitrate, HQ_32k))
+ {
+ tnsAllowed = 1;
+ move16();
+ }
+ }
+
+ return tnsAllowed;
+}
+
+
+Word8 getRestrictedMode(const Word32 bitrate, const Word16 Opt_AMR_WB)
+{
+
+ Word8 restrictedMode;
+
+ restrictedMode = 3;
+ move16();
+
+ test();
+ IF ( (Opt_AMR_WB == 0) && (GT_32(bitrate,32000)))
+ {
+ restrictedMode = 6;
+ move16();
+ }
+ ELSE IF( Opt_AMR_WB )
+ {
+ restrictedMode = 1;
+ move16();
+ }
+
+ return restrictedMode;
+}
+
+
+Word16 sr2fscale(const Word32 sr)
+{
+ Word16 fscale;
+
+ SWITCH(sr)
+ {
+ case 8000:
+ fscale = (FSCALE_DENOM*8000)/12800;
+ move16();
+ BREAK;
+
+ case 12800:
+ fscale = FSCALE_DENOM;
+ move16();
+ BREAK;
+
+ case 16000:
+ fscale = (FSCALE_DENOM*16000)/12800;
+ move16();
+ BREAK;
+
+ case 25600:
+ fscale = (FSCALE_DENOM*25600)/12800;
+ move16();
+ BREAK;
+
+ case 32000:
+ fscale = (FSCALE_DENOM*32000)/12800;
+ move16();
+ BREAK;
+
+ case 48000:
+ fscale = (FSCALE_DENOM*48000)/12800;
+ move16();
+ BREAK;
+
+ default:
+ assert(0);
+ fscale = 0; /* just to avoid compiler warning */
+ BREAK;
+ }
+ return fscale;
+}
+
+Word32 getCoreSamplerateMode2(const Word32 bitrate, const Word16 bandwidth, const Word16 rf_mode)
+{
+
+ Word32 sr_core;
+ sr_core = -1; /* to suppress MSVC warning */ move32();
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+
+ IF( EQ_32( bandwidth,NB))
+ {
+ sr_core = 12800;
+ move32();
+ }
+
+ ELSE IF ( L_and(EQ_32(bandwidth,WB),LT_32(bitrate,13200))||
+ L_and(EQ_32(bandwidth,SWB), LE_32(bitrate,13200)) || EQ_16(rf_mode,1) )
+
+ {
+ sr_core = 12800;
+ move32();
+ }
+ ELSE IF (EQ_32(bandwidth,WB)||((LE_32(bitrate,32000))&&((EQ_32(bandwidth,SWB))||(EQ_32(bandwidth,FB)))))
+ {
+ sr_core = 16000;
+ move32();
+ }
+ ELSE IF ( ((EQ_32(bandwidth,SWB))||(EQ_32(bandwidth,FB)))&&(LE_32(bitrate,64000)))
+ {
+ sr_core = 25600;
+ move32();
+ }
+ ELSE IF (EQ_32(bandwidth,SWB)||EQ_32(bandwidth,FB))
+ {
+ sr_core = 32000;
+ move32();
+ }
+ ELSE
+ {
+ assert(0);
+ }
+
+ return sr_core;
+}
+
+Word16 getTcxBandwidth(const Word16 bandwidth)
+{
+
+ Word16 tcxBandwidth;
+
+ tcxBandwidth = 16384/*0.5f Q15*/;
+ move16();
+ if(EQ_16(bandwidth, NB))
+ {
+ tcxBandwidth = 10240/*0.3125f Q15*/;
+ move16();
+
+ }
+
+ return tcxBandwidth;
+}
+
+
+Word8 getIgfPresent(
+ const Word32 bitrate,
+ const Word16 bandwidth
+ ,const Word16 rf_mode
+)
+{
+ Word8 igfPresent;
+
+ igfPresent = 0;
+ move16();
+
+ test();
+ test();
+ if( (EQ_16(bandwidth, SWB))&&(GE_32(bitrate,ACELP_9k60))&&(LT_32(bitrate,HQ_64k)))
+ {
+ igfPresent = 1;
+ move16();
+ }
+
+ test();
+ if( EQ_16(bandwidth, FB)&&(GE_32(bitrate,ACELP_16k40)))
+ {
+ igfPresent = 1;
+ move16();
+ }
+
+ test();
+ if( (EQ_16(bandwidth, WB))&&(EQ_32(bitrate,ACELP_9k60)))
+ {
+ igfPresent = 1;
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ if( ((EQ_16(bandwidth, WB))||(EQ_16(bandwidth,SWB)))&&(EQ_16(rf_mode,1))&&(EQ_32(bitrate,ACELP_13k20)))
+ {
+ igfPresent = 1;
+ move16();
+ }
+
+ return igfPresent;
+}
+
+
+Word8 getCnaPresent(
+ const Word32 bitrate,
+ const Word16 bandwidth
+)
+{
+ Word8 flag_cna = 0;
+
+ flag_cna = 0;
+ move16();
+ test();
+ if( EQ_16(bandwidth, NB)&&(LE_32(bitrate,ACELP_13k20)))
+ {
+ flag_cna = 1;
+ move16();
+ }
+
+ test();
+ if( (EQ_16(bandwidth, WB))&&(LE_32(bitrate,ACELP_13k20)))
+ {
+ flag_cna = 1;
+ move16();
+ }
+
+ test();
+ if( (EQ_16(bandwidth, SWB))&&(LE_32(bitrate,ACELP_13k20)))
+ {
+ flag_cna = 1;
+ move16();
+ }
+
+ return flag_cna;
+}
+
+Word8 getTcxLtp(const Word32 sr_core)
+{
+
+ Word8 tcxltp = 0;
+
+ tcxltp = 0;
+ move16();
+ test();
+ if ( (LE_32(sr_core, 25600)))
+ {
+ tcxltp = 1;
+ move16();
+ }
+
+ return tcxltp;
+}
+
+
+Word16 initPitchLagParameters(
+ const Word32 sr_core,
+ Word16 *pit_min,
+ Word16 *pit_fr1,
+ Word16 *pit_fr1b,
+ Word16 *pit_fr2,
+ Word16 *pit_max
+)
+{
+
+ Word16 pit_res_max;
+
+ IF (EQ_32(sr_core, 12800))
+ {
+
+ *pit_min = PIT_MIN_12k8;
+ move16();
+ *pit_max = PIT_MAX_12k8;
+ move16();
+ *pit_fr2 = PIT_FR2_12k8;
+ move16();
+ *pit_fr1 = PIT_FR1_12k8;
+ move16();
+ *pit_fr1b = PIT_FR1_8b_12k8;
+ move16();
+ pit_res_max = 4;
+ move16();
+
+ }
+ ELSE IF (EQ_32(sr_core, 16000))
+ {
+
+ *pit_min = PIT_MIN_16k;
+ move16();
+ *pit_max = PIT_MAX_16k;
+ move16();
+ *pit_fr2 = PIT_FR2_16k;
+ move16();
+ *pit_fr1 = PIT_FR1_16k;
+ move16();
+ *pit_fr1b = PIT_FR1_8b_16k;
+ move16();
+ pit_res_max = 6;
+ move16();
+
+ }
+ ELSE IF (EQ_32(sr_core, 25600))
+ {
+
+ *pit_min = PIT_MIN_25k6;
+ move16();
+ *pit_max = PIT_MAX_25k6;
+ move16();
+ *pit_fr2 = PIT_FR2_25k6;
+ move16();
+ *pit_fr1 = PIT_FR1_25k6;
+ move16();
+ *pit_fr1b = PIT_FR1_8b_25k6;
+ move16();
+ pit_res_max = 4;
+ move16();
+ }
+ ELSE /* sr_core==32000 */
+ {
+
+ *pit_min = PIT_MIN_32k;
+ move16();
+ *pit_max = PIT_MAX_32k;
+ move16();
+ *pit_fr2 = PIT_FR2_32k;
+ move16();
+ *pit_fr1 = PIT_FR1_32k;
+ move16();
+ *pit_fr1b = PIT_FR1_8b_32k;
+ move16();
+ pit_res_max = 6;
+ move16();
+
+ }
+
+ return pit_res_max;
+}
+
+Word16 getNumTcxCodedLines(const Word16 bwidth)
+{
+
+ Word16 tcx_coded_lines;
+
+ tcx_coded_lines = 0;
+ move16();
+
+ if(EQ_16(bwidth, NB))
+ {
+ tcx_coded_lines = 160;
+ move16();
+ }
+
+ if(EQ_16(bwidth, WB))
+ {
+ tcx_coded_lines = 320;
+ move16();
+ }
+
+ if(EQ_16(bwidth, SWB))
+ {
+ tcx_coded_lines = 640;
+ move16();
+ }
+
+ if(EQ_16(bwidth, FB))
+ {
+ tcx_coded_lines = 960;
+ move16();
+ }
+
+ return tcx_coded_lines;
+}
+
+Word16 getTcxLpcShapedAri(
+ const Word32 total_brate,
+ const Word16 bwidth
+ ,const Word16 rf_mode
+)
+{
+ Word16 tcx_lpc_shaped_ari = 0;
+ move16();
+
+ (void) bwidth;
+
+ test();
+ if( (LE_32(total_brate, LPC_SHAPED_ARI_MAX_RATE))||rf_mode)
+ {
+ tcx_lpc_shaped_ari = 1;
+ move16();
+ }
+
+
+ return tcx_lpc_shaped_ari;
+}
diff --git a/lib_com/deemph_fx.c b/lib_com/deemph_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..56e32fc65a8d80c444eb10c01f518613cdf4da19
--- /dev/null
+++ b/lib_com/deemph_fx.c
@@ -0,0 +1,136 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+#include "basop_util.h"
+
+/*========================================================================*/
+/* FUNCTION : deemph_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Deemphasis: filtering through 1/(1-mu z^-1) */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) mu : deemphasis factor Q15 */
+/* _ (Word16) L : vector size */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16*) signal : signal Q_syn2-1 */
+/* _ (Word16*) mem : memory (y[-1]) Q_syn2-1 */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
+void deemph_fx(
+ Word16 *signal, /* i/o: signal Qx */
+ const Word16 mu, /* i : deemphasis factor Q15 */
+ const Word16 L, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (y[-1]) Qx */
+)
+{
+ Word16 i;
+ Word32 L_tmp;
+
+ L_tmp = L_deposit_h(signal[0]);
+ L_tmp = L_mac(L_tmp, *mem, mu);
+ signal[0] = round_fx(L_tmp);
+
+ FOR (i = 1; i < L; i++)
+ {
+ L_tmp = L_deposit_h(signal[i]);
+ L_tmp = L_mac(L_tmp, signal[i - 1], mu);
+ signal[i] = round_fx(L_tmp);
+ }
+
+ *mem = signal[L - 1];
+ move16();
+}
+
+/*-------------------------------------------------------------------*
+ * Deeemph2 :
+ *
+ * Deemphasis: filtering through 1/(1-mu z^-1)
+ * Output divided by 2
+ *-------------------------------------------------------------------*/
+void Deemph2(
+ Word16 x[], /* i/o: input signal overwritten by the output Qx/Qx-1 */
+ const Word16 mu, /* i : deemphasis factor Q15 */
+ const Word16 L, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (y[-1]) Qx-1 */
+)
+{
+ Word16 i;
+ Word32 L_tmp;
+
+ /* saturation can occur in L_mac() */
+
+ L_tmp = L_mult(x[0], 16384);
+ x[0] = mac_r(L_tmp, *mem, mu);
+ move16();
+
+ FOR (i = 1; i < L; i++)
+ {
+ L_tmp = L_mult(x[i], 16384);
+ x[i] = mac_r(L_tmp, x[i - 1], mu);
+ move16();
+ }
+
+ *mem = x[L - 1];
+ move16();
+}
+
+
+/*
+ * E_UTIL_deemph2
+ *
+ * Parameters:
+ * shift I: scale output
+ * x I/O: signal Qx/Qx-shift
+ * mu I: deemphasis factor Qx
+ * L I: vector size
+ * mem I/O: memory (signal[-1]) Qx
+ *
+ * Function:
+ * Filtering through 1/(1-mu z^-1)
+ * Signal is divided by 2.
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_deemph2(Word16 shift, Word16 *x, const Word16 mu, const Word16 L, Word16 *mem)
+{
+ Word16 i;
+ Word32 L_tmp;
+
+ /* signal[0] = signal[0] + mu * (*mem); */
+ L_tmp = L_deposit_h(*mem);
+ IF(shift >= 0)
+ {
+ shift = shr(-32768, shift);
+ FOR (i = 0; i < L; i++)
+ {
+ L_tmp = L_msu(Mpy_32_16_1(L_tmp, mu), x[i],shift);
+ x[i] = round_fx(L_tmp);
+ }
+
+ }
+ ELSE
+ {
+ FOR (i = 0; i < L; i++)
+ {
+ L_tmp = L_msu(Mpy_32_16_1(L_tmp, mu), shr(x[i],shift),-32768);
+ x[i] = round_fx(L_tmp);
+ }
+ }
+
+ *mem = x[L - 1];
+ move16();
+
+ return;
+}
diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c
new file mode 100644
index 0000000000000000000000000000000000000000..f67b752c4c5ab1af305a634f92673fbdab2754ed
--- /dev/null
+++ b/lib_com/delay_comp.c
@@ -0,0 +1,43 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "stl.h"
+#include "prot_fx.h"
+
+
+/*--------------------------------------------------------------------------
+* get_delay_fx()
+*
+* Function returns various types of delays in the codec in ms.
+*--------------------------------------------------------------------------*/
+
+Word32 get_delay_fx( /* o : delay value in ms */
+ const Word16 what_delay, /* i : what delay? (ENC or DEC) */
+ const Word32 io_fs /* i : input/output sampling frequency */
+)
+{
+ Word32 delay = 0;
+
+ IF( EQ_16(what_delay,ENC))
+ {
+ delay = (DELAY_FIR_RESAMPL_NS + ACELP_LOOK_NS);
+ move32();
+ }
+ ELSE
+ {
+ IF( EQ_32(io_fs,8000))
+ {
+ delay = DELAY_CLDFB_NS;
+ move32();
+ }
+ ELSE
+ {
+ delay = DELAY_BWE_TOTAL_NS;
+ move32();
+ }
+ }
+
+ return delay;
+}
diff --git a/lib_com/disclaimer.c b/lib_com/disclaimer.c
new file mode 100644
index 0000000000000000000000000000000000000000..52f2fc2e5de1bafbac79d0d6d8d326828bd03b6a
--- /dev/null
+++ b/lib_com/disclaimer.c
@@ -0,0 +1,19 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "disclaimer.h"
+#include "options.h"
+#include "stl.h"
+
+/* WMC_TOOL_SKIP_FILE */
+
+int print_disclaimer(FILE *fPtr)
+{
+
+ fprintf(fPtr, "\n===========================================================================\n");
+ fprintf(fPtr, " EVS Codec 3GPP TS26.452 August 12, 2021. \n");
+ fprintf(fPtr, " Version 16.3.0\n");
+ fprintf(fPtr, "===========================================================================\n\n\n");
+ return 0;
+}
diff --git a/lib_com/disclaimer.h b/lib_com/disclaimer.h
new file mode 100644
index 0000000000000000000000000000000000000000..cb41b938d9d33006c6e8180b4b06672167f4ad54
--- /dev/null
+++ b/lib_com/disclaimer.h
@@ -0,0 +1,15 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#ifndef __INCLUDED_DISCLAIMER_H
+#define __INCLUDED_DISCLAIMER_H
+
+#include
+
+int print_disclaimer(FILE *fPtr);
+
+
+
+
+#endif /* __INCLUDED_DISCLAIMER_H */
diff --git a/lib_com/dlpc_bfi.c b/lib_com/dlpc_bfi.c
new file mode 100644
index 0000000000000000000000000000000000000000..4271e1cec393eef5c8b89098018a11d09f4dba97
--- /dev/null
+++ b/lib_com/dlpc_bfi.c
@@ -0,0 +1,55 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+/* Header files */
+#include
+#include
+#include
+#include "prot_fx.h"
+#include "stl.h"
+#include "prot_fx.h"
+
+void dlpc_bfi(
+ const Word16 L_frame,
+ Word16 *lsf_q, /* o : quantized LSFs */
+ const Word16 *lsfold, /* i : past quantized LSF */
+ const Word16 last_good, /* i : last good received frame */
+ const Word16 nbLostCmpt, /* i : counter of consecutive bad frames */
+ Word16 mem_MA[], /* i/o: quantizer memory for MA model */
+ Word16 mem_AR[], /* i/o: quantizer memory for AR model */
+ Word16 *stab_fac, /* i : LSF stability factor */
+ Word16 *lsf_adaptive_mean,/* i : LSF adaptive mean, updated when BFI==0 */
+ Word16 numlpc, /* i : Number of division per superframe */
+ Word16 lsf_cng[],
+ Word8 plcBackgroundNoiseUpdated,
+ Word16 *lsf_q_cng, /* o : quantized LSFs */
+ Word16 *old_lsf_q_cng, /* o : old quantized LSFs for background noise */
+ const Word16* lsfBase, /* i : base for differential LSF coding */
+ Word8 tcxonly
+)
+{
+
+ lsf_dec_bfi(
+ MODE2,
+ &lsf_q[0], lsfold, lsf_adaptive_mean, lsfBase, mem_MA, mem_AR, *stab_fac,
+ 0, L_frame, last_good, nbLostCmpt,
+ plcBackgroundNoiseUpdated, lsf_q_cng, lsf_cng, old_lsf_q_cng, 0, 0, tcxonly
+ ,0
+
+ );
+ IF ( EQ_16(numlpc,2))
+ {
+ /* Decode the second LPC */
+ lsf_dec_bfi(
+ MODE2,
+ &lsf_q[M], &lsf_q[0], lsf_adaptive_mean, lsfBase, mem_MA, mem_AR, *stab_fac,
+ 0, L_frame, last_good, nbLostCmpt+1,
+ plcBackgroundNoiseUpdated, lsf_q_cng, lsf_cng, old_lsf_q_cng, 0, 0, tcxonly
+ ,0
+ );
+ }
+ /**/ /*No local variabvles defined*/
+}
+
diff --git a/lib_com/edct_fx.c b/lib_com/edct_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f45a54fa36dff4b351bc343a59ebb81a9f0637d4
--- /dev/null
+++ b/lib_com/edct_fx.c
@@ -0,0 +1,424 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+
+#include "math_32.h"
+
+static Word16 const * get_edct_table(Word16 length, Word16 *q)
+{
+ Word16 const * edct_table = NULL;
+ SWITCH (length)
+ {
+ case 1200:
+ edct_table = edct_table_600_fx;
+ move16();
+ *q = add(*q, 2);
+ BREAK;
+ case 960 :
+ edct_table = edct_table_480_fx;
+ move16();
+ BREAK;
+ case 640 :
+ edct_table = edct_table_320_fx;
+ move16();
+ BREAK;
+ case 320 :
+ edct_table = edct_table_160_fx;
+ move16();
+ BREAK;
+ case 256 :
+ edct_table = edct_table_128_fx;
+ move16();
+ BREAK;
+ case 240 :
+ edct_table = edct_table_120_fx;
+ move16();
+ BREAK;
+ case 200 :
+ edct_table = edct_table_100_fx;
+ move16();
+ BREAK;
+ case 160 :
+ edct_table = edct_table_80_fx ;
+ move16();
+ BREAK;
+ case 40 :
+ edct_table = edct_table_20_fx ;
+ move16();
+ BREAK;
+ case 800 :
+ edct_table = edct_table_400_fx;
+ move16();
+ *q = add(*q, 2);
+ BREAK;
+ case 512 :
+ edct_table = edct_table_256_fx;
+ move16();
+ BREAK;
+ case 480 :
+ edct_table = edct_table_240_fx;
+ move16();
+ BREAK;
+ case 400 :
+ edct_table = edct_table_200_fx;
+ move16();
+ BREAK;
+ case 128 :
+ edct_table = edct_table_64_fx ;
+ move16();
+ BREAK;
+ case 80 :
+ edct_table = edct_table_40_fx ;
+ move16();
+ BREAK;
+ default:
+ BREAK;
+ }
+ return edct_table;
+}
+
+/*-------------------------------------------------------------------------*
+ * FUNCTION : edct_fx()
+ *
+ * PURPOSE : DCT transform
+ *
+ * INPUT ARGUMENTS :
+ * _ (Word16) length : length
+ * _ (Word16*) x : input signal Qx
+ * _ (Word16*) edct_table_128_fx : edct table Q16
+ *
+ * OUTPUT ARGUMENTS :
+ * _ (Word16[]) y : output transform Qx
+ *-------------------------------------------------------------------------*/
+void edct_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length */
+ Word16 *q /* i : Q value of input signal */
+)
+{
+ Word16 i;
+ Word32 re;
+ Word32 im;
+ const Word16 *edct_table = 0; /*Q16 */
+ Word32 complex_buf[2*(L_FRAME48k/2+240)];
+ Word32 L_tmp;
+ Word16 tmp;
+ Word16 len1;
+
+ edct_table = get_edct_table(length, q);
+ len1 = shr(length, 1);
+ /* Twiddling and Pre-rotate */
+ FOR (i = 0; i < len1; i++)
+ {
+ L_tmp = Mult_32_16(x[2*i], edct_table[i]); /*Q(q+1) */
+ complex_buf[2*i] = Madd_32_16(L_tmp, x[length-1-2*i], edct_table[len1-1-i]); /*Q(q+1) */ move32();
+
+ L_tmp = Mult_32_16(x[length-1-2*i], edct_table[i]); /*Q(q+1) */
+
+ complex_buf[2*i+1] = Msub_32_16(L_tmp, x[2*i], edct_table[len1-1-i]); /*Q(q+1) */ move32();
+ }
+
+ *q = sub(15, *q);
+ BASOP_cfft((cmplx *)complex_buf, len1, q, y);
+
+ tmp = div_s(1, length); /*Q15 */
+ tmp = round_fx(L_shl(L_mult(tmp, 19302), 2)); /*Q15 */
+ FOR (i = 0; i < len1; i++)
+ {
+ re = Msub_32_16(complex_buf[2*i], complex_buf[2*i+1], tmp);
+ im = Madd_32_16(complex_buf[2*i+1], complex_buf[2*i], tmp);
+ y[2 * i] = L_add(Mult_32_16(re, edct_table[i]), Mult_32_16(im, edct_table[len1 - 1 - i]));
+ move32();
+ y[length - 1 - 2 * i] = L_sub(Mult_32_16(re, edct_table[len1 - 1 - i]), Mult_32_16(im, edct_table[i]));
+ move32();
+ } /*Q(q-2) */
+
+ *q = sub(15+2, *q);
+ return;
+}
+
+/*-------------------------------------------------------------------------*
+ * FUNCTION : edst_fx()
+ *
+ * PURPOSE : DST_IV transform
+ *
+ * INPUT ARGUMENTS :
+ * _ (Word16) length : length
+ * _ (Word16*) x : input signal Qx
+ * _ (Word16*) edct_table_128_fx : edct table Q16
+ *
+ * OUTPUT ARGUMENTS :
+ * _ (Word16[]) y : output transform Qx
+ *-------------------------------------------------------------------------*/
+void edst_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length */
+ Word16 *q /* i : Q value of input signal */
+)
+{
+ Word16 i;
+ Word32 re;
+ Word32 im;
+ const Word16 *edct_table = 0; /*Q16 */
+ Word32 complex_buf[2*(L_FRAME48k/2+240)];
+ Word32 L_tmp;
+ Word16 tmp;
+ Word16 len1;
+
+ edct_table = get_edct_table(length, q);
+ len1 = shr(length, 1);
+ /* Twiddling and Pre-rotate */
+ FOR (i = 0; i < len1; i++)
+ {
+ L_tmp = Mult_32_16(x[length-1-2*i], edct_table[i]);
+ complex_buf[2*i] = Madd_32_16(L_tmp, x[2*i], edct_table[len1-1-i]);
+ move32();
+
+ L_tmp = Mult_32_16(x[2*i], edct_table[i]);
+ complex_buf[2*i+1] = Msub_32_16(L_tmp, x[length-1-2*i], edct_table[len1-1-i]);
+ move32();
+ }
+
+ *q = sub(15, *q);
+ BASOP_cfft((cmplx *)complex_buf, len1, q, y);
+
+ tmp = div_s(1, length); /*Q15 */
+ tmp = round_fx(L_shl(L_mult(tmp, 19302), 2)); /*Q15 */
+ FOR (i = 0; i < len1; i++)
+ {
+ re = Msub_32_16(complex_buf[2*i], complex_buf[2*i+1], tmp);
+ im = Madd_32_16(complex_buf[2*i+1], complex_buf[2*i], tmp);
+ y[2 * i] = L_add(Mult_32_16(re, edct_table[i]), Mult_32_16(im, edct_table[len1 - 1 - i]));
+ move32();
+ y[length - 1 - 2 * i] = L_sub(Mult_32_16(im, edct_table[i]), Mult_32_16(re, edct_table[len1 - 1 - i]));
+ move32();
+ } /*Q(q) */
+
+ *q = sub(15+2, *q);
+
+ return;
+}
+
+/*========================================================================*/
+/* FUNCTION : edct_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : DCT transform */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) length : length */
+/* _ (Word16*) x : input signal Qx */
+/* _ (Word16*) edct_table_128_fx : edct table Q15 */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16[]) y : output transform Qx */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
+void edct_16fx(
+ const Word16 *x, /* i : input signal Qx */
+ Word16 *y, /* o : output transform Qx */
+ Word16 length, /* i : length */
+ Word16 bh /* bit-headroom */
+)
+{
+ Word16 i;
+ Word16 re[L_FRAME48k/2];
+ Word16 im[L_FRAME48k/2];
+ const Word16 *edct_table = 0;
+ Word16 re2[L_FRAME48k/2];
+ Word16 im2[L_FRAME48k/2];
+
+ Word32 L_tmp, Lacc, Lmax;
+ Word16 tmp, fact;
+ Word16 Q_edct;
+ Word16 Len2, i2;
+ const Word16 *px, *pt;
+ Word16 *py;
+
+ /*COMPLETE: some eDCT sub function are missing */
+
+ IF (EQ_16(length,L_FRAME32k))
+ {
+ edct_table = &edct_table_320_16fx[0];
+ move16();
+ }
+ ELSE IF (EQ_16(length,L_FRAME))
+ {
+ edct_table = &edct_table_128_16fx[0];
+ move16();
+ }
+ ELSE IF (EQ_16(length,L_FRAME16k))
+ {
+ edct_table = &edct_table_160_16fx[0];
+ move16();
+ }
+ ELSE
+ {
+ }
+
+ /* Twiddling and Pre-rotate */
+ Lmax = L_deposit_l(0);
+ Len2 = shr(length,1);
+ px = x + length - 1;
+ pt = edct_table + Len2 - 1;
+ FOR (i = 0; i < Len2; i++)
+ {
+ i2 = shl(i,1);
+ L_tmp = L_mult(x[i2],edct_table[i]);/*Q(Qx+16) */
+
+ Lacc = L_mac(L_tmp,*px,*pt);/*Q(Qx+16) */
+
+ Lmax = L_max(Lmax, Lacc);
+
+ L_tmp = L_mult(*px,edct_table[i]);/*Q(Qx+16) */
+ Lacc = L_msu(L_tmp,x[i2],*pt);/*Q(Qx+16) */
+ Lmax = L_max(Lmax, Lacc);
+
+ px -= 2;
+ pt--;
+ }
+
+ tmp = 31;
+ if( Lmax != 0 )
+ {
+ tmp = norm_l(Lmax);
+ }
+ Q_edct = sub(tmp,bh); /*creating a bit-headroom */
+
+ px = x + length - 1;
+ pt = edct_table + Len2 - 1;
+ FOR (i = 0; i < Len2; i++)
+ {
+ i2 = shl(i,1);
+
+ L_tmp = L_mult(x[i2],edct_table[i]);/*Q(Qx+16) */
+ Lacc = L_mac(L_tmp,*px,*pt);/*Q(Qx+16) */
+ re2[i] = round_fx(L_shl(Lacc, Q_edct)); /* Q(Qx+Q_edct) */
+
+ L_tmp = L_mult(*px,edct_table[i]);/*Q(Qx+16) */
+ Lacc = L_msu(L_tmp,x[i2],*pt);/*Q(Qx+16) */
+ im2[i] = round_fx(L_shl(Lacc, Q_edct)); /* Q(Qx+Q_edct) */
+
+ px -= 2;
+ pt--;
+ }
+ IF (EQ_16(length,L_FRAME32k))
+ {
+ DoRTFT320_16fx(re2, im2);
+ }
+ ELSE IF (EQ_16(length,L_FRAME ))
+ {
+ DoRTFT128_16fx(re2, im2);
+ }
+ ELSE IF (EQ_16(length,L_FRAME16k))
+ {
+ DoRTFT160_16fx(re2, im2);
+ }
+ ELSE
+ {
+ }
+ tmp = div_s(1,length); /*Q15 */
+ L_tmp = L_mult(tmp,19302); /*Q29, (3*PI/4) in Q13 */
+ fact = round_fx(L_shl(L_tmp,2)); /*Q15 */
+ FOR (i = 0; i < length/2; i++)
+ {
+ tmp = mult_r(im2[i],fact); /*Q(Qx+Q_edct) */
+ re[i] = sub(re2[i],tmp); /*Q(Qx+Q_edct) */ move16();
+
+ tmp = mult_r(re2[i],fact); /*Q(Qx+Q_edct) */
+ im[i] = add(im2[i],tmp); /*Q(Qx+Q_edct) */ move16();
+ }
+
+ /* Post-rotate and obtain the output data */
+ py = y + length - 1;
+ pt = edct_table + Len2 - 1;
+ FOR (i = 0; i < Len2; i++)
+ {
+ i2 = shl(i,1);
+
+ L_tmp = L_mult(re[i],edct_table[i]);/*Q(Qx+Q_edct+16) */
+ Lacc = L_mac(L_tmp,im[i],*pt);/*Q(Qx+Q_edct+16) */
+ y[i2] = round_fx(L_shr(Lacc,Q_edct)); /* Q(Qx) */
+
+ L_tmp = L_mult(re[i],edct_table[length/2-1-i]);/*Q(Qx+Q_edct+16) */
+ Lacc = L_msu(L_tmp,im[i],edct_table[i]);/*Q(Qx+Q_edct+16) */
+ *py = round_fx(L_shr(Lacc,Q_edct)); /* Q(Qx) */
+
+ py -= 2;
+ pt--;
+ }
+ return;
+}
+
+
+/*-----------------------------------------------------------------*
+ * iedct_short_fx()
+ *
+ * Inverse EDCT for short frames
+ *-----------------------------------------------------------------*/
+
+void iedct_short_fx(
+ const Word32 *in, /* i : input vector */
+ Word16 *Q, /* i/o: Q value of input */
+ Word32 *out, /* o : output vector */
+ const Word16 segment_length /* i : length */
+)
+{
+ Word32 alias[MAX_SEGMENT_LENGTH];
+ Word16 seg_len_div2, seg_len_div4, seg_len_3mul_div4;
+ Word16 i;
+ Word16 qtmp, tmp;
+
+ qtmp = *Q;
+ move16();
+ tmp = 0;
+ move16();
+ seg_len_div2 = shr(segment_length, 1);
+ seg_len_div4 = shr(segment_length, 2);
+ seg_len_3mul_div4 = add(seg_len_div2, seg_len_div4);
+
+ edct_fx(in, alias, seg_len_div2, Q);
+ FOR (i = 0; i < seg_len_div2; i++)
+ {
+ IF (alias[i] != 0)
+ {
+ tmp = 1;
+ move16();
+ BREAK;
+ }
+ }
+ if (tmp == 0)
+ {
+ *Q = qtmp;
+ move16();
+ }
+ FOR (i = 0; i < seg_len_div4; i++)
+ {
+ out[i] = alias[seg_len_div4 + i];
+ move32();
+ out[seg_len_div4 + i] = L_negate(alias[seg_len_div2 - 1 - i]);
+ move32();
+ out[seg_len_div2 + i] = L_negate(alias[seg_len_div4 - 1 - i]);
+ move32();
+ out[seg_len_3mul_div4 + i] = L_negate(alias[i]);
+ move32();
+ }
+
+ return;
+}
diff --git a/lib_com/enhancer_fx.c b/lib_com/enhancer_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..81b8097abbcce4af3a8ecde7192d01fbc61f2b30
--- /dev/null
+++ b/lib_com/enhancer_fx.c
@@ -0,0 +1,679 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "stl.h"
+#include "basop_util.h"
+
+/*---------------------------------------------------------------------*
+ * Local constants
+ *---------------------------------------------------------------------*/
+#define pitch_0_9 14746 /* 0.9 in Q14 */
+#define pitch_0_6 9830 /* 0.6 in Q14 */
+#define SIZE 64
+#define SIZE2 32
+#define NUM_STAGES 5
+
+/*---------------------------------------------------------------------*
+ * Local functions
+ *---------------------------------------------------------------------*/
+static void phase_dispersion_fx(Word32 gain_code,Word16 gain_pit,Word16 code[],Word16 mode,struct dispMem_fx *dm_fx);
+static void agc2_fx(const Word16 *sig_in,Word16 *sig_out,const Word16 l_trm);
+
+/*======================================================================================*/
+/* FUNCTION : enhancer_fx() */
+/*--------------------------------------------------------------------------------------*/
+/* PURPOSE : Enhancement of the excitation signal before synthesis */
+/*--------------------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word32) core_brate : decoder bitrate */
+/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */
+/* _ (Word16) coder_type : coder type */
+/* _ (Word16) i_subfr : subframe number */
+/* _ (Word16) voice_fac : subframe voicing estimation (Q15) */
+/* _ (Word16) stab_fac : LP filter stablility measure (Q15) */
+/* _ (Word32) norm_gain_code : normalised innovative cb. gain (Q16) */
+/* _ (Word16) gain_inov : gain of the unscaled innovation (Q12) */
+/* _ (Word16) gain_pit_fx : Pitch gain (Q14) */
+/* _ (Word16) Q_exc : Q of the excitation */
+/* _ (Word16) Enc : Encoder = 1; decoder = 0 */
+/*--------------------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) voice_factors_fx : TBE voicing factor (Q15) */
+/*--------------------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word32*) gc_threshold : gain code threshold (Q16) */
+/* _ (Word16*[]) code : innovation (Q12) */
+/* _ (Word16*[]) exc2 : adapt. excitation/total exc (Q0) */
+/* _ (struct dispMem_fx*) dm_fx : phase dispersion algorithm memory */
+/* (a[0]->Q0,a[1]->Q16,a[2-7]->Q14) */
+/*--------------------------------------------------------------------------------------*/
+
+/* _ None */
+/*--------------------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*======================================================================================*/
+void enhancer_fx(
+ const Word32 core_brate, /* i : decoder bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 i_subfr, /* i : subframe number */
+ const Word16 L_frame, /* i : frame size */
+ const Word16 voice_fac, /* i : subframe voicing estimation Q15 */
+ const Word16 stab_fac, /* i : LP filter stablility measure Q15 */
+ Word32 norm_gain_code, /* i : normalised innovative cb. gain Q16 */
+ const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */
+ Word32 *gc_threshold,/* i/o: gain code threshold Q16 */
+ Word16 *code, /* i/o: innovation Q12 */
+ Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/
+ const Word16 gain_pit, /* i : quantized pitch gain Q14 */
+ struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */
+ const Word16 Q_exc /* i : Q of the excitation */
+)
+{
+ Word16 tmp, fac, *pt_exc2;
+ Word16 i;
+ Word32 L_tmp;
+ Word16 gain_code_hi;
+ Word16 pit_sharp, tmp16;
+ Word16 excp[L_SUBFR], sc;
+
+ pit_sharp = gain_pit;
+ move16(); /* to remove gcc warning */
+ pt_exc2 = exc2 + i_subfr;
+ move16();
+
+ /*------------------------------------------------------------*
+ * Phase dispersion to enhance noise at low bit rate
+ *------------------------------------------------------------*/
+
+ i = 2;
+ move16(); /* no dispersion */
+ IF (Opt_AMR_WB)
+ {
+ IF ( LE_32(core_brate,ACELP_6k60))
+ {
+ i = 0;
+ move16(); /* high dispersion */
+ }
+ ELSE if ( LE_32(core_brate,ACELP_8k85))
+ {
+ i = 1;
+ move16(); /* low dispersion */
+ }
+ }
+ ELSE IF( NE_16(coder_type,UNVOICED))
+
+ {
+ test();
+ test();
+ test();
+ test();
+ IF ( LE_32(core_brate,ACELP_7k20))
+ {
+ i = 0;
+ move16(); /* high dispersion */
+ }
+ ELSE if ( ( EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION)||EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&LE_32(core_brate,ACELP_9k60))
+ {
+ i = 1;
+ move16(); /* low dispersion */
+ }
+ }
+ phase_dispersion_fx(norm_gain_code, gain_pit, code, i, dm_fx);
+
+ /*------------------------------------------------------------
+ * noise enhancer
+ *
+ * - Enhance excitation on noise. (modify gain of code)
+ * If signal is noisy and LPC filter is stable, move gain
+ * of code 1.5 dB toward gain of code threshold.
+ * This decreases by 3 dB noise energy variation.
+ *-----------------------------------------------------------*/
+
+ /* tmp = 0.5f * (1.0f - voice_fac) */
+ tmp = msu_r(0x40000000, voice_fac, 16384); /*Q15 */ /* 1=unvoiced, 0=voiced */
+ /* fac = stab_fac * tmp */
+ fac = mult(stab_fac, tmp); /*Q15*/
+
+ IF (LT_32(norm_gain_code, *gc_threshold))
+ {
+ L_tmp = Madd_32_16(norm_gain_code, norm_gain_code, 6226);/*Q16 */
+ L_tmp = L_min(L_tmp, *gc_threshold);/*Q16 */
+ }
+ ELSE
+ {
+ L_tmp = Mult_32_16(norm_gain_code, 27536);/*Q16 */
+ L_tmp = L_max(L_tmp, *gc_threshold); /*Q16 */
+ }
+ *gc_threshold = L_tmp;
+ move32(); /*Q16 */
+
+ /* gain_code = (fac * tmp) + (1.0 - fac) * gain_code ==> fac * (tmp - gain_code) + gain_code */
+ L_tmp = L_sub(L_tmp, norm_gain_code); /*Q16 */
+ norm_gain_code = Madd_32_16(norm_gain_code, L_tmp, fac);/*Q16 */
+
+ /* gain_code *= gain_inov - Inverse the normalization */
+ L_tmp = Mult_32_16(norm_gain_code, gain_inov); /*Q13*/ /* gain_inov in Q12 */
+
+ sc = 6;
+ move16();
+
+ gain_code_hi = round_fx(L_shl(L_tmp, add(Q_exc, 3))); /* in Q_exc */
+
+ /*------------------------------------------------------------*
+ * pitch enhancer
+ *
+ * - Enhance excitation on voiced. (HP filtering of code)
+ * On voiced signal, filtering of code by a smooth fir HP
+ * filter to decrease energy of code at low frequency.
+ *------------------------------------------------------------*/
+ test();
+ IF( !Opt_AMR_WB && EQ_16(coder_type,UNVOICED))
+ {
+ /* Copy(code, exc2, L_SUBFR) */
+ FOR (i = 0; i < L_SUBFR; i++)
+ {
+ pt_exc2[i] = round_fx(L_shl(L_mult(gain_code_hi, code[i]), sc)); /*Q0 */ /* code in Q12 (Q9 for encoder) */
+ }
+ }
+ ELSE
+ {
+ test();
+ test();
+ IF ( Opt_AMR_WB && ( EQ_32(core_brate,ACELP_8k85)||EQ_32(core_brate,ACELP_6k60)))
+ {
+ pit_sharp = shl(gain_pit, 1); /* saturation can occur here Q14 -> Q15 */
+
+ /* saturation takes care of "if (pit_sharp > 1.0) { pit_sharp=1.0; }" */
+ IF (GT_16(pit_sharp, 16384))
+ {
+ tmp16 = mult(pit_sharp, 8192);
+ FOR (i = 0; i < L_SUBFR; i++)
+ {
+ /* excp[i] = pt_exc2[i] * pit_sharp * 0.25 */
+ excp[i] = mult_r(pt_exc2[i], tmp16);
+ move16();
+ }
+ }
+ }
+
+ IF ( EQ_16(L_frame, L_FRAME16k))
+ {
+ /* tmp = 0.150 * (1.0 + voice_fac) */
+ /* 0.30=voiced, 0=unvoiced */
+ tmp = mac_r(0x10000000L, voice_fac, 4915);/*Q15 */
+ }
+ ELSE
+ {
+ /* tmp = 0.125 * (1.0 + voice_fac) */
+ /* 0.25=voiced, 0=unvoiced */
+ tmp = mac_r(0x10000000L, voice_fac, 4096);/*Q15 */
+ }
+
+ /*-----------------------------------------------------------------
+ * Do a simple noncasual "sharpening": effectively an FIR
+ * filter with coefs [-tmp 1.0 -tmp] where tmp=0...0.25.
+ * This is applied to code and add_fxed to exc2
+ *-----------------------------------------------------------------*/
+ /* pt_exc2[0] += code[0] - tmp * code[1] */
+ L_tmp = L_deposit_h(code[0]); /* if Enc :Q9 * Q15 -> Q25 */
+ L_tmp = L_msu(L_tmp, code[1], tmp); /* Q12 * Q15 -> Q28 */
+ L_tmp = L_shl(L_mult(gain_code_hi, extract_h(L_tmp)), sc);
+ pt_exc2[0] = msu_r(L_tmp, -32768, pt_exc2[0]);
+ move16();/* in Q_exc */
+
+ FOR (i = 1; i < L_SUBFR-1; i++)
+ {
+ /* pt_exc2[i] += code[i] - tmp * code[i-1] - tmp * code[i+1] */
+ L_tmp = L_msu(-32768, code[i], -32768);
+ L_tmp = L_msu(L_tmp, code[i + 1], tmp);
+ tmp16 = msu_r(L_tmp, code[i - 1], tmp);
+ L_tmp = L_shl(L_mult(gain_code_hi, tmp16), sc);
+ pt_exc2[i] = msu_r(L_tmp, -32768, pt_exc2[i]);
+ move16(); /* in Q_exc */
+ }
+
+ /* pt_exc2[L_SUBFR-1] += code[L_SUBFR-1] - tmp * code[L_SUBFR-2] */
+ L_tmp = L_deposit_h(code[L_SUBFR - 1]);/*Q28 */
+ L_tmp = L_msu(L_tmp, code[L_SUBFR - 2], tmp);/*Q28 */
+ L_tmp = L_shl(L_mult(gain_code_hi, extract_h(L_tmp)), sc);
+ pt_exc2[L_SUBFR - 1] = msu_r(L_tmp, -32768, pt_exc2[L_SUBFR - 1]);
+ move16();/* in Q_exc */
+ test();
+ test();
+ IF ( Opt_AMR_WB && ( EQ_32(core_brate,ACELP_8k85)||EQ_32(core_brate,ACELP_6k60)))
+ {
+ IF (GT_16(pit_sharp, 16384))
+ {
+ FOR (i = 0; i < L_SUBFR; i++)
+ {
+ /* excp[i] += pt_exc2[i] */
+ excp[i] = add(excp[i], pt_exc2[i]);
+ move16();
+ }
+ agc2_fx(pt_exc2, excp, L_SUBFR);
+ Copy(excp, pt_exc2, L_SUBFR);
+ }
+ }
+ }
+}
+
+/*---------------------------------------------------------*
+ * Enhancement of the excitation signal before synthesis
+ *---------------------------------------------------------*/
+
+Word16 E_UTIL_enhancer(
+ Word16 voice_fac, /* i : subframe voicing estimation Q15 */
+ Word16 stab_fac, /* i : LP filter stability measure Q15 */
+ Word32 gain_code, /* i : innovative cb. gain 15Q16 */
+ Word16 gain_inov, /* i : gain of the unscaled innovation Q11 */
+ Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */
+ Word16 *code, /* i/o: innovation(in: Q9) code_exp */
+ Word16 *exc2, /* i/o: adapt. excitation/total exc. */
+ Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */
+ Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */
+ Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */
+ Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */
+ Word16 coder_type, /* i : coder type */
+ Word16 cdk_index, /* i : */
+ Word16 L_subfr, /* i : length of subframe */
+ Word16 L_frame, /* i : frame size */
+ Word16 Q_new
+)
+{
+ Word16 disp_mode, i;
+ Word16 tmp, fac, gain;
+ Word32 L_tmp;
+ Word16 code_exp, exc2_exp;
+ Word16 max_cdk_index_uv;
+
+ move16();
+ code_exp = 15-9;
+ exc2_exp = 15-Q_new;
+ gain_inov = shr(gain_inov,1);
+ /*-----------------------------------------------------------------*
+ * Phase dispersion to enhance noise at low bit rates
+ *-----------------------------------------------------------------*/
+
+ max_cdk_index_uv = 10;
+ move16();
+ if ( EQ_16(L_frame, L_FRAME16k))
+ {
+ max_cdk_index_uv = 14;
+ move16();
+ }
+ disp_mode = 2; /* any=off */ move16();
+ test();
+ test();
+ test();
+ test();
+ IF ( ( (NE_16(coder_type, VOICED))&&(LE_16(cdk_index,2)))||((EQ_16(coder_type,UNVOICED))&&(LE_16(cdk_index,max_cdk_index_uv))))
+ {
+ disp_mode = 0; /* high */ move16();
+ }
+ ELSE IF ( (NE_16(coder_type, VOICED))&&(LE_16(cdk_index,7)))
+ {
+ disp_mode = 1; /* low */ move16();
+ }
+
+ phase_dispersion(gain_code, gain_pit,code, &code_exp, disp_mode, prev_gain_code, prev_gain_pit, prev_state, L_subfr);
+
+ /*------------------------------------------------------------*
+ * noise enhancer *
+ * ~~~~~~~~~~~~~~ *
+ * - Enhance excitation on noise. (modify gain of code) *
+ * If signal is noisy and LPC filter is stable, move gain *
+ * of code 1.5 dB toward gain of code threshold. *
+ * This decrease by 3 dB noise energy variation. *
+ *------------------------------------------------------------*/
+ fac = 0;
+ move16();
+
+ /* if gain_code is computed function of energy, noise enhancer is by-passed.*/
+ BASOP_SATURATE_WARNING_OFF
+ tmp = msu_r(1073741824l/*0.5f Q31*/, 16384/*0.5f Q15*/, voice_fac); /* 1=unvoiced, 0=voiced */
+ BASOP_SATURATE_WARNING_ON
+ fac = mult_r(stab_fac, tmp); /* fac in Q15 */
+
+ L_tmp = gain_code; /* L_tmp in 15Q16 */
+ move32();
+
+ IF (LT_32(L_tmp,*gc_threshold))
+ {
+ L_tmp = L_shl(Mpy_32_32(L_tmp, 1277752832l/*1.19f/2.0f Q31*/),1);
+ L_tmp = L_min(L_tmp, *gc_threshold);
+ }
+ ELSE
+ {
+ L_tmp = Mpy_32_32(L_tmp, 1804608000l/*1.0f/1.19f Q31*/);
+ L_tmp = L_max(L_tmp, *gc_threshold);
+ }
+ move32();
+ *gc_threshold = L_tmp; /* in 15Q16 */
+
+ /* gain = ( (fac * L_tmp) + (gain_code - fac*gain_code) ) * gain_inov */
+ /* exponent of L_tmp: 31-16 + 15-11 */
+ L_tmp = Mpy_32_16_1(L_add(Mpy_32_16_1(L_tmp, fac), L_sub(gain_code, Mpy_32_16_1(gain_code, fac))), gain_inov);
+
+ /* exponent gain: 31-16 + 15-11 - tmp */
+ tmp = norm_l(L_tmp);
+
+ /* exponent of code: 31-16 + 15-11 - tmp + code_exp */
+ move16();
+ code_exp = sub(add(31-16 + 15-11, code_exp), tmp);
+
+ L_tmp = L_shl(L_tmp, tmp);
+ gain = round_fx(L_tmp);
+
+ FOR (i=0; iQ0,a[1]->Q16,a[2-7]->Q14) */
+/*--------------------------------------------------------------------------------------*/
+
+/* _ None */
+/*--------------------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*======================================================================================*/
+static void phase_dispersion_fx(
+ Word32 gain_code, /* i : gain of code Q16 */
+ Word16 gain_pit, /* i : gain of pitch Q14 */
+ Word16 code[], /* i/o: code vector */
+ Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */
+ struct dispMem_fx *dm_fx /* i/o: static memory (size = 8) */
+)
+{
+ Word16 i, j, state;
+ Word16 *prev_gain_pit, *prev_state;
+ Word32 *prev_gain_code;
+ Word16 *code2_real, *code2_imag;
+ Word16 *code_real, *code_imag;
+ const Word16 *h_real, *h_imag;
+
+ Word16 code2[2 * L_SUBFR];
+
+ prev_state = &(dm_fx->prev_state);
+ prev_gain_code = &(dm_fx->prev_gain_code);
+ prev_gain_pit = dm_fx->prev_gain_pit;
+
+ state = 2;
+ move16();
+ if (LT_16(gain_pit, pitch_0_9))
+ {
+ state = 1;
+ move16();
+ }
+
+ if (LT_16(gain_pit, pitch_0_6))
+ {
+ state = 0;
+ move16();
+ }
+
+ FOR (i = 5; i > 0; i--)
+ {
+ prev_gain_pit[i] = prev_gain_pit[i - 1];
+ move16();
+ }
+ prev_gain_pit[0] = gain_pit;
+ move16();
+
+ IF (GT_32(L_sub(gain_code, *prev_gain_code), L_shl(*prev_gain_code, 1)))
+ {
+ state = s_min(add(state, 1), 2);
+ }
+ ELSE
+ {
+ j = 0;
+ move16();
+
+ FOR (i = 0; i < 6; i++)
+ {
+ j = sub(j, shr(sub(prev_gain_pit[i], pitch_0_6), 15));
+ }
+
+ if (GT_16(j, 2))
+ {
+ state = 0;
+ move16();
+ }
+
+ if (GT_16(sub(state, *prev_state), 1))
+ {
+ state = sub(state, 1);
+ }
+ }
+
+ *prev_gain_code = gain_code;
+ move32();
+ *prev_state = state;
+ move16();
+
+ /*-----------------------------------------------------------------*
+ * circular convolution
+ *-----------------------------------------------------------------*/
+
+ state = add(state, mode); /* level of dispersion */
+
+ IF (LT_16(state, 2))
+ {
+ r_fft_fx_lc(phs_tbl_dec, SIZE, SIZE2, NUM_STAGES, code, code2, 1);
+
+ h_real = Mid_H_phasedisp;
+ move16();
+ if (state == 0)
+ {
+ h_real = Low_H_phasedisp;
+ move16();
+ }
+
+ /* FFT Coefs are in code2 */
+ code2_real = code2;
+ move16();
+ code2_imag = code2 + L_SUBFR - 1;
+ move16();
+
+ code_real = code;
+ move16();
+ code_imag = code + L_SUBFR - 1;
+ move16();
+
+ h_imag = h_real + L_SUBFR - 1;
+ move16();
+
+ *code_real++ = mult(*code2_real++, *h_real++);
+ move16(); /* DC */
+
+ FOR (i=1; i 0 && pulses[i-1] != 0 && pulses[i+1] != 0 )
+ {
+ adj[i] = 11796; /* Q15, 0.36f */ move16();
+ }
+ ELSE IF ( i > 0 && ( pulses[i-1] == 0 || pulses[i+1] == 0) )
+ {
+ adj[i] = 17695; /* Q15, 0.54f */ move16();
+ }
+ ELSE
+ {
+ adj[i] = 23593; /* Q15, 0.72f */ move16();
+ }
+ }
+ ELSE IF ( LT_16(i,last_sfm))
+ {
+ test();
+ IF ( pulses[i-1] != 0 && pulses[i+1] != 0 )
+ {
+ adj[i] = 17695; /* Q15, 0.54f */ move16();
+ }
+ ELSE
+ {
+ adj[i] = 23593; /* Q15, 0.72f */ move16();
+ }
+ }
+ ELSE
+ {
+ adj[i] = 23593; /* Q15, 0.72f */ move16();
+ }
+
+ if( att_state == 0 )
+ {
+ start = i;
+ move16();
+ }
+
+ len = add(len,1);
+ move16();
+ att_state = 1;
+ move16();
+ }
+ ELSE
+ {
+ adj[i] = MAX_16; /* Q15, 1.0f (saturated) */
+ IF( EQ_16(att_state, 1)) /* End of attenuation region found */
+ {
+ /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */
+ tmp = round_fx(L_shl(L_mult0(s_max( 0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX),16)); /* Q15 (15+16-16) */
+ tmp_diff = sub(MAX_16, tmp); /* Q15 */ move16();
+ FOR( j = start; j < i ; j++ )
+ {
+ /* adj[j] = max(tmp + (1-tmp)*adj[j],env_stab); */
+ adj[j] = s_max(add(tmp, mult(tmp_diff, adj[j])), env_stab); /* Q15 (15+15-15) */ move16();
+ }
+ len = 0;
+ move16();
+ att_state = 0;
+ move16();
+ }
+ }
+ }
+ /* length == L_FRAME16k */
+ ELSE
+ {
+
+ /* Calculate low accuracy band attenuation */
+ gain_adj = 32767; /* Q15, 1.0f (saturated) */ move16();
+
+ test();
+ IF( npul > 0 && LT_16(npul, MAX_P_ATT))
+ {
+ /*idx = (short)(npul * att_step[group] + 0.5f) - 1; */
+ idx = sub(mult_r(shl(npul,2),att_step_fx[group]), 1); /* Q0 (2+13+1-16) */
+ if( LT_16(idx, MAX_P_ATT))
+ {
+ gain_adj = gain_att_fx[idx]; /* Q15 */ move16();
+ }
+ }
+ adj[i] = gain_adj;
+ move16();
+ }
+ }
+
+ /* Check if the sequence ended with an attenuation region */
+ IF( EQ_16(att_state, 1))
+ {
+ /* tmp = min(1, max(0, len-ENV_ADJ_START)*(1.0f/ENV_ADJ_INCL)); */
+ tmp = round_fx(L_shl(L_mult0(s_max( 0, sub(len, ENV_ADJ_START_FX)), ENV_ADJ_INV_INCL_FX),16)); /* Q15 (15+16-16) */
+ tmp_diff = sub(MAX_16, tmp); /* Q15 */ move16();
+ FOR( j = start; j < i ; j++ )
+ {
+
+ /* adj[j] = max(tmp + (1-tmp)*adj[j],env_stab); */
+ adj[j] = s_max(add(tmp, mult(tmp_diff, adj[j])), env_stab); /* Q15 (15+15-15) */ move16();
+ }
+ }
+
+ return;
+}
diff --git a/lib_com/env_stab_fx.c b/lib_com/env_stab_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..e3e8c63297f0c51402ac555e456a91360aa4df45
--- /dev/null
+++ b/lib_com/env_stab_fx.c
@@ -0,0 +1,188 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "stl.h" /* required by wmc_tool */
+
+/*--------------------------------------------------------------------------*
+ * Local constants
+ *--------------------------------------------------------------------------*/
+#define ENV_STAB_SMO_HO 10 /* number of hangover frames when switching from music to speech state */
+
+/*--------------------------------------------------------------------------*/
+/* Function env_stability_fx */
+/* ~~~~~~~~~~~~~~~~~~~~~ */
+/* */
+/* Envelope stability measure */
+/*--------------------------------------------------------------------------*/
+
+Word16 env_stability_fx( /* in Q15 */
+ const Word16 *ynrm, /*i: Norm vector for current frame */
+ const Word16 nb_sfm, /*i: Number of sub-bands */
+ Word16 *mem_norm, /*i/o: Norm vector memory from past frame */
+ Word16 *mem_env_delta /*i/o: Envelope stability memory for smoothing in Q12 */
+)
+{
+ Word16 env_delta;
+ Word16 env_stab;
+ Word16 tmp, tmp_stab;
+ Word16 i;
+
+ Word16 exp, exp2;
+ Word32 L_tmp, L_env_delta;
+ Word16 inv_nb_sfm;
+
+ /* Calculate envelope stability parameter */
+ L_env_delta = L_deposit_l(0);
+ FOR (i = 0; i < nb_sfm; i++)
+ {
+ tmp = sub(mem_norm[i],ynrm[i]);
+ L_env_delta = L_mac0(L_env_delta, tmp, tmp);
+ mem_norm[i] = ynrm[i];
+ move16();
+ }
+
+ inv_nb_sfm = 19418; /* Q19 */ move16();
+ if (nb_sfm == 26)
+ {
+ inv_nb_sfm = 20165; /* Q19 */ move16();
+ }
+ exp = norm_l(L_env_delta);
+ L_env_delta = Mult_32_16(L_shl(L_env_delta, exp), inv_nb_sfm); /* 0+exp+19-15 */
+
+ L_tmp = Sqrt_l(L_env_delta, &exp2); /* exp+4+31+exp2 */
+
+ exp = add(35, add(exp, exp2));
+ if ( EQ_16(s_and(exp, 1), 1))
+ {
+ L_tmp = Mult_32_16(L_tmp, 23170); /* 1/sqrt(2) in Q15 */
+ }
+ exp = shr(exp, 1);
+
+ env_delta = round_fx(L_shl(L_tmp, sub(26, exp))); /* Q10 */
+
+ L_tmp = L_mult0(26214, env_delta); /* 26214 is 0.1 in Q18. Q28 */
+ L_tmp = L_mac(L_tmp, 29491, *mem_env_delta); /* 29491 is 0.9 in Q15. Q28 */
+
+ *mem_env_delta = round_fx(L_tmp); /* Q12 */
+ Overflow = 0;
+ move16();
+ env_delta = round_fx(L_shl(L_tmp, 1)); /* Q13 */
+
+ IF (Overflow != 0) /* Saturated due to the above up-shifting operation. */
+ {
+ return stab_trans_fx[L_STAB_TBL-1]; /* The highest quantized index. */
+ }
+
+ /* If tmp_stab > (D_STAB_TBL*L_STAB_TBL + M_STAB_TBL), i.e., 0.103138*10+2.51757=3.603137,
+ * the quantized index is equal to 9. Hence, we only need to worry about any tmpStab < 4.
+ * In this case, Q13 is good enough.
+ */
+ tmp_stab = sub(env_delta, M_STAB_TBL_FX); /* in Q13 */
+ tmp_stab = abs_s(tmp_stab);
+
+ /* Table lookup for smooth transitions
+ * First, find the quantization level, i, of tmpStab. */
+#if L_STAB_TBL > 10
+#error env_stability_fx: Use more efficient usquant()
+#endif
+ tmp_stab = sub(tmp_stab, HALF_D_STAB_TBL_FX); /* in Q13 */
+ FOR (i = 0; i < L_STAB_TBL-1; i++)
+ {
+ IF (tmp_stab < 0)
+ {
+ BREAK;
+ }
+ ELSE
+ {
+ tmp_stab = sub(tmp_stab, D_STAB_TBL_FX); /* in Q13 */
+ }
+ }
+
+ env_stab = stab_trans_fx[i];
+ move16();
+ if(LT_16(env_delta, M_STAB_TBL_FX))
+ {
+ env_stab = sub(0x7FFF,stab_trans_fx[i]);
+ }
+
+ return env_stab;
+}
+
+/*--------------------------------------------------------------------------*
+ * env_stab_smo_fx()
+ *
+ *
+ *--------------------------------------------------------------------------*/
+Word16 env_stab_smo_fx( /* Q0 */
+ Word16 env_stab, /*i : env_stab value Q15 */
+ Word16 *env_stab_state_p, /*i/o: env_stab state probabilities Q15 */
+ Word16 *ho_cnt /*i/o: hangover counter for speech state */
+)
+{
+ Word16 state, prev_state;
+ Word16 maxval, pp[NUM_ENV_STAB_PLC_STATES], pa[NUM_ENV_STAB_PLC_STATES];
+ Word16 i;
+ Word16 tmp, sum, exp;
+
+ /* get previous state */
+ prev_state = maximum_fx(env_stab_state_p, NUM_ENV_STAB_PLC_STATES, &maxval);
+
+ /* assume two states: speech(0), music(1) */
+ /* set a posteriori likelihoods for the two states according to env_stab */
+ /* re-scale. Unclear if needed */
+ /* env_stab = (env_stab - stab_trans_fx[L_STAB_TBL-1])/(1-2*stab_trans_fx[L_STAB_TBL-1]); */
+ tmp = sub(env_stab, stab_trans_fx[L_STAB_TBL-1]);
+ tmp = round_fx(L_shl(L_mult(tmp, INV_STAB_TRANS_FX), 1)); /* Q15 */
+
+ pp[0] = sub(32767, tmp);
+ move16(); /* 1 in Q15 */
+ pp[1] = tmp;
+ move16();
+
+ /* calculate a priori likelihoods */
+ pa[0] = round_fx(Dot_product(env_stab_tp_fx[0], env_stab_state_p, NUM_ENV_STAB_PLC_STATES)); /* Q15*/
+ pa[1] = round_fx(Dot_product(env_stab_tp_fx[1], env_stab_state_p, NUM_ENV_STAB_PLC_STATES));
+
+ /* multiply elementwise with a posteriori likelihoods */
+ sum = 0;
+ move16();
+ FOR (i = 0; i < NUM_ENV_STAB_PLC_STATES; i++)
+ {
+ env_stab_state_p[i] = mult_r(pa[i], pp[i]);
+ move16(); /* Q15 */
+ sum = add(sum, env_stab_state_p[i]);
+ }
+
+ /* renormalize state probabilities */
+ exp = norm_s(sum);
+ tmp = div_s(16384, shl(sum, exp)); /* Q(14-exp) */
+ /*tmp = shl(tmp, add(exp, 1));*/ /* Q15 */
+ FOR (i = 0; i < NUM_ENV_STAB_PLC_STATES; i++)
+ {
+ env_stab_state_p[i] = round_fx(L_shl(L_mult(env_stab_state_p[i], tmp), add(exp, 1))); /* Q15 */
+ }
+
+ /* find maximum index as return value */
+ state = maximum_fx(env_stab_state_p, NUM_ENV_STAB_PLC_STATES, &maxval);
+
+ /* apply some hangover for speech */
+ test();
+ if (state == 0 && EQ_16(prev_state, 1))
+ {
+ *ho_cnt = ENV_STAB_SMO_HO;
+ move16();
+ }
+
+ IF (*ho_cnt > 0)
+ {
+ *ho_cnt = sub(*ho_cnt, 1);
+ move16();
+ }
+
+ return state;
+}
diff --git a/lib_com/env_stab_trans_fx.c b/lib_com/env_stab_trans_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..6e86bca565b2981cb1b1d0eeedba19517d571c28
--- /dev/null
+++ b/lib_com/env_stab_trans_fx.c
@@ -0,0 +1,161 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "math_op.h" /* WMOPS macros */
+#include "stl.h" /* required by wmc_tool */
+
+/*--------------------------------------------------------------------------*
+ * env_stab_transient_detect()
+ *
+ * Transient detector for envelope stability measure
+ *--------------------------------------------------------------------------*/
+
+void env_stab_transient_detect_fx(
+ const Word16 is_transient, /* i: Transient flag */
+ const Word16 length, /* i : Length of spectrum (32 or 48 kHz) */
+ const Word16 norm[], /* i : quantization indices for norms */
+ Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover (Q0) */
+ Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection (Q13) */
+ const Word16 HQ_mode, /* i : HQ coding mode */
+ const Word16 bin_th, /* i : HVQ cross-over frequency bin */
+ const Word32 *L_coeff, /* i : Coded spectral coefficients */
+ const Word16 Qcoeff /* i : Q of coded spectral coefficients */
+)
+{
+ Word16 i, blk, norm_ind, sqrt_exp, bin_th_1, temp, sh;
+ Word32 L_e_frame, L_temp, L_d_max;
+ Word32 L_energy_lt_local;
+ Word32 L_E_sub[4];
+ Word32 L_delta_e_sub;
+
+ L_energy_lt_local = *L_energy_lt;
+ move32();
+
+ L_d_max = L_deposit_l(0);
+ L_e_frame = L_deposit_l(0);
+ temp = 32;
+ move16();
+
+ IF( EQ_16(HQ_mode,HQ_HVQ))
+ {
+ FOR (i = 0; i < bin_th; i++) /* find adaptive shift */
+ {
+ temp = s_min(temp,norm_l(L_coeff[i]));
+ }
+ sh = sub(temp,2); /* scale such that 2 msbs are not used, the resulting adaptive Qcoeff will be: Qcoeff+sh-16 */
+ FOR (i = 0; i < bin_th; i++) /* Maximum number of loop runs 320 */
+ {
+ temp = extract_h(L_shl(L_coeff[i],sh));
+ L_e_frame = L_mac(L_e_frame,temp,temp); /* Q(2*(Qcoeff+sh-16)+1)=Q(2*(Qcoeff+sh)-31 */
+ }
+
+ bin_th_1 = INV_HVQ_THRES_BIN_24k;
+ move16();
+ if (EQ_16(bin_th, HVQ_THRES_BIN_32k))
+ {
+ bin_th_1 = INV_HVQ_THRES_BIN_32k;
+ move16();
+ }
+ L_temp = Mult_32_16(L_e_frame,bin_th_1); /* Q(2*(Qcoeff-16+sh)+1+21-15) -> Q(2*(Qcoeff+sh)-25) */
+ L_e_frame = Sqrt_l(L_temp,&sqrt_exp);
+ L_e_frame = L_shr(L_e_frame, add(sub(add(sh,Qcoeff),10),shr(sqrt_exp,1))); /* Adjust by (Qcoeff+sh-10) to fixed Q13: Qcoeff+sh+(-25+31)/2 - (Qcoeff+sh-10) -> Q13 */
+
+ IF ( GT_32(L_e_frame, ENERGY_TH_FX))
+ {
+ L_energy_lt_local = Mult_32_16(*L_energy_lt, ENERGY_LT_BETA_FX);
+ L_temp = Mult_32_16(L_e_frame, ENERGY_LT_BETA_1_FX);
+ *L_energy_lt = L_add(L_energy_lt_local,L_temp);
+ move32();
+ }
+
+ IF (*no_att_hangover > 0)
+ {
+ (*no_att_hangover) = sub((*no_att_hangover), 1);
+ move16();
+ }
+ }
+ ELSE
+ {
+ L_e_frame = L_deposit_l(0);
+
+ test();
+ IF (is_transient && EQ_16(length,L_FRAME32k))
+ {
+ /* Measure subframe energies */
+ FOR (blk = 0; blk < NUM_SUBFRAMES; blk++)
+ {
+ L_E_sub[blk] = L_deposit_l(0); /* Q9 */
+
+ FOR (i=0; i < 2^4 */
+ {
+ norm_ind = subf_norm_groups_fx[blk][i];
+ move16();
+ L_E_sub[blk] = L_add(L_E_sub[blk],L_shr(dicn_fx[norm[norm_ind]],4));
+ move32(); ; /* Q10 */
+ }
+
+ L_E_sub[blk] = Mult_32_16(L_E_sub[blk], INV_BANDS_PER_SUBFRAMES);
+ move32(); /* Q(10+17-15) -> Q12 */
+
+ L_e_frame = L_add(L_e_frame,L_E_sub[blk]); /* Q12 */
+ }
+
+ /* Test for transient */
+ /* if (e_frame > ENERGY_TH * NUM_SUBFRAMES) */
+ IF (GT_32(L_e_frame, ENERGY_TH_NUM_SUBFRAMES))
+ {
+ FOR (blk = 0; blk < NUM_SUBFRAMES-1; blk++)
+ {
+ L_delta_e_sub = L_sub(L_E_sub[blk+1],L_E_sub[blk]); /* Q12 */
+ if (GT_32(L_delta_e_sub,L_d_max))
+ {
+ L_d_max = L_delta_e_sub; /* L_d_max is NOT normalized with *energy_lt */
+ move32();
+ }
+ }
+ }
+ }
+ ELSE
+ {
+ /* Update long-term energy measure */
+ L_e_frame = L_deposit_l(0); /* Q9 */
+ FOR (i = 0; i < SFM_N_ENV_STAB; i++) /* 27 times -> < 2^5 */
+ {
+ L_e_frame = L_add(L_e_frame,L_shr(dicn_fx[norm[i]],5));
+ /* Q9 */
+ }
+
+ L_e_frame = Mult_32_16(L_e_frame, INV_SFM_N_ENV_STAB); /* Q(9+19-15) -> Q13 */
+
+ IF ( GT_32(L_e_frame, ENERGY_TH_FX))
+ {
+ L_energy_lt_local = Mult_32_16(*L_energy_lt, ENERGY_LT_BETA_FX);
+ L_temp = Mult_32_16(L_e_frame, ENERGY_LT_BETA_1_FX);
+ *L_energy_lt = L_add(L_energy_lt_local,L_temp);
+ move32();
+ }
+ }
+
+ /* Add hang-over for conservative application of stability dependent attenuation */
+ /* -> Note: L_d_max not normalized with *energy_lt */
+ /* Hence, we compare L_d_max/DELTA_TH with *energy_lt */
+ IF (GT_32(Mult_32_16(L_d_max, INV_DELTA_TH),L_energy_lt_local)) /* Q13 = Q(12 + 16 -15) */
+ {
+ *no_att_hangover = ATT_LIM_HANGOVER;
+ move16();
+ }
+ ELSE if (*no_att_hangover > 0)
+ {
+ *no_att_hangover = sub(*no_att_hangover,1);
+ move16();
+ }
+ }
+
+ return;
+}
+
diff --git a/lib_com/est_tilt_fx.c b/lib_com/est_tilt_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..07a7ac03db0ce8d384756e1ed0938f01f393c99d
--- /dev/null
+++ b/lib_com/est_tilt_fx.c
@@ -0,0 +1,269 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+#include "basop_mpy.h"
+#include "basop_util.h"
+
+
+/*======================================================================*/
+/* FUNCTION : est_tilt_fx() */
+/*-----------------------------------------------------------------------*/
+/* PURPOSE : Estimate spectral tilt based on the relative E of adaptive */
+/* and innovative excitations */
+/* */
+/*-----------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16 *) exc : adaptive excitation vector Q0 */
+/* _ (Word16) gain_pit : adaptive gain Q14 */
+/* _ (Word16 *) code : algebraic exctitation vector Q12 */
+/* _ (Word32) gain_code : algebraic code gain Q16 */
+/* _ (Word16) Q_exc : Scaling factor of excitation Q0 */
+/*-----------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 *) voice_fac : voicing factor Q15 */
+/*-----------------------------------------------------------------------*/
+/* INPUT OUTPUT ARGUMENTS */
+/*-----------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word16) tolt_code : tilt of the code Q15 */
+/*=======================================================================*/
+Word16 est_tilt_fx( /* o : tilt of the code Q15 */
+ const Word16 *exc, /* i : adaptive excitation vector Qx */
+ const Word16 gain_pit, /* i : adaptive gain Q14 */
+ const Word16 *code, /* i : algebraic exctitation vector Q9 */
+ const Word32 gain_code, /* i : algebraic code gain Q16 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
+)
+{
+ Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
+ Word32 L_tmp;
+ Word16 tilt_code;
+
+ ener1 = extract_h(Dot_product12(exc, exc, L_SUBFR, &exp1));
+ exp1 = sub(exp1, add(Q_exc, Q_exc));
+ L_tmp = L_mult(gain_pit, gain_pit); /* energy of pitch excitation */
+ exp = norm_l(L_tmp);
+ tmp = extract_h(L_shl(L_tmp, exp));
+ ener1 = mult(ener1, tmp);
+ exp1 = sub(sub(exp1, exp), 10); /* 10 -> gain_pit Q14 to Q9 */
+
+ ener2 = extract_h(Dot_product12(code, code, L_SUBFR, &exp2));
+
+ exp = norm_l(gain_code);
+ tmp = extract_h(L_shl(gain_code, exp));
+ tmp = mult(tmp, tmp); /* energy of innovative code excitation */
+ ener2 = mult(ener2, tmp);
+ exp2 = sub(exp2, add(exp, exp));
+
+ i = sub(exp1, exp2);
+ BASOP_SATURATE_WARNING_OFF
+ ener1 = shr(ener1, sub(1, s_min(i, 0)));
+ ener2 = shr(ener2, add(s_max(0, i), 1));
+ BASOP_SATURATE_WARNING_ON
+ tmp = sub(ener1, ener2);
+ ener1 = add(add(ener1, ener2), 1);
+
+ /* find voice factor (1=voiced, -1=unvoiced) */
+ exp = div_s(abs_s(tmp), ener1);
+ if (tmp < 0)
+ {
+ exp = negate(exp);
+ }
+ *voice_fac = exp;
+ move16();
+
+ /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
+
+ /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
+ tilt_code = mac_r(8192L*65536-0x8000, *voice_fac, 8192); /*Q15 */
+
+ return tilt_code;
+}
+/*-------------------------------------------------------------------*
+ * Est_tilt2:
+ *
+ * Estimate spectral tilt based on the relative E of adaptive
+ * and innovative excitations
+ *-------------------------------------------------------------------*/
+Word16 Est_tilt2( /* o : tilt of the code */
+ const Word16 *exc, /* i : adaptive excitation vector Qx */
+ const Word16 gain_pit, /* i : adaptive gain Q14 */
+ const Word16 *code, /* i : algebraic exctitation vector Q9 */
+ const Word32 gain_code, /* i : algebraic code gain Q16 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
+)
+{
+ Word16 i, tmp, exp, ener1, exp1, ener2, exp2;
+ Word32 L_tmp;
+ Word16 tilt_code;
+
+ /* Scale exc to avoid overflow */
+ ener1 = extract_h(Energy_scale(exc, L_SUBFR, Q_exc, &exp1));
+
+ exp1 = sub(exp1, add(Q_exc, Q_exc));
+ L_tmp = L_mult(gain_pit, gain_pit); /* energy of pitch excitation */
+ exp = norm_l(L_tmp);
+ tmp = extract_h(L_shl(L_tmp, exp));
+ ener1 = mult(ener1, tmp);
+ exp1 = sub(sub(exp1, exp), 10); /* 10 -> gain_pit Q14 to Q9 */
+
+ ener2 = extract_h(Dot_product12(code, code, L_SUBFR, &exp2));
+
+ exp = norm_l(gain_code);
+ tmp = extract_h(L_shl(gain_code, exp));
+ tmp = mult(tmp, tmp); /* energy of innovative code excitation */
+ ener2 = mult(ener2, tmp);
+ exp2 = sub(exp2, add(exp, exp));
+
+ i = sub(exp1, exp2);
+ ener1 = shr(ener1, sub(1, s_min(i, 0)));
+ ener2 = shr(ener2, add(s_max(0, i), 1));
+
+ tmp = sub(ener1, ener2);
+ ener1 = add(add(ener1, ener2), 1);
+
+ /* find voice factor (1=voiced, -1=unvoiced) */
+ exp = div_s(abs_s(tmp), ener1);
+ if (tmp < 0)
+ {
+ exp = negate(exp);
+ }
+ *voice_fac = exp;
+ move16();
+
+ /* tilt of code for next subframe: 0.5=voiced, 0=unvoiced */
+
+ /* tilt_code = (float)(0.25*(1.0 + *voice_fac)) */
+ tilt_code = mac_r(8192L*65536-0x8000, *voice_fac, 8192);
+
+ return tilt_code;
+}
+
+/*---------------------------------------------------------*
+ * Find voice factor and tilt code *
+ *---------------------------------------------------------*/
+void E_UTIL_voice_factor( Word16 *exc, /* i : pointer to the excitation frame Q_new */
+ Word16 i_subfr, /* i : subframe index */
+ Word16 *code, /* i : innovative codebook Q9 */
+ Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */
+ Word32 gain_code, /* i : innovative cb. gain 15Q16 */
+ Word16 *voice_fac, /* o : subframe voicing estimation Q15 */
+ Word16 *tilt_code, /* o : tilt factor Q15 */
+ Word16 L_subfr, /* i : subframe length */
+ Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/
+ Word16 Q_new, /* i : excitation buffer format */
+ Word16 shift /* i : scaling to get 12bit */
+ )
+{
+ Word16 i, e, e2, stmp, exp_ener, fac;
+ Word32 ener, tmp, num;
+ Word64 ener_64;
+
+ BASOP_SATURATE_ERROR_ON;
+
+
+ IF(shift != 0)
+ {
+ fac = shl(0x4000,add(1,shift));
+ /* energy of pitch excitation */
+ stmp = mult_r(exc[0+i_subfr], fac); /* remove fac bits */
+ ener_64 = W_mult0_16_16(stmp, stmp);
+ FOR (i=1; i exponent = (15-Q_new)*2+1 */
+ }
+ }
+ ener = W_sat_l( ener_64 );
+
+
+ /* exponent of ener: (2*(15-Q_new+shift)+1+2-exp_ener-2*e2) */
+ exp_ener = norm_l(ener);
+ if(ener == 0)
+ {
+ exp_ener = 31;
+ move16();
+ }
+ ener = L_shl(ener,exp_ener);
+ e2 = norm_s(gain_pit);
+ gain_pit = shl(gain_pit,e2);
+ ener = Mpy_32_16_1(ener, mult_r(gain_pit, gain_pit));
+
+
+ /* energy of innovative code excitation */
+ tmp = L_deposit_l(1);
+
+ FOR (i=0; i 13Q18 */
+ }
+ /* exponent of tmp: 2*(15-9)+1+2*(15-e)) */
+ e = norm_l(gain_code);
+ gain_code = L_shl(gain_code, e);
+ tmp = Mpy_32_32(tmp, Mpy_32_32(gain_code,gain_code));
+
+ /* find voice factor (1=voiced, -1=unvoiced) */
+ /*i = (2*(15-Q_new+shift)+1+2-exp_ener-2*e2) - (2*(15-9)+1 + 2*(15-e));*/
+ i = sub(sub(sub(sub(sub(33,add(shift,shift)),add(Q_new,Q_new)),exp_ener),add(e2,e2)),sub(43,add(e,e)));
+ IF(i >= 0)
+ {
+ ener = L_shr(ener,1);
+ tmp = L_shr(tmp, add(1,i));
+ }
+ ELSE
+ {
+ tmp = L_shr(tmp,1);
+ BASOP_SATURATE_WARNING_OFF
+ ener = L_shr(ener, sub(1,i));
+ BASOP_SATURATE_WARNING_ON
+ }
+
+ *voice_fac = 0;
+ move16();
+ num = L_sub(ener, tmp);
+ IF(num != 0)
+ {
+ BASOP_SATURATE_WARNING_OFF /* Allow saturating the voice factor because if has a limited range by definition. */
+ *voice_fac = divide3232(num, L_add(ener, tmp));
+ move16();
+ BASOP_SATURATE_WARNING_ON
+ }
+
+ /* find tilt of code for next subframe */
+ IF (flag_tilt==0)
+ {
+ /*Between 0 (=unvoiced) and 0.5 (=voiced)*/
+ move16();
+ *tilt_code = add(8192/*0.25f Q15*/, mult_r(8192/*0.25f Q15*/, *voice_fac));
+ }
+ ELSE IF (flag_tilt==1)
+ {
+ /*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/
+ move16();
+ *tilt_code = add(mult_r(4096/*0.125f Q15*/, *voice_fac), 12288/*0.125f+0.25f Q15*/);
+ }
+ ELSE
+ {
+ /*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/
+ move16();
+ *tilt_code = add(mult_r(4588/*0.14f Q15*/, *voice_fac), 13763/*0.14f+0.28f Q15*/);
+ }
+ BASOP_SATURATE_ERROR_OFF;
+}
diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c
new file mode 100644
index 0000000000000000000000000000000000000000..400a41d8e78c6647600445e9e622d653ab601d77
--- /dev/null
+++ b/lib_com/fd_cng_com.c
@@ -0,0 +1,1826 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "stl.h"
+#include "basop_util.h"
+#include "options.h"
+#include "stl.h"
+#include "rom_basop_util.h"
+#include "rom_com_fx.h"
+#include "prot_fx.h"
+
+#define DELTA_SHIFT 2
+#define DELTA_SHIFT_LD64 67108864l/*DELTA_SHIFT/64.0 Q31*/
+
+
+
+/*****************************************
+* Create an instance of type FD_CNG_COM *
+*****************************************/
+void createFdCngCom(HANDLE_FD_CNG_COM * hFdCngCom)
+{
+ HANDLE_FD_CNG_COM hs;
+
+ /* Allocate memory */
+ hs = (HANDLE_FD_CNG_COM) calloc(1, sizeof (FD_CNG_COM));
+ move16();
+
+
+ *hFdCngCom = hs;
+ move16();
+ return;
+}
+
+void initFdCngCom(HANDLE_FD_CNG_COM hs, Word16 scale)
+{
+ /* Calculate CLDFB scaling factor */
+ /* shl(i_mult2(scale, scale), 3) does not fit in 16 bit */
+ /*hs->scalingFactor = div_s(1, shl(i_mult2(scale, scale), 3));*/
+ assert(2048/*1.0/(1<<4) Q15*/ < mult(scale, scale));
+ /* Exponent invScalingFactor: -16 = -(2*7 (scale) + 2 (8.0) */
+ hs->invScalingFactor = shl(mult(scale,scale),1);
+ /* Exponent scalingFactor: -15 = -(2*7 (scale) + 2 (8.0) - 1 (1.0)) */
+ hs->scalingFactor = div_s(0x4000,hs->invScalingFactor);
+
+ /* Initialize the overlap-add */
+ set16_fx( hs->timeDomainBuffer, 0, L_FRAME16k );
+ hs->olapBufferAna = NULL;
+ move16();
+ set16_fx( hs->olapBufferSynth, 0, FFTLEN );
+ hs->olapBufferSynth2 = NULL;
+ move16();
+
+ /* Initialize the comfort noise generation */
+ set32_fx( hs->fftBuffer, 0, FFTLEN );
+ set32_fx( hs->cngNoiseLevel, 0, FFTCLDFBLEN );
+
+ /* Initialize quantizer */
+ set32_fx( hs->sidNoiseEst, 0, NPART );
+ set16_fx( hs->A_cng, 0, M+1 );
+ hs->A_cng[0] = 4096/*1.f Q12*/; /* 3Q12 */ move16();
+
+ /* Set some counters and flags */
+ hs->inactive_frame_counter = 0; /* Either SID or zero frames */ move16();
+ hs->active_frame_counter = 0;
+ move16();
+ hs->frame_type_previous = ACTIVE_FRAME;
+ move16();
+ hs->flag_noisy_speech = 0;
+ move16();
+ hs->likelihood_noisy_speech = 0;
+ move16();
+ hs->numCoreBands = 0;
+ move16();
+ hs->stopBand = 0;
+ move16();
+ hs->startBand = 0;
+ move16();
+ hs->stopFFTbin = 0;
+ move16();
+ hs->frameSize = 0;
+ move16();
+ hs->fftlen = 0;
+ move16();
+
+ /* Initialize noise estimation algorithm */
+ set32_fx( hs->periodog, 0, PERIODOGLEN );
+ mhvals(MSNUMSUBFR*MSSUBFRLEN, &(hs->msM_win));
+ mhvals(MSSUBFRLEN, &(hs->msM_subwin));
+ set32_fx( hs->msPeriodogSum, 0, 2 );
+ hs->msPeriodogSum_exp[0] = 0;
+ move16();
+ hs->msPeriodogSum_exp[1] = 0;
+ move16();
+ set32_fx( hs->msPsdSum, 0, 2 );
+ set16_fx( hs->msSlope, 0, 2 );
+ set32_fx( hs->msQeqInvAv, 0, 2 );
+ hs->msQeqInvAv_exp[0] = 0;
+ move16();
+ hs->msQeqInvAv_exp[1] = 0;
+ move16();
+ hs->msFrCnt_init_counter = 0;
+ move16();
+ hs->msFrCnt_init_thresh = 1;
+ move16();
+ hs->init_old = 0;
+ move16();
+ hs->offsetflag = 0;
+ move16();
+ hs->msFrCnt = MSSUBFRLEN;
+ move16();
+ hs->msMinBufferPtr = 0;
+ move16();
+ hs->msAlphaCor[0] = 644245120l/*0.3f Q31*/;
+ move16();
+ hs->msAlphaCor[1] = 644245120l/*0.3f Q31*/;
+ move16();
+
+ /* Initialize exponents */
+ hs->exp_cldfb_periodog = 0;
+ move16();
+
+ return;
+}
+
+/*****************************************
+* Delete an instance of type FD_CNG_COM *
+*****************************************/
+void deleteFdCngCom(HANDLE_FD_CNG_COM * hFdCngCom) /* i/o: Contains the variables related to the CLDFB-based CNG process */
+{
+ HANDLE_FD_CNG_COM hsCom;
+ hsCom = *hFdCngCom;
+ move16();
+ IF (hsCom != NULL)
+ {
+ free(hsCom);
+ *hFdCngCom = NULL;
+ move16();
+ }
+}
+
+/***************************************
+* Initialize the spectral partitioning *
+****************************************/
+void initPartitions( const Word16* part_in,
+ Word16 npart_in,
+ Word16 startBand,
+ Word16 stopBand,
+ Word16* part_out,
+ Word16* npart_out,
+ Word16* midband,
+ Word16* psize,
+ Word16* psize_norm,
+ Word16* psize_norm_exp,
+ Word16* psize_inv,
+ Word16 stopBandFR
+ )
+{
+ Word16 i, j, len_out, tmp16;
+
+
+ IF (part_in != NULL)
+ {
+ len_out = 0;
+ move16();
+ IF (GT_16(stopBandFR, startBand))
+ {
+ len_out = sub(stopBandFR, startBand);
+ FOR(i = 0 ; i < len_out; i++)
+ {
+ part_out[i] = i;
+ move16();
+ }
+ }
+ FOR(j=0 ; j < npart_in; j++)
+ {
+ IF (GE_16(part_in[j], stopBand))
+ {
+ BREAK;
+ }
+ tmp16 = sub(part_in[j],startBand);
+ test();
+ if (GE_16(part_in[j],stopBandFR)&&tmp16>=0)
+ {
+ part_out[len_out++] = tmp16;
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ len_out = sub(stopBand, startBand);
+ FOR (i = 0 ; i < len_out; i++)
+ {
+ part_out[i] = i;
+ move16();
+ }
+ }
+
+ *npart_out = len_out;
+ move16();
+ getmidbands(part_out, len_out, midband, psize, psize_norm, psize_norm_exp, psize_inv);
+
+}
+
+#define CNG_HS 4 /* 4 bit headroom for dot product */
+#define CNG_S 6 /* 1 sign bit, 6 bit integer part, 9 bit frational part for input and output data */
+
+
+
+
+/********************************************************
+* Apply some dynamic range compression based on the log *
+********************************************************/
+void compress_range(
+ Word32 *in,
+ Word16 in_exp,
+ Word16 *out,
+ Word16 len
+)
+{
+ Word16 i;
+ Word32 in_s;
+ Word32 one_s;
+ Word32 in_exp32;
+ Word32 L_tmp;
+
+
+ /* out = log2( 1 + in ) */
+ IF ( in_exp >= 0 )
+ {
+ one_s = L_shr(1073741824l/*0.5 Q31*/,in_exp);
+ in_exp32 = L_shl(L_deposit_l(add(in_exp,1)),WORD32_BITS-1-LD_DATA_SCALE);
+ FOR (i=0; i < len; i++)
+ {
+ in_s = L_add(L_shr(in[i],1),one_s);
+ L_tmp = L_add(BASOP_Util_Log2(in_s),in_exp32);
+ if (in_s == 0)
+ {
+ out[i] = 0;
+ move16();
+ }
+ if (in_s != 0)
+ {
+ out[i] = extract_h(L_tmp);
+ }
+ if(out[i] == 0)
+ {
+ out[i] = 1;
+ }
+ }
+ }
+ ELSE
+ {
+ in_exp = sub(in_exp,1);
+ in_exp32 = L_shl(L_deposit_l(1),WORD32_BITS-1-LD_DATA_SCALE);
+ FOR (i=0; i < len; i++)
+ {
+ L_tmp = L_add(BASOP_Util_Log2(L_add(L_shl(in[i],in_exp),1073741824l/*0.5 Q31*/)),in_exp32);
+ if (in[i] == 0)
+ {
+ out[i] = 0;
+ move16();
+ }
+ if (in[i] != 0)
+ {
+ out[i] = extract_h(L_tmp);
+ }
+ if (out[i] == 0)
+ {
+ out[i] = 1;
+ }
+ }
+ }
+
+}
+
+/*************************************************************
+* Apply some dynamic range expansion to undo the compression *
+*************************************************************/
+void expand_range(
+ Word16 *in,
+ Word32 *out,
+ Word16 *out_exp,
+ Word16 len
+)
+{
+ Word16 i;
+ Word16 s;
+ Word16 tmp;
+ Word32 one_s, tmp32;
+ Word16 maxVal;
+ Word16 maxVal2;
+
+
+ maxVal = 0;
+ move16();
+ FOR (i=0; i < len; i++)
+ {
+ maxVal = s_max(maxVal,in[i]);
+ }
+
+ maxVal2 = maxVal;
+ move16();
+ s = 0;
+ move16();
+ WHILE ( maxVal >= 0 )
+ {
+ maxVal = sub(maxVal,512/*0.015625 Q15*/);
+ s = add(s,1);
+ }
+ tmp = sub(maxVal2,maxVal);
+
+ one_s = L_shr(1073741824l/*0.5 Q31*/,sub(s,1));
+ tmp32 = L_shr(726941l/*0.0003385080526823181 Q31*/,s);
+ /* out = (2^(in) - 1) */
+ FOR (i=0; i < len; i++)
+ {
+ out[i] = L_sub(BASOP_Util_InvLog2(L_deposit_h(sub(in[i],tmp))),one_s);
+ move32();
+ if ( out[i] == 0 )
+ {
+ out[i] = tmp32;
+ move32();
+ }
+ }
+ *out_exp = s;
+ move16();
+
+}
+
+/*************************************************
+* Noise estimation using Minimum Statistics (MS) *
+*************************************************/
+void minimum_statistics (
+ Word16 len, /* i : Total number of partitions (CLDFB or FFT) */
+ Word16 lenFFT, /* i : Number of FFT partitions */
+ Word16 *psize, /* i : Partition sizes, fractional */
+ Word16 *msPeriodog, /* i : Periodogram (energies) */
+ Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */
+ Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */
+ Word32 *msAlpha, /* i/o: Forgetting factors */
+ Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */
+ Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */
+ Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */
+ Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */
+ Word32 *msBminWin, /* o : Bias correction factors */
+ Word32 *msBminSubWin, /* o : Bias correction factors */
+ Word32 *msCurrentMin, /* i/o: Local minima (energies) */
+ Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */
+ Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */
+ Word16 *msLocalMinFlag, /* i : Binary flag */
+ Word16 *msNewMinFlag, /* i : Binary flag */
+ Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */
+ Word16 *msPeriodogBufPtr, /* i/o: Counter */
+ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */
+)
+{
+ Word16 i,j,k,s,s1,s2,s3;
+ Word16 len2;
+ Word16 current_len;
+ Word16 start, stop, cnt;
+ Word16 totsize;
+ Word16 inv_totsize;
+
+ Word32 tmp, tmp0, tmp1;
+ Word32 scalar, scalar2, scalar3;
+ Word32 snr;
+ Word32 msAlphaHatMin2;
+ Word32 BminCorr;
+ Word32 QeqInvAv;
+ Word32 *ptr;
+ Word32 *msPsdSum;
+ Word32 *msPeriodogSum;
+
+ Word16 tmp16, tmp16_1;
+ Word16 beta;
+ Word16 slope;
+ Word16 QeqInv;
+ Word16 scalar16;
+ Word16 scalar216;
+ Word16 scalar316;
+ Word16 msM_win;
+ Word16 msM_subwin;
+ Word16 msAlphaCorAlpha;
+ Word16 msAlphaCorAlpha2;
+ Word16 msPeriodogSum16;
+ Word16 msNoiseFloor16;
+
+
+ len2 = i_mult(MSNUMSUBFR,len);
+
+ msM_win = st->msM_win;
+ move16();
+ msM_subwin = st->msM_subwin;
+ move16();
+
+ msAlphaCorAlpha = MSALPHACORALPHA;
+ move16();
+ msAlphaCorAlpha2 = MSALPHACORALPHA2;
+ move16();
+
+ msPsdSum = st->msPsdSum;
+ msPeriodogSum = st->msPeriodogSum;
+
+ /* No minimum statistics at initialization */
+ IF ( LT_16(st->msFrCnt_init_counter,st->msFrCnt_init_thresh))
+ {
+ Copy(msPeriodog, msPsd, len); /* 6Q9 */
+ Copy(msPeriodog, msNoiseFloor, len); /* 6Q9 */
+ Copy(msPeriodog, msNoiseEst, len); /* 6Q9 */
+ Copy(msPeriodog, msPsdFirstMoment, len); /* 6Q9 */
+
+ set32_fx(msPsdSecondMoment, 0l/*0.0 Q31*/, len);
+ msPeriodogSum[0] = dotp_s_fx(msPeriodog, psize, lenFFT, CNG_HS);
+ move32();
+ msPsdSum[0] = msPeriodogSum[0]; /* 16Q15 */ move32();
+
+ IF ( LT_16(lenFFT,len))
+ {
+ msPeriodogSum[1] = dotp_s_fx(msPeriodog+lenFFT, psize+lenFFT, sub(len,lenFFT), CNG_HS);
+ move32();
+ msPsdSum[1] = msPeriodogSum[1]; /* 16Q15 */ move32();
+ }
+
+ /* Increment frame counter at initialization */
+ /* Some frames are sometimes zero at initialization => ignore them */
+ IF ( LT_16(msPeriodog[0],st->init_old))
+ {
+ set32_fx(msCurrentMinOut, 2147483647l/*1.0 Q31*/, len); /* 16Q15 */
+ set32_fx(msCurrentMin, 2147483647l/*1.0 Q31*/, len); /* 16Q15 */
+ set32_fx(msMinBuf, 2147483647l/*1.0 Q31*/, len2); /* 16Q15 */
+ set32_fx(msCurrentMinSubWindow, 2147483647l/*1.0 Q31*/, len); /* 16Q15 */
+
+ st->msFrCnt_init_counter = add(st->msFrCnt_init_counter,1);
+ move16();
+ }
+ st->init_old = msPeriodog[0]; /* 6Q9 */ move16();
+ }
+ ELSE
+ {
+ /* Consider the FFT and CLDFB bands separately
+ - first iteration for FFT bins,
+ - second one for CLDFB bands in SWB mode */
+ cnt = 0;
+ move16();
+ start = 0;
+ move16();
+ stop = lenFFT;
+ move16();
+ totsize = sub(st->stopFFTbin,st->startBand);
+ WHILE ( GT_16(stop,start))
+ {
+ current_len = sub(stop,start);
+
+ /* Compute smoothed correction factor for PSD smoothing */
+
+ /* msPeriodogSum[cnt] with format 16Q15 */
+ msPeriodogSum[cnt] = dotp_s_fx(msPeriodog+start, psize+start, current_len, CNG_HS);
+ move32();
+
+ IF ( msPeriodogSum[cnt] == 0 )
+ {
+ st->msAlphaCor[cnt] = Mpy_32_16_1(st->msAlphaCor[cnt], msAlphaCorAlpha);
+ move32();
+ }
+ ELSE
+ {
+ /* calculate scalar with normalized msPeriodogSum[cnt], exponent -2*s1 */
+ s1 = norm_l(msPeriodogSum[cnt]);
+ msPeriodogSum16 = round_fx(L_shl(msPeriodogSum[cnt],s1));
+ scalar = L_mult(msPeriodogSum16, msPeriodogSum16);
+
+ /* calculate difference, both elements in 16Q15 format, use absolute value
+ to avoid -1.0 x -1.0 multiplications later */
+ scalar2 = L_abs(L_sub(msPsdSum[cnt], msPeriodogSum[cnt]));
+
+ s2 = WORD32_BITS-1;
+ move16();
+ if ( scalar2 != 0 )
+ {
+ /* use absolute value to avoid -1.0 x -1.0 multiplications */
+ s2 = norm_l(scalar2);
+ }
+ scalar216 = round_fx(L_shl(scalar2,s2));
+ scalar2 = L_mult(scalar216, scalar216);
+
+ /* find common exponent */
+ tmp16_1 = sub(s1,s2);
+ tmp16 = s_min(shl(abs_s(tmp16_1),1),WORD32_BITS-1);
+ if ( tmp16_1 < 0 )
+ {
+ scalar2 = L_shr(scalar2,tmp16);
+ }
+ if(tmp16_1 > 0)
+ {
+ scalar = L_shr(scalar,tmp16);
+ }
+
+
+ /* add scalar and scalar2, avoid overflows */
+ scalar = L_shr(scalar,1);
+ scalar2 = L_shr(scalar2,1);
+ scalar3 = L_add(scalar,scalar2);
+
+ /* calculate division */
+ scalar16 = BASOP_Util_Divide3232_uu_1616_Scale(scalar, scalar3, &s3);
+ s3 = s_max(s3,-(WORD16_BITS-1));
+ scalar16 = shl(scalar16,s3);
+ scalar16 = s_max(scalar16, MSALPHACORMAX);
+
+ st->msAlphaCor[cnt] = L_add(Mpy_32_16_1(st->msAlphaCor[cnt], msAlphaCorAlpha),
+ L_mult(scalar16, msAlphaCorAlpha2));
+ move32();
+ }
+
+ /* Compute SNR */
+
+ /* msPeriodogSum[cnt] with format 16Q15 */
+ snr = dotp_s_fx(msNoiseFloor+start, psize+start, current_len, CNG_HS);
+
+ IF ( GT_32(L_shr(Mpy_32_16_1(msPsdSum[cnt],18431/*0.56246299817 Q15*/),13),snr))
+ {
+ tmp0 = BASOP_Util_Log2(msPsdSum[cnt]);
+ tmp1 = BASOP_Util_Log2(snr);
+ tmp1 = L_sub(tmp0, tmp1);
+ tmp1 = Mpy_32_16_1(tmp1, MSSNREXP);
+ msAlphaHatMin2 = BASOP_Util_InvLog2(tmp1);
+ }
+ ELSE
+ {
+ msAlphaHatMin2 = MSALPHAHATMIN;
+ move32();
+ }
+ scalar = Mpy_32_16_1(st->msAlphaCor[cnt], MSALPHAMAX);
+
+ FOR (j=start; j 0)
+ {
+ scalar2 = L_shr(scalar2,tmp16);
+ }
+
+ /* add scalar2 and scalar3, avoid overflows */
+ scalar2 = L_shr(scalar2,1);
+ scalar3 = L_shr(scalar3,1);
+ scalar3 = L_add(scalar2,scalar3);
+
+ /* calculate division */
+ tmp16 = BASOP_Util_Divide3232_uu_1616_Scale(scalar2, scalar3, &s3);
+ scalar2 = Mpy_32_16_1(scalar, tmp16);
+ s3 = s_max(s3,-(WORD32_BITS-1));
+ scalar2 = L_shl(scalar2,s3);
+ msAlpha[j] = L_max(scalar2, msAlphaHatMin2);
+ move32();
+ }
+
+ /* Compute the PSD (smoothed periodogram) in each band */
+ msPsd[j] = round_fx(L_add(Mpy_32_16_1(msAlpha[j], msPsd[j]),
+ Mpy_32_16_1(L_sub(2147483647l/*1.0 Q31*/,msAlpha[j]), msPeriodog[j])));
+ }
+ msPsdSum[cnt] = dotp_s_fx(msPsd+start, psize+start, current_len, CNG_HS);
+ move32();
+
+ QeqInvAv = 0l/*0.0 Q31*/;
+ move32();
+
+ /* scalar: 7Q24 format */
+ tmp = 1191182336l/*(float)(MSNUMSUBFR*MSSUBFRLEN)-1.0 Q24*/;
+ move32();
+ scalar = L_sub(tmp, L_mult(round_fx(tmp), msM_win));
+
+ /* scalar2: 4Q27 format */
+ tmp = 1476395008l/*(float)MSSUBFRLEN-1.0 Q27*/;
+ move32();
+ scalar2 = L_sub(tmp, L_mult(round_fx(tmp), msM_subwin));
+
+ FOR (j=start; jmsQeqInvAv[cnt] = QeqInvAv;
+ move32();
+
+ /* New minimum? */
+
+ /* exponent QeqInvAv: CNG_S, exponent MSAV: (4>>1) */
+ s = CNG_S+2*MSAV_EXP;
+ move16();
+ BminCorr = Mpy_32_16_1(Sqrt32(QeqInvAv, &s), MSAV);
+ BminCorr = L_shl(BminCorr,sub(s,1));
+
+ /* exponent BminCorr: 1 */
+ BminCorr = L_add(BminCorr, 1073741824l/*0.5 Q31*/);
+
+ FOR (j=start; jmsFrCnt,MSSUBFRLEN))
+ {
+ FOR ( i = 0; i < 3; i++ )
+ {
+ IF ( LT_32(st->msQeqInvAv[cnt],L_shr(L_deposit_h(msQeqInvAv_thresh[i]),CNG_S))/*0.0 Q31*/)
+ {
+ BREAK;
+ }
+ }
+ /* format 1Q30 */
+ st->msSlope[cnt] = msNoiseSlopeMax[i];
+ move32();
+ }
+
+ /* Consider the FFT and CLDFB bands separately */
+ start = stop;
+ move16();
+ stop = len;
+ move16();
+ totsize = sub(st->stopBand,st->stopFFTbin);
+ cnt = add(cnt,1);
+ } /*while (stop > start)*/
+
+ /* Update minimum between sub windows */
+ test();
+ IF ( GT_16(st->msFrCnt,1)&<_16(st->msFrCnt,MSSUBFRLEN))
+ {
+ FOR (j=0; j 0 )
+ {
+ msLocalMinFlag[j] = 1;
+ move16();
+ }
+ if ( LT_32(msCurrentMinSubWindow[j],msCurrentMinOut[j])/*0.0 Q31*/)
+ {
+ /* msCurrentMinOut[j] scaled with CNG_S */
+ msCurrentMinOut[j] = msCurrentMinSubWindow[j];
+ move32();
+ }
+ }
+ /* Get the current noise floor */
+ Copy_Scale_sig_32_16(msCurrentMinOut, msNoiseFloor, len, -16);
+ }
+ ELSE /* sub window complete */
+ {
+ IF ( GE_16(st->msFrCnt,MSSUBFRLEN))
+ {
+ /* Collect buffers */
+ Copy32(msCurrentMinSubWindow, msMinBuf+len*st->msMinBufferPtr, len);
+
+ /* Compute minimum among all buffers */
+ Copy32(msMinBuf, msCurrentMinOut, len);
+ ptr = msMinBuf + len;
+ FOR (i=1; imsSlope[0];
+ move16();
+ FOR (j=0; jmsSlope[1];
+ move16();
+ }
+ test();
+ test();
+ test();
+ IF ( ( msLocalMinFlag[j] != 0 )
+ && ( msNewMinFlag[j] == 0 )
+ && ( LT_32(L_shr(msCurrentMinSubWindow[j],1),Mpy_32_16_1(msCurrentMinOut[j],slope)) /*0.0 Q31*/ )
+ && ( GT_32(msCurrentMinSubWindow[j],msCurrentMinOut[j]) /*0.0 Q31*/ )
+ )
+ {
+ msCurrentMinOut[j] = msCurrentMinSubWindow[j];
+ move32();
+ i = j;
+ move16();
+ FOR (k=0; koffsetflag > 0 )
+ {
+ Copy(msPeriodog, msPsd, len);
+ FOR (j=0; j < len; j++)
+ {
+ msCurrentMinOut[j] = L_deposit_h(msPeriodog[j]);
+ }
+ set32_fx(st->msAlphaCor, 2147483647l/*1.0 Q31*/, cnt);
+ set32_fx(msAlpha, 0l/*0.0 Q31*/, len);
+ Copy(msPeriodog, msPsdFirstMoment, len);
+ set32_fx(msPsdSecondMoment, 0l/*0.0 Q31*/, len);
+
+ msPsdSum[0] = dotp_s_fx(msPeriodog, psize, lenFFT, CNG_HS);
+ move32();
+ IF ( LT_16(lenFFT,len))
+ {
+ msPsdSum[1] = dotp_s_fx(msPeriodog+lenFFT, psize+lenFFT, sub(len,lenFFT), CNG_HS);
+ move32();
+ }
+ }
+ st->offsetflag = 1;
+ move16();
+ }
+ ELSE
+ {
+ st->offsetflag = 0;
+ move16();
+ }
+
+
+ /* Increment frame counter */
+ IF ( EQ_16(st->msFrCnt,MSSUBFRLEN))
+ {
+ st->msFrCnt = 1;
+ move16();
+ st->msMinBufferPtr = add(st->msMinBufferPtr,1);
+ move16();
+ if ( EQ_16(st->msMinBufferPtr,MSNUMSUBFR))
+ {
+ st->msMinBufferPtr = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ st->msFrCnt = add(st->msFrCnt,1);
+ }
+
+ /* Smooth noise estimate during CNG phases */
+ FOR (j=0; j= 0/*0.0 Q15*/);
+ }
+
+}
+
+
+/***********************************
+* Apply bitrate-dependant scale *
+***********************************/
+void apply_scale(Word32 *scale, Word16 bwmode, Word32 bitrate)
+{
+ Word16 i;
+ Word16 scaleTableSize = sizeof (scaleTable) / sizeof (scaleTable[0]);
+
+
+
+ FOR (i=0; i < scaleTableSize; i++)
+ {
+ cast16();
+ IF ( s_and( (Word16)EQ_16(bwmode, (Word16)scaleTable[i].bwmode),
+ s_and( L_sub(bitrate,scaleTable[i].bitrateFrom) >= 0,
+ L_sub(bitrate,scaleTable[i].bitrateTo) < 0))
+ )
+ {
+ BREAK;
+ }
+ }
+
+ {
+ *scale = L_add(*scale, L_deposit_h(scaleTable[i].scale));
+ }
+
+}
+
+
+/***************************************
+* Compute the power for each partition *
+***************************************/
+void bandcombinepow(Word32* bandpow, /* i : Power for each band */
+ Word16 exp_bandpow, /* i : exponent of bandpow */
+ Word16 nband, /* i : Number of bands */
+ Word16* part, /* i : Partition upper boundaries (band indices starting from 0) */
+ Word16 npart, /* i : Number of partitions */
+ Word16* psize_inv, /* i : Inverse partition sizes */
+ Word32* partpow, /* o : Power for each partition */
+ Word16* exp_partpow)
+{
+
+ Word16 i, p;
+ Word32 temp;
+ Word16 smin, len, prev_part;
+ Word16 facTabExp[NPART_SHAPING];
+
+
+
+ IF (EQ_16(nband, npart))
+ {
+ Copy32(bandpow, partpow, nband);
+ smin = 0;
+ move16();
+ }
+ ELSE
+ {
+ /* Compute the power in each partition */
+ prev_part = -1;
+ move16();
+ FOR (p=0; p < npart; p++)
+ {
+ len = sub(part[p],prev_part);
+ facTabExp[p] = getScaleFactor32 (&bandpow[prev_part+1], len);
+ move16();
+ prev_part = part[p];
+ move16();
+ }
+
+ smin = WORD32_BITS-1;
+ move16();
+ FOR (p=0; p < npart; p++)
+ {
+ smin = s_min(smin,facTabExp[p]);
+ }
+
+ i = 0;
+ move16();
+ FOR (p = 0; p < npart; p++)
+ {
+ /* Arithmetic averaging of power for all bins in partition */
+ temp = 0;
+ move32();
+ FOR ( ; i <= part[p]; i++)
+ {
+ temp = L_add(temp, Mpy_32_16_1(L_shl(bandpow[i],facTabExp[p]),psize_inv[p]));
+ }
+ partpow[p] = L_shr(temp,sub(facTabExp[p],smin));
+ move32();
+ }
+
+ }
+
+ *exp_partpow = sub(exp_bandpow,smin);
+ move16();
+}
+
+
+/************************************
+* Scale partitions (with smoothing) *
+************************************/
+void scalebands (Word32 *partpow, /* i : Power for each partition */
+ Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */
+ Word16 npart, /* i : Number of partitions */
+ Word16 *midband, /* i : Central band of each partition */
+ Word16 nFFTpart, /* i : Number of FFT partitions */
+ Word16 nband, /* i : Number of bands */
+ Word32 *bandpow, /* o : Power for each band */
+ Word16 flag_fft_en
+ )
+{
+ Word16 i, j, s, s1, nint, delta, delta_cmp, delta_s;
+ Word16 startBand, startPart, stopPart, stopPartM1;
+ Word32 tmp, val, partpowLD64, partpowLD64M1;
+
+
+
+ j = 0;
+ move16();
+ delta = 0;
+ move16();
+ partpowLD64M1 = 0L; /* to avoid compilation warnings */
+
+ /* Interpolate the bin/band-wise levels from the partition levels */
+ IF ( EQ_16(nband, npart))
+ {
+ Copy32(partpow, bandpow, npart);
+ }
+ ELSE
+ {
+ startBand = 0;
+ move16();
+ startPart = 0;
+ move16();
+ stopPart = nFFTpart;
+ move16();
+
+ WHILE ( LT_16(startBand,nband))
+ {
+ stopPartM1 = sub(stopPart, 1);
+ test();
+ IF ( (flag_fft_en != 0) || (GE_16(startPart,nFFTpart)))
+ {
+ /* first half partition */
+ j = startPart;
+ move16();
+
+ FOR (i=startBand; i <= midband[j]; i++)
+ {
+ bandpow[i] = partpow[j];
+ move32();
+ }
+ j = add(j, 1);
+
+ /* inner partitions */
+ IF (j < stopPart)
+ {
+ partpowLD64M1 = BASOP_Util_Log2(partpow[j-1]);
+ }
+
+ /* Debug values to check this variable is set. */
+ delta = 0x4000;
+ move16();
+ delta_cmp = 0x4000;
+ move16();
+ s1 = 1;
+ move16();
+ s = 1;
+ move16();
+
+ FOR ( ; j < stopPart; j++)
+ {
+ nint = sub(midband[j], midband[j-1]);
+
+ /* log-linear interpolation */
+ partpowLD64 = BASOP_Util_Log2(partpow[j]);
+ tmp = L_sub(partpowLD64, partpowLD64M1);
+ tmp = Mpy_32_16_1(tmp, getNormReciprocalWord16(nint));
+
+ /* scale logarithmic value */
+ tmp = L_sub(tmp, DELTA_SHIFT_LD64);
+ delta_s = DELTA_SHIFT;
+ move16();
+
+ WHILE (tmp > 0)
+ {
+ tmp = L_sub(tmp,33554432l/*0.015625 Q31*/);
+ delta_s = add(delta_s,1);
+ }
+ delta_cmp = shl(1, s_max(-15, sub(WORD16_BITS-1,delta_s)));
+
+ tmp = BASOP_Util_InvLog2(tmp);
+ s = norm_l(tmp);
+ s1 = sub(delta_s, s);
+
+ delta = round_fx(L_shl(tmp, s));
+
+ /* Choose scale such that the interpolation start and end point both are representable and add 1 additional bit hr. */
+ delta_s = sub(s_min(norm_l(partpow[j-1]), norm_l(partpow[j])), 1);
+ val = L_shl(partpow[j-1], delta_s);
+ FOR ( ; i < midband[j]; i++)
+ {
+ val = L_shl(Mpy_32_16_1(val, delta), s1);
+ bandpow[i] = L_shr(val, delta_s);
+ move32();
+ }
+ bandpow[i++] = partpow[j];
+ move32();
+ partpowLD64M1 = partpowLD64;
+ move32();
+ }
+
+ IF ( GT_16(shr(delta, s), delta_cmp))
+ {
+ delta = 0x4000;
+ move16();
+ s1 = 1;
+ move16();
+ }
+
+ /* last half partition */
+ val = partpow[stopPartM1];
+ move32();
+ FOR ( ; i <= part[stopPartM1]; i++)
+ {
+ val = L_shl(Mpy_32_16_1(val,delta), s1);
+ bandpow[i] = val;
+ move32();
+ }
+
+ }
+ startBand = add(part[stopPartM1], 1);
+ startPart = stopPart;
+ move16();
+ stopPart = npart;
+ move16();
+ }
+ }
+
+}
+
+
+/**************************************
+* Get central band for each partition *
+**************************************/
+void getmidbands(Word16* part, /* i : Partition upper boundaries (band indices starting from 0) */
+ Word16 npart, /* i : Number of partitions */
+ Word16* midband, /* o : Central band of each partition */
+ Word16* psize, /* o : Partition sizes */
+ Word16* psize_norm, /* o : Partition sizes, fractional values */
+ Word16* psize_norm_exp, /* o : Exponent for fractional partition sizes */
+ Word16* psize_inv) /* o : Inverse of partition sizes */
+{
+ Word16 j, max_psize, shift;
+
+
+ max_psize = psize[0];
+ move16();
+ /* first half partition */ move16();
+ midband[0] = part[0];
+ psize[0] = add(part[0], 1);
+ move16();
+ psize_inv[0] = getNormReciprocalWord16(psize[0]);
+ move16();
+ /* inner partitions */
+ FOR (j = 1; j < npart; j++)
+ {
+ midband[j] = shr(add(add(part[j-1], 1), part[j]), 1);
+ move16();
+ psize[j] = sub(part[j], part[j-1]);
+ move16();
+ psize_inv[j] = getNormReciprocalWord16(psize[j]);
+ move16();
+ if(GT_16(psize[j], max_psize))
+ {
+ max_psize = psize[j];
+ move16();
+ }
+ }
+
+ shift = 9;
+ move16();
+ *psize_norm_exp = sub(15, shift);
+ move16();
+ FOR(j=0; j < npart; j++)
+ {
+ psize_norm[j] = shl(psize[j], shift);
+ move16();
+ }
+ /* minimum_statistics needs fixed exponent of 6 */
+ assert(norm_s(-max_psize) >= 9 );
+}
+
+
+/*
+ AnalysisSTFT
+
+ Parameters:
+
+ timeDomainInput, i : pointer to time signal
+ fftBuffer, o : FFT bins
+ fftBufferExp, i : exponent of FFT bins
+ st i/o: FD_CNG structure containing all buffers and variables
+
+ Function:
+ STFT analysis filterbank
+
+ Returns:
+ void
+*/
+void AnalysisSTFT (const Word16 *timeDomainInput, /* i : pointer to time signal */
+ Word16 Q,
+ Word32 *fftBuffer, /* o : FFT bins */
+ Word16 *fftBuffer_exp, /* i : exponent of FFT bins */
+ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
+ )
+{
+ Word16 i, len;
+ Word16 len2;
+ const PWord16 *olapWin;
+ Word16 *olapBuffer;
+
+
+
+ assert( (st->fftlen>>1) == st->frameSize);
+
+ /* pointer inititialization */
+ assert(st->olapBufferAna != NULL);
+ olapBuffer = st->olapBufferAna;
+ olapWin = st->olapWinAna;
+
+ /* olapWin factor is scaled with one bit */
+ *fftBuffer_exp = 1;
+ move16();
+ len = sub(st->fftlen,st->frameSize);
+ assert(len <= 320); /* see size of olapBuffer */
+
+ /* Window the signal */
+ len2 = shr(len,1);
+ FOR (i=0; i < len2; i++)
+ {
+ move32();
+ move32();
+ fftBuffer[i] = L_mult(olapBuffer[i], mult_r(olapWin[i].v.im, 23170/*1.4142135623730950488016887242097 Q14*/));
+ fftBuffer[i+len2] = L_mult(olapBuffer[i+len2], mult_r(olapWin[len2-1-i].v.re, 23170/*1.4142135623730950488016887242097 Q14*/));
+ }
+ len2 = shr(st->frameSize,1);
+ FOR (i=0; i fftlen, fftBuffer_exp, -1);
+
+ FOR (i=0; i frameSize,len)+i], Q );
+ move16();
+ }
+
+}
+
+
+/*
+ SynthesisSTFT
+
+ Parameters:
+
+ fftBuffer i : pointer to FFT bins
+ fftBufferExp i : exponent of FFT bins
+ timeDomainOutput o : pointer to time domain signal
+ timeDomainOutputExp o : pointer to exponent of time domain output
+ olapBuffer i/o : pointer to overlap buffer
+ olapWin i : pointer to overlap window
+ st i/o : pointer to FD_CNG structure containing all buffers and variables
+
+ Function:
+ STFT synthesis filterbank
+
+ Returns:
+ void
+*/
+void
+SynthesisSTFT (Word32 *fftBuffer, /* i : pointer to FFT bins */
+ Word16 fftBufferExp, /* i : exponent of FFT bins */
+ Word16 *timeDomainOutput, /* o : pointer to time domain signal */
+ Word16 *olapBuffer, /* i/o : pointer to overlap buffer */
+ const PWord16 *olapWin, /* i : pointer to overlap window */
+ Word16 tcx_transition,
+ HANDLE_FD_CNG_COM st, /* i/o : pointer to FD_CNG structure containing all buffers and variables */
+ Word16 gen_exc,
+ Word16 *Q_new
+ )
+{
+ Word16 i, len, scale, tmp;
+ Word16 len2, len3, len4;
+ Word16 buf[M+1+L_FRAME16k];
+
+
+ /* Perform IFFT */
+ scale = 0;
+ BASOP_rfft(fftBuffer, st->fftlen, &scale, 1);
+ fftBufferExp = add(fftBufferExp, scale);
+ fftBufferExp = add(fftBufferExp, st->fftlenShift);
+
+ /* Perform overlap-add */
+ Copy(olapBuffer+st->frameSize, olapBuffer, st->frameSize);
+ set16_fx(olapBuffer+st->frameSize, 0, st->frameSize);
+
+ len2 = shr(st->fftlen,2);
+ len4 = shr(st->fftlen,3);
+ len3 = add(len2,len4);
+ len = add(st->frameSize,len4);
+ IF ( tcx_transition )
+ {
+ FOR (i=0; i < len; i++)
+ {
+ olapBuffer[i] = round_fx(L_shl(fftBuffer[i],fftBufferExp-15));
+ }
+ }
+ ELSE
+ {
+ FOR (i=0; i < len4; i++)
+ {
+ olapBuffer[i+1*len4] = add(olapBuffer[i+1*len4], mult_r(round_fx(L_shl(fftBuffer[i+1*len4],fftBufferExp-15)),olapWin[i].v.im));
+ move16();
+ olapBuffer[i+2*len4] = add(olapBuffer[i+2*len4], mult_r(round_fx(L_shl(fftBuffer[i+2*len4],fftBufferExp-15)),olapWin[len4-1-i].v.re));
+ move16();
+ }
+ FOR (i=len3; i < len; i++)
+ {
+ olapBuffer[i] = round_fx(L_shl(fftBuffer[i],fftBufferExp-15));
+ }
+ }
+
+ FOR (i=0; i < len4; i++)
+ {
+ olapBuffer[i+5*len4] = mult_r(round_fx(L_shl(fftBuffer[i+5*len4],fftBufferExp-15)),olapWin[i].v.re);
+ move16();
+ olapBuffer[i+6*len4] = mult_r(round_fx(L_shl(fftBuffer[i+6*len4],fftBufferExp-15)),olapWin[len4-1-i].v.im);
+ move16();
+ }
+
+ len = add( len, len2 );
+ FOR (i=len; i < st->fftlen ; i++)
+ {
+ olapBuffer[i] = 0;
+ move16();
+ }
+
+ /* Get time-domain signal */
+ FOR (i=0; i < st->frameSize; i++)
+ {
+ timeDomainOutput[i] = mult_r( olapBuffer[i+len4], st->fftlenFac );
+ move16();
+ }
+
+ /* Generate excitation */
+ IF ( EQ_16( gen_exc, 1 ))
+ {
+ FOR (i=0; i < M+1+st->frameSize; i++)
+ {
+ buf[i] = mult_r( olapBuffer[i+len4-M-1], st->fftlenFac );
+ move16();
+ }
+ tmp = buf[0];
+ E_UTIL_f_preemph2( *Q_new-1, buf+1, PREEMPH_FAC, M+st->frameSize, &tmp );
+ Residu3_fx( st->A_cng, buf+1+M, st->exc_cng, st->frameSize, 1 );
+ }
+ IF ( EQ_16( gen_exc, 2 ))
+ {
+ FOR (i=0; i < M+1+st->frameSize; i++)
+ {
+ buf[i] = mult_r( olapBuffer[i+len4-M-1], st->fftlenFac );
+ move16();
+ }
+ tmp = buf[0];
+ *Q_new = E_UTIL_f_preemph3( buf+1, PREEMPH_FAC, M+st->frameSize, &tmp, 1 );
+ Residu3_fx( st->A_cng, buf+1+M, st->exc_cng, st->frameSize, 1 );
+ }
+
+}
+
+
+/**************************************************************************************
+* Compute some values used in the bias correction of the minimum statistics algorithm *
+**************************************************************************************/
+void mhvals(Word16 d,
+ Word16 * m /*, float * h*/
+ )
+{
+ Word16 i, j;
+ Word16 len = sizeof(d_array)/sizeof(Word16);
+
+
+ assert( d==72 || d==12); /* function only tested for d==72 and d==12) */
+ i = 0;
+ move16();
+ FOR (i=0 ; i < len ; i++)
+ {
+ IF (LE_16(d,d_array[i]))
+ {
+ BREAK;
+ }
+ }
+ IF (EQ_16(i, len))
+ {
+ i = sub(len, 1);
+ j = i;
+ move16();
+ }
+ ELSE
+ {
+ j = sub(i, 1);
+ }
+ IF (EQ_16(d, d_array[i]))
+ {
+ *m = m_array[i];
+ move16();
+ }
+ ELSE
+ {
+ Word32 qi_m, qj_m, q_m, tmp1_m, tmp2_m;
+ Word16 qi_e, qj_e, q_e, tmp1_e, tmp2_e, tmp1_w16_m, tmp1_w16_e, shift;
+
+
+ /* d_array has exponent 15 */
+ qj_e = 15;
+ move16();
+ qj_m = L_deposit_h(d_array[i-1]);
+
+ qi_e = 15;
+ move16();
+ qi_m = L_deposit_h(d_array[i]);
+
+ q_e = 15;
+ move16();
+ q_m = L_deposit_h(d);
+
+ qj_m = Sqrt32(qj_m, &qj_e);
+ qi_m = Sqrt32(qi_m, &qi_e);
+ q_m = Sqrt32(q_m, &q_e);
+
+ tmp1_m = Mpy_32_32(qi_m, qj_m);
+ tmp1_e = add(qi_e, qj_e);
+ tmp1_m = L_deposit_h(BASOP_Util_Divide3232_Scale(tmp1_m, q_m, &shift));
+ tmp1_e = sub(tmp1_e, q_e);
+ tmp1_e = add(tmp1_e, shift);
+ tmp1_m = BASOP_Util_Add_Mant32Exp(tmp1_m, tmp1_e, L_negate(qj_m), qj_e, &tmp1_e);
+
+ tmp2_m = BASOP_Util_Add_Mant32Exp (qi_m, qi_e, L_negate(qj_m), qj_e, &tmp2_e);
+ tmp1_w16_m = round_fx(tmp2_m);
+ tmp1_w16_e = tmp2_e;
+ move16();
+ BASOP_Util_Divide_MantExp(sub(m_array[j], m_array[i]), 0, tmp1_w16_m, tmp1_w16_e, &tmp1_w16_m, &tmp1_w16_e);
+
+ tmp2_m = Mpy_32_16_1(tmp1_m, tmp1_w16_m);
+ tmp2_e = add(tmp1_e, tmp1_w16_e);
+
+ tmp2_m = BASOP_Util_Add_Mant32Exp (tmp2_m, tmp2_e, L_deposit_h(m_array[i]), 0, &tmp2_e);
+ assert(tmp2_e == 0);
+ *m = extract_h(tmp2_m);
+ }
+}
+
+
+/*
+ rand_gauss
+
+ Parameters:
+
+ seed i/o : pointer to seed
+
+ Function:
+ Random generator with Gaussian distribution with mean 0 and std 1
+
+ Returns:
+ random signal format Q3.29
+*/
+Word32 rand_gauss (Word16 *seed)
+{
+ Word32 temp;
+ Word16 loc_seed;
+
+
+
+ /* This unrolled version reduces the cycles from 17 to 10 */
+ loc_seed = extract_l(L_mac0(13849, *seed, 31821));
+ temp = L_deposit_l(loc_seed);
+
+ loc_seed = extract_l(L_mac0(13849, loc_seed, 31821));
+ temp = L_msu0(temp,loc_seed,-1);
+
+ loc_seed = extract_l(L_mac0(13849, loc_seed, 31821));
+ temp = L_msu0(temp,loc_seed,-1);
+
+ *seed = loc_seed;
+ move16();
+ return L_shl(temp,WORD16_BITS-CNG_RAND_GAUSS_SHIFT);
+}
+
+
+/*
+ lpc_from_spectrum
+
+ Parameters:
+
+ powspec i : pointer to noise levels format Q5.27
+ start i : start band
+ stop i : stop band
+ fftlen i : size of fft
+ A o : lpc coefficients format Q3.12
+ s i : lpc order
+ preemph_fac i : preemphase factor format Q1.15
+
+
+ Function:
+ calculate lpc coefficients from the spectrum
+
+ Returns:
+ void
+*/
+void lpc_from_spectrum (Word32 *powspec,
+ Word16 powspec_exp,
+ Word16 start,
+ Word16 stop,
+ Word16 fftlen,
+ Word16 *A,
+ Word16 lpcorder,
+ Word16 preemph_fac
+ )
+{
+ Word16 i, s1, s2, s3, fftlen2, scale, fftlen4, fftlen8, len, step, preemph_fac2;
+ Word32 maxVal, r[32], fftBuffer[FFTLEN], *ptr, *pti, nf;
+ Word16 tmp, r_h[32], r_l[32];
+ const PWord16 *table;
+
+
+
+ scale = 0;
+ move16();
+ fftlen2 = shr(fftlen,1);
+ fftlen4 = shr(fftlen,2);
+ fftlen8 = shr(fftlen,3);
+
+ /* Power Spectrum */
+ maxVal = 0;
+ move32();
+ len = sub(stop, start);
+ FOR (i=0; i < len; i++)
+ {
+ maxVal = L_max(maxVal, L_abs(powspec[i]));
+ }
+ s1 = norm_l(maxVal);
+ nf = L_shr_r(1099511680l/*1e-3f Q40*/,add(sub(powspec_exp,s1),9));
+
+ ptr = fftBuffer;
+ pti = fftBuffer+1;
+
+ FOR (i=0; i < start; i++)
+ {
+ *ptr = nf;
+ move32();
+ *pti = L_deposit_l(0);
+ ptr += 2;
+ pti += 2;
+ }
+
+ FOR ( ; i < stop; i++ )
+ {
+ *ptr = L_max( nf, L_shl(powspec[i-start], s1) );
+ move32();
+ *pti = L_deposit_l(0);
+ ptr += 2;
+ pti += 2;
+ }
+
+ FOR ( ; i < fftlen2; i++ )
+ {
+ *ptr = nf;
+ move32();
+ *pti = L_deposit_l(0);
+ ptr += 2;
+ pti += 2;
+ }
+
+ fftBuffer[1] = nf;
+ move32();
+
+ /* Pre-emphasis */
+
+ BASOP_getTables(&table, NULL, &step, fftlen4);
+ tmp = round_fx(L_shr(L_add(0x40000000, L_mult0(preemph_fac, preemph_fac)),1));
+ preemph_fac2 = shr(preemph_fac,1);
+ ptr = fftBuffer;
+ *ptr = Mpy_32_16_1( *ptr, sub( tmp, preemph_fac2 ) );
+ move32();
+ ptr += 2;
+ FOR ( i = 1; i < fftlen8; i++ )
+ {
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, sub( tmp, mult_r(preemph_fac2,add(shr(table[i-1].v.re,1),shr(table[i].v.re,1)) ) ) );
+ ptr += 2;
+ }
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, sub( tmp, mult_r(preemph_fac2,add(shr(table[fftlen8-1].v.re,1),shr(table[fftlen8-1].v.im,1)) ) ) );
+ ptr += 2;
+ FOR ( i = 1; i < fftlen8; i++ )
+ {
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, sub( tmp, mult_r(preemph_fac2,add(shr(table[fftlen8-i-1].v.im,1),shr(table[fftlen8-i].v.im,1)) ) ) );
+ ptr += 2;
+ }
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, tmp );
+ ptr += 2;
+ FOR ( i = 1; i < fftlen8; i++ )
+ {
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, add( tmp, mult_r(preemph_fac2,add(shr(table[i-1].v.im,1),shr(table[i].v.im,1)) ) ) );
+ ptr += 2;
+ }
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, add( tmp, mult_r(preemph_fac2,add(shr(table[fftlen8-1].v.re,1),shr(table[fftlen8-1].v.im,1)) ) ) );
+ ptr += 2;
+ FOR ( i = 1; i < fftlen8; i++ )
+ {
+ move32();
+ *ptr = Mpy_32_16_1( *ptr, add( tmp, mult_r(preemph_fac2,add(shr(table[fftlen8-i-1].v.re,1),shr(table[fftlen8-i].v.re,1)) ) ) );
+ ptr += 2;
+ }
+ move32();
+ fftBuffer[1] = Mpy_32_16_1( fftBuffer[1], add( tmp, preemph_fac2 ) );
+ maxVal = 0;
+ move32();
+ FOR (i=0; i < fftlen; i++)
+ {
+ maxVal = L_max(maxVal, L_abs(fftBuffer[i]));
+ }
+ s2 = norm_l(maxVal);
+ FOR (i=0; i < fftlen; i++)
+ {
+ fftBuffer[i] = L_shl( fftBuffer[i], s2 );
+ move32();
+ }
+
+ /* Autocorrelation */
+
+ BASOP_rfft(fftBuffer, fftlen, &scale, 1);
+
+ s3 = getScaleFactor32(fftBuffer, add(lpcorder,1));
+
+ FOR (i=0; i <= lpcorder; i++ )
+ {
+ r[i] = L_shl(fftBuffer[i], s3);
+ move32();
+ }
+
+ r[0] = Mpy_32_32( r[0], 1074278656l/*1.0005f Q30*/ );
+ move32();
+ FOR (i=1; i <= lpcorder; i++ )
+ {
+ r[i] = Mpy_32_32( r[i], 1073741824l/*1.f Q30*/ );
+ move32();
+ }
+ s3 = getScaleFactor32(r, add(lpcorder,1));
+
+ FOR (i=0; i <= lpcorder; i++ )
+ {
+ r[i] = L_shl(r[i], s3);
+ move32();
+ }
+
+ FOR (i=0; i <= lpcorder; i++ )
+ {
+ L_Extract(r[i], &r_h[i], &r_l[i]);
+ }
+
+ /* LPC */
+
+ E_LPC_lev_dur(r_h, r_l, A, NULL, lpcorder, NULL);
+
+}
+
+/*
+ msvq_decoder
+
+ Parameters:
+
+ cb i : Codebook (indexed cb[stages][levels][p]) format Q9.7
+ stages i : Number of stages
+ N i : Vector dimension
+ maxN i : Codebook vector dimension
+ Idx o : Indices
+ uq[] i : Quantized vector format Q9.7
+
+
+ Function:
+ multi stage vector dequantisation
+
+ Returns:
+ void
+*/
+void msvq_decoder (const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */
+ Word16 stages, /* i : Number of stages */
+ Word16 N, /* i : Vector dimension */
+ Word16 maxN, /* i : Codebook vector dimension */
+ Word16 Idx[], /* i : Indices */
+ Word16 *uq /* o : quantized vector */
+ )
+{
+ Word16 s, i, offset;
+
+
+
+ offset = i_mult(Idx[0], maxN);
+ FOR (i=0; iA_cng, Aq+i*(M+1), M+1 );
+ }
+
+ E_LPC_a_lsp_conversion( Aq, lsp_new, lsp_old, M );
+
+ IF( first_CNG == 0 )
+ {
+ Copy( lsp_old, lspCNG, M );
+ }
+ FOR( i=0; iexc_cng, exc, L_frame );
+ Copy( hs->exc_cng, exc2, L_frame );
+
+ IF( EQ_16(L_frame,L_FRAME))
+ {
+ interp_code_5over2_fx( exc2, bwe_exc, L_frame );
+ }
+ ELSE
+ {
+ interp_code_4over2_fx( exc2, bwe_exc, L_frame );
+ }
+}
+
diff --git a/lib_com/fft.c b/lib_com/fft.c
new file mode 100644
index 0000000000000000000000000000000000000000..9869909efb3e7ecb7dd6157f255b72cbde97eb85
--- /dev/null
+++ b/lib_com/fft.c
@@ -0,0 +1,2475 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "prot_fx.h"
+#include "basop_util.h"
+#include "rom_basop_util.h"
+#include "options.h"
+#include "stl.h"
+
+void fft16_with_cmplx_data( cmplx *pInp, Word16 bsacle);
+
+/**
+ * \brief Profiling / Precision results
+ *
+ * Profiling / Precision of complex valued FFTs: BASOP_cfft()
+ *
+ * WOPS BASOP Precision BASOP
+ * FFT5 87 16.96
+ * FFT8 108 17.04
+ * FFT10 194 16.70
+ * FFT15 354 16.97
+ * FFT16 288 16.62
+ * FFT20 368 16.06
+ * FFT30 828 16.80
+ * FFT32 752 15.45 (cplx mult mit 3 mult und 3 add)
+ * FFT32 824 16.07 (cplx mult mit 4 mult und 2 add)
+ * FFT64 ( 8x 8) 3.129 15.16
+ * FFT80 (10x 8) 4.385 15.55
+ * FFT100 (20x 5) 6.518 15.65
+ * FFT120 (15x 8) 7.029 15.38
+ * FFT128 (16x 8) 6.777 15.28
+ * FFT160 (20x 8) 9.033 14.95
+ * FFT240 (30x 8) 14.961 15.49
+ * FFT256 (32x 8) 14.905 14.61 (cplx mult mit 3 mult und 3 add)
+ * FFT256 (32x 8) 15.265 15.04 (cplx mult mit 4 mult und 2 add)
+ * FFT320 (20x16) 21.517 15.21
+ *
+ *
+ * Profiling / Precision of real valued FFTs / iFFTs: BASOP_rfft()
+ *
+ * WOPS BASOP Precision BASOP
+ * rFFT40 955 15.68
+ * rFFT64 1635 16.17
+ *
+ * irFFT40 1116 15.36
+ * irFFT64 1759 15.18
+ *
+ */
+
+
+#define Mpy_32_xx Mpy_32_16_1
+
+#define FFTC(x) WORD322WORD16((Word32)x)
+
+#define C31 (FFTC(0x91261468)) /* FL2WORD32( -0.86602540) -sqrt(3)/2 */
+
+#define C51 (FFTC(0x79bc3854)) /* FL2WORD32( 0.95105652) */
+#define C52 (FFTC(0x9d839db0)) /* FL2WORD32(-1.53884180/2) */
+#define C53 (FFTC(0xd18053ce)) /* FL2WORD32(-0.36327126) */
+#define C54 (FFTC(0x478dde64)) /* FL2WORD32( 0.55901699) */
+#define C55 (FFTC(0xb0000001)) /* FL2WORD32(-1.25/2) */
+
+#define C81 (FFTC(0x5a82799a)) /* FL2WORD32( 7.071067811865475e-1) */
+#define C82 (FFTC(0xa57d8666)) /* FL2WORD32(-7.071067811865475e-1) */
+
+#define C161 (FFTC(0x5a82799a)) /* FL2WORD32( 7.071067811865475e-1) INV_SQRT2 */
+#define C162 (FFTC(0xa57d8666)) /* FL2WORD32(-7.071067811865475e-1) -INV_SQRT2 */
+
+#define C163 (FFTC(0x7641af3d)) /* FL2WORD32( 9.238795325112867e-1) COS_PI_DIV8 */
+#define C164 (FFTC(0x89be50c3)) /* FL2WORD32(-9.238795325112867e-1) -COS_PI_DIV8 */
+
+#define C165 (FFTC(0x30fbc54d)) /* FL2WORD32( 3.826834323650898e-1) COS_3PI_DIV8 */
+#define C166 (FFTC(0xcf043ab3)) /* FL2WORD32(-3.826834323650898e-1) -COS_3PI_DIV8 */
+
+
+#define cplxMpy4_8_0(re,im,a,b,c,d) re = L_shr(L_sub(Mpy_32_xx(a,c),Mpy_32_xx(b,d)),1); \
+ im = L_shr(L_add(Mpy_32_xx(a,d),Mpy_32_xx(b,c)),1);
+
+#define cplxMpy4_8_1(re,im,a,b) re = L_shr(a,1); \
+ im = L_shr(b,1);
+
+
+
+
+/**
+ * \brief Function performs a complex 5-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR5 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 88 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+static void fft5_with_cmplx_data(cmplx *inp)
+{
+ cmplx x0,x1,x2,x3,x4;
+ cmplx y1,y2,y3,y4;
+ cmplx t;
+
+ x0 = CL_shr(inp[0],SCALEFACTOR5);
+ x1 = CL_shr(inp[1],SCALEFACTOR5);
+ x2 = CL_shr(inp[2],SCALEFACTOR5);
+ x3 = CL_shr(inp[3],SCALEFACTOR5);
+ x4 = CL_shr(inp[4],SCALEFACTOR5);
+
+ y1 = CL_add(x1,x4);
+ y4 = CL_sub(x1,x4);
+ y3 = CL_add(x2,x3);
+ y2 = CL_sub(x2,x3);
+ t = CL_scale_t(CL_sub(y1,y3),C54);
+ y1 = CL_add(y1,y3);
+ inp[0] = CL_add(x0,y1);
+
+ /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of
+ the values as fracts */
+ y1 = CL_add(inp[0],(CL_shl(CL_scale_t(y1,C55),1)));
+ y3 = CL_sub(y1,t);
+ y1 = CL_add(y1,t);
+
+ t = CL_scale_t(CL_add(y4,y2),C51);
+ /* Bit shift left because of the constant C55 which was scaled with the factor 0.5 because of the representation of
+ the values as fracts */
+ y4 = CL_add(t,CL_shl(CL_scale_t(y4, C52),1));
+ y2 = CL_add(t,CL_scale_t(y2,C53));
+
+
+ /* combination */
+ inp[1] = CL_msu_j(y1,y2);
+ inp[4] = CL_mac_j(y1,y2);
+
+ inp[2] = CL_mac_j(y3,y4);
+ inp[3] = CL_msu_j(y3,y4);
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 5;
+#endif
+
+}
+
+/**
+ * \brief Function performs a complex 8-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR8 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 108 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+static void fft8_with_cmplx_data(cmplx *inp)
+{
+ cmplx x0, x1, x2, x3, x4, x5, x6, x7;
+ cmplx s0, s1, s2, s3, s4, s5, s6, s7;
+ cmplx t0, t1, t2, t3, t4, t5, t6, t7;
+
+ /* Pre-additions */
+ x0 = CL_shr(inp[0], SCALEFACTOR8);
+ x1 = CL_shr(inp[1], SCALEFACTOR8);
+ x2 = CL_shr(inp[2], SCALEFACTOR8);
+ x3 = CL_shr(inp[3], SCALEFACTOR8);
+ x4 = CL_shr(inp[4], SCALEFACTOR8);
+ x5 = CL_shr(inp[5], SCALEFACTOR8);
+ x6 = CL_shr(inp[6], SCALEFACTOR8);
+ x7 = CL_shr(inp[7], SCALEFACTOR8);
+
+ /* loops are unrolled */
+ {
+ t0 = CL_add(x0,x4);
+ t1 = CL_sub(x0,x4);
+
+ t2 = CL_add(x1,x5);
+ t3 = CL_sub(x1,x5);
+
+ t4 = CL_add(x2,x6);
+ t5 = CL_sub(x2,x6);
+
+ t6 = CL_add(x3,x7);
+ t7 = CL_sub(x3,x7);
+ }
+
+ /* Pre-additions and core multiplications */
+
+ s0 = CL_add(t0, t4);
+ s2 = CL_sub(t0, t4);
+
+ s4 = CL_mac_j(t1, t5);
+ s5 = CL_msu_j(t1, t5);
+
+ s1 = CL_add(t2, t6);
+ s3 = CL_sub(t2, t6);
+ s3 = CL_mul_j(s3);
+
+ t0 = CL_add(t3, t7);
+ t1 = CL_sub(t3, t7);
+
+ s6 = CL_scale_t(CL_msu_j(t1, t0), C81);
+ s7 = CL_dscale_t(CL_swap_real_imag(CL_msu_j(t0, t1)), C81, C82);
+
+ /* Post-additions */
+
+ inp[0] = CL_add(s0, s1);
+ inp[4] = CL_sub(s0, s1);
+
+ inp[2] = CL_sub(s2, s3);
+ inp[6] = CL_add(s2, s3);
+
+ inp[3] = CL_add(s4, s7);
+ inp[7] = CL_sub(s4, s7);
+
+ inp[1] = CL_add(s5, s6);
+ inp[5] = CL_sub(s5, s6);
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 8;
+#endif
+
+
+}
+
+
+/**
+ * \brief Function performs a complex 10-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR10 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 196 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+
+static void fft10_with_cmplx_data(cmplx *inp_data)
+{
+ cmplx r1,r2,r3,r4;
+ cmplx x0,x1,x2,x3,x4,t;
+ cmplx y[10];
+
+ /* FOR i=0 */
+ {
+ x0 = CL_shr(inp_data[0],SCALEFACTOR10);
+ x1 = CL_shr(inp_data[2],SCALEFACTOR10);
+ x2 = CL_shr(inp_data[4],SCALEFACTOR10);
+ x3 = CL_shr(inp_data[6],SCALEFACTOR10);
+ x4 = CL_shr(inp_data[8],SCALEFACTOR10);
+
+ r1 = CL_add(x3,x2);
+ r4 = CL_sub(x3,x2);
+ r3 = CL_add(x1,x4);
+ r2 = CL_sub(x1,x4);
+ t = CL_scale_t(CL_sub(r1,r3),C54);
+ r1 = CL_add(r1,r3);
+ y[0] = CL_add(x0,r1);
+ r1 = CL_add(y[0],(CL_shl(CL_scale_t(r1,C55),1)));
+ r3 = CL_sub(r1,t);
+ r1 = CL_add(r1,t);
+ t = CL_scale_t((CL_add(r4,r2)),C51);
+ r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1));
+ r2 = CL_add(t,CL_scale_t(r2,C53));
+
+
+ y[2] = CL_msu_j(r1,r2);
+ y[8] = CL_mac_j(r1,r2);
+ y[4] = CL_mac_j(r3,r4);
+ y[6] = CL_msu_j(r3,r4);
+ }
+ /* FOR i=1 */
+ {
+ x0 = CL_shr(inp_data[5],SCALEFACTOR10);
+ x1 = CL_shr(inp_data[1],SCALEFACTOR10);
+ x2 = CL_shr(inp_data[3],SCALEFACTOR10);
+ x3 = CL_shr(inp_data[7],SCALEFACTOR10);
+ x4 = CL_shr(inp_data[9],SCALEFACTOR10);
+
+ r1 = CL_add(x1,x4);
+ r4 = CL_sub(x1,x4);
+ r3 = CL_add(x3,x2);
+ r2 = CL_sub(x3,x2);
+ t = CL_scale_t(CL_sub(r1,r3),C54);
+ r1 = CL_add(r1,r3);
+ y[1] = CL_add(x0,r1);
+ r1 = CL_add(y[1],(CL_shl(CL_scale_t(r1,C55),1)));
+ r3 = CL_sub(r1,t);
+ r1 = CL_add(r1,t);
+ t = CL_scale_t((CL_add(r4,r2)),C51);
+ r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1));
+ r2 = CL_add(t,CL_scale_t(r2,C53));
+
+
+ y[3] = CL_msu_j(r1,r2);
+ y[9] = CL_mac_j(r1,r2);
+ y[5] = CL_mac_j(r3,r4);
+ y[7] = CL_msu_j(r3,r4);
+ }
+
+ /* FOR i=0 */
+ {
+ inp_data[0] = CL_add(y[0],y[1]);
+ inp_data[5] = CL_sub(y[0],y[1]);
+ }
+ /* FOR i=2 */
+ {
+ inp_data[2] = CL_add(y[2],y[3]);
+ inp_data[7] = CL_sub(y[2],y[3]);
+ }
+ /* FOR i=4 */
+ {
+ inp_data[4] = CL_add(y[4],y[5]);
+ inp_data[9] = CL_sub(y[4],y[5]);
+ }
+ /* FOR i=6 */
+ {
+ inp_data[6] = CL_add(y[6],y[7]);
+ inp_data[1] = CL_sub(y[6],y[7]);
+ }
+ /* FOR i=8 */
+ {
+ inp_data[8] = CL_add(y[8],y[9]);
+ inp_data[3] = CL_sub(y[8],y[9]);
+ }
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 10;
+#endif
+
+}
+
+
+/**
+ * \brief Function performs a complex 15-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR15 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 354 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+
+static void fft15_with_cmplx_data(cmplx *inp_data)
+{
+ cmplx c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14;
+ cmplx c_z0,c_z1, c_z2, c_z3, c_z4, c_z5, c_z6, c_z7, c_z8, c_z9, c_z10, c_z11, c_z12, c_z13, c_z14;
+ cmplx c_y1,c_y2,c_y3,c_y4;
+ cmplx c_t;
+
+ c0 = CL_shr(inp_data[ 0],SCALEFACTOR15);
+ c1 = CL_shr(inp_data[ 3],SCALEFACTOR15);
+ c2 = CL_shr(inp_data[ 6],SCALEFACTOR15);
+ c3 = CL_shr(inp_data[ 9],SCALEFACTOR15);
+ c4 = CL_shr(inp_data[12],SCALEFACTOR15);
+ c5 = CL_shr(inp_data[ 5],SCALEFACTOR15);
+ c6 = CL_shr(inp_data[ 8],SCALEFACTOR15);
+ c7 = CL_shr(inp_data[11],SCALEFACTOR15);
+ c8 = CL_shr(inp_data[14],SCALEFACTOR15);
+ c9 = CL_shr(inp_data[ 2],SCALEFACTOR15);
+ c10 = CL_shr(inp_data[10],SCALEFACTOR15);
+ c11 = CL_shr(inp_data[13],SCALEFACTOR15);
+ c12 = CL_shr(inp_data[ 1],SCALEFACTOR15);
+ c13 = CL_shr(inp_data[ 4],SCALEFACTOR15);
+ c14 = CL_shr(inp_data[ 7],SCALEFACTOR15);
+
+ /* 1. FFT5 stage */
+ c_y1 = CL_add(c1,c4);
+ c_y4 = CL_sub(c1,c4);
+ c_y3 = CL_add(c2,c3);
+ c_y2 = CL_sub(c2,c3);
+ c_t = CL_scale_t(CL_sub(c_y1,c_y3),C54);
+ c_y1 = CL_add(c_y1,c_y3);
+ c_z0 = CL_add(c0,c_y1);
+ c_y1 = CL_add(c_z0,(CL_shl(CL_scale_t(c_y1,C55),1)));
+ c_y3 = CL_sub(c_y1,c_t);
+ c_y1 = CL_add(c_y1,c_t);
+ c_t = CL_scale_t(CL_add(c_y4,c_y2),C51);
+ c_y4 = CL_add(c_t,CL_shl(CL_scale_t(c_y4,C52),1));
+ c_y2 = CL_add(c_t,CL_scale_t(c_y2,C53));
+
+ /* combination */
+ c_z1 = CL_msu_j(c_y1,c_y2);
+ c_z2 = CL_mac_j(c_y3,c_y4);
+ c_z3 = CL_msu_j(c_y3,c_y4);
+ c_z4 = CL_mac_j(c_y1,c_y2);
+
+
+ /* 2. FFT5 stage */
+ c_y1 = CL_add(c6,c9);
+ c_y4 = CL_sub(c6,c9);
+ c_y3 = CL_add(c7,c8);
+ c_y2 = CL_sub(c7,c8);
+ c_t = CL_scale_t(CL_sub(c_y1,c_y3),C54);
+ c_y1 = CL_add(c_y1,c_y3);
+ c_z5 = CL_add(c5,c_y1);
+ c_y1 = CL_add(c_z5,(CL_shl(CL_scale_t(c_y1,C55),1)));
+ c_y3 = CL_sub(c_y1,c_t);
+ c_y1 = CL_add(c_y1,c_t);
+ c_t = CL_scale_t(CL_add(c_y4,c_y2),C51);
+ c_y4 = CL_add(c_t,CL_shl(CL_scale_t(c_y4,C52),1));
+ c_y2 = CL_add(c_t,CL_scale_t(c_y2,C53));
+ /* combination */
+ c_z6 = CL_msu_j(c_y1,c_y2);
+ c_z7 = CL_mac_j(c_y3,c_y4);
+ c_z8 = CL_msu_j(c_y3,c_y4);
+ c_z9 = CL_mac_j(c_y1,c_y2);
+
+
+ /* 3. FFT5 stage */
+
+ c_y1 = CL_add(c11,c14);
+ c_y4 = CL_sub(c11,c14);
+ c_y3 = CL_add(c12,c13);
+ c_y2 = CL_sub(c12,c13);
+ c_t = CL_scale_t(CL_sub(c_y1,c_y3),C54);
+ c_y1 = CL_add(c_y1,c_y3);
+ c_z10 = CL_add(c10,c_y1);
+ c_y1 = CL_add(c_z10,(CL_shl(CL_scale_t(c_y1,C55),1)));
+ c_y3 = CL_sub(c_y1,c_t);
+ c_y1 = CL_add(c_y1,c_t);
+ c_t = CL_scale_t(CL_add(c_y4,c_y2),C51);
+ c_y4 = CL_add(c_t,CL_shl(CL_scale_t(c_y4,C52),1));
+ c_y2 = CL_add(c_t,CL_scale_t(c_y2,C53));
+ /* combination */
+ c_z11 = CL_msu_j(c_y1,c_y2);
+ c_z12 = CL_mac_j(c_y3,c_y4);
+ c_z13 = CL_msu_j(c_y3,c_y4);
+ c_z14 = CL_mac_j(c_y1,c_y2);
+
+
+
+ /* 1. FFT3 stage */
+
+ c_y1 = CL_add(c_z5,c_z10);
+ c_y2 = CL_scale_t(CL_sub(c_z5,c_z10),C31);
+ inp_data[0] = CL_add(c_z0,c_y1);
+ c_y1 = CL_sub(c_z0,CL_shr(c_y1,1));
+ inp_data[10] = CL_mac_j(c_y1,c_y2);
+ inp_data[5] = CL_msu_j(c_y1,c_y2);
+
+ /* 2. FFT3 stage */
+ c_y1 = CL_add(c_z6,c_z11);
+ c_y2 = CL_scale_t(CL_sub(c_z6,c_z11),C31);
+ inp_data[6] = CL_add(c_z1,c_y1);
+ c_y1 = CL_sub(c_z1,CL_shr(c_y1,1));
+ inp_data[1] = CL_mac_j(c_y1,c_y2);
+ inp_data[11] = CL_msu_j(c_y1,c_y2);
+
+ /* 3. FFT3 stage */
+ c_y1 = CL_add(c_z7,c_z12);
+ c_y2 = CL_scale_t(CL_sub(c_z7,c_z12),C31);
+ inp_data[12] = CL_add(c_z2,c_y1);
+ c_y1 = CL_sub(c_z2,CL_shr(c_y1,1));
+ inp_data[7] = CL_mac_j(c_y1,c_y2);
+ inp_data[2] = CL_msu_j(c_y1,c_y2);
+
+
+ /* 4. FFT3 stage */
+ c_y1 = CL_add(c_z8,c_z13);
+ c_y2 = CL_scale_t(CL_sub(c_z8,c_z13),C31);
+ inp_data[3] = CL_add(c_z3,c_y1);
+ c_y1 = CL_sub(c_z3,CL_shr(c_y1,1));
+ inp_data[13] = CL_mac_j(c_y1,c_y2);
+ inp_data[8] = CL_msu_j(c_y1,c_y2);
+
+
+ /* 5. FFT3 stage */
+ c_y1 = CL_add(c_z9,c_z14);
+ c_y2 = CL_scale_t(CL_sub(c_z9,c_z14),C31);
+ inp_data[9] = CL_add(c_z4,c_y1);
+ c_y1 = CL_sub(c_z4,CL_shr(c_y1,1));
+ inp_data[4] = CL_mac_j(c_y1,c_y2);
+ inp_data[14] = CL_msu_j(c_y1,c_y2);
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 15;
+#endif
+
+}
+
+
+/**
+ * \brief Function performs a complex 16-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR16 bits.
+ *
+ * WOPS with 32x16 bit multiplications (scale on ): 288 cycles
+ * WOPS with 32x16 bit multiplications (scale off): 256 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+void fft16(Word32 *re, Word32 *im, Word16 s, Word16 bScale)
+{
+ int i;
+ if ( s == 2 )
+ {
+ fft16_with_cmplx_data( (cmplx *) re, bScale );
+ }
+ else
+ {
+ cmplx inp_data[16];
+ FOR(i=0; i<16; i++)
+ {
+ inp_data[i] = CL_form(re[s*i], im[s*i]);
+ }
+ fft16_with_cmplx_data(inp_data, bScale );
+ FOR(i=0; i<16; i++)
+ {
+ re[s*i] = CL_Extract_real(inp_data[i]);
+ im[s*i] = CL_Extract_imag(inp_data[i]);
+ }
+ }
+}
+
+void fft16_with_cmplx_data(cmplx *input, Word16 bScale )
+{
+ cmplx x0, x1, x2, x3, temp;
+ cmplx t0,t2,t4,t6,t7;
+ cmplx y[16];
+
+ IF (bScale)
+ {
+ {
+ x0 = CL_shr(input[0],SCALEFACTOR16);
+ x1 = CL_shr(input[4],SCALEFACTOR16);
+ x2 = CL_shr(input[8],SCALEFACTOR16);
+ x3 = CL_shr(input[12],SCALEFACTOR16);
+ t0 = CL_add(x0,x2);
+ t2 = CL_sub(x0,x2);
+ t4 = CL_add(x1,x3);
+ t6 = CL_sub(x1,x3);
+ t6 = CL_mul_j(t6);
+ y[0] = CL_add(t0,t4);
+ y[1] = CL_sub(t2,t6);
+ y[2] = CL_sub(t0,t4);
+ y[3] = CL_add(t2,t6);
+
+
+ x0 = CL_shr(input[1],SCALEFACTOR16);
+ x1 = CL_shr(input[5],SCALEFACTOR16);
+ x2 = CL_shr(input[9],SCALEFACTOR16);
+ x3 = CL_shr(input[13],SCALEFACTOR16);
+ t0 = CL_add(x0,x2);
+ t2 = CL_sub(x0,x2);
+ t4 = CL_add(x1,x3);
+ t6 = CL_sub(x1,x3);
+ t6 = CL_mul_j(t6);
+ y[4] = CL_add(t0,t4);
+ y[5] = CL_sub(t2,t6);
+ y[6] = CL_sub(t0,t4);
+ y[7] = CL_add(t2,t6);
+
+
+ x0 = CL_shr(input[2],SCALEFACTOR16);
+ x1 = CL_shr(input[6],SCALEFACTOR16);
+ x2 = CL_shr(input[10],SCALEFACTOR16);
+ x3 = CL_shr(input[14],SCALEFACTOR16);
+ t0 = CL_add(x0,x2);
+ t2 = CL_sub(x0,x2);
+ t4 = CL_add(x1,x3);
+ t6 = CL_sub(x1,x3);
+ t6 = CL_mul_j(t6);
+ y[8] = CL_add(t0,t4);
+ y[9] = CL_sub(t2,t6);
+ y[10] = CL_sub(t4,t0);
+ y[10] = CL_mul_j(y[10]);
+ y[11] = CL_add(t2,t6);
+
+
+ x0 = CL_shr(input[3],SCALEFACTOR16);
+ x1 = CL_shr(input[7],SCALEFACTOR16);
+ x2 = CL_shr(input[11],SCALEFACTOR16);
+ x3 = CL_shr(input[15],SCALEFACTOR16);
+ t0 = CL_add(x0,x2);
+ t2 = CL_sub(x0,x2);
+ t4 = CL_add(x1,x3);
+ t6 = CL_sub(x1,x3);
+ t6 = CL_mul_j(t6);
+ y[12] = CL_add(t0,t4);
+ y[13] = CL_sub(t2,t6);
+ y[14] = CL_sub(t0,t4);
+ y[15] = CL_add(t2,t6);
+ }
+ }
+ else
+ {
+ {
+ t0 = CL_add(input[ 0],input[ 8]);
+ t2 = CL_sub(input[ 0],input[ 8]);
+ t4 = CL_add(input[ 4],input[12]);
+ t7 = CL_sub(input[ 4],input[12]);
+
+ y[0] = CL_add(t0,t4);
+ y[1] = CL_msu_j(t2,t7);
+ y[2] = CL_sub(t0,t4);
+ y[3] = CL_mac_j(t2,t7);
+ }
+ /* i=1 */
+ {
+ t0 = CL_add(input[ 1],input[ 9]);
+ t2 = CL_sub(input[ 1],input[ 9]);
+ t4 = CL_add(input[ 5],input[13]);
+ t7 = CL_sub(input[ 5],input[13]);
+
+ y[4] = CL_add(t0,t4);
+ y[5] = CL_msu_j(t2,t7);
+ y[6] = CL_sub(t0,t4);
+ y[7] = CL_mac_j(t2,t7);
+ }
+ /* i=2 */
+ {
+ t0 = CL_add(input[ 2],input[ 10]);
+ t2 = CL_sub(input[ 2],input[ 10]);
+ t4 = CL_add(input[ 6],input[14]);
+ t7 = CL_sub(input[ 6],input[14]);
+
+ y[8] = CL_add(t0,t4);
+ y[9] = CL_msu_j(t2,t7);
+ temp = CL_sub(t0,t4);
+ y[10] = CL_negate(CL_mul_j(temp));
+ y[11] = CL_mac_j(t2,t7);
+ }
+ /* i=3 */
+ {
+ t0 = CL_add(input[ 3],input[ 11]);
+ t2 = CL_sub(input[ 3],input[ 11]);
+ t4 = CL_add(input[ 7],input[15]);
+ t7 = CL_sub(input[ 7],input[15]);
+
+ y[12] = CL_add(t0,t4);
+ y[13] = CL_msu_j(t2,t7);
+ y[14] = CL_sub(t0,t4);
+ y[15] = CL_mac_j(t2,t7);
+ }
+
+ }
+
+ x0 = CL_scale_t(y[11],C162);
+ y[11] = CL_mac_j(x0,x0);
+
+ x0 = CL_scale_t(y[14],C162);
+ y[14] = CL_mac_j(x0,x0);
+
+ x0 = CL_scale_t(y[6],C161);
+ y[6] = CL_msu_j(x0,x0);
+
+ x0 = CL_scale_t(y[9],C161);
+ y[9] = CL_msu_j(x0,x0);
+
+ y[5] = CL_mac_j(CL_scale_t(y[5], C163), CL_scale_t(y[5], C166));
+ y[7] = CL_mac_j(CL_scale_t(y[7], C165), CL_scale_t(y[7], C164));
+ y[13] = CL_mac_j(CL_scale_t(y[13], C165), CL_scale_t(y[13], C164));
+ y[15] = CL_mac_j(CL_scale_t(y[15], C164), CL_scale_t(y[15], C165));
+
+
+ /* i=0 */
+ {
+ t0 = CL_add(y[ 0],y[ 8]);
+ t2 = CL_sub(y[ 0],y[ 8]);
+ t4 = CL_add(y[ 4],y[12]);
+ t7 = CL_sub(y[ 4],y[12]);
+
+ input[0] = CL_add(t0,t4);
+ input[4] = CL_msu_j(t2,t7);
+ input[8] = CL_sub(t0,t4);
+ input[12] = CL_mac_j(t2,t7);
+ }
+ /* i=1 */
+ {
+ t0 = CL_add(y[ 1],y[ 9]);
+ t2 = CL_sub(y[ 1],y[ 9]);
+ t4 = CL_add(y[ 5],y[13]);
+ t7 = CL_sub(y[ 5],y[13]);
+
+ input[1] = CL_add(t0,t4);
+ input[5] = CL_msu_j(t2,t7);
+ input[9] = CL_sub(t0,t4);
+ input[13] = CL_mac_j(t2,t7);
+ }
+ /* i=2 */
+ {
+ t0 = CL_add(y[ 2],y[ 10]);
+ t2 = CL_sub(y[ 2],y[ 10]);
+ t4 = CL_add(y[ 6],y[14]);
+ t7 = CL_sub(y[ 6],y[14]);
+
+ input[2] = CL_add(t0,t4);
+ input[6] = CL_msu_j(t2,t7);
+ input[10] = CL_sub(t0,t4);
+ input[14] = CL_mac_j(t2,t7);
+ }
+ /* i=3 */
+ {
+ t0 = CL_add(y[ 3],y[ 11]);
+ t2 = CL_sub(y[ 3],y[ 11]);
+ t4 = CL_add(y[ 7],y[15]);
+ t7 = CL_sub(y[ 7],y[15]);
+
+ input[3] = CL_add(t0,t4);
+ input[7] = CL_msu_j(t2,t7);
+ input[11] = CL_sub(t0,t4);
+ input[15] = CL_mac_j(t2,t7);
+ }
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 16;
+#endif
+
+}
+
+
+/**
+ * \brief Function performs a complex 20-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR20 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 432 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+static void fft20_with_cmplx_data(cmplx *inp_data)
+{
+ cmplx r1,r2,r3,r4;
+ cmplx x0,x1,x2,x3,x4;
+ cmplx t,t0,t1,t2,t3;
+ cmplx y[20];
+ cmplx *y0, *y1,*y2,*y3,*y4;
+
+ y0 = y;
+ y1 = &y[4];
+ y2 = &y[16];
+ y3 = &y[8];
+ y4 = &y[12];
+
+ {
+ x0 = CL_shr(inp_data[0],SCALEFACTOR20);
+ x1 = CL_shr(inp_data[16],SCALEFACTOR20);
+ x2 = CL_shr(inp_data[12],SCALEFACTOR20);
+ x3 = CL_shr(inp_data[8],SCALEFACTOR20);
+ x4 = CL_shr(inp_data[4],SCALEFACTOR20);
+
+ r4 = CL_sub(x1,x4);
+ r2 = CL_sub(x2,x3);
+ r1 = CL_add(x1,x4);
+ r3 = CL_add(x2,x3);
+ t = CL_scale_t(CL_sub(r1,r3),C54);
+ r1 = CL_add(r1,r3);
+ y0[0] = CL_add(x0,r1);
+ r1 = CL_add(y0[0],(CL_shl(CL_scale_t(r1,C55),1)));
+ r3 = CL_sub(r1,t);
+ r1 = CL_add(r1,t);
+ t = CL_scale_t((CL_add(r4,r2)),C51);
+ r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1));
+ r2 = CL_add(t,CL_scale_t(r2,C53));
+
+
+ y1[0] = CL_msu_j(r1,r2);
+ y2[0] = CL_mac_j(r1,r2);
+ y3[0] = CL_mac_j(r3,r4);
+ y4[0] = CL_msu_j(r3,r4);
+ }
+ {
+ x0 = CL_shr(inp_data[5],SCALEFACTOR20);
+ x1 = CL_shr(inp_data[1],SCALEFACTOR20);
+ x2 = CL_shr(inp_data[17],SCALEFACTOR20);
+ x3 = CL_shr(inp_data[13],SCALEFACTOR20);
+ x4 = CL_shr(inp_data[9],SCALEFACTOR20);
+
+ r4 = CL_sub(x1,x4);
+ r2 = CL_sub(x2,x3);
+ r1 = CL_add(x1,x4);
+ r3 = CL_add(x2,x3);
+ t = CL_scale_t(CL_sub(r1,r3),C54);
+ r1 = CL_add(r1,r3);
+ y0[1] = CL_add(x0,r1);
+ r1 = CL_add(y0[1],(CL_shl(CL_scale_t(r1,C55),1)));
+ r3 = CL_sub(r1,t);
+ r1 = CL_add(r1,t);
+ t = CL_scale_t((CL_add(r4,r2)),C51);
+ r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1));
+ r2 = CL_add(t,CL_scale_t(r2,C53));
+
+
+ y1[1] = CL_msu_j(r1,r2);
+ y2[1] = CL_mac_j(r1,r2);
+ y3[1] = CL_mac_j(r3,r4);
+ y4[1] = CL_msu_j(r3,r4);
+ }
+ {
+ x0 = CL_shr(inp_data[10],SCALEFACTOR20);
+ x1 = CL_shr(inp_data[6],SCALEFACTOR20);
+ x2 = CL_shr(inp_data[2],SCALEFACTOR20);
+ x3 = CL_shr(inp_data[18],SCALEFACTOR20);
+ x4 = CL_shr(inp_data[14],SCALEFACTOR20);
+
+ r4 = CL_sub(x1,x4);
+ r2 = CL_sub(x2,x3);
+ r1 = CL_add(x1,x4);
+ r3 = CL_add(x2,x3);
+ t = CL_scale_t(CL_sub(r1,r3),C54);
+ r1 = CL_add(r1,r3);
+ y0[2] = CL_add(x0,r1);
+ r1 = CL_add(y0[2],(CL_shl(CL_scale_t(r1,C55),1)));
+ r3 = CL_sub(r1,t);
+ r1 = CL_add(r1,t);
+ t = CL_scale_t((CL_add(r4,r2)),C51);
+ r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1));
+ r2 = CL_add(t,CL_scale_t(r2,C53));
+
+
+ y1[2] = CL_msu_j(r1,r2);
+ y2[2] = CL_mac_j(r1,r2);
+ y3[2] = CL_mac_j(r3,r4);
+ y4[2] = CL_msu_j(r3,r4);
+ }
+ {
+ x0 = CL_shr(inp_data[15],SCALEFACTOR20);
+ x1 = CL_shr(inp_data[11],SCALEFACTOR20);
+ x2 = CL_shr(inp_data[7],SCALEFACTOR20);
+ x3 = CL_shr(inp_data[3],SCALEFACTOR20);
+ x4 = CL_shr(inp_data[19],SCALEFACTOR20);
+
+ r4 = CL_sub(x1,x4);
+ r2 = CL_sub(x2,x3);
+ r1 = CL_add(x1,x4);
+ r3 = CL_add(x2,x3);
+ t = CL_scale_t(CL_sub(r1,r3),C54);
+ r1 = CL_add(r1,r3);
+ y0[3] = CL_add(x0,r1);
+ r1 = CL_add(y0[3],(CL_shl(CL_scale_t(r1,C55),1)));
+ r3 = CL_sub(r1,t);
+ r1 = CL_add(r1,t);
+ t = CL_scale_t((CL_add(r4,r2)),C51);
+ r4 = CL_add(t,CL_shl(CL_scale_t(r4, C52),1));
+ r2 = CL_add(t,CL_scale_t(r2,C53));
+
+
+ y1[3] = CL_msu_j(r1,r2);
+ y2[3] = CL_mac_j(r1,r2);
+ y3[3] = CL_mac_j(r3,r4);
+ y4[3] = CL_msu_j(r3,r4);
+ }
+
+ {
+ cmplx * ptr_y = y;
+ {
+ cmplx Cy0, Cy1, Cy2, Cy3;
+
+ Cy0 = *ptr_y++;
+ Cy1 = *ptr_y++;
+ Cy2 = *ptr_y++;
+ Cy3 = *ptr_y++;
+
+ /* Pre-additions */
+ t0 = CL_add(Cy0,Cy2);
+ t1 = CL_sub(Cy0,Cy2);
+ t2 = CL_add(Cy1,Cy3);
+ t3 = CL_sub(Cy1,Cy3);
+
+
+ inp_data[0] = CL_add(t0,t2);
+ inp_data[5] = CL_msu_j(t1,t3);
+ inp_data[10] = CL_sub(t0,t2);
+ inp_data[15] = CL_mac_j(t1,t3);
+ }
+
+ {
+ cmplx Cy0, Cy1, Cy2, Cy3;
+
+ Cy0 = *ptr_y++;
+ Cy1 = *ptr_y++;
+ Cy2 = *ptr_y++;
+ Cy3 = *ptr_y++;
+
+ /* Pre-additions */
+ t0 = CL_add(Cy0,Cy2);
+ t1 = CL_sub(Cy0,Cy2);
+ t2 = CL_add(Cy1,Cy3);
+ t3 = CL_sub(Cy1,Cy3);
+
+
+ inp_data[4] = CL_add(t0,t2);
+ inp_data[9] = CL_msu_j(t1,t3);
+ inp_data[14] = CL_sub(t0,t2);
+ inp_data[19] = CL_mac_j(t1,t3);
+ }
+
+ {
+ cmplx Cy0, Cy1, Cy2, Cy3;
+
+ Cy0 = *ptr_y++;
+ Cy1 = *ptr_y++;
+ Cy2 = *ptr_y++;
+ Cy3 = *ptr_y++;
+
+ /* Pre-additions */
+ t0 = CL_add(Cy0,Cy2);
+ t1 = CL_sub(Cy0,Cy2);
+ t2 = CL_add(Cy1,Cy3);
+ t3 = CL_sub(Cy1,Cy3);
+
+
+ inp_data[8] = CL_add(t0,t2);
+ inp_data[13] = CL_msu_j(t1,t3);
+ inp_data[18] = CL_sub(t0,t2);
+ inp_data[3] = CL_mac_j(t1,t3);
+ }
+
+ {
+ cmplx Cy0, Cy1, Cy2, Cy3;
+
+ Cy0 = *ptr_y++;
+ Cy1 = *ptr_y++;
+ Cy2 = *ptr_y++;
+ Cy3 = *ptr_y++;
+
+ /* Pre-additions */
+ t0 = CL_add(Cy0,Cy2);
+ t1 = CL_sub(Cy0,Cy2);
+ t2 = CL_add(Cy1,Cy3);
+ t3 = CL_sub(Cy1,Cy3);
+
+ inp_data[12] = CL_add(t0,t2);
+ inp_data[17] = CL_msu_j(t1,t3);
+ inp_data[2] = CL_sub(t0,t2);
+ inp_data[7] = CL_mac_j(t1,t3);
+ }
+
+ {
+ cmplx Cy0, Cy1, Cy2, Cy3;
+
+ Cy0 = *ptr_y++;
+ Cy1 = *ptr_y++;
+ Cy2 = *ptr_y++;
+ Cy3 = *ptr_y++;
+
+ /* Pre-additions */
+ t0 = CL_add(Cy0,Cy2);
+ t1 = CL_sub(Cy0,Cy2);
+ t2 = CL_add(Cy1,Cy3);
+ t3 = CL_sub(Cy1,Cy3);
+
+
+ inp_data[16] = CL_add(t0,t2);
+ inp_data[1] = CL_msu_j(t1,t3);
+ inp_data[6] = CL_sub(t0,t2);
+ inp_data[11] = CL_mac_j(t1,t3);
+ }
+ }
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 20;
+#endif
+
+}
+
+
+/**
+ * \brief Function performs a complex 30-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR30 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 828 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+
+static void fft30_with_cmplx_data(cmplx * inp)
+{
+ cmplx *l = &inp[0];
+ cmplx *h = &inp[15];
+
+ cmplx z[30], y[15], x[15], rs1, rs2, rs3, rs4, t;
+
+ /* 1. FFT15 stage */
+
+ x[0] = CL_shr(inp[0],SCALEFACTOR30_1);
+ x[1] = CL_shr(inp[18],SCALEFACTOR30_1);
+ x[2] = CL_shr(inp[6],SCALEFACTOR30_1);
+ x[3] = CL_shr(inp[24],SCALEFACTOR30_1);
+ x[4] = CL_shr(inp[12],SCALEFACTOR30_1);
+
+ x[5] = CL_shr(inp[20],SCALEFACTOR30_1);
+ x[6] = CL_shr(inp[8],SCALEFACTOR30_1);
+ x[7] = CL_shr(inp[26],SCALEFACTOR30_1);
+ x[8] = CL_shr(inp[14],SCALEFACTOR30_1);
+ x[9] = CL_shr(inp[2],SCALEFACTOR30_1);
+
+ x[10] = CL_shr(inp[10],SCALEFACTOR30_1);
+ x[11] = CL_shr(inp[28],SCALEFACTOR30_1);
+ x[12] = CL_shr(inp[16],SCALEFACTOR30_1);
+ x[13] = CL_shr(inp[4],SCALEFACTOR30_1);
+ x[14] = CL_shr(inp[22],SCALEFACTOR30_1);
+
+
+ /* 1. FFT5 stage */
+ rs1 = CL_add(x[1],x[4]);
+ rs4 = CL_sub(x[1],x[4]);
+ rs3 = CL_add(x[2],x[3]);
+ rs2 = CL_sub(x[2],x[3]);
+ t = CL_scale_t(CL_sub(rs1,rs3),C54);
+ rs1 = CL_add(rs1,rs3);
+ y[0] = CL_add(x[0],rs1);
+ rs1 = CL_add(y[0],(CL_shl(CL_scale_t(rs1,C55),1)));
+ rs3 = CL_sub(rs1,t);
+ rs1 = CL_add(rs1,t);
+ t = CL_scale_t(CL_add(rs4,rs2),C51);
+ rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1));
+ rs2 = CL_add(t,CL_scale_t(rs2,C53));
+
+ /* combination */
+ y[1] = CL_msu_j(rs1,rs2);
+ y[4] = CL_mac_j(rs1,rs2);
+ y[2] = CL_mac_j(rs3,rs4);
+ y[3] = CL_msu_j(rs3,rs4);
+
+
+ /* 2. FFT5 stage */
+ rs1 = CL_add(x[6],x[9]);
+ rs4 = CL_sub(x[6],x[9]);
+ rs3 = CL_add(x[7],x[8]);
+ rs2 = CL_sub(x[7],x[8]);
+ t = CL_scale_t(CL_sub(rs1,rs3),C54);
+ rs1 = CL_add(rs1,rs3);
+ y[5] = CL_add(x[5],rs1);
+ rs1 = CL_add(y[5],(CL_shl(CL_scale_t(rs1,C55),1)));
+ rs3 = CL_sub(rs1,t);
+ rs1 = CL_add(rs1,t);
+ t = CL_scale_t(CL_add(rs4,rs2),C51);
+ rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1));
+ rs2 = CL_add(t,CL_scale_t(rs2,C53));
+
+ /* combination */
+ y[6] = CL_msu_j(rs1,rs2);
+ y[9] = CL_mac_j(rs1,rs2);
+ y[7] = CL_mac_j(rs3,rs4);
+ y[8] = CL_msu_j(rs3,rs4);
+
+
+ /* 3. FFT5 stage */
+ rs1 = CL_add(x[11],x[14]);
+ rs4 = CL_sub(x[11],x[14]);
+ rs3 = CL_add(x[12],x[13]);
+ rs2 = CL_sub(x[12],x[13]);
+ t = CL_scale_t(CL_sub(rs1,rs3),C54);
+ rs1 = CL_add(rs1,rs3);
+ y[10] = CL_add(x[10],rs1);
+ rs1 = CL_add(y[10],(CL_shl(CL_scale_t(rs1,C55),1)));
+ rs3 = CL_sub(rs1,t);
+ rs1 = CL_add(rs1,t);
+ t = CL_scale_t(CL_add(rs4,rs2),C51);
+ rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1));
+ rs2 = CL_add(t,CL_scale_t(rs2,C53));
+
+ /* combination */
+ y[11] = CL_msu_j(rs1,rs2);
+ y[14] = CL_mac_j(rs1,rs2);
+ y[12] = CL_mac_j(rs3,rs4);
+ y[13] = CL_msu_j(rs3,rs4);
+ /*for (i=10; i<15; i++)
+ {
+ printf("%d,\t %d,\t",y[i].re, y[i].im);
+ }
+ printf("\n\n");*/
+
+
+ /* 1. FFT3 stage */
+ /* real part */
+ rs1 = CL_add(y[5],y[10]);
+ rs2 = CL_scale_t(CL_sub(y[5],y[10]),C31);
+ z[0] = CL_add(y[0],rs1);
+ rs1 = CL_sub(y[0],CL_shr(rs1,1));
+
+ z[10] = CL_mac_j(rs1,rs2);
+ z[5] = CL_msu_j(rs1,rs2);
+
+ /* 2. FFT3 stage */
+ rs1 = CL_add(y[6],y[11]);
+ rs2 = CL_scale_t(CL_sub(y[6],y[11]),C31);
+ z[6] = CL_add(y[1],rs1);
+ rs1 = CL_sub(y[1],CL_shr(rs1,1));
+
+ z[1] = CL_mac_j(rs1,rs2);
+ z[11] = CL_msu_j(rs1,rs2);
+
+
+ /* 3. FFT3 stage */
+ rs1 = CL_add(y[7],y[12]);
+ rs2 = CL_scale_t(CL_sub(y[7],y[12]),C31);
+ z[12] = CL_add(y[2],rs1);
+ rs1 = CL_sub(y[2],CL_shr(rs1,1));
+
+ z[7] = CL_mac_j(rs1,rs2);
+ z[2] = CL_msu_j(rs1,rs2);
+
+
+ /* 4. FFT3 stage */
+ rs1 = CL_add(y[8],y[13]);
+ rs2 = CL_scale_t(CL_sub(y[8],y[13]),C31);
+ z[3] = CL_add(y[3],rs1);
+ rs1 = CL_sub(y[3],CL_shr(rs1,1));
+
+ z[13] = CL_mac_j(rs1,rs2);
+ z[8] = CL_msu_j(rs1,rs2);
+
+
+ /* 5. FFT3 stage */
+ rs1 = CL_add(y[9],y[14]);
+ rs2 = CL_scale_t(CL_sub(y[9],y[14]),C31);
+ z[9] = CL_add(y[4],rs1);
+ rs1 = CL_sub(y[4],CL_shr(rs1,1));
+
+ z[4] = CL_mac_j(rs1,rs2);
+ z[14] = CL_msu_j(rs1,rs2);
+
+ /*for (i=0; i<15; i++)
+ printf("%d,\t %d,\t",z[i].re, z[i].im);
+ printf("\n\n");*/
+
+
+ /* 2. FFT15 stage */
+
+ x[0] = CL_shr(inp[15],SCALEFACTOR30_1);
+ x[1] = CL_shr(inp[3],SCALEFACTOR30_1);
+ x[2] = CL_shr(inp[21],SCALEFACTOR30_1);
+ x[3] = CL_shr(inp[9],SCALEFACTOR30_1);
+ x[4] = CL_shr(inp[27],SCALEFACTOR30_1);
+
+ x[5] = CL_shr(inp[5],SCALEFACTOR30_1);
+ x[6] = CL_shr(inp[23],SCALEFACTOR30_1);
+ x[7] = CL_shr(inp[11],SCALEFACTOR30_1);
+ x[8] = CL_shr(inp[29],SCALEFACTOR30_1);
+ x[9] = CL_shr(inp[17],SCALEFACTOR30_1);
+
+ x[10] = CL_shr(inp[25],SCALEFACTOR30_1);
+ x[11] = CL_shr(inp[13],SCALEFACTOR30_1);
+ x[12] = CL_shr(inp[1],SCALEFACTOR30_1);
+ x[13] = CL_shr(inp[19],SCALEFACTOR30_1);
+ x[14] = CL_shr(inp[7],SCALEFACTOR30_1);
+
+ /* 1. FFT5 stage */
+ rs1 = CL_add(x[1],x[4]);
+ rs4 = CL_sub(x[1],x[4]);
+ rs3 = CL_add(x[2],x[3]);
+ rs2 = CL_sub(x[2],x[3]);
+ t = CL_scale_t(CL_sub(rs1,rs3),C54);
+ rs1 = CL_add(rs1,rs3);
+ y[0] = CL_add(x[0],rs1);
+ rs1 = CL_add(y[0],(CL_shl(CL_scale_t(rs1,C55),1)));
+ rs3 = CL_sub(rs1,t);
+ rs1 = CL_add(rs1,t);
+ t = CL_scale_t(CL_add(rs4,rs2),C51);
+ rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1));
+ rs2 = CL_add(t,CL_scale_t(rs2,C53));
+
+ /* combination */
+ y[1] = CL_msu_j(rs1,rs2);
+ y[4] = CL_mac_j(rs1,rs2);
+ y[2] = CL_mac_j(rs3,rs4);
+ y[3] = CL_msu_j(rs3,rs4);
+
+
+ /* 2. FFT5 stage */
+ rs1 = CL_add(x[6],x[9]);
+ rs4 = CL_sub(x[6],x[9]);
+ rs3 = CL_add(x[7],x[8]);
+ rs2 = CL_sub(x[7],x[8]);
+ t = CL_scale_t(CL_sub(rs1,rs3),C54);
+ rs1 = CL_add(rs1,rs3);
+ y[5] = CL_add(x[5],rs1);
+ rs1 = CL_add(y[5],(CL_shl(CL_scale_t(rs1,C55),1)));
+ rs3 = CL_sub(rs1,t);
+ rs1 = CL_add(rs1,t);
+ t = CL_scale_t(CL_add(rs4,rs2),C51);
+ rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1));
+ rs2 = CL_add(t,CL_scale_t(rs2,C53));
+
+ /* combination */
+ y[6] = CL_msu_j(rs1,rs2);
+ y[9] = CL_mac_j(rs1,rs2);
+ y[7] = CL_mac_j(rs3,rs4);
+ y[8] = CL_msu_j(rs3,rs4);
+
+
+ /* 3. FFT5 stage */
+ rs1 = CL_add(x[11],x[14]);
+ rs4 = CL_sub(x[11],x[14]);
+ rs3 = CL_add(x[12],x[13]);
+ rs2 = CL_sub(x[12],x[13]);
+ t = CL_scale_t(CL_sub(rs1,rs3),C54);
+ rs1 = CL_add(rs1,rs3);
+ y[10] = CL_add(x[10],rs1);
+ rs1 = CL_add(y[10],(CL_shl(CL_scale_t(rs1,C55),1)));
+ rs3 = CL_sub(rs1,t);
+ rs1 = CL_add(rs1,t);
+ t = CL_scale_t(CL_add(rs4,rs2),C51);
+ rs4 = CL_add(t,CL_shl(CL_scale_t(rs4, C52),1));
+ rs2 = CL_add(t,CL_scale_t(rs2,C53));
+
+ /* combination */
+ y[11] = CL_msu_j(rs1,rs2);
+ y[14] = CL_mac_j(rs1,rs2);
+ y[12] = CL_mac_j(rs3,rs4);
+ y[13] = CL_msu_j(rs3,rs4);
+ /*for (i=10; i<15; i++)
+ {
+ printf("%d,\t %d,\t",y[i].re, y[i].im);
+ }
+ printf("\n\n");*/
+
+
+ /* 1. FFT3 stage */
+ /* real part */
+ rs1 = CL_add(y[5],y[10]);
+ rs2 = CL_scale_t(CL_sub(y[5],y[10]),C31);
+ z[15] = CL_add(y[0],rs1);
+ rs1 = CL_sub(y[0],CL_shr(rs1,1));
+
+ z[25] = CL_mac_j(rs1,rs2);
+ z[20] = CL_msu_j(rs1,rs2);
+
+ /* 2. FFT3 stage */
+ rs1 = CL_add(y[6],y[11]);
+ rs2 = CL_scale_t(CL_sub(y[6],y[11]),C31);
+ z[21] = CL_add(y[1],rs1);
+ rs1 = CL_sub(y[1],CL_shr(rs1,1));
+
+ z[16] = CL_mac_j(rs1,rs2);
+ z[26] = CL_msu_j(rs1,rs2);
+
+
+ /* 3. FFT3 stage */
+ rs1 = CL_add(y[7],y[12]);
+ rs2 = CL_scale_t(CL_sub(y[7],y[12]),C31);
+ z[27] = CL_add(y[2],rs1);
+ rs1 = CL_sub(y[2],CL_shr(rs1,1));
+
+ z[22] = CL_mac_j(rs1,rs2);
+ z[17] = CL_msu_j(rs1,rs2);
+
+
+ /* 4. FFT3 stage */
+ rs1 = CL_add(y[8],y[13]);
+ rs2 = CL_scale_t(CL_sub(y[8],y[13]),C31);
+ z[18] = CL_add(y[3],rs1);
+ rs1 = CL_sub(y[3],CL_shr(rs1,1));
+
+ z[28] = CL_mac_j(rs1,rs2);
+ z[23] = CL_msu_j(rs1,rs2);
+
+
+ /* 5. FFT3 stage */
+ rs1 = CL_add(y[9],y[14]);
+ rs2 = CL_scale_t(CL_sub(y[9],y[14]),C31);
+ z[24] = CL_add(y[4],rs1);
+ rs1 = CL_sub(y[4],CL_shr(rs1,1));
+
+ z[19] = CL_mac_j(rs1,rs2);
+ z[29] = CL_msu_j(rs1,rs2);
+
+ /*for (i=0; i<30; i++)
+ printf("%d,\t %d,\t",z[i].re, z[i].im);
+ printf("\n\n");*/
+
+
+ /* 1. FFT2 stage */
+ rs1 = CL_shr(z[0], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[15],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 2. FFT2 stage */
+ rs1 = CL_shr(z[8], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[23],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+
+ /* 3. FFT2 stage */
+ rs1 = CL_shr(z[1], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[16],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+
+ /* 4. FFT2 stage */
+ rs1 = CL_shr(z[9], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[24],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 5. FFT2 stage */
+ rs1 = CL_shr(z[2], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[17],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 6. FFT2 stage */
+ rs1 = CL_shr(z[10], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[25],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 7. FFT2 stage */
+ rs1 = CL_shr(z[3], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[18],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 8. FFT2 stage */
+ rs1 = CL_shr(z[11], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[26],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 9. FFT2 stage */
+ rs1 = CL_shr(z[4], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[19],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 10. FFT2 stage */
+ rs1 = CL_shr(z[12], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[27],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 11. FFT2 stage */
+ rs1 = CL_shr(z[5], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[20],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 12. FFT2 stage */
+ rs1 = CL_shr(z[13], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[28],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 13. FFT2 stage */
+ rs1 = CL_shr(z[6], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[21],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 14. FFT2 stage */
+ rs1 = CL_shr(z[14], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[29],SCALEFACTOR30_2);
+ *h = CL_add(rs1,rs2);
+ *l = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+ /* 15. FFT2 stage */
+ rs1 = CL_shr(z[7], SCALEFACTOR30_2);
+ rs2 = CL_shr(z[22],SCALEFACTOR30_2);
+ *l = CL_add(rs1,rs2);
+ *h = CL_sub(rs1,rs2);
+ l+=1; h+=1;
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 30;
+#endif
+
+}
+
+/**
+ * \brief Function performs a complex 32-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR32 bits.
+ *
+ * WOPS with 32x16 bit multiplications: 752 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+
+
+static void fft32_with_cmplx_data(cmplx * inp)
+{
+ cmplx x[32], y[32], t[32], s[32], temp, temp1;
+ const cmplx_s *pRotVector_32 = ( const cmplx_s *)RotVector_32;
+
+ /* 1. FFT8 stage */
+
+ x[0] = CL_shr(inp[0], SCALEFACTOR32_1);
+ x[1] = CL_shr(inp[4], SCALEFACTOR32_1);
+ x[2] = CL_shr(inp[8], SCALEFACTOR32_1);
+ x[3] = CL_shr(inp[12], SCALEFACTOR32_1);
+ x[4] = CL_shr(inp[16], SCALEFACTOR32_1);
+ x[5] = CL_shr(inp[20], SCALEFACTOR32_1);
+ x[6] = CL_shr(inp[24], SCALEFACTOR32_1);
+ x[7] = CL_shr(inp[28], SCALEFACTOR32_1);
+
+
+ t[0] = CL_add(x[0],x[4]);
+ t[1] = CL_sub(x[0],x[4]);
+ t[2] = CL_add(x[1],x[5]);
+ t[3] = CL_sub(x[1],x[5]);
+ t[4] = CL_add(x[2],x[6]);
+ t[5] = CL_sub(x[2],x[6]);
+ t[6] = CL_add(x[3],x[7]);
+ t[7] = CL_sub(x[3],x[7]);
+
+ /* Pre-additions and core multiplications */
+
+ s[0] = CL_add(t[0], t[4]);
+ s[2] = CL_sub(t[0], t[4]);
+ s[4] = CL_mac_j(t[1], t[5]);
+ s[5] = CL_msu_j(t[1], t[5]);
+ s[1] = CL_add(t[2], t[6]);
+ s[3] = CL_sub(t[2], t[6]);
+ s[3] = CL_mul_j(s[3]);
+
+ temp = CL_add(t[3], t[7]);
+ temp1 = CL_sub(t[3], t[7]);
+ s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81);
+ s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82);
+
+
+ y[0] = CL_add(s[0],s[1]);
+ y[4] = CL_sub(s[0],s[1]);
+ y[2] = CL_sub(s[2],s[3]);
+ y[6] = CL_add(s[2],s[3]);
+ y[3] = CL_add(s[4],s[7]);
+ y[7] = CL_sub(s[4],s[7]);
+ y[1] = CL_add(s[5],s[6]);
+ y[5] = CL_sub(s[5],s[6]);
+
+ /* 2. FFT8 stage */
+
+ x[0] = CL_shr(inp[1], SCALEFACTOR32_1);
+ x[1] = CL_shr(inp[5], SCALEFACTOR32_1);
+ x[2] = CL_shr(inp[9], SCALEFACTOR32_1);
+ x[3] = CL_shr(inp[13], SCALEFACTOR32_1);
+ x[4] = CL_shr(inp[17], SCALEFACTOR32_1);
+ x[5] = CL_shr(inp[21], SCALEFACTOR32_1);
+ x[6] = CL_shr(inp[25], SCALEFACTOR32_1);
+ x[7] = CL_shr(inp[29], SCALEFACTOR32_1);
+
+
+ t[0] = CL_add(x[0],x[4]);
+ t[1] = CL_sub(x[0],x[4]);
+ t[2] = CL_add(x[1],x[5]);
+ t[3] = CL_sub(x[1],x[5]);
+ t[4] = CL_add(x[2],x[6]);
+ t[5] = CL_sub(x[2],x[6]);
+ t[6] = CL_add(x[3],x[7]);
+ t[7] = CL_sub(x[3],x[7]);
+
+ /* Pre-additions and core multiplications */
+
+ s[0] = CL_add(t[0], t[4]);
+ s[2] = CL_sub(t[0], t[4]);
+ s[4] = CL_mac_j(t[1], t[5]);
+ s[5] = CL_msu_j(t[1], t[5]);
+ s[1] = CL_add(t[2], t[6]);
+ s[3] = CL_sub(t[2], t[6]);
+ s[3] = CL_mul_j(s[3]);
+
+ temp = CL_add(t[3], t[7]);
+ temp1 = CL_sub(t[3], t[7]);
+ s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81);
+ s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82);
+
+ /* Post-additions */
+
+ y[8] = CL_add(s[0],s[1]);
+ y[12] = CL_sub(s[0],s[1]);
+ y[10] = CL_sub(s[2],s[3]);
+ y[14] = CL_add(s[2],s[3]);
+ y[11] = CL_add(s[4],s[7]);
+ y[15] = CL_sub(s[4],s[7]);
+ y[9] = CL_add(s[5],s[6]);
+ y[13] = CL_sub(s[5],s[6]);
+
+ /* 3. FFT8 stage */
+
+ x[0] = CL_shr(inp[2], SCALEFACTOR32_1);
+ x[1] = CL_shr(inp[6], SCALEFACTOR32_1);
+ x[2] = CL_shr(inp[10], SCALEFACTOR32_1);
+ x[3] = CL_shr(inp[14], SCALEFACTOR32_1);
+ x[4] = CL_shr(inp[18], SCALEFACTOR32_1);
+ x[5] = CL_shr(inp[22], SCALEFACTOR32_1);
+ x[6] = CL_shr(inp[26], SCALEFACTOR32_1);
+ x[7] = CL_shr(inp[30], SCALEFACTOR32_1);
+
+
+ t[0] = CL_add(x[0],x[4]);
+ t[1] = CL_sub(x[0],x[4]);
+ t[2] = CL_add(x[1],x[5]);
+ t[3] = CL_sub(x[1],x[5]);
+ t[4] = CL_add(x[2],x[6]);
+ t[5] = CL_sub(x[2],x[6]);
+ t[6] = CL_add(x[3],x[7]);
+ t[7] = CL_sub(x[3],x[7]);
+
+ /* Pre-additions and core multiplications */
+
+ s[0] = CL_add(t[0], t[4]);
+ s[2] = CL_sub(t[0], t[4]);
+ s[4] = CL_mac_j(t[1], t[5]);
+ s[5] = CL_msu_j(t[1], t[5]);
+ s[1] = CL_add(t[2], t[6]);
+ s[3] = CL_sub(t[2], t[6]);
+ s[3] = CL_mul_j(s[3]);
+
+ temp = CL_add(t[3], t[7]);
+ temp1 = CL_sub(t[3], t[7]);
+ s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81);
+ s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82);
+
+ /* Post-additions */
+
+ y[16] = CL_add(s[0],s[1]);
+ y[20] = CL_sub(s[0],s[1]);
+ y[18] = CL_sub(s[2],s[3]);
+ y[22] = CL_add(s[2],s[3]);
+ y[19] = CL_add(s[4],s[7]);
+ y[23] = CL_sub(s[4],s[7]);
+ y[17] = CL_add(s[5],s[6]);
+ y[21] = CL_sub(s[5],s[6]);
+
+ /* 4. FFT8 stage */
+
+ x[0] = CL_shr(inp[3], SCALEFACTOR32_1);
+ x[1] = CL_shr(inp[7], SCALEFACTOR32_1);
+ x[2] = CL_shr(inp[11], SCALEFACTOR32_1);
+ x[3] = CL_shr(inp[15], SCALEFACTOR32_1);
+ x[4] = CL_shr(inp[19], SCALEFACTOR32_1);
+ x[5] = CL_shr(inp[23], SCALEFACTOR32_1);
+ x[6] = CL_shr(inp[27], SCALEFACTOR32_1);
+ x[7] = CL_shr(inp[31], SCALEFACTOR32_1);
+
+
+ t[0] = CL_add(x[0],x[4]);
+ t[1] = CL_sub(x[0],x[4]);
+ t[2] = CL_add(x[1],x[5]);
+ t[3] = CL_sub(x[1],x[5]);
+ t[4] = CL_add(x[2],x[6]);
+ t[5] = CL_sub(x[2],x[6]);
+ t[6] = CL_add(x[3],x[7]);
+ t[7] = CL_sub(x[3],x[7]);
+
+
+ /* Pre-additions and core multiplications */
+
+ s[0] = CL_add(t[0], t[4]);
+ s[2] = CL_sub(t[0], t[4]);
+ s[4] = CL_mac_j(t[1], t[5]);
+ s[5] = CL_msu_j(t[1], t[5]);
+ s[1] = CL_add(t[2], t[6]);
+ s[3] = CL_sub(t[2], t[6]);
+ s[3] = CL_mul_j(s[3]);
+
+ temp = CL_add(t[3], t[7]);
+ temp1 = CL_sub(t[3], t[7]);
+ s[6] = CL_scale_t(CL_msu_j(temp1, temp), C81);
+ s[7] = CL_dscale_t(CL_swap_real_imag( CL_msu_j(temp, temp1)), C81, C82);
+
+ /* Post-additions */
+
+ y[24] = CL_add(s[0],s[1]);
+ y[28] = CL_sub(s[0],s[1]);
+ y[26] = CL_sub(s[2],s[3]);
+ y[30] = CL_add(s[2],s[3]);
+ y[27] = CL_add(s[4],s[7]);
+ y[31] = CL_sub(s[4],s[7]);
+ y[25] = CL_add(s[5],s[6]);
+ y[29] = CL_sub(s[5],s[6]);
+
+
+ /* apply twiddle factors */
+ y[0] = CL_shr(y[0],SCALEFACTOR32_2);
+ y[1] = CL_shr(y[1],SCALEFACTOR32_2);
+ y[2] = CL_shr(y[2],SCALEFACTOR32_2);
+ y[3] = CL_shr(y[3],SCALEFACTOR32_2);
+ y[4] = CL_shr(y[4],SCALEFACTOR32_2);
+ y[5] = CL_shr(y[5],SCALEFACTOR32_2);
+ y[6] = CL_shr(y[6],SCALEFACTOR32_2);
+ y[7] = CL_shr(y[7],SCALEFACTOR32_2);
+ y[8] = CL_shr(y[8],SCALEFACTOR32_2);
+ y[16] = CL_shr(y[16],SCALEFACTOR32_2);
+ y[24] = CL_shr(y[24],SCALEFACTOR32_2);
+ y[20] = CL_shr(y[20],SCALEFACTOR32_2);
+
+
+ y[9] = CL_mult_32x16((CL_shr(y[9],1)), pRotVector_32[ 0 ]);
+ y[10] = CL_mult_32x16((CL_shr(y[10],1)), pRotVector_32[ 1 ]);
+ y[11] = CL_mult_32x16((CL_shr(y[11],1)), pRotVector_32[ 2 ]);
+ y[12] = CL_mult_32x16((CL_shr(y[12],1)), pRotVector_32[ 3 ]);
+ y[13] = CL_mult_32x16((CL_shr(y[13],1)), pRotVector_32[ 4 ]);
+ y[14] = CL_mult_32x16((CL_shr(y[14],1)), pRotVector_32[ 5 ]);
+ y[15] = CL_mult_32x16((CL_shr(y[15],1)), pRotVector_32[ 6 ]);
+ y[17] = CL_mult_32x16((CL_shr(y[17],1)), pRotVector_32[ 7 ]);
+ y[18] = CL_mult_32x16((CL_shr(y[18],1)), pRotVector_32[ 8 ]);
+ y[19] = CL_mult_32x16((CL_shr(y[19],1)), pRotVector_32[ 9 ]);
+ y[21] = CL_mult_32x16((CL_shr(y[21],1)), pRotVector_32[ 10 ]);
+ y[22] = CL_mult_32x16((CL_shr(y[22],1)), pRotVector_32[ 11 ]);
+ y[23] = CL_mult_32x16((CL_shr(y[23],1)), pRotVector_32[ 12 ]);
+ y[25] = CL_mult_32x16((CL_shr(y[25],1)), pRotVector_32[ 13 ]);
+ y[26] = CL_mult_32x16((CL_shr(y[26],1)), pRotVector_32[ 14 ]);
+ y[27] = CL_mult_32x16((CL_shr(y[27],1)), pRotVector_32[ 15 ]);
+ y[28] = CL_mult_32x16((CL_shr(y[28],1)), pRotVector_32[ 16 ]);
+ y[29] = CL_mult_32x16((CL_shr(y[29],1)), pRotVector_32[ 17 ]);
+ y[30] = CL_mult_32x16((CL_shr(y[30],1)), pRotVector_32[ 18 ]);
+ y[31] = CL_mult_32x16((CL_shr(y[31],1)), pRotVector_32[ 19 ]);
+
+ /* 1. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[0],y[16]);
+ t[1] = CL_sub(y[0],y[16]);
+ t[2] = CL_add(y[8],y[24]);
+ t[3] = CL_mul_j(CL_sub(y[8],y[24]));
+
+ /* Post-additions */
+ inp[0] = CL_add(t[0], t[2]);
+ inp[8] = CL_sub(t[1], t[3]);
+ inp[16] = CL_sub(t[0], t[2]);
+ inp[24] = CL_add(t[1], t[3]);
+
+ /* 2. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[1],y[17]);
+ t[1] = CL_sub(y[1],y[17]);
+ t[2] = CL_add(y[9],y[25]);
+ t[3] = CL_mul_j(CL_sub(y[9],y[25]));
+
+ /* Post-additions */
+ inp[1] = CL_add(t[0], t[2]);
+ inp[9] = CL_sub(t[1], t[3]);
+ inp[17] = CL_sub(t[0], t[2]);
+ inp[25] = CL_add(t[1], t[3]);
+
+
+ /* 3. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[2],y[18]);
+ t[1] = CL_sub(y[2],y[18]);
+ t[2] = CL_add(y[10],y[26]);
+ t[3] = CL_mul_j(CL_sub(y[10],y[26]));
+
+ /* Post-additions */
+ inp[2] = CL_add(t[0], t[2]);
+ inp[10] = CL_sub(t[1], t[3]);
+ inp[18] = CL_sub(t[0], t[2]);
+ inp[26] = CL_add(t[1], t[3]);
+
+
+ /* 4. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[3],y[19]);
+ t[1] = CL_sub(y[3],y[19]);
+ t[2] = CL_add(y[11],y[27]);
+ t[3] = CL_mul_j(CL_sub(y[11],y[27]));
+
+
+ /* Post-additions */
+ inp[3] = CL_add(t[0], t[2]);
+ inp[11] = CL_sub(t[1], t[3]);
+ inp[19] = CL_sub(t[0], t[2]);
+ inp[27] = CL_add(t[1], t[3]);
+
+
+ /* 5. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_msu_j(y[4],y[20]);
+ t[1] = CL_mac_j(y[4],y[20]);
+ t[2] = CL_add(y[12],y[28]);
+ t[3] = CL_mul_j(CL_sub(y[12],y[28]));
+
+
+ /* Post-additions */
+ inp[4] = CL_add(t[0], t[2]);
+ inp[12] = CL_sub(t[1], t[3]);
+ inp[20] = CL_sub(t[0], t[2]);
+ inp[28] = CL_add(t[1], t[3]);
+
+
+ /* 6. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[5],y[21]);
+ t[1] = CL_sub(y[5],y[21]);
+ t[2] = CL_add(y[13],y[29]);
+ t[3] = CL_mul_j(CL_sub(y[13],y[29]));
+
+
+ /* Post-additions */
+ inp[5] = CL_add(t[0], t[2]);
+ inp[13] = CL_sub(t[1], t[3]);
+ inp[21] = CL_sub(t[0], t[2]);
+ inp[29] = CL_add(t[1], t[3]);
+
+
+ /* 7. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[6],y[22]);
+ t[1] = CL_sub(y[6],y[22]);
+ t[2] = CL_add(y[14],y[30]);
+ t[3] = CL_mul_j(CL_sub(y[14],y[30]));
+
+
+ /* Post-additions */
+ inp[6] = CL_add(t[0], t[2]);
+ inp[14] = CL_sub(t[1], t[3]);
+ inp[22] = CL_sub(t[0], t[2]);
+ inp[30] = CL_add(t[1], t[3]);
+
+
+ /* 8. FFT4 stage */
+
+ /* Pre-additions */
+ t[0] = CL_add(y[7],y[23]);
+ t[1] = CL_sub(y[7],y[23]);
+ t[2] = CL_add(y[15],y[31]);
+ t[3] = CL_mul_j(CL_sub(y[15],y[31]));
+
+
+ /* Post-additions */
+ inp[7] = CL_add(t[0], t[2]);
+ inp[15] = CL_sub(t[1], t[3]);
+ inp[23] = CL_sub(t[0], t[2]);
+ inp[31] = CL_add(t[1], t[3]);
+
+#if (WMOPS)
+ multiCounter[currCounter].CL_move += 32;
+#endif
+
+
+}
+
+
+/**
+ * \brief Combined FFT
+ *
+ * \param [i/o] re real part
+ * \param [i/o] im imag part
+ * \param [i ] W rotation factor
+ * \param [i ] len length of fft
+ * \param [i ] dim1 length of fft1
+ * \param [i ] dim2 length of fft2
+ * \param [i ] sx stride real and imag part
+ * \param [i ] sc stride phase rotation coefficients
+ * \param [tmp] x 32-bit workbuffer of length=2*len
+ * \param [i ] Woff offset for addressing the rotation vector table
+ *
+ * \return void
+ */
+
+static void fftN2(
+ cmplx *__restrict pComplexBuf,
+ const Word16 *__restrict W,
+ Word16 len,
+ Word16 dim1,
+ Word16 dim2,
+ Word16 sc,
+ Word32 *x,
+ Word16 Woff
+)
+{
+ Word16 i, j;
+ cmplx *x_cmplx = (cmplx *)x;
+
+ assert(len == (dim1*dim2));
+ assert((dim1 == 3) || (dim1 == 5) || (dim1 == 8) || (dim1 == 10) || (dim1 == 15) || (dim1 == 16) || (dim1 == 20) || (dim1 == 30) || (dim1 == 32));
+ assert((dim2 == 4) || (dim2 == 8) || (dim2 == 10) || (dim2 == 12) || (dim2 == 16) || (dim2 == 20));
+
+ FOR(i = 0; i
+
+/*-----------------------------------------------------------------*
+* Local functions
+*-----------------------------------------------------------------*/
+
+#define FFT3_ONE_THIRD 21845 /* 1/3 in Q16 */
+
+static void fft5_shift4_16fx( Word16 n1, Word16 *zRe, Word16 *zIm, const Word16 *Idx );
+static void fft64_16fx( Word16 *x, Word16 *y, const Word16 *Idx );
+static void fft32_5_16fx( Word16 *x, Word16 *y, const Word16 *Idx );
+static void cftmdl_16fx(Word16 n, Word16 l, Word16 *a, const Word32 *w);
+static void cftfsub_16fx( Word16 n, Word16 *a, const Word32 *w );
+static void cft1st_16fx(Word16 n, Word16 *a, const Word32 *w);
+static void cftmdl_16fx(Word16 n, Word16 l, Word16 *a, const Word32 *w);
+static void fft5_shift4_16fx( Word16 n1, Word16 *zRe, Word16 *zIm, const Word16 *Idx );
+static void bitrv2_SR_16fx( Word16 n, const Word16 *ip, Word16 *a );
+static void fft64_16fx( Word16 *x, Word16 *y, const Word16 *Idx );
+static void fft5_32_16fx( Word16 *zRe, Word16 *zIm, const Word16 *Idx );
+static void cdftForw_16fx( Word16 n, Word16 *a, const Word16 *ip, const Word32 *w );
+
+#include "math_32.h"
+
+/*-----------------------------------------------------------------*
+* Local functions
+*-----------------------------------------------------------------*/
+static void cdftForw_fx( Word16 n, Word32 *a, const Word16 *ip, const Word16 *w );
+static void bitrv2_SR_fx( Word16 n, const Word16 *ip, Word32 *a );
+static void cftfsub_fx( Word16 n, Word32 *a, const Word16 *w );
+static void cft1st_fx( Word16 n, Word32 *a, const Word16 *w );
+static void cftmdl_fx( Word16 n, Word16 l, Word32 *a, const Word16 *w );
+
+
+void DoRTFTn_fx(
+ Word32 *x, /* i/o : real part of input and output data */
+ Word32 *y, /* i/o : imaginary part of input and output data */
+ const Word16 n /* i : size of the FFT up to 1024 */
+)
+{
+
+ Word16 i;
+ Word32 z[2048], *pt;
+
+ pt = z;
+ FOR ( i=0; i=1 ; i--)
+ {
+ x[i]=*pt++;
+ move16();
+ y[i]=*pt++;
+ move16();
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+ * cdftForw_fx()
+ * Main fuction of Complex Discrete Fourier Transform
+ *-----------------------------------------------------------------*/
+static void cdftForw_fx(
+ Word16 n, /* i : data length of real and imag */
+ Word32 *a, /* i/o : input/output data Q(q)*/
+ const Word16 *ip, /* i : work area for bit reversal */
+ const Word16 *w /* i : cos/sin table Q14*/
+)
+{
+ /* bit reversal */
+ bitrv2_SR_fx(n, ip + 2, a);
+
+ /* Do FFT */
+ cftfsub_fx(n, a, w);
+}
+
+/*-----------------------------------------------------------------*
+ * bitrv2_SR_fx()
+ * Bit reversal
+ *-----------------------------------------------------------------*/
+static void bitrv2_SR_fx(
+ Word16 n, /* i : data length of real and imag */
+ const Word16 *ip, /* i/o : work area for bit reversal */
+ Word32 *a /* i/o : input/output data Q(q)*/
+)
+{
+ Word16 j, j1, k, k1, m, m2;
+ Word16 l;
+ Word32 xr, xi, yr, yi;
+
+ l = n;
+ move16();
+ m = 1;
+ move16();
+
+ WHILE (shl(m, 3) < l)
+ {
+ l = shr(l, 1);
+ m = shl(m, 1);
+ }
+
+ m2 = shl(m, 1);
+ IF (shl(m, 3) == l)
+ {
+ FOR (k = 0; k < m; k++)
+ {
+ FOR (j = 0; j < k; j++)
+ {
+ j1 = add(shl(j, 1), ip[k]);
+ k1 = add(shl(k, 1), ip[j]);
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ j1 = add(j1, m2);
+ k1 = add(k1, shl(m2, 1));
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ j1 = add(j1, m2);
+ k1 = sub(k1, m2);
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ j1 = add(j1, m2);
+ k1 = add(k1, shl(m2, 1));
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ }
+
+ j1 = add(add(shl(k, 1), m2), ip[k]);
+ k1 = add(j1, m2);
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR (k = 1; k < m; k++)
+ {
+ FOR (j = 0; j < k; j++)
+ {
+ j1 = add(shl(j, 1), ip[k]);
+ k1 = add(shl(k, 1), ip[j]);
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ j1 = add(j1, m2);
+ k1 = add(k1, m2);
+ xr = a[j1]; move32();
+ xi = a[j1 + 1]; move32();
+ yr = a[k1]; move32();
+ yi = a[k1 + 1]; move32();
+ a[j1] = yr;
+ move32();
+ a[j1 + 1] = yi;
+ move32();
+ a[k1] = xr;
+ move32();
+ a[k1 + 1] = xi;
+ move32();
+ }
+ }
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+ * cftfsub_fx()
+ * Complex Discrete Fourier Transform
+ *-----------------------------------------------------------------*/
+static void cftfsub_fx(
+ Word16 n, /* i : data length of real and imag */
+ Word32 *a, /* i/o : input/output data Q(q)*/
+ const Word16 *w /* i : cos/sin table Q14*/
+)
+{
+ Word16 j, j1, j2, j3, l;
+ Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+
+ l = 2;
+ move16();
+
+ IF (n > 8)
+ {
+ cft1st_fx(n, a, w);
+ l = 8;
+ move16();
+ WHILE ((shl(l, 2) < n))
+ {
+ cftmdl_fx(n, l, a, w);
+ l = shl(l, 2);
+ }
+ }
+ IF (shl(l, 2) == n)
+ {
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j, l);
+ j2 = add(j1, l);
+ j3 = add(j2, l);
+ x0r = L_add(a[j], a[j1]);
+ x0i = L_add(a[j + 1], a[j1 + 1]);
+ x1r = L_sub(a[j], a[j1]);
+ x1i = L_sub(a[j + 1], a[j1 + 1]);
+ x2r = L_add(a[j2], a[j3]);
+ x2i = L_add(a[j2 + 1], a[j3 + 1]);
+ x3r = L_sub(a[j2], a[j3]);
+ x3i = L_sub(a[j2 + 1], a[j3 + 1]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j2] = L_sub(x0r, x2r);
+ move32();
+ a[j + 1] = L_add(x0i, x2i);
+ move32();
+ a[j2 + 1] = L_sub(x0i, x2i);
+ move32();
+ a[j1] = L_sub(x1r, x3i);
+ move32();
+ a[j1 + 1] = L_add(x1i, x3r);
+ move32();
+ a[j3] = L_add(x1r, x3i);
+ move32();
+ a[j3 + 1] = L_sub(x1i, x3r);
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j, l);
+ x0r = L_sub(a[j], a[j1]);
+ x0i = L_sub(a[j + 1], a[j1 + 1]);
+ a[j] = L_add(a[j], a[j1]);
+ move32();
+ a[j + 1] = L_add(a[j + 1], a[j1 + 1]);
+ move32();
+ a[j1] = x0r;
+ move32();
+ move32();
+ a[j1 + 1] = x0i;
+ move32();
+ move32();
+ }
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+ * cft1st_fx()
+ * Subfunction of Complex Discrete Fourier Transform
+ *-----------------------------------------------------------------*/
+static void cft1st_fx(
+ Word16 n, /* i : data length of real and imag */
+ Word32 *a, /* i/o : input/output data Q(q)*/
+ const Word16 *w /* i : cos/sin table Q14*/
+)
+{
+ Word16 j, k1, k2;
+ Word16 wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
+ Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+
+ x0r = L_add(a[0], a[2]);
+ x0i = L_add(a[1], a[3]);
+ x1r = L_sub(a[0], a[2]);
+ x1i = L_sub(a[1], a[3]);
+ x2r = L_add(a[4], a[6]);
+ x2i = L_add(a[5], a[7]);
+ x3r = L_sub(a[4], a[6]);
+ x3i = L_sub(a[5], a[7]);
+ a[0] = L_add(x0r, x2r);
+ move32();
+ a[1] = L_add(x0i, x2i);
+ move32();
+ a[4] = L_sub(x0r, x2r);
+ move32();
+ a[5] = L_sub(x0i, x2i);
+ move32();
+ a[2] = L_sub(x1r, x3i);
+ move32();
+ a[3] = L_add(x1i, x3r);
+ move32();
+ a[6] = L_add(x1r, x3i);
+ move32();
+ a[7] = L_sub(x1i, x3r);
+ move32();
+
+ wk1r = w[2];
+ move16();
+ x0r = L_add(a[8], a[10]);
+ x0i = L_add(a[9], a[11]);
+ x1r = L_sub(a[8], a[10]);
+ x1i = L_sub(a[9], a[11]);
+ x2r = L_add(a[12], a[14]);
+ x2i = L_add(a[13], a[15]);
+ x3r = L_sub(a[12], a[14]);
+ x3i = L_sub(a[13], a[15]);
+ a[8] = L_add(x0r, x2r);
+ move32();
+ a[9] = L_add(x0i, x2i);
+ move32();
+ a[12] = L_sub(x2i, x0i);
+ move32();
+ a[13] = L_sub(x0r, x2r);
+ move32();
+
+ x0r = L_sub(x1r, x3i);
+ x0i = L_add(x1i ,x3r);
+ a[10] = Mult_32_16(L_shl(L_sub(x0r, x0i), 1), wk1r);
+ move32();
+ a[11] = Mult_32_16(L_shl(L_add(x0r, x0i), 1), wk1r);
+ move32();
+ x0r = L_add(x3i, x1r);
+ x0i = L_sub(x3r,x1i);
+ a[14] = Mult_32_16(L_shl(L_sub(x0i, x0r), 1), wk1r);
+ move32();
+ a[15] = Mult_32_16(L_shl(L_add(x0i, x0r), 1), wk1r);
+ move32();
+
+ k1 = 0;
+ move16();
+ FOR (j = 16; j < n; j += 16)
+ {
+ k1 = add(k1, 2);
+ k2 = shl(k1, 1);
+ wk2r = w[k1];
+ move16();
+ wk2i = w[k1 + 1];
+ move16();
+ wk1r = w[k2];
+ move16();
+ wk1i = w[k2 + 1];
+ move16();
+ wk3r = extract_l(L_sub(L_deposit_l(wk1r), L_shr(L_mult(wk2i, wk1i), 14)));
+ wk3i = extract_l(L_msu0(L_shr(L_mult(wk2i, wk1r), 14), wk1i, 1));
+ x0r = L_add(a[j], a[j + 2]);
+ x0i = L_add(a[j + 1], a[j + 3]);
+ x1r = L_sub(a[j], a[j + 2]);
+ x1i = L_sub(a[j + 1], a[j + 3]);
+ x2r = L_add(a[j + 4], a[j + 6]);
+ x2i = L_add(a[j + 5], a[j + 7]);
+ x3r = L_sub(a[j + 4], a[j + 6]);
+ x3i = L_sub(a[j + 5], a[j + 7]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j + 1] = L_add(x0i, x2i);
+ move32();
+ x0r = L_sub(x0r, x2r);
+ x0i = L_sub(x0i, x2i);
+ a[j + 4] = L_sub(Mult_32_16(L_shl(x0r, 1), wk2r), Mult_32_16(L_shl(x0i, 1), wk2i));
+ move32();
+ a[j + 5] = L_add(Mult_32_16(L_shl(x0i, 1), wk2r), Mult_32_16(L_shl(x0r, 1), wk2i));
+ move32();
+ x0r = L_sub(x1r, x3i);
+ x0i = L_add(x1i, x3r);
+ a[j + 2] = L_sub(Mult_32_16(L_shl(x0r, 1), wk1r), Mult_32_16(L_shl(x0i, 1), wk1i));
+ move32();
+ a[j + 3] = L_add(Mult_32_16(L_shl(x0i, 1), wk1r), Mult_32_16(L_shl(x0r, 1), wk1i));
+ move32();
+ x0r = L_add(x1r, x3i);
+ x0i = L_sub(x1i, x3r);
+ a[j + 6] = L_sub(Mult_32_16(L_shl(x0r, 1), wk3r), Mult_32_16(L_shl(x0i, 1), wk3i));
+ move32();
+ a[j + 7] = L_add(Mult_32_16(L_shl(x0i, 1), wk3r), Mult_32_16(L_shl(x0r, 1), wk3i));
+ move32();
+
+ wk1r = w[k2 + 2];
+ move16();
+ wk1i = w[k2 + 3];
+ move16();
+ wk3r = extract_l(L_sub(L_deposit_l(wk1r), L_shr(L_mult(wk2r, wk1i), 14)));
+ wk3i = extract_l(L_msu0(L_shr(L_mult(wk2r, wk1r), 14), wk1i, 1));
+ x0r = L_add(a[j + 8], a[j + 10]);
+ x0i = L_add(a[j + 9], a[j + 11]);
+ x1r = L_sub(a[j + 8], a[j + 10]);
+ x1i = L_sub(a[j + 9], a[j + 11]);
+ x2r = L_add(a[j + 12], a[j + 14]);
+ x2i = L_add(a[j + 13], a[j + 15]);
+ x3r = L_sub(a[j + 12], a[j + 14]);
+ x3i = L_sub(a[j + 13], a[j + 15]);
+ a[j + 8] = L_add(x0r, x2r);
+ move32();
+ a[j + 9] = L_add(x0i, x2i);
+ move32();
+ x0r = L_sub(x0r, x2r);
+ x0i = L_sub(x0i, x2i);
+ a[j + 12] = L_negate(L_add(Mult_32_16(L_shl(x0r, 1), wk2i), Mult_32_16(L_shl(x0i, 1), wk2r)));
+ move32();
+ a[j + 13] = L_sub(Mult_32_16(L_shl(x0r, 1), wk2r), Mult_32_16(L_shl(x0i, 1), wk2i));
+ move32();
+ x0r = L_sub(x1r, x3i);
+ x0i = L_add(x1i, x3r);
+ a[j + 10] = L_sub(Mult_32_16(L_shl(x0r, 1), wk1r), Mult_32_16(L_shl(x0i, 1), wk1i));
+ move32();
+ a[j + 11] = L_add(Mult_32_16(L_shl(x0i, 1), wk1r), Mult_32_16(L_shl(x0r, 1), wk1i));
+ move32();
+ x0r =L_add(x1r, x3i);
+ x0i =L_sub(x1i, x3r);
+ a[j + 14] = L_sub(Mult_32_16(L_shl(x0r, 1), wk3r), Mult_32_16(L_shl(x0i, 1), wk3i));
+ move32();
+ a[j + 15] = L_add(Mult_32_16(L_shl(x0i, 1), wk3r), Mult_32_16(L_shl(x0r, 1), wk3i));
+ move32();
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+ * cftmdl_fx()
+ * Subfunction of Complex Discrete Fourier Transform
+ *-----------------------------------------------------------------*/
+static void cftmdl_fx(
+ Word16 n, /* i : data length of real and imag */
+ Word16 l, /* i : initial shift for processing */
+ Word32 *a, /* i/o : input/output data Q(Qx+Q_edct)*/
+ const Word16 *w /* i : cos/sin table Q30*/
+)
+{
+ Word16 j, j1, j2, j3, k, k1, k2, m, m2;
+ Word16 wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
+ Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+ Word16 tmp;
+
+ m = shl(l, 2);
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j, l);
+ j2 = add(j1, l);
+ j3 = add(j2, l);
+ x0r = L_add(a[j], a[j1]);
+ x0i = L_add(a[j + 1], a[j1 + 1]);
+ x1r = L_sub(a[j], a[j1]);
+ x1i = L_sub(a[j + 1], a[j1 + 1]);
+ x2r = L_add(a[j2], a[j3]);
+ x2i = L_add(a[j2 + 1], a[j3 + 1]);
+ x3r = L_sub(a[j2], a[j3]);
+ x3i = L_sub(a[j2 + 1], a[j3 + 1]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j + 1] = L_add(x0i, x2i);
+ move32();
+ a[j2] = L_sub(x0r, x2r);
+ move32();
+ a[j2 + 1] =L_sub(x0i, x2i);
+ move32();
+ a[j1] = L_sub(x1r, x3i);
+ move32();
+ a[j1 + 1] = L_add(x1i, x3r);
+ move32();
+ a[j3] = L_add(x1r, x3i);
+ move32();
+ a[j3 + 1] = L_sub(x1i, x3r);
+ move32();
+ }
+
+ wk1r = w[2];
+ move16();
+ tmp = add(l, m);
+ FOR (j = m; j < tmp; j += 2)
+ {
+ j1 = add(j, l);
+ j2 = add(j1, l);
+ j3 = add(j2, l);
+ x0r = L_add(a[j], a[j1]);
+ x0i = L_add(a[j + 1], a[j1 + 1]);
+ x1r = L_sub(a[j], a[j1]);
+ x1i = L_sub(a[j + 1], a[j1 + 1]);
+ x2r = L_add(a[j2], a[j3]);
+ x2i = L_add(a[j2 + 1], a[j3 + 1]);
+ x3r = L_sub(a[j2], a[j3]);
+ x3i = L_sub(a[j2 + 1], a[j3 + 1]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j + 1] = L_add(x0i, x2i);
+ move32();
+ a[j2] = L_sub(x2i, x0i);
+ move32();
+ a[j2 + 1] = L_sub(x0r, x2r);
+ move32();
+ x0r = L_sub(x1r, x3i);
+ x0i = L_add(x1i, x3r);
+ a[j1] = Mult_32_16(L_shl(L_sub(x0r, x0i), 1), wk1r);
+ move32();
+ a[j1 + 1] = Mult_32_16(L_shl(L_add(x0r, x0i), 1), wk1r);
+ move32();
+ x0r = L_add(x3i, x1r);
+ x0i = L_sub(x3r, x1i);
+ a[j3] = Mult_32_16(L_shl(L_sub(x0i, x0r), 1), wk1r);
+ move32();
+ a[j3 + 1] = Mult_32_16(L_shl(L_add(x0r, x0i), 1), wk1r);
+ move32();
+ }
+
+ k1 = 0;
+ move16();
+ m2 = shl(m, 1);
+ FOR (k = m2; k < n; k += m2)
+ {
+ k1 = add(k1, 2);
+ k2 = shl(k1, 1);
+ wk2r = w[k1];
+ move16();
+ wk2i = w[k1 + 1];
+ move16();
+ wk1r = w[k2];
+ move16();
+ wk1i = w[k2 + 1];
+ move16();
+ wk3r = extract_l(L_sub(L_deposit_l(wk1r), L_shr(L_mult(wk2i, wk1i), 14)));
+ wk3i = extract_l(L_msu0(L_shr(L_mult(wk2i, wk1r), 14), wk1i, 1));
+
+ tmp = add(l, k) ;
+ FOR (j = k; j < tmp; j += 2)
+ {
+ j1 = add(j, l);
+ j2 = add(j1, l);
+ j3 = add(j2, l);
+ x0r = L_add(a[j], a[j1]);
+ x0i = L_add(a[j + 1], a[j1 + 1]);
+ x1r = L_sub(a[j], a[j1]);
+ x1i = L_sub(a[j + 1], a[j1 + 1]);
+ x2r = L_add(a[j2], a[j3]);
+ x2i = L_add(a[j2 + 1], a[j3 + 1]);
+ x3r = L_sub(a[j2], a[j3]);
+ x3i = L_sub(a[j2 + 1], a[j3 + 1]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j + 1] = L_add(x0i, x2i);
+ move32();
+ x0r = L_sub(x0r, x2r);
+ x0i = L_sub(x0i, x2i);
+ a[j2] = L_sub(Mult_32_16(L_shl(x0r, 1), wk2r), Mult_32_16(L_shl(x0i, 1), wk2i));
+ move32();
+ a[j2 + 1] = L_add(Mult_32_16(L_shl(x0i, 1), wk2r), Mult_32_16(L_shl(x0r, 1), wk2i));
+ move32();
+ x0r = L_sub(x1r, x3i);
+ x0i = L_add(x1i, x3r);
+ a[j1] = L_sub(Mult_32_16(L_shl(x0r, 1), wk1r), Mult_32_16(L_shl(x0i, 1), wk1i));
+ move32();
+ a[j1 + 1] = L_add(Mult_32_16(L_shl(x0i, 1), wk1r), Mult_32_16(L_shl(x0r, 1), wk1i));
+ move32();
+ x0r = L_add(x1r, x3i);
+ x0i = L_sub(x1i, x3r);
+ a[j3] = L_sub(Mult_32_16(L_shl(x0r, 1), wk3r), Mult_32_16(L_shl(x0i, 1), wk3i));
+ move32();
+ a[j3 + 1] = L_add(Mult_32_16(L_shl(x0i, 1), wk3r), Mult_32_16(L_shl(x0r, 1), wk3i));
+ move32();
+ }
+
+ wk1r = w[k2 + 2];
+ move16();
+ wk1i = w[k2 + 3];
+ move16();
+ wk3r = extract_l(L_sub(L_deposit_l(wk1r), L_shr(L_mult(wk2r, wk1i), 14)));
+ wk3i = extract_l(L_msu0(L_shr(L_mult(wk2r, wk1r), 14), wk1i, 1));
+
+ tmp = add(l, add(k, m));
+ FOR (j = add(k, m); j < tmp; j += 2)
+ {
+ j1 = add(j, l);
+ j2 = add(j1, l);
+ j3 = add(j2, l);
+ x0r = L_add(a[j], a[j1]);
+ x0i = L_add(a[j + 1], a[j1 + 1]);
+ x1r = L_sub(a[j], a[j1]);
+ x1i = L_sub(a[j + 1], a[j1 + 1]);
+ x2r = L_add(a[j2], a[j3]);
+ x2i = L_add(a[j2 + 1], a[j3 + 1]);
+ x3r = L_sub(a[j2], a[j3]);
+ x3i = L_sub(a[j2 + 1], a[j3 + 1]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j + 1] = L_add(x0i, x2i);
+ move32();
+ x0r= L_sub(x0r, x2r);
+ x0i=L_sub(x0i, x2i);
+ a[j2] = L_negate(L_add(Mult_32_16(L_shl(x0r, 1), wk2i), Mult_32_16(L_shl(x0i, 1), wk2r)));
+ move32();
+ a[j2 + 1] = L_sub(Mult_32_16(L_shl(x0r, 1), wk2r), Mult_32_16(L_shl(x0i, 1), wk2i));
+ move32();
+ x0r = L_sub(x1r, x3i);
+ x0i = L_add(x1i, x3r);
+ a[j1] = L_sub(Mult_32_16(L_shl(x0r, 1), wk1r), Mult_32_16(L_shl(x0i, 1), wk1i));
+ move32();
+ a[j1 + 1] = L_add(Mult_32_16(L_shl(x0i, 1), wk1r), Mult_32_16(L_shl(x0r, 1), wk1i));
+ move32();
+ x0r = L_add(x1r, x3i);
+ x0i = L_sub(x1i, x3r);
+ a[j3] = L_sub(Mult_32_16(L_shl(x0r, 1), wk3r), Mult_32_16(L_shl(x0i, 1), wk3i));
+ move32();
+ a[j3 + 1] = L_add(Mult_32_16(L_shl(x0i, 1), wk3r), Mult_32_16(L_shl(x0r, 1), wk3i));
+ move32();
+ }
+ }
+
+ return;
+}
+
+
+static void cftbsub_fx(
+ Word16 n,
+ Word32 *a,
+ const Word16 *w /* i : cos/sin table */
+)
+{
+ Word16 j, j1, j2, j3, l;
+ Word32 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+
+ l = 2;
+ move16();
+ IF (n > 8)
+ {
+ cft1st_fx(n, a, w);
+ l = 8;
+ move16();
+
+ WHILE (LT_16(shl(l, 2), n))
+ {
+ cftmdl_fx(n, l, a, w);
+ l = shl(l, 2);
+ }
+ }
+
+ IF (EQ_16(shl(l, 2), n))
+ {
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j, l);
+ j2 = add(j1, l);
+ j3 = add(j2, l);
+ x0r = L_add(a[j], a[j1]);
+ x0i = L_negate(L_add(a[j + 1], a[j1 + 1]));
+ x1r = L_sub(a[j], a[j1]);
+ x1i = L_sub(a[j1 + 1], a[j + 1]);
+ x2r = L_add(a[j2], a[j3]);
+ x2i = L_add(a[j2 + 1], a[j3 + 1]);
+ x3r = L_sub(a[j2], a[j3]);
+ x3i = L_sub(a[j2 + 1], a[j3 + 1]);
+ a[j] = L_add(x0r, x2r);
+ move32();
+ a[j + 1] = L_sub(x0i, x2i);
+ move32();
+ a[j2] = L_sub(x0r, x2r);
+ move32();
+ a[j2 + 1] = L_add(x0i, x2i);
+ move32();
+ a[j1] = L_sub(x1r, x3i);
+ move32();
+ a[j1 + 1] = L_sub(x1i, x3r);
+ move32();
+ a[j3] = L_add(x1r, x3i);
+ move32();
+ a[j3 + 1] = L_add(x1i, x3r);
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j, l);
+ x0r = L_sub(a[j], a[j1]);
+ x0i = L_sub(a[j1 + 1], a[j + 1]);
+ a[j] = L_add(a[j], a[j1]);
+ move32();
+ a[j + 1] = L_negate(L_add(a[j + 1], a[j1 + 1]));
+ move32();
+ a[j1] = x0r;
+ move32();
+ move32();
+ a[j1 + 1] = x0i;
+ move32();
+ move32();
+ }
+ }
+}
+
+static void rftfsub_fx(
+ Word16 n,
+ Word32 *a,
+ Word16 nc,
+ const Word16 *c
+)
+{
+ Word16 j, k, kk, ks, m, tmp;
+ Word32 xr, xi, yr, yi;
+ Word16 wkr, wki;
+
+ m = shr(n, 1);
+ /*ks = 2 * nc / m; */
+ tmp = shl(nc, 1);
+ ks = 0;
+ move16();
+ WHILE (GE_16(tmp, m))
+ {
+ ks = add(ks, 1);
+ tmp = sub(tmp, m);
+ }
+ kk = 0;
+ move16();
+ FOR (j = 2; j < m; j += 2)
+ {
+ k = sub(n, j);
+ kk = add(kk, ks);
+ wkr = sub(8192, c[nc - kk]);
+ wki = c[kk];
+ move16();
+ xr = L_sub(a[j], a[k]);
+ xi = L_add(a[j + 1], a[k + 1]);
+ yr = L_sub(Mult_32_16(L_shl(xr, 1), wkr), Mult_32_16(L_shl(xi, 1), wki));
+ yi = L_add(Mult_32_16(L_shl(xi, 1), wkr), Mult_32_16(L_shl(xr, 1), wki));
+ a[j] = L_sub(a[j], yr);
+ move32();
+ a[j + 1] = L_sub(a[j + 1], yi);
+ move32();
+ a[k] = L_add(a[k], yr);
+ move32();
+ a[k + 1] = L_sub(a[k + 1], yi);
+ move32();
+ }
+}
+
+
+static void rftbsub_fx(
+ Word16 n,
+ Word32 *a,
+ Word16 nc,
+ const Word16 *c
+)
+{
+ Word16 j, k, kk, ks, m, tmp;
+ Word32 xr, xi, yr, yi;
+ Word16 wkr, wki;
+
+ a[1] = L_negate(a[1]);
+ m = shr(n, 1);
+ /*ks = 2 * nc / m; */
+ tmp = shl(nc, 1);
+ ks = 0;
+ move16();
+ WHILE (GE_16(tmp, m))
+ {
+ ks = add(ks, 1);
+ tmp = sub(tmp, m);
+ }
+ kk = 0;
+ move16();
+ FOR (j = 2; j < m; j += 2)
+ {
+ k = sub(n, j);
+ kk = add(kk, ks);
+ wkr = sub(8192, c[nc - kk]);
+ wki = c[kk];
+ move16();
+ xr = L_sub(a[j], a[k]);
+ xi = L_add(a[j + 1], a[k + 1]);
+ yr = L_add(Mult_32_16(L_shl(xr, 1), wkr), Mult_32_16(L_shl(xi, 1), wki));
+ yi = L_sub(Mult_32_16(L_shl(xi, 1), wkr), Mult_32_16(L_shl(xr, 1), wki));
+ a[j] = L_sub(a[j], yr);
+ move32();
+ a[j + 1] = L_sub(yi, a[j + 1]);
+ move32();
+ a[k] = L_add(a[k], yr);
+ move32();
+ a[k + 1] = L_sub(yi, a[k + 1]);
+ move32();
+ }
+ a[m + 1] = L_negate(a[m + 1]);
+ move32();
+}
+
+
+static void dctsub_fx(
+ Word16 n,
+ Word32 *a,
+ Word16 nc,
+ const Word16 *c
+)
+{
+ Word16 j, k, kk, ks, m, tmp;
+ Word16 wkr, wki;
+ Word32 xr;
+
+ m = shr(n, 1);
+ /*ks = nc / n; */
+ tmp = nc;
+ move16();
+ ks = 0;
+ move16();
+ WHILE (GE_16(tmp, n))
+ {
+ ks = add(ks, 1);
+ tmp = sub(tmp, n);
+ }
+ kk = 0;
+ move16();
+ FOR (j = 1; j < m; j++)
+ {
+ k = sub(n, j);
+ kk = add(kk, ks);
+ wkr = sub(c[kk], c[nc - kk]);
+ wki = add(c[kk], c[nc - kk]);
+ xr = L_sub(Mult_32_16(L_shl(a[j], 1), wki), Mult_32_16(L_shl(a[k], 1), wkr));
+ a[j] = L_add(Mult_32_16(L_shl(a[j], 1), wkr), Mult_32_16(L_shl(a[k], 1), wki));
+ move32();
+ a[k] = xr;
+ move32();
+ }
+ a[m] = Mult_32_16(L_shl(a[m], 1), c[0]);
+}
+
+/*-----------------------------------------------------------------*
+ * edct2_fx()
+ *
+ * Transformation of the signal to DCT domain
+ * OR Inverse EDCT-II for short frames
+ *-----------------------------------------------------------------*/
+
+void edct2_fx(
+ Word16 n,
+ Word16 isgn,
+ Word16 *in,
+ Word32 *a,
+ Word16 *q,
+ const Word16 *ip,
+ const Word16 *w
+)
+{
+ Word16 j, nw, nc;
+ Word32 xr;
+
+ *q = Exp16Array(n, in);
+ *q = add(*q, 6);
+ FOR (j = 0; j < n; j++)
+ {
+ a[j] = L_shl((Word32) in[j], *q);
+ move32();
+ }
+
+ nw = ip[0];
+ move16();
+ if (GT_16(n, shl(nw, 2)))
+ {
+ nw = shr(n, 2);
+ }
+
+ nc = ip[1];
+ move16();
+ if (n > nc)
+ {
+ nc = n;
+ move16();
+ }
+
+ IF (isgn < 0)
+ {
+ xr = a[n - 1];
+ move32();
+ FOR (j = n - 2; j >= 2; j -= 2)
+ {
+ a[j + 1] = L_sub(a[j], a[j - 1]);
+ move32();
+ a[j] = L_add(a[j], a[j - 1]);
+ move32();
+ }
+ a[1] = L_sub(a[0], xr);
+ move32();
+ a[0] = L_add(a[0], xr);
+ move32();
+
+ IF (n > 4)
+ {
+ rftbsub_fx(n, a, nc, w + nw);
+ bitrv2_SR_fx(n, ip + 2, a);
+ cftbsub_fx(n, a, w);
+ }
+ ELSE IF (n == 4)
+ {
+ cftfsub_fx(n, a, w);
+ }
+ }
+
+ IF (isgn >= 0)
+ {
+ a[0] = L_shr(a[0], 1);
+ move32();
+ }
+
+ dctsub_fx(n, a, nc, w + nw);
+
+ IF (isgn >= 0)
+ {
+ IF (n > 4)
+ {
+ bitrv2_SR_fx(n, ip + 2, a);
+ cftfsub_fx(n, a, w);
+ rftfsub_fx(n, a, nc, w + nw);
+ }
+ ELSE IF (n == 4)
+ {
+ cftfsub_fx(n, a, w);
+ }
+ xr = L_sub(a[0], a[1]);
+ a[0] = L_add(a[0], a[1]);
+ move32();
+ FOR (j = 2; j < n; j += 2)
+ {
+ a[j - 1] = L_sub(a[j], a[j + 1]);
+ move32();
+ a[j] = L_add(a[j], a[j + 1]);
+ move32();
+ }
+ a[n - 1] = xr;
+ move32();
+
+ FOR (j = 0; j < n; j ++)
+ {
+ a[j] = L_shr(a[j], 5);
+ move32();
+ }
+ }
+}
+
+
+/*-----------------------------------------------------------------*
+* fft5_shift4()
+* 5-point FFT with 4-point circular shift
+*-----------------------------------------------------------------*/
+
+static void fft5_shift4_16fx(
+ Word16 n1, /* i : length of data */
+ Word16 *zRe, /* i/o : real part of input and output data */
+ Word16 *zIm, /* i/o : imaginary part of input and output data */
+ const Word16 *Idx /* i : pointer of the address table */
+)
+{
+ Word16 T1, To, T8, Tt, T9, Ts, Te, Tp, Th, Tn,T2, T3, T4, T5, T6, T7;
+ Word16 i0,i1,i2,i3,i4;
+ Word32 L_tmp;
+
+ i0 = Idx[0];
+ move16();
+ i1 = Idx[n1];
+ move16();
+ i2 = Idx[n1*2];
+ move16();
+ i3 = Idx[n1*3];
+ move16();
+ i4 = Idx[n1*4];
+ move16();
+
+ T1 = zRe[i0];
+ move16();
+ To = zIm[i0];
+ move16();
+
+ T2 = zRe[i1];
+ move16();
+ T3 = zRe[i4];
+ move16();
+ T4 = add(T2,T3);
+ T5 = zRe[i2];
+ move16();
+ T6 = zRe[i3];
+ move16();
+ T7 = add(T5,T6);
+ T8 = add(T4,T7);
+ Tt = sub(T5,T6);
+ /* T9 = KP559016994 * (T4 - T7); */
+ L_tmp = Mult_32_16(KP559016994_16FX,sub(T4,T7));
+ T9 = round_fx(L_tmp);
+ Ts = sub(T2,T3);
+
+ T2 = zIm[i1];
+ move16();
+ T3 = zIm[i4];
+ move16();
+ T4 = add(T2,T3);
+ T5 = zIm[i2];
+ move16();
+ T6 = zIm[i3];
+ move16();
+ T7 = add(T5,T6);
+ Te = sub(T2,T3);
+ Tp = add(T4,T7);
+ Th = sub(T5,T6);
+ /* Tn = KP559016994 * (T4 - T7); */
+ L_tmp = Mult_32_16(KP559016994_16FX,sub(T4,T7));
+ Tn = round_fx(L_tmp);
+
+ zRe[i0] = add(T1,T8);
+ move16();
+ zIm[i0] = add(To,Tp);
+ move16();
+
+ /* T2 = KP951056516*Te + KP587785252*Th; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Te);
+ L_tmp = Madd_32_16(L_tmp,KP587785252_16FX,Th);
+ T2 = round_fx(L_tmp);
+
+ /*T3 = KP951056516*Th - KP587785252*Te; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Th);
+ L_tmp = Msub_32_16(L_tmp,KP587785252_16FX,Te);
+ T3 = round_fx(L_tmp);
+
+ T6 = sub(T1,shr(T8,2));
+ T4 = add(T9,T6);
+ T5 = sub(T6,T9);
+ zRe[i1] = sub(T4,T2);
+ move16();
+ zRe[i2] = add(T5,T3);
+ move16();
+ zRe[i4] = add(T4,T2);
+ move16();
+ zRe[i3] = sub(T5,T3);
+ move16();
+
+ /* T2 = KP951056516 * Ts + KP587785252 * Tt; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Ts);
+ L_tmp = Madd_32_16(L_tmp,KP587785252_16FX,Tt);
+ T2 = round_fx(L_tmp);
+
+ /* T3 = KP951056516 * Tt - KP587785252 * Ts; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Tt);
+ L_tmp = Msub_32_16(L_tmp,KP587785252_16FX,Ts);
+ T3 = round_fx(L_tmp);
+
+ T6 = sub(To,shr(Tp,2));
+ T4 = add(Tn,T6);
+ T5 = sub(T6,Tn);
+ zIm[i4] = sub(T4,T2);
+ move16();
+ zIm[i2] = sub(T5,T3);
+ move16();
+ zIm[i1] = add(T2,T4);
+ move16();
+ zIm[i3] = add(T3,T5);
+ move16();
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* fft5_32()
+* 5-point FFT called for 32 times
+*-----------------------------------------------------------------*/
+static void fft5_32_16fx(
+ Word16 *zRe, /* i/o : real part of input and output data */
+ Word16 *zIm, /* i/o : imaginary part of input and output data */
+ const Word16 *Idx /* i : pointer of the address table */
+)
+{
+ Word16 T1, To, T8, Tt, T9, Ts, Te, Tp, Th, Tn,T2, T3, T4, T5, T6, T7;
+ Word16 i0,i1,i2,i3,i4;
+ Word32 L_tmp;
+
+ i0 = Idx[0];
+ move16();
+ i1 = Idx[32];
+ move16();
+ i2 = Idx[64];
+ move16();
+ i3 = Idx[96];
+ move16();
+ i4 = Idx[128];
+ move16();
+
+ T1 = zRe[i0];
+ move16();
+ To = zIm[i0];
+ move16();
+
+ T2 = zRe[i1];
+ move16();
+ T3 = zRe[i4];
+ move16();
+ T4 = add(T2, T3);
+ T5 = zRe[i2];
+ move16();
+ T6 = zRe[i3];
+ move16();
+ T7 = add(T5,T6);
+ T8 = add(T4,T7);
+ Tt = sub(T5,T6);
+ /* T9 = KP559016994 * (T4 - T7); */
+ L_tmp = Mult_32_16(KP559016994_16FX,sub(T4,T7));
+ T9 = round_fx(L_tmp);
+ Ts = sub(T2,T3);
+
+ T2 = zIm[i1];
+ move16();
+ T3 = zIm[i4];
+ move16();
+ T4 = add(T2,T3);
+ T5 = zIm[i2];
+ move16();
+ T6 = zIm[i3];
+ move16();
+ T7 = add(T5,T6);
+ Te = sub(T2,T3);
+ Tp = add(T4,T7);
+ Th = sub(T5,T6);
+ L_tmp = Mult_32_16(KP559016994_16FX,sub(T4,T7));
+ Tn = round_fx(L_tmp);
+
+
+
+ zRe[i0] = add(T1,T8);
+ move16();
+ zIm[i0] = add(To,Tp);
+ move32();
+
+
+
+ /*T2 = KP951056516*Te + KP587785252*Th; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Te);
+ L_tmp = Madd_32_16(L_tmp,KP587785252_16FX,Th);
+ T2 = round_fx(L_tmp);
+
+ /*T3 = KP951056516*Th - KP587785252*Te; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Th);
+ L_tmp = Msub_32_16(L_tmp,KP587785252_16FX,Te);
+ T3 = round_fx(L_tmp);
+
+
+
+ T6 = sub(T1,shr(T8,2));
+ T4 = add(T9,T6);
+ T5 = sub(T6,T9);
+ zRe[i3] = sub(T4,T2);
+ move32();
+ zRe[i1] = add(T5,T3);
+ move32();
+ zRe[i2] = add(T4,T2);
+ move32();
+ zRe[i4] = sub(T5,T3);
+ move32();
+
+ /* T2 = KP951056516 * Ts + KP587785252 * Tt; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Ts);
+ L_tmp = Madd_32_16(L_tmp,KP587785252_16FX,Tt);
+ T2 = round_fx(L_tmp);
+
+ /* T3 = KP951056516 * Tt - KP587785252 * Ts; */
+ L_tmp = Mult_32_16(KP951056516_16FX,Tt);
+ L_tmp = Msub_32_16(L_tmp,KP587785252_16FX,Ts);
+ T3 = round_fx(L_tmp);
+
+ T6 = sub(To,shr(Tp,2));
+ T4 = add(Tn,T6);
+ T5 = sub(T6,Tn);
+ zIm[i2] = sub(T4,T2);
+ move16();
+ zIm[i1] = sub(T5,T3);
+ move16();
+ zIm[i3] = add(T2,T4);
+ move16();
+ zIm[i4] = add(T3,T5);
+ move16();
+
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* fft64()
+* 64-point FFT
+*-----------------------------------------------------------------*/
+static void fft64_16fx(
+ Word16 *x, /* i/o : real part of input and output data */
+ Word16 *y, /* i/o : imaginary part of input and output data */
+ const Word16 *Idx /* i : pointer of the address table */
+)
+{
+ Word16 i,id,jd;
+ Word16 z[128];
+ move16();/*penalty for 1 ptr init */
+ FOR ( i=0; i<64; i++ )
+ {
+ id = Idx[i];
+ move16();
+ z[2*i] = x[id];
+ move16();
+ z[2*i+1] = y[id];
+ move16();
+ }
+
+ cdftForw_16fx(128, z, Ip_fft64_16fx, w_fft128_16fx);
+
+ move16();/*penalty for 1 ptr init */
+ FOR( i=0; i<64 ; i++)
+ {
+ jd = Odx_fft64_16fx[i];
+ move16();
+ id = Idx[jd];
+ move16();
+ x[id]=z[2*i];
+ move16();
+ y[id]=z[2*i+1];
+ move16();
+ }
+
+ return;
+}
+
+
+/*-----------------------------------------------------------------*
+* fft32_5()
+* 32-point FFT called for 5 times
+*-----------------------------------------------------------------*/
+static void fft32_5_16fx(
+ Word16 *x, /* i/o : real part of input and output data */
+ Word16 *y, /* i/o : imaginary part of input and output data */
+ const Word16 *Idx /* i : pointer of the address table */
+)
+{
+ Word16 i,id,jd;
+ Word16 z[64];
+
+ move16();/*penalty for 1 ptr init */
+ FOR( i=0; i<32; i++ )
+ {
+ id = Idx[i];
+ move16();
+ z[2*i] = x[id];
+ move16();
+ z[2*i+1] = y[id];
+ move16();
+ }
+
+ cdftForw_16fx(64,z,Ip_fft32_16fx,w_fft32_16fx);
+
+ move16();/*penalty for 1 ptr init */
+ FOR( i=0; i<32; i++ )
+ {
+ jd = Odx_fft32_5[i];
+ move16();
+ id = Idx[jd];
+ move16();
+ x[id]=z[2*i];
+ move16();
+ y[id]=z[2*i+1];
+ move16();
+ }
+
+ return;
+}
+
+
+
+/*-----------------------------------------------------------------*
+* DoRTFT160()
+* a low complexity 2-dimensional DFT of 160 points
+*-----------------------------------------------------------------*/
+void DoRTFT160_16fx(
+ Word16 x[], /* i/o : real part of input and output data */
+ Word16 y[] /* i/o : imaginary part of input and output data */
+)
+{
+ Word16 j;
+
+ /* Applying 32-point FFT for 5 times based on the address table Idx_dortft160 */
+ FOR(j=0; j<5; j++)
+ {
+ fft32_5_16fx(x,y,Idx_dortft160+shl(j,5)/*32*j*/);
+ }
+
+ /* Applying 5-point FFT for 32 times based on the address table Idx_dortft160 */
+ FOR(j=0; j<32; j++)
+ {
+ fft5_32_16fx(x,y,Idx_dortft160+j);
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* DoRTFT320()
+* a low complexity 2-dimensional DFT of 320 points
+*-----------------------------------------------------------------*/
+void DoRTFT320_16fx(
+ Word16 *x, /* i/o : real part of input and output data */
+ Word16 *y /* i/o : imaginary part of input and output data */
+)
+{
+ Word16 j;
+
+ /* Applying 64-point FFT for 5 times based on the address table Idx_dortft160 */
+ FOR(j=0; j<5; j++)
+ {
+ fft64_16fx(x,y,Idx_dortft320_16fx+shl(j,6)/*64*j*/);
+ }
+
+ /* Applying 5-point FFT for 64 times based on the address table Idx_dortft160 */
+ FOR(j=0; j<64; j++)
+ {
+ fft5_shift4_16fx(64,x,y,Idx_dortft320_16fx+j);
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* DoRTFT128()
+* FFT with 128 points
+*-----------------------------------------------------------------*/
+void DoRTFT128_16fx(
+ Word16 *x, /* i/o : real part of input and output data Q(Qx+Q_edct)*/
+ Word16 *y /* i/o : imaginary part of input and output data Q(Qx+Q_edct)*/
+)
+{
+
+ Word16 i;
+ Word16 z[256];
+
+ move16();/*penalty for 1 ptr init */
+ FOR ( i=0; i<128; i++ )
+ {
+ z[2*i] = x[i];
+ move16();
+ z[2*i+1] = y[i];
+ move16();
+ }
+
+ cdftForw_16fx(256,z,Ip_fft128_16fx,w_fft128_16fx);
+
+ x[0]=z[0];
+ move16();
+ y[0]=z[1];
+ move16();
+ move16();/*penalty for 1 ptr init */
+ move16();/*penalty for 1 ptr init */
+ FOR( i=1; i<128 ; i++)
+ {
+ x[128-i]=z[2*i];
+ move16();
+ y[128-i]=z[2*i+1];
+ move16();
+ }
+
+ return;
+}
+/*-----------------------------------------------------------------*
+* cdftForw()
+* Main fuction of Complex Discrete Fourier Transform
+*-----------------------------------------------------------------*/
+static void cdftForw_16fx(
+ Word16 n, /* i : data length of real and imag */
+ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/
+ const Word16 *ip, /* i : work area for bit reversal */
+ const Word32 *w /* i : cos/sin table Q30*/
+)
+{
+ /* bit reversal */
+ bitrv2_SR_16fx(n, ip + 2, a);
+
+ /* Do FFT */
+ cftfsub_16fx(n, a, w);
+}
+
+/*-----------------------------------------------------------------*
+* bitrv2_SR()
+* Bit reversal
+*-----------------------------------------------------------------*/
+static void bitrv2_SR_16fx(
+ Word16 n, /* i : data length of real and imag */
+ const Word16 *ip, /* i/o : work area for bit reversal */
+ Word16 *a /* i/o : input/output data Q(Qx+Q_edct)*/
+)
+{
+ Word16 j, j1, k, k1, m, m2;
+ Word16 l;
+ Word16 xr, xi, yr, yi;
+
+ l = n;
+ move16();
+ m = 1;
+ move16();
+
+ WHILE (LT_16(shl(m,3),l))
+ {
+ l = shr(l,1);
+ m = shl(m,1);
+ }
+
+ m2 = shl(m,1);
+ IF (EQ_16(shl(m, 3),l))
+ {
+ FOR (k = 0; k < m; k++)
+ {
+ FOR (j = 0; j < k; j++)
+ {
+ j1 = add(shl(j,1),ip[k]);
+ k1 = add(shl(k,1),ip[j]);
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ j1 = add(j1,m2);
+ k1 = add(k1,shl(m2,1));
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ j1 = add(j1,m2);
+ k1 = sub(k1,m2);
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ j1 = add(j1,m2);
+ k1 = add(k1,shl(m2,1));
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ }
+
+ j1 = add(add(shl(k,1),m2),ip[k]);
+ k1 = add(j1,m2);
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR (k = 1; k < m; k++)
+ {
+ FOR (j = 0; j < k; j++)
+ {
+ j1 = add(shl(j,1),ip[k]);
+ k1 = add(shl(k,1),ip[j]);
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ j1 = add(j1,m2);
+ k1 = add(k1,m2);
+ xr = a[j1];
+ move16();
+ xi = a[j1 + 1];
+ move16();
+ yr = a[k1];
+ move16();
+ yi = a[k1 + 1];
+ move16();
+ a[j1] = yr;
+ move16();
+ a[j1 + 1] = yi;
+ move16();
+ a[k1] = xr;
+ move16();
+ a[k1 + 1] = xi;
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* cftfsub()
+* Complex Discrete Fourier Transform
+*-----------------------------------------------------------------*/
+static void cftfsub_16fx(
+ Word16 n, /* i : data length of real and imag */
+ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/
+ const Word32 *w /* i : cos/sin table Q30*/
+)
+{
+ Word16 j, j1, j2, j3, l;
+ Word16 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+
+ l = 2;
+ move16();
+ IF (GT_16(n,8))
+ {
+ cft1st_16fx(n, a, w);
+ l = 8;
+ move16();
+ WHILE (LT_16(shl(l, 2),n))
+ {
+ cftmdl_16fx(n, l, a, w);
+ l = shl(l,2);
+ }
+ }
+
+ IF (EQ_16(shl(l,2),n))
+ {
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j,l);
+ j2 = add(j1,l);
+ j3 = add(j2,l);
+ x0r = add(a[j],a[j1]);
+ x0i = add(a[j + 1],a[j1 + 1]);
+ x1r = sub(a[j],a[j1]);
+ x1i = sub(a[j + 1],a[j1 + 1]);
+ x2r = add(a[j2],a[j3]);
+ x2i = add(a[j2 + 1],a[j3 + 1]);
+ x3r = sub(a[j2],a[j3]);
+ x3i = sub(a[j2 + 1],a[j3 + 1]);
+ a[j] = add(x0r,x2r);
+ move16();
+ a[j + 1] = add(x0i,x2i);
+ move16();
+ a[j2] = sub(x0r,x2r);
+ move16();
+ a[j2 + 1] = sub(x0i,x2i);
+ move16();
+ a[j1] = sub(x1r,x3i);
+ move16();
+ a[j1 + 1] = add(x1i,x3r);
+ move16();
+ a[j3] = add(x1r,x3i);
+ move16();
+ a[j3 + 1] = sub(x1i,x3r);
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j,l);
+ x0r = sub(a[j],a[j1]);
+ x0i = sub(a[j + 1],a[j1 + 1]);
+ a[j] = add(a[j],a[j1]);
+ move16();
+ a[j + 1] = add(a[j + 1],a[j1 + 1]);
+ move16();
+ a[j1] = x0r;
+ move16();
+ a[j1 + 1] = x0i;
+ move16();
+ }
+ }
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* cft1st()
+* Subfunction of Complex Discrete Fourier Transform
+*-----------------------------------------------------------------*/
+static void cft1st_16fx(
+ Word16 n, /* i : data length of real and imag */
+ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/
+ const Word32 *w /* i : cos/sin table Q30*/
+)
+{
+ Word16 j, k1, k2;
+ Word32 wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
+ Word16 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+ Word16 tmp;
+ Word32 L_tmp;
+
+ x0r = add(a[0],a[2]);
+ x0i = add(a[1],a[3]);
+ x1r = sub(a[0],a[2]);
+ x1i = sub(a[1],a[3]);
+ x2r = add(a[4],a[6]);
+ x2i = add(a[5],a[7]);
+ x3r = sub(a[4],a[6]);
+ x3i = sub(a[5],a[7]);
+ a[0] = add(x0r,x2r);
+ move16();
+ a[1] = add(x0i,x2i);
+ move16();
+ a[4] = sub(x0r,x2r);
+ move16();
+ a[5] = sub(x0i,x2i);
+ move16();
+ a[2] = sub(x1r,x3i);
+ move16();
+ a[3] = add(x1i,x3r);
+ move16();
+ a[6] = add(x1r,x3i);
+ move16();
+ a[7] = sub(x1i,x3r);
+ move16();
+
+ wk1r = w[2];
+ move32();
+
+ x0r = add(a[8],a[10]);
+ x0i = add(a[9],a[11]);
+ x1r = sub(a[8],a[10]);
+ x1i = sub(a[9],a[11]);
+ x2r = add(a[12],a[14]);
+ x2i = add(a[13],a[15]);
+ x3r = sub(a[12],a[14]);
+ x3i = sub(a[13],a[15]);
+ a[8] = add(x0r,x2r);
+ move16();
+ a[9] = add(x0i,x2i);
+ move16();
+ a[12] = sub(x2i,x0i);
+ move16();
+ a[13] = sub(x0r,x2r);
+ move16();
+
+ x0r = sub(x1r,x3i);
+ x0i = add(x1i,x3r);
+ tmp = sub(x0r,x0i);
+ L_tmp = Mult_32_16(wk1r,tmp); /*Q(15+Qx+Q_edct) */
+
+ a[10] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ tmp = add(x0r,x0i);
+ L_tmp = Mult_32_16(wk1r,tmp); /*Q(15+Qx+Q_edct) */
+ a[11] = round_fx(L_shl(L_tmp,1)); /* Q(Qx+Q_edct) */
+
+ x0r = add(x3i,x1r);
+ x0i = sub(x3r,x1i);
+ tmp = sub(x0i,x0r);
+ L_tmp = Mult_32_16(wk1r,tmp); /*Q(15+Qx+Q_edct) */
+ a[14] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ tmp = add(x0i,x0r);
+ L_tmp = Mult_32_16(wk1r,tmp); /*Q(15+Qx+Q_edct) */
+ a[15] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ k1 = 0;
+ move16();
+
+ FOR (j = 16; j < n; j += 16)
+ {
+ k1 = add(k1,2);
+ k2 = shl(k1,1);
+
+ wk2r = w[k1]; move32();
+ wk2i = w[k1 + 1]; move32();
+ wk1r = w[k2]; move32();
+ wk1i = w[k2 + 1]; move32();
+
+ L_tmp = L_shl(Mult_32_32(wk2i,wk1i),1);/*Q29 */
+ wk3r = L_sub(wk1r,L_shl(L_tmp,1));/*Q30 */
+
+ L_tmp = L_shl(Mult_32_32(wk2i,wk1r),1);/*Q29 */
+ wk3i = L_sub(L_shl(L_tmp,1),wk1i);/*Q30 */
+
+ x0r = add(a[j],a[j + 2]);
+ x0i = add(a[j + 1],a[j + 3]);
+ x1r = sub(a[j],a[j + 2]);
+ x1i = sub(a[j + 1],a[j + 3]);
+ x2r = add(a[j + 4],a[j + 6]);
+ x2i = add(a[j + 5],a[j + 7]);
+ x3r = sub(a[j + 4],a[j + 6]);
+ x3i = sub(a[j + 5],a[j + 7]);
+ a[j] = add(x0r,x2r);
+ move16();
+ a[j + 1] = add(x0i,x2i);
+ move16();
+
+ x0r = sub(x0r,x2r);
+ x0i = sub(x0i,x2i);
+ L_tmp = Mult_32_16(wk2r,x0r);/*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk2i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j + 4] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk2r,x0i);/*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk2i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j + 5] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = sub(x1r,x3i);
+ x0i = add(x1i,x3r);
+ L_tmp = Mult_32_16(wk1r,x0r);/*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk1i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j + 2] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk1r,x0i);/*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk1i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j + 3] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = add(x1r,x3i);
+ x0i = sub(x1i,x3r);
+ L_tmp = Mult_32_16(wk3r,x0r); /*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk3i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j + 6] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk3r,x0i); /*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk3i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j + 7] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ wk1r = w[k2 + 2]; move32();
+ wk1i = w[k2 + 3]; move32();
+ L_tmp = L_shl(Mult_32_32(wk2r,wk1i),1);/*Q29 */
+ wk3r = L_sub(wk1r,L_shl(L_tmp,1)); /*Q30 */
+
+ L_tmp = L_shl(Mult_32_32(wk2r,wk1r),1);/*Q29 */
+ wk3i = L_sub(L_shl(L_tmp,1),wk1i); /*Q30 */
+
+ x0r = add(a[j + 8],a[j + 10]);
+ x0i = add(a[j + 9],a[j + 11]);
+ x1r = sub(a[j + 8],a[j + 10]);
+ x1i = sub(a[j + 9],a[j + 11]);
+ x2r = add(a[j + 12],a[j + 14]);
+ x2i = add(a[j + 13],a[j + 15]);
+ x3r = sub(a[j + 12],a[j + 14]);
+ x3i = sub(a[j + 13],a[j + 15]);
+ a[j + 8] = add(x0r,x2r);
+ move16();
+ a[j + 9] = add(x0i,x2i);
+ move16();
+
+ x0r = sub(x0r,x2r);
+ x0i = sub(x0i,x2i);
+ tmp = negate(x0r);
+ L_tmp = Mult_32_16(wk2i,tmp);/*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk2r,x0i); /*Q(15+Qx+Q_edct) */
+ a[j + 12] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ tmp = negate(x0i);
+ L_tmp = Mult_32_16(wk2i,tmp);/*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk2r,x0r); /*Q(15+Qx+Q_edct) */
+ a[j + 13] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = sub(x1r,x3i);
+ x0i = add(x1i,x3r);
+ L_tmp = Mult_32_16(wk1r,x0r);/*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk1i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j + 10] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk1r,x0i);/*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk1i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j + 11] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = add(x1r,x3i);
+ x0i = sub(x1i,x3r);
+
+ L_tmp = Mult_32_16(wk3r,x0r); /*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk3i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j + 14] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk3r,x0i); /*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk3i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j + 15] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------*
+* cftmdl()
+* Subfunction of Complex Discrete Fourier Transform
+*-----------------------------------------------------------------*/
+static void cftmdl_16fx(
+ Word16 n, /* i : data length of real and imag */
+ Word16 l, /* i : initial shift for processing */
+ Word16 *a, /* i/o : input/output data Q(Qx+Q_edct)*/
+ const Word32 *w /* i : cos/sin table Q30*/
+)
+{
+ Word16 j, j1, j2, j3, k, k1, k2, m, m2;
+ Word32 wk1r, wk1i, wk2r, wk2i, wk3r, wk3i;
+ Word16 x0r, x0i, x1r, x1i, x2r, x2i, x3r, x3i;
+ Word16 tmp, tmp2;
+ Word32 L_tmp;
+ Word32 L_x0r, L_x0i;
+
+ m = shl(l, 2);
+ move16();
+ FOR (j = 0; j < l; j += 2)
+ {
+ j1 = add(j,l);
+ j2 = add(j1,l);
+ j3 = add(j2,l);
+ x0r = add(a[j],a[j1]);
+ x0i = add(a[j + 1],a[j1 + 1]);
+ x1r = sub(a[j],a[j1]);
+ x1i = sub(a[j + 1],a[j1 + 1]);
+ x2r = add(a[j2],a[j3]);
+ x2i = add(a[j2 + 1],a[j3 + 1]);
+ x3r = sub(a[j2],a[j3]);
+ x3i = sub(a[j2 + 1],a[j3 + 1]);
+ a[j] = add(x0r,x2r);
+ move16();
+ a[j + 1] = add(x0i,x2i);
+ move16();
+ a[j2] = sub(x0r,x2r);
+ move16();
+ a[j2 + 1] = sub(x0i,x2i);
+ move16();
+ a[j1] = sub(x1r,x3i);
+ move16();
+ a[j1 + 1] = add(x1i,x3r);
+ move16();
+ a[j3] = add(x1r,x3i);
+ move16();
+ a[j3 + 1] = sub(x1i,x3r);
+ move16();
+ }
+
+ wk1r = w[2];
+ move32();
+ tmp2 = add(l,m);
+ FOR (j = m; j < tmp2; j += 2)
+ {
+ j1 = add(j,l);
+ j2 = add(j1,l);
+ j3 = add(j2,l);
+ x0r = add(a[j],a[j1]);
+ x0i = add(a[j + 1],a[j1 + 1]);
+ x1r = sub(a[j],a[j1]);
+ x1i = sub(a[j + 1],a[j1 + 1]);
+ x2r = add(a[j2],a[j3]);
+ x2i = add(a[j2 + 1],a[j3 + 1]);
+ x3r = sub(a[j2],a[j3]);
+ x3i = sub(a[j2 + 1],a[j3 + 1]);
+ a[j] = add(x0r,x2r);
+ move16();
+ a[j + 1] = add(x0i,x2i);
+ move16();
+ a[j2] = sub(x2i,x0i);
+ move16();
+ a[j2 + 1] = sub(x0r,x2r);
+ move16();
+
+ x0r = sub(x1r,x3i);
+ x0i = add(x1i,x3r);
+ tmp = sub(x0r,x0i);
+ L_tmp = Mult_32_16(wk1r,tmp);/*Q(15+Qx+Q_edct) */
+ a[j1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ tmp = add(x0r,x0i);
+ L_tmp = Mult_32_16(wk1r,tmp); /*Q(15+Qx+Q_edct) */
+ a[j1 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = add(x3i,x1r);
+ x0i = sub(x3r,x1i);
+ tmp = sub(x0i,x0r);
+ L_tmp = Mult_32_16(wk1r,tmp);/*Q(15+Qx+Q_edct) */
+ a[j3] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ tmp = add(x0i,x0r);
+ L_tmp = Mult_32_16(wk1r,tmp); /*Q(15+Qx+Q_edct) */
+ a[j3 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+ }
+
+ k1 = 0;
+ move16();
+ m2 = shl(m,1);
+ FOR (k = m2; k < n; k += m2)
+ {
+ k1 = add(k1,2);
+ k2 = shl(k1,1);
+ wk2r = w[k1]; move32();
+ wk2i = w[k1 + 1]; move32();
+ wk1r = w[k2]; move32();
+ wk1i = w[k2 + 1]; move32();
+ L_tmp = L_shl(Mult_32_32(wk2i,wk1i),1);/*Q29 */
+ wk3r = L_sub(wk1r,L_shl(L_tmp,1));/*Q30 */
+
+ L_tmp = L_shl(Mult_32_32(wk2i,wk1r),1);/*Q29 */
+ wk3i = L_sub(L_shl(L_tmp,1),wk1i);/*Q30 */
+
+ tmp2 = add(l,k);
+ FOR (j = k; j < tmp2; j += 2)
+ {
+ j1 = add(j,l);
+ j2 = add(j1,l);
+ j3 = add(j2,l);
+ x0r = add(a[j],a[j1]);
+ x0i = add(a[j + 1],a[j1 + 1]);
+ x1r = sub(a[j],a[j1]);
+ x1i = sub(a[j + 1],a[j1 + 1]);
+ x2r = add(a[j2],a[j3]);
+ x2i = add(a[j2 + 1],a[j3 + 1]);
+ x3r = sub(a[j2],a[j3]);
+ x3i = sub(a[j2 + 1],a[j3 + 1]);
+ a[j] = add(x0r,x2r);
+ move16();
+ a[j + 1] = add(x0i,x2i);
+ move16();
+
+ x0r = sub(x0r,x2r);
+ x0i = sub(x0i,x2i);
+
+ L_tmp = Mult_32_16(wk2r,x0r); /*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk2i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j2] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk2r,x0i); /*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk2i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j2 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = sub(x1r,x3i);
+ x0i = add(x1i,x3r);
+
+ L_tmp = Mult_32_16(wk1r,x0r); /*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk1i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk1r,x0i); /*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk1i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j1 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_x0r = L_add((Word32) x1r, (Word32) x3i);
+ L_x0i = L_sub((Word32) x1i, (Word32) x3r);
+ x0r = extract_l(L_x0r);
+ x0i = extract_l(L_x0i);
+ L_tmp = Mult_32_16(wk3r,x0r); /*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk3i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j3] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk3r,x0i); /*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk3i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j3 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+ }
+
+ wk1r = w[k2 + 2];
+ move32();
+ wk1i = w[k2 + 3];
+ move32();
+ L_tmp = L_shl(Mult_32_32(wk2r,wk1i),1);/*Q29 */
+ wk3r = L_sub(wk1r,L_shl(L_tmp,1)); /*Q30 */
+
+ L_tmp = L_shl(Mult_32_32(wk2r,wk1r),1);/*Q29 */
+ wk3i = L_sub(L_shl(L_tmp,1),wk1i); /*Q30 */
+
+ tmp2 = add(l,add(k,m));
+ FOR (j = add(k,m); j < tmp2; j += 2)
+ {
+ j1 = add(j,l);
+ j2 = add(j1,l);
+ j3 = add(j2,l);
+ x0r = add(a[j],a[j1]);
+ x0i = add(a[j + 1],a[j1 + 1]);
+ x1r = sub(a[j],a[j1]);
+ x1i = sub(a[j + 1],a[j1 + 1]);
+ x2r = add(a[j2],a[j3]);
+ x2i = add(a[j2 + 1],a[j3 + 1]);
+ x3r = sub(a[j2],a[j3]);
+ x3i = sub(a[j2 + 1],a[j3 + 1]);
+ a[j] = add(x0r,x2r);
+ move16();
+ a[j + 1] = add(x0i,x2i);
+ move16();
+
+ x0r = sub(x0r,x2r);
+ x0i = sub(x0i,x2i);
+
+ tmp = negate(x0r);
+ L_tmp = Mult_32_16(wk2i,tmp);/*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk2r,x0i); /*Q(15+Qx+Q_edct) */
+ a[j2] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ tmp = negate(x0i);
+ L_tmp = Mult_32_16(wk2i,tmp);/*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk2r,x0r); /*Q(15+Qx+Q_edct) */
+ a[j2 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = sub(x1r,x3i);
+ x0i = add(x1i,x3r);
+
+ L_tmp = Mult_32_16(wk1r,x0r);/*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk1i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk1r,x0i);/*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk1i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j1 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ x0r = add(x1r,x3i);
+ x0i = sub(x1i,x3r);
+
+ L_tmp = Mult_32_16(wk3r,x0r); /*Q(15+Qx+Q_edct) */
+ L_tmp = Msub_32_16(L_tmp,wk3i,x0i); /*Q(15+Qx+Q_edct) */
+ a[j3] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+
+ L_tmp = Mult_32_16(wk3r,x0i); /*Q(15+Qx+Q_edct) */
+ L_tmp = Madd_32_16(L_tmp,wk3i,x0r); /*Q(15+Qx+Q_edct) */
+ a[j3 + 1] = round_fx(L_shl(L_tmp,1)); /*Q(Qx+Q_edct) */
+ }
+ }
+
+ return;
+}
+
+void fft3_fx(const Word16 X[], Word16 Y[], const Word16 n)
+{
+ Word16 Z[PH_ECU_SPEC_SIZE];
+ Word16 *Z0, *Z1, *Z2;
+ Word16 *z0, *z1, *z2;
+ const Word16 *x;
+ const Word16 *t_sin = sincos_t_rad3_fx;
+ Word16 m, mMinus1, step;
+ Word16 i, l;
+ Word16 c1_ind, s1_ind, c2_ind, s2_ind;
+ Word16 c1_step, s1_step, c2_step, s2_step;
+ Word16 *RY, *IY, *RZ0, *IZ0, *RZ1, *IZ1, *RZ2, *IZ2;
+ Word32 acc;
+ Word16 mBy2, orderMinus1;
+ const Word16 *pPhaseTbl;
+
+ /* Determine the order of the transform, the length of decimated */
+ /* transforms m, and the step for the sine and cosine tables. */
+ SWITCH(n)
+ {
+ case 1536:
+ orderMinus1 = 9-1;
+ move16();
+ m = 512;
+ move16();
+ step = 1;
+ move16();
+ pPhaseTbl = FFT_W256;
+ BREAK;
+ case 384:
+ orderMinus1 = 7-1;
+ move16();
+ m = 128;
+ move16();
+ step = 4;
+ move16();
+ pPhaseTbl = FFT_W64;
+ BREAK;
+ default:
+ orderMinus1 = 7-1;
+ move16();
+ m = 128;
+ move16();
+ step = 4;
+ move16();
+ pPhaseTbl = FFT_W64;
+ BREAK;
+ }
+
+ /* Compose decimated sequences X[3i], X[3i+1],X[3i+2] */
+ /* compute their FFT of length m. */
+ Z0 = &Z[0];
+ z0 = &Z0[0];
+ Z1 = &Z0[m];
+ z1 = &Z1[0]; /* Z1 = &Z[ m]; */
+ Z2 = &Z1[m];
+ z2 = &Z2[0]; /* Z2 = &Z[2m]; */
+ x = &X[0];
+ FOR (i = 0; i < m; i++)
+ {
+ *z0++ = *x++; /* Z0[i] = X[3i]; */ move16();
+ *z1++ = *x++; /* Z1[i] = X[3i+1]; */ move16();
+ *z2++ = *x++; /* Z2[i] = X[3i+2]; */ move16();
+ }
+ mBy2 = shr(m,1);
+ r_fft_fx_lc(pPhaseTbl, m, mBy2, orderMinus1, Z0, Z0, 1);
+ r_fft_fx_lc(pPhaseTbl, m, mBy2, orderMinus1, Z1, Z1, 1);
+ r_fft_fx_lc(pPhaseTbl, m, mBy2, orderMinus1, Z2, Z2, 1);
+
+ /* Butterflies of order 3. */
+ /* pointer initialization */
+ mMinus1 = sub(m,1);
+ RY = &Y[0];
+ IY = &Y[n];
+ IY--; /* Decrement the address counter.*/
+ RZ0 = &Z0[0];
+ IZ0 = &Z0[mMinus1];
+ RZ1 = &Z1[0];
+ IZ1 = &Z1[mMinus1];
+ RZ2 = &Z2[0];
+ IZ2 = &Z2[mMinus1];
+
+ c1_step = negate(step);
+ s1_step = step;
+ move16();
+ c2_step = shl(c1_step,1);
+ s2_step = shl(s1_step,1);
+ c1_ind = add(T_SIN_PI_2, c1_step);
+ s1_ind = s1_step;
+ move16();
+ c2_ind = add(T_SIN_PI_2, c2_step);
+ s2_ind = s2_step;
+ move16();
+
+ /* special case: i = 0 */
+ acc = L_mult(*RZ0++, 0x4000);
+ acc = L_mac(acc, *RZ1++, 0x4000);
+ *RY++ = mac_r(acc, *RZ2++, 0x4000);
+ move16();
+
+ /* first 3/12-- from 1 to (3*m/8)-1 */
+ l = sub(shr(n, 3),1); /* (3*m/8) - 1 = (n/8) - 1 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_shl(*RZ0++, 15); /* Align with the following non-fractional mode so as to gain 1 more bit headroom. */
+ acc = L_mac0(acc, *RZ1, t_sin[c1_ind]); /* Non-fractional mode gains 1 more bit headroom. */
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_mac0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_mac0(acc, *IZ2, t_sin[s2_ind]);
+ *RY++ = round_fx(acc); /* bit growth = 1 (compensated by non-fractional mode MAC). */
+
+ acc = L_shl(*IZ0--, 15);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_mac0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2++, t_sin[s2_ind]);
+ acc = L_mac0(acc, *IZ2--, t_sin[c2_ind]);
+ *IY-- = round_fx(acc);
+
+ c1_ind = add(c1_ind, c1_step);
+ s1_ind = add(s1_ind, s1_step);
+ c2_ind = add(c2_ind, c2_step);
+ s2_ind = add(s2_ind, s2_step);
+ }
+
+ /* next 1/12-- from (3*m/8) to (4*m/8)-1 */
+ l = shr(m,3); /* (4*m/8) - (3*m/8) = m/8 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_shl(*RZ0++, 15);
+ acc = L_mac0(acc, *RZ1, t_sin[c1_ind]); /* Non-fractional mode gains 1 more bit headroom. */
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_mac0(acc, *IZ2, t_sin[s2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = L_shl(*IZ0--, 15);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_mac0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2++, t_sin[s2_ind]);
+ acc = L_msu0(acc, *IZ2--, t_sin[c2_ind]);
+ *IY-- = round_fx(acc);
+
+ c1_ind = add(c1_ind, c1_step);
+ s1_ind = add(s1_ind, s1_step);
+ c2_ind = sub(c2_ind, c2_step);
+ s2_ind = sub(s2_ind, s2_step);
+ }
+
+ /* special case: i = m/2 i.e. 1/3 */
+ acc = L_shl(*RZ0--, 15);
+ acc = L_mac0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = 0;
+ acc = L_msu0(acc, *RZ1--, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY-- = round_fx(acc);
+ IZ0++;
+ IZ1++;
+ IZ2++;
+
+ c1_ind = add(c1_ind, c1_step);
+ s1_ind = add(s1_ind, s1_step);
+ c2_ind = sub(c2_ind, c2_step);
+ s2_ind = sub(s2_ind, s2_step);
+
+ /* next 2/12-- from ((m/2)+1) to (6*m/8)-1 */
+ l = sub(shr(m,2), 1); /* (6*m/8) - ((m/2)+1) = m/4 - 1 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_shl(*RZ0--, 15);
+ acc = L_mac0(acc, *RZ1, t_sin[c1_ind]); /* Non-fractional mode gains 1 more bit headroom. */
+ acc = L_msu0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0++, -32768);
+ acc = L_msu0(acc, *RZ1--, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ1++, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[s2_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ *IY-- = round_fx(acc);
+
+ c1_ind = add(c1_ind, c1_step);
+ s1_ind = add(s1_ind, s1_step);
+ c2_ind = sub(c2_ind, c2_step);
+ s2_ind = sub(s2_ind, s2_step);
+ }
+
+ /*--------------------------half--------------------------// */
+ /* next 2/12-- from (6*m/8) to (8*m/8) - 1 */
+ l = shr(m,2);
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_shl(*RZ0--, 15);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]); /* Non-fractional mode gains 1 more bit headroom. */
+ acc = L_msu0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_mac0(acc, *IZ2, t_sin[s2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0++, -32768);
+ acc = L_msu0(acc, *RZ1--, t_sin[s1_ind]);
+ acc = L_mac0(acc, *IZ1++, t_sin[c1_ind]);
+ acc = L_mac0(acc, *RZ2--, t_sin[s2_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ *IY-- = round_fx(acc);
+
+ c1_ind = sub(c1_ind, c1_step);
+ s1_ind = sub(s1_ind, s1_step);
+ c2_ind = add(c2_ind, c2_step);
+ s2_ind = add(s2_ind, s2_step);
+ }
+
+ /* special case: i = m, i.e 2/3 */
+ acc = L_shl(*RZ0++, 15);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = L_deposit_l(0);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_mac0(acc, *RZ2++, t_sin[s2_ind]);
+ *IY-- = round_fx(acc);
+ IZ0--; /* Just decrement the address counter */
+ IZ1--;
+ IZ2--;
+
+ c1_ind = sub(c1_ind, c1_step);
+ s1_ind = sub(s1_ind, s1_step);
+ c2_ind = add(c2_ind, c2_step);
+ s2_ind = add(s2_ind, s2_step);
+
+ /* next 1/12-- from (m + 1) to (9*m/8) - 1 */
+ l = sub(shr(m, 3), 1); /* (9*m/8) - (m +1) = m/8 - 1 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_shl(*RZ0++, 15);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]); /* Non-fractional mode gains 1 more bit headroom. */
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = L_shl(*IZ0--, 15);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_mac0(acc, *RZ2++, t_sin[s2_ind]);
+ acc = L_msu0(acc, *IZ2--, t_sin[c2_ind]);
+ *IY-- = round_fx(acc);
+
+ c1_ind = sub(c1_ind, c1_step);
+ s1_ind = sub(s1_ind, s1_step);
+ c2_ind = add(c2_ind, c2_step);
+ s2_ind = add(s2_ind, s2_step);
+ }
+
+ /* last 3/12-- from (9*m/8) to (12*m/8) - 1 */
+ l = shr(n,3); /* (12*m/8) - (9*m/8) = 3*m/8 = n/8 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_shl(*RZ0++, 15);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]); /* Non-fractional mode gains 1 more bit headroom. */
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_mac0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY++ = round_fx(acc);
+
+ acc = L_shl(*IZ0--, 15);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_mac0(acc, *RZ2++, t_sin[s2_ind]);
+ acc = L_mac0(acc, *IZ2--, t_sin[c2_ind]);
+ *IY-- = round_fx(acc);
+
+ c1_ind = sub(c1_ind, c1_step);
+ s1_ind = sub(s1_ind, s1_step);
+ c2_ind = sub(c2_ind, c2_step);
+ s2_ind = sub(s2_ind, s2_step);
+ }
+
+ /* special case: i = 3*m/2 */
+ acc = L_shl(*RZ0, 15);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_mac0(acc, *RZ2, t_sin[c2_ind]);
+ *RY = round_fx(acc);
+
+ return;
+}
+
+
+void ifft3_fx(const Word16 Z[], Word16 X[], const Word16 n)
+{
+ Word16 Y[PH_ECU_SPEC_SIZE];
+ const Word16 *t_sin = sincos_t_rad3_fx;
+ Word16 m, mMinus1, step, step2;
+ Word16 i, l;
+ Word16 c0_ind, s0_ind, c1_ind, s1_ind, c2_ind, s2_ind;
+ const Word16 *RZ0, *IZ0, *RZ1, *IZ1, *RZ2, *IZ2;
+ const Word16 *RZ00, *IZ00, *RZ10, *IZ10, *RZ20, *IZ20;
+ Word16 *RY0, *IY0, *RY1, *IY1, *RY2, *IY2, *y0, *y1, *y2, *pX;
+ Word32 acc;
+ Word16 mBy2, orderMinus1, nMinusMBy2;
+ const Word16 *pPhaseTbl;
+
+ /* Determine the order of the transform, the length of decimated */
+ /* transforms m, and the step for the sine and cosine tables. */
+ SWITCH(n)
+ {
+ case 1536:
+ orderMinus1 = 9-1;
+ move16();
+ m = 512;
+ move16();
+ step = 1;
+ move16();
+ pPhaseTbl = FFT_W256;
+ BREAK;
+ case 384:
+ orderMinus1 = 7-1;
+ move16();
+ m = 128;
+ move16();
+ step = 4;
+ move16();
+ pPhaseTbl = FFT_W64;
+ BREAK;
+ default:
+ orderMinus1 = 7-1;
+ move16();
+ m = 128;
+ move16();
+ step = 4;
+ move16();
+ pPhaseTbl = FFT_W64;
+ BREAK;
+ }
+
+ nMinusMBy2 = shr(sub(n, m),1);
+ mMinus1 = sub(m,1);
+ /* pointer initialization */
+ RY0 = &Y[0];
+ IY0 = &Y[m];
+ RY1 = &RY0[m];
+ IY1 = &RY1[mMinus1];
+ RY2 = &RY1[m];
+ IY2 = &RY2[mMinus1];
+
+ RZ00 = &Z[0]; /* The zero positions of the pointers */
+ RZ10 = &RZ00[m];
+ RZ20 = &RZ00[nMinusMBy2];
+ IZ00 = &Z[n];
+ IZ10 = &IZ00[-m];
+ IZ20 = &IZ00[-nMinusMBy2];
+
+ RZ0 = RZ00; /* Reset the pointers to zero positions. */
+ RZ1 = RZ10;
+ RZ2 = RZ20;
+ IZ0 = IZ00;
+ IZ1 = IZ10;
+ IZ2 = IZ20;
+
+ /* Inverse butterflies of order 3. */
+
+ /* Construction of Y0 */
+ acc = L_mult(*RZ0++, 0x4000);
+ acc = L_mac(acc, *RZ1++, 0x4000);
+ *RY0++ = mac_r(acc, *RZ2--, 0x4000);
+ move16();
+ IZ0--;
+ IZ1--;
+ IZ2++;
+ IY0--;
+
+ l = sub(shr(m, 1), 1);
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult(*RZ0++, 0x4000);
+ acc = L_mac(acc, *RZ1++, 0x4000);
+ *RY0++ = mac_r(acc, *RZ2--, 0x4000);
+ move16();
+
+ acc = L_mult(*IZ0--, 0x4000);
+ acc = L_mac(acc, *IZ1--, 0x4000);
+ *IY0-- = msu_r(acc, *IZ2++, 0x4000);
+ move16();
+ }
+
+ /* m/2 */
+ acc = L_mult(*RZ0, 0x4000);
+ acc = L_mac(acc, *RZ1, 0x4000);
+ *RY0++ = mac_r(acc, *RZ2, 0x4000);
+ move16();
+
+
+ /* Construction of Y1 */
+ c0_ind=T_SIN_PI_2;
+ s0_ind=0;
+ c1_ind=T_SIN_PI_2*1/3;
+ s1_ind=T_SIN_PI_2*2/3;
+ c2_ind=T_SIN_PI_2*1/3;
+ s2_ind=T_SIN_PI_2*2/3;
+
+ RZ0 = RZ00; /* Reset pointers to zero positions. */
+ RZ1 = RZ10;
+ RZ2 = RZ20;
+ IZ0 = IZ00;
+ IZ1 = IZ10;
+ IZ2 = IZ20;
+ acc = L_mult0(*RZ0++, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ1++, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[c2_ind]);
+ IZ0--;
+ acc = L_msu0(acc, *IZ1--, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2++, t_sin[s2_ind]);
+ *RY1++ = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step);
+ s0_ind=add(s0_ind,step);
+ c1_ind=add(c1_ind,step);
+ s1_ind=sub(s1_ind,step);
+ c2_ind=sub(c2_ind,step);
+ s2_ind=add(s2_ind,step);
+
+ /* From 1 to (m/4) - 1. */
+ l = sub(shr(m,2),1);
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult0(*RZ0, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_msu0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY1++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0--, t_sin[c0_ind]);
+ acc = L_msu0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ acc = L_mac0(acc, *RZ0++, t_sin[s0_ind]);
+ acc = L_mac0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY1-- = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step);
+ s0_ind=add(s0_ind,step);
+ c1_ind=add(c1_ind,step);
+ s1_ind=sub(s1_ind,step);
+ c2_ind=sub(c2_ind,step);
+ s2_ind=add(s2_ind,step);
+ }
+
+ /* From m/4 to m/2 -1. */
+ l = shr(m, 2); /* m/2 - m/4 = m/4 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult0(*RZ0, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_mac0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_msu0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY1++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0--, t_sin[c0_ind]);
+ acc = L_msu0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_msu0(acc, *IZ2++, t_sin[c2_ind]);
+ acc = L_mac0(acc, *RZ0++, t_sin[s0_ind]);
+ acc = L_mac0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY1-- = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step);
+ s0_ind=add(s0_ind,step);
+ c1_ind=add(c1_ind,step);
+ s1_ind=sub(s1_ind,step);
+ c2_ind=add(c2_ind,step);
+ s2_ind=sub(s2_ind,step);
+ }
+
+ /* m/2 */
+ acc = L_mult0(*RZ0, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_mac0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_msu0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY1++ = round_fx(acc);
+
+ /* Construction of Y2 */
+ c0_ind=T_SIN_PI_2;
+ s0_ind=0;
+ c1_ind=T_SIN_PI_2*1/3;
+ s1_ind=T_SIN_PI_2*2/3;
+ c2_ind=T_SIN_PI_2*1/3;
+ s2_ind=T_SIN_PI_2*2/3;
+ step2 = shl(step,1);
+
+ RZ0 = RZ00; /* Reset pointers to zero positions. */
+ RZ1 = RZ10;
+ RZ2 = RZ20;
+ IZ0 = IZ00;
+ IZ1 = IZ10;
+ IZ2 = IZ20;
+ acc = L_mult0(*RZ0++, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ1++, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[c2_ind]);
+ IZ0--;
+ acc = L_mac0(acc, *IZ1--, t_sin[s1_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[s2_ind]);
+ *RY2++ = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step2);
+ s0_ind=add(s0_ind,step2);
+ c1_ind=sub(c1_ind,step2);
+ s1_ind=add(s1_ind,step2);
+ c2_ind=add(c2_ind,step2);
+ s2_ind=sub(s2_ind,step2);
+
+ /* From 1 to (m/8) - 1. */
+ l = sub(shr(m, 3),1); /* m/8 - 1. */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult0(*RZ0, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_mac0(acc, *IZ2, t_sin[s2_ind]);
+ *RY2++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0--, t_sin[c0_ind]);
+ acc = L_msu0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ acc = L_mac0(acc, *RZ0++, t_sin[s0_ind]);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_mac0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY2-- = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step2);
+ s0_ind=add(s0_ind,step2);
+ c1_ind=sub(c1_ind,step2);
+ s1_ind=add(s1_ind,step2);
+ c2_ind=add(c2_ind,step2);
+ s2_ind=sub(s2_ind,step2);
+ }
+
+ /* From (m/8) to (m/4) - 1. */
+ l = shr(m, 3); /* m/4 - m/8 = m/8 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult0(*RZ0, t_sin[c0_ind]);
+ acc = L_mac0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_mac0(acc, *IZ2, t_sin[s2_ind]);
+ *RY2++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0--, t_sin[c0_ind]);
+ acc = L_mac0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ acc = L_mac0(acc, *RZ0++, t_sin[s0_ind]);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_mac0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY2-- = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step2);
+ s0_ind=add(s0_ind,step2);
+ c1_ind=add(c1_ind,step2);
+ s1_ind=sub(s1_ind,step2);
+ c2_ind=add(c2_ind,step2);
+ s2_ind=sub(s2_ind,step2);
+ }
+
+ /* From m/4 to 3*m/8 - 1. */
+ l = shr(m, 3); /* 3*m/8 - m/4 = m/8 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult0(*RZ0, t_sin[c0_ind]);
+ acc = L_mac0(acc, *RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY2++ = round_fx(acc);
+
+ acc = L_mult0(*IZ0--, t_sin[c0_ind]);
+ acc = L_mac0(acc, *IZ1--, t_sin[c1_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ acc = L_mac0(acc, *RZ0++, t_sin[s0_ind]);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY2-- = round_fx(acc);
+
+ c0_ind=sub(c0_ind,step2);
+ s0_ind=add(s0_ind,step2);
+ c1_ind=add(c1_ind,step2);
+ s1_ind=sub(s1_ind,step2);
+ c2_ind=sub(c2_ind,step2);
+ s2_ind=add(s2_ind,step2);
+ }
+
+ /* From 3*m/8 to m/2 - 1*/
+ l = shr(m, 3); /* m/2 - 3*m/8 = m/8 */
+ FOR (i = 0; i < l; i++)
+ {
+ acc = L_mult0(*RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ0, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY2++ = round_fx(acc);
+
+ acc = L_mult0(*IZ1--, t_sin[c1_ind]);
+ acc = L_msu0(acc, *IZ0--, t_sin[c0_ind]);
+ acc = L_mac0(acc, *IZ2++, t_sin[c2_ind]);
+ acc = L_mac0(acc, *RZ0++, t_sin[s0_ind]);
+ acc = L_msu0(acc, *RZ1++, t_sin[s1_ind]);
+ acc = L_msu0(acc, *RZ2--, t_sin[s2_ind]);
+ *IY2-- = round_fx(acc);
+
+ c0_ind=add(c0_ind,step2);
+ s0_ind=sub(s0_ind,step2);
+ c1_ind=add(c1_ind,step2);
+ s1_ind=sub(s1_ind,step2);
+ c2_ind=sub(c2_ind,step2);
+ s2_ind=add(s2_ind,step2);
+ }
+
+ /* m/2 */
+ acc = L_mult0(*RZ1, t_sin[c1_ind]);
+ acc = L_msu0(acc, *RZ0, t_sin[c0_ind]);
+ acc = L_msu0(acc, *RZ2, t_sin[c2_ind]);
+ acc = L_msu0(acc, *IZ0, t_sin[s0_ind]);
+ acc = L_mac0(acc, *IZ1, t_sin[s1_ind]);
+ acc = L_msu0(acc, *IZ2, t_sin[s2_ind]);
+ *RY2++ = round_fx(acc);
+
+ /* Compute the inverse FFT for all 3 blocks. */
+ RY0 = &Y[0]; /* Rewind the pointers. */
+ RY1 = &Y[m];
+ RY2 = &RY1[m];
+ mBy2 = shr(m,1);
+ r_fft_fx_lc(pPhaseTbl, m, mBy2, orderMinus1, RY0, RY0, 0); /* inverse FFT */
+ r_fft_fx_lc(pPhaseTbl, m, mBy2, orderMinus1, RY1, RY1, 0); /* inverse FFT */
+ r_fft_fx_lc(pPhaseTbl, m, mBy2, orderMinus1, RY2, RY2, 0); /* inverse FFT */
+
+ y0 = RY0;
+ y1 = RY1;
+ y2 = RY2;
+
+ /* Interlacing and scaling, scale = 1/3 */
+ pX = X;
+ FOR (i = 0; i < m; i++)
+ {
+ *pX++ = shl(mult_r(*y0++, FFT3_ONE_THIRD), 1);
+ move16();
+ *pX++ = shl(mult_r(*y1++, FFT3_ONE_THIRD), 1);
+ move16();
+ *pX++ = shl(mult_r(*y2++, FFT3_ONE_THIRD), 1);
+ move16();
+ }
+
+ return;
+}
diff --git a/lib_com/fft_rel_fx.c b/lib_com/fft_rel_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..51aa3e6eb8973562472f99dc4bcc5572c6012371
--- /dev/null
+++ b/lib_com/fft_rel_fx.c
@@ -0,0 +1,433 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "stl.h"
+
+#include "stdint.h"
+/*------------------------------------------------------------------
+ *
+ * This is an implementation of decimation-in-time FFT algorithm for
+ * real sequences. The techniques used here can be found in several
+ * books, e.g., i) Proakis and Manolakis, "Digital Signal Processing",
+ * 2nd Edition, Chapter 9, and ii) W.H. Press et. al., "Numerical
+ * Recipes in C", 2nd Edition, Chapter 12.
+ *
+ * Input - There are two inputs to this function:
+ *
+ * 1) An integer pointer to the input data array
+ * 2) An integer value which should be set as +1 for FFT
+ * and some other value, e.g., -1 for ifFT
+ *
+ * Output - There is no return value.
+ * The input data are replaced with transformed data. if the
+ * input is a real time domain sequence, it is replaced with
+ * the complex FFT for positive frequencies. The FFT value
+ * for DC and the foldover frequency are combined to form the
+ * first complex number in the array. The remaining complex
+ * numbers correspond to increasing frequencies. if the input
+ * is a complex frequency domain sequence arranged as above,
+ * it is replaced with the corresponding time domain sequence.
+ *
+ * Notes:
+ *
+ * 1) This function is designed to be a part of a noise supp-
+ * ression algorithm that requires 128-point FFT of real
+ * sequences. This is achieved here through a 64-point
+ * complex FFT. Consequently, the FFT size information is
+ * not transmitted explicitly. However, some flexibility
+ * is provided in the function to change the size of the
+ * FFT by specifying the size information through "define"
+ * statements.
+ *
+ * 2) The values of the complex sinusoids used in the FFT
+ * algorithm are computed once (i.e., the first time the
+ * r_fft function is called) and stored in a table. To
+ * further speed up the algorithm, these values can be
+ * precomputed and stored in a ROM table in actual DSP
+ * based implementations.
+ *
+ * 3) In the c_fft function, the FFT values are divided by
+ * 2 after each stage of computation thus dividing the
+ * final FFT values by 64. No multiplying factor is used
+ * for the ifFT. This is somewhat different from the usual
+ * definition of FFT where the factor 1/N, i.e., 1/64, is
+ * used for the ifFT and not the FFT. No factor is used in
+ * the r_fft function.
+ *
+ * 4) Much of the code for the FFT and ifFT parts in r_fft
+ * and c_fft functions are similar and can be combined.
+ * They are, however, kept separate here to speed up the
+ * execution.
+ *------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*
+ * c_fft_fx:
+ *
+ * Computes the complex part of the split-radix FFT
+ *------------------------------------------------------------------------*/
+
+static void c_fft_fx(
+ const Word16 *phs_tbl, /* i : Table of phases */
+ Word16 SIZE, /* i : Size of the FFT */
+ Word16 NUM_STAGE, /* i : Number of stages */
+ const Word16 *in_ptr, /* i : coefficients in the order re[0], re[n/2], re[1], im[1], ..., re[n/2-1], im[n/2-1] */
+ Word16 *out_ptr, /* o : coefficients in the order re[0], re[n/2], re[1], im[1], ..., re[n/2-1], im[n/2-1] */
+ /* in_ptr & out_ptr must not overlap! */
+ const Word16 isign) /* i : 1=fft, otherwise it is ifft*/
+{
+ Word16 i, j, k, ii, jj, kk, ji, kj;
+ Word32 L_tmp1, L_tmp2;
+ Word16 tmp1,tmp2,tmp3,tmp4;
+ const Word16 *table_ptr;
+ const Word16 *input_ptr1,*input_ptr2,*input_ptr3,*input_ptr4;
+ Word16 shift=0;
+ /* Setup Reorder Variables */
+ table_ptr = NULL;
+ table_ptr = FFT_REORDER_1024;
+ SWITCH(SIZE)
+ {
+ case 1024:
+ shift = 0;
+ BREAK;
+ case 512:
+ shift = 1;
+ BREAK;
+ case 256:
+ shift = 2;
+ BREAK;
+ case 128:
+ shift = 3;
+ BREAK;
+ case 64:
+ shift = 4;
+ BREAK;
+ }
+ /* The FFT part */
+ IF (isign != 0)
+ {
+ /* Unrolled 1st/2nd Stage
+ * 1) to take advantage of Table Values (0 & +/- 16384)
+ * 2) to perform reordering of Input Values
+ */
+ FOR (k = 0; k < SIZE; k += 8)
+ {
+ /*
+ * This loop use:
+ * 4 Word16 (tmp1...tmp4)
+ * 2 Word32 (L_tmp1 & L_tmp2)
+ * 4 Pointers (table_ptr, input_ptr1, input_ptr2, input_ptr3)
+ *
+ * The addition of 'in_ptr' + and index value from 'reorder_ptr'
+ * is counted as a move16()
+ */
+
+ input_ptr1 = in_ptr + (const Word16 ) ((uintptr_t)(*table_ptr++)>>(uintptr_t)shift);
+
+ L_tmp1 = L_mult(*input_ptr1++, 16384);
+ L_tmp2 = L_mult(*input_ptr1, 16384);
+
+ input_ptr1 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+
+ tmp1 = msu_r(L_tmp1, *input_ptr1, 16384);
+ tmp3 = mac_r(L_tmp1, *input_ptr1++, 16384);
+
+ input_ptr2 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+ input_ptr3 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+
+ L_tmp1 = L_mult(*input_ptr2++, 16384);
+ tmp2 = mac_r(L_tmp1, *input_ptr3, 16384);
+ tmp4 = msu_r(L_tmp1, *input_ptr3++, 16384);
+
+ L_tmp1 = L_mult(tmp3, 16384);
+ out_ptr[k] = mac_r(L_tmp1, tmp2, 16384);
+ move16();
+ out_ptr[k+4] = msu_r(L_tmp1, tmp2, 16384);
+ move16();
+
+ tmp2 = mac_r(L_tmp2, *input_ptr1, 16384);
+ tmp3 = msu_r(L_tmp2, *input_ptr1, 16384);
+
+ L_tmp2 = L_mult(*input_ptr2, 16384);
+
+ L_tmp1 = L_mult(tmp1, 16384);
+ tmp1 = msu_r(L_tmp2, *input_ptr3, 16384);
+ out_ptr[k+2] = mac_r(L_tmp1, tmp1, 16384);
+ move16();
+ out_ptr[k+6] = msu_r(L_tmp1, tmp1, 16384);
+ move16();
+
+ L_tmp1 = L_mult(tmp2, 16384);
+ tmp2 = mac_r(L_tmp2, *input_ptr3, 16384);
+ out_ptr[k+1] = mac_r(L_tmp1, tmp2, 16384);
+ move16();
+ out_ptr[k+5] = msu_r(L_tmp1, tmp2, 16384);
+ move16();
+
+ L_tmp1 = L_mult(tmp3, 16384);
+ out_ptr[k+3] = msu_r(L_tmp1, tmp4, 16384);
+ move16();
+ out_ptr[k+7] = mac_r(L_tmp1, tmp4, 16384);
+ move16();
+ }
+
+ /* Remaining Stages */
+ FOR (i = 2; i < NUM_STAGE; i++)
+ {
+ /* i is stage counter */
+ jj = shl(2, i); /* FFT size */
+ kk = shl(jj, 1); /* 2 * FFT size */
+ ii = shr(SIZE, i);
+ ji = 0;
+ move16(); /* ji is phase table index */
+
+ FOR (j = 0; j < jj; j += 2)
+ {
+ /* j is sample counter */
+ FOR (k = j; k < SIZE; k += kk)
+ {
+ /* k is butterfly top */
+ kj = add(k, jj); /* kj is butterfly bottom */
+
+ /* Butterfly computations */
+ L_tmp1 = L_msu(L_mult(*(out_ptr + kj), phs_tbl[ji]),
+ *(out_ptr + kj + 1), phs_tbl[ji + 1]);
+ L_tmp2 = L_mac(L_mult(*(out_ptr + kj + 1), phs_tbl[ji]),
+ *(out_ptr + kj), phs_tbl[ji + 1]);
+
+ out_ptr[kj] = mac_r(L_negate(L_tmp1), out_ptr[k], 16384);
+ move16();
+ out_ptr[kj+1] = mac_r(L_negate(L_tmp2), out_ptr[k+1], 16384);
+ move16();
+ out_ptr[k] = mac_r(L_tmp1, out_ptr[k], 16384);
+ move16();
+ out_ptr[k+1] = mac_r(L_tmp2, out_ptr[k+1], 16384);
+ move16();
+ }
+ ji = add(ji, ii);
+ }
+ }
+ }
+ ELSE /* The ifFT part */
+ {
+ /* Unrolled 1st/2nd Stage
+ * 1) to take advantage of Table Values (0 & +/- 16384)
+ * 2) to perform reordering of Input Values
+ */
+ FOR (k = 0; k < SIZE; k += 8)
+ {
+ /*
+ * This loop use:
+ * 4 Word16 (tmp1...tmp4)
+ * 2 Word32 (L_tmp1 & L_tmp2)
+ * 5 Pointers (reorder_ptr, input_ptr1...input_ptr4)
+ *
+ * The addition of 'in_ptr' + and index value from 'reorder_ptr'
+ * is counted as a move16()
+ */
+ input_ptr1= in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+ input_ptr2 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+
+ input_ptr3 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+ input_ptr4 = in_ptr + (const Word16)((uintptr_t)(*table_ptr++) >> (uintptr_t)shift);
+
+
+ tmp3 = sub(*input_ptr1, *input_ptr2);
+ tmp4 = add(*input_ptr1++, *input_ptr2++);
+
+ tmp2 = sub(input_ptr3[0], input_ptr4[0]);
+ tmp1 = sub(input_ptr3[1], input_ptr4[1]);
+
+ out_ptr[k+2] = sub(tmp3, tmp1);
+ move16();
+ out_ptr[k+6] = add(tmp3, tmp1);
+ move16();
+
+ tmp1 = sub(*input_ptr1, *input_ptr2);
+ out_ptr[k+3] = add(tmp1, tmp2);
+ move16();
+ out_ptr[k+7] = sub(tmp1, tmp2);
+ move16();
+
+ tmp1 = add(input_ptr3[0], input_ptr4[0]);
+ tmp3 = add(input_ptr3[1], input_ptr4[1]);
+
+ out_ptr[k] = add(tmp4, tmp1);
+ move16();
+ out_ptr[k+4] = sub(tmp4, tmp1);
+ move16();
+
+ tmp4 = add(*input_ptr1, *input_ptr2);
+ out_ptr[k+1] = add(tmp4, tmp3);
+ move16();
+ out_ptr[k+5] = sub(tmp4, tmp3);
+ move16();
+ }
+
+ table_ptr = phs_tbl + SIZE; /* access part of table that is scaled by 2 */
+
+ /* Remaining Stages */
+ FOR (i = 2; i < NUM_STAGE; i++)
+ {
+ /* i is stage counter */
+ jj = shl(2, i); /* FFT size */
+ kk = shl(jj, 1); /* 2 * FFT size */
+ ii = shr(SIZE, i);
+ ji = 0;
+ move16(); /* ji is phase table index */
+
+ FOR (j = 0; j < jj; j += 2)
+ {
+ /* j is sample counter */
+ /* This can be computed by successive add_fxitions of ii to ji, starting from 0
+ hence line-count it as a one-line add (still need to increment op count!!) */
+
+ FOR (k = j; k < SIZE; k += kk)
+ {
+ /* k is butterfly top */
+ kj = add(k, jj); /* kj is butterfly bottom */
+
+ /* Butterfly computations */
+ tmp1 = mac_r(L_mult(out_ptr[kj], table_ptr[ji]),
+ out_ptr[kj+1], table_ptr[ji + 1]);
+
+ tmp2 = msu_r(L_mult(out_ptr[kj+1], table_ptr[ji]),
+ out_ptr[kj], table_ptr[ji+1]);
+
+ out_ptr[kj] = sub(out_ptr[k], tmp1);
+ move16();
+ out_ptr[kj+1] = sub(out_ptr[k+1], tmp2);
+ move16();
+ out_ptr[k] = add(out_ptr[k], tmp1);
+ move16();
+ out_ptr[k+1] = add(out_ptr[k+1], tmp2);
+ move16();
+ }
+ ji = add(ji, ii);
+ }
+ }
+ }
+}
+
+/*--------------------------------------------------------------------------------*
+ * r_fft_fx:
+ *
+ * Perform FFT fixed-point for real-valued sequences of length 32, 64 or 128
+ *--------------------------------------------------------------------------------*/
+void r_fft_fx_lc(
+ const Word16 *phs_tbl, /* i : Table of phase */
+ const Word16 SIZE, /* i : Size of the FFT */
+ const Word16 SIZE2, /* i : Size / 2 */
+ const Word16 NUM_STAGE, /* i : Number of stage */
+ const Word16 *in_ptr, /* i : coefficients in the order re[0], re[1], ... re[n/2], im[n/2-1], im[n/2-2], ..., im[1] */
+ Word16 *out_ptr, /* o : coefficients in the order re[0], re[1], ... re[n/2], im[n/2-1], im[n/2-2], ..., im[1] */
+ const Word16 isign /* i : 1=fft, otherwize it's ifft */
+)
+{
+ Word16 tmp2_real, tmp2_imag;
+ Word32 Ltmp1_real, Ltmp1_imag;
+ Word16 i;
+ Word32 Ltmp1;
+ const Word16 *phstbl_ptrDn;
+ Word16 *ptrDn;
+ Word16 temp[1024]; /* Accommodates real input FFT size up to 1024. */
+
+ /* Setup Pointers */
+ phstbl_ptrDn = &phs_tbl[SIZE-1];
+
+ /* The FFT part */
+ IF (isign != 0)
+ {
+ Word16 *ptRealUp, *ptRealDn, *ptImaUp, *ptImaDn;
+
+ /* Perform the complex FFT */
+ c_fft_fx(phs_tbl, SIZE, NUM_STAGE, in_ptr, temp, isign);
+
+ /* First, handle the DC and foldover frequencies */
+ out_ptr[SIZE2] = sub(temp[0], temp[1]);
+ move16();
+ out_ptr[0] = sub(add(temp[0], temp[1]), shr(NUM_STAGE, 1));
+ move16();/* DC have a small offset */
+
+ ptrDn = &temp[SIZE-1];
+
+ ptImaDn = &out_ptr[SIZE-1];
+ ptRealUp = &out_ptr[1];
+ ptImaUp = &out_ptr[SIZE2+1];
+ ptRealDn = &out_ptr[SIZE2-1];
+
+ /* Now, handle the remaining positive frequencies */
+ FOR (i = 2; i <= SIZE2; i += 2)
+ {
+ Ltmp1_imag = L_mult(temp[i+1], 16384);
+ Ltmp1_imag = L_msu(Ltmp1_imag, *ptrDn, 16384);
+ tmp2_real = add(temp[i+1], *ptrDn--);
+
+ Ltmp1_real = L_mult(temp[i], 16384);
+ Ltmp1_real = L_mac(Ltmp1_real, *ptrDn, 16384);
+ tmp2_imag = sub(*ptrDn--, temp[i]);
+
+
+ *ptRealUp++ = msu_r(L_mac(Ltmp1_real, tmp2_real, phs_tbl[i]), tmp2_imag, phs_tbl[i+1]);
+ move16();
+ *ptImaDn-- = mac_r(L_mac(Ltmp1_imag, tmp2_imag, phs_tbl[i]), tmp2_real, phs_tbl[i+1]);
+ move16();
+ Ltmp1 = L_mac(L_negate(Ltmp1_imag), tmp2_real, *phstbl_ptrDn);
+ Ltmp1_real = L_mac(Ltmp1_real, tmp2_imag, *phstbl_ptrDn--);
+ *ptImaUp++ = msu_r(Ltmp1, tmp2_imag, *phstbl_ptrDn);
+ move16();
+ *ptRealDn-- = mac_r(Ltmp1_real, tmp2_real, *phstbl_ptrDn--);
+ move16();
+ }
+ }
+ ELSE /* The ifFT part */
+ {
+ const Word16 *ptRealUp, *ptRealDn, *ptImaUp, *ptImaDn;
+
+ /* First, handle the DC and foldover frequencies */
+ Ltmp1 = L_mult(in_ptr[0], 16384);
+ temp[0] = mac_r(Ltmp1, in_ptr[SIZE2], 16384);
+ move16();
+ temp[1] = msu_r(Ltmp1, in_ptr[SIZE2], 16384);
+ move16();
+
+ ptrDn = &temp[SIZE-1];
+
+ /* Here we cast to Word16 * from a const Word16 *. */
+ /* This is ok because we use these pointers for */
+ /* reading only. This is just to avoid declaring a */
+ /* bunch of 4 other pointer with const Word16 *. */
+ ptImaDn = &in_ptr[SIZE-1];
+ ptRealUp = &in_ptr[1];
+ ptImaUp = &in_ptr[SIZE2+1];
+ ptRealDn = &in_ptr[SIZE2-1];
+
+ /* Now, handle the remaining positive frequencies */
+ FOR (i = 2; i <= SIZE2; i += 2)
+ {
+ Ltmp1_imag = L_mult(*ptImaDn, 16384);
+ Ltmp1_imag = L_msu(Ltmp1_imag, *ptImaUp, 16384);
+ tmp2_real = add(*ptImaDn--, *ptImaUp++);
+ Ltmp1_real = L_mult(*ptRealUp, 16384);
+ Ltmp1_real = L_mac(Ltmp1_real, *ptRealDn, 16384);
+ tmp2_imag = sub(*ptRealUp++, *ptRealDn--);
+
+
+ temp[i] = mac_r(L_msu(Ltmp1_real, tmp2_real, phs_tbl[i]), tmp2_imag, phs_tbl[i+1]);
+ move16();
+ temp[i+1] = mac_r(L_mac(Ltmp1_imag, tmp2_imag, phs_tbl[i]), tmp2_real, phs_tbl[i+1]);
+ move16();
+ Ltmp1 = L_mac(L_negate(Ltmp1_imag), tmp2_real, *phstbl_ptrDn);
+ Ltmp1_real = L_msu(Ltmp1_real, tmp2_imag, *phstbl_ptrDn--);
+ *ptrDn-- = msu_r(Ltmp1, tmp2_imag, *phstbl_ptrDn);
+ move16();
+ *ptrDn-- = msu_r(Ltmp1_real, tmp2_real, *phstbl_ptrDn--);
+ move16();
+ }
+
+ /* Perform the complex ifFT */
+ c_fft_fx(phs_tbl, SIZE, NUM_STAGE, temp, out_ptr, isign);
+ }
+}
diff --git a/lib_com/fft_rel_sas_fx.c b/lib_com/fft_rel_sas_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..06a7c0f28d993d69051bdfcb153f9add388502f1
--- /dev/null
+++ b/lib_com/fft_rel_sas_fx.c
@@ -0,0 +1,456 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+/*---------------------------------------------------------------------*
+ * Local constants
+ *---------------------------------------------------------------------*/
+
+#define INV_SQR2_FX 23170
+#define N_MAX_SAS 256
+
+/*---------------------------------------------------------------------*
+ * fft_rel_fx()
+ *
+ * Computes the split-radix FFT in place for the real-valued
+ * signal x of length n. The algorithm has been ported from
+ * the fortran code of [1].
+ *
+ * The function needs sine and cosine tables t_sin and t_cos,
+ * and the constant N_MAX_SAS. The table entries are defined as
+ * sin(2*pi*i) and cos(2*pi*i) for i = 0, 1, ..., N_MAX_SAS-1. The
+ * implementation assumes that any entry will not be needed
+ * outside the tables. Therefore, N_MAX_SAS and n must be properly
+ * set. The function has been tested with the values n = 16,
+ * 32, 64, 128, 256, and N_MAX_SAS = 1280.
+ *
+ * References
+ * [1] H.V. Sorensen, D.L. Jones, M.T. Heideman, C.S. Burrus,
+ * "Real-valued fast Fourier transform algorithm," IEEE
+ * Trans. on Signal Processing, Vol.35, No.6, pp 849-863,
+ * 1987.
+ *
+ * OUTPUT
+ * x[0:n-1] Transform coeffients in the order re[0], re[1],
+ * ..., re[n/2], im[n/2-1], ..., im[1].
+ *---------------------------------------------------------------------*/
+/*MERGE fft_rel_fx and fft_rel_fx_lc */
+void fft_rel_fx(
+ Word16 x[], /* i/o: input/output vector */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+)
+{
+ Word16 i, j, k, n1, n2, n4;
+ Word16 step;
+ Word16 xt, t1, t2;
+ Word16 *x0, *x1, *x2;
+ const Word16 *s, *c;
+ Word16 *xi2, *xi3, *xi4, *xi1;
+
+
+ /*-----------------------------------------------------------------*
+ * Digit reverse counter
+ *-----------------------------------------------------------------*/
+
+ j = 0;
+ move16();
+ x0 = &x[0];
+ move16();
+ FOR (i = 0; i < n-1; i++)
+ {
+ IF (LT_16(i,j))
+ {
+ xt = x[j];
+ move16();
+ x[j] = *x0;
+ move16();
+ *x0 = xt;
+ move16();
+ }
+ x0++;
+ k = shr(n,1);
+ WHILE (LE_16(k,j))
+ {
+ j = sub(j,k);
+ k = shr(k,1);
+ }
+ j = add(j,k);
+ }
+
+ /*-----------------------------------------------------------------*
+ * Length two butterflies
+ *-----------------------------------------------------------------*/
+
+ x0 = &x[0];
+ move16();
+ x1 = &x[1];
+ move16();
+ FOR (i = 0; i < n/2; i++)
+ {
+ xt = *x0;
+ move16();
+ *x0 = add(xt,*x1);
+ move16();
+ *x1 = sub(xt,*x1);
+ move16();
+ x0++;
+ x0++;
+ x1++;
+ x1++;
+ }
+
+ /*-----------------------------------------------------------------*
+ * Other butterflies
+ *
+ * The implementation described in [1] has been changed by using
+ * table lookup for evaluating sine and cosine functions. The
+ * variable ind and its increment step are needed to access table
+ * entries. Note that this implementation assumes n4 to be so
+ * small that ind will never exceed the table. Thus the input
+ * argument n and the constant N_MAX_SAS must be set properly.
+ *-----------------------------------------------------------------*/
+
+ n2 = 1;
+ move16();
+ /* step = N_MAX_SAS/4; */
+ FOR (k = 2; k <= m; k++)
+ {
+ n4 = n2;
+ move16();
+ n2 = shl(n4,1);
+ n1 = shl(n2,1);
+
+ step = N_MAX_SAS/n1;
+
+ x0 = x;
+ x1 = x + n2;
+ x2 = x + add(n2, n4);
+ FOR (i = 0; i < n; i += n1)
+ {
+ xt = *x0;
+ move16(); /* xt = x[i]; */
+ *x0 = add(xt,*x1);
+ move16(); /* x[i] = xt + x[i+n2]; */
+ *x1 = sub(xt,*x1);
+ move16(); /* x[i+n2] = xt - x[i+n2]; */
+ *x2 = negate(*x2);
+ move16(); /* x[i+n2+n4] = -x[i+n2+n4]; */
+
+
+ s = sincos_t_fx + step;
+ c = s + 64;
+ xi1 = x + add(i, 1);
+ xi3 = xi1 + n2;
+ xi2 = xi3 - 2;
+ xi4 = xi1 + sub(n1, 2);
+
+ FOR (j = 1; j < n4; j++)
+ {
+ t1 = add(mult_r(*xi3,*c),mult_r(*xi4,*s)); /* t1 = *xi3**(pt_c+ind) + *xi4**(pt_s+ind); */
+ t2 = sub(mult_r(*xi3,*s),mult_r(*xi4,*c)); /* t2 = *xi3**(pt_s+ind) - *xi4**(pt_c+ind); */
+ *xi4 = sub(*xi2,t2);
+ move16();
+ *xi3 = negate(add(*xi2,t2));
+ move16();
+ *xi2 = sub(*xi1,t1);
+ move16();
+ *xi1 = add(*xi1,t1);
+ move16();
+
+ xi4--;
+ xi2--;
+ xi3++;
+ xi1++;
+ c += step;
+ s += step; /* autoincrement by ar0 */
+ }
+
+ x0 += n1;
+ x1 += n1;
+ x2 += n1;
+ }
+ /* step = shr(step, 1); */
+ }
+
+ return;
+}
+
+void ifft_rel_fx(
+ Word16 io[], /* i/o: input/output vector */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+)
+{
+ Word16 i, j, k;
+ Word16 step;
+ Word16 n2, n4, n8, i0;
+ Word16 is, id;
+ Word16 *x,*xi0, *xi1, *xi2, *xi3, *xi4, *xup1, *xdn6, *xup3, *xdn8;
+ Word16 xt;
+ Word16 r1;
+ Word16 t1, t2, t3, t4, t5;
+ const Word16 *s, *c, *s3, *c3;
+
+ Word16 cc1, cc3, ss1, ss3;
+ Word16 tmp;
+
+
+ /*-----------------------------------------------------------------*
+ * ifft
+ *-----------------------------------------------------------------*/
+
+ x = &io[-1];
+ move16();
+ n2 = shl(n,1);
+ FOR (k=1; k
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+
+/*--------------------------------------------------------------------------*
+ * fill_spectrum()
+ *
+ * Apply spectral filling by
+ * - filling zero-bit bands below BWE region
+ * - applying BWE above transition frequency
+ *--------------------------------------------------------------------------*/
+
+void fill_spectrum_fx(
+ Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */
+ Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */
+ const Word16 *R, /* i : number of pulses per band Q0 */
+ const Word16 is_transient, /* i : transient flag Q0 */
+ Word16 norm[], /* i : quantization indices for norms Q0 */
+ const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */
+ const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */
+ const Word16 nf_idx, /* i : noise fill index Q0 */
+ const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */
+ const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */
+ Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */
+ Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input Q0 */
+ const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */
+ const Word16 core_sfm, /* i : index of the end band for core Q0 */
+ const Word16 HQ_mode, /* i : HQ mode Q0 */
+ Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */
+ const Word32 L_core_brate, /* i : target bit-rate Q0 */
+ Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */
+ Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */
+ Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */
+ const Word16 *peak_idx, /* i : peak indices for hvq Q0 */
+ const Word16 Npeaks, /* i : number of peaks in hvq Q0 */
+ const Word16 *npulses, /* i : number of pulses per band Q0 */
+ const Word16 prev_is_transient, /* i : previous transient flag Q0 */
+ Word32 *prev_normq, /* i/o: previous norms Q14 */
+ Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */
+ const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */
+ const Word16 *sfmsize, /* i : Length of bands Q0 */
+ const Word16 *sfm_start, /* i : Start of bands Q0 */
+ const Word16 *sfm_end, /* i : End of bands Q0 */
+ Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */
+ const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */
+ const Word16 num_sfm /* i : Total number of bands Q0 */
+ ,Word16 *prev_env_Q
+ ,const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_GEN Q0 */
+)
+{
+ Word16 CodeBook[FREQ_LENGTH]; /* Q12 */
+ Word16 cb_size;
+ Word16 last_sfm;
+ Word16 CodeBook_mod[FREQ_LENGTH]; /*Q12 */
+ Word16 norm_adj[NB_SFM]; /*Q15 */
+ Word16 high_sfm;
+ Word16 flag_32K_env_hangover;
+ Word16 bin_th;
+ Word16 peak_pos[L_HARMONIC_EXC];
+ Word16 bwe_peaks[L_FRAME48k];
+ Word32 L_normq_v[NB_SFM]; /*Q14 */
+ Word16 coeff_fine[L_FRAME48k]; /*Q15 */
+ Word32 L_coeff_out1[L_FRAME48k]; /*Q12 */
+
+ set16_fx( peak_pos, 0, L_HARMONIC_EXC );
+ set16_fx( bwe_peaks, 0, L_FRAME48k );
+ set16_fx(norm_adj, 32767, num_sfm); /* 1.0, Q15 */
+ cb_size = 0;
+ move16();
+ bin_th = 0;
+ move16();
+ high_sfm = 23;
+ move16();
+
+ test();
+ IF ( EQ_16(HQ_mode, HQ_TRANSIENT))
+ {
+ last_sfm = sub(num_sfm, 1);
+ }
+ ELSE IF ( EQ_16(HQ_mode,HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB))
+ {
+ last_sfm = s_max(core_sfm,sub(num_env_bands,1));
+ }
+ ELSE
+ {
+ last_sfm = core_sfm;
+ move16();
+ }
+
+ IF ( EQ_16(HQ_mode, HQ_HARMONIC))
+ {
+ /*high_sfm = (core_brate == HQ_24k40) ? HVQ_THRES_SFM_24k-1 : HVQ_THRES_SFM_32k-3; */
+ high_sfm = sub(HVQ_THRES_SFM_32k, 1);
+ if (EQ_32(L_core_brate, HQ_24k40))
+ {
+ high_sfm = sub(HVQ_THRES_SFM_24k, 1);
+ }
+
+ if( LT_16(last_sfm, high_sfm))
+ {
+ last_sfm = high_sfm;
+ move16();
+ }
+ }
+ ELSE if ( EQ_16(HQ_mode, HQ_HVQ))
+ {
+ bin_th = sfm_end[last_sfm];
+ move16();
+ }
+
+ /* Transient analysis for envelope stability measure */
+ IF ( EQ_16(length, L_FRAME32k))
+ {
+ env_stab_transient_detect_fx( is_transient, length, norm, no_att_hangover, L_energy_lt, HQ_mode, bin_th, L_coeff_out, 12 );
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF ( EQ_16(length, L_FRAME16k)||
+ ((EQ_16(length, L_FRAME32k) && NE_16(HQ_mode, HQ_HARMONIC) && NE_16(HQ_mode, HQ_HVQ) ) && *no_att_hangover == 0) )
+ {
+ /* Norm adjustment function */
+ env_adj_fx( npulses, length, last_sfm, norm_adj, env_stab, sfmsize );
+ }
+
+ /*flag_32K_env_hangover = ( length == L_FRAME32k && ( (env_stab < 0.5f && *no_att_hangover == 0) || HQ_mode == HQ_HVQ ) ); */
+ flag_32K_env_hangover = 0;
+ move16();
+ test();
+ test();
+ test();
+ if ( EQ_16(length, L_FRAME32k)&&((LT_16(env_stab,16384)&&*no_att_hangover==0)||EQ_16(HQ_mode,HQ_HVQ)))
+ {
+ flag_32K_env_hangover = 1;
+ move16();
+ }
+
+
+ /*----------------------------------------------------------------*
+ * Build noise-fill codebook
+ *----------------------------------------------------------------*/
+
+ IF ( NE_16(HQ_mode, HQ_HVQ))
+ {
+ cb_size = build_nf_codebook_fx(flag_32K_env_hangover, coeff, sfm_start, sfmsize, sfm_end, last_sfm, R, CodeBook, CodeBook_mod);
+ }
+ /*----------------------------------------------------------------*
+ * Prepare fine structure for Harmonic and HVQ
+ *----------------------------------------------------------------*/
+
+ IF ( EQ_16(HQ_mode, HQ_HARMONIC))
+ {
+ harm_bwe_fine_fx( R, last_sfm, high_sfm, num_sfm, norm, sfm_start, sfm_end, prev_L_swb_norm, coeff, L_coeff_out, coeff_fine );
+ }
+ ELSE IF ( EQ_16(HQ_mode, HQ_HVQ))
+ {
+ hvq_bwe_fine_fx( last_sfm, num_sfm, sfm_end, peak_idx, Npeaks, peak_pos, prev_L_swb_norm, L_coeff_out, bwe_peaks, coeff_fine );
+ }
+
+ /*----------------------------------------------------------------*
+ * Apply noise-fill
+ *----------------------------------------------------------------*/
+
+ test();
+ IF ( NE_16(HQ_mode, HQ_HVQ)&&cb_size>0)
+ {
+ apply_noisefill_HQ_fx( R, length, flag_32K_env_hangover, L_core_brate, last_sfm, CodeBook,
+ CodeBook_mod, cb_size, sfm_start, sfm_end, sfmsize, coeff );
+ }
+
+ /*----------------------------------------------------------------*
+ * Normal mode BWE
+ *----------------------------------------------------------------*/
+
+ IF ( HQ_mode == HQ_NORMAL )
+ {
+ hq_fold_bwe_fx(last_sfm, sfm_end, num_sfm, coeff);
+ }
+
+ /*----------------------------------------------------------------*
+ * Apply noise-fill adjustment
+ *----------------------------------------------------------------*/
+
+ test();
+ test();
+ test();
+ IF( (GE_16(length, L_FRAME32k)||GT_32(L_core_brate,HQ_32k)||LT_32(L_core_brate,HQ_24k40))
+ && NE_16(HQ_mode, HQ_HVQ) )
+ {
+ apply_nf_gain_fx(nf_idx, last_sfm, R, sfm_start, sfm_end, coeff);
+ }
+
+ /*----------------------------------------------------------------*
+ * Prepare fine strucutre for HQ GENERIC
+ *----------------------------------------------------------------*/
+ test();
+ IF ( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB))
+ {
+ hq_generic_fine_fx( coeff, last_sfm, sfm_start, sfm_end, bwe_seed, coeff_fine );
+ }
+
+ /*----------------------------------------------------------------*
+ * Apply envelope
+ *----------------------------------------------------------------*/
+
+ test();
+ IF ( NE_16(HQ_mode, HQ_HARMONIC)&&NE_16(HQ_mode,HQ_HVQ))
+ {
+ apply_envelope_fx( coeff, norm, norm_adj, num_sfm, last_sfm, HQ_mode, length, sfm_start, sfm_end,
+ L_normq_v, L_coeff_out, coeff_fine, L_coeff_out1 );
+ }
+
+ /*----------------------------------------------------------------*
+ * Harmonic BWE, HVQ BWE and HQ SWB BWE
+ *----------------------------------------------------------------*/
+ test();
+ IF ( EQ_16(HQ_mode, HQ_HARMONIC))
+ {
+ harm_bwe_fx( coeff_fine, coeff, num_sfm, sfm_start, sfm_end, last_sfm, R, prev_hq_mode, norm, noise_level, prev_noise_level, bwe_seed, L_coeff_out );
+ }
+ ELSE IF ( EQ_16(HQ_mode, HQ_HVQ))
+ {
+ hvq_bwe_fx( L_coeff_out, coeff_fine, sfm_start, sfm_end, sfmsize, last_sfm,
+ prev_hq_mode, bwe_peaks, bin_th, num_sfm, L_core_brate, R, norm,
+ noise_level, prev_noise_level, bwe_seed, L_coeff_out, 15, 12 );
+ }
+ ELSE IF ( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB))
+ {
+ hq_bwe_fx( HQ_mode, L_coeff_out1, hq_generic_fenv, L_coeff_out, hq_generic_offset, prev_L_swb_norm, hq_generic_exc_clas, sfm_end, num_sfm, num_env_bands, R );
+ }
+
+ /*----------------------------------------------------------------*
+ * HQ WB BWE refinements
+ *----------------------------------------------------------------*/
+ test();
+ IF ( EQ_16(length, L_FRAME16k)&&EQ_32(L_core_brate,HQ_32k))
+ {
+ hq_wb_nf_bwe_fx( coeff, is_transient, prev_bfi, L_normq_v, num_sfm, sfm_start, sfm_end, sfmsize, last_sfm, R,
+ prev_is_transient, prev_normq, prev_env, bwe_seed, prev_coeff_out, prev_R, L_coeff_out, prev_env_Q );
+ }
+
+ /*----------------------------------------------------------------*
+ * Update memories
+ *----------------------------------------------------------------*/
+
+ test();
+ IF ( NE_16(HQ_mode, HQ_HARMONIC)&&NE_16(HQ_mode,HQ_HVQ))
+ {
+ prev_noise_level[0] = 3277;
+ move16();/* 0.1 in Q15 */
+ prev_noise_level[1] = 3277;
+ move16();/* 0.1 in Q15 */
+ }
+ test();
+ IF ( !(EQ_16(length, L_FRAME16k)&&EQ_32(L_core_brate,HQ_32k)))
+ {
+ set32_fx( prev_env, 0, SFM_N_WB );
+ set32_fx( prev_normq, 0, SFM_N_WB );
+ }
+
+ test();
+ IF ( EQ_16(length, L_FRAME32k)&&LE_32(L_core_brate,HQ_32k))
+ {
+ *prev_R = R[SFM_N_WB-1];
+ Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out, L_HQ_WB_BWE );
+ }
+
+ return;
+}
diff --git a/lib_com/findpulse_fx.c b/lib_com/findpulse_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f292b65847cd9d05a3d68d700555079d608d65e1
--- /dev/null
+++ b/lib_com/findpulse_fx.c
@@ -0,0 +1,117 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+/*----------------------------------------------------------------------------------*
+ * findpulse()
+ *
+ * Find first pitch pulse in a frame
+ *----------------------------------------------------------------------------------*/
+Word16 findpulse_fx( /* o : pulse position */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 res[], /* i : Residual signal <12 bits */
+ const Word16 T0, /* i : Pitch estimation Q0 */
+ const Word16 enc, /* i : enc = 1 -> encoder side; enc = 0 -> decoder side */
+ Word16 *sign /* i/o: sign of the maximum */
+)
+{
+ const Word16 *ptr;
+ Word16 maxval;
+ Word16 i, maxi;
+ Word32 Ltmp;
+ Word16 resf[L_FRAME16k]; /* Low pass filtered residual */
+
+ IF (enc != DEC)
+ {
+ /*------------------------------------------------------------------------*
+ * 1. Very simple LP filter
+ *------------------------------------------------------------------------*/
+
+ /* resf[0] = 0.50f * res[0] + 0.25f * res[1] */
+ Ltmp = L_mult(res[0], 16384);
+ resf[0] = mac_r(Ltmp, res[1], 8192);
+ move16();
+ FOR (i=1; i= 0)
+ {
+ *sign = 0; move16();
+ }*/
+ *sign = negate(shr(ptr[-maxi], 15));
+ move16();
+ }
+ ELSE
+ {
+ /*-----------------------------------------------------------------*
+ * 2. Find "biggest" pulse in the last pitch section according to the sign
+ *-----------------------------------------------------------------*/
+
+ maxval = 0;
+ move16();
+ maxi = 0;
+ move16();
+
+ IF (*sign == 0)
+ {
+ FOR (i = 0; i < T0; i++)
+ {
+ if (GE_16(res[i], maxval))
+ {
+ maxi = add(i, 1);
+ }
+ maxval = s_max(res[i], maxval);
+ }
+ }
+ ELSE
+ {
+ FOR (i = 0; i < T0; i++)
+ {
+ if (LE_16(res[i], maxval))
+ {
+ maxi = add(i, 1);
+ }
+ maxval = s_min(res[i], maxval);
+ }
+ }
+ }
+
+ return maxi;
+}
diff --git a/lib_com/fine_gain_bits_fx.c b/lib_com/fine_gain_bits_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..d6db7260ea16b162cd85c43514c21d3b8ace3166
--- /dev/null
+++ b/lib_com/fine_gain_bits_fx.c
@@ -0,0 +1,107 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+
+
+/*--------------------------------------------------------------------------
+ * subband_gain_bits()
+ *
+ * HQ core encoder
+ *--------------------------------------------------------------------------*/
+
+void subband_gain_bits_fx(
+ const Word16 *Rk, /* i : bit allocation per band Q3 */
+ const Word16 N, /* i : number of bands */
+ Word16 *bits, /* o : gain bits per band */
+ const Word16 *sfmsize /* i : Size of bands */
+)
+{
+ Word16 i,b,tot;
+ Word16 bps;
+
+ tot = 0;
+ move16();
+
+ FOR ( i = 0; i < N; i++ )
+ {
+ /*bps = (short)(Rk[i]*((word16)min(32767, ceil(32767.0f/sfmsize[i]); inexact C-integer division approx. */
+ bps = extract_l(L_shr(L_mult0(Rk[i], inv_tbl_fx[sfmsize[i]]), 18)); /* 3+15 */
+ if (EQ_32(L_shl(L_mult0(sfmsize[i], add(bps, 1)), 3), Rk[i]))
+ {
+ bps = add(bps, 1);
+ }
+
+ bps = s_min(7, bps);
+ b = fine_gain_bits[bps];
+ move16();
+ bits[i] = b;
+ move16();
+ tot = add(tot, b);
+ }
+
+ if ( tot == 0)
+ {
+ /* If no gain bits were assigned, use one bit anyway for potential PVQ overage */
+ bits[0] = 1;
+ move16();
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * assign_gain_bits()
+ *
+ * Assign gain adjustment bits and update bit budget
+ *--------------------------------------------------------------------------*/
+
+Word16 assign_gain_bits_fx( /* o : Number of assigned gain bits */
+ const Word16 core, /* i : HQ core */
+ const Word16 BANDS, /* i : Number of bands */
+ const Word16 *band_width, /* i : Sub band bandwidth */
+ Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */
+ Word16 *gain_bits_array, /* o : Assigned gain bits */
+ Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */
+)
+{
+ Word16 subband_cnt;
+ Word16 gain_bits_tot;
+ Word16 i;
+
+ /* Allocate gain bits for every subband used, based on bit rate and bandwidth */
+ IF( EQ_16(core, HQ_CORE))
+ {
+ subband_gain_bits_fx(Rk, BANDS, gain_bits_array, band_width);
+ }
+ ELSE
+ {
+ set16_fx( gain_bits_array, 0, BANDS );
+ }
+
+ /* Re-adjust bit budget for gain quantization */
+ subband_cnt = 0;
+ move16();
+ gain_bits_tot = 0;
+ move16();
+ *Rcalc = 0;
+ move16();
+ FOR (i = 0; i < BANDS; i++)
+ {
+ IF (Rk[i] > 0)
+ {
+ subband_cnt = add(subband_cnt, 1);
+ Rk[i] = sub(Rk[i], shl(gain_bits_array[i], 3));
+ move16();
+ gain_bits_tot = add(gain_bits_tot, gain_bits_array[i]);
+ *Rcalc = add(*Rcalc, Rk[i]);
+ move16();
+ }
+ }
+
+ return gain_bits_tot;
+}
diff --git a/lib_com/frame_ener_fx.c b/lib_com/frame_ener_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..a70235e53e4b69a8413455723d99b51c4928e826
--- /dev/null
+++ b/lib_com/frame_ener_fx.c
@@ -0,0 +1,196 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+/*----------------------------------------------------------------------------------*
+ * frame_ener()
+ *
+ * Estimation of pitch-synchronous (voiced) or mean half-frame (unvoiced) energy
+ *----------------------------------------------------------------------------------*/
+Word16 frame_ener_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 clas, /* i : frame classification */
+ const Word16 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q_new */
+ const Word16 pitch, /* i : pitch period Q0 */
+ Word32 *enr_q, /* o : pitch-synchronous or half_frame energy Q0 */
+ const Word16 offset, /* i : speech pointer offset (0 or L_FRAME) */
+ const Word16 Q_new, /* i : Scaling factor */
+ Word16 shift, /* i : Shift need to obtain 12 bits vectors */
+ const Word16 enc /* i : Encoder/decoder */
+)
+{
+ Word16 len, exp_enrq, exp_tmp, pos;
+ Word16 i;
+ const Word16 *pt_synth;
+ Word32 Ltmp;
+
+ exp_enrq = 0;
+ move16();
+ test();
+ test();
+ IF( (EQ_16(clas, VOICED_CLAS))||(EQ_16(clas,ONSET))||(EQ_16(clas,SIN_ONSET))) /* current frame is voiced */
+ {
+ /* current frame is voiced */
+ len = pitch;
+ move16(); /* pitch value at the end of frame */
+ pt_synth = synth;
+ move16();
+ if (offset != 0)
+ {
+ pt_synth = synth + sub(L_frame, len);
+ }
+ emaximum_fx(Q_new, pt_synth, len, enr_q);
+ move16();/* pitch synchronous E */
+ IF (enc != 0)
+ {
+ exp_enrq = norm_l(*enr_q);
+ *enr_q = L_shl(*enr_q, exp_enrq);
+ move32();
+ exp_enrq = sub(exp_enrq, 2);
+ }
+ }
+ ELSE
+ {
+ /* current frame is unvoiced */
+ Word16 L_frame2, exp2, enr_q_tmp;
+
+ L_frame2 = shr(L_frame,1);
+ pos = 0;
+ move16();
+
+ if (offset != 0)
+ {
+ pos = sub(L_frame, L_frame2);
+ }
+ Ltmp = L_mult(synth[pos], synth[pos]);
+ FOR (i = 1; i < L_frame2; i++)
+ {
+ Ltmp = L_mac(Ltmp, synth[pos+i], synth[pos+i]);
+ }
+ test();
+ IF (EQ_32(Ltmp, MAX_32)||enc!=0)
+ {
+ /* scale down when overflow occurs */
+ *enr_q = Energy_scale(synth+pos, L_frame2, shift, &exp_enrq);
+ move32();
+ }
+ ELSE
+ {
+ shift = 0;
+ move16();
+ /* Normalize acc in Q31 (energy already calculated) */
+ pos = norm_l(Ltmp);
+ Ltmp = L_shl(Ltmp, pos);
+ exp_enrq = sub(30, pos); /* exponent = 0..30 */
+ *enr_q = Ltmp;
+ move32();
+ }
+
+ /* enr2 = 1.0f/L_FRAME2 * dot_product(synth, synth, L_FRAME2) */
+ exp_enrq = sub(exp_enrq, shl(shift, 1));
+
+ IF (enc != 0)
+ {
+ assert(L_frame == 256 || L_frame == 320);
+
+ exp_tmp = add(shl(Q_new, 1), -2+7); /* L_subfr == L_SUBFR */
+ exp_enrq = sub(exp_enrq, exp_tmp);
+ exp_enrq = sub(31, exp_enrq);
+
+ IF(EQ_16(L_frame, 320))
+ {
+ *enr_q = Mult_32_16(*enr_q, 26214); /*x 0.8 to get /160*/
+ i = norm_l(*enr_q);
+ *enr_q = L_shl(*enr_q, i);
+ exp_enrq = add(i, exp_enrq);
+ }
+ }
+ ELSE
+ {
+ exp_enrq = sub(exp_enrq, add(Q_new, Q_new));
+ enr_q_tmp /*Q30 exp2+exp_enrq*/ = BASOP_Util_Divide3216_Scale(*enr_q /*Q31*/, L_frame2 /*Q0*/, &exp2);
+ *enr_q = L_shr(L_deposit_l(enr_q_tmp),sub(30,add(exp2,exp_enrq))); /*Q0*/
+ *enr_q = L_add(*enr_q, 1);
+ move32();
+ exp_enrq = 0;
+ move16();
+ }
+
+
+
+
+
+
+ }
+
+ return exp_enrq;
+}
+
+/*------------------------------------------------------------------------*
+ * frame_energy()
+ *
+ * Compute pitch-synchronous energy at the frame end
+ *------------------------------------------------------------------------*/
+Word16 frame_energy_fx( /* o : Frame energy in Q8 */
+ Word16 L_frame,
+ const Word16 *pitch, /* i : pitch values for each subframe Q6 */
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_syn*/
+ const Word16 lp_speech, /* i : long term active speech energy average Q8 */
+ Word16 *frame_ener, /* o : pitch-synchronous energy at frame end Q8 */
+ const Word16 Q_syn /* i : Synthesis scaling */
+)
+{
+ Word32 Ltmp;
+ const Word16 *pt1;
+ Word16 tmp16, exp1, exp2, tmp1, tmp2;
+ Word16 len, enern;
+
+ /* len = (0.5f * (pitch[2]/64.0 + pitch[3]/64.0) + 0.5f) */
+ len = mult_r(add(pitch[2], pitch[3]), 256);
+
+ if(LT_16(len,L_SUBFR))
+ {
+ len = shl(len, 1);
+ }
+ pt1 = speech + sub(L_frame,len);
+
+ /* *frame_ener = 10.0f * log10(dot_product(pt1, pt1, len) / (float)len) */
+
+ tmp1 = norm_s(len);
+ tmp2 = shl(len, tmp1);
+ tmp1 = sub(15, tmp1);
+
+ Ltmp = Dot_productSq16HQ( 0, pt1, len, &exp1);
+ exp1 = sub(exp1, shl(Q_syn, 1));
+ exp1 = sub(exp1, 1); /* compensation of leftshift caused by mac operation in dot_productSq16HQ */
+ tmp16 = BASOP_Util_Divide3216_Scale( Ltmp, len, &exp2);
+
+ exp1 = add(exp1, exp2);
+ exp1 = add(exp1, 1); /* compensate result of division Q-1 */
+
+
+ tmp2 = norm_s(tmp16);
+ Ltmp = L_shl(L_deposit_h(tmp16),tmp2); /*Q16, (exp1-tmp2) = Q31, exp1-tmp2+15*/
+
+ Ltmp = BASOP_Util_Log2(Ltmp);/*Q(31-6) = Q25*/
+ exp1 = sub(15+exp1,tmp2);
+
+ /*add ld(2^exp1)=exp1 but check format, first*/
+ tmp16=sub(sub(15,norm_s(exp1)),5); /*factor to shift Ltmp and exp1 with (shr) to avoid overflows when adding*/
+ Ltmp= L_shr(Ltmp,tmp16); /*Q25, tmp16*/
+ exp2 = shr(exp1,tmp16); /*Q0 , tmp16*/
+ Ltmp = L_add(Ltmp,L_shl(L_deposit_l(exp2),25)); /*Q25, tmp16, normalized*/
+
+ /*make 10*log10 out of log2*/
+ Ltmp = Mpy_32_16_1(Ltmp,LG10); /*Q25,tmp16 * Q13 = Q23, tmp16*/
+ *frame_ener = extract_h(L_shl(Ltmp,add(tmp16,1)));/*Q8*/ move16();
+ enern = sub( *frame_ener ,lp_speech); /*Q8*/
+
+ return enern;
+}
diff --git a/lib_com/g192.c b/lib_com/g192.c
new file mode 100644
index 0000000000000000000000000000000000000000..05ad613443a08e809ea128ee598fd7e8e18eec7a
--- /dev/null
+++ b/lib_com/g192.c
@@ -0,0 +1,254 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.442 May 28, 2020. Version 12.13.0 / 13.8.0 / 14.4.0 / 15.2.0 / 16.0.0
+ ====================================================================================*/
+
+#include
+#include
+#include
+#include
+
+#ifndef _WIN32
+#include
+#include
+#else
+#include
+typedef unsigned short uint16_t;
+typedef signed short int16_t;
+typedef unsigned int uint32_t;
+typedef signed int int32_t;
+typedef unsigned __int64 uint64_t;
+typedef signed __int64 int64_t;
+#endif
+#include "options.h"
+#include "stl.h"
+#include "g192.h"
+
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4996 )
+#endif
+
+#define G192_SYNC_GOOD_FRAME (Word16)0x6B21
+#define G192_SYNC_BAD_FRAME (Word16)0x6B20
+#define G192_BIT0 (Word16)0x007F
+#define G192_BIT1 (Word16)0x0081
+#define MAX_BITS_PER_FRAME 2560
+#define RTP_HEADER_PART1 (Word16)22 /* magic number by network simulator */
+
+/*
+ * Structures
+ */
+
+/* main handle */
+struct __G192
+{
+ FILE * file;
+};
+
+/*
+ * Functions
+ */
+
+G192_ERROR
+G192_Reader_Open(G192_HANDLE* phG192, FILE * filename)
+{
+ /* create handle */
+ *phG192 = (G192_HANDLE) calloc(1, sizeof(struct __G192) );
+ if ( *phG192 == NULL )
+ {
+ return G192_MEMORY_ERROR;
+ }
+
+ memset(*phG192, 0, sizeof(struct __G192));
+
+ /* associate file stream */
+ (*phG192)->file = filename;
+ if( (*phG192)->file == NULL )
+ {
+ G192_Reader_Close(phG192);
+ return G192_FILE_NOT_FOUND;
+ }
+
+ return G192_NO_ERROR;
+}
+
+G192_ERROR
+G192_ReadVoipFrame_compact(G192_HANDLE const hG192,
+ unsigned char * const serial,
+ Word16 * const num_bits,
+ Word16 *rtpSequenceNumber,
+ Word32 *rtpTimeStamp,
+ Word32 *rcvTime_ms)
+{
+ Word16 short_serial [MAX_BITS_PER_FRAME];
+ G192_ERROR err;
+ Word16 i;
+
+ err = G192_ReadVoipFrame_short(hG192, short_serial, num_bits, rtpSequenceNumber, rtpTimeStamp, rcvTime_ms);
+ if(err != G192_NO_ERROR)
+ {
+ return err;
+ }
+
+ for(i=0; i<*num_bits; i++)
+ {
+ unsigned char bit = (short_serial[i] == G192_BIT1) ? 1 : 0;
+ unsigned char bitinbyte = bit << (7- (i&0x7));
+ if(!(i&0x7))
+ serial[i>>3] = 0;
+ serial[i>>3] |= bitinbyte;
+ }
+
+ return G192_NO_ERROR;
+}
+
+G192_ERROR
+G192_ReadVoipFrame_short(G192_HANDLE const hG192,
+ Word16 * const serial,
+ Word16 *num_bits,
+ Word16 *rtpSequenceNumber,
+ Word32 *rtpTimeStamp,
+ Word32 *rcvTime_ms)
+{
+ Word32 rtpPacketSize;
+ Word16 rtpPacketHeaderPart1;
+ Word32 ssrc;
+ Word16 rtpPayloadG192[2];
+ Word16 rtpPayloadSize;
+
+ /* RTP packet size */
+ if(fread(&rtpPacketSize, sizeof(rtpPacketSize), 1, hG192->file) != 1)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "RTP Packet Size could't be read\n");
+ return G192_READ_ERROR;
+ }
+
+ if(rtpPacketSize <= 12)
+ {
+ fprintf(stderr, "RTP Packet size too small: %d\n", rtpPacketSize);
+ return G192_INVALID_DATA;
+ }
+
+ /* RTP packet arrival time */
+ if(fread(rcvTime_ms, sizeof(*rcvTime_ms), 1, hG192->file) != 1)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "Reception Time in ms could't be read\n");
+ return G192_READ_ERROR;
+ }
+
+ /* RTP packet header (part without sequence number) */
+ if(fread(&rtpPacketHeaderPart1, sizeof(rtpPacketHeaderPart1), 1, hG192->file) != 1)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "RTP Header couldn't be read\n");
+ return G192_READ_ERROR;
+ }
+
+ if(rtpPacketHeaderPart1 != RTP_HEADER_PART1)
+ {
+ fprintf(stderr, "Unexpected RTP Packet header\n");
+ return G192_INVALID_DATA;
+ }
+
+ /* RTP sequence number */
+ if(fread(rtpSequenceNumber, sizeof(*rtpSequenceNumber), 1, hG192->file) != 1)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "RTP Sequence Number be read\n");
+ return G192_READ_ERROR;
+ }
+
+ *rtpSequenceNumber = ntohs(*rtpSequenceNumber);
+ /* RTP timestamp */
+ if(fread(rtpTimeStamp, sizeof(*rtpTimeStamp), 1, hG192->file) != 1)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "RTP Timestamp could't be read\n");
+ return G192_READ_ERROR;
+ }
+
+ *rtpTimeStamp = ntohl(*rtpTimeStamp);
+ /* RTP ssrc */
+ if(fread(&ssrc, sizeof(ssrc), 1, hG192->file) != 1)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "RTP SSRC could't be read\n");
+ return G192_READ_ERROR;
+ }
+
+ /* RTP payload size */
+ rtpPayloadSize = (Word16)(rtpPacketSize - 12);
+ if(rtpPayloadSize <= 2)
+ {
+ fprintf(stderr, "RTP payload size too small: %d\n", rtpPayloadSize);
+ return G192_INVALID_DATA;
+ }
+ /* RTP payload */
+ if(fread(rtpPayloadG192, sizeof(Word16), 2, hG192->file) != 2)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "Premature end of file, cannot read G.192 header\n");
+ return G192_READ_ERROR;
+ }
+ if(rtpPayloadG192[0] != G192_SYNC_GOOD_FRAME)
+ {
+ fprintf(stderr, "G192_SYNC_WORD missing from RTP payload!");
+ return G192_INVALID_DATA;
+ }
+ *num_bits = rtpPayloadG192[1];
+ if(*num_bits == 0 || *num_bits + 2 != rtpPayloadSize || *num_bits > MAX_BITS_PER_FRAME)
+ {
+ fprintf(stderr, "error in parsing RTP payload: rtpPayloadSize=%u nBits=%d",
+ rtpPayloadSize, *num_bits);
+ return G192_INVALID_DATA;
+ }
+ if( (Word16)fread(serial, sizeof(Word16), *num_bits, hG192->file) != *num_bits)
+ {
+ if(feof( hG192->file) != 0)
+ {
+ return G192_EOF;
+ }
+ fprintf(stderr, "Premature end of file, cannot read G.192 payload\n");
+ return G192_READ_ERROR;
+ }
+
+ return G192_NO_ERROR;
+}
+
+G192_ERROR
+G192_Reader_Close(G192_HANDLE* phG192)
+{
+ if(phG192 == NULL || *phG192 == NULL)
+ {
+ return G192_NO_ERROR;
+ }
+
+ free( *phG192 );
+ *phG192 = NULL;
+ phG192 = NULL;
+
+ return G192_NO_ERROR;
+}
diff --git a/lib_com/g192.h b/lib_com/g192.h
new file mode 100644
index 0000000000000000000000000000000000000000..12981f6f78db56a7d474856419d68f5b4a242330
--- /dev/null
+++ b/lib_com/g192.h
@@ -0,0 +1,64 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.442 May 28, 2020. Version 12.13.0 / 13.8.0 / 14.4.0 / 15.2.0 / 16.0.0
+ ====================================================================================*/
+
+#ifndef G192_H
+#define G192_H G192_H
+
+/*
+ * ENUMS
+ */
+
+/* error enums */
+
+typedef enum _G192_ERROR
+{
+ G192_NO_ERROR = 0x0000,
+ G192_MEMORY_ERROR = 0x0001,
+ G192_WRONG_PARAMS = 0x0002,
+ G192_INIT_ERROR = 0x0003,
+ G192_WRITE_ERROR = 0x0004,
+ G192_READ_ERROR = 0x0005,
+ G192_FILE_NOT_FOUND = 0x0006,
+ G192_INVALID_DATA = 0x0007, /* error returned when read data is invalid */
+ G192_NOT_IMPLEMENTED = 0x0010,
+ G192_NOT_INITIALIZED = 0x0100,
+ G192_UNKNOWN_ERROR = 0x1000,
+ G192_EOF = 0xffff /* EOF during reading */
+} G192_ERROR;
+
+/*
+ * Structures
+ */
+
+/* main handle */
+struct __G192;
+typedef struct __G192 * G192_HANDLE;
+
+/*
+ * Functions
+ */
+
+G192_ERROR
+G192_Reader_Open(G192_HANDLE* phG192, FILE * filename);
+
+G192_ERROR
+G192_ReadVoipFrame_compact(G192_HANDLE const hG192,
+ unsigned char * const serial,
+ Word16 * const num_bits,
+ Word16 *rtpSequenceNumber,
+ Word32 *rtpTimeStamp,
+ Word32 *rcvTime_ms);
+
+G192_ERROR
+G192_ReadVoipFrame_short(G192_HANDLE const hG192,
+ Word16 * const serial,
+ Word16 *num_bits,
+ Word16 *rtpSequenceNumber,
+ Word32 *rtpTimeStamp,
+ Word32 *rcvTime_ms);
+
+G192_ERROR
+G192_Reader_Close(G192_HANDLE* phG192);
+
+#endif /* G192_H */
diff --git a/lib_com/gain_inov.c b/lib_com/gain_inov.c
new file mode 100644
index 0000000000000000000000000000000000000000..703054cc05030a0adc532b3e57f5c7dc69f1903a
--- /dev/null
+++ b/lib_com/gain_inov.c
@@ -0,0 +1,54 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "prot_fx.h"
+#include "stl.h"
+#include "basop_util.h"
+#include "rom_com_fx.h"
+
+
+Word32 calc_gain_inov( /* returns innovation gain Q16 */
+ const Word16 *code, /* i : algebraic excitation Q9 */
+ Word16 lcode, /* i : Subframe size Q0 */
+ Word32 *dotp, /* o : intermediate result Q31-e */
+ Word16 *dotp_e /* o : intermediate result exponent Q0 */
+)
+{
+ Word32 L_tmp;
+ Word16 exp_L_tmp, i;
+
+ /* L_tmp = dot_product(code, code, lcode) + 0.01 */
+ L_tmp = Dot_product12_offs(code, code, lcode, &exp_L_tmp, 2621l/*0.01f/2.0f Q19*/);
+ exp_L_tmp = sub(exp_L_tmp, 18);
+
+ /* gain_inov = 1.0f / sqrt((dot_product(code, code, lcode) + 0.01) / lcode) */
+ /* Note: lcode is in range: 32,40,64,80 */
+ assert((lcode == 32) || (lcode == 40) || (lcode == 64) || (lcode == 80));
+ if (s_and(lcode, sub(lcode, 1)) != 0)
+ {
+ L_tmp = Mpy_32_32(L_tmp, 1717986918l/*64.0/80.0 Q31*/);
+ }
+ exp_L_tmp = sub(exp_L_tmp, sub(14, norm_s(lcode)));
+
+ i = norm_l(L_tmp);
+ L_tmp = L_shl(L_tmp, i);
+ exp_L_tmp = sub(exp_L_tmp, i);
+
+ if (dotp != NULL)
+ {
+ *dotp = L_tmp;
+ move32();
+ }
+ if (dotp_e != NULL)
+ {
+ *dotp_e = exp_L_tmp;
+ move16();
+ }
+
+ L_tmp = ISqrt32norm(L_tmp, &exp_L_tmp);
+
+ return L_shl(L_tmp, sub(exp_L_tmp, 15)); /* 15Q16 */
+}
+
diff --git a/lib_com/get_gain.c b/lib_com/get_gain.c
new file mode 100644
index 0000000000000000000000000000000000000000..9db8199567f9a798b2ab5742134d02df68500ba9
--- /dev/null
+++ b/lib_com/get_gain.c
@@ -0,0 +1,97 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "prot_fx.h"
+#include "stl.h"
+#include "basop_util.h"
+
+Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */
+ Word16 x[], /* input : target signal */
+ Word16 y[], /* input : filtered codebook excitation */
+ Word16 n /* input : segment length */
+)
+{
+ Word32 tcorr, tener, Lgain;
+ Word16 exp_c, exp_e, exp, tmp;
+
+
+ tcorr = L_deposit_l(0);
+ tener = L_deposit_l(0);
+
+
+
+ /*----------------------------------------------------------------*
+ * Find gain based on inter-correlation product
+ *----------------------------------------------------------------*/
+
+ tcorr = Dot_product16HQ( 0, x, y, n, &exp_c );
+ tener = Dot_productSq16HQ( 0, y, n, &exp_e );
+
+ BASOP_Util_Divide_MantExp(round_fx(tcorr), exp_c, s_max(round_fx(tener),1), exp_e, &tmp,&exp);
+ Lgain = L_shl(L_deposit_l(tmp)/*Q15*/,add(1,exp))/*Q16*/;
+
+ return Lgain;
+}
+
+Word32 get_gain2( /* output: codebook gain (adaptive or fixed) Q16 */
+ Word16 x[], /* input : target signal */
+ Word16 y[], /* input : filtered codebook excitation */
+ Word16 n /* input : segment length */
+)
+{
+ Word32 tcorr, tener, Lgain;
+ Word16 m_corr, m_ener, negative, Q_corr, Q_ener;
+
+ negative = 0;
+ move16();
+
+ /*----------------------------------------------------------------*
+ * Find gain based on inter-correlation product
+ *----------------------------------------------------------------*/
+ tcorr = Dot_product16HQ(0, x, y, n, &Q_corr);
+ tener = Dot_productSq16HQ(0, y, n, &Q_ener);
+
+ tener = L_max(tener, 1);
+
+ if (tcorr <= 0)
+ {
+ negative = 1;
+ move16();
+ }
+ BASOP_SATURATE_WARNING_OFF /*tcorr max be negative maxvall - not critical*/
+ tcorr = L_abs(tcorr);
+ BASOP_SATURATE_WARNING_ON
+
+ m_corr = extract_h(tcorr);
+
+ m_ener = extract_h(tener);
+
+ IF (GT_16(m_corr, m_ener))
+ {
+ m_corr = shr(m_corr, 1);
+ Q_corr = add(Q_corr,1);
+ }
+ if (m_ener==0)
+ {
+ move16();
+ m_corr = 0x7FFF;
+ }
+ if (m_ener != 0)
+ {
+ m_corr = div_s(m_corr, m_ener);
+ }
+
+ Q_corr = sub(Q_corr,Q_ener);
+
+ Lgain = L_shl(L_deposit_l(m_corr), add(Q_corr, 1)); /* Lgain in Q16 */
+
+ if (negative != 0)
+ {
+ Lgain = L_negate(Lgain); /* Lgain in Q16 */
+ }
+
+
+ return Lgain;
+}
diff --git a/lib_com/gs_bitallocation_fx.c b/lib_com/gs_bitallocation_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f82fb3f2440533834e20398ae7f3f10803382af8
--- /dev/null
+++ b/lib_com/gs_bitallocation_fx.c
@@ -0,0 +1,481 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "assert.h" /* Debug prototypes */
+#include "stl.h"
+
+/*==================================================================================*/
+/* FUNCTION : void bands_and_bit_alloc_fx(); */
+/*----------------------------------------------------------------------------------*/
+/* PURPOSE : AC mode (GSC) bands and bits allocation */
+/*----------------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) cor_strong_limit : HF correlation */
+/* _ (Word16) noise_lev : dwn scaling factor Q0 */
+/* _ (Word32) core_brate : core codec used Q0 */
+/* _ (Word16) Diff_len : Lenght of the difference signal Q0 */
+/* _ (Word16) bits_used : Number of bit used before frequency Q0 */
+/* _ (Word16) idx : Energy band 14 Q0 */
+/* _ (Word16*) exc_diff : Difference signal to quantize (Encoder only) */
+/* _ (Word16) coder_type : coding type Q0 */
+/* _ (Word16) bwidth : input signal bandwidth Q0 */
+/*----------------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) max_ener_band : Sorted order */
+/* _ (Word16*) nb_subbands : Number of subband allowed Q0 */
+/* _ (Word16*) concat_in : Concatened PVQ's input vector (Encoder Only) */
+/* _ (Word16*) pvq_len : Number of bin covered with the PVQ Q0 */
+/*----------------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16*) bit :Number of bit allowed for frequency quantization */
+/* _ (Word16*) Ener_per_bd_iQ : Quantized energy vector Q13 */
+/* _ (Word32*) bits_per_bands : Number of bit allowed per allowed subband Q18 */
+/*----------------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*==================================================================================*/
+void bands_and_bit_alloc_fx(
+ const Word16 cor_strong_limit, /* i : HF correlation */
+ const Word16 noise_lev, /* i : dwn scaling factor */
+ const Word32 core_brate, /* i : core bit rate */
+ const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
+ const Word16 bits_used, /* i : Number of bit used before frequency Q */
+ Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
+ const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */
+ Word16 *max_ener_band, /* o : Sorted order */
+ Word16 *out_bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */
+ Word16 *nb_subbands, /* o : Number of subband allowed */
+ const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */
+ Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
+ Word16 *pvq_len, /* o : Number of bin covered with the PVQ */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 GSC_noisy_speech
+)
+{
+
+ Word16 bandoffset, i, j, nb_bands_max, bit_new_bands, bit_tmp, st_band, nb_bands;
+ Word16 ener_vec[MBANDS_GN]; /*Q12 */
+ Word16 nb_tot_bands = 16;
+ Word16 bit_index, bit_index_mem, imax;
+ Word32 L_tmp;
+ Word32 sum_bit, bit_fracf;
+ Word16 etmp;
+ Word16 tmp;
+ Word16 Ener_per_bd_iQ_tmp[MBANDS_GN];
+ Word16 pos, band;
+ Word16 SWB_bit_budget;
+ Word32 bits_per_bands[MBANDS_GN];
+ Word16 w_sum_bit;
+
+ Copy( Ener_per_bd_iQ, Ener_per_bd_iQ_tmp, MBANDS_GN );
+
+ set32_fx( bits_per_bands, 0, MBANDS_GN );
+ set16_fx( out_bits_per_bands, 0, MBANDS_GN );
+
+ /* To adapt current energy band to PVQ freq band for sorting*/
+ ener_vec[0] = add(Ener_per_bd_iQ[0],Ener_per_bd_iQ[1]); /*Q12 */
+ Copy( Ener_per_bd_iQ_tmp+1, ener_vec, 15 ); /*Q12 */
+ ener_vec[15] = ener_vec[14];
+ move16();
+
+ /*------------------------------------------------------------------------
+ * Determination of the number of bits available to the frequency domain
+ * Allocation of a maximum number of band to be encoded
+ *-----------------------------------------------------------------------*/
+
+ nb_bands_max = nb_tot_bands;
+ move16();
+ bit_new_bands = 5;
+ move16();
+
+ bit_index = i_mult2(BRATE2IDX_fx(core_brate),17);
+ bit_index_mem = bit_index;
+ move16();
+
+ test();
+ test();
+ IF( (EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&EQ_16(bwidth,NB))
+ {
+ IF(GE_32(core_brate,ACELP_9k60))
+ {
+ /* *bit = (short)(core_brate*(1.0f/50) + 0.5f) - bits_used - 25; */
+ L_tmp = Mult_32_16(core_brate,20971);
+ tmp = extract_l(L_shr_r(L_tmp,5));
+ *bit = sub(sub(tmp,bits_used), 25);
+ move16();
+ }
+ ELSE
+ {
+ L_tmp = Mult_32_16(core_brate,20971);
+ tmp = extract_l(L_shr_r(L_tmp,5));
+ *bit = sub(sub(tmp,bits_used), 21);
+ move16();
+ }
+ nb_tot_bands = 10;
+ move16();
+ }
+ ELSE
+ {
+ /* *bit = (short)(core_brate*(1.0f/50) + 0.5f) - bits_used - GSC_freq_bits[bit_index]; */
+
+ L_tmp = Mult_32_16(core_brate,20971);
+ tmp = extract_l(L_shr_r(L_tmp,5));
+ *bit = sub(sub(tmp,bits_used),GSC_freq_bits[bit_index]);
+ move16();
+ }
+
+ IF( EQ_16(GSC_noisy_speech,1))
+ {
+ SWB_bit_budget = *bit;
+ move16();
+ nb_bands = 5;
+ move16();
+ st_band = nb_bands;
+ move16();
+
+ set32_fx( bits_per_bands, 0, MBANDS_GN );
+ /*bit_fracf = (1.0f/nb_bands)*(SWB_bit_budget); */
+ bit_fracf = L_mult(div_s(1,nb_bands),shl(SWB_bit_budget,2)); /* Q18 */
+
+ nb_tot_bands = sub(nb_bands_max,6);
+ nb_tot_bands = s_min(nb_tot_bands, 16);
+
+ FOR(j = 0; j < 2; j++)
+ {
+ i = j;
+ move16();
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = 0;
+ move16();
+ }
+
+ FOR(; j < nb_bands; j++)
+ {
+ i = maximum_fx(ener_vec, nb_tot_bands, &etmp);
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = 0;
+ move16();
+ }
+
+ set32_fx(bits_per_bands, bit_fracf, nb_bands);
+ }
+ ELSE
+ {
+ bit_index++;
+ bit_tmp = sub(*bit,GSC_freq_bits[bit_index]);
+ bit_index++;
+ nb_bands_max = add(nb_bands_max,GSC_freq_bits[bit_index]);
+ bit_index++;
+
+ *pvq_len = 112;
+ move16();
+ st_band = 7;
+ move16();
+
+ IF( LE_32(core_brate,ACELP_9k60))
+ {
+ *pvq_len = 80;
+ move16();
+ st_band = 5;
+ move16();
+
+ IF( Diff_len == 0 )
+ {
+ nb_bands_max = add(nb_bands_max,2);
+ bit_tmp = sub(bit_tmp,13);
+ }
+ }
+
+ ELSE IF( Diff_len == 0 )
+ {
+ nb_bands_max = add(nb_bands_max,2);
+ bit_tmp = sub(bit_tmp,17);
+ }
+
+ nb_bands = shr(*pvq_len,4);
+
+ /*------------------------------------------------------------------------
+ * Ajustement of the maximum number of bands in function of the
+ * dynamics of the spectrum (more or less speech like)
+ *-----------------------------------------------------------------------*/
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16(coder_type,INACTIVE)||GE_16(noise_lev,NOISE_LEVEL_SP3))
+ {
+ /* Probably classification error -> concentrate bits on LF */
+ nb_bands_max = nb_bands;
+ move16();
+ if( GE_32(core_brate,ACELP_8k00))
+ {
+ nb_bands_max = add(nb_bands,1);
+ }
+ }
+ ELSE IF( GE_16(noise_lev,NOISE_LEVEL_SP2)||
+ (LE_32(core_brate,ACELP_13k20) && GE_32(core_brate,ACELP_9k60) && cor_strong_limit == 0) ) /* Very low dynamic, tend to speech, do not try to code HF at all */
+ {
+ nb_bands_max = sub(nb_bands_max,2);
+ }
+ ELSE if( GE_16(noise_lev,NOISE_LEVEL_SP1)) /* Very low dynamic, tend to speech, code less HF */
+ {
+ nb_bands_max = sub(nb_bands_max,1);
+ }
+
+ test();
+ if( EQ_16(bwidth,NB)&>_16(nb_bands_max,10))
+ {
+ nb_bands_max = 10;
+ move16();
+ }
+
+ /*------------------------------------------------------------------------
+ * Find extra number of band to code according to bit rate availables
+ *-----------------------------------------------------------------------*/
+ WHILE ( GE_16(bit_tmp,bit_new_bands)&&LE_16(nb_bands,sub(nb_bands_max,1)))
+ {
+ bit_tmp = sub(bit_tmp,bit_new_bands);
+ nb_bands = add(nb_bands,1);
+ }
+
+ /*------------------------------------------------------------------------
+ * Fractional bits to distribute on the first x bands
+ *-----------------------------------------------------------------------*/
+
+ bit_fracf = L_mult(div_s(1,st_band),shl(bit_tmp,2)); /* Q18 */
+
+ /*------------------------------------------------------------------------
+ * Complete the bit allocation per frequency band
+ *-----------------------------------------------------------------------*/
+ imax = 5;
+ move16();
+
+ if( GT_32(core_brate,ACELP_9k60))
+ {
+ imax = 7;
+ move16();
+ }
+ FOR(i = 0; i < imax; i++)
+ {
+ bits_per_bands[i] = L_add(GSC_freq_bits_fx[bit_index],bit_fracf);
+ move32();/* Q18 */
+ bit_index = add(bit_index,1);
+ }
+
+ IF( Diff_len == 0 )
+ {
+ bit_index = add(bit_index_mem,10);
+ FOR( i = 0; i < 7; i++ )
+ {
+ bits_per_bands[i] = L_add(bits_per_bands[i],GSC_freq_bits_fx[bit_index]);
+ move32();/*chk Q18 */
+ bit_index = add(bit_index,1);
+ }
+ }
+
+ /*--------------------------------------------------------------------------
+ * Complete the bit allocation per frequency band for 16kHz high brate mode
+ *--------------------------------------------------------------------------*/
+
+ FOR( j = st_band; j < nb_bands; j++ )
+ {
+ bits_per_bands[j] = L_shl(bit_new_bands,18);
+ move32(); /*chk Q18 */
+ }
+
+ /*--------------------------------------------------------------------------
+ * Compute a maximum band (band offset) for the search on maximal energy
+ * This is function of the spectral dynamic and the bitrate
+ *--------------------------------------------------------------------------*/
+
+ bandoffset = sub(nb_tot_bands,add(nb_bands,2));
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( LE_16(noise_lev,NOISE_LEVEL_SP1a))
+ {
+ bandoffset = sub(bandoffset,1);
+ }
+ ELSE if ( (LE_32(core_brate,ACELP_13k20)&&(EQ_16(coder_type,INACTIVE)||GE_16(noise_lev,NOISE_LEVEL_SP3)))||
+ (LE_32(core_brate,ACELP_13k20) && GE_32(core_brate,ACELP_9k60) && cor_strong_limit == 0) )
+ {
+ bandoffset = add(bandoffset,1);
+ }
+
+ bandoffset = s_max(bandoffset ,0);
+
+ /*--------------------------------------------------------------------------
+ * Initiazed sorted vector
+ * For the first x bands to be included in th final sorted vector
+ * Sort the remaining bands in decrease energy order
+ *--------------------------------------------------------------------------*/
+ FOR(j = 0; j < nb_tot_bands; j++)
+ {
+ max_ener_band[j] = -10;
+ move16();
+ }
+ FOR(j = 0; j < st_band; j++)
+ {
+ max_ener_band[j] = j;
+ move16();
+ ener_vec[j] = -10;
+ move16();
+ }
+ pos = st_band;
+ move16();
+ FOR(; j < nb_bands; j++)
+ {
+ i = maximum_fx(ener_vec, sub(nb_tot_bands,bandoffset), &etmp);
+ pos = s_max(pos,i);
+ max_ener_band[j] = i;
+ move16();
+ ener_vec[i] = -10;
+ move16();
+ }
+
+ /* re-allocate bits to the frames such that the highest band with allocated bits is higher than the threshold */
+ test();
+ test();
+ test();
+ IF( GT_16(sub(nb_tot_bands, bandoffset),nb_bands)&&(GT_16(pos,7)&&EQ_32(core_brate,ACELP_8k00))&&EQ_16(bwidth,WB))
+ {
+ band = sub(nb_tot_bands, add(bandoffset,nb_bands));
+ FOR(j=0; j 0; bit_tmp--)
+ {
+ bits_per_bands[j] = L_sub(bits_per_bands[j],262144); /*Q18 */
+ j = add(j,1);
+ if ( EQ_16(j,sub(st_band, i)))
+ {
+ j = 0;
+ move16();
+ }
+ test();
+ if( j == 0 && LT_16(i,sub(st_band, 1)))
+ {
+ i = add(i,1);
+ }
+ }
+ }
+ }
+ /*--------------------------------------------------------------------------
+ * Bit sum verification for GSC inactive at very high rate
+ * The maximum number of bits per band of length 16 is 112
+ * Redistribute the overage bits if needed
+ *--------------------------------------------------------------------------*/
+ sum_bit = 0;
+ move16();
+ j = 0;
+ move16();
+ FOR( i = 0; i < nb_bands; i++ )
+ {
+ L_tmp = Mult_32_16(sum_bit,10923);
+
+ IF( GT_32(bits_per_bands[i],29360128)) /* 112 in Q18 */
+ {
+ sum_bit = L_add(sum_bit,L_sub(bits_per_bands[i],29360128)); /* Q18 */
+ bits_per_bands[i] = 29360128;
+ move32();
+ j = add(i,1);
+ }
+ ELSE if( GT_32(L_add(bits_per_bands[i],L_tmp),29360128 )) /* Q18 */
+ {
+ j = add(i,1);
+ }
+ }
+
+ IF( sum_bit != 0 )
+ {
+ tmp = sub(nb_bands,j);
+ sum_bit = Mult_32_16(sum_bit,div_s(1,tmp)); /* Q18 */
+ FOR( i = j; i < nb_bands; i++ )
+ {
+ bits_per_bands[i] = L_add(bits_per_bands[i],sum_bit);
+ move32();/* Q18 */
+ }
+ }
+ /*--------------------------------------------------------------------------
+ * second step of bit sum verification, normally sum_bit == *bit
+ *--------------------------------------------------------------------------*/
+ w_sum_bit = 0;
+ move16();
+ FOR( i = 0; i < nb_bands; i++ )
+ {
+ out_bits_per_bands[i] = shl(extract_l(L_shr(bits_per_bands[i],18)),3);
+ move16();
+ w_sum_bit = add(w_sum_bit,out_bits_per_bands[i]); /* Q3 */
+ }
+ tmp = shl(*bit,3);
+
+ IF( GT_16(tmp,w_sum_bit))
+ {
+ i = sub(nb_bands,1);
+ move16();
+ FOR( ; tmp > w_sum_bit; w_sum_bit += (1<<3) )
+ {
+ out_bits_per_bands[i] = add(out_bits_per_bands[i],1<<3);
+ move16();
+ i = sub(i, 1);
+ if(i==0)
+ {
+ i = sub(nb_bands,1);
+ }
+ }
+ }
+ /*--------------------------------------------------------------------------
+ * Recompute the real number/length of frequency bands to encode
+ *--------------------------------------------------------------------------*/
+ *nb_subbands = nb_bands;
+ move16();
+ *pvq_len = shl(*nb_subbands,4);
+
+ /*--------------------------------------------------------------------------
+ * Concatenate bands (encoder only)
+ *--------------------------------------------------------------------------*/
+ IF( exc_diff != NULL )
+ {
+ FOR( j = 0; j < nb_bands; j++ )
+ {
+ Copy( exc_diff + shl(max_ener_band[j],4), concat_in+shl(j,4), 16 );
+ }
+ }
+
+ return;
+}
diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..438c75016d15f61410dedeefef9e6db5f83274df
--- /dev/null
+++ b/lib_com/gs_gains_fx.c
@@ -0,0 +1,673 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+static Word16 VDQ_vec_fx( Word16 *Qvec_out_fx, const Word16 *mean_dic_fx, const Word16 *dic_fx,
+ const Word16 index_fx, const Word16 vec_en_fx );
+
+/*========================================================================*/
+/* FUNCTION : void Comp_and_apply_gain_enc_fx */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Compute and apply the quantized per band gain */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16[]) Ener_per_bd_iQ : Target ener per band Q12 */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16[]) exc_diffQ : Quantized excitation Qexc */
+/* _ (Word16[]) Ener_per_bd_yQ : Ener per band for norm vectori->Q12/o->Q2*/
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ None */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
+void Comp_and_apply_gain_fx(
+ Word16 exc_diffQ[], /* i/o: Quantized excitation */
+ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
+ Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */
+ Word16 Mbands_gn, /* i : number of bands */
+ const Word16 ReUseGain, /* i : Reuse the gain in Ener_per_bd_yQ */
+ Word16 Qexc_diff,
+ Word16 Q_exc
+)
+{
+ Word16 i, i_band;
+ Word16 StartBin, NB_Qbins;
+ Word16 y_gain;
+ Word16 L16, frac, exp1, tmp_exp;
+ Word32 L32;
+
+ /* Recreate excitation for local synthesis and decoder */
+ StartBin = 0;
+ move16();
+ NB_Qbins = 0;
+ move16();
+
+ tmp_exp = add(14,sub(Q_exc,Qexc_diff)); /* In case of reuse, it can be computed outside the loop*/
+ FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
+ {
+ StartBin = add(StartBin, NB_Qbins);
+ NB_Qbins = mfreq_bindiv_loc[i_band];
+ move16();
+ IF( EQ_16(ReUseGain,1))
+ {
+ y_gain = Ener_per_bd_yQ[i_band];
+ move16();
+
+ FOR(i = StartBin ; i < NB_Qbins + StartBin ; i++)
+ {
+ L32 = L_shl(L_mult(exc_diffQ[i], y_gain),tmp_exp); /*Q_exc+16 */
+ exc_diffQ[i] = round_fx(L32);/*Q_exc */
+ }
+ }
+ ELSE
+ {
+ /*-----------------------------------------------------------------*
+ * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
+ * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band]))
+ *-----------------------------------------------------------------*/
+ L16 = sub(Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band]);/*Q12 */
+ L32 = L_mult(L16, 27213); /* 3.321928 in Q13 -> Q26 */
+ L32 = L_shr(L32, 10); /* From Q26 to Q16 */
+ frac = L_Extract_lc(L32, &exp1); /* Extract exponent of gcode0 */
+ y_gain = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */
+ /* output of Pow2() will be: */
+ /* 16384 < Pow2() <= 32767 */
+ Ener_per_bd_yQ[i_band] = shl(y_gain, sub(exp1, 13));
+ move16();/*Q1 */
+ tmp_exp = add(add(exp1,1),sub(Q_exc,Qexc_diff));
+
+ FOR(i = StartBin ; i < NB_Qbins + StartBin ; i++)
+ {
+ L32 = L_mult(exc_diffQ[i], y_gain); /*Qexc_diff+15 */
+ exc_diffQ[i] = round_fx(L_shl(L32,tmp_exp)); /*Q_exc */
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*========================================================================*/
+/* FUNCTION : Ener_per_band_comp_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Compute the energy per band in log domain for quantization */
+/* purposes. */
+/* Loops are decomposed to accomodate the PVQ quantization */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16*) edct_table_128_fx : edct table Q15 */
+/* _ (Word16*) Q_exc_diff : input format of exc_diff */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16[]) y_gain4 : Energy per band to quantize Q12 */
+/* _ (Word32*) etmp14 : Energy band 14 Q_exc_diff*2+1 */
+/* _ (Word32*) etmp15 : Energy band 15 Q_exc_diff*2+1 */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
+static Word16 Comp_band_log_ener( /* o : Band gain Q12 */
+ const Word16 *pt_fx, /* i : Dct input Q_sc */
+ const Word16 Len, /* i : Lenght en energy accumulation */
+ const Word16 Q_sc, /* i : scaling of input */
+ const Word16 E_sc /* i : Additional scaling factor for energy */
+)
+{
+ Word32 L_tmp;
+ Word16 e_tmp, f_tmp, tmp16, ener_exp;
+
+ /*for(i = 0; i < 8; i++){etmp += (*pt * *pt);pt++;}*/
+ L_tmp = Calc_Energy_Autoscaled(pt_fx, Q_sc, Len, &ener_exp);
+
+ /*y_gain4[j] = (float)log10(sqrt(etmp< Q12 */
+ }
+ ELSE IF (LE_32(core_brate,ACELP_8k00))
+ {
+ Gain_off = 27034;
+ move16(); /* 6.6f -> Q12 */
+ }
+ ELSE IF (LE_32(core_brate,ACELP_9k60))
+ {
+ Gain_off = 19661;
+ move16(); /*4.8f-> Q12 */
+ }
+ ELSE IF (LE_32(core_brate,ACELP_11k60))
+ {
+ Gain_off = 14336;
+ move16(); /* 3.5f -> Q12 */
+ }
+ ELSE IF (LE_32(core_brate,ACELP_13k20))
+ {
+ Gain_off = 12288;
+ move16(); /* 3.0f -> Q12 dB */
+ }
+
+ /*mimic ACELP decay of energy for low rates*/
+ FOR( i = 0; i < MBANDS_GN; i++ )
+ {
+ old_y_gain[i] = y_gain_tmp[i];
+ move16();
+ /*y_gainQ[i] = y_gain_tmp[i]+mean_4g[0]-(i*(Gain_off/20.f)/((float) Mbands_gn));*/
+ y_gainQ[i] = add(y_gain_tmp[i], sub(mean_g, i_mult2(i, mult_r(Gain_off, 102))));
+ move16();
+ }
+ }
+
+ return;
+}
+/*==========================================================================*/
+/* FUNCTION : Word16 gsc_gaindec_fx () */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : Generic signal frequency band decoding and application */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) pvq_bits_fx : core used Q0 */
+/* _ (Word16) coder_type_fx : coding type Q0 */
+/* _ (Word16) core_fx : core used Q0 */
+/* _ (Word16) bwidth_fx : input signal bandwidth Q0 */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16[]) y_gainQ_fx : quantized gain per band */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16[]) old_y_gain_fx : AR gain quantizer for low rate */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word16) : average frequency gain */
+/*==========================================================================*/
+
+Word16 gsc_gaindec_fx( /* o : average frequency gain */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 y_gainQ_fx[], /* o : quantized gain per band */
+ const Word32 core_brate_fx, /* i : core used */
+ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 bwidth_fx /* i : input signal bandwidth */
+)
+{
+ Word16 idx_g_fx, i;
+ Word16 mean_4g_fx;
+ Word16 y_gain_tmp3_fx[MBANDS_GN];
+
+ test();
+ test();
+ IF( (EQ_16(coder_type_fx,AUDIO)||EQ_16(coder_type_fx,INACTIVE))&&EQ_16(bwidth_fx,NB))
+ {
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx(&mean_4g_fx, Gain_meanNB_fx, Gain_mean_dicNB_fx, idx_g_fx, 1 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ move16();
+ VDQ_vec_fx(y_gainQ_fx, Mean_dic_NB_fx, Gain_dic1_NB_fx, idx_g_fx, 3 );
+
+ IF(LT_32(core_brate_fx,ACELP_9k60))
+ {
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx(y_gainQ_fx+3, Mean_dic_NB_fx+3, Gain_dic2_NB_fx, idx_g_fx, 3 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
+ VDQ_vec_fx(y_gainQ_fx+6, Mean_dic_NB_fx+6, Gain_dic3_NB_fx, idx_g_fx, 4 );
+ }
+ ELSE
+ {
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx(y_gainQ_fx+3, Mean_dic_NB_fx+3, Gain_dic2_NBHR_fx, idx_g_fx, 3 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 7 );
+ VDQ_vec_fx(y_gainQ_fx+6, Mean_dic_NB_fx+6, Gain_dic3_NBHR_fx, idx_g_fx, 4 );
+ }
+ test();
+ IF( LE_32(core_brate_fx,ACELP_9k60)&&EQ_16(coder_type_fx,INACTIVE))
+ {
+ /* Some energy is needed in high band for stat_noise_uv_enc
+ to be functional in inactive speech */
+ y_gainQ_fx[10] = mean_fx(y_gainQ_fx+6, 3);
+ move16();
+ y_gainQ_fx[11] = mean_fx(y_gainQ_fx+7, 3);
+ move16();
+ y_gainQ_fx[12] = mean_fx(y_gainQ_fx+8, 3);
+ move16();
+ y_gainQ_fx[13] = mean_fx(y_gainQ_fx+9, 3);
+ move16();
+ y_gainQ_fx[14] = mean_fx(y_gainQ_fx+10, 3);
+ move16();
+ y_gainQ_fx[15] = mean_fx(y_gainQ_fx+11, 3);
+ move16();
+ }
+ ELSE
+ {
+ set16_fx( y_gainQ_fx + 10, 0, MBANDS_GN - 10 );
+ }
+ }
+ ELSE
+ {
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+
+ VDQ_vec_fx(&mean_4g_fx, mean_m_fx, mean_gain_dic_fx, idx_g_fx, 1 );
+
+ IF(LE_32(core_brate_fx,ACELP_9k60))
+ {
+ /*--------------------------------------------------------------------------------------*
+ * UQ of the first 8 bands and half of the last 8 bands
+ *--------------------------------------------------------------------------------------*/
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx(y_gainQ_fx, YGain_mean_LR_fx, YGain_dic1_LR_fx, idx_g_fx, 3 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx(y_gainQ_fx+3, YGain_mean_LR_fx+3, YGain_dic2_LR_fx, idx_g_fx, 4 );
+
+ /*----------------------------------------------------------------------*
+ * Interpolation of the last 4 Q bands to create bands 8-16
+ * And scaling
+ *----------------------------------------------------------------------*/
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+
+ VDQ_vec_fx(y_gainQ_fx+7, YGain_mean_LR_fx+7, YGain_dic3_LR_fx, idx_g_fx, 5 );
+
+ Copy(y_gainQ_fx+8, y_gain_tmp3_fx, 4);
+ set16_fx(y_gainQ_fx+12, 0, 4);
+
+ fft_rel_fx(y_gainQ_fx+8, 4, 2);
+
+ y_gainQ_fx[15] = y_gainQ_fx[11];
+ move16();
+ y_gainQ_fx[11] = 0;
+ move16();
+ ifft_rel_fx(y_gainQ_fx+8, 8, 3);
+ FOR(i = 8; i < 16; i++)
+ {
+ /*y_gainQ_fx[i] *= 1.41f;*/
+ y_gainQ_fx[i] = round_fx(L_shl(L_mult(y_gainQ_fx[i] , 23101),1));/*Q12 */
+ }
+ /*----------------------------------------------------------------------*
+ * Copy the true Q values in the specific bands
+ *----------------------------------------------------------------------*/
+ y_gainQ_fx[8] = y_gain_tmp3_fx[0];
+ move16();
+ y_gainQ_fx[10]= y_gain_tmp3_fx[1];
+ move16();
+ y_gainQ_fx[12]= y_gain_tmp3_fx[2];
+ move16();
+ y_gainQ_fx[14]= y_gain_tmp3_fx[3];
+ move16();
+ }
+ ELSE
+ {
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 6 );
+ VDQ_vec_fx(y_gainQ_fx, YG_mean16_fx, YG_dicMR_1_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx(y_gainQ_fx+4, YG_mean16_fx+4, YG_dicMR_2_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 5 );
+ VDQ_vec_fx(y_gainQ_fx+8, YG_mean16_fx+8, YG_dicMR_3_fx, idx_g_fx, 4 );
+
+ idx_g_fx = (Word16) get_next_indice_fx( st_fx, 4 );
+ VDQ_vec_fx(y_gainQ_fx+12, YG_mean16_fx+12, YG_dicMR_4_fx, idx_g_fx, 4 );
+ }
+ }
+
+ /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
+ GSC_gain_adj(coder_type_fx, core_brate_fx, mean_4g_fx, old_y_gain_fx, y_gainQ_fx, y_gainQ_fx);
+
+ return mean_4g_fx;
+
+}
+
+/*-------------------------------------------------------------------*
+ * gsc_gainQ()
+ *
+ * Quantization of the energy per band
+ *-------------------------------------------------------------------*/
+Word16 gsc_gainQ_fx( /*Q12*/
+ Encoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 y_gain4[], /* i : Energy per band Q12 */
+ Word16 y_gainQ[], /* o : quantized energy per band Q12 */
+ const Word32 core_brate, /* i : Core rate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth /* i : input signal bandwidth */
+)
+{
+ Word16 y_gain_tmp[MBANDS_GN], y_gain_tmp2[MBANDS_GN];
+ Word16 i, idx_g = 0;
+ Word16 mean_4g[1] = {0}, tmp16,tmp1, tmp2;
+ Word16 Mbands_gn = MBANDS_GN;
+ Word16 y_gain_tmp3[MBANDS_GN];
+ Word16 cnt;
+ Word32 L_tmp;
+
+ mean_4g[0] = 0;
+
+ test();
+ test();
+ IF( (EQ_16(coder_type,AUDIO)||EQ_16(coder_type,INACTIVE))&&EQ_16(bwidth,NB))
+ {
+
+ /*ftmp1 = mean(y_gain4, 10)-0.6f;*/
+ L_tmp = L_deposit_l(0);
+ FOR(cnt = 0 ; cnt < 10 ; cnt++)
+ {
+ L_tmp = L_mac(L_tmp,y_gain4[cnt], 3277);
+ }
+ tmp16 = sub(round_fx(L_tmp), 4915);
+
+ FOR(i = 0; i < Mbands_gn; i++)
+ {
+ y_gain_tmp2[i] = y_gain4[i];
+ move16();
+ /*if(y_gain4[i] < ftmp1-0.6f)*/
+ y_gain_tmp2[i] = s_max(y_gain_tmp2[i], tmp16);
+ move16();
+ }
+
+ L_tmp = L_deposit_l(0);
+ FOR(i = 0; i < 10; i++)
+ {
+ L_tmp = L_mac(L_tmp,y_gain_tmp2[i], 3277);
+ }
+
+ /* Quantized mean gain without clipping */
+ mean_4g[0] = round_fx(L_tmp);
+ idx_g = vquant_fx(mean_4g, Gain_meanNB_fx, mean_4g, Gain_mean_dicNB_fx, 1, 64);
+ push_indice_fx( st_fx, IND_MEAN_GAIN2, idx_g, 6 );
+
+ FOR(i = 0; i < Mbands_gn; i++)
+ {
+ y_gain_tmp[i] = sub(y_gain_tmp2[i],mean_4g[0]);
+ move16();
+ }
+ /*if(y_gain_tmp[9] < -0.3f){y_gain_tmp[9] = -0.3f;}*/
+ y_gain_tmp[9] = s_max(y_gain_tmp[9], -1229);
+ move16();
+ set16_fx(y_gain_tmp+10, 0, MBANDS_GN-10);
+ idx_g = vquant_fx(y_gain_tmp, Mean_dic_NB_fx, y_gain_tmp, Gain_dic1_NB_fx, 3, 64);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 6 );
+
+ IF(LT_32(core_brate,ACELP_9k60))
+ {
+ idx_g = vquant_fx(y_gain_tmp+3, Mean_dic_NB_fx+3, y_gain_tmp+3, Gain_dic2_NB_fx, 3, 32);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 );
+ idx_g = vquant_fx(y_gain_tmp+6, Mean_dic_NB_fx+6, y_gain_tmp+6, Gain_dic3_NB_fx, 4, 16);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 4 );
+ }
+ ELSE
+ {
+ idx_g = vquant_fx(y_gain_tmp+3, Mean_dic_NB_fx+3, y_gain_tmp+3, Gain_dic2_NBHR_fx, 3, 64);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 6 );
+ idx_g = vquant_fx(y_gain_tmp+6, Mean_dic_NB_fx+6, y_gain_tmp+6, Gain_dic3_NBHR_fx, 4, 128);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 7 );
+ }/*add end */
+
+ test();
+ IF( LE_32(core_brate,ACELP_9k60)&&EQ_16(coder_type,INACTIVE))
+ {
+ /* Some energy is needed in high band for stat_noise_uv_enc
+ to be functional in inactive speech */
+ y_gain_tmp[10] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[6],8192),y_gain_tmp[7],8192),y_gain_tmp[8],8192));
+ y_gain_tmp[11] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[7],8192),y_gain_tmp[8],8192),y_gain_tmp[9],8192));
+
+ y_gain_tmp[12] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[8],8192),y_gain_tmp[9],8192),y_gain_tmp[10],8192));
+ y_gain_tmp[13] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[9],8192),y_gain_tmp[10],8192),y_gain_tmp[11],8192));
+ y_gain_tmp[14] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[10],8192),y_gain_tmp[11],8192),y_gain_tmp[12],8192));
+ y_gain_tmp[15] = round_fx(L_mac(L_mac(L_mult(y_gain_tmp[11],8192),y_gain_tmp[12],8192),y_gain_tmp[13],8192));
+ }
+ ELSE
+ {
+ set16_fx( y_gain_tmp + 10, 0, MBANDS_GN - 10 );
+ }
+ }
+ ELSE
+ {
+ /*ftmp1 = mean(y_gain4, 16);*/
+
+ L_tmp =0;
+ FOR(cnt = 0 ; cnt < 16 ; cnt++)
+ {
+ L_tmp = L_mac(L_tmp,y_gain4[cnt], 2048);
+ }
+ tmp16 = round_fx(L_tmp);
+
+ tmp1 = sub(tmp16,4915);
+ tmp2 = add(tmp16,4915);
+ L_tmp =0;
+ FOR(i = 0; i < 16; i++)
+ {
+ y_gain_tmp2[i] = y_gain4[i];
+ move16();
+ /*if(y_gain4[i] < ftmp1-0.6f)*/
+ y_gain_tmp2[i] = s_max(y_gain_tmp2[i], tmp1);
+ move16();
+ /*else if(y_gain4[i] > ftmp1+0.6f)*/
+ y_gain_tmp2[i] = s_min(y_gain_tmp2[i], tmp2);
+ move16();
+ L_tmp = L_mac(L_tmp,y_gain_tmp2[i], 2048);
+ }
+ FOR(; i < Mbands_gn; i++)
+ {
+ y_gain_tmp2[i] = y_gain4[i];
+ /*if(y_gain4[i] < ftmp1-0.6f)*/
+ y_gain_tmp2[i] = s_max(y_gain_tmp2[i], tmp1); /* Just the last move is needed, because s_max and s_min could be done in 1 line*/
+ /*else if(y_gain4[i] > ftmp1+0.6f)*/
+ y_gain_tmp2[i] = s_min(y_gain_tmp2[i], tmp2);
+ move16();
+ }
+
+ /* Quantized mean gain without clipping */
+ mean_4g[0] = round_fx(L_tmp);
+
+
+ /*idx_g = (short)vquant(mean_4g, mean_m, mean_4g, mean_gain_dic, 1, 64);*/
+ idx_g = vquant_fx(mean_4g, mean_m_fx, mean_4g, mean_gain_dic_fx, 1, 64);
+ push_indice_fx( st_fx, IND_MEAN_GAIN2, idx_g, 6 );
+
+ FOR(i = 0; i < Mbands_gn; i++)
+ {
+ y_gain_tmp[i] = sub(y_gain_tmp2[i],mean_4g[0]);
+ move16();
+ }
+
+ IF( LT_32(core_brate,ACELP_9k60))
+ {
+ /*mvr2r(y_gain_tmp, y_gain_tmp2, 8); */
+ Copy(y_gain_tmp, y_gain_tmp2, 8);
+
+ y_gain_tmp2[8] = y_gain_tmp[8];
+ move16();
+ y_gain_tmp2[9] = y_gain_tmp[10];
+ move16();
+ y_gain_tmp2[10] =y_gain_tmp[12];
+ move16();
+ y_gain_tmp2[11] =y_gain_tmp[14];
+ move16();
+
+ idx_g = 0;
+
+ /*idx_g = (short)vquant(y_gain_tmp2, YGain_mean_LR, y_gain_tmp2, YGain_dic1_LR, 3, 32);*/
+ idx_g = vquant_fx(y_gain_tmp2, YGain_mean_LR_fx, y_gain_tmp2, YGain_dic1_LR_fx, 3, 32 );
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 );
+ /*idx_g = (short)vquant(y_gain_tmp2+3, YGain_mean_LR+3, y_gain_tmp2+3, YGain_dic2_LR, 4, 32);*/
+ idx_g = vquant_fx(y_gain_tmp2+3, YGain_mean_LR_fx+3, y_gain_tmp2+3, YGain_dic2_LR_fx, 4, 32 );
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 );
+ /*idx_g = (short)vquant(y_gain_tmp2+7, YGain_mean_LR+7, y_gain_tmp2+7, YGain_dic3_LR, 5, 32);*/
+ idx_g = vquant_fx(y_gain_tmp2+7, YGain_mean_LR_fx+7, y_gain_tmp2+7, YGain_dic3_LR_fx, 5, 32);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 );
+ /*set_f(y_gain_tmp2+12, 0, MBANDS_GN-12);*/
+ set16_fx(y_gain_tmp2+12, 0, MBANDS_GN-12);
+
+ /* Update to quantized vector */
+ Copy(y_gain_tmp2, y_gain_tmp, 8);
+
+ Copy(y_gain_tmp2+8, y_gain_tmp3, 4);
+ set16_fx(y_gain_tmp+8, 0,8);
+ fft_rel_fx(y_gain_tmp2+8, 4, 2);
+
+ Copy(y_gain_tmp2+8, y_gain_tmp+8, 3);
+ y_gain_tmp[15] = y_gain_tmp2[11];
+ ifft_rel_fx(y_gain_tmp+8, 8, 3);
+
+ FOR(i = 8; i < 16; i++)
+ {
+ /*y_gain_tmp[i] *= 1.41f;*/
+ y_gain_tmp[i] = shl( mult_r(y_gain_tmp[i] , 23101),1) ;
+ move16();
+ }
+
+ y_gain_tmp[8] = y_gain_tmp3[0];
+ move16();
+ y_gain_tmp[10]= y_gain_tmp3[1];
+ move16();
+ y_gain_tmp[12]= y_gain_tmp3[2];
+ move16();
+ y_gain_tmp[14]= y_gain_tmp3[3];
+ move16();
+ }
+ ELSE
+ {
+ idx_g = vquant_fx(y_gain_tmp, YG_mean16_fx, y_gain_tmp, YG_dicMR_1_fx, 4, 64);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 6 );
+ idx_g = vquant_fx(y_gain_tmp+4, YG_mean16_fx+4, y_gain_tmp+4, YG_dicMR_2_fx, 4, 32);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 );
+ idx_g = vquant_fx(y_gain_tmp+8, YG_mean16_fx+8, y_gain_tmp+8, YG_dicMR_3_fx, 4, 32);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 5 );
+ idx_g = vquant_fx(y_gain_tmp+12, YG_mean16_fx+12, y_gain_tmp+12, YG_dicMR_4_fx, 4, 16);
+ push_indice_fx( st_fx, IND_Y_GAIN_TMP, idx_g, 4 );
+ }
+ }
+
+ /* Gain adjustment to fit ACELP generic inactive coding gain at low rate */
+ GSC_gain_adj(coder_type, core_brate, mean_4g[0], y_gain_tmp2 /* dummy buffer */, y_gain_tmp, y_gainQ);
+
+ return mean_4g[0]; /*Q12*/
+}
+/*-------------------------------------------------------------------*
+ * VDQ_vec()
+ *
+ * Return the dequantized vector of index
+ *-------------------------------------------------------------------*/
+static Word16 VDQ_vec_fx(
+ Word16 *Qvec_out_fx, /* o: Quanitzed vector */
+ const Word16 *mean_dic_fx, /* i: average codebook */
+ const Word16 *dic_fx, /* i: codebook */
+ const Word16 index_fx, /* i: index of codebook*/
+ const Word16 vec_en_fx /* i: vector length */
+)
+{
+ Word16 i, j;
+
+ /*j = shr_r(extract_l(L_mult(index_fx,vec_en_fx)),1);*/
+ j = i_mult2(index_fx,vec_en_fx);
+ FOR ( i = 0; i < vec_en_fx; i++)
+ {
+ Qvec_out_fx[i] = dic_fx[j++];
+ move16();
+ }
+
+ FOR(i = 0; i < vec_en_fx; i++)
+ {
+ Qvec_out_fx[i] = add(Qvec_out_fx[i],mean_dic_fx[i]);
+ move16();
+ }
+
+ return index_fx;
+}
diff --git a/lib_com/gs_inact_switching_fx.c b/lib_com/gs_inact_switching_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..a92a7199e7d012c1f34b3782c5128dee350f0774
--- /dev/null
+++ b/lib_com/gs_inact_switching_fx.c
@@ -0,0 +1,153 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+#define ALPHA0_FX 13107
+#define BETA0_FX (32768-ALPHA0_FX)
+
+/*========================================================================*/
+/* FUNCTION : Inac_swtch_ematch_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Apply energy matching when swithcing to INACTIVE frame coded */
+/* by the GSC technology */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) coder_type : Coding mode */
+/* _ (Word16) L_frame : Frame lenght */
+/* _ (Word32) core_brate : core bitrate */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16[]) exc2 : CELP/GSC excitation buffer Q_exc */
+/* _ (Word16[]) lt_ener_per_band : Long term energy per band Q12 */
+/* _ (Word16*) Q_exc : input and output format of exc2 */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
+void Inac_swtch_ematch_fx(
+ Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
+ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
+ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
+ const Word16 coder_type, /* i : Coding mode */
+ const Word16 L_frame, /* i : Frame lenght */
+ const Word32 core_brate, /* i : Core bit rate */
+ const Word16 Q_exc /* i : input and output format of exc2 */
+ ,const Word16 bfi /* i : frame lost indicator */
+ ,const Word16 last_core, /* i : Last core used */
+ const Word16 last_codec_mode /* i : Last codec mode */
+)
+{
+ Word16 Ener_per_bd[MBANDS_GN];
+ Word16 ftmp;
+ Word16 *pt_exc;
+ Word16 j, i;
+
+ Word16 exp,frac;
+ Word32 L_tmp;
+
+ /*--------------------------------------------------------------------------
+ * average energy per band
+ *--------------------------------------------------------------------------*/
+
+ test();
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF(EQ_16(coder_type,AUDIO)&&bfi==0)
+ {
+ Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1);
+
+ /* reset long-term energy per band */
+ FOR(i = 0; i < MBANDS_GN; i++)
+ {
+ lt_ener_per_band[i] = Ener_per_bd[i];
+ move16();
+ }
+
+ }
+ ELSE IF( EQ_16(coder_type,VOICED)||EQ_16(coder_type,GENERIC)||EQ_16(coder_type,TRANSITION)||NE_16(last_core,ACELP_CORE)||NE_16(last_codec_mode,MODE1))
+ {
+ /* Find spectrum and energy per band for GC and VC frames */
+ edct_16fx( exc2, dct_exc_tmp, L_frame, 5 );
+
+ Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1);
+
+ /* reset long-term energy per band */
+ FOR(i = 0; i < MBANDS_GN; i++)
+ {
+ lt_ener_per_band[i] = Ener_per_bd[i];
+ move16();
+ }
+ }
+ ELSE IF( EQ_16(coder_type,INACTIVE)&&LE_32(core_brate,ACELP_24k40))
+ {
+ /* Find spectrum and energy per band for inactive frames */
+ edct_16fx( exc2, dct_exc_tmp, L_frame, 5 );
+ Ener_per_band_comp_fx( dct_exc_tmp, Ener_per_bd, Q_exc, MBANDS_GN, 1 );
+
+ /* More agressive smoothing in the first 50 frames */
+ pt_exc = dct_exc_tmp;
+ move16();
+ FOR(i = 0; i < MBANDS_GN; i++)
+ {
+ /* Compute smoothing gain to apply with gain limitation */
+ L_tmp = L_mult(ALPHA0_FX,lt_ener_per_band[i]); /*Q(15+12+1)=Q(28) */
+ L_tmp = L_mac(L_tmp,BETA0_FX,Ener_per_bd[i]); /*Q28 */
+ lt_ener_per_band[i] = round_fx(L_tmp); /*Q12 */
+
+ ftmp = sub(lt_ener_per_band[i],Ener_per_bd[i]); /*Q12 */
+
+ /* ftmp = (float)pow(10, ftmp);= pow(2,3.321928*ftmp);*/
+
+ L_tmp = L_mult(27213,ftmp); /*Q(13+12+1)=Q26 ; 27213=3.321928 in Q13 */
+ L_tmp = L_shr(L_tmp, 10); /* From Q26 to Q16 */
+ frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of ftmp */
+ ftmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */
+ /* output of Pow2() will be: */
+ /* 16384 < Pow2() <= 32767 */
+
+ exp = sub(exp,14);
+ IF( LT_16(i,2))
+ {
+ FOR (j = 0; j < 8; j ++)
+ {
+ L_tmp = L_mult(*pt_exc,ftmp); /* Q_exc*Q0 -> Q(Q_exc+1) */
+ L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc+1) -> Q(16+Q_exc)*/
+ *pt_exc = round_fx(L_tmp);
+ pt_exc++;
+ }
+ }
+ ELSE
+ {
+ FOR (j = 0; j < 16; j ++)
+ {
+ L_tmp = L_mult(*pt_exc,ftmp); /* Q_exc*Q0 -> Q(Q_exc+1) */
+ L_tmp = L_shl(L_tmp, add(exp,15)); /* Q(Q_exc+1) -> Q(16+Q_exc)*/
+ *pt_exc = round_fx(L_tmp); /*Q_exc*/
+ pt_exc++;
+ }
+ }
+ }
+
+ /* Going back to time */
+ edct_16fx( dct_exc_tmp, exc2, L_frame, 5 );
+ }
+
+ return;
+}
diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..4c83b664599aa3ac5d35e3c1fe3fbc41a5f82fba
--- /dev/null
+++ b/lib_com/gs_noisefill_fx.c
@@ -0,0 +1,922 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "rom_com_fx.h"
+#include "prot_fx.h"
+#include "stl.h"
+
+/*-------------------------------------------------------------------*
+ * gs_noisf()
+ *
+ * Noise fill-in function
+ *-------------------------------------------------------------------*/
+
+static void gs_noisf_fx(
+ const Word16 Start_BIN, /* i : First bin for noise fill */
+ const Word16 NB_Qbins, /* i : Number of bin per band */
+ const Word16 Noise_fac, /* i : Noise level Q15 */
+ const Word16 *y_norm, /* i : Quantized pulses Qn */
+ Word16 *exc_diffQ, /* o : Quantized pulses with noise added Qn */
+ Word16 *seed_tcx, /* i : Random generator seed */
+ const Word16 coder_type, /* i : coder type */
+ Word16 qNoise_fac
+)
+{
+ Word32 ftmp;
+ Word16 i, k;
+ Word16 NB_zer;
+ Word32 const_1=1;
+ Word16 tmp;
+
+ NB_zer = shr(NB_Qbins,1);
+
+ const_1 = L_shl(const_1, add(qNoise_fac, qNoise_fac));
+ if( EQ_16(coder_type,INACTIVE))
+ {
+ NB_zer = 2;
+ move16();
+ }
+
+ /*----------------------------------------------*
+ * noise fill-in on unquantized subvector *
+ * injected only from 1066Hz to 6400Hz. *
+ *----------------------------------------------*/
+
+ FOR( k=Start_BIN; k ACELP_24k40 )
+ {
+ noise_offset = 6554;
+ move16(); /*.2f * 32768 */
+ }
+ ELSE IF ( bitrate >= ACELP_22k60 )
+ {
+ noise_offset = 9830;
+ move16();/*.3f * 32768 */
+ }
+ ELSE IF ( bitrate >= ACELP_9k60 )
+ {
+ noise_offset = 11469;
+ move16(); /*0.35f * 32768 */
+ }
+ ELSE
+ {
+ noise_offset = 13107;
+ move16(); /*.4f * 32768 */
+ }
+
+ set16_fx( noisepb + i_band, noise_offset, sub(Mbands_gn, i_band) );
+
+ FOR( i = i_band; i < 5; i++ )
+ {
+ noisepb[i] = s_min(noisepb[i], 6554);
+ move16();
+ }
+
+ return;
+}
+/*==========================================================================*/
+/* FUNCTION : void EstimateNoiseLevel_fx() */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word32) bitrate : Bitrate of the codec Q0 */
+/* _ (Word16) Diff_len : number of bin before cut-off frequency */
+/* _ (Word16) Mbands_gn : number of bands Q0 */
+/* _ (Word16) coder_type : coder type Q0 */
+/* _ (Word16) noise_lev : pulses dynamic Q0 */
+/* _ (Word16) pit_band_idx : bin position of the cut-off frequency */
+/* _ (Word16*) freq_nsbin_per_band : bin per bands tables Q0 */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) noisepb : Noise per band Q15 */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* None */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*==========================================================================*/
+static void EstimateNoiseLevel_fx(
+ Word16 *noisepb, /* o : Noise per band */
+ const Word32 bitrate, /* i : Bitrate of the codec */
+ const Word16 Diff_len, /* i : number of bin before cut-off frequency */
+ const Word16 Mbands_gn, /* i : number of bands */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 noise_lev, /* i : pulses dynamic */
+ const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */
+ Word16 last_bin, /* i : the last bin of bit allocation */
+ Word16 bwidth
+)
+{
+ Word16 i_band;
+
+ i_band = 0;
+ move16();
+
+ IF( LT_16(Diff_len,L_FRAME))
+ {
+ EstimateNoiseLevel_inner_fx(noisepb, bitrate, i_band, MBANDS_GN);
+ IF( coder_type != INACTIVE )
+ {
+ test();
+ test();
+ IF( (EQ_32(bitrate,ACELP_8k00)&>_16(last_bin,8))&&NE_16(bwidth,NB))
+ {
+ FOR( ; Mbands_gn > i_band; i_band++)
+ {
+ noisepb[i_band] = add(noisepb[i_band],noisepb[i_band]);
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR( ; pit_band_idx > i_band; i_band++ )
+ {
+ noisepb[i_band] = mult_r(noisepb[i_band], 16384);
+ move16();/* 1/2=0.5 in Q15 */
+ }
+ }
+ }
+ }
+ test();
+ IF ( (EQ_16(coder_type,INACTIVE)||GE_16(noise_lev,NOISE_LEVEL_SP3)))
+ {
+ FOR( i_band = 9; i_band < Mbands_gn; i_band++ )
+ {
+ noisepb[i_band] = add(noisepb[i_band], mult_r(noisepb[i_band], 4915));
+ move16();/*noisepb[i_band]*1.15=noisepb[i_band] *(1 + 0.15) */
+ }
+ }
+
+ return;
+}
+
+/*============================================================================*/
+/* FUNCTION : void Appy_NoiseFill_fx() */
+/*----------------------------------------------------------------------------*/
+/* PURPOSE : */
+/*----------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16*) seed_tcx : Seed for noise Q0 */
+/* _ (Word16*) noisepb : Noise per band Q15 */
+/* _ (Word16) Diff_len : number of bin before cut-off frequency Q0 */
+/* _ (Word16) Mbands_gn : number of bands Q0 */
+/* _ (Word16) coder_type : pulses dynamic Q0 */
+/* _ (Word16*) freq_nsbin_per_band: bin per bands tables Q0 */
+/* _ (Word16) qexc_diffQ : Q format of exc_diffQ */
+/*----------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) exc_diffQ : Noise per band qexc_diffQ */
+/*----------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* None */
+/*----------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*============================================================================*/
+static void Apply_NoiseFill_fx(
+ Word16 *exc_diffQ, /* i/o: Noise per band qexc_diffQ */
+ Word16 *seed_tcx, /* i : Seed for noise */
+ const Word16 *noisepb, /* i : Noise per band Q15 */
+ const Word16 Diff_len, /* i : number of bin before cut-off frequency */
+ const Word16 Mbands_gn, /* i : number of bands */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 *freq_nsbin_per_band, /* i : bin per bands tables */
+ Word16 qexc_diffQ
+)
+{
+ Word16 StartBin, NB_Qbins, i_band;
+ StartBin = 0;
+ move16();
+ NB_Qbins = 0;
+ move16();
+
+ FOR( i_band = 0; i_band < Mbands_gn; i_band++ )
+ {
+ StartBin += NB_Qbins;
+ move16();
+ NB_Qbins = freq_nsbin_per_band[i_band];
+ move16();
+
+ IF( LT_16(Diff_len,L_FRAME))
+ {
+ gs_noisf_fx( StartBin , NB_Qbins, noisepb[i_band], exc_diffQ, exc_diffQ, seed_tcx, coder_type, qexc_diffQ);
+ }
+ }
+
+ return;
+}
+/*==========================================================================*/
+/* FUNCTION :void freq_dnw_scaling_fx () */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) cor_strong_limit : HF correlation Q0 */
+/* _ (Word16) coder_type : coder type Q0 */
+/* _ (Word16) noise_lev : Noise level Q0 */
+/* _ (Word32) core_brate : Core bitrate Q0 */
+/* _ (Word16) Qx : Q format of fy_norm */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ None */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16[]) fy_norm : Frequency quantized parameter Qx */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _None */
+/*==========================================================================*/
+void freq_dnw_scaling_fx(
+ const Word16 cor_strong_limit, /* i : HF correlation */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 noise_lev, /* i : Noise level */
+ const Word32 core_brate, /* i : Core bitrate */
+ Word16 fy_norm[], /* i/o: Frequency quantized parameter */
+ Word16 Qx /* Q format of fy_norm*/
+)
+{
+ Word16 sc_dyn;
+ Word16 start_sc, i;
+
+ sc_dyn = 32767;
+ move16(); /*Q15 */
+ start_sc = L_FRAME;
+ move16();
+ test();
+ IF( LE_32(core_brate,ACELP_8k00)&&EQ_16(coder_type,INACTIVE))
+ {
+ sc_dyn = mult_r(sc_dyn,4915); /*Q15 (0.15 in Q15) */
+ start_sc = 64;
+ move16();
+ }
+ ELSE IF ( EQ_16(coder_type,INACTIVE))
+ {
+ sc_dyn = mult_r(sc_dyn,8192); /*Q15 (0.25 in Q15) */
+ start_sc = 80;
+ move16();
+ }
+ ELSE
+ {
+ /*sc_dyn = (float)(NOISE_LEVEL_SP3 - noise_lev)/10.0f + 0.4f;*/
+ sc_dyn = extract_l(L_mac(13107, sub(NOISE_LEVEL_SP3, noise_lev), 1638)); /*Q0*Q14x2+Q15 =Q15*/
+ start_sc = add(112, shl(sub(NOISE_LEVEL_SP3, noise_lev), 4));
+ if( EQ_16(noise_lev,NOISE_LEVEL_SP0))
+ {
+ start_sc = L_FRAME;
+ move16();
+ }
+ }
+
+ FOR(i = start_sc; i < L_FRAME; i++)
+ {
+ fy_norm[i] = mult_r(fy_norm[i],sc_dyn);
+ move16();/*Qx */
+ }
+
+ test();
+ test();
+ IF( (LT_32(core_brate,ACELP_13k20)&&cor_strong_limit==0)||LT_32(core_brate,ACELP_9k60))
+ {
+ FOR(i = 160; i < L_FRAME; i++)
+ {
+ fy_norm[i] = s_min(fy_norm[i],shl(1,Qx));
+ move16();
+ fy_norm[i] = s_max(fy_norm[i],shl(-1,Qx));
+ move16();
+ }
+ }
+ ELSE IF ( LT_32(core_brate,ACELP_22k60))
+ {
+ FOR(i = 160; i < L_FRAME; i++)
+ {
+ fy_norm[i] = s_min(fy_norm[i],shr_r(1536,sub(10,Qx)));
+ move16();
+ fy_norm[i] = s_max(fy_norm[i],shr_r(-1536,sub(10,Qx)));
+ move16();
+ }
+ }
+
+ return;
+
+}
+
+static void Decreas_freqPeak_fx(
+ Word16 *lsf_new, /* i : ISFs at the end of the frame */
+ Word16 *exc_diffQ, /* i/o: frequency coefficients of per band */
+ Word16 rat /* i : threshold of ratio between consecutive lsf_new_diff */
+)
+{
+ Word16 i, j, k;
+ Word16 last_bin = 0;
+ Word16 pos = 0;
+ Word16 *src, max,avrg;
+ Word32 L_avrg,L_tmp;
+ Word16 lsf_new_diff[M];
+ Word16 tmp,tmp1,exp;
+ Word16 tmp2;
+
+ move16(); /*ptr init*/
+ lsf_new_diff[0] = 0; /* prevent unitialized value */
+ FOR(j=1; j<(M-1); j++)
+ {
+ lsf_new_diff[j] =sub( lsf_new[j] , lsf_new[j-1]);/*Qx2.56 */
+ }
+
+ avrg = 0;
+ move16();
+ L_avrg = L_deposit_l(0);
+ max = 1;
+ move16();
+ FOR(i=160; iQ_exc + 6 */
+ avrg = round_fx(L_shl(L_avrg,10));/*Q_exc */
+ last_bin = M-1;
+ move16(); /* When the search is false, should equate the end of the vector, not the beginning */
+ FOR(i=0; i<(M-1); i++)
+ {
+ if(GT_16(lsf_new[i],10240))
+ {
+ last_bin = i;
+ move16();
+ BREAK;
+ }
+ }
+
+ FOR(i=last_bin; i<14; i++)
+ {
+ tmp = mult_r(rat,lsf_new_diff[i-1] );/*Qx2.56 */
+ IF(GT_16(tmp , lsf_new_diff[i]))
+ {
+ src = &exc_diffQ[shl(sub(i,1),4)];
+ move16();
+ FOR(j=0; j<2; j++)
+ {
+ FOR(k=0; k<16; k++)
+ {
+ tmp = mult_r(16384,abs_s(*src));
+ IF(GT_16(tmp,avrg))
+ {
+ tmp = abs_s(*src) ;
+ exp = norm_s(max);
+ tmp1 = div_s(shl(1,sub(14,exp)),max);/*Q(29 - exp - Q_exc) */
+ L_tmp = L_mult(tmp,tmp1);/*Q(30 - exp) */
+ tmp = round_fx(L_shl(L_tmp,exp));/*Q14 */
+ tmp = sub(32767,tmp);/*Q14 */
+ L_tmp = L_mult(avrg,tmp);/*Q_exc +15 */
+
+ tmp = round_fx(L_shl(L_tmp,1));
+ tmp1 = negate(tmp);
+
+ tmp2 = *src;
+ *(src) = tmp1;
+ move16();
+ if( tmp2 > 0 )
+ {
+ *(src) = tmp;
+ move16();
+ }
+
+ }
+ src++;
+ }
+ }
+ }
+ }
+
+ tmp = mult_r(8192,max);/*Q_exc */
+ test();
+ IF(EQ_16(abs_s(exc_diffQ[pos]),max)&>_16(tmp,avrg))
+ {
+ FOR(i=pos-1; iQ(2*Q_exc-7) */
+
+ exp1 = norm_l(Ener_fx);
+ Ener_fx = L_shl(Ener_fx, exp1);
+ exp1 = 31-exp1-sub(shl(Q_exc,1),7);
+ move16();
+ Ener_fx = Isqrt_lc(Ener_fx, &exp1); /*Q(31-exp1) */
+
+ weight_fx = 16384; /*Q15 */
+ src_fx = &exc_diffQ_fx[start_band]; /*Q_exc */
+ FOR(i=last_bin; i Q16 */
+
+ frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */
+ tmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */
+ /* output of Pow2() will be: */
+ /* 16384 < Pow2() <= 32767 */
+ exp = sub(exp, 14);
+ Ener1_fx = mult_r(13107, shl(tmp, exp)); /*Q0 */
+
+ FOR(j=0; j<16; j++)
+ {
+ /**src = Ener1*(weight*(*src)*Ener + (1.0f-weight)*own_random(seed_tcx)/32768.0f); */
+ L_tmp = Mult_32_16(Ener_fx, *src_fx); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */
+ tmp = extract_l(L_shr(L_tmp, add(4, sub(Q_exc, exp1)))); /*Q12 */
+ tmp = mult_r(weight_fx, tmp); /*Q12 */
+
+ L_tmp = L_mult0(sub(32767, weight_fx), Random(seed_tcx)); /*Q30 */
+ tmp1 = round_fx(L_shr(L_tmp, 2));
+
+ L_exc_diffQ_fx[16*i+j] = L_mult0(Ener1_fx, add(tmp, tmp1)); /*Q12 */ move32();
+ src_fx++;
+ }
+ }
+
+ /*Ener1 = (float)(0.4f*pow(10, Ener_per_bd_iQ[15])); */
+ L_tmp = L_shr(L_mult0(Ener_per_bd_iQ_fx[15], 27213), 9); /* 3.321928 in Q13 -> Q16 */
+
+ frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */
+ tmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */
+ /* output of Pow2() will be: */
+ /* 16384 < Pow2() <= 32767 */
+ exp = sub(exp, 14);
+ Ener1_fx = mult_r(13107, shl(tmp, exp)); /*Q0 */
+
+ src_fx = &exc_diffQ_fx[224];
+ FOR(j=0; j<32; j++)
+ {
+ /**src = Ener1*(weight*(*src)*Ener + (1.0f-weight)*own_random(seed_tcx)/32768.0f); */
+ L_tmp = Mult_32_16(Ener_fx, *src_fx); /*Q(31-exp+Q_exc-15) -> Q(16-exp+Q_exc) */
+ tmp = extract_l(L_shr(L_tmp, add(4, sub(Q_exc, exp1)))); /*Q12 */
+ tmp = mult_r(weight_fx, tmp); /*Q12 */
+
+ L_tmp = L_mult0(sub(32767, weight_fx), Random(seed_tcx)); /*Q30 */
+ tmp1 = round_fx(L_shr(L_tmp, 2)); /*Q12 */
+
+ L_exc_diffQ_fx[16*i+j] = L_mult0(Ener1_fx, add(tmp, tmp1)); /*Q12 */ move32();
+ src_fx++;
+ }
+
+ exc_diffQ_max = 0;
+ move16();
+ FOR(i=start_band; i Q27 */
+ L_tmp = L_shr(L_tmp, 10); /* From Q27 to Q16 */
+
+ frac = L_Extract_lc(L_tmp, &exp); /* Extract exponent of L_tmp */
+ tmp = extract_l(Pow2(14, frac));/* Put 14 as exponent so that */
+ /* output of Pow2() will be: */
+ /* 16384 < Pow2() <= 32767 */
+ exp = sub(exp, 14);
+ tmp1 = shl(tmp,exp);
+ move16();
+ ener = add (tmp1,ener);/*Q0 */
+ }
+
+ test();
+ IF( EQ_32(core_brate,ACELP_8k00)&&NE_16(bwidth,NB))
+ {
+ if(NE_16(last_coder_type,AUDIO))
+ {
+ *last_ener = ener;
+ move16();
+ }
+ test();
+ test();
+ IF((GT_16(last_bin,8)||Diff_len!=0)&&EQ_16(last_coder_type,AUDIO))
+ {
+ MAX_Bin = 10;
+ move16();
+ bwe_flag = 1;
+ move16();
+ }
+ ELSE
+ {
+ MAX_Bin = 15;
+ move16();
+ }
+
+ last_bin_tmp = last_bin;
+ move16();
+ last_bin = s_max(last_bin , MAX_Bin);
+ last_bin = add(last_bin, 1);
+ }
+ ELSE
+ {
+ last_bin = MBANDS_GN;
+ move16();
+ last_bin_tmp = last_bin;
+ move16();
+ }
+ IF( bfi )
+ {
+ set16_fx( noisepb, 13107, MBANDS_GN ); /*0.4 in Q15 */
+ }
+ ELSE
+ {
+ EstimateNoiseLevel_fx( noisepb, core_brate, Diff_len, last_bin, coder_type, noise_lev, pit_band_idx,
+ last_bin_tmp, bwidth );
+ }
+
+ IF( exc_wo_nf != NULL )
+ {
+ Copy( exc_diffQ, exc_wo_nf, L_FRAME );
+ }
+
+ test();
+ IF( GSC_noisy_speech && !bfi )
+ {
+ set16_fx( noisepb, 3277, MBANDS_GN );
+ }
+ Apply_NoiseFill_fx( exc_diffQ, seed_tcx, noisepb, Diff_len, last_bin, coder_type, mfreq_bindiv, Qexc_diffQ );
+
+ /*--------------------------------------------------------------------------------------*
+ * Quantize average gain
+ * Substract Q averaged gain
+ * VQ of remaining gain per band
+ *--------------------------------------------------------------------------------------*/
+ test();
+ IF( EQ_32(core_brate,ACELP_8k00)&&NE_16(bwidth,NB))
+ {
+ Ener_per_band_comp_fx(exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, add(last_bin,1), 0);
+ }
+ ELSE
+ {
+ Ener_per_band_comp_fx(exc_diffQ, Ener_per_bd_yQ, Qexc_diffQ, MBANDS_GN, 1 );
+
+ IF( LT_16(nb_subfr, 4))
+ {
+ FOR(i = L_FRAME-16; i < L_FRAME; i++)
+ {
+ /*exc_diffQ[i] *= 0.067f * i - 15.0f; = -15 - (-0.067f * i) */
+ tmp = msu_r(-7680*65536, -17564, shl(i,6));/*-15 in Q9; -0.067 in Q18 and i in Q6= Q9 */
+ L_tmp = L_mult(exc_diffQ[i],tmp); /*Q(Qexc_diffQ+10) */
+ exc_diffQ[i] = round_fx(L_shl(L_tmp,16-10));/*Qexc_diffQ */
+ }
+ }
+ }
+ /*--------------------------------------------------------------------------------------*
+ * Check potential energy excitation overshoot
+ *--------------------------------------------------------------------------------------*/
+ IF( bfi )
+ {
+ test();
+ IF (GSC_noisy_speech == 0 && GT_16(coder_type,UNVOICED)) /* Here coder_type == last_coder_type because of the bfi */
+ {
+ FOR( i=0; i end)
+ {
+ *src-- = *dst--;
+ move16();
+ }
+ test();
+ test();
+ if( (bitallocation_exc[0] != 0 || bitallocation_exc[1] != 0) && EQ_32(core_brate, ACELP_8k00))
+ {
+ exc_diffQ[160] = 0;
+ move16();
+ }
+
+ Q_hb_exc = 0;
+ move16();
+ envelop_modify_fx( exc_diffQ, seed_tcx, last_bin, Ener_per_bd_iQ, Q_exc, &Q_hb_exc);
+ Copy_Scale_sig( &exc_diffQ[tmp1], &exc_dct_in[tmp1], sub(L_FRAME,tmp1), sub(Q_exc, Q_hb_exc)); /* from Q_hb_exc -> Q_exc as expected */
+ }
+
+ IF( LT_16(nb_subfr,4))
+ {
+ FOR( i = sub(L_FRAME,16); i < L_FRAME; i++ )
+ {
+ /*exc_dct_in[i] *= (0.067f*i-15.f); */
+ tmp = mult_r(17564,shl(i,6)); /*0.067 in Q18 and i in Q6= Q9 */
+ tmp = sub(tmp,7680); /*15 in Q9 = Q9 */
+ L_tmp = L_mult(exc_dct_in[i],tmp);/*Q(Q_exc+10) */
+ exc_dct_in[i] = round_fx(L_shl(L_tmp,6));/*Q_exc */
+ }
+ }
+
+ tmp1 = mult_r(ener,16384);
+ tmp1 = sub(*last_ener,tmp1);
+ tmp = mult_r(*last_ener,16384);
+ tmp = sub(ener,tmp);
+ test();
+ IF( tmp>0 && tmp1>0 )
+ {
+ length_bin = 6;
+ move16();
+ IF(last_coder_type != AUDIO)
+ {
+ set16_fx( last_bitallocation_band, 0, 6 );
+ Copy( &exc_dct_in[(4+length_bin)*16], &last_exc_dct_in[(4+length_bin)*16], length_bin*16 );
+ }
+
+ FOR(i=4; i<(4+length_bin); i++)
+ {
+ test();
+ IF( !(bitallocation_band[i] == 0 && last_bitallocation_band[i-4] == 0))
+ {
+ k = shl(add(i,length_bin),4);
+ src = &exc_dct_in[k]; /*(i+length_bin)*16*/
+ dst = &last_exc_dct_in[k];
+ FOR(j=0; j<16; j++)
+ {
+ tmp= mult_r(10923,abs_s(*src));
+ tmp1 =mult_r(10923,abs_s(*dst));
+
+ IF(GT_16(tmp,abs_s(*dst)))
+ {
+ tmp2 = *src;
+ *src = mult_r(16384,sub(*src , abs_s(*dst))); /*Q_exc */ move16();
+ tmp = mult_r(16384,add(tmp2 , abs_s(*dst))); /*Q_exc */
+ if( tmp2 > 0 )
+ {
+ *src = tmp;
+ move16();
+ }
+ }
+ ELSE IF (GT_16(tmp1,abs_s(*src)))
+ {
+ tmp = mult_r(*src,22938);
+ tmp1 = mult_r(9830,abs_s(*dst));
+ tmp2 = *src;
+ *src = sub(tmp,tmp1); /*Q_exc */ move16();
+ if( tmp2 > 0 )
+ {
+ *src = add(tmp,tmp1); /*Q_exc */ move16();
+ }
+ }
+ src++;
+ dst++;
+ }
+ }
+ }
+ }
+ IF(EQ_16(bwe_flag,1))
+ {
+ Decreas_freqPeak_fx( lsf_new, exc_dct_in, 9830 );
+ }
+ ELSE
+ {
+ Decreas_freqPeak_fx( lsf_new, exc_dct_in, 16384 );
+ }
+ }
+
+ Copy( &exc_dct_in[64], &last_exc_dct_in[64], L_FRAME-64 );
+ Copy(&bitallocation_band[4], last_bitallocation_band, 6);
+ *last_ener = ener;
+ move16();
+
+ return;
+}
diff --git a/lib_com/gs_preech_fx.c b/lib_com/gs_preech_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..75928b745fcb7a5c252fda8d2f469a6191ff760b
--- /dev/null
+++ b/lib_com/gs_preech_fx.c
@@ -0,0 +1,139 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+#define ATT_LENGHT 64
+#define ATT_SEG_LEN (L_FRAME/ATT_LENGHT)
+#define INV_ATT_SEG_LEN (1.0f/ATT_SEG_LEN)
+#define INV_L_FRAME (1.0f/L_FRAME)
+
+/*==========================================================================*/
+/* FUNCTION : void pre_echo_att_fx(); */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : Attenuation of the pre-echo when encoder specifies an attack */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) L_frame_fx : length of the frame Q0 */
+/* _ (Word16) gsc_attack_flag_fx : LP filter coefficient Q0 */
+/* _ (Word16) core_fx : core codec used Q0 */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ None */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ (Word16*) exc_fx : adapt. excitation exc Q_exc */
+/* _ (Word32*) Last_frame_ener_fx : Energy of the last frame Q1 */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*==========================================================================*/
+void pre_echo_att_fx(
+ Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
+ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
+ const Word16 gsc_attack_flag_fx /* i : flag signalling attack encoded by AC mode (GSC) */
+ ,const Word16 Q_new
+ ,const Word16 last_coder_type_fx /* i : Last coding mode */
+)
+{
+ Word32 etmp_fx;
+ Word32 finc_fx[ATT_LENGHT] = {0};
+ Word16 ratio_fx;
+ Word16 attack_pos_fx, i;
+ Word32 L_tmp, L_tmp1;
+ Word16 tmp, n1, n2, exp, frac1, frac2;
+ Word32 etmp1_fx;
+ test();
+ IF ( EQ_16(gsc_attack_flag_fx,1)&&EQ_16(last_coder_type_fx,AUDIO)) /*gsc_attack_flag_fx does not get set for all the test cases */
+ {
+ /*-------------------------------------------------------------------------*
+ * Find where the onset (attack) occurs by computing the energy per section
+ * The inverse weighting aims to favor the first maxima in case of
+ * gradual onset
+ *-------------------------------------------------------------------------*/
+ FOR(i = 0; i < ATT_LENGHT; i++)
+ {
+ L_tmp = sum2_fx(&exc_fx[shl(i,2)], ATT_SEG_LEN ); /*2*Q_new+1, //ATT_SEG_LEN=(L_FRAME/ATT_LENGHT)=4(=shl(x,2))*/
+ tmp = div_s(sub(ATT_LENGHT,i),ATT_LENGHT); /*Q15 */
+ L_tmp = Mult_32_16(L_tmp, tmp); /*2*Q_new+1 */
+ finc_fx[i] = L_tmp;
+ move32(); /*2*Q_new+1 */
+ }
+
+ attack_pos_fx = maximum_32_fx(finc_fx, ATT_LENGHT, &etmp_fx);
+
+ /* Scaled the maximum energy and allowed 6 dB increase*/
+ etmp_fx = L_shr(etmp_fx,add(2+1-4, shl(Q_new,1)));/*2*Q_new+1 //INV_ATT_SEG_LEN=1/4(=shr(x,2)) -> Q4 */
+ etmp1_fx = etmp_fx;
+ move32();
+ *Last_frame_ener_fx = L_shl(*Last_frame_ener_fx,2);
+ move32(); /*2*Q_new+1 */
+
+ /* If the maximum normalized energy > last frame energy + 6dB */
+ test();
+ IF( GT_32(etmp_fx,*Last_frame_ener_fx)&&attack_pos_fx>0)
+ {
+ /* Find the average energy before the attack */
+ L_tmp = sum32_fx( finc_fx, attack_pos_fx); /*Q1 */
+ L_tmp1 = L_shr(L_mult(attack_pos_fx,attack_pos_fx),1); /*Q0 */
+ tmp = round_fx(Isqrt(L_tmp1)); /*Q15 */
+ L_tmp = L_shr(L_tmp,2); /*Q1 ; ATT_SEG_LEN=4 */
+ etmp_fx = Mult_32_16(L_tmp,tmp); /*Q1 */
+
+ etmp_fx = L_shr(etmp_fx,add(1-4, shl(Q_new,1))); /* makes etmp i nQ4 as *Last_frame_ener_fx */
+ /* Find the correction factor and apply it before the attack */
+ /* ratio = (float)sqrt(*Last_frame_ener/etmp);*/
+ /* = isqrt(etmp/(*Last_frame_ener)) */
+ etmp_fx = L_max(etmp_fx,1);
+ *Last_frame_ener_fx = L_max(*Last_frame_ener_fx,1);
+ n1 = norm_l(etmp_fx);
+ n2 = norm_l(*Last_frame_ener_fx);
+
+ n1 = sub(n1,1);
+ exp = sub(n1,n2);
+
+ frac1 = round_fx(L_shl(etmp_fx,n1));
+ frac2 = round_fx(L_shl(*Last_frame_ener_fx,n2));
+
+ L_tmp = L_mult0(128, div_s(frac1, frac2)); /* s = gain_out / gain_in */
+ L_tmp = L_shr(L_tmp, exp); /* add exponent */
+
+ L_tmp = Isqrt(L_tmp);
+ ratio_fx = round_fx(L_shl(L_tmp, 9));
+
+ /* Pre-echo atttenuation should never increase the energy */
+ ratio_fx = s_min(ratio_fx, 8192);
+ FOR(i = 0; i < attack_pos_fx*ATT_SEG_LEN; i++)
+ {
+ /*exc_fx[i] *= ratio_fx;*/
+ exc_fx[i] = round_fx(L_shl(L_mac(-8192, exc_fx[i], ratio_fx), 2));
+ }
+ }
+ *Last_frame_ener_fx = etmp1_fx;
+ move32();
+ }
+ ELSE
+ {
+ /*-------------------------------------------------------*
+ * In normal cases, just compute the energy of the frame
+ *-------------------------------------------------------*/
+
+ etmp_fx = sum2_fx( exc_fx, L_FRAME ); /*2*Q_new+1 */
+
+ etmp_fx = L_shr(etmp_fx,add(8+1-4, shl(Q_new,1))); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
+ *Last_frame_ener_fx = etmp_fx;
+ move32(); /*2*Q_new+1*/
+ }
+
+ return;
+}
diff --git a/lib_com/guided_plc_util.c b/lib_com/guided_plc_util.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c1fa7debd30a01d29742bb43b4b84fdbe417e39
--- /dev/null
+++ b/lib_com/guided_plc_util.c
@@ -0,0 +1,324 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "prot_fx.h"
+#include "stl.h"
+#include "rom_com_fx.h"
+
+#include "basop_util.h"
+#include "rom_basop_util.h"
+
+void getLookAheadResSig( Word16 *speechLookAhead, Word16 *A_3Q12, Word16 *res, Word16 L_frame, Word16 numSubFrame )
+{
+ Word16 *p_A;
+ Word16 i_subfr;
+ Word16 subfr_len[2] = { L_SUBFR, L_SUBFR };
+
+ if( GT_16( L_FRAME16k, L_frame ))
+ {
+ subfr_len[1] = 48;
+ move16(); /* 0.75 * L_SUBFR(64) */
+ }
+
+ p_A = A_3Q12;
+ FOR(i_subfr=0; i_subfrlsfoldbfi1_14Q1[i] );
+ L_tmp = L_mac( L_tmp, divide_by_3_Q15, decState->lsfoldbfi0_14Q1[i] );
+ decState->lsf_adaptive_mean_14Q1[i] = mac_r( L_tmp, divide_by_3_Q15, lsf_14Q1[i] );
+ decState->lsfoldbfi1_14Q1[i] = decState->lsfoldbfi0_14Q1[i];
+ move16();
+ decState->lsfoldbfi0_14Q1[i] = lsf_14Q1[i];
+ move16();
+ }
+
+ return;
+}
+
+void getConcealedLP( HANDLE_PLC_ENC_EVS memDecState, Word16 *AqCon, const Word16 lsfBase[], Word16 last_good, Word16 L_frame)
+{
+ Word16 *lsf;
+ Word16 lsp[(NB_DIV+1)*M];
+ Word32 int_fs;
+
+ move16();
+ lsf = memDecState->lsf_con;
+
+
+ dlpc_bfi( L_frame, &lsf[0], memDecState->lsfold_14Q1, last_good,
+ 1, memDecState->mem_MA_14Q1, memDecState->mem_AR, &(memDecState->stab_fac_Q15), memDecState->lsf_adaptive_mean_14Q1,
+ 1,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ lsfBase,
+ 0
+ );
+ Copy( memDecState->lspold_Q15, lsp, M );
+
+ int_fs = INT_FS_FX;
+ move32();
+ if( EQ_16(L_frame,L_FRAME_16k))
+ {
+ int_fs = INT_FS_16k_FX;
+ move32();
+ }
+ lsf2lsp_fx( lsf, &lsp[M], M, int_fs );
+
+ int_lsp_fx( L_frame, &lsp[0], &lsp[M], AqCon, M, interpol_frac_fx, 0 );
+
+ return;
+}
+
+void getConcealedLSF( HANDLE_PLC_ENC_EVS memDecState, const Word16 lsfBase[], Word16 last_good, Word16 L_frame)
+{
+ Word16 *lsf = memDecState->lsf_con;
+
+
+ dlpc_bfi( L_frame, &lsf[0], memDecState->lsfold_14Q1, last_good,
+ 1, memDecState->mem_MA_14Q1, memDecState->mem_AR, &(memDecState->stab_fac_Q15), memDecState->lsf_adaptive_mean_14Q1,
+ 1,
+ NULL,
+ 0,
+ NULL,
+ NULL,
+ lsfBase,
+ 0
+ );
+
+ return;
+}
+
+static void reorder_lsfs(Word16 *lsf, const Word16 min_dist, const Word16 n, const Word32 sr_core);
+
+void RecLpcSpecPowDiffuseLc( Word16 *lspq, Word16 *lsp_old, Word16 *lsfq, Decoder_State_fx *st, Word16 reset_q )
+{
+ const Word16 *means;
+ Word16 lsf_old[M];
+ Word16 i;
+
+ means = PlcGetLsfBase ( st->lpcQuantization,
+ st->narrowBand,
+ st->sr_core );
+
+ Copy( st->lsf_old_fx, lsf_old, M );
+
+ modify_lsf( lsf_old, M, st->sr_core, reset_q );
+
+ lsf2lsp_fx( lsf_old, lsp_old, M, st->sr_core );
+
+ IF( reset_q )
+ {
+ FOR ( i=0; imem_MA_fx[i], means[i]);
+ move16();
+ }
+ sort_fx( lsfq, 0, sub(M, 1) );
+
+ reorder_lsfs( lsfq, LSF_GAP_FX, M, st->sr_core );
+ lsf2lsp_fx( lsfq, lspq, M, st->sr_core );
+ }
+ ELSE
+ {
+ modify_lsf( lsfq, M, st->sr_core, reset_q );
+ lsf2lsp_fx(lsfq, lspq, M, st->sr_core);
+ }
+
+ return;
+}
+
+void modify_lsf(
+ Word16 *lsf,
+ const Word16 n,
+ const Word32 sr_core
+ , Word16 reset_q
+)
+{
+ Word16 i, k, th_x1p28_Q14;
+ Word16 gap, gap_sum;
+
+
+ th_x1p28_Q14 = 4864/*1900.0f*1.28f Q1*/;
+ move16();
+ if( EQ_32( sr_core, 16000 ))
+ {
+ th_x1p28_Q14 = 6080/*2375.0f*1.28f Q1*/;
+ move16();
+ }
+
+ IF( reset_q == 0 )
+ {
+ th_x1p28_Q14 = 2048; /* 800.0f*1.28f Q1*/ move16();
+ if( EQ_32( sr_core, 16000 ))
+ {
+ th_x1p28_Q14 = 2560; /*1000.0f*1.28f Q1*/ move16();
+ }
+ }
+
+ FOR ( i=1; i= 0; i--) /* Reverify the minimum ISF gap in the reverse direction */
+ {
+ IF (LE_16(lsf[i], th2))
+ {
+ curr_min_dist = min_dist_fac2;
+ move16();
+ }
+ ELSE
+ {
+ if (LE_16(lsf[i], th1))
+ {
+ curr_min_dist = min_dist_fac3;
+ move16();
+ }
+ }
+
+ if (GT_16(lsf[i], lsf_max))
+ {
+ lsf[i] = lsf_max;
+ move16();
+ }
+ lsf_max = sub(lsf[i], curr_min_dist);
+ }
+ }
+
+ return;
+}
+
diff --git a/lib_com/hp50.c b/lib_com/hp50.c
new file mode 100644
index 0000000000000000000000000000000000000000..93b5219b68ae1e2efd597fe4adf368611364c5b5
--- /dev/null
+++ b/lib_com/hp50.c
@@ -0,0 +1,250 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+#include
+#include "stl.h"
+#include "prot_fx.h"
+#include "basop_util.h"
+#include "options.h"
+
+
+#define HP20_COEFF_SCALE (2)
+
+/*
+ * hp20
+ *
+ * Function:
+ * 2nd order high pass filter with nominal cut off frequency at 20 Hz.
+ *
+ * Returns:
+ * void
+ */
+
+static Word32 HP50_Mode2_Mpy_32_16_fix(Word32 a, Word16 b)
+{
+ Word32 result = Mpy_32_16_1(a,b);
+ /* perform rounding towards lower value for negative results */
+ if (result < 0) result = L_add(result,1);
+ return result;
+}
+
+static Word32 HP50_Mpy_32_32_fix(Word32 a, Word32 b)
+{
+ Word32 result = Mpy_32_32(a,b);
+ /* perform rounding towards lower value for negative results */
+ if (result < 0) result = L_add(result,1);
+ return result;
+}
+
+
+static void filter_2nd_order(
+ Word16 signal[],
+ const Word16 stride,
+ const Word16 prescale,
+ const Word16 lg,
+ Word32 mem[4],
+ Word32 a1,
+ Word32 a2,
+ Word32 b1,
+ Word32 b2
+)
+{
+
+ Word16 i;
+ Word16 x2, x1;
+ Word32 L_sum, L_y1, L_y2;
+
+
+ /*
+ * Saturation: The states of the filter, namely L_y1 and L_y2 shall
+ * never saturate, because that causes error in the filter feedback.
+ * The final output written into signal[] might saturate because of
+ * unavoidable filter overshoot.
+ */
+
+ /* Execute first 2 iterations with 32-bit x anx y memory values */
+ BASOP_SATURATE_ERROR_ON
+ L_sum = HP50_Mpy_32_32_fix(b2,mem[2]); /* b2*x2 */
+ L_sum = L_add(L_sum,HP50_Mpy_32_32_fix(b1,mem[3])); /* b1*x1 */
+ x2 = shr(signal[0*stride], prescale);
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b2,x2)); /* b2*x0 */
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[0],a2)); /* y2*a2 */
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[1],a1)); /* y1*a1 */
+
+ L_y2 = L_shl(L_sum, HP20_COEFF_SCALE);
+ BASOP_SATURATE_ERROR_OFF
+ BASOP_SATURATE_WARNING_OFF
+ signal[0*stride] = round_fx(L_shl(L_y2, prescale));
+ BASOP_SATURATE_WARNING_ON
+
+ BASOP_SATURATE_ERROR_ON
+ L_sum = HP50_Mpy_32_32_fix(b2,mem[3]); /* b2*x2 */
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b1,x2)); /* b1*x1 */
+ x1 = shr(signal[1*stride], prescale);
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b2,x1)); /* b2*x0 */
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(mem[1],a2)); /* y2*a2 */
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2, a1)); /* y1*a1 */
+
+ L_y1 = L_shl(L_sum, HP20_COEFF_SCALE);
+ BASOP_SATURATE_ERROR_OFF
+ BASOP_SATURATE_WARNING_OFF
+ signal[1*stride] = round_fx(L_shl(L_y1, prescale));
+ BASOP_SATURATE_WARNING_ON
+
+ /* New we use a trick and toggle x1/x2 and L_y1/L_y2 to save a few cycles unrolling the loop by 2 */
+ FOR (i = 2; i < lg; i+=2)
+ {
+ /* y[i+0] = b2*x[i-2] + b1*x[i-1] + b2*x[i-0] + a2*y[i-2] + a1*y[i-1]; */
+ BASOP_SATURATE_ERROR_ON
+ L_sum = HP50_Mode2_Mpy_32_16_fix(b2,x2);
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b1,x1));
+ x2 = shr(signal[i*stride], prescale);
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b2,x2));
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2,a2));
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y1,a1));
+
+ L_y2 = L_shl(L_sum, HP20_COEFF_SCALE);
+ BASOP_SATURATE_ERROR_OFF
+ BASOP_SATURATE_WARNING_OFF
+ signal[i*stride] = round_fx(L_shl(L_y2, prescale));
+ BASOP_SATURATE_WARNING_ON
+ /* y[i+1] = b2*x[i-1] + b1*x[i-0] + b2*x[i+1] + a2*y[i-1] + a1*y[i+0]; */
+ BASOP_SATURATE_ERROR_ON
+ L_sum = HP50_Mode2_Mpy_32_16_fix(b2,x1);
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b1,x2));
+ x1 = shr(signal[(i+1)*stride], prescale);
+ L_sum = L_add(L_sum,HP50_Mode2_Mpy_32_16_fix(b2,x1));
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y1,a2));
+ L_sum = L_add(L_sum, HP50_Mpy_32_32_fix(L_y2,a1));
+
+ L_y1 = L_shl(L_sum, HP20_COEFF_SCALE);
+ BASOP_SATURATE_ERROR_OFF
+ BASOP_SATURATE_WARNING_OFF
+ signal[(i+1)*stride] = round_fx(L_shl(L_y1, prescale));
+ BASOP_SATURATE_WARNING_ON
+ }
+ /* update static filter memory from variables */
+ mem[0] = L_y2;
+ move32();
+ mem[1] = L_y1;
+ move32();
+ mem[2] = L_deposit_h(x2);
+ mem[3] = L_deposit_h(x1);
+
+
+ return;
+}
+
+
+void hp20(Word16 signal[], /* i/o: signal to filter any */
+ const Word16 stride, /* i : stride to be applied accessing signal */
+ const Word16 lg, /* i : length of signal (integer) Q0 */
+ Word32 mem[5], /* i/o: static filter memory with this layout: */
+ /* mem[0]: y[-2] (32-bit) */
+ /* mem[1]; y[-1] (32-bit) */
+ /* mem[2]: x[-2] << 16 */
+ /* mem[3]: x[-1] << 16 */
+ /* Note: mem[0..3] need to be scaled per frame */
+ /* mem[4]: states scale */
+ const Word32 sFreq) /* i : input sampling rate Q0 */
+{
+ Word32 a1, b1, a2, b2;
+ Word16 prescale, prescaleOld, diff;
+
+
+
+ prescale = getScaleFactor16(signal, lg);
+ prescaleOld = extract_l(mem[4]);
+ diff = norm_l(L_shl(mem[2], prescaleOld));
+ if (mem[2] != 0)
+ {
+ prescale = s_min(prescale, diff);
+ }
+ diff = norm_l(L_shl(mem[3], prescaleOld));
+ if (mem[3] != 0)
+ {
+ prescale = s_min(prescale, diff);
+ }
+ /* Take into account the left shift performed into the loop + 1 bit headroom*/
+ prescale = s_max(-12, sub(1+HP20_COEFF_SCALE, prescale));
+ IF (prescale != prescaleOld)
+ {
+ diff = sub(prescale, prescaleOld);
+ mem[0] = L_shr(mem[0], diff);
+ move32();
+ mem[1] = L_shr(mem[1], diff);
+ move32();
+ mem[2] = L_shr(mem[2], diff);
+ move32();
+ mem[3] = L_shr(mem[3], diff);
+ move32();
+ mem[4] = L_deposit_l(prescale);
+ }
+
+ IF ( EQ_32(sFreq,8000))
+ {
+ /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate
+ [b,a] = butter(2, 20.0/4000.0, 'high');
+ b = [0.988954248067140 -1.977908496134280 0.988954248067140]
+ a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/
+ a1 = 1061816033l/* 1.977786483776764 Q29*/; move32();
+ a2 = -525076131l/*-0.978030508491796 Q29*/; move32();
+ b1 = -1061881538l/*-1.977908496134280 Q29*/; move32();
+ b2 = 530940769l/* 0.988954248067140 Q29*/; move32();
+
+ }
+ ELSE IF ( EQ_32(sFreq,16000))
+ {
+ /* hp filter 20Hz at 3dB for 16000KHz sampling rate
+ [b,a] = butter(2, 20.0/8000.0, 'high');
+ b = [0.994461788958195 -1.988923577916390 0.994461788958195]
+ a = [1.000000000000000 -1.988892905899653 0.988954249933127] */
+ a1 = 1067778748l/* 1.988892905899653 Q29*/; move32();
+ a2 = -530940770l/*-0.988954249933127 Q29*/; move32();
+ b1 = -1067795215l/*-1.988923577916390 Q29*/; move32();
+ b2 = 533897608l/* 0.994461788958195 Q29*/; move32();
+
+ }
+ ELSE IF ( EQ_32(sFreq,32000))
+ {
+ /* hp filter 20Hz at 3dB for 32000KHz sampling rate
+ [b,a] = butter(2, 20.0/16000.0, 'high');
+ b = [0.997227049904470 -1.994454099808940 0.997227049904470]
+ a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/
+ a1 = 1070760263l/* 1.994446410541927 Q29*/; move32();
+ a2 = -533897608l/*-0.994461789075954 Q29*/; move32();
+ b1 = -1070764392l/*-1.994454099808940 Q29*/; move32();
+ b2 = 535382196l/* 0.997227049904470 Q29*/; move32();
+ }
+ ELSE
+ {
+ assert (sFreq == 48000);
+ /* hp filter 20Hz at 3dB for 48000KHz sampling rate
+ [b,a] = butter(2, 20.0/24000.0, 'high');
+ b =[0.998150511190452 -1.996301022380904 0.998150511190452]
+ a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
+ a1 = 1071754114l/* 1.996297601769122 Q29*/; move32();
+ a2 = -534886875l/*-0.996304442992686 Q29*/; move32();
+ b1 = -1071755951l/*-1.996301022380904 Q29*/; move32();
+ b2 = 535877975l/* 0.998150511190452 Q29*/; move32();
+ }
+
+
+ filter_2nd_order(signal,
+ stride,
+ prescale,
+ lg,
+ mem,
+ a1,
+ a2,
+ b1,
+ b2);
+
+ return;
+}
+
+
+
+
diff --git a/lib_com/hq2_bit_alloc_fx.c b/lib_com/hq2_bit_alloc_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..802ffc0eb4433bbb19e409c7fc66a22c63c10b24
--- /dev/null
+++ b/lib_com/hq2_bit_alloc_fx.c
@@ -0,0 +1,914 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "prot_fx.h"
+#include "stl.h" /* required for wmc_tool */
+
+#define MIN_BITS_FIX 0 /* QRk=18 */
+#define HQ_16k40_BIT (HQ_16k40/50) /* 16400/50=328 */
+#define Qbf 14 /* Q value for bits_fact */
+#define C1_QRk (1< 0 )
+ {
+ be_sum_fx = add(be_sum_fx, y_index_fx[k]);
+ }
+ }
+ QBavg = 0;
+ move16();
+
+ /*Ravg = (float) be_sum/be_cnt;*/
+ Ravg_fx = 0;
+ move16();
+ QRavg = 0;
+ move16();
+ IF( be_cnt_fx != 0x0 )
+ {
+ exp_normn = norm_s(be_sum_fx);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(be_cnt_fx);
+ Ravg_fx = div_s(shl(be_sum_fx, exp_normn), shl(be_cnt_fx, exp_normd));
+
+ Ravg_fx = shr(Ravg_fx, 2); /* safe shift */
+ QRavg = add(sub(exp_normn, exp_normd), 15-2);
+ }
+
+ enr_diffcnt_fx = 0;
+ move16();
+ th_5_fx = shl(5, QRavg);
+ FOR (j = 0; j < be_cnt_fx; j++)
+ {
+ if( GT_16(abs_s(sub(Ravg_fx, shl(y_index_fx[j], QRavg))), th_5_fx))
+ {
+ enr_diffcnt_fx = add(enr_diffcnt_fx, 1);
+ }
+ }
+
+ scale_fact_fx = 19661;
+ move16(); /* 0.60f 19660.8(Q15) */
+ if( enr_diffcnt_fx > 0 )
+ {
+ scale_fact_fx = 11468;
+ move16(); /* 0.35f 11468.8(Q15) */
+ }
+
+ /* Bits allocation to individual SB's in a group based on Band Energies */
+ FOR (j = 0; j < be_cnt_fx; j++)
+ {
+ Rcnt_fx = add(i, 1);
+
+ /* Ravg = (float) be_sum/Rcnt; */
+ exp_normn = norm_s(be_sum_fx);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(Rcnt_fx);
+ Ravg_fx = div_s(shl(be_sum_fx, exp_normn), shl(Rcnt_fx, exp_normd));
+ Ravg_fx = shr(Ravg_fx, 2); /* safe shift */
+ QRavg = add(sub(exp_normn, exp_normd), 15-2);
+
+ if(be_sum_fx <= 0)
+ {
+ be_sum_fx = 1;
+ move16();
+ }
+
+ /* Bits_avg = (float) Bits/(be_sum+EPSILON); */
+ Bits_avg_fx = 0;
+ move16();
+ QBavg = 0;
+ move16();
+ IF ( Bits != 0 )
+ {
+ exp_normn = norm_s(Bits);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(be_sum_fx);
+ Bits_avg_fx = div_s(shl(Bits, exp_normn), shl(be_sum_fx, exp_normd));
+ Bits_avg_fx = shr(Bits_avg_fx, 2); /* safe_shift */
+ QBavg = add(sub(exp_normn, exp_normd), 15-2);
+ }
+ FOR (k = 0; k <=i; k++)
+ {
+ IF(L_R_temp[k] > 0) /* Rtemp -> SWB_BWE_LR_QRk */
+ {
+ /* Allocate more bits to SB, if SB bandenergy is higher than average energy */
+ /* R_temp[k] = (float)( Bits_avg * y_index[k]+( scale_fact * (y_index[k] - Ravg))); */
+ L_temp1 = L_mult(Bits_avg_fx, y_index_fx[k]); /* QBavg+1 */
+ L_temp2 = L_mult(scale_fact_fx, sub(shl(y_index_fx[k], QRavg), Ravg_fx)); /* 15+QRavg+1 */
+ L_R_temp[k] = L_add(L_shr(L_temp1, sub(add(QBavg, 1), SWB_BWE_LR_QRk)), L_shr(L_temp2, sub(add(QRavg, 16), SWB_BWE_LR_QRk))); /* SWB_BWE_LR_QRk */
+ }
+ }
+ IF ( LT_32(L_R_temp[i], L_Bits_needed))
+ {
+ L_R_temp[i] = L_deposit_l(0);
+
+ p2aflags_fx_ptr[index_fx[i]] = 0;
+ move16();
+
+ /* be_sum -= y_index[i]; */
+ be_sum_fx = sub(be_sum_fx, y_index_fx[i]);
+
+ i = sub(i, 1);
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+
+ /* Rearrange the bit allocation to align with original */
+ FOR ( k = 0 ; k < band_num_fx; k++ )
+ {
+ j = index_fx[k];
+ move16();
+ L_R_ptr[j] = L_R_temp[k];
+ move32();
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * hq2_bit_alloc_har()
+ *
+ * Bit allocation mechanism for HQ_HARMONIC mode
+ *-------------------------------------------------------------------*/
+
+void hq2_bit_alloc_har_fx (
+ const Word32 *L_y, /* i : Qbe band energy of sub-vectors */
+ Word16 B_fx, /* i : Q0 number of available bits */
+ const Word16 N_fx, /* i : Q0 number of sub-vectors */
+ Word32 *L_Rsubband, /* o : QRk sub-band bit-allocation vector */
+ Word16 p2a_bands_fx, /* i : highfreq bands */
+ const Word32 L_core_brate, /* i : Q0 core bit rate */
+ Word16 p2a_flags_fx[], /* i/o: Q0 p2a_flags */
+ const Word16 band_width_fx[] /* i : Q0 table of band_width */
+)
+{
+ Word16 i, j, k;
+
+ Word32 L_norm_sum; /* Qbe */
+ Word32 L_Ravg_sub[GRP_SB]; /* Qbe */
+ Word32 L_temp_band_energy[BANDS_MAX]; /* Qbe */
+
+ Word16 j_fx, k_fx, Bits_grp_fx[GRP_SB];
+
+ Word32 L_temp_band_energydiff[BANDS_MAX];
+ Word16 G1_BE_DIFF_POS_fx; /* Q0 */
+ Word32 L_G1_BE_DIFF_VAL; /* Qbe Word32 */
+ Word16 final_gr_fact_pos_fx, gmax_range_fx[2], temp_fx;
+ Word16 bits_fact_fx, bits_fact1_fx; /* Q? */
+ Word16 grp_rngmax_fx[2] = {0};
+ Word16 index_fx[NB_SWB_SUBBANDS_HAR], y_index_fx[NB_SWB_SUBBANDS_HAR], esthf_bits_fx, grp_bit_avg_fx, harmonic_band_fx;
+ Word32 L_norm_sum_avg;
+ Word32 L_norm_diff; /* Qbe */
+ Word16 bits_allocweigh_fx; /* Q15 */
+ Word16 grp_bound_fx[5];
+ Word32 L_grp_thr[GRP_SB]; /* not require Word32 precission */
+ Word16 lf_hf_ge_r_fx; /* Q15 */
+ Word32 L_avg_enhf_en_diff; /* Qbe */
+
+ Word16 B_norm_fx;
+
+ Word32 L_temp, L_temp2;
+ Word16 exp, frac;
+
+ Word32 L_THR1, L_THR2, L_THR3;
+
+ Word16 exp_norm;
+ Word16 norm_sum_fx;
+ Word16 Qns; /* Q value for norm_sum_fx */
+ Word16 Inv_norm_sum_fx; /* 1/norm_sum */
+ Word16 QIns; /* Q value for Inv_norm_sum_fx */
+
+ Word16 exp_normn, exp_normd;
+ Word16 div_fx;
+
+ Word16 Inv_p2a_bands_fx;
+ Word16 QIpb;
+
+ Word16 exp_shift;
+
+ L_THR1 = L_shl(L_deposit_l(THR1), SWB_BWE_LR_QRk);
+ L_THR2 = L_shl(L_deposit_l(THR2), SWB_BWE_LR_QRk);
+ L_THR3 = L_shl(L_deposit_l(THR3), SWB_BWE_LR_QRk);
+
+ set16_fx(Bits_grp_fx, 0, GRP_SB);
+
+ /* Initialize subbands bits allocation vector based on harmonic bands */
+ harmonic_band_fx = add(sub(N_fx, p2a_bands_fx), 1);
+ /*printf("harmonic_band= %d %d\n", harmonic_band, harmonic_band_fx);*/
+ FOR (k = 0; k < N_fx; k++)
+ {
+ L_Rsubband[k] = (Word32)(C1_QRk);
+ move32(); /* Constant Value */
+ L_temp_band_energy[k] = L_y[k];
+ move32(); /* SWB_BWE_LR_Qbe */
+ }
+ final_gr_fact_pos_fx = 2;
+ move16();
+ bits_fact_fx = C1_Qbf;
+ move16();
+ bits_fact1_fx = C1_Qbf;
+ move16();
+
+ gmax_range_fx[0]= G1_RANGE;
+ move16();
+ gmax_range_fx[1]= G1G2_RANGE;
+ move16();
+
+ IF( EQ_32(L_core_brate, HQ_16k40))
+ {
+ gmax_range_fx[1] = add(gmax_range_fx[1], 2);
+ move16();
+ }
+
+ /* decide each group range, for grouping spectral coefficients */
+ grp_rngmax_fx[1] = 16;
+ move16();
+ grp_rngmax_fx[0] = 7;
+ move16();
+ temp_fx = 0;
+ move16();
+ FOR( i=0; i<2; i++ )
+ {
+ j_fx = gmax_range_fx[i];
+ move16();
+ k_fx = 0;
+ move16();
+ WHILE(GE_32(L_temp_band_energy[gmax_range_fx[i] - 1], L_temp_band_energy[j_fx]) && LT_16(j_fx, grp_rngmax_fx[i]) )
+ {
+ test();
+ k_fx = add(k_fx, 1);
+ j_fx = add(j_fx, 1);
+ }
+
+ temp_fx = k_fx;
+ move16();
+ IF( GT_16(temp_fx, 1))
+ {
+ FOR( temp_fx = 2; temp_fx <= k_fx ; )
+ {
+ IF( LT_32(L_temp_band_energy[gmax_range_fx[i]+temp_fx-1], L_temp_band_energy[gmax_range_fx[i]+temp_fx]))
+ {
+ BREAK;
+ }
+ ELSE IF( GE_32(L_temp_band_energy[gmax_range_fx[i]+temp_fx-1], L_temp_band_energy[gmax_range_fx[i]+temp_fx]))
+ {
+ temp_fx = add(temp_fx, 1);;
+ IF( GT_16(temp_fx, k_fx))
+ {
+ temp_fx = sub(temp_fx, 1);
+ BREAK;
+ }
+ }
+ }
+
+ gmax_range_fx[i] = add(gmax_range_fx[i], temp_fx);
+ move16();
+ }
+ ELSE
+ {
+ gmax_range_fx[i] = add(gmax_range_fx[i], temp_fx);
+ move16();
+ }
+ }
+
+ grp_bound_fx[0] = 0;
+ move16();
+ FOR(i=1; i 0x0L )
+ {
+ L_Ravg_sub[i] = L_add(L_Ravg_sub[i], L_temp_band_energy[j]);
+ move32();
+ }
+ }
+ }
+
+ L_temp_band_energydiff[0] = L_temp_band_energy[0];
+ move32();
+ FOR ( j = 1; j < harmonic_band_fx; j++ )
+ {
+ L_temp_band_energydiff[j]= L_abs(L_sub(L_temp_band_energy[j], L_temp_band_energy[j-1]));
+ move32();
+ }
+
+ G1_BE_DIFF_POS_fx = 0;
+ move16();
+ L_G1_BE_DIFF_VAL = L_deposit_l(0);
+
+ FOR(j=1; j< harmonic_band_fx; j++)
+ {
+ IF( GT_32(L_temp_band_energydiff[j], L_G1_BE_DIFF_VAL))
+ {
+ G1_BE_DIFF_POS_fx = j;
+ move16();
+ L_G1_BE_DIFF_VAL = L_temp_band_energydiff[j];
+ }
+ }
+
+ test();
+ test();
+ IF( LT_16(G1_BE_DIFF_POS_fx, gmax_range_fx[0] )&&G1_BE_DIFF_POS_fx>0)
+ {
+ final_gr_fact_pos_fx = 0;
+ move16();
+ }
+ ELSE IF ( GE_16(G1_BE_DIFF_POS_fx, gmax_range_fx[0])&<_16(G1_BE_DIFF_POS_fx,gmax_range_fx[1]))
+ {
+ final_gr_fact_pos_fx = 1;
+ move16();
+ }
+ ELSE
+ {
+ final_gr_fact_pos_fx = 2;
+ move16();
+ }
+
+ test();
+ IF( final_gr_fact_pos_fx == 0 || EQ_16(final_gr_fact_pos_fx, 1))
+ {
+ IF( EQ_32(L_core_brate, HQ_16k40 ))
+ {
+ bits_fact_fx = BITS_FACT_1p10;
+ move16(); /* 1.10f; */ /* G1 */
+ bits_fact1_fx = BITS_FACT_0p92;
+ move16(); /* 0.92f; */ /* G3 */
+ }
+ ELSE
+ {
+ bits_fact_fx = BITS_FACT_1p05;
+ move16(); /* 1.05f; */ /* G1 */
+ bits_fact1_fx = BITS_FACT_0p97;
+ move16(); /* 0.97f; */ /* G3 */
+ }
+ }
+ ELSE
+ {
+ IF( EQ_32(L_core_brate, HQ_16k40))
+ {
+ bits_fact_fx = BITS_FACT_0p97;
+ move16(); /* 0.97f; */ /* G1 */
+ bits_fact1_fx = BITS_FACT_1p00;
+ move16(); /* 1.00f; */ /* G3 */
+ }
+ ELSE
+ {
+ bits_fact_fx = BITS_FACT_0p92;
+ move16(); /* 0.92f; */ /* G1 */
+ bits_fact1_fx = BITS_FACT_1p00;
+ move16(); /* 1.00f; */ /* G3 */
+ }
+ }
+
+ j = sub(N_fx, harmonic_band_fx);
+ FOR ( i = 0; i < j; i++ )
+ {
+ y_index_fx[i] = extract_h(L_shl(L_temp_band_energy[harmonic_band_fx+i], sub(16, SWB_BWE_LR_Qbe)));
+ index_fx[i] = add(harmonic_band_fx, i);
+ move16();
+ }
+
+ reordvct_fx(y_index_fx, sub(N_fx, harmonic_band_fx), index_fx);
+
+ /* Log2 */
+ L_temp = L_deposit_l(band_width_fx[index_fx[0]]);
+ exp = norm_l(L_temp);
+ frac = Log2_norm_lc(L_shl(L_temp, exp));
+ exp = sub(30, exp);
+ L_temp = L_Comp(exp, frac);
+ /* ceil */
+ if( L_and(0x0000ffff, L_temp) > 0 )
+ {
+ L_temp = L_add(L_temp, 0x00010000);
+ }
+ esthf_bits_fx = extract_h(L_temp);
+
+ L_grp_thr[0] = L_THR1;
+ move32();
+ L_grp_thr[1] = L_THR2;
+ move32();
+ L_grp_thr[2] = L_THR3;
+ move32();
+ L_grp_thr[3] = L_shl(L_deposit_l(esthf_bits_fx), SWB_BWE_LR_QRk);
+ move16();
+
+ L_norm_sum = L_deposit_l(1);
+ FOR(i=0; i<3; i++)
+ {
+ L_norm_sum = L_add( L_norm_sum, L_Ravg_sub[i]);
+ }
+
+ /*reserve bits for HF coding */
+ L_temp = L_add(L_norm_sum, L_Ravg_sub[GRP_SB-1]);
+ exp_normn = norm_l(L_temp);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(N_fx);
+
+ div_fx = div_l(L_shl(L_temp, exp_normn), shl(N_fx, exp_normd)); /* (Qbe+exp_normn)-(0+exp_normd)-1) */
+ L_norm_sum_avg = L_shr(L_deposit_h(div_fx), add(sub(exp_normn, exp_normd), 15)); /* -> Qbe */
+
+ exp_norm = norm_l(L_norm_sum);
+ norm_sum_fx = extract_h( L_shl(L_norm_sum, exp_norm) ); /* SWB_BWE_LR_Qbe+exp_norm-16 */
+ Qns = sub(add(SWB_BWE_LR_Qbe, exp_norm), 16);
+
+ Inv_norm_sum_fx = div_s( 0x4000 /* Q15 */ , norm_sum_fx );
+ QIns = sub(31, exp_norm); /* 14 - (14+exp_norm-16) + 15 */
+
+ grp_bit_avg_fx = div_s_ss(B_fx, GRP_SB); /* Q0 */
+
+ exp_normd = norm_s(p2a_bands_fx);
+ Inv_p2a_bands_fx = div_s(0x3fff, shl(p2a_bands_fx, exp_normd)); /* 14-exp_normd+15 */
+ QIpb = sub(29, exp_normd);
+
+ L_temp = L_shl(Mult_32_16(L_Ravg_sub[GRP_SB-1], Inv_p2a_bands_fx), sub(SWB_BWE_LR_Qbe, sub(QIpb,1)));
+ L_norm_diff = L_sub(L_temp, L_norm_sum_avg); /* Qbe */
+
+ L_temp = Mult_32_16(L_Ravg_sub[GRP_SB-1], sub(GRP_SB, 1)); /* Qbe+0+1 */
+ L_temp = Mult_32_16(L_temp, Inv_norm_sum_fx); /* Qbe+1+QIpb+1 */
+ lf_hf_ge_r_fx = round_fx(L_shl(L_temp, sub(15+16, sub(add(SWB_BWE_LR_Qbe, QIns),30))));
+
+ exp_normn = norm_s(norm_sum_fx);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(harmonic_band_fx);
+
+ div_fx = div_s(shl(norm_sum_fx, exp_normn), shl(harmonic_band_fx, exp_normd));
+ L_avg_enhf_en_diff = L_sub(L_temp_band_energy[index_fx[0]], L_shl(L_deposit_h(div_fx), sub(sub(SWB_BWE_LR_Qbe, (add(Qns,sub(exp_normn,exp_normd)))),31))); /* Qbe - (Qns+exp_normn-(exp_normd)+15) -16 */
+
+ test();
+ IF(GT_16(lf_hf_ge_r_fx, 26214) && GT_32(L_avg_enhf_en_diff, (Word32)(8 << SWB_BWE_LR_Qbe))) /* 0.8=26214.4(Q15) 8.0f=131072(Qbe) */
+ {
+ bits_allocweigh_fx = 6554;
+ move16(); /* 0.2 6553.6(Q15) */
+ if(L_norm_diff < 0x0L)
+ {
+ bits_allocweigh_fx = 13107;
+ move16(); /* 0.4 13107.2(Q15) */
+ }
+
+ /*allocate bits*/
+ /*Bits_grp[GRP_SB-1] = (short)min((grp_bit_avg/p2a_bands + bits_allocweigh*norm_diff),10);*/
+ L_temp = L_mult(grp_bit_avg_fx, Inv_p2a_bands_fx); /* Q0+QIpb+1 */
+ L_temp2 = Mult_32_16(L_norm_diff, bits_allocweigh_fx); /* Qbe+Q15-15 */
+
+ L_temp = L_shr(L_temp, add(QIpb, 1));
+ L_temp = L_add(L_shl(L_temp,SWB_BWE_LR_Qbe), L_temp2);
+
+ Bits_grp_fx[GRP_SB-1] = extract_h(L_shl(L_temp, sub(16, SWB_BWE_LR_Qbe)));
+ Bits_grp_fx[GRP_SB-1] = s_min(Bits_grp_fx[GRP_SB-1], 10);
+ move16();
+
+ if( LT_16(Bits_grp_fx[GRP_SB-1], esthf_bits_fx))
+ {
+ Bits_grp_fx[GRP_SB-1] = 0;
+ move16();
+ }
+ B_fx = sub(B_fx, Bits_grp_fx[GRP_SB-1]);
+ }
+
+ exp_shift = sub(add(SWB_BWE_LR_Qbe, QIns), 47); /* (SWB_BWE_LR_Qbe+14+1+QIns-15-16) */
+ exp_norm = norm_s(B_fx);
+ B_norm_fx = shl(B_fx, exp_norm);
+ exp_shift = add(exp_shift, exp_norm);
+
+ IF( EQ_16(final_gr_fact_pos_fx, 1))
+ {
+ L_temp = Mult_32_16(L_Ravg_sub[1], extract_h(L_mult(bits_fact_fx, B_norm_fx)));
+ L_temp = Mult_32_16(L_temp, Inv_norm_sum_fx);
+ Bits_grp_fx[1] = extract_h(L_shr(L_temp, exp_shift));
+
+ L_temp = Mult_32_16(L_Ravg_sub[2], extract_h(L_mult(bits_fact1_fx, B_norm_fx)));
+ L_temp = Mult_32_16(L_temp, Inv_norm_sum_fx);
+ Bits_grp_fx[2] = extract_h(L_shr(L_temp, exp_shift));
+
+ Bits_grp_fx[0] = sub(sub(B_fx, Bits_grp_fx[1]), Bits_grp_fx[2]);
+ move16();
+ }
+ ELSE
+ {
+ L_temp = Mult_32_16(L_Ravg_sub[0], extract_h(L_mult(bits_fact_fx, B_norm_fx)));
+ L_temp = Mult_32_16(L_temp, Inv_norm_sum_fx);
+ Bits_grp_fx[0] = extract_h(L_shr(L_temp, exp_shift));
+
+ L_temp = Mult_32_16(L_Ravg_sub[2], extract_h(L_mult(bits_fact1_fx, B_norm_fx)));
+ L_temp = Mult_32_16(L_temp, Inv_norm_sum_fx);
+ Bits_grp_fx[2] = extract_h(L_shr(L_temp, exp_shift));
+
+ Bits_grp_fx[1] = sub(sub(B_fx, Bits_grp_fx[0]), Bits_grp_fx[2]);
+ move16();
+ }
+
+ IF( LT_16(Bits_grp_fx[2], THR2 ))
+ {
+ Bits_grp_fx[1] = add(Bits_grp_fx[1], Bits_grp_fx[2]);
+ move16();
+ Bits_grp_fx[2] = 0;
+ move16();
+ }
+
+ FOR(i=0; i 0)
+ {
+ Bits2indvsb_fx( L_temp_band_energy, grp_bound_fx[i], grp_bound_fx[i+1] , Bits_grp_fx[i], L_grp_thr[i], L_Rsubband, p2a_flags_fx);
+ }
+ ELSE
+ {
+ set32_fx(L_Rsubband+grp_bound_fx[i], 0x0L, sub(grp_bound_fx[i+1], grp_bound_fx[i]));
+ IF( EQ_16(i, GRP_SB-1))
+ {
+ set16_fx(p2a_flags_fx+grp_bound_fx[i], 0, sub(grp_bound_fx[i+1], grp_bound_fx[i]));
+ }
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * hq2_bit_alloc()
+ *
+ * HQ2 bit-allocation
+ *--------------------------------------------------------------------------*/
+
+Word32 hq2_bit_alloc_fx (
+ const Word32 L_band_energy[], /* i : band energy of each subband */
+ const Word16 bands, /* i : total number of subbands in a frame */
+ Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */
+ Word16 *bit_budget_fx, /* i/o: bit bugdet */
+ Word16 *p2a_flags, /* i : HF tonal indicator */
+ const Word16 weight_fx, /* i : weight */
+ const Word16 band_width[], /* i : Sub band bandwidth */
+ const Word16 num_bits, /* i : available bits */
+ const Word16 hqswb_clas, /* i : HQ2 class information */
+ const Word16 bwidth, /* i : input bandwidth */
+ const Word16 is_transient /* i : indicator HQ_TRANSIENT or not */
+)
+{
+ Word16 j, k;
+ Word16 tmp;
+ Word16 bit_budget_norm_fx;
+
+ Word32 L_Rcalc, L_Ravg, L_Rcalc1;
+
+ Word16 exp_normn, exp_normd;
+
+ Word16 Rcnt_fx;
+
+ Word16 div_fx;
+ Word16 Qdiv;
+
+ Word32 L_tmp;
+ Word16 tmp_fx;
+
+ Word32 L_maxxy;
+ Word16 maxdex_fx;
+ Word32 L_dummy;
+
+ Word16 bit_budget_temp_fx;
+
+ Word16 negflag;
+
+ Word32 L_THR1, L_THR2, L_THR3;
+
+ L_THR1 = L_shl(L_deposit_l(THR1), SWB_BWE_LR_QRk);
+ L_THR2 = L_shl(L_deposit_l(THR2), SWB_BWE_LR_QRk);
+ L_THR3 = L_shl(L_deposit_l(THR3), SWB_BWE_LR_QRk);
+
+ /* Init Rk to non-zero values for bands to be allocated bits */
+ IF( LE_16(num_bits, HQ_16k40_BIT))
+ {
+ set32_fx( L_Rk, (Word32)(C1_QRk), bands); /* 1< 0 )
+ {
+ L_Ravg = L_add(L_Ravg, L_shl(L_band_energy[k], sub(SWB_BWE_LR_QRk, SWB_BWE_LR_Qbe))); /* SWB_BWE_LR_QRk-SWB_BWE_LR_Qbe */
+ Rcnt_fx = add(Rcnt_fx, 1);
+ }
+ }
+ /* Ravg Qband_energy */
+
+ /*L_Ravg /= Rcnt; */
+ exp_normd = norm_l(L_Ravg);
+ exp_normd = sub(exp_normd, 1);
+ exp_normn = norm_s(Rcnt_fx);
+
+ tmp = shl(Rcnt_fx, exp_normn);
+ tmp = s_max(tmp,1);
+ IF ( L_Ravg > 0 )
+ {
+ div_fx = div_l(L_shl(L_Ravg, exp_normd), tmp); /* Qdiv = 14+exp_normd-(exp_normn)-1 */
+ }
+ ELSE
+ {
+ div_fx = div_l(L_shl(L_abs(L_Ravg), exp_normd), tmp); /* Qdiv = 14+exp_normd-(exp_normn)-1 */
+ div_fx = negate(div_fx);
+ }
+
+ Qdiv = sub(sub(add(SWB_BWE_LR_QRk, exp_normd), exp_normn), 1);
+
+ L_Ravg = L_shr(L_deposit_l(div_fx), sub(Qdiv, SWB_BWE_LR_QRk));
+
+ exp_normd = norm_s(*bit_budget_fx);
+ exp_normd = sub(exp_normd, 1);
+ bit_budget_norm_fx = shl(*bit_budget_fx, exp_normd);
+ div_fx = 0;
+ move16();
+
+ test();
+ IF( bit_budget_norm_fx > 0 && LT_16(bit_budget_norm_fx, tmp))
+ {
+ div_fx = div_s(bit_budget_norm_fx, tmp);
+ }
+ Qdiv = add(sub(exp_normd, exp_normn), 15);
+ FOR (k = 0; k < bands; k++)
+ {
+ IF ( L_Rk[k] > 0)
+ {
+ /*Rk[k] = ((float) *bit_budget / Rcnt + weight * (band_energy[k] - Ravg)); */
+
+ L_tmp = Mult_32_16(L_sub(L_shl(L_band_energy[k], sub(SWB_BWE_LR_QRk, SWB_BWE_LR_Qbe)), L_Ravg), weight_fx); /* SWB_BWE_LR_QRk + Q13 - 15 */
+ L_tmp = L_shl(L_tmp, 2); /* -> SWB_BWE_LR_QRk */
+
+ L_Rk[k] = L_add(L_shr(L_deposit_l(div_fx), sub(Qdiv, SWB_BWE_LR_QRk)) , L_tmp);
+ move32();
+ }
+ }
+
+ negflag = 0;
+ move16();
+ L_Rcalc = L_deposit_l(0);
+ FOR (k = 0; k < bands; k++)
+ {
+ IF ( LT_32(L_Rk[k], MIN_BITS_FIX))
+ {
+ L_Rk[k] = L_deposit_l(0);
+ negflag = 1;
+ move16();
+ }
+ L_Rcalc = L_add( L_Rcalc , L_Rk[k]); /*SWB_BWE_LR_QRk */
+ }
+
+ /* prune noiselike bands with low allocation */
+ test();
+ IF ( LE_16(num_bits, HQ_16k40_BIT)&&negflag==0)
+ {
+ L_maxxy = L_deposit_l(0);
+ maxdex_fx = -1;
+ move16();
+ L_Rcalc = L_deposit_l(0);
+
+ /* find worst under-allocation */
+ FOR (k = sub(bands, 1); k >= 0; k--)
+ {
+ tmp_fx = s_min( band_width[k], s_max(12, shr( band_width[k], 2)));
+ L_dummy = L_sub(L_shl(L_deposit_l(tmp_fx), SWB_BWE_LR_QRk), L_Rk[k]) ; /*SWB_BWE_LR_QRk */
+ test();
+ test();
+ IF ( p2a_flags[k] == 0 && GT_32(L_dummy, L_maxxy)&&L_Rk[k]>0)
+ {
+ maxdex_fx = k;
+ move16();
+ L_maxxy = L_dummy; /*SWB_BWE_LR_QRk */
+ move32();
+ }
+ }
+
+ /* prune worst allocation and recalculate total allocation */
+ if ( GT_16(maxdex_fx, -1))
+ {
+ L_Rk[maxdex_fx] = L_deposit_l(0);
+ }
+ FOR (k = 0; k < bands; k++)
+ {
+ L_Rcalc = L_add(L_Rcalc, L_Rk[k]); /*SWB_BWE_LR_QRk */
+ }
+ }
+ test();
+ test();
+ IF ( EQ_32(L_Rcalc, L_Rcalc1)&&EQ_16(bwidth,SWB))
+ {
+ /* Reallocate bits to individual subbands for HQ_NORMAL mode */
+ /* if bits allocated to subbands areless than predefined threshold */
+ test();
+ IF( EQ_16(hqswb_clas, HQ_NORMAL)&<_16(num_bits,HQ_16k40_BIT))
+ {
+ L_dummy = L_deposit_l(0);
+ FOR( k = 0; k < bands; k++ )
+ {
+ test();
+ test();
+ test();
+ test();
+ test();
+ IF( LT_16(k, 11)&<_32(L_Rk[k],L_THR1))
+ {
+ L_Rk[k] = L_deposit_l(0);
+ }
+ ELSE IF( GE_16(k, 11)&<_16(k,16)&<_32(L_Rk[k],L_THR2))
+ {
+ L_Rk[k] = L_deposit_l(0);
+ }
+ ELSE if( GE_16(k, 16)&<_16(k,bands)&<_32(L_Rk[k],L_THR3))
+ {
+ L_Rk[k] = L_deposit_l(0);
+ }
+
+ L_dummy = L_add(L_dummy, L_Rk[k]);
+ }
+
+ IF( EQ_32(L_dummy, L_Rcalc ))
+ {
+ test();
+ IF( EQ_16(hqswb_clas, HQ_NORMAL)&<_16(num_bits,HQ_16k40_BIT))
+ {
+ bit_budget_temp_fx = *bit_budget_fx;
+ move16();
+ FOR( k=0; kBER_detect */
+ }
+ ELSE IF( EQ_16(bit_budget_temp_fx, *bit_budget_fx ))
+ {
+ BREAK;
+ }
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+ }
+ ELSE
+ {
+ BREAK;
+ }
+ }
+ ELSE IF ( EQ_32(L_Rcalc, L_Rcalc1 )&&NE_16(bwidth,SWB))
+ {
+ BREAK;
+ }
+
+ L_Rcalc1 = L_Rcalc;
+ move32();
+
+ }
+
+ return L_Rcalc;
+}
+
diff --git a/lib_com/hq2_core_com_fx.c b/lib_com/hq2_core_com_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..8fd73d140b04b8f28e6b84274ce1eefe27cc11a5
--- /dev/null
+++ b/lib_com/hq2_core_com_fx.c
@@ -0,0 +1,770 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "cnst_fx.h" /* Audio core constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h"
+#include "stl.h"
+#include "basop_mpy.h"
+
+/*--------------------------------------------------------------------------*
+ * mdct_spectrum_denorm()
+ *
+ *
+ *--------------------------------------------------------------------------*/
+
+void mdct_spectrum_denorm_fx(
+ const Word16 inp_vector[], /* i : Q0 : */
+ Word32 L_y2[], /* i/o : Qs : decoded spectrum */
+ const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
+ const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
+ const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */
+ const Word32 L_band_energy[], /* i : Qbe : band energy */
+ const Word16 npulses[], /* i : Q0 : number of coded spectrum */
+ const Word16 bands, /* i : Q0 : number of subbands */
+ const Word16 ld_slope_fx, /* i : Q15 : */
+ const Word16 pd_thresh_fx /* i : Q15 : */
+)
+{
+ Word16 i, k;
+ Word32 L_Eyy;
+ Word32 L_tmp, L_temp;
+ Word16 temp_fx, temp_lo_fx, temp_hi_fx;
+ Word32 L_inp_tmp[L_FRAME48k];
+ Word16 exp_norm;
+ Word16 exp_safe;
+ Word16 exp_normn, exp_normd;
+
+ Word16 pd_fx;
+ Word16 Qpd;
+
+ Word16 div_pd_fx;
+ Word16 Qdivpd;
+ Word32 L_div_pd;
+
+ Word16 frac, exp;
+
+ Word16 gain_tweak_fx;
+ Word16 Qtweak;
+
+ Word16 exp_shift;
+
+ Word16 QEyy;
+ Word16 pow_fx;
+ Word16 Qpow;
+ Word16 Qdiv;
+ Word16 Qgamma;
+ Word16 gamma_fx;
+
+ Word16 cond_fx;
+
+ exp_safe = 4; /* safe bit for overflow */
+
+ FOR (k = 0; k < bands; k++)
+ {
+ L_tmp = L_deposit_l(0);
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ L_inp_tmp[i] = L_mult(inp_vector[i], inp_vector[i]);
+ move32(); /* Q0+Q0+1 */
+ L_tmp = L_or(L_tmp, L_inp_tmp[i]);
+ }
+ exp_norm = norm_l(L_tmp);
+ exp_norm = sub(exp_norm, exp_safe);
+
+ L_Eyy = L_deposit_l(0);
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ /*Eyy += (float) inp_vector[i] * inp_vector[i]; */
+ L_Eyy = L_add(L_Eyy, L_shl(L_inp_tmp[i], exp_norm)); /* Q1+exp_norm */
+ }
+ QEyy = add(1, exp_norm);
+
+ IF ( L_Eyy > 0x0L )
+ {
+ /* Set gamma to be pulse gain which results in perfect quantized subband energy */
+ /*gamma = (float) sqrt (pow (2.0f, band_energy[k]) / Eyy); */
+
+ /* Pow part (pow(2.0f, band_energy) ) */
+ L_temp = L_shr(L_band_energy[k], sub(SWB_BWE_LR_Qbe, 16));
+ temp_lo_fx = L_Extract_lc(L_temp, &temp_hi_fx);
+ Qpow = sub(14, temp_hi_fx);
+ pow_fx = extract_l(Pow2(14, temp_lo_fx)); /* Qpow */
+
+ /* Div part ( pow (2.0f, band_energy[i])/Eyy ) */
+ exp_normn = norm_s(pow_fx);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_l(L_Eyy);
+ temp_fx = div_s( shl( pow_fx, exp_normn), extract_h(L_shl(L_Eyy, exp_normd)));
+ Qdiv = add(sub(add(Qpow, exp_normn) , add(QEyy, exp_normd)), 31);
+
+ exp_norm = norm_s(temp_fx);
+ temp_fx = shl(temp_fx, exp_norm);
+ Qdiv = add(Qdiv, exp_norm);
+
+ /* Sqrt part sqrt(pow (2.0f, band_energy[i])/Eyy) */
+ Qgamma = add(Qdiv, 16);
+ IF ( s_and(Qdiv, 1) == 0 ) /* Qdiv % 2 == 0 */
+ {
+ L_temp = Sqrt_l(L_shr(L_deposit_h(temp_fx),1), &exp_norm);
+ L_temp = L_shr(L_temp, exp_norm);
+ Qgamma = sub(shr(Qgamma, 1), 1);
+ gamma_fx = round_fx(L_temp);
+ }
+ ELSE
+ {
+ L_temp = Sqrt_l(L_deposit_h(temp_fx), &exp_norm);
+ L_temp = L_shr(L_temp, exp_norm);
+ Qgamma = shr(Qgamma, 1);
+ gamma_fx = round_fx(L_temp);
+ }
+
+ /* Adjust gamma based on pulse density (0 bit MSE gain estimator) */
+ /*pd = (float) npulses[k] / band_width[k]; */
+ exp_normn = norm_s(npulses[k]);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(band_width[k]);
+ pd_fx = div_s(shl(npulses[k],exp_normn), shl(band_width[k], exp_normd));
+ Qpd = add(sub(exp_normn, exp_normd), 15);
+
+ cond_fx = sub(shl(pd_fx, sub(15, Qpd)), pd_thresh_fx/*Q15*/);
+ Overflow = 0;
+ move16(); /* allow overflow happen. */
+ IF ( cond_fx < 0 )
+ {
+ /*gain_tweak = (float) pow (2.0f, (ld_slope * log2_f (pd / pd_thresh))); */
+ /* Div part */
+ exp_normn = norm_s(pd_fx);
+ exp_normn = sub(exp_normn, 1);
+ exp_normd = norm_s(pd_thresh_fx);
+ div_pd_fx = div_s(shl(pd_fx, exp_normn), shl(pd_thresh_fx, exp_normd)); /* Qpd+exp_normn - (15 + exp_normd) + 15 */
+ Qdivpd = add(sub(add(Qpd, exp_normn), add(15, exp_normd)), 15);
+
+ /* Log2 part */
+ exp_norm = norm_s(div_pd_fx);
+ L_div_pd = L_deposit_h(shl(div_pd_fx, exp_norm));
+ Qdivpd = add(add(Qdivpd, exp_norm), 16);
+
+ frac = Log2_norm_lc(L_div_pd);
+ exp = sub(30, Qdivpd);
+ L_tmp = L_Comp(exp, frac); /* Q16 */
+
+ /* Mult part */
+ L_tmp = Mpy_32_16_1(L_tmp, ld_slope_fx);
+
+ /* Pow part */
+ temp_lo_fx = L_Extract_lc(L_tmp, &temp_hi_fx);
+ Qtweak = sub(14, temp_hi_fx);
+ gain_tweak_fx = extract_l(Pow2(14, temp_lo_fx));
+
+ /*gamma *= gain_tweak; */
+ L_tmp = L_mult(gamma_fx, gain_tweak_fx); /* Qgamma+Qtweak+1 */
+ exp_norm = norm_l(L_tmp);
+ gamma_fx = round_fx(L_shl(L_tmp, exp_norm));
+ Qgamma = sub(add(add(Qgamma, Qtweak), exp_norm), 15);/*Qgamma+Qtweak+1+exp_norm-16; */
+ }
+
+ exp_shift = sub(SWB_BWE_LR_Qs-1, Qgamma);
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ /*y2[i] = gamma * inp_vector[i]; */
+ L_tmp = L_mult(gamma_fx, (Word16)inp_vector[i]); /* Qgamma+0+1=Qgamma+1 */
+ L_y2[i] = L_shl(L_tmp, exp_shift);
+ move32();
+ }
+ }
+ }
+
+ return;
+}
+/*==========================================================================*/
+/* FUNCTION : void hq2_core_configure_fx() */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* Word16 *qint o: Q13 */
+/* Word16 *eref o: Q10 */
+/* Word16 *bit_alloc_weight o: Q13 */
+/* Word16 *p2a_th o: Q11 */
+/* Word16 *pd_thresh o: Q15 */
+/* Word16 *ld_slope o: Q15 */
+/* Word16 *ni_coef o: Q14 */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*--------------------------------------------------------------------------*/
+/* CALLED FROM : */
+/*==========================================================================*/
+
+void hq2_core_configure_fx (
+ const Word16 frame_length,
+ const Word16 num_bits,
+ const Word16 is_transient,
+ Word16 *bands,
+ Word16 *length,
+ Word16 band_width[],
+ Word16 band_start[],
+ Word16 band_end[],
+ Word32 *L_qint,
+ Word16 *eref,
+ Word16 *bit_alloc_weight,
+ Word16 *gqlevs,
+ Word16 *Ngq,
+ Word16 *p2a_bands,
+ Word16 *p2a_th,
+ Word16 *pd_thresh,
+ Word16 *ld_slope,
+ Word16 *ni_coef,
+ Word32 L_bwe_br
+)
+{
+ const Xcore_Config_fx *xcore_config_fx;
+
+ Word16 i, k;
+ Word16 bands_sh;
+
+ xcore_config_fx = &xcore_config_32kHz_013200bps_long_fx; /* default set for VC Warning */
+
+ IF ( EQ_16(frame_length, L_FRAME8k))
+ {
+ IF( is_transient )
+ {
+ IF ( LE_16(num_bits, ACELP_7k20 / 50))
+ {
+ xcore_config_fx = &xcore_config_8kHz_007200bps_short_fx;
+ }
+ ELSE IF ( LE_16(num_bits, ACELP_8k00 / 50))
+ {
+ xcore_config_fx = &xcore_config_8kHz_008000bps_short_fx;
+ }
+ ELSE IF ( LE_16(num_bits, ACELP_13k20 / 50))
+ {
+ xcore_config_fx = &xcore_config_8kHz_013200bps_short_fx;
+ }
+ ELSE
+ {
+ xcore_config_fx = &xcore_config_8kHz_016400bps_short_fx;
+ }
+ }
+ ELSE
+ {
+ IF ( LE_16(num_bits, ACELP_7k20 / 50))
+ {
+ xcore_config_fx = &xcore_config_8kHz_007200bps_long_fx;
+ }
+ ELSE IF ( LE_16(num_bits, ACELP_8k00 / 50))
+ {
+ xcore_config_fx = &xcore_config_8kHz_008000bps_long_fx;
+ }
+ ELSE IF ( LE_16(num_bits, ACELP_13k20 / 50))
+ {
+ xcore_config_fx = &xcore_config_8kHz_013200bps_long_fx;
+ }
+ ELSE
+ {
+ xcore_config_fx = &xcore_config_8kHz_016400bps_long_fx;
+ }
+ }
+ }
+ ELSE IF ( EQ_16(frame_length, L_FRAME16k))
+ {
+ IF (is_transient)
+ {
+ IF ( LE_16(num_bits, ACELP_13k20 / 50))
+ {
+ xcore_config_fx = &xcore_config_16kHz_013200bps_short_fx;
+ move16();
+ }
+ ELSE if ( LE_16(num_bits, ACELP_16k40 / 50))
+ {
+ xcore_config_fx = &xcore_config_16kHz_016400bps_short_fx;
+ move16();
+ }
+ }
+ ELSE
+ {
+ IF ( LE_16(num_bits, ACELP_13k20 / 50))
+ {
+ xcore_config_fx = &xcore_config_16kHz_013200bps_long_fx;
+ move16();
+ }
+ ELSE if ( LE_16(num_bits, ACELP_16k40 / 50))
+ {
+ xcore_config_fx = &xcore_config_16kHz_016400bps_long_fx;
+ move16();
+ }
+ }
+ }
+ ELSE /* (frame_length == SWB) */
+ {
+ IF (is_transient)
+ {
+ IF ( LE_32(L_bwe_br, ACELP_13k20))
+ {
+ xcore_config_fx = &xcore_config_32kHz_013200bps_short_fx;
+ move16();
+ }
+ ELSE if ( LE_32(L_bwe_br, ACELP_16k40))
+ {
+ xcore_config_fx = &xcore_config_32kHz_016400bps_short_fx;
+ move16();
+ }
+ }
+ ELSE
+ {
+ IF ( LE_32(L_bwe_br, ACELP_13k20))
+ {
+ xcore_config_fx = &xcore_config_32kHz_013200bps_long_fx;
+ move16();
+ }
+ ELSE if ( LE_32(L_bwe_br, ACELP_16k40))
+ {
+ xcore_config_fx = &xcore_config_32kHz_016400bps_long_fx;
+ move16();
+ }
+ }
+ }
+
+ *bands = xcore_config_fx->bands;
+ move16();
+ *length = xcore_config_fx->bw;
+ move16();
+ *L_qint = xcore_config_fx->L_qint;
+ move32();
+
+ *eref = xcore_config_fx->eref;
+ move16();
+ *bit_alloc_weight = xcore_config_fx->bit_alloc_weight;
+ move16();
+ *gqlevs = xcore_config_fx->gqlevs;
+ move16();
+ *Ngq = xcore_config_fx->Ngq;
+ move16();
+
+ *p2a_bands = xcore_config_fx->p2a_bands;
+ move16();
+ *p2a_th = xcore_config_fx->p2a_th;
+ move16();
+
+ *pd_thresh = xcore_config_fx->pd_thresh;
+ move16();
+ *ld_slope = xcore_config_fx->ld_slope;
+ move16();
+ *ni_coef = xcore_config_fx->ni_coef;
+ move16();
+
+ /*mvs2s_fx (xcore_config_fx->band_width, band_width, *bands); */
+ Copy(xcore_config_fx->band_width, band_width, *bands);
+
+ /* Expand band_width[] table for short windows */
+ IF (is_transient)
+ {
+ bands_sh = *bands;
+ move16();
+ *bands = shl(bands_sh,2);
+ *length = shl(*length, 2);
+
+ FOR (i = 1; i <= 3; i++)
+ {
+ FOR (k = 0; k < bands_sh; k++)
+ {
+ band_width[i * bands_sh + k] = band_width[k];
+ move16();
+ }
+ }
+ }
+
+ /* Formulate band_start and band_end tables from band_width table */
+ band_start[0] = 0;
+ move16();
+ band_end[0] = sub(band_width[0], 1);
+ move16();
+ FOR (k = 1; k < *bands; k++)
+ {
+ band_start[k] = add( band_start[k - 1] , band_width[k - 1]);
+ move16();
+ band_end[k] = sub(add( band_start[k] , band_width[k]) , 1);
+ move16();
+ }
+
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * reverse_transient_frame_energies()
+ *
+ *
+ *--------------------------------------------------------------------------*/
+
+void reverse_transient_frame_energies_fx(
+ Word32 L_band_energy[], /* o : Q14 : band energies */
+ const Word16 bands /* i : Q0 : number of bands */
+)
+{
+ Word16 k, k1, k2;
+ Word32 L_be;
+ Word16 bands_2, bands_4, bands_8;
+ Word32 *p_be1, *p_be2;
+
+ bands_2 = shr(bands, 1);
+ bands_4 = shr(bands, 2);
+ bands_8 = shr(bands, 3);
+
+ k1 = bands_4;
+ k2 = sub(bands_2, 1);
+ p_be1 = &L_band_energy[k1];
+ p_be2 = &L_band_energy[k2];
+ FOR( k = 0; k < bands_8; k++ )
+ {
+ L_be = *p_be1;
+ move32();
+ *p_be1 = *p_be2;
+ move32();
+ *p_be2 = L_be;
+ move32();
+ p_be1++;
+ p_be2--;
+ }
+
+ k1 = sub(bands, bands_4); /* 3*bands/4 */
+ k2 = sub(bands, 1);
+ p_be1 = &L_band_energy[k1];
+ p_be2 = &L_band_energy[k2];
+ FOR( k = 0; k < bands_8; k++ )
+ {
+ L_be = *p_be1;
+ move32();
+ *p_be1 = *p_be2;
+ move32();
+ *p_be2 = L_be;
+ move32();
+ p_be1++;
+ p_be2--;
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * spt_shorten_domain_pre()
+ *
+ * Compute shorten subband if previous frame has spectral peak.
+ *--------------------------------------------------------------------------*/
+
+void spt_shorten_domain_pre_fx(
+ const Word16 band_start[], /* i: Starting position of sub band */
+ const Word16 band_end[], /* i: End position of sub band */
+ const Word16 prev_SWB_peak_pos[], /* i: Spectral peak */
+ const Word16 BANDS, /* i: total number of bands */
+ const Word32 L_bwe_br, /* i: bitrate information */
+ Word16 new_band_start[], /* o: Starting position of new shorten sub band */
+ Word16 new_band_end[], /* o: End position of new shorten sub band */
+ Word16 new_band_width[] /* o: new sub band bandwidth */
+)
+{
+ Word16 j;
+ Word16 k;
+ Word16 kpos;
+
+ Word16 new_band_width_half;
+ const Word16 *p_bw_SPT_tbl; /* pointer of bw_SPT_tbl */
+
+ p_bw_SPT_tbl = bw_SPT_tbl[0];
+ if( EQ_32(L_bwe_br, HQ_16k40))
+ {
+ p_bw_SPT_tbl = bw_SPT_tbl[1];
+ }
+
+ kpos = 0;
+ j = 0;
+ move16();
+ FOR(k=sub(BANDS,SPT_SHORTEN_SBNUM); k0)
+ {
+ exp = norm_s(band_width[k_sort[k]]);
+ tmp = shl(band_width[k_sort[k]],exp);/*Q(exp) */
+ tmp = div_s(16384,tmp);/*Q(15+14-exp = 29-exp) */
+ L_tmp = Mult_32_16(Rk_sort[k],tmp);/* Q(16+29-exp-15 = 30-exp) */
+ tmp = sub(18,exp);
+ ever_sort[k] = extract_l(L_shr(L_tmp,tmp));/*Q12 */
+ IF(LT_16(ever_sort[k],ever_temp))
+ {
+ ever_temp = ever_sort[k];
+ move16();
+ k2 = k;
+ move16();
+ }
+ }
+ }
+ }
+
+ k_num[0] = k2;
+ IF(EQ_16(k_sort[k2],sub(BANDS,1)))
+ {
+ FOR (k = 0; k < BANDS; k++)
+ {
+ if(EQ_16(k_sort[k],sub(k_sort[k2],1)))
+ {
+ k_num[1] = k;
+ move16();
+ }
+ }
+ }
+ ELSE IF(k_sort[k2] == 0)
+ {
+ FOR (k = 0; k < BANDS; k++)
+ {
+ if(EQ_16(k_sort[k],add(k_sort[k2],1)))
+ {
+ k_num[1] = k;
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ IF ( LT_32( Rk[sub(k_sort[k2],1)],Rk[add(k_sort[k2],1)] ))
+ {
+ FOR (k = 0; k < BANDS; k++)
+ {
+ if(EQ_16(k_sort[k],sub(k_sort[k2],1)))
+ {
+ k_num[1] = k;
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ FOR (k = 0; k < BANDS; k++)
+ {
+ if(EQ_16(k_sort[k],add(k_sort[k2],1)))
+ {
+ k_num[1] = k;
+ move16();
+ }
+ }
+ }
+ }
+}
diff --git a/lib_com/hq2_noise_inject_fx.c b/lib_com/hq2_noise_inject_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..b6de4103e92697904a6581429c84d36b2efd1b90
--- /dev/null
+++ b/lib_com/hq2_noise_inject_fx.c
@@ -0,0 +1,618 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "stl.h"
+#include "prot_fx.h"
+#include "math_op.h"
+#include "math_32.h"
+#include "oper_32b.h"
+#include "move.h"
+#include "count.h"
+
+/*--------------------------------------------------------------------------*
+ * hq2_noise_inject()
+ *
+ * HQ2 noise injection for WB signals
+ *--------------------------------------------------------------------------*/
+void hq2_noise_inject_fx(
+ Word32 L_y2[],
+ const Word16 band_start[],
+ const Word16 band_end[],
+ const Word16 band_width[],
+ Word32 Ep_fx[],
+ Word32 Rk_fx[],
+ const Word16 npulses[],
+ Word16 ni_seed,
+ const Word16 bands,
+ const Word16 ni_start_band,
+ const Word16 bw_low,
+ const Word16 bw_high,
+ const Word32 enerL_fx,
+ const Word32 enerH_fx,
+ Word32 last_ni_gain_fx[],
+ Word16 last_env_fx[],
+ Word16 *last_max_pos_pulse,
+ Word16 *p2a_flags,
+ Word16 p2a_bands,
+ const Word16 hqswb_clas,
+ const Word16 bwidth,
+ const Word32 bwe_br
+)
+{
+ Word32 L_tmp,L_tmp2,L_tmp2x,L_tmp3,L_tmp1;
+ Word16 exp,exp2,Q_speech;
+ Word16 pd_fx[BANDS_MAX], rand_fx, peak_fx[BANDS_MAX], fac_fx;
+
+ Word16 tmp,tmpx,tmp1,tmp2,tmp3,tmp4,Q_env_fx[BANDS_MAX],Q_Ep_fx[BANDS_MAX];
+
+ Word16 Qs=SWB_BWE_LR_Qs;
+ Word32 env_fx[BANDS_MAX];
+ Word16 env_fx2[BANDS_MAX];
+ Word32 ni_gain_fx[BANDS_MAX];
+ Word16 y2hat_fx[L_FRAME48k];
+
+ Word16 i, j, k, ni_end_band, satur, count[BANDS_MAX], max_pos_pulse, pos;
+ Word16 sb = bands;
+
+ satur = 0;
+ move16();
+
+ FOR(i = 0 ; i < bands; i++)
+ {
+ Ep_fx[i] = L_shl(Ep_fx[i], 6);/* Q-6 -> Q0 */ move32();
+ }
+
+ tmp = add(band_end[bands-1], 1);
+ FOR (k = 0; k < tmp; k++)
+ {
+ y2hat_fx[k] = (Word16)L_min(L_max(L_shr(L_y2[k],Qs),-32768),32767);
+ move16(); /* Extract_l or something else is missing here */
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF( (EQ_16(hqswb_clas,HQ_HARMONIC)||EQ_16(hqswb_clas,HQ_NORMAL))&&(EQ_32(bwe_br,HQ_16k40)||EQ_32(bwe_br,HQ_13k20))&&EQ_16(bwidth,SWB))
+ {
+ sb = 17;
+ move16();
+ if( EQ_32(bwe_br,HQ_16k40))
+ {
+ sb = 19;
+ move16();
+ }
+ }
+
+ /* calculate the envelopes/ the decoded peak coeff./number of the decoded coeff./ the last subbands of the bit-allocated/saturation of bit-allocation */
+ ni_end_band = bands;
+ max_pos_pulse = bands;
+ FOR (k = ni_start_band; k < ni_end_band; k++)
+ {
+ tmp = div_s(1, band_width[k]); /*Q15 */
+ L_tmp = Mult_32_16(Rk_fx[k],tmp);/*Q(16+15-15=16) */
+ pd_fx[k] = extract_h(L_shl(L_tmp,10)); /*16+10-16 =Q10 */
+
+ L_tmp2 = Ep_fx[k];/*Q0 */
+ move32();
+ L_tmp = L_max(1, L_tmp2);
+ exp = norm_l(L_tmp);
+ tmp = extract_h(L_shl(L_tmp, exp));
+
+ L_tmp3 = (Word32)band_width[k];
+ move32();
+ exp2 = norm_l(L_tmp3);
+ tmp2 = extract_h(L_shl(L_tmp3, exp2));
+
+ exp2 = sub(exp, exp2); /* Denormalize and substract */
+
+ tmp3 = sub(tmp2, tmp);
+ if (tmp3 > 0)
+ {
+ tmp2 = shr(tmp2, 1);
+ }
+ if (tmp3 > 0)
+ {
+ exp2 = add(exp2, 1);
+ }
+ tmp = div_s(tmp2, tmp);
+ L_tmp = L_deposit_h(tmp);
+ L_tmp = Isqrt_lc(L_tmp, &exp2);
+ env_fx[k] = L_tmp;
+ move32();/*Q(31-exp2) move32(); */
+ Q_env_fx[k] = sub(31,exp2);
+ move16();
+ tmp = sub(17,Q_env_fx[k]);
+ env_fx2[k] = extract_h(L_shl(env_fx[k],tmp));/*Q1 */
+ peak_fx[k] = 0;
+ move16();
+ count[k] = 0;
+ move16();
+
+ IF(npulses[k] != 0)
+ {
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ L_tmp =L_mult0(y2hat_fx[i],y2hat_fx[i]); /*0 */
+ Ep_fx[k] =L_sub(Ep_fx[k],L_tmp);
+ move32();/*0 */
+ IF(GT_16(abs_s(y2hat_fx[i]),peak_fx[k]))
+ {
+ peak_fx[k] = abs_s(y2hat_fx[i]);
+ move16();/*0 */
+ }
+
+ IF(y2hat_fx[i] != 0)
+ {
+ count[k] = add(count[k],1);
+ move16();
+ }
+ }
+
+ max_pos_pulse = k;
+ L_tmp2 = Ep_fx[k];
+ move32();
+ L_tmp = L_max(1, L_tmp2);
+ exp = norm_l(L_tmp);
+ tmp = extract_h(L_shl(L_tmp, exp));
+
+ L_tmp3 = (Word32)band_width[k];
+ exp2 = norm_l(L_tmp3);
+ tmp2 = extract_h(L_shl(L_tmp3, exp2));
+
+ exp2 = sub(exp, exp2); /* Denormalize and substract */
+
+ tmp3 = sub(tmp2, tmp);
+ if (tmp3 > 0)
+ {
+ tmp2 = shr(tmp2, 1);
+ }
+ if (tmp3 > 0)
+ {
+ exp2 = add(exp2, 1);
+ }
+ tmp = div_s(tmp2, tmp);
+ L_tmp = L_deposit_h(tmp);
+ L_tmp = Isqrt_lc(L_tmp, &exp2);
+ Ep_fx[k] = L_tmp;
+ move32();/*Q(31-exp2) */
+ Q_Ep_fx[k] = sub(31,exp2);
+ move16();
+ }
+ ELSE
+ {
+ Ep_fx[k] = env_fx[k];
+ move32();/*Q(Q_env_fx[k]) */
+ Q_Ep_fx[k] = Q_env_fx[k];
+ move16();/*31-exp2 */
+ }
+ }
+
+ FOR(k = ni_start_band; k < ni_end_band; k++)
+ {
+ /* calculate the noise gain */
+ satur =0;
+ move16();
+ if(GE_16(pd_fx[k],819))
+ {
+ satur =1;
+ move16();
+ }
+
+ test();
+ IF (satur == 0 && Ep_fx[k] > 0)
+ {
+ IF(npulses[k] != 0)
+ {
+ IF( EQ_16(bwidth,SWB))
+ {
+ IF(NE_16(hqswb_clas,HQ_TRANSIENT))
+ {
+ IF(peak_fx[k]!=0)
+ {
+ Q_speech = norm_s(peak_fx[k]);
+ tmp = shl(peak_fx[k],Q_speech);/*Q(Q_speech) */
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech) */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;
+ move16();
+ Q_speech = 0;
+ move16();
+ }
+ L_tmp2x = Mult_32_16(Ep_fx[k],tmp);/* Q(Q_Ep_fx[k]+29-Q_speech-15 = Q_Ep_fx[k]-Q_speech+14) */
+ tmp = sub(Q_Ep_fx[k],Q_speech);
+ tmpx = add(tmp,1);
+ tmp2 = extract_l(L_shr(L_tmp2x,s_min(tmpx, 31)));/*Q13 Ep[k]/peak[k] */
+
+ IF(EQ_16(hqswb_clas, HQ_HARMONIC))
+ {
+ tmp = sub(1536,pd_fx[k]); /*Q10 */
+ tmp3 = shl(tmp,4); /*Q14 */
+ L_tmp = Mult_32_16(env_fx[k],tmp3);/*Q(Q_env_fx[k]+14-15 = Q_env_fx[k]-1) */
+ L_tmp = Mult_32_16(L_tmp,6144);/*Q(Q_env_fx[k]-1+10-15 = Q_env_fx[k]-6) */
+
+ IF(peak_fx[k]!=0)
+ {
+ Q_speech = norm_s(peak_fx[k]);
+ tmp = shl(peak_fx[k],Q_speech);/*Q(Q_speech) */
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech) */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;
+ move16();
+ Q_speech = 0;
+ move16();
+ }
+
+ L_tmp2 = Mult_32_16(Ep_fx[k],tmp);/* Q(Q_Ep_fx[k]+29-Q_speech-15=Q_Ep_fx[k]-Q_speech+14) */
+ L_tmp3 = Mult_32_16(L_tmp,tmp);/* Q(Q_env_fx[k]-6+29-Q_speech-15=Q_env_fx[k]-Q_speech+8) */
+ L_tmp = Mult_32_32(L_tmp2,L_tmp3); /*Q(Q_Ep_fx[k]-Q_speech+14+Q_env_fx[k]-Q_speech+8-31=Q_Ep_fx[k]+Q_env_fx[k]-2*Q_speech-9) */
+
+ tmp = add(Q_Ep_fx[k],Q_env_fx[k]);
+ tmp = sub(tmp,Q_speech);
+ tmp = sub(tmp,Q_speech);
+ tmp = sub(37,tmp);
+ tmp1= extract_h(L_shl(L_tmp,tmp));/*Q12 //6.0f*(1.5f - pd[k])*env[k]*Ep[k]/(peak[k]*peak[k]) */
+
+ fac_fx = tmp1;
+ move16();/*Q12 */
+ if(GT_16(k,sb))
+ {
+ fac_fx =mult(24576,tmp2);/*//Q(14+13-15=12) */
+ }
+ }
+ ELSE
+ {
+ IF(LE_16(k,sb))
+ {
+ tmp = sub(1536,pd_fx[k]); /*Q10 */
+ tmp3 = shl(tmp,4); /*Q14 */
+ L_tmp = Mult_32_16(L_tmp2x,tmp3);/*Q(Q_Ep_fx[k]-Q_speech+14+14-15 = Q_Ep_fx[k]-Q_speech+13) */
+ L_tmp = Mult_32_16(L_tmp,20480);/*Q(Q_Ep_fx[k]-Q_speech+13+12-15 = Q_Ep_fx[k]-Q_speech+10) */
+ fac_fx= extract_h(L_shl(L_tmp,sub(add(18,Q_speech),Q_Ep_fx[k])));/*Q_Ep_fx[k]-Q_speech+10 +18+Q_speech-Q_Ep_fx[k] -16 =12 */
+ }
+ ELSE
+ {
+ fac_fx =shl(mult(32767,tmp2),1);/*//Q(13+13-15+1=12) */
+ }
+ }
+ }
+ ELSE
+ {
+ fac_fx = 4505;
+ move16();/*Q12 */
+ }
+ }
+ ELSE
+ {
+ tmp = sub(1536,pd_fx[k]); /*Q10 */
+ tmp2 = s_min(1024,tmp); /*q10 */
+ tmp2 = shl(tmp2,4); /*Q14 */
+ L_tmp = Mult_32_16(env_fx[k],tmp2);/*Q(Q_env_fx[k]+14-15 = Q_env_fx[k]-1) */
+ L_tmp = Mult_32_16(L_tmp,20480);/*Q(Q_env_fx[k]-1+10-15 = Q_env_fx[k]-6) */
+
+ IF(peak_fx[k]!=0)
+ {
+ Q_speech = norm_s(peak_fx[k]);
+ tmp = shl(peak_fx[k],Q_speech);/*Q(Q_speech) */
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech) */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;
+ move16();
+ Q_speech = 0;
+ move16();
+ }
+
+ L_tmp2 = Mult_32_16(Ep_fx[k],tmp);/* Q(Q_Ep_fx[k]+29-Q_speech-15=Q_Ep_fx[k]-Q_speech+14) */
+ L_tmp3 = Mult_32_16(L_tmp,tmp);/* Q(Q_env_fx[k]-6+29-Q_speech-15=Q_env_fx[k]-Q_speech+8) */
+ L_tmp = Mult_32_32(L_tmp2,L_tmp3); /*Q(Q_Ep_fx[k]-Q_speech+14+Q_env_fx[k]-Q_speech+8-31=Q_Ep_fx[k]+Q_env_fx[k]-2*Q_speech-9) */
+
+ tmp = add(Q_Ep_fx[k],Q_env_fx[k]);
+ tmp = sub(tmp,Q_speech);
+ tmp = sub(tmp,Q_speech);
+ tmp = sub(37,tmp);
+
+ fac_fx = extract_h(L_shl(L_tmp,tmp));/*Q12 */
+
+ test();
+ IF(GT_16(k,1)&<_16(k,sub(ni_end_band,1)))
+ {
+ IF(env_fx2[k]!=0)
+ {
+ Q_speech = norm_s(env_fx2[k]);
+ tmp = shl(env_fx2[k],Q_speech);/*Q(Q_speech+1) */
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech-1=28-Q_speech) */
+ Q_speech = sub(28,Q_speech);
+ }
+ ELSE
+ {
+ tmp =0x7fff;
+ move16();
+ Q_speech = 0;
+ move16();
+ }
+ tmp1 = mult(env_fx2[add(k,1)],16384);/*Q(1+15-15=1) Q1 */
+ tmp2 = sub(env_fx2[k],tmp1);
+ tmp1 = mult(env_fx2[k],16384);/*Q(1+15-15=1) Q1 */
+ tmp3 = sub(tmp1,env_fx2[sub(k,1)]);
+ tmp1 = mult(peak_fx[k],16384);/*Q(0+15-15=0) Q0 */
+ tmp4 = sub(tmp1,shr(env_fx2[k],1));
+ test();
+ test();
+ test();
+ IF(count[add(k,1)] == 0 && tmp2 > 0 && tmp3 < 0)
+ {
+ L_tmp = L_mult(env_fx2[add(k,1)],tmp);/* Q(1+Q_speech+1 = Q_speech+2) */
+ L_tmp = Mult_32_16(L_tmp,24576); /*Q(Q_speech+2+14-15=Q_speech+1) */
+ fac_fx = extract_h(L_shl(L_tmp,sub(27,Q_speech)));/*Q12 */
+ }
+ ELSE IF(count[sub(k,1)] == 0 && tmp4 > 0)
+ {
+ L_tmp = L_mult(env_fx2[sub(k,1)],tmp); /* Q(1+Q_speech+1 = Q_speech+2) */
+ fac_fx = extract_h(L_shl(L_tmp,sub(26,Q_speech)));/*Q12 */
+ }
+ }
+
+ test();
+ IF(GE_16(k,sub(ni_end_band,p2a_bands))&&EQ_16(bwidth,WB))
+ {
+ L_tmp = Mult_32_16(enerH_fx, bw_low);
+ L_tmp2= Mult_32_16(enerL_fx, bw_high);
+ L_tmp = L_sub(L_tmp,L_tmp2);
+ tmp1 = mult(peak_fx[k],16384);/*Q(0+15-15=0) Q0 */
+ tmp4 = sub(tmp1,shr(env_fx2[k],1));
+ test();
+ IF(L_tmp > 0 && tmp4 < 0)
+ {
+ IF(peak_fx[k]!=0)
+ {
+ Q_speech = norm_s(peak_fx[k]);
+ tmp = shl(peak_fx[k],Q_speech);/*Q(Q_speech) */
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech) */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;
+ move16();
+ Q_speech = 0;
+ move16();
+ }
+ L_tmp2 = Mult_32_16(Ep_fx[k],tmp);/* Q(Q_Ep_fx[k]+29-Q_speech-15 = Q_Ep_fx[k]-Q_speech+14) */
+ tmp = sub(Q_Ep_fx[k],Q_speech);
+ tmp = add(tmp,1);
+ tmp = extract_l(L_shr(L_tmp2,tmp));/*Q13 */
+ tmp = sub(16384,tmp);/*Q13 */
+ fac_fx = extract_h(L_shl(L_mult(fac_fx,tmp),2));/*Q12*/
+ }
+
+ IF(p2a_flags[k] == 0)
+ {
+ L_tmp2 = Mult_32_16(Ep_fx[k],fac_fx);/*Q(Q_Ep_fx[k]+12-15 = Q_Ep_fx[k]-3) */
+ Q_speech = norm_l(L_tmp2);
+ tmp = extract_h(L_shl(L_tmp2,Q_speech));/*Q(Q_Ep_fx[k]-3+Q_speech-16 = Q_Ep_fx[k]+Q_speech-19) */
+ IF(tmp != 0)
+ {
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_Ep_fx[k]-Q_speech+19 = 48-Q_Ep_fx[k]-Q_speech) */
+ L_tmp2 = Mult_32_16(env_fx[k],tmp);/*Q(Q_env_fx[k]+48-Q_Ep_fx[k]-Q_speech-15 = Q_env_fx[k]-Q_Ep_fx[k]-Q_speech+33) */
+ L_tmp2 = Mult_32_16(L_tmp2,20480);/*Q(Q_env_fx[k]-Q_Ep_fx[k]-Q_speech+33+14-15 = Q_env_fx[k]-Q_Ep_fx[k]-Q_speech+32) */
+ tmp = sub(Q_env_fx[k],Q_Ep_fx[k]);
+ tmp = sub(tmp,Q_speech);
+ tmp = add(tmp,25);
+ L_tmp = L_shr(L_tmp2,tmp);/*Q7 */
+ tmp = extract_l(L_min(L_tmp,192));/* */
+ fac_fx = extract_h(L_shl(L_mult(fac_fx,tmp),8));/*Q12 */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;/*Q0 */
+ L_tmp2 = Mult_32_16(env_fx[k],tmp);/*Q(Q_env_fx[k]+0-15 = Q_env_fx[k]-15) */
+ L_tmp2 = Mult_32_16(L_tmp2,20480);/*Q(Q_env_fx[k]-15+14-15 = Q_env_fx[k]-16) */
+ tmp = sub(Q_env_fx[k],23);
+ L_tmp = L_shr(L_tmp2,tmp);/*Q7 */
+ tmp = extract_l((L_min(L_tmp,192)));/* */
+ fac_fx = extract_h(L_shl(L_mult(fac_fx,tmp),8));/*Q12 */
+ }
+ }
+ }
+ }
+ }
+ ELSE
+ {
+ fac_fx = 4505;
+ move16();
+ test();
+ if( EQ_16(hqswb_clas,HQ_HARMONIC)&&EQ_16(bwidth,SWB))
+ {
+ fac_fx = 3277;
+ move16();
+ }
+ }
+
+ L_tmp = Mult_32_16(Ep_fx[k],fac_fx);/*Q(Q_Ep_fx[k]+12-15 = Q_Ep_fx[k]-3) */
+ ni_gain_fx[k] = L_shr(L_tmp,sub(Q_Ep_fx[k],20));
+ move32();/*Q17 */
+ }
+ ELSE
+ {
+ ni_gain_fx[k] = L_deposit_l(0);
+ }
+
+ /* smooth the noise gain between the current frame and the previous frame */
+ pos = s_max(max_pos_pulse, *last_max_pos_pulse);
+ move16();
+ if( EQ_16(bwidth,SWB))
+ {
+ pos = sub(ni_end_band,1);
+ move16();
+ }
+
+ IF(LE_16(k,pos))
+ {
+ test();
+ IF(k > 0 && LT_16(sub(k,ni_end_band),-1))
+ {
+ tmp1 = mult(last_env_fx[k],16384);/*Q(1+15-15=1) Q1 */
+ tmp2 = sub(env_fx2[k],tmp1);/*>0 */
+ tmp1 = mult(env_fx2[k],16384);/*Q(1+15-15=1) Q1 */
+ tmp3 = sub(tmp1,last_env_fx[k]);/*<0 */
+ L_tmp = L_add((Word32)env_fx2[k],(Word32)env_fx2[sub(k,1)]);
+ L_tmp = L_add(L_tmp,(Word32)env_fx2[add(k,1)]);/*Q1 */
+ L_tmp1 = L_add((Word32)last_env_fx[k],(Word32)last_env_fx[sub(k,1)]);
+ L_tmp1 = L_add(L_tmp1,(Word32)last_env_fx[add(k,1)]);/*Q1 */
+ L_tmp2 = Mult_32_16(L_tmp1,16384);/*Q(1+15-15) Q1 */
+ L_tmp2 = L_sub(L_tmp,L_tmp2);/*>0 */
+ L_tmp3 = Mult_32_16(L_tmp,16384);/*Q(1+15-15) Q1 */
+ L_tmp3 = L_sub(L_tmp3,L_tmp1);/*<0 */
+ test();
+ test();
+ test();
+ IF( (tmp2 > 0 && tmp3 < 0) ||(L_tmp2 > 0 && L_tmp3 < 0))
+ {
+ IF( GT_32(ni_gain_fx[k],last_ni_gain_fx[k]))
+ {
+ L_tmp = Mult_32_16(ni_gain_fx[k],6554);/*Q(17+15-15 = 17) */
+ L_tmp1 = Mult_32_16(last_ni_gain_fx[k],26214);/*Q17 */
+ ni_gain_fx[k] = L_add(L_tmp,L_tmp1);
+ move32();
+ }
+ ELSE
+ {
+ L_tmp = Mult_32_16(ni_gain_fx[k],19661);/*Q(17+15-15 = 17) */
+ L_tmp1 = Mult_32_16(last_ni_gain_fx[k],13107);/*Q17 */
+ ni_gain_fx[k] = L_add(L_tmp,L_tmp1);
+ move32();
+ }
+ }
+ }
+ ELSE IF (add(sub(k,ni_end_band),1) == 0)
+ {
+ tmp1 = mult(last_env_fx[k],16384);/*Q(1+15-15=1) Q1 */
+ tmp2 = sub(env_fx2[k],tmp1);/*>0 */
+ tmp1 = mult(env_fx2[k],16384);/*Q(1+15-15=1) Q1 */
+ tmp3 = sub(tmp1,last_env_fx[k]);/*<0 */
+ L_tmp = L_add((Word32)env_fx2[k],(Word32)env_fx2[sub(k,1)]);/*Q1 */
+ L_tmp1 = L_add((Word32)last_env_fx[k],(Word32)last_env_fx[sub(k,1)]);/*Q1 */
+ L_tmp2 = Mult_32_16(L_tmp1,16384);/*Q(1+15-15) Q1 */
+ L_tmp2 = L_sub(L_tmp,L_tmp2);/*>0 */
+ L_tmp3 = Mult_32_16(L_tmp,16384);/*Q(1+15-15) Q1 */
+ L_tmp3 = L_sub(L_tmp3,L_tmp1);/*<0 */
+
+ test();
+ test();
+ test();
+ IF( (tmp2 > 0 && tmp3 < 0) ||(L_tmp2 > 0 && L_tmp3 < 0))
+ {
+ IF( GT_32(ni_gain_fx[k],last_ni_gain_fx[k]))
+ {
+ L_tmp = Mult_32_16(ni_gain_fx[k],6554);/*Q(17+15-15 = 17) */
+ L_tmp1 = Mult_32_16(last_ni_gain_fx[k],26214);/*Q17 */
+ ni_gain_fx[k] = L_add(L_tmp,L_tmp1);
+ move32();
+ }
+ ELSE
+ {
+ L_tmp = Mult_32_16(ni_gain_fx[k],19661);/*Q(17+15-15 = 17) */
+ L_tmp1 = Mult_32_16(last_ni_gain_fx[k],13107);/*Q17 */
+ ni_gain_fx[k] = L_add(L_tmp,L_tmp1);
+ move32();
+ }
+ }
+ }
+ }
+
+ /* inject noise into the non-decoded coeffs */
+ test();
+ test();
+ IF(add(sub(k,ni_end_band),p2a_bands) >=0 && p2a_flags[k] == 0 && NE_16(bwidth,SWB) )
+ {
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ IF (L_y2[i] != 0)
+ {
+ L_y2[i] = Mult_32_16(L_y2[i],26215);
+ move32();/*Q(12+15-15=12) */
+ }
+ }
+ }
+
+ test();
+ test();
+ test();
+ IF(EQ_16(k,max_pos_pulse)&&add(sub(k,bands),p2a_bands)<0&&NE_16(satur,1)&&NE_16(bwidth,SWB))
+ {
+ j = 0;
+ Q_speech = norm_l(ni_gain_fx[k]);
+ tmp = extract_h(L_shl(ni_gain_fx[k],Q_speech));/*Q(Q_speech+1) */
+ IF(tmp != 0)
+ {
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech-1 = 28-Q_speech) */
+ L_tmp = Mult_32_16(Ep_fx[k],tmp); /*Q(Q_Ep_fx[k]+28-Q_speech-15 = Q_Ep_fx[k]+13-Q_speech) */
+ tmp = sub(Q_Ep_fx[k],Q_speech);
+ tmp = sub(15,tmp);
+ tmp = extract_h(L_shl(L_tmp,tmp));/*Q12 */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;/*Q0 */
+ L_tmp = Mult_32_16(Ep_fx[k],tmp); /*Q(Q_Ep_fx[k]+0-15 = Q_Ep_fx[k]-15) */
+ tmp = sub(43,Q_Ep_fx[k]);
+ tmp = extract_h(L_shl(L_tmp,tmp));/*Q12 */
+ }
+ fac_fx = s_max(tmp,4096);/*Q12 */
+
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ IF (L_y2[i] == 0)
+ {
+ rand_fx = Random(&ni_seed); /*Q15 */
+ IF(band_width[k] != 0)
+ {
+ Q_speech = norm_s(band_width[k]);
+ tmp = shl(band_width[k],Q_speech);/*Q(Q_speech) */
+ tmp = div_s(16384,tmp);/*Q(15+14-Q_speech) */
+ }
+ ELSE
+ {
+ tmp = 0x7fff;
+ Q_speech = 0;
+ }
+ tmp1 = sub(fac_fx,4096);/*Q12 */
+ L_tmp = L_mult(tmp1,j);/*Q13 */
+ L_tmp = Mult_32_16(L_tmp,tmp);/*Q(13+29-Q_speech-15 = 27-Q_speech) */
+ tmp = extract_h(L_shl(L_tmp,add(1,Q_speech)));/*Q12 */
+ tmp = sub(fac_fx,tmp);/*Q12 */
+ L_tmp = Mult_32_16(ni_gain_fx[k],tmp);/*Q(17+12-15=14) */
+ L_y2[i] = L_add(L_y2[i],L_shr(Mult_32_16(L_tmp,rand_fx),2));
+ move32();/*Q12 */
+ }
+ j=add(j,1);
+ }
+ }
+ ELSE
+ {
+ FOR (i = band_start[k]; i <= band_end[k]; i++)
+ {
+ IF (L_y2[i] == 0)
+ {
+ rand_fx = Random(&ni_seed); /*Q15 */
+ L_tmp = Mult_32_16(ni_gain_fx[k],rand_fx);/*Q(17+15-15=17) */
+ L_y2[i] = L_add(L_y2[i],L_shr(L_tmp,5));
+ move32();/*Q12 */
+ }
+ }
+ }
+ }
+
+ Copy(env_fx2,last_env_fx,ni_end_band);
+ Copy32(ni_gain_fx,last_ni_gain_fx,ni_end_band);
+ *last_max_pos_pulse = max_pos_pulse;
+ move16();
+ return;
+}
diff --git a/lib_com/hq_bit_allocation_fx.c b/lib_com/hq_bit_allocation_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..7053a4922ac246c30f54b88d06cf8728b7d4f9f7
--- /dev/null
+++ b/lib_com/hq_bit_allocation_fx.c
@@ -0,0 +1,217 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "stl.h" /* required for wmc_tool */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst_fx.h" /* Common constants */
+
+/*--------------------------------------------------------------------------*
+ * hq_bit_allocation_fx()
+ *
+ * Assign bits for HQ fine structure coding with PVQ
+ *--------------------------------------------------------------------------*/
+
+void hq_bit_allocation_fx(
+ const Word32 core_brate, /* i : Core bit-rate Q0 */
+ const Word16 length, /* i : Frame length Q0 */
+ const Word16 hqswb_clas, /* i : HQ class Q0 */
+ Word16 *num_bits, /* i/o: Remaining bit budget Q0 */
+ const Word16 *normqlg2, /* i : Quantized norms Q0 */
+ const Word16 nb_sfm, /* i : Number sub bands to be encoded Q0 */
+ const Word16 *sfmsize, /* i : Sub band bandwidths Q0 */
+ Word16 *noise_level, /* o : HVQ noise level */
+ Word16 *R, /* o : Bit allocation per sub band Q0 */
+ Word16 *Rsubband, /* o : Fractional bit allocation Q3 */
+ Word16 *sum, /* o : Sum of allocated shape bits Q0 */
+ Word16 *core_sfm, /* o : Last coded band in core Q0 */
+ const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_GEN Q0 */
+)
+{
+ Word16 i;
+ Word16 idx[NB_SFM];
+ Word16 wnorm[NB_SFM];
+ Word16 avrg_wnorm;
+ Word16 tmp, tmp2;
+ Word16 E_low;
+ Word16 E_hb_mean;
+ Word16 E_max;
+ Word16 i_max;
+ /* Temp */
+
+ Word16 sfm_limit = nb_sfm;
+ move16();
+
+ set16_fx( R, 0, NB_SFM);
+ FOR( i = 0; i < nb_sfm; i++ )
+ {
+ idx[i] = i;
+ move16();
+ }
+ test();
+ test();
+ test();
+ if( NE_16(hqswb_clas, HQ_TRANSIENT)&&NE_16(hqswb_clas,HQ_HVQ)&&!(EQ_16(length,L_FRAME16k)&&EQ_32(core_brate,HQ_32k)))
+ {
+ /* 'nf_idx' 2-bits index written later */
+ *num_bits = sub(*num_bits, 2);
+ }
+
+ test();
+ IF ( EQ_16(hqswb_clas, HQ_GEN_SWB)||EQ_16(hqswb_clas,HQ_GEN_FB))
+ {
+ IF ( EQ_32(core_brate, HQ_32k))
+ {
+ *num_bits = sub(*num_bits, HQ_GENERIC_SWB_NBITS2 );
+ }
+ ELSE
+ {
+ *num_bits = sub(*num_bits, HQ_GENERIC_SWB_NBITS );
+ }
+
+ if ( EQ_16(hqswb_clas, HQ_GEN_FB))
+ {
+ *num_bits = sub(*num_bits, HQ_GENERIC_FB_NBITS );
+ }
+ }
+
+ IF( ( EQ_16(length, L_FRAME48k))&&(NE_16(hqswb_clas,HQ_HARMONIC))&&(NE_16(hqswb_clas,HQ_HVQ)))
+ {
+ tmp = 0;
+ move16();
+ if( EQ_16(hqswb_clas,HQ_TRANSIENT))
+ {
+ tmp = 1;
+ move16();
+ }
+ map_quant_weight_fx( normqlg2, wnorm, tmp );
+ }
+ ELSE
+ {
+ Copy( normqlg2, wnorm, nb_sfm );
+ }
+
+ IF( EQ_16(hqswb_clas, HQ_HARMONIC))
+ {
+ /* classification and limit bandwidth for bit allocation */
+ sfm_limit = sub(sfm_limit, 2);
+ limit_band_noise_level_calc_fx( wnorm, &sfm_limit, core_brate, noise_level );
+
+ /* Detect important band in high frequency region */
+ E_low = sum16_fx(wnorm, SFM_G1);
+ i_max = 0;
+ move16();
+ E_max = MIN16B;
+ move16();
+ E_hb_mean = 0;
+ move16();
+ FOR( i = SFM_G1; i < nb_sfm; i++)
+ {
+ E_hb_mean = add(E_hb_mean, wnorm[i]);
+ IF( GT_16(wnorm[i], E_max))
+ {
+ E_max = wnorm[i];
+ move16();
+ i_max = i;
+ move16();
+ }
+ }
+ E_hb_mean = shr(E_hb_mean, 4); /* Truncated division by SFM_G1 */
+ set16_fx( wnorm + sfm_limit, -20, sub(nb_sfm, sfm_limit) );
+ IF (L_msu0(L_deposit_l(E_low), E_max, 15) <= 0)
+ {
+ IF (L_msu(L_deposit_h(E_hb_mean), E_max, 21955) <= 0) /* 21955 = 0.67 (Q15) */
+ {
+ if (GE_16(i_max, sfm_limit))
+ {
+ wnorm[i_max] = E_max;
+ move16();
+ }
+ }
+ }
+ }
+ test();
+ test();
+ test();
+ test();
+ IF( EQ_16(hqswb_clas, HQ_HVQ))
+ {
+ *sum = 0;
+ move16();
+ }
+ ELSE IF ( EQ_16(hqswb_clas, HQ_GEN_SWB)||(EQ_16(hqswb_clas,HQ_TRANSIENT)&&EQ_16(length,L_FRAME32k)&&LE_32(core_brate,HQ_32k)))
+ {
+ *sum = BitAllocF_fx( wnorm, core_brate, *num_bits, nb_sfm, R, Rsubband, hqswb_clas, num_env_bands );
+ }
+ ELSE IF( EQ_16(length, L_FRAME16k)&&EQ_32(core_brate,HQ_32k))
+ {
+ IF( NE_16(hqswb_clas, HQ_TRANSIENT))
+ {
+ avrg_wnorm = wnorm[10];
+ move16();
+ FOR( i=11; i<18; i++ )
+ {
+ avrg_wnorm = add(avrg_wnorm, wnorm[i]);
+ }
+
+ avrg_wnorm = shr(avrg_wnorm, 3);
+ FOR( i=0; i<4; i++ )
+ {
+ if( LT_16(wnorm[i], avrg_wnorm))
+ {
+ wnorm[i] = avrg_wnorm;
+ move16();
+ }
+ }
+
+ /* Estimate number of bits per band */
+ *sum = BitAllocWB_fx( wnorm, *num_bits, nb_sfm, R, Rsubband );
+ }
+ ELSE
+ {
+ reordvct_fx(wnorm, nb_sfm, idx);
+ bitalloc_fx( wnorm, idx, *num_bits, nb_sfm, QBIT_MAX2, R, sfmsize, hqswb_clas );
+ bitallocsum_fx( R, nb_sfm, sum, Rsubband, *num_bits, length, sfmsize );
+ }
+ }
+ ELSE
+ {
+ reordvct_fx(wnorm, nb_sfm, idx);
+
+ /* enlarge the wnorm value so that more bits can be allocated to (sfm_limit/2 ~ sfm_limit) range */
+ IF( EQ_16(hqswb_clas, HQ_HARMONIC))
+ {
+ tmp = shr(sfm_limit,1);
+ tmp2 = sub(tmp,1);
+ FOR( i=tmp; i
+#include "options.h"
+#include "cnst_fx.h" /* Audio core constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+
+/*--------------------------------------------------------------------------*
+ * hq_configure()
+ *
+ * Configuration routine for HQ mode
+ *--------------------------------------------------------------------------*/
+
+void hq_configure_fx(
+ const Word16 length, /* i : Frame length Q0 */
+ const Word16 hqswb_clas, /* i : HQ SWB class Q0 */
+ const Word32 core_brate, /* i : Codec bitrate Q0 */
+ Word16 *num_sfm, /* o : Total number of subbands Q0 */
+ Word16 *nb_sfm, /* o : Total number of coded bands Q0 */
+ Word16 *start_norm, /* o : First norm to be SDE encoded Q0 */
+ Word16 *num_env_bands, /* o : Number coded envelope bands Q0 */
+ Word16 *numnrmibits, /* o : Number of bits in fall-back norm encoding Q0 */
+ Word16 *hq_generic_offset, /* o : Freq offset for HQ GENERIC Q0 */
+ Word16 const **sfmsize, /* o : Subband bandwidths Q0 */
+ Word16 const **sfm_start, /* o : Subband start coefficients Q0 */
+ Word16 const **sfm_end /* o : Subband end coefficients Q0 */
+)
+{
+ *start_norm = 0;
+ move16();
+
+ IF ( EQ_16(length, L_FRAME48k))
+ {
+ IF ( EQ_16(hqswb_clas, HQ_GEN_FB))
+ {
+ *num_sfm = NB_SFM;
+ move16();
+ *sfmsize = band_len_HQ;
+ move16();
+ *sfm_start = band_start_HQ;
+ move16();
+ *sfm_end = band_end_HQ;
+ move16();
+
+ test();
+ IF ( EQ_32(core_brate, HQ_32k))
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
+ move16();
+ }
+ ELSE IF ( EQ_32(core_brate, HQ_16k40)||EQ_32(core_brate,HQ_24k40))
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
+ move16();
+ }
+
+ /* setting start frequency of FD BWE */
+ test();
+ IF ( EQ_32(core_brate, HQ_32k))
+ {
+ *num_env_bands = SFM_N_STA_10k;
+ move16();
+ }
+ ELSE IF ( EQ_32(core_brate, HQ_16k40)||EQ_32(core_brate,HQ_24k40))
+ {
+ *num_env_bands = SFM_N_STA_8k;
+ move16();
+ }
+ *nb_sfm = *num_sfm;
+ move16();
+ }
+ ELSE
+ {
+ IF(EQ_16(hqswb_clas, HQ_HARMONIC))
+ {
+ *num_sfm = SFM_N_HARM_FB;
+ move16();
+ *nb_sfm = SFM_N_HARM_FB;
+ move16();
+ *num_env_bands = SFM_N_HARM_FB;
+ move16();
+
+ *sfmsize = band_len_harm;
+ move16();
+ *sfm_start = band_start_harm;
+ move16();
+ *sfm_end = band_end_harm;
+ move16();
+ }
+ ELSE IF ( EQ_16(hqswb_clas, HQ_HVQ))
+ {
+ IF ( EQ_32(core_brate, HQ_24k40))
+ {
+ *num_sfm = SFM_N_HARM_FB;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_24k;
+ move16();
+ *num_env_bands = sub(*num_sfm, *nb_sfm);
+
+ *sfmsize = band_len_harm;
+ move16();
+ *sfm_start = band_start_harm;
+ move16();
+ *sfm_end = band_end_harm;
+ move16();
+ *start_norm = HVQ_THRES_SFM_24k;
+ move16();
+ }
+ ELSE
+ {
+ *num_sfm = SFM_N_HARM_FB;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_32k;
+ move16();
+ *num_env_bands = sub(*num_sfm, *nb_sfm);
+
+ *sfmsize = band_len_harm;
+ move16();
+ *sfm_start = band_start_harm;
+ move16();
+ *start_norm = HVQ_THRES_SFM_32k;
+ move16();
+ *sfm_end = band_end_harm;
+ move16();
+ }
+ }
+ ELSE
+ {
+ *num_sfm = NB_SFM;
+ move16();
+ *nb_sfm = *num_sfm;
+ move16();
+ *num_env_bands = NB_SFM;
+ move16();
+
+ *sfmsize = band_len_HQ;
+ move16();
+ *sfm_start = band_start_HQ;
+ move16();
+ *sfm_end = band_end_HQ;
+ move16();
+ }
+ }
+ }
+ ELSE IF( EQ_16(length, L_FRAME32k))
+ {
+ IF ( EQ_16(hqswb_clas, HQ_HARMONIC))
+ {
+ *num_sfm = SFM_N_HARM;
+ move16();
+ *nb_sfm = SFM_N_HARM;
+ move16();
+ *num_env_bands = SFM_N_HARM;
+ move16();
+
+ *sfmsize = band_len_harm;
+ move16();
+ *sfm_start = band_start_harm;
+ move16();
+ *sfm_end = band_end_harm;
+ move16();
+ }
+ ELSE IF ( EQ_16(hqswb_clas, HQ_HVQ))
+ {
+ IF ( EQ_32(core_brate, HQ_24k40))
+ {
+ *num_sfm = SFM_N_HARM;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_24k;
+ move16();
+ *num_env_bands = sub(*num_sfm, *nb_sfm);
+
+ *sfmsize = band_len_harm;
+ move16();
+ *sfm_start = band_start_harm;
+ move16();
+ *sfm_end = band_end_harm;
+ move16();
+ *start_norm = HVQ_THRES_SFM_24k;
+ move16();
+ }
+ ELSE
+ {
+ *num_sfm = SFM_N_HARM;
+ move16();
+ *nb_sfm = HVQ_THRES_SFM_32k;
+ move16();
+ *num_env_bands = sub(*num_sfm, *nb_sfm);
+
+ *sfmsize = band_len_harm;
+ move16();
+ *sfm_start = band_start_harm;
+ move16();
+ *start_norm = HVQ_THRES_SFM_32k;
+ move16();
+ *sfm_end = band_end_harm;
+ move16();
+ }
+ }
+ ELSE IF ( EQ_16(hqswb_clas, HQ_GEN_SWB))
+ {
+ *num_sfm = SFM_N_SWB;
+ move16();
+ *sfmsize = band_len_HQ;
+ move16();
+ *sfm_start = band_start_HQ;
+ move16();
+ *sfm_end = band_end_HQ;
+ move16();
+
+ IF ( EQ_32(core_brate, HQ_32k))
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
+ move16();
+ }
+ ELSE if ( EQ_32(core_brate, HQ_24k40))
+ {
+ *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
+ move16();
+ }
+
+ /* setting start frequency of HQ Generic */
+ IF ( EQ_32(core_brate, HQ_32k))
+ {
+ *num_env_bands = SFM_N_STA_10k;
+ move16();
+ }
+ ELSE if( EQ_32(core_brate, HQ_24k40))
+ {
+ *num_env_bands = SFM_N_STA_8k;
+ move16();
+ }
+
+ *nb_sfm = *num_sfm;
+ move16();
+ }
+ ELSE
+ {
+ /* HQ_NORMAL and HQ_TRANSIENT */
+ *num_sfm = SFM_N_SWB;
+ move16();
+ *nb_sfm = *num_sfm;
+ move16();
+ *num_env_bands = SFM_N_SWB;
+ move16();
+
+ *sfmsize = band_len_HQ;
+ move16();
+ *sfm_start = band_start_HQ;
+ move16();
+ *sfm_end = band_end_HQ;
+ move16();
+ }
+ }
+ ELSE
+ {
+ *num_sfm = SFM_N_WB;
+ move16();
+ *nb_sfm = *num_sfm;
+ move16();
+ *num_env_bands = SFM_N_WB;
+ move16();
+
+ *sfmsize = band_len_wb;
+ move16();
+ *sfm_start = band_start_wb;
+ move16();
+ *sfm_end = band_end_wb;
+ move16();
+ }
+
+ *numnrmibits = extract_l(L_mult0(sub(*num_env_bands, 1), NORMI_BITS));
+
+ return;
+}
diff --git a/lib_com/hq_tools_fx.c b/lib_com/hq_tools_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f20cca9c493f4179132538f429da019311d751ba
--- /dev/null
+++ b/lib_com/hq_tools_fx.c
@@ -0,0 +1,2342 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "rom_com_fx.h" /* Static table prototypes FIP version */
+#include "stl.h" /* required for wmc_tool */
+#include "prot_fx.h"
+
+/*--------------------------------------------------------------------------*
+ * Local functions
+ *--------------------------------------------------------------------------*/
+
+static void overlap_hq_bwe_fx( const Word32 *hq_swb_overlap_buf, Word32 *coeff_out, const Word16 n_swb_overlap_offset,
+ const Word16 n_swb_overlap, const Word16 *R, const Word16 num_env_bands, const Word16 num_sfm, const Word16 *sfm_end);
+
+/*--------------------------------------------------------------------------*
+* hq_swb_harmonic_calc_norm_envelop()
+*
+* Calculate normalization envelop
+*--------------------------------------------------------------------------*/
+
+void hq_swb_harmonic_calc_norm_envelop_fx(
+ Word32 *L_SWB_signal, /* i : input signal Q=12*/
+ Word32 *L_envelope, /* o : output envelope Q=12*/
+ Word16 L_swb_norm, /* i : length of normaliztion */
+ Word16 SWB_flength /* i : length of input signal */
+)
+{
+
+ Word16 lookback;
+ Word16 env_index;
+ Word16 n_freq;
+ Word16 n_lag_now;
+ Word16 n_lag;
+ Word16 i;
+ Word32 L_tmp;
+
+ lookback = shr(L_swb_norm,1);
+ env_index = 0;
+ move16();
+ FOR (n_freq = 0; n_freq < lookback; n_freq++)
+ {
+ n_lag_now = add(lookback,n_freq);
+
+ /* Apply MA filter */
+ L_envelope[env_index] = EPSILLON_FX;
+ move16();
+
+ FOR (n_lag=0; n_lag 0)
+ {
+ CodeBook_mod[cb_size] = 1<<12;
+ move16(); /* set to 1, Q value 12 */
+ E_cb_vec = add(E_cb_vec,1);
+ }
+ ELSE IF (coeff[j] < 0)
+ {
+ CodeBook_mod[cb_size] = -1 * (1<<12);
+ move16(); /* set to -1, Q value 12 */
+ E_cb_vec = add(E_cb_vec,1);
+ }
+ ELSE
+ {
+ CodeBook_mod[cb_size] = 0;
+ move16();
+ }
+ cb_size = add(cb_size,1);
+ }
+
+ if (E_cb_vec < 2)
+ {
+ cb_size = sub(cb_size,8);
+ }
+ }
+ }
+ ELSE
+ {
+ FOR (j = sfm_start[sfm]; j < sfm_end[sfm]; j++)
+ {
+ CodeBook[cb_size] = coeff[j];
+ move16();
+ cb_size = add(cb_size,1);
+ }
+ }
+ }
+ }
+
+ IF (flag_32K_env_ho)
+ {
+ FOR (j = 0; j < cb_size; j++)
+ {
+ IF (CodeBook_mod[j] != 0)
+ {
+ /* Densify codebook */
+ CodeBook[j] = -4096;
+ move16(); /* -1 in Q12 */
+ if (CodeBook_mod[j] > 0)
+ {
+ CodeBook[j] = 4096;
+ move16(); /* 1 in Q12 */
+ }
+
+ IF (CodeBook_mod[cb_size-j-1] != 0)
+ {
+ CodeBook[j] = shl(CodeBook[j], 1);
+ move16(); /* Mult by 2 */
+ }
+ }
+ ELSE
+ {
+ CodeBook[j] = CodeBook_mod[cb_size-j-1];
+ move16();
+ }
+ }
+ }
+
+ return cb_size;
+}
+
+
+/*--------------------------------------------------------------------------*
+* find_last_band()
+*
+* Find the last band which has bits allocated
+*--------------------------------------------------------------------------*/
+
+Word16 find_last_band_fx( /* o : index of last band */
+ const Word16 *bitalloc, /* i : bit allocation */
+ const Word16 nb_sfm /* i : number of possibly coded bands */
+)
+{
+ Word16 sfm, core_sfm;
+
+ core_sfm = sub(nb_sfm,1);
+
+ FOR (sfm = nb_sfm-1; sfm >= 0; sfm--)
+ {
+ IF ( bitalloc[sfm] != 0 )
+ {
+ core_sfm = sfm;
+ move16();
+ BREAK;
+ }
+ }
+
+ return core_sfm;
+}
+
+/*--------------------------------------------------------------------------*
+ * apply_noisefill_HQ()
+ *
+ * Inject noise in non-coded bands
+ *--------------------------------------------------------------------------*/
+
+void apply_noisefill_HQ_fx(
+ const Word16 *R, /* i : bit allocation Q0 */
+ const Word16 length, /* i : input frame length Q0 */
+ const Word16 flag_32K_env_ho,/* i : envelope stability hangover flag Q0 */
+ const Word32 L_core_brate, /* i : core bit rate Q0 */
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 *CodeBook, /* i : Noise-fill codebook Q12 */
+ const Word16 *CodeBook_mod, /* i : Densified noise-fill codebook Q12 */
+ const Word16 cb_size, /* i : Codebook length Q0 */
+ const Word16 *sfm_start, /* i : Subband start coefficient Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ const Word16 *sfmsize, /* i : Subband band width Q0 */
+ Word16 *coeff /* i/o: coded/noisefilled spectrum Q12 */
+)
+{
+ Word16 sfm;
+ Word16 cb_pos;
+ Word16 E_corr;
+ Word16 cb_buff[PVQ_MAX_BAND_SIZE];
+ Word16 i, j;
+ Word16 istart;
+ UWord16 lsb;
+ Word32 L_E_cb_vec;
+ Word32 L_E_corr;
+
+ test();
+ test();
+ IF ( (GE_16(length, L_FRAME32k))||(GT_32(L_core_brate,HQ_32k))||(LT_32(L_core_brate,HQ_24k40)))
+ {
+ /* Read from codebook */
+ cb_pos = 0;
+ move16();
+
+ FOR (sfm = 0; sfm <= last_sfm; sfm++)
+ {
+ IF (R[sfm] == 0)
+ {
+ IF (EQ_16(flag_32K_env_ho, 1))
+ {
+ L_E_cb_vec = L_deposit_l(0);
+ IF (LT_16(sfm, 20))
+ {
+ FOR (i = 0; i < sfmsize[sfm]; i++)
+ {
+ cb_buff[i] = CodeBook_mod[cb_pos++];
+ move16();
+ L_E_cb_vec = L_mac0(L_E_cb_vec, cb_buff[i], cb_buff[i]); /*Q24 (12+12) */
+
+ if (GE_16(cb_pos, cb_size))
+ {
+ cb_pos = 0;
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ FOR (i = 0; i < sfmsize[sfm]; i++)
+ {
+ cb_buff[i] = CodeBook[cb_pos++];
+ move16();
+ L_E_cb_vec = L_mac0(L_E_cb_vec, cb_buff[i], cb_buff[i]); /*Q24 (12+12) */
+
+ if (GE_16(cb_pos, cb_size))
+ {
+ cb_pos = 0;
+ move16();
+ }
+ }
+ }
+
+ /*E_corr = E_cb_vec / ((float) sfmsize[sfm]); */
+ Mpy_32_16_ss(L_E_cb_vec, inv_tbl_fx[sfmsize[sfm]], &L_E_corr, &lsb); /*Q24 (24+15+1-16) */
+ move16();
+
+ /*E_corr = 1.0f / (float)sqrt(E_corr); */
+ L_E_corr = Isqrt(L_E_corr); /*Q19 (31-24/2) */
+ E_corr = extract_h(L_shl(L_E_corr, 10)); /*Q13 (13-(19-16)) */
+
+ istart = sfm_start[sfm];
+ move16();
+ FOR(j = istart; j < sfm_end[sfm]; j++)
+ {
+ /*coeff[j] = cb_buff[j - istart] * E_corr; */
+ coeff[j] = extract_h(L_shl(L_mult(cb_buff[j - istart], E_corr), 2)); /*Q12 (12+13+1+2-16) */
+ }
+ }
+ ELSE
+ {
+ FOR (j = sfm_start[sfm]; j < sfm_end[sfm]; j++)
+ {
+ coeff[j] = CodeBook[cb_pos++];
+ move16();
+ if (GE_16(cb_pos, cb_size))
+ {
+ cb_pos = 0;
+ move16();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * harm_bwe_fine_fx()
+ *
+ * Prepare harmonic BWE fine structure
+ *--------------------------------------------------------------------------*/
+
+void harm_bwe_fine_fx(
+ const Word16 *R, /* i : bit allocation */
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 high_sfm, /* i : higher transition band to BWE */
+ const Word16 num_sfm, /* i : total number of bands */
+ const Word16 *norm, /* i : quantization indices for norms */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length */
+ Word16 *coeff, /* i/o: coded/noisefilled normalized spectrum */
+ Word32 *coeff_out /* o : coded/noisefilled spectrum */
+ , Word16 *coeff_fine /* o : BWE fine structure */
+)
+{
+ Word16 sfm;
+ Word16 i;
+ Word32 normq;
+ Word16 SWB_signal[L_HARMONIC_EXC];
+ Word32 envelope[L_HARMONIC_EXC], L_signal[L_HARMONIC_EXC];
+ Word16 enve_lo[L_HARMONIC_EXC], enve_hi[L_HARMONIC_EXC];
+ Word16 *src, *dst, *end;
+ Word16 norm_signal;
+
+ Word16 norm_width = 64;
+ move16();
+
+ /* shape the spectrum */
+ FOR (sfm = 0; sfm <= last_sfm; sfm++)
+ {
+ IF( R[sfm] != 0 )
+ {
+ normq = dicn_fx[norm[sfm]];
+ move32();
+
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ coeff_out[i] = L_shl(Mult_32_16(normq, coeff[i]),1); /*12 14+12+1+1-16 */
+ move32();
+ }
+ }
+ ELSE
+ {
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ coeff_out[i] = L_deposit_l(0);
+ }
+ }
+ }
+
+ /* excitation replication */
+ Copy32(coeff_out, L_signal, L_HARMONIC_EXC);
+ calc_normal_length_fx_32( HQ_CORE, coeff_out, HQ_HARMONIC, -1, &norm_width, prev_L_swb_norm );
+ hq_swb_harmonic_calc_norm_envelop_fx( L_signal, envelope, norm_width, L_HARMONIC_EXC );
+
+ /* Normalize with envelope */
+ FOR (i = 0; i < L_HARMONIC_EXC; i++)
+ {
+ IF (L_signal[i] > 0)
+ {
+ norm_signal = norm_l(envelope[i]);
+ enve_lo[i] = L_Extract_lc(L_shl(envelope[i], norm_signal), &enve_hi[i]);
+ L_signal[i] = Div_32(L_signal[i], enve_hi[i], enve_lo[i]);
+ SWB_signal[i] = round_fx(L_shl(L_signal[i], norm_signal));
+ move16();
+ move16();
+ move32();
+
+ }
+ ELSE
+ {
+ norm_signal = norm_l(envelope[i]);
+ enve_lo[i] = L_Extract_lc(L_shl(envelope[i], norm_signal), &enve_hi[i]);
+ L_signal[i] = L_negate(Div_32(L_negate(L_signal[i]), enve_hi[i], enve_lo[i]));
+ SWB_signal[i] = round_fx(L_shl(L_signal[i], norm_signal));
+ move16();
+ move16();
+ move32();
+
+ }
+ }
+
+ dst = coeff_fine + sfm_end[last_sfm];
+ end = coeff_fine + sfm_end[num_sfm-1];
+
+ IF (LE_16(sub(sfm_end[last_sfm], sfm_end[high_sfm]),(L_HARMONIC_EXC - START_EXC) ))
+ {
+ src = SWB_signal + START_EXC + sub(sfm_end[last_sfm], sfm_end[high_sfm]);
+ }
+ ELSE
+ {
+ src = SWB_signal + L_HARMONIC_EXC - 1;
+ }
+
+ WHILE (dst < end)
+ {
+ logic32();
+ WHILE (dst < end && src < &SWB_signal[L_HARMONIC_EXC])
+ {
+ *dst++ = *src++;
+ move16();
+ }
+ src --;
+
+ logic32();
+ WHILE (dst < end && src >= &SWB_signal[START_EXC])
+ {
+ *dst++ = *src--;
+ move16();
+ }
+ src++;
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * hvq_bwe_fine()
+ *
+ * Prepare HVQ BWE fine structure
+ *--------------------------------------------------------------------------*/
+
+void hvq_bwe_fine_fx(
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 num_sfm, /* i : total number of bands Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ const Word16 *peak_idx, /* i : Peak index Q0 */
+ const Word16 Npeaks, /* i : Number of peaks Q0 */
+ Word16 *peak_pos, /* o : Peak positions Q0 */
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length Q0 */
+ Word32 *L_coeff, /* i : coded/noisefilled normalized spectrum Q12 */
+ Word16 *bwe_peaks, /* o : Positions of peaks in BWE Q0 */
+ Word16 *coeff_fine /* o : HVQ BWE fine structure Q15 */
+)
+{
+ Word16 i, j;
+ Word16 SWB_signal[L_HARMONIC_EXC];
+ Word32 L_envelope[L_HARMONIC_EXC];
+ Word16 *src, *dst, *end;
+ Word16 *peak_dst, *peak_src;
+ Word16 norm_width = 64;
+ Word16 tmp;
+ Word16 shift, shift2;
+ Word32 L_tmp;
+ UWord16 lsb;
+
+ calc_normal_length_fx_32( HQ_CORE, L_coeff, HQ_HVQ, -1, &norm_width, prev_L_swb_norm );
+
+ hq_swb_harmonic_calc_norm_envelop_fx(L_coeff, L_envelope, norm_width, L_HARMONIC_EXC);
+
+ /* Normalize with envelope */
+ FOR (i = 0; i < L_HARMONIC_EXC; i++)
+ {
+ /*SWB_signal[i] = SWB_signal[i] / envelope[i]; */
+
+ shift = norm_l(L_envelope[i]);
+ tmp = round_fx(L_shl(L_envelope[i], shift)); /* 12+s-16=Q(-4+s) */
+
+ /* Avoid division by zero */
+ if (tmp == 0)
+ {
+ tmp = 1<<14;
+ move16();
+ }
+
+ tmp = div_s(1<<14, tmp); /* 15+14-(-4+s)=Q(33-s) */
+ Mpy_32_16_ss(L_coeff[i], tmp, &L_tmp, &lsb); /* 12+33-s+1-16=Q(30-s) */
+ shift2 = add(shift, 1);
+ tmp = round_fx(L_shl(L_tmp, shift2)); /* 30-s+s+1-16=Q(15) */
+ SWB_signal[i] = add(tmp, lshr(lsb, sub(32, shift2)));
+ move16(); /* Q15 */
+ /*SWB_signal[i] = round_fx(L_shl(L_tmp, add(shift, 1))); // 30-s+s+1-16=Q(15) */
+
+ }
+
+ dst = coeff_fine;
+ end = coeff_fine + sfm_end[num_sfm-1] - sfm_end[last_sfm];
+
+ src = SWB_signal + START_EXC;
+ peak_src = peak_pos + START_EXC;
+
+ FOR (i = 0; i < Npeaks; i++)
+ {
+ if ( LT_16(peak_idx[i], L_HARMONIC_EXC))
+ {
+ peak_pos[peak_idx[i]] = 1;
+ move16();
+ }
+ }
+
+ i = sub(L_HARMONIC_EXC, 1);
+ WHILE ( i-- > 0 )
+ {
+ IF ( EQ_16(peak_pos[i], 1))
+ {
+ BREAK;
+ }
+ }
+
+ if ( LT_16(i, 180))
+ {
+ i = 180;
+ move16();
+ }
+
+ FOR ( j = L_HARMONIC_EXC-1; j > i+1; j-- )
+ {
+ SWB_signal[j] = 0;
+ move16();
+ }
+
+ peak_dst = bwe_peaks + sfm_end[last_sfm];
+ WHILE ( dst < end )
+ {
+ test();
+ WHILE ( dst < end && src < &SWB_signal[L_HARMONIC_EXC] )
+ {
+ *dst++ = *src++;
+ move16();
+ *peak_dst++ = *peak_src++;
+ move16();
+ }
+ peak_src--;
+ src --;
+
+ test();
+ WHILE ( dst < end && src >= &SWB_signal[START_EXC] )
+ {
+ *dst++ = *src--;
+ move16();
+ *peak_dst++ = *peak_src--;
+ move16();
+ }
+ peak_src++;
+ src++;
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * hq_fold_bwe_fx()
+ *
+ * HQ mode folding BWE
+ *--------------------------------------------------------------------------*/
+
+void hq_fold_bwe_fx(
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ const Word16 num_sfm, /* i : Number of subbands Q0 */
+ Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */
+)
+{
+ Word16 low_coeff;
+ Word16 first_coeff;
+ Word16 *src, *dst, *end;
+
+ low_coeff = shr(sfm_end[last_sfm], 1);
+ src = coeff + sfm_end[last_sfm] - 1;
+
+ first_coeff = sfm_end[last_sfm];
+ dst = coeff + sfm_end[last_sfm];
+ end = coeff + sfm_end[num_sfm-1];
+
+ WHILE(dst < end)
+ {
+ WHILE(dst < end && src >= &coeff[low_coeff])
+ {
+ *dst++ = *src--;
+ move16();
+ }
+
+ src++;
+
+ WHILE(dst < end && src < &coeff[first_coeff])
+ {
+ *dst++ = *src++;
+ move16();
+ }
+ }
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * apply_nf_gain()
+ *
+ * Apply noise fill gain
+ *--------------------------------------------------------------------------*/
+
+void apply_nf_gain_fx(
+ const Word16 nf_idx, /* i : noise fill gain index Q0 */
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 *R, /* i : bit allocation Q0 */
+ const Word16 *sfm_start, /* i : Subband start coefficient Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */
+)
+{
+ Word16 sfm;
+ Word16 j;
+
+ FOR (sfm = 0; sfm <= last_sfm; sfm++)
+ {
+ IF (R[sfm] == 0)
+ {
+ FOR (j = sfm_start[sfm]; j < sfm_end[sfm]; j++)
+ {
+ /* Scale NoiseFill */
+ coeff[j] = shr(coeff[j], nf_idx);
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * harm_bwe_fx()
+ *
+ * HQ Harmonic BWE
+ *--------------------------------------------------------------------------*/
+
+void harm_bwe_fx(
+ const Word16 *coeff_fine, /* i : fine structure for BWE */
+ const Word16 *coeff, /* i : coded/noisefilled normalized spectrum */
+ const Word16 num_sfm, /* i : Number of subbands */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 *R, /* i : bit allocation */
+ const Word16 prev_hq_mode, /* i : previous hq mode */
+ Word16 *norm, /* i/o: quantization indices for norms */
+ Word16 *noise_level, /* i/o: noise levels for harmonic modes */
+ Word16 *prev_noise_level, /* i/o: noise factor in previous frame */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input */
+ Word32 *coeff_out /* o : coded/noisefilled spectrum */
+)
+{
+ Word16 i, j;
+ Word16 sfm, band_width;
+ Word32 normq, L_tmp,L_tmp2;
+ Word32 E_L;
+ Word16 alfa = 16384;
+ Word16 tmp, tmp1, exp1;
+ Word16 beta;
+ Word32 *src, *dst;
+
+ move16(); /* alfa */
+
+ FOR (sfm = 0; sfm <= last_sfm; sfm++)
+ {
+ IF (R[sfm] == 0)
+ {
+ normq = dicn_fx[norm[sfm]]; /*Q14 */ move16();
+
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ coeff_out[i] = L_shl(Mult_32_16(normq, coeff[i]),1);
+ move32(); /*12 Q(14 +12+1-16 +1) */
+
+ }
+ }
+ }
+ noise_level[1] = noise_level[0];
+ move16();
+
+ /* shaping the BWE spectrum further by envelopes and noise factors */
+ L_tmp = L_mult(29491, prev_noise_level[0]); /* 15 +1 +15 */
+ noise_level[0] = round_fx(L_mac(L_tmp, 3277, noise_level[0])); /*15 */
+
+ L_tmp = L_mult(29491, prev_noise_level[1]);
+ noise_level[1] = round_fx(L_mac(L_tmp, 3277, noise_level[1]));
+
+ test();
+ IF (prev_hq_mode == HQ_NORMAL || EQ_16(prev_hq_mode, HQ_GEN_SWB))
+ {
+ IF (LT_16(noise_level[0], 8192))
+ {
+ noise_level[0] = shl(noise_level[0], 2);
+ move16();
+ }
+
+ IF (LT_16(noise_level[1], 8192))
+ {
+ noise_level[1] = shl(noise_level[1], 2);
+ move16();
+ }
+ }
+
+ FOR (i = add(last_sfm, 1); i < num_sfm; i++)
+ {
+ E_L = 1;
+ move32();
+ FOR (j = sfm_start[i]; j < sfm_end[i]; j++)
+ {
+ L_tmp =L_mult0(coeff_fine[j], coeff_fine[j]);/*Q30 */
+ E_L =L_add(E_L,L_shr(L_tmp,6));/*Q24 */
+ }
+
+ normq = dicn_fx[norm[i]];
+ move32();
+
+ alfa = noise_level[0];
+ move16();
+ if (GT_16(i, 27))
+ {
+ alfa = noise_level[1];
+ move16();
+ }
+
+ band_width = sub(sfm_end[i], sfm_start[i]); /* */
+ exp1 =norm_l(E_L);
+ IF(exp1 ==0)
+ {
+ E_L = Mult_32_16(E_L, inv_tbl_fx[band_width]); /* Q24 (24+15+1-16) *//*24+15+1-16 */
+ tmp = div_l(E_L,sub(32767,alfa)); /*Q24-15-1 =8 */
+ tmp = s_max(1,tmp);
+ L_tmp =L_deposit_h(tmp); /*24 */
+ E_L = Isqrt(L_tmp); /* Q19 (31-24/2) */
+ }
+ ELSE
+ {
+ exp1 =sub(exp1,1);
+ E_L = Mult_32_16(L_shl(E_L,exp1), inv_tbl_fx[band_width]); /* Q24+exp1 (24+exp1+15+1-16) */
+ tmp = div_l(E_L,sub(32767,alfa)); /*Q24+exp1-15-1 =8+exp1 */
+ tmp = s_max(1,tmp);
+ L_tmp =L_shl(L_deposit_l(tmp),sub(16,exp1)); /*24 8+exp1+16-exp1 */
+ E_L = Isqrt(L_tmp); /* Q19 (31-24/2) */
+ }
+
+ exp1 = norm_s(alfa);
+ tmp1 = shl(alfa, exp1);
+ exp1 = add(1, exp1);
+ tmp1 = s_max(tmp1, 16384);
+ tmp1 = div_s(16384, tmp1);
+ L_tmp2 = L_deposit_h(tmp1);
+ L_tmp2 = Isqrt_lc(L_tmp2, &exp1);
+ beta = round_fx(L_shl(L_tmp2, exp1));
+ beta =shr(beta,1); /*Q15 */
+
+
+ FOR(sfm = sfm_start[i]; sfm < sfm_end[i]; sfm++)
+ {
+ L_tmp = Mult_32_16(E_L,coeff_fine[sfm]); /*Q19 19 + 15 +1-16 */
+ L_tmp = L_shl(L_tmp,9);/*Q28 */
+ tmp = Random(bwe_seed); /*Q15 */
+ L_tmp2 =L_shr(L_mult(beta,tmp),3);/* Q28 31-3 15+15 +1-3 */
+ L_tmp =L_add(L_tmp,L_tmp2);/*Q28 */
+ coeff_out[sfm] = L_shl(Mult_32_32(L_tmp, normq),1);/*Q12 28 +14 +1 -31 */ move32();
+ }
+ }
+
+ prev_noise_level[0] = noise_level[0];
+ move16();
+ prev_noise_level[1] = noise_level[1];
+ move16();
+
+ src = &coeff_out[add(sfm_end[last_sfm], L_HARMONIC_EXC - START_EXC)]; /*Q12 */
+
+ dst = src-1;
+ FOR( i = 0; i < 16; i++ )
+ {
+ *src = Mult_32_16(*src, hvq_bwe_fac_fx[i]); /* Q12 (12+15+1-16) */ move32();
+ src++;
+ *dst = Mult_32_16(*dst, hvq_bwe_fac_fx[i]); /* Q12 (12+15+1-16) */ move32();
+ dst--;
+ }
+ IF(EQ_16(num_sfm, 33))
+ {
+ set32_fx(&coeff_out[800], 0, 160);
+ }
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * HVQ_bwe_fx()
+ *
+ * HQ HVQ BWE
+ *--------------------------------------------------------------------------*/
+
+void hvq_bwe_fx(
+ const Word32 *L_coeff, /* i : coded/noisefilled normalized spectrum Q12 */
+ const Word16 *coeff_fine, /* i : coded/noisefilled normalized spectrum Qin */
+ const Word16 *sfm_start, /* i : Subband start coefficient Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ const Word16 *sfm_len, /* i : Subband length Q0 */
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 prev_hq_mode, /* i : previous hq mode Q0 */
+ const Word16 *bwe_peaks, /* i : HVQ bwe peaks Q0 */
+ const Word16 bin_th, /* i : HVQ transition bin Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word32 core_brate, /* i : Core bit-rate Q0 */
+ const Word16 *R, /* i : Bit allocation */
+ Word16 *norm, /* i/o: quantization indices for norms Q0 */
+ Word16 *noise_level, /* i/o: noise levels for harmonic modes Q15 */
+ Word16 *prev_noise_level, /* i/o: noise factor in previous frame Q15 */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input Q0 */
+ Word32 *L_coeff_out, /* o : coded/noisefilled spectrum Qout*/
+ const Word16 qin,
+ const Word16 qout
+)
+{
+ Word16 i, j;
+ Word16 N;
+ Word32 L_normq;
+ Word32 L_E;
+ Word32 L_tmp_norm = 0;
+ Word16 bwe_noise_th = 0;
+ Word16 peak_band, low, high, sel_norm;
+ Word16 norm_ind;
+ Word32 *L_src, *L_dst;
+ Word16 istart, iend;
+ Word16 offset = sfm_end[last_sfm];
+
+ /* Fx specific variables */
+ Word32 L_tmp0, L_tmp1;
+ Word16 tmp, tmp2, band_size;
+ Word16 last_norm_ind;
+ Word16 shift, power_shift;
+ Word16 coeff_s[L_FRAME48k];
+ Word16 j_N;
+ Word16 n_c;
+ UWord16 lsb;
+
+ move32(); /* L_tmp_norm */
+ move16(); /* bwe_noise_th */
+
+ bwe_noise_th = add(bin_th, shr(sub(sfm_end[sub(num_sfm,1)], bin_th),1));
+ logqnorm_fx(&L_coeff_out[sfm_start[last_sfm]], qout, &norm[last_sfm], 40, sfm_len[last_sfm], 0);
+ move16();
+
+ /* shaping the BWE spectrum further by envelopes and noise factors */
+ noise_level[0] = round_fx(L_mac(L_mult(29491,prev_noise_level[0]),3277,noise_level[0])); /* Q15 (15+15+1-16) */
+ noise_level[1] = round_fx(L_mac(L_mult(29491,prev_noise_level[1]),3277,noise_level[1])); /* Q15 (15+15+1-16) */
+
+ test();
+ IF (prev_hq_mode == HQ_NORMAL || EQ_16(prev_hq_mode, HQ_GEN_SWB))
+ {
+ IF( LT_16(noise_level[0], 8192 /* 0.25f */))
+ {
+ noise_level[0] = shl(noise_level[0], 2);
+ move16();
+ }
+
+ IF( LT_16(noise_level[1], 8192 /* 0.25f */))
+ {
+ noise_level[1] = shl(noise_level[1], 2);
+ move16();
+ }
+ }
+
+ norm_ind = add(last_sfm, 1);
+ IF ( EQ_32(core_brate, HQ_24k40))
+ {
+ peak_band = 0;
+ move16();
+
+ tmp = 1;
+ move16();
+ FOR (i = sfm_start[norm_ind]; i < sfm_end[norm_ind+1]; i++)
+ {
+ tmp2 = abs_s(coeff_fine[i-offset]);
+ tmp = s_max(tmp, tmp2);
+ }
+ band_size = sub(sfm_end[norm_ind+1], sfm_start[norm_ind]);
+
+ /* Headroom for square and accumulate */
+ shift = sub(norm_s(tmp), sqac_headroom_fx[band_size]);
+ L_E = L_deposit_l(1);
+ FOR (i = sfm_start[norm_ind]; i < sfm_end[norm_ind+1]; i++)
+ {
+ if (bwe_peaks[i])
+ {
+ peak_band = 1;
+ move16();
+ }
+ /* E_L += coeff_fine[i-offset] * coeff_fine[i-offset]; */
+ coeff_s[i] = shl(coeff_fine[i-offset], shift);
+ move16();/* Q15 + shift */
+ L_E = L_mac0(L_E, coeff_s[i], coeff_s[i]); /* Q2*(qin + shift) */
+ }
+ power_shift = shl(shift, 1);
+
+ L_E = L_shr(L_E,sub(power_shift,28-2*qin)); /* Q28 */
+
+ /* E_L = (float)sqrt((sfm_end[norm_ind+1] - sfm_start[norm_ind])/E_L); */
+ L_E = Mult_32_16(L_E, inv_tbl_fx[band_size]); /* Q28 (28+15+1-16) */
+ /* To avoid overflow in Isqrt() */
+ if( L_E == 0 )
+ {
+ L_E = L_deposit_l(1);
+ }
+ L_E = Isqrt(L_E); /* Q17 (31-28/2) */
+
+ /* normq = 0.1f*dicn[norm[norm_ind-1]] + 0.8f*dicn[norm[norm_ind]] + 0.1f*dicn[norm[norm_ind+1]]; */
+ /* tmp_norm = 0.1f*dicn[norm[norm_ind]] + 0.8f*dicn[norm[norm_ind+1]] + 0.1f*dicn[norm[norm_ind+2]]; */
+ L_tmp0 = L_add(dicn_fx[norm[norm_ind]], 0);
+ L_tmp1 = L_add(dicn_fx[norm[norm_ind+1]], 0);
+ L_normq = Madd_32_16(Madd_32_16(Mult_32_16(L_tmp0, 26214 /* Q15, 0.8f */), dicn_fx[norm[norm_ind-1]], 3277 /* Q15, 0.1f */), L_tmp1, 3277 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16();
+ L_tmp_norm = Madd_32_16(Madd_32_16(Mult_32_16(L_tmp1, 26214 /* Q15, 0.8f */), dicn_fx[norm[norm_ind+2]], 3277 /* Q15, 0.1f */), L_tmp0, 3277 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16();
+
+ istart = sfm_start[norm_ind];
+ move16();
+ /* iend = istart + sfm_len[norm_ind]/2; */
+ iend = 240;
+ move16();
+
+ noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, istart, iend, noise_level[0], L_coeff_out, qin, qout);
+
+ j = 0;
+ move16();
+ /* N = sfm_len[norm_ind]/2+sfm_len[norm_ind+1]/2-1; */
+ N = 31;
+ move16();
+ j_N = N;
+ move16();
+
+ istart = iend;
+ move16();
+ /* iend = sfm_start[norm_ind+1] + sfm_len[norm_ind+1]/2; */
+ iend = 272;
+ move16();
+
+ /* special case that is not handled by noise_mix_fx() */
+ n_c = sub(MAX_16,noise_level[0]); /* Q15 */
+ FOR (i = istart; i < iend; i++)
+ {
+ /* coeff_out[i] = ((float)(N-j)/N*normq + (float)j/N*tmp_norm)*((1.0f - noise_level[i/bwe_noise_th])*coeff_fine[i-offset]*E_L + noise_level[i/bwe_noise_th]*own_random(bwe_seed)/32768.0f); */
+ L_tmp1 = Madd_32_16(Mult_32_16(L_normq, inv_N_fx[j_N] ), L_tmp_norm, inv_N_fx[j]); /* Q14 (14+15+1-16) */
+ j = add(j,1);
+ j_N = sub(j_N,1);
+
+ Mpy_32_16_ss(L_E, coeff_fine[i-offset], &L_tmp0, &lsb); /* Qin+2 (17+qin+1-16) */
+ Mpy_32_16_ss(L_tmp0, n_c, &L_tmp0, &lsb); /* Qin+2-15 (qin+2+15+1-16) */
+
+ IF(L_tmp0 != 0)
+ {
+ /* Normalize with 1 bit headroom for addition */
+ tmp = 30-(qin+2); /* Assuming fixed Q values */
+ tmp = s_min(norm_l(L_tmp0), tmp);
+ tmp = sub(tmp,1);
+
+ L_tmp0 = L_add(L_shl(L_tmp0,tmp), L_deposit_l(lshr(lsb, sub(16,tmp)))); /* Qin+2+tmp */
+
+ L_tmp0 = L_add(L_tmp0, L_shr(L_mult0(noise_level[0], Random(bwe_seed)), sub(30-(qin+2), tmp))); /* Qin+2+tmp */
+ tmp = round_fx(L_shl(L_tmp0,27-(qin+2)-tmp)); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */
+
+ Mpy_32_16_ss(L_tmp1, tmp, &L_tmp0, &lsb); /* Q10 (14+11+1-16) */
+ L_coeff_out[i] = L_add(L_shl(L_tmp0,qout-10), L_deposit_l(lshr(lsb, 10+16-qout)));
+ move32(); /* Qout (10+qout-10) */
+ }
+ ELSE
+ {
+ L_tmp0 = L_mult0(noise_level[0], Random(bwe_seed)); /* Q30 (15+15) */
+ tmp = round_fx(L_tmp0); /* Q14 (30-16) */
+ Mpy_32_16_ss(L_tmp1, tmp, &L_tmp0, &lsb); /* Q13 (14+14+1-16) */
+ L_coeff_out[i] = L_shr(L_tmp0,13-qout);
+ move32();/* Qout (13-(13-qout)) */
+ }
+ }
+
+ istart = iend;
+ move16();
+ iend = sfm_end[norm_ind+1];
+ move16();
+
+ noise_mix_fx( &coeff_fine[-offset], L_E, L_tmp_norm, bwe_seed, istart, iend, noise_level[0], L_coeff_out, qin, qout);
+
+ norm_ind = add(norm_ind, 2);
+ }
+
+ FOR ( ; norm_ind < num_sfm; norm_ind++)
+ {
+ IF ( R[norm_ind] == 0 )
+ {
+ peak_band = 0;
+ move16();
+
+ FOR (i = sfm_start[norm_ind]; i < sfm_end[norm_ind]; i++)
+ {
+ if (bwe_peaks[i])
+ {
+ peak_band = 1;
+ move16();
+ }
+ }
+
+ istart = sfm_start[norm_ind];
+ move16();
+ iend = sfm_end[norm_ind];
+ move16();
+
+ last_norm_ind = sub(num_sfm, 1);
+ test();
+ test();
+ IF ( EQ_16(peak_band, 1)&>_16(norm_ind,add(last_sfm,1))&<_16(norm_ind,last_norm_ind))
+ {
+ istart = sub(istart, shr(sfm_len[norm_ind-1],1));
+ iend = add(iend, shr(sfm_len[norm_ind+1],1));
+ }
+
+ tmp = 1;
+ move16();
+ FOR (i = istart; i < iend; i++)
+ {
+ tmp2 = abs_s(coeff_fine[i-offset]);
+ tmp = s_max(tmp, tmp2);
+ }
+ band_size = sub(iend, istart);
+ /* Headroom for square and accumulate */
+ shift = sub(norm_s(tmp), sqac_headroom_fx[band_size]);
+
+ L_E = 1L;
+ move32();
+ FOR (i = istart; i < iend; i++)
+ {
+ /* E_L += coeff_fine[i-offset] * coeff_fine[i-offset]; */
+ coeff_s[i] = shl(coeff_fine[i-offset], shift);
+ move16();/* Q15 + shift */
+ L_E = L_mac0(L_E, coeff_s[i], coeff_s[i]); /* Q2*(15 + shift) */
+ }
+ power_shift = shl(shift, 1);
+
+ L_E = L_shr(L_E,sub(power_shift,28-2*qin)); /* Q28 */
+
+ /* E_L = (float)sqrt((iend - istart)/E_L); */
+ L_E = Mult_32_16(L_E, inv_tbl_fx[band_size]); /* Q28 (28+15+1-16) */
+ /* To avoid overflow in Isqrt() */
+ if( L_E == 0 )
+ {
+ L_E = 1L;
+ move32();
+ }
+ L_E = Isqrt(L_E); /* Q17 (31-28/2) */
+
+ IF ( peak_band )
+ {
+ IF ( GT_16(add(norm_ind,2), num_sfm))
+ {
+ /* normq = 0.15f*dicn[norm[norm_ind-1]] + 0.85f*dicn[norm[norm_ind]]; */
+ L_normq = Madd_32_16(Mult_32_16(dicn_fx[norm[norm_ind]], 27853 /* Q15, 0.85f */), dicn_fx[norm[norm_ind-1]], 4915 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16();
+ move16();
+ }
+ ELSE
+ {
+ /* normq = 0.1f*dicn[norm[norm_ind-1]] + 0.8f*dicn[norm[norm_ind]] + 0.1f*dicn[norm[norm_ind+1]]; */
+ L_normq = Madd_32_16(Madd_32_16(Mult_32_16(dicn_fx[norm[norm_ind]], 26214 /* Q15, 0.8f */), dicn_fx[norm[norm_ind+1]], 3277 /* Q15, 0.1f */), dicn_fx[norm[norm_ind-1]], 3277 /* Q15, 0.1f */); /* Q14 (14+15+1-16) */ move16();
+ move16();
+ move16();
+ }
+ }
+ ELSE
+ {
+ low = norm_ind;
+ move16();
+ high = s_min(add(norm_ind,1), last_norm_ind);
+ move16();
+ sel_norm = norm[norm_ind-1];
+ move16();
+ FOR (j = low; j <= high; j++)
+ {
+ if ( GT_16(norm[j], sel_norm))
+ {
+ sel_norm = norm[j];
+ move16();
+ }
+ }
+ L_normq = dicn_fx[sel_norm];
+ move16();
+ }
+
+ iend = s_min(sfm_end[norm_ind], bwe_noise_th);
+ move16();
+ IF( GT_16(iend, sfm_start[norm_ind]))
+ {
+ noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, sfm_start[norm_ind], iend, noise_level[0], L_coeff_out, qin, qout);
+ }
+ ELSE
+ {
+ iend = sfm_end[norm_ind];
+ move16();
+ noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, sfm_start[norm_ind], iend, noise_level[1], L_coeff_out, qin, qout);
+ }
+ /* Noisemix up to threshold done */
+ IF( EQ_16(iend, bwe_noise_th))
+ {
+ noise_mix_fx( &coeff_fine[-offset], L_E, L_normq, bwe_seed, iend, sfm_end[norm_ind], noise_level[1], L_coeff_out, qin, qout);
+ }
+
+ }
+ ELSE /* R[norm_ind] > 0 */
+ {
+ FOR (i = sfm_start[norm_ind]; i < sfm_end[norm_ind]; i++)
+ {
+ L_coeff_out[i] = L_coeff[i]; /* Scaling already applied */ move32();
+ }
+ }
+ }
+
+ prev_noise_level[0] = noise_level[0];
+ move16();
+ prev_noise_level[1] = noise_level[1];
+ move16();
+ L_src = &L_coeff_out[add(sfm_end[last_sfm], L_HARMONIC_EXC - START_EXC)]; /* Address initialization */
+ L_dst = L_src - 1 ; /* Address computation */
+
+ FOR( i = 0; i < 16; i++ )
+ {
+ *L_src = Mult_32_16(*L_src, hvq_bwe_fac_fx[i]);
+ L_src++; /* Qout (Qout+15+1-16) */ move32();
+ *L_dst = Mult_32_16(*L_dst, hvq_bwe_fac_fx[i]);
+ L_dst--; /* Qout (Qout+15+1-16) */ move32();
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+* hvq_concat_bands_fx()
+*
+* Compute the band limits for concatenated bands for PVQ target signal in HVQ
+*--------------------------------------------------------------------------*/
+void hvq_concat_bands_fx
+(
+ const Word16 pvq_bands, /* i : Number of bands in concatenated PVQ target */
+ const Word16 *sel_bnds, /* i : Array of selected high bands */
+ const Word16 n_sel_bnds, /* i : Number of selected high bands */
+ Word16 *hvq_band_start, /* i : Band start indices */
+ Word16 *hvq_band_width, /* i : Band widths */
+ Word16 *hvq_band_end /* i : Band end indices */
+)
+{
+ Word16 k, k_1;
+ const Word16 *pSelBnds;
+
+ pSelBnds = sel_bnds;
+ FOR (k = 0; k < pvq_bands; k++)
+ {
+
+ IF( GE_16(k, sub(pvq_bands, n_sel_bnds)))
+ {
+ k_1 = sub(k, 1);
+ hvq_band_start[k] = hvq_band_end[k_1];
+ move16();
+ hvq_band_width[k] = band_len_harm[*pSelBnds++];
+ move16();
+ move16();
+ hvq_band_end[k] = add(hvq_band_end[k_1], hvq_band_width[k]);
+ move16();
+ }
+ ELSE
+ {
+ hvq_band_start[k] = extract_l(L_mult0(k, HVQ_PVQ_COEFS));
+ hvq_band_width[k] = HVQ_PVQ_COEFS;
+ move16();
+ hvq_band_end[k] = add(hvq_band_start[k], HVQ_PVQ_COEFS);
+ move16();
+ }
+ }
+
+ return;
+}
+/*--------------------------------------------------------------------------*
+ * noise_mix_fx()
+ *--------------------------------------------------------------------------*/
+
+void noise_mix_fx(
+ const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */
+ const Word32 L_E, /* i : normalization factor Q17 */
+ const Word32 L_normq, /* i : quantized norm Q14 */
+ Word16 *seed, /* i/o: random seed Q0 */
+ const Word16 istart, /* i : start coefficient Q0 */
+ const Word16 iend, /* i : end coefficient Q0 */
+ const Word16 noise_level, /* i : noise_level Q0 */
+ Word32 *L_coeff_out, /* o : noise mixed spectrum Qout */
+ const Word16 qin,
+ const Word16 qout
+)
+{
+ Word16 i, tmp, n_c;
+ Word32 L_tmp0;
+ UWord16 lsb;
+
+ n_c = sub(MAX_16,noise_level); /* Q15 */
+ FOR (i = istart; i < iend; i++)
+ {
+ /* L_coeff_out[i] = ((1.0f - noise_level)*coeff_fine[i]*L_E + noise_level*own_random(seed)/32768.0f)*normq; */
+ Mpy_32_16_ss(L_E, coeff_fine[i], &L_tmp0, &lsb); /* Qin+qL_E-15 (qL_E+qin+1-16) */
+ Mpy_32_16_ss(L_tmp0, n_c, &L_tmp0, &lsb); /* Qin+qL_E-15 (qin+qL_E-15+15+1-16) */
+
+ IF(L_tmp0 != 0)
+ {
+ /* Normalize with 1 bit headroom for addition */
+ tmp = 30-(qin+2); /* Assuming fixed Q values */
+ tmp = s_min(norm_l(L_tmp0), tmp);
+ tmp = sub(tmp,1);
+
+ L_tmp0 = L_add(L_shl(L_tmp0,tmp), L_deposit_l(lshr(lsb, sub(16,tmp)))); /* Qin+2+tmp */
+ L_tmp0 = L_add(L_tmp0, L_shr(L_mult0(noise_level, Random(seed)), sub(30-(qin+2), tmp))); /* Qin+2+tmp */
+
+ tmp = round_fx(L_shl(L_tmp0,27-(qin+2)-tmp)); /* Q11 (Qin+2+tmp+27-qin-2-tmp-16) */
+ Mpy_32_16_ss(L_normq, tmp, &L_tmp0, &lsb); /* Q10 (14+11+1-16) */
+ L_coeff_out[i] = L_add(L_shl(L_tmp0,qout-10), L_deposit_l(lshr(lsb, 10+16-qout)));
+ move32();/* Qout (10+qout-10) */
+ }
+ ELSE
+ {
+ L_tmp0 = L_mult0(noise_level, Random(seed)); /* Q30 (15+15) */
+ tmp = round_fx(L_tmp0); /* Q14 (30-16) */
+ Mpy_32_16_ss(L_normq, tmp, &L_tmp0, &lsb); /* Q13 (14+14+1-16) */
+ L_coeff_out[i] = L_shr(L_tmp0,13-qout);
+ move32();/* Qout (13-(13-qout)) */
+ }
+ }
+}
+
+
+/*--------------------------------------------------------------------------*
+ * hq_generic_fine_fx()
+ *
+ * Prepare HQ GENERIC HF fine structure
+ *--------------------------------------------------------------------------*/
+void hq_generic_fine_fx(
+ Word16 *coeff, /* i : coded/noisefilled normalized spectrum */
+ const Word16 last_sfm, /* i : Last coded band */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input */
+ Word16 *coeff_out1 /* o : HQ GENERIC input */
+)
+{
+ Word16 sfm;
+ Word16 i;
+
+ FOR (sfm = 0; sfm <= last_sfm; sfm++)
+ {
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ IF (coeff[i]==0)
+ {
+ coeff_out1[i] = -2048;
+ move16();
+ if (Random(bwe_seed) > 0)
+ {
+ coeff_out1[i] = 2048;
+ move16();
+ }
+ }
+ ELSE
+ {
+ coeff_out1[i] = coeff[i];
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * overlap_hq_bwe_fx()
+ *
+ * Overlapping at the boundary between HQ core and BWE
+ *--------------------------------------------------------------------------*/
+static void overlap_hq_bwe_fx(
+ const Word32 *hq_swb_overlap_buf, /* i : spectrum from HQ core */
+ Word32 *coeff_out, /* i/o: spectrum from BWE, overlapped output */
+ const Word16 n_swb_overlap_offset, /* i : starting offset of overlapping */
+ const Word16 n_swb_overlap, /* i : length of overlapping */
+ const Word16 *R,
+ const Word16 num_env_bands,
+ const Word16 num_sfm,
+ const Word16 *sfm_end
+)
+{
+ Word16 i;
+ Word16 weighting;
+ Word16 step;
+ Word16 exp, tmp, n_band;
+
+ IF ( R[sub(num_env_bands,1)] != 0)
+ {
+ Copy32( hq_swb_overlap_buf, &coeff_out[n_swb_overlap_offset], n_swb_overlap );
+ }
+ ELSE
+ {
+ exp = norm_s(n_swb_overlap);
+ tmp = div_s(16384, shl(n_swb_overlap, exp));/*15 + 14 - exp */
+ tmp = shr(tmp, sub(14, exp));/*15 */
+ step = mult_r(tmp, 32767);/*15 */
+ weighting = 32767;
+ move16();
+ FOR (i = 0; i < n_swb_overlap; i++)
+ {
+ coeff_out[add(n_swb_overlap_offset,i)] = L_add(coeff_out[add(n_swb_overlap_offset,i)],
+ Mult_32_16(L_sub(hq_swb_overlap_buf[i], coeff_out[add(n_swb_overlap_offset,i)]), weighting));
+ move32();
+ weighting = sub(weighting, step);
+ }
+ }
+
+ FOR (n_band = num_env_bands; n_band < num_sfm; n_band++)
+ {
+ IF (R[n_band] !=0 )
+ {
+ FOR(i=sfm_end[sub(n_band,1)]; i0)
+ {
+ i=sub(nb_sfm,1);
+ WHILE(b_add_bits_denv>0 && i>=0)
+ {
+ IF ( GT_16(Rsubband[i], 24))
+ {
+ Rsubband[i] = sub(Rsubband[i] , 8);
+ move16();
+ b_add_bits_denv = sub(b_add_bits_denv,1);
+ }
+ i = sub(i,1);
+ }
+ }
+
+ return;
+}
+
+Word16 get_nor_delta_hf_fx(
+ Decoder_State_fx *st,
+ Word16 *ynrm,
+ Word16 *Rsubband, /* Q3 */
+ const Word16 num_env_bands,
+ const Word16 nb_sfm,
+ const Word16 core_sfm
+)
+{
+ Word16 i;
+ Word16 delta,bitsforDelta,add_bits_denv;
+
+ add_bits_denv = 0;
+ move16();
+ IF (GE_16(core_sfm ,num_env_bands))
+ {
+ bitsforDelta = (Word16)get_next_indice_fx(st,2);
+ bitsforDelta = add(bitsforDelta, 2);
+ add_bits_denv = add(add_bits_denv,2);
+
+ FOR(i=num_env_bands; iBER_detect = 1;
+ move16();
+ }
+ /*ynrm[i] += delta - (1<<(bitsforDelta-1));*/
+ add_bits_denv = add(add_bits_denv,bitsforDelta);
+ }
+ }
+ update_rsubband_fx(nb_sfm, Rsubband,add_bits_denv);
+ }
+ return add_bits_denv;
+}
+
+Word16 calc_nor_delta_hf_fx(
+ Encoder_State_fx *st,
+ const Word32 *t_audio,
+ Word16 *ynrm,
+ Word16 *Rsubband,
+ const Word16 num_env_bands,
+ const Word16 nb_sfm,
+ const Word16 *sfmsize,
+ const Word16 *sfm_start,
+ const Word16 core_sfm
+)
+{
+ Word16 i;
+ Word16 ynrm_t[44],normqlg2_t[44];
+ Word16 delta,max_delta,min_delta,bitsforDelta,add_bits_denv;
+ Word16 temp_num;
+
+ temp_num=0;
+ move16();
+
+ max_delta=-100;
+ move16();
+ calc_norm_fx( t_audio, 12, ynrm_t, normqlg2_t, 0, nb_sfm, sfmsize, sfm_start );
+ add_bits_denv = 0;
+ move16();
+ FOR(i=num_env_bands; i 0)
+ {
+ delta = add(delta,1);
+ }
+ ELSE
+ {
+ delta = negate(delta);
+ }
+ if (GT_16(delta,max_delta))
+ {
+ max_delta = delta;
+ move16();
+ }
+ }
+ }
+ IF (GE_16(core_sfm ,num_env_bands))
+ {
+ IF (LT_16(max_delta, 16))
+ {
+ bitsforDelta = 2;
+ move16();
+ FOR( ; max_delta >= 2; max_delta >>= 1 )
+ {
+ bitsforDelta = add(bitsforDelta,1);
+ }
+ }
+ ELSE
+ {
+ bitsforDelta = 5;
+ move16();
+ }
+ max_delta = sub( shl(1, sub(bitsforDelta,1)), 1);
+ min_delta = negate(add(max_delta,1));
+
+ /* updating norm & storing delta norm */
+ add_bits_denv = 2;
+ move16();
+ push_indice_fx( st, IND_DELTA_ENV_HQ, sub(bitsforDelta,2) , 2 );
+ FOR(i=num_env_bands; i0)
+ {
+ exp = norm_s(total_bit);
+ tmp = shl(total_bit,exp);/*Q(exp) */
+ tmp = div_s(16384,tmp);/*Q(15+14-exp) */
+ L_tmp = L_mult(tmp, bitalloc_var_fx); /*Q(29-exp+1) */
+ bitalloc_var_fx = round_fx(L_shl(L_tmp,exp));/*Q14 */
+ }
+ ELSE
+ {
+ bitalloc_var_fx = 0; /*Q14 */
+ }
+ /* calculate the peak-average ratio of saturable subbands */
+ num = 0;
+ sharp_fx = 0;
+ FOR(sfm = last_sfm; sfm >= 8; sfm--)
+ {
+ tmp = shl(sfmsize[sfm], 9);/*Q9 */
+ tmp = mult( rat_fx[sfm],tmp );/*Q(14+9-15=8) */
+ IF(GE_16(shl(R[sfm],8),tmp))
+ {
+ peak_fx = 0;
+ move16();
+ mean_fx = 0;
+ move16();
+ FOR( i = sfm_start[sfm]; i < sfm_end[sfm]; i++ )
+ {
+ fabs_coeff_out_fx = L_abs(L_coeff_out[i]);
+ mean_fx = L_add(mean_fx, fabs_coeff_out_fx);/*Q12 */
+ if(GT_32(fabs_coeff_out_fx, peak_fx))
+ {
+ peak_fx = fabs_coeff_out_fx;/*Q12 */
+ move32();
+ }
+ }
+
+ IF(mean_fx != 0)
+ {
+ exp = norm_l(mean_fx);
+ mean_fx = L_shl(mean_fx, exp);/*Q(exp+12) */
+ tmp = round_fx(mean_fx);/*Q(exp-4) */
+ tmp = div_s(16384,tmp); /*Q(15+14-exp+4 = 33-exp) */
+ L_tmp = Mult_32_16(peak_fx, tmp);/*Q(12+33-exp-15 = 30-exp) */
+ tmp = shl(sfmsize[sfm], 9);/*Q9 */
+ L_tmp = Mult_32_16(L_tmp, tmp);/*Q(30-exp+9-15 = 24-exp) */
+ tmp = round_fx(L_shl(L_tmp,exp));/*Q8 */
+ sharp_fx = add(sharp_fx,tmp);
+ }
+ num = add(num,1);
+ }
+ }
+ test();
+ IF(num != 0 && sharp_fx != 0)
+ {
+ num = add(num,num);
+ exp = norm_s(sharp_fx);
+ sharp_fx = shl(sharp_fx,exp);/*Q(8+exp) */
+ tmp = div_s(16384,sharp_fx);/*Q(21-exp) */
+ L_tmp = L_mult(num,tmp);/*Q(22-exp) */
+ sharp_fx = round_fx(L_shl(L_tmp,add(8,exp)));/*Q14 */
+ }
+ ELSE
+ {
+ sharp_fx = 16384;
+ move16();/*Q14 = 1 */
+ }
+ harm_para_fx = sharp_fx;
+ move16();/*Q14 */
+
+ IF(last_sfm == 0)
+ {
+ tmp = 0;
+ move16();
+ }
+ ELSE
+ {
+ tmp = div_s(1,last_sfm);/*Q15 */
+ }
+
+ L_tmp = L_mult(5,sharp_fx);/*Q15 */
+ L_tmp = Mult_32_16(L_tmp,tmp);/*Q15 */
+ step_fx = round_fx(L_shl(L_tmp,16));/*Q15 */
+ alfa_fx = 20480;
+ move16();/*Q13 = 2.5 */
+ /* fill noise for the insaturable subbands */
+ FOR( sfm = 0; sfm < num_sfm; sfm++ )
+ {
+ env_fx = L_deposit_l(0);
+ L_tmp2 =L_deposit_l(0);
+ exp = 0;
+ move16();
+ test();
+ IF(R[sfm] != 0 && LT_16(R[sfm], shl(mult(24756,sfmsize[sfm]),1)))
+ {
+ /* calculate the energy of the undecoded coefficients */
+ env_fx =L_deposit_l(0);
+ exp1=norm_l(L_normq_v[sfm]);
+ L_tmp4 = L_shl(L_normq_v[sfm],exp1); /*14+exp1 */
+ L_tmp1 = Mult_32_32(L_tmp4,L_tmp4); /*2*exp1-3 14+exp1+14+exp1 -31 */
+ L_tmp2 =L_deposit_l(0);
+ peak_fx = L_deposit_l(0);
+ min_coef_fx = 0x7fffffff;
+ move32();
+
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ fabs_coeff_out_fx = L_abs(L_coeff_out[i]);
+ test();
+ if(LT_32(fabs_coeff_out_fx, min_coef_fx)&&L_coeff_out[i]!=0)
+ {
+ min_coef_fx = fabs_coeff_out_fx;
+ move32();
+ }
+ if(GT_32(fabs_coeff_out_fx,peak_fx))
+ {
+ peak_fx = fabs_coeff_out_fx;
+ move32();
+ }
+ }
+
+ exp2 =norm_l(peak_fx);
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ L_tmp4 = L_shl(L_coeff_out[i],exp2); /*12+exp2 */
+ L_tmp3 = L_shr(Mult_32_32(L_tmp4,L_tmp4),4);/*2*exp2-7-4 12+exp2+12+exp2-31-4 */
+ L_tmp2 = L_add(L_tmp2 ,L_tmp3); /*2*exp2-11 */
+ }
+
+ tmp1 =div_s(1,sfmsize[sfm]); /*15 */
+ L_tmp4 = Mult_32_16(L_tmp2,tmp1);/*2*exp2-11 2*exp2-7+15+1-16 */
+
+ exp =norm_l(L_tmp1);
+ L_tmp1 = L_shl(L_tmp1,exp);/*exp + 2*exp1 - 3 */
+ exp1 =sub(add(exp,shl(exp1,1)),3);
+
+ exp =norm_l(L_tmp4);
+ L_tmp4 = L_shl(L_tmp4,exp);/*exp + 2*exp1 - 3 */
+ exp2 =sub(add(exp,shl(exp2,1)),11);
+ exp = s_min(exp1,exp2);
+
+ L_tmp1 = L_shl(L_tmp1,sub(exp,exp1));
+ L_tmp4 = L_shl(L_tmp4,sub(exp,exp2));
+ env_fx= L_sub(L_tmp1,L_tmp4); /*exp */
+ exp1 = norm_l(env_fx);
+ env_fx = L_shl(env_fx,exp1);/*exp + exp1 */
+ exp =add(exp,exp1);
+
+ IF (env_fx > 0 )
+ {
+ IF(sfm == 0)
+ {
+ avrg_norm_fx = L_add(L_shr(L_normq_v[0],1),L_shr(L_normq_v[1],1));/*13 */
+ avrg_norm_fx = L_add(avrg_norm_fx,L_shr(L_normq_v[2],1));/*13 */
+ prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[0],1),L_shr(prev_normq_fx[1],1));/*13 */
+ prev_avrg_norm_fx = L_add(prev_avrg_norm_fx,L_shr(prev_normq_fx[2],1));/*13 */
+ }
+ ELSE IF (EQ_16(sfm,25))
+ {
+ avrg_norm_fx = L_add(L_shr(L_normq_v[23],1),L_shr(L_normq_v[24],1));/*13 */
+ avrg_norm_fx = L_add(avrg_norm_fx,L_shr(L_normq_v[25],1));/*13 */
+ prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[23],1),L_shr(prev_normq_fx[24],1));/*13 */
+ prev_avrg_norm_fx = L_add(prev_avrg_norm_fx,L_shr(prev_normq_fx[25],1));/*13 */
+ }
+ ELSE
+ {
+ avrg_norm_fx = L_add(L_shr(L_normq_v[sub(sfm,1)],1),L_shr(L_normq_v[sfm],1));/*13 */
+ avrg_norm_fx = L_add(avrg_norm_fx,L_shr(L_normq_v[sfm+1],1));/*13 */
+ prev_avrg_norm_fx = L_add(L_shr(prev_normq_fx[sub(sfm,1)],1),L_shr(prev_normq_fx[sfm],1));/*13 */
+ prev_avrg_norm_fx = L_add(prev_avrg_norm_fx,L_shr(prev_normq_fx[add(sfm,1)],1));/*13 */
+ }
+
+ test();
+ test();
+ IF((GT_16(bitalloc_var_fx,4915)||LT_32(L_normq_v[sfm],peak_fx))&&peak_fx!=0)
+ {
+ Word16 exp_p;
+ exp_p =norm_l(peak_fx);
+ exp =sub(31,exp);
+ env_fx = Isqrt_lc(env_fx, &exp);
+ L_tmp1 = Mult_32_32(env_fx, L_shl(peak_fx, exp_p));/*12+exp2-exp 31-exp+12+exp1-31 */
+ L_tmp2 = Mult_32_16(avrg_norm_fx,harm_para_fx);/*12 13 + 14 + 1 -16 */
+ exp1 = norm_l(L_tmp1);
+ L_tmp1 = L_shl(L_tmp1,exp1);/* 12+exp2-exp+exp1 */
+ exp = add(sub(12,exp), add(exp1, exp_p));
+ L_tmp2 = Div_32(L_tmp2, extract_h(L_tmp1), extract_l(L_tmp1));
+ exp=sub(43,exp);
+ }
+ ELSE
+ {
+ L_tmp1 = Mult_32_16(L_normq_v[sfm],alfa_fx);/*12 13 + 14 + 1 -16 */
+ IF(LT_32(L_tmp1,peak_fx))
+ {
+ exp=sub(31,exp);
+ env_fx = Isqrt_lc(env_fx,&exp);
+ exp1 = norm_l(env_fx);
+ env_fx = L_shl(env_fx,exp1);/* 31-exp+exp1 */
+ exp = add(sub(31,exp),exp1);
+ L_tmp1 = (Word32)sharp_fx;
+ L_tmp2 = Div_32(L_tmp1, extract_h(env_fx), extract_l(env_fx)); /* 45-exp 14 - exp + 31 //39-exp 8 - exp + 31 */
+ exp = sub(45,exp);
+ exp1 = norm_l(peak_fx);
+ L_tmp1 = L_shl(peak_fx,exp1); /*12 + exp1 */
+ L_tmp1 = Div_32(L_tmp2,extract_h(L_tmp1), extract_l(L_tmp1)); /* exp - (12 + exp1) +31 */
+ L_tmp2 = Mult_32_32(L_tmp2,L_tmp1);/*2*exp+exp1-12 exp +exp - (12 + exp1) +31 - 31 */
+ exp = sub(add(shl(exp,1),exp1),12);
+ }
+ ELSE
+ {
+ exp = sub(31,exp);
+ env_fx = Isqrt_lc(env_fx,&exp);
+ exp1 = norm_l(env_fx);
+ env_fx =L_shl(env_fx,exp1);/* 31-exp+exp1 */
+ exp = add(sub(31,exp),exp1);
+ L_tmp1=(Word32)(sharp_fx);
+ L_tmp2 = Div_32(L_tmp1, extract_h(env_fx), extract_l(env_fx)); /* 45-exp 14 - exp + 31 //39-exp 8 - exp + 31 */
+ exp =sub(45,exp);
+ }
+
+ sharp_fx = add(sharp_fx,shr(step_fx,1));
+ }
+
+ IF(GT_32(L_tmp2,L_shl(min_coef_fx,sub(exp,13))))/*exp */
+ {
+ L_tmp2 = L_shr(min_coef_fx,1);
+ exp = 12;
+ move16();
+ }
+
+ IF(EQ_16(prev_bfi,1))
+ {
+ prev_env_Q[sfm] = exp;
+ move16();
+ prev_env_fx[sfm] = L_tmp2;
+ move32();
+ }
+ /* smooth the noise magnitudes between inter-frame */
+ test();
+ test();
+ IF(GT_32(prev_avrg_norm_fx,L_shr(avrg_norm_fx,1))&<_32(prev_avrg_norm_fx,L_shl(avrg_norm_fx,1))&&prev_is_transient==0)
+ {
+ exp1 =norm_l(prev_env_fx[sfm]);
+ L_tmp1 = L_shl(prev_env_fx[sfm],exp1);/* prev_env_Q[sfm] +exp1 */
+
+ exp2= norm_l(L_tmp2);
+ L_tmp3 = L_shl(L_tmp2,exp2);/* exp +exp2 */
+ exp3 = s_min(add(prev_env_Q[sfm],exp1),add(exp,exp2));
+
+ L_tmp1 = L_shl(L_tmp1,sub(sub(exp3,prev_env_Q[sfm]),exp1)); /*exp3 */
+ L_tmp3 = L_shl(L_tmp3,sub(sub(exp3,exp),exp2)); /*exp3 */
+ L_tmp2 = L_add(L_shr(L_tmp1,1),L_shr(L_tmp3,1));/*exp3 */
+ exp = exp3;
+ move16();
+ }
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ IF (coeff_fx[i] == 0)
+ {
+ tmp1 = Random(bwe_seed);/*Q15 */
+ L_tmp1= Mult_32_16(L_tmp2,tmp1);/*exp exp+15+1 -16 */
+ L_tmp1 = L_shl(L_tmp1,sub(12,exp));
+ L_coeff_out[i] = L_tmp1;
+ move32();
+ }
+ }
+ }
+ ELSE
+ {
+ exp =0;
+ move16();
+ L_tmp2 =L_deposit_l(0);
+ }
+ }
+ ELSE IF(R[sfm] == 0)
+ {
+ /* fill random noise for 0 bit subbands */
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ IF(coeff_fx[i] == 0)
+ {
+ tmp1 =Random(bwe_seed);/*Q15 */
+ L_tmp1= Mult_32_16(L_normq_v[sfm],tmp1);/*14 14+15+1 -16 */
+ L_tmp1 = L_shr(L_tmp1,2);/* */
+ L_coeff_out[i] = L_tmp1;
+ move32();
+ }
+ }
+ L_tmp2 = L_normq_v[sfm];
+ move32();
+ exp = 14;
+ move16();
+ }
+
+ test();
+ test();
+ test();
+ test();
+ IF(EQ_16(sfm,sub(SFM_N_WB,1))&&prev_is_transient==0&>_32(prev_normq_fx[sfm],L_shr(L_normq_v[sfm],1))
+ && LT_32(prev_normq_fx[sfm],L_shl(L_normq_v[sfm],1)) && LE_16(bitalloc_var_fx,4915))
+ {
+ Word32 *p_prev_coeff_out = prev_coeff_out_fx;
+ FOR (i = add(sfm_start[sfm],12); i < sfm_end[sfm]; i++)
+ {
+ test();
+ test();
+ test();
+ test();
+ IF(GT_32(L_abs(L_coeff_out[i]),L_shl(L_abs(*p_prev_coeff_out),2))
+ || LT_32(L_abs(L_coeff_out[i]),L_shr(L_abs(*p_prev_coeff_out),2))
+ || ((R[sfm] == 0 || *prev_R == 0) && add(R[sfm], *prev_R) != 0))
+ {
+ L_tmp = L_add(L_shr(L_abs(L_coeff_out[i]),1),L_shr(L_abs(*p_prev_coeff_out),1));
+
+ if(L_coeff_out[i] <= 0 )
+ {
+ L_tmp = L_negate(L_tmp);
+ }
+ L_coeff_out[i] = L_tmp;
+ move32();
+ }
+ p_prev_coeff_out++;
+ }
+ }
+ prev_env_Q[sfm] = exp;
+ move16();
+ prev_env_fx[sfm] = L_tmp2;
+ move32();
+ }
+ }
+ ELSE
+ {
+ /* fill random noise for 0 bit subbands of transient frame */
+ FOR(sfm = 0; sfm < num_sfm; sfm++)
+ {
+ IF( R[sfm] == 0 )
+ {
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ tmp1 =Random(bwe_seed);/*Q15 */
+ L_tmp1= Mult_32_16(L_normq_v[sfm],tmp1);/*14 14+15+1 -16 */
+ L_tmp1 =L_shr(L_tmp1,2);/* */
+ L_coeff_out[i] = L_tmp1;
+ move32();
+ }
+ }
+ }
+ set16_fx( prev_env_Q, 0, SFM_N_WB );
+ set32_fx( prev_env_fx, 0, SFM_N_WB );
+ }
+
+ Copy32(L_normq_v,prev_normq_fx,SFM_N_WB);
+ Copy32( L_coeff_out + L_FRAME16k - L_HQ_WB_BWE, prev_coeff_out_fx, L_HQ_WB_BWE );
+ *prev_R = R[SFM_N_WB-1];
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * enforce_zero_for_min_envelope_fx()
+ *
+ * Detect minimum level of envelope and set corresponding bands to zero
+ *--------------------------------------------------------------------------*/
+
+void enforce_zero_for_min_envelope_fx(
+ const Word16 hqswb_clas, /* i : HQ coding mode Q0 */
+ const Word16 *ynrm, /* i : Envelope indices Q0 */
+ Word32 *L_coefsq, /* i/o: Quantized spectrum/zeroed spectrum Q12 */
+ const Word16 nb_sfm, /* i : Number of coded sub bands Q0 */
+ const Word16 *sfm_start, /* i : Sub band start indices Q0 */
+ const Word16 *sfm_end /* i : Sub band end indices Q0 */
+)
+{
+ Word16 i, j;
+
+ /* prevent non-zero output for all-zero input */
+ IF( NE_16(hqswb_clas,HQ_HVQ))
+ {
+ IF( EQ_16(ynrm[0], 31))
+ {
+ FOR( j = sfm_start[0]; j < sfm_end[0]; j++ )
+ {
+ L_coefsq[j] = L_deposit_l(0);
+ }
+ }
+
+ FOR( i = 1; i < nb_sfm; i++ )
+ {
+ IF( EQ_16(ynrm[i], 39))
+ {
+ FOR( j = sfm_start[i]; j < sfm_end[i]; j++ )
+ {
+ L_coefsq[j] = L_deposit_l(0);
+ }
+ }
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * apply_envelope()
+ *
+ * Apply spectral envelope with envelope adjustments
+ *--------------------------------------------------------------------------*/
+
+void apply_envelope_fx(
+ const Word16 *coeff, /* i/o: Coded/noisefilled normalized spectrum Q12 */
+ const Word16 *norm, /* i : Envelope Q0 */
+ const Word16 *norm_adj, /* i : Envelope adjustment Q15 */
+ const Word16 num_sfm, /* i : Total number of bands Q0 */
+ const Word16 last_sfm, /* i : Last coded band Q0 */
+ const Word16 HQ_mode, /* i : HQ mode Q0 */
+ const Word16 length, /* i : Frame length Q0 */
+ const Word16 *sfm_start, /* i : Sub band start indices Q0 */
+ const Word16 *sfm_end, /* i : Sub band end indices Q0 */
+ Word32 *normq_v, /* o : Envelope with adjustment Q14 */
+ Word32 *coeff_out, /* o : coded/noisefilled spectrum Q12 */
+ const Word16 *coeff1, /* i : coded/noisefilled spectrum Q12 */
+ Word32 *coeff_out1 /* o : coded/noisefilled spectrum Q12 */
+)
+{
+ Word16 i;
+ Word16 sfm;
+ UWord16 lsb;
+ Word32 normq;
+ Word32 L_tmp;
+ Word16 len;
+
+ len = num_sfm;
+ move16();
+ test();
+ if( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB))
+ {
+ len = add(last_sfm, 1);
+ }
+
+ IF( EQ_16(length, L_FRAME16k))
+ {
+ FOR (sfm = 0; sfm < num_sfm; sfm++)
+ {
+ normq_v[sfm] = dicn_fx[norm[sfm]];
+ move16();
+ move32();
+ /*normq = normq_v[sfm] * norm_adj[sfm]; */
+ Mpy_32_16_ss(normq_v[sfm], norm_adj[sfm], &normq, &lsb); /* Q14 (14+15+1-16) */
+
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ /*coeff_out[i] = coeff[i]*normq; */
+ Mpy_32_16_ss(normq, coeff[i], &L_tmp, &lsb);
+ coeff_out[i] = L_add(L_shl(L_tmp, 1), lshr(lsb, 15));
+ move32(); /* Q12 (14+12+1-16)+1 */
+ }
+ }
+ }
+ ELSE
+ {
+ FOR (sfm = 0; sfm < len; sfm++)
+ {
+ normq_v[sfm] = dicn_fx[norm[sfm]];
+ move16();
+ move32();
+ /*normq_v[sfm] *= norm_adj[sfm]; */
+ Mpy_32_16_ss(normq_v[sfm], norm_adj[sfm], &normq_v[sfm], &lsb);
+ move32(); /* Q14 (14+15+1-16) */
+
+ normq = normq_v[sfm];
+ move32();
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ /*coeff_out[i] = coeff[i]*normq; */
+ Mpy_32_16_ss(normq, coeff[i], &L_tmp, &lsb);
+ coeff_out[i] = L_add(L_shl(L_tmp, 1), lshr(lsb, 15));
+ move32(); /* Q12 (14+12+1-16)+1 */
+ }
+ }
+
+ test();
+ IF ( EQ_16(HQ_mode, HQ_GEN_SWB)||EQ_16(HQ_mode,HQ_GEN_FB))
+ {
+ FOR (sfm = 0; sfm <= last_sfm; sfm++)
+ {
+ normq = normq_v[sfm];
+ move32();
+ FOR (i = sfm_start[sfm]; i < sfm_end[sfm]; i++)
+ {
+ /*coeff_out1[i] = coeff_out1[i]*normq; */
+ Mpy_32_16_ss(normq, coeff1[i], &L_tmp, &lsb);
+ coeff_out1[i] = L_add(L_shl(L_tmp, 1), lshr(lsb, 15));
+ move32(); /* Q12 (14+12+1-16)+1 */
+ }
+ }
+ }
+ }
+
+
+ return;
+}
+
+
diff --git a/lib_com/hvq_pvq_bitalloc_fx.c b/lib_com/hvq_pvq_bitalloc_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..6d21a77720614ee8fd1601a5909e043988d2fac1
--- /dev/null
+++ b/lib_com/hvq_pvq_bitalloc_fx.c
@@ -0,0 +1,191 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "stl.h" /* required by wmc_tool */
+
+#include "rom_com_fx.h"
+
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst_fx.h" /* Common constants */
+
+/*--------------------------------------------------------------------------*/
+/* Function hvq_pvq_bitalloc */
+/* ~~~~~~~~~~~~~~~~~~~~~~~~ */
+/* */
+/* Calculate the number of PVQ bands to code and allocate bits based on */
+/* the number of available bits. */
+/*--------------------------------------------------------------------------*/
+
+Word16 hvq_pvq_bitalloc_fx(
+ Word16 num_bits, /* i/o: Number of available bits (including gain bits) */
+ const Word32 brate, /* i : bitrate */
+ const Word16 bwidth_fx, /* i : Encoded bandwidth */
+ const Word16 *ynrm, /* i : Envelope coefficients */
+ const Word32 manE_peak, /* i : Peak energy mantissa */
+ const Word16 expE_peak, /* i : Peak energy exponent */
+ Word16 *Rk, /* o : bit allocation for concatenated vector */
+ Word16 *R, /* i/o: Global bit allocation */
+ Word16 *sel_bands, /* o : Selected bands for encoding */
+ Word16 *n_sel_bands /* o : No. of selected bands for encoding */
+)
+{
+ Word16 num_bands, band_max_bits;
+ Word16 one_over_band_max_bits;
+ Word16 k;
+ Word16 reciprocal, envSum, expo, align, m, n, indx;
+ Word16 k_max;
+ Word16 k_start;
+ Word32 E_max, E_max5;
+ Word32 tmp, acc;
+ Word32 env_mean;
+ UWord16 lsb;
+ Word16 num_sfm;
+
+ IF (EQ_16(bwidth_fx, FB))
+ {
+ num_sfm = SFM_N_HARM_FB;
+ }
+ ELSE
+ {
+ num_sfm = SFM_N_HARM;
+ }
+
+ IF ( EQ_32(brate, HQ_24k40))
+ {
+ band_max_bits = HVQ_BAND_MAX_BITS_24k;
+ move16();
+ one_over_band_max_bits = ONE_OVER_HVQ_BAND_MAX_BITS_24k_FX;
+ move16();
+ k_start = HVQ_THRES_SFM_24k;
+ move16();
+ IF (EQ_16(bwidth_fx, FB))
+ {
+ reciprocal = 2731; /* Q15, 1/(SFM_N_HARM_FB + 1 - k_start) */ move16();
+ }
+ ELSE
+ {
+ reciprocal = 3277; /* Q15, 1/(SFM_N_HARM + 1 - k_start) */ move16();
+ }
+ }
+ ELSE
+ {
+ band_max_bits = HVQ_BAND_MAX_BITS_32k;
+ move16();
+ one_over_band_max_bits = ONE_OVER_HVQ_BAND_MAX_BITS_32k_FX;
+ move16();
+ k_start = HVQ_THRES_SFM_32k;
+ move16();
+ IF (EQ_16(bwidth_fx, FB))
+ {
+ reciprocal = 3641; /* Q15, 1/(SFM_N_HARM_FB + 1 - k_start) */ move16();
+ }
+ ELSE
+ {
+ reciprocal = 4681; /* Q15, 1/(SFM_N_HARM + 1 - k_start) */ move16();
+ }
+ }
+
+ num_bands = mult( num_bits, one_over_band_max_bits ); /* Q0 */
+ num_bits = sub( num_bits, i_mult(num_bands, band_max_bits) ); /* Q0 */
+
+ IF ( GE_16(num_bits, HVQ_NEW_BAND_BIT_THR))
+ {
+ num_bands = add(num_bands, 1);
+ }
+ ELSE
+ {
+ num_bits = add(num_bits, band_max_bits);
+ }
+
+ /* safety check in case of bit errors */
+ if (LT_16(num_bands, 1))
+ {
+ return 0;
+ }
+
+ *n_sel_bands = 0;
+ move16();
+ envSum = 0;
+ move16();
+ E_max = L_deposit_l(0);
+ k_max = k_start;
+ move16();
+ FOR ( k = k_start; k < num_sfm; k++ )
+ {
+ indx = ynrm[k];
+ move16();
+ tmp = dicn_fx[indx]; /* Q14 */
+ move32();
+ envSum = add(envSum, indx); /* Since the size of dicn_fx = 40, ynrm[k] must be less than 41. 16 bits are enough for envSum.*/
+ IF (GT_32(tmp, E_max))
+ {
+ E_max = tmp;
+ move32();
+ k_max = k;
+ move16();
+ }
+ }
+ env_mean = L_mult(envSum, reciprocal); /* env_mean in Q16 */
+ IF (GT_32(L_sub(env_mean, L_deposit_h(ynrm[k_max])), 0x30000L)) /* condition: env_mean - ynrm[k_max] > 3 */
+ {
+ expo = norm_l(E_max);
+ E_max = L_shl(E_max, expo);
+ Mpy_32_16_ss(E_max, 0x7a12, &E_max5, &lsb); /* NB: 5.0e5 = 0x7a12(Q15) x 2^19. */
+ /* True floating point value of E_max*5e5 = E_max5 x 2^(19 - expo - 14).
+ * In this context, the 32-bit E_max5 is in Q0, and
+ * -14 is due to Emax in Q14.
+ * True floating point value of E_peak = manE_peak x 2^(31 - expE_peak - 2*12). See peak_vq_enc_fx().
+ */
+
+ /* Align the Q-points of the floating point Emax*5e5 and E_peak. */
+ align = sub(expo, expE_peak);
+ align = add(align, (19 - 14) - (31 - 2*12));
+ IF (align < 0)
+ {
+ acc = L_sub(E_max5, L_shl(manE_peak, align));
+ }
+ ELSE
+ {
+ acc = L_sub(L_shr(E_max5, align), manE_peak);
+ }
+
+ IF (acc > 0) /* condition: E_max*5.e5 > E_peak */
+ {
+ IF ( EQ_16(band_len_harm[k_max], 96))
+ {
+ n = 61;
+ }
+ ELSE
+ {
+ QuantaPerDsDirac_fx(band_len_harm[k_max], 1, hBitsN, &n);
+ }
+ m = shl(sub(num_bits, HVQ_PVQ_GAIN_BITS), 3);
+ IF (GE_16(m, n))
+ {
+ IF (GT_16(num_bands, 1)) /* condition: num_bands > 1 */
+ {
+ sel_bands[*n_sel_bands] = k_max;
+ move16();
+ *n_sel_bands = add(*n_sel_bands, 1);
+ R[k_max] = 1; /* Mark that the band has been encoded for fill_spectrum */ move16();
+ }
+ }
+ }
+ }
+
+ /* Allocate bits */
+ tmp = sub(num_bands,1);
+ FOR (k = 0; k < tmp; k++)
+ {
+ Rk[k] = shl(sub(band_max_bits, HVQ_PVQ_GAIN_BITS), 3);
+ move16();
+ }
+ /* NB: When it exits the above loop, k = num_bands - 1. */
+ Rk[k] = shl(sub(num_bits, HVQ_PVQ_GAIN_BITS), 3);
+ move16();
+
+ return num_bands;
+}
+
diff --git a/lib_com/igf_base.c b/lib_com/igf_base.c
new file mode 100644
index 0000000000000000000000000000000000000000..3c799c5fca00f6fe8d37c88f3977a65b551f354e
--- /dev/null
+++ b/lib_com/igf_base.c
@@ -0,0 +1,936 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include
+#include
+#include "options.h"
+#include "stl.h"
+#include "prot_fx.h"
+#include "rom_com_fx.h"
+#include "basop_util.h"
+
+/**********************************************************************/ /*
+returns an int val, multiplied with transFac
+**************************************************************************/
+static Word16 IGF_ApplyTransFac( /**< out: Q0 | multiplication factor */
+ const Word16 val, /**< in: Q15 | input value for multiplication, Q15 */
+ const Word16 transFac /**< in: Q14 | multiplicator for variable val, Q14: 1.25f=0x5000, 1.0f=0x4000, 0.5f=0x2000 */
+)
+{
+ Word16 ret;
+
+ if(EQ_16(transFac, 0x4000))
+ {
+ return val;
+ }
+
+ ret = shl(val, 1);
+ ret = mac_r(0x00000000, ret, transFac);
+ ret = add(ret, s_and(ret, 1));
+
+
+ return ret;
+}
+
+/**********************************************************************/ /*
+maps a given bitrate to the IGF_BITRATE index
+**************************************************************************/
+static Word16 IGF_MapBitRateToIndex( /**< out: Q0 | return bit rate index */
+ Word32 bitRate, /**< in: | bitrate */
+ Word16 mode /**< in: | bandwidth mode */
+ , Word16 rf_mode /**< in: | flag to signal the RF mode */
+)
+{
+ Word16 bitRateIndex;
+
+
+ bitRateIndex = IGF_BITRATE_UNKNOWN;
+ move16();
+
+ switch (mode)
+ {
+ case IGF_MODE_WB:
+ switch (bitRate)
+ {
+ case 13200:
+ if (EQ_16(rf_mode,1))
+ {
+ bitRateIndex = IGF_BITRATE_RF_WB_13200;
+ }
+ break;
+ case 9600:
+ bitRateIndex = IGF_BITRATE_WB_9600;
+ break;
+ default:
+ assert(0);
+ }
+ break;
+ case IGF_MODE_SWB:
+ switch (bitRate)
+ {
+ case 9600:
+ bitRateIndex = IGF_BITRATE_SWB_9600;
+ break;
+ case 13200:
+ bitRateIndex = IGF_BITRATE_SWB_13200;
+ if (EQ_16(rf_mode,1))
+ {
+ bitRateIndex = IGF_BITRATE_RF_SWB_13200;
+ }
+ break;
+ case 16400:
+ bitRateIndex = IGF_BITRATE_SWB_16400;
+ break;
+ case 24400:
+ bitRateIndex = IGF_BITRATE_SWB_24400;
+ break;
+ case 32000:
+ bitRateIndex = IGF_BITRATE_SWB_32000;
+ break;
+ case 48000:
+ bitRateIndex = IGF_BITRATE_SWB_48000;
+ break;
+ default:
+ assert(0);
+ }
+ break;
+ case IGF_MODE_FB:
+ switch (bitRate)
+ {
+ case 16400:
+ bitRateIndex = IGF_BITRATE_FB_16400;
+ break;
+ case 24400:
+ bitRateIndex = IGF_BITRATE_FB_24400;
+ break;
+ case 32000:
+ bitRateIndex = IGF_BITRATE_FB_32000;
+ break;
+ case 48000:
+ bitRateIndex = IGF_BITRATE_FB_48000;
+ break;
+ case 96000:
+ bitRateIndex = IGF_BITRATE_FB_96000;
+ break;
+ case 128000:
+ bitRateIndex = IGF_BITRATE_FB_128000;
+ break;
+ default:
+ assert(0);
+ }
+ break;
+ default:
+ assert(0);
+ }
+
+ return bitRateIndex;
+}
+
+/**********************************************************************/ /*
+IGF grid setup
+**************************************************************************/
+static void IGF_gridSetUp(H_IGF_GRID hGrid, /**< out: | IGF grid handle */
+ Word16 bitRateIndex, /**< in: Q0 | IGF bitrate index */
+ Word32 sampleRate, /**< in: | sample rate */
+ Word16 frameLength, /**< in: | frame length */
+ Word16 transFac, /**< in: | transFac */
+ Word16 igfMinFq /**< in: | IGF minimum frequency indicating lower start frequency for copy up */
+ )
+{
+ Word16 t;
+ Word16 sfb;
+ const Word16 *swb_offset;
+ Word16 swb_offset_len;
+ Word16 bandwidth;
+ Word16 wrp_sfb;
+ Word16 tmp1;
+ Word16 tmp2;
+ Word32 L_tmp1;
+ Word32 L_tmp2;
+
+ swb_offset = NULL;
+ move16();
+ swb_offset_len = 0;
+ move16();
+
+ SWITCH (bitRateIndex)
+ {
+ case IGF_BITRATE_WB_9600:
+ case IGF_BITRATE_SWB_9600:
+ case IGF_BITRATE_RF_WB_13200:
+ case IGF_BITRATE_RF_SWB_13200:
+ case IGF_BITRATE_SWB_13200:
+ case IGF_BITRATE_SWB_16400:
+ case IGF_BITRATE_SWB_24400:
+ case IGF_BITRATE_SWB_32000:
+ case IGF_BITRATE_SWB_48000:
+ swb_offset = &swb_offset_LB_new[bitRateIndex][1];
+ swb_offset_len = swb_offset_LB_new[bitRateIndex][0];
+ move16();
+ Copy(&igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2);
+ BREAK;
+ case IGF_BITRATE_FB_16400:
+ case IGF_BITRATE_FB_24400:
+ case IGF_BITRATE_FB_32000:
+ swb_offset = &swb_offset_LB_new[bitRateIndex][1];
+ swb_offset_len = swb_offset_LB_new[bitRateIndex][0];
+ move16();
+ Copy(&igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2);
+ BREAK;
+ case IGF_BITRATE_FB_48000:
+ case IGF_BITRATE_FB_96000:
+ case IGF_BITRATE_FB_128000:
+ swb_offset = &swb_offset_LB_new[bitRateIndex][1];
+ swb_offset_len = swb_offset_LB_new[bitRateIndex][0];
+ move16();
+ Copy(&igf_whitening_TH[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2);
+ BREAK;
+ case IGF_BITRATE_UNKNOWN:
+ default:
+ assert(0);
+ }
+
+ FOR(sfb = 0; sfb < swb_offset_len; sfb++)
+ {
+ hGrid->swb_offset[sfb] = IGF_ApplyTransFac(swb_offset[sfb], transFac);
+ move16();
+ }
+
+ hGrid->infoIsRefined = 0;
+ move16();
+ frameLength = IGF_ApplyTransFac(frameLength, transFac);
+ tmp2 = norm_s(frameLength);
+ bandwidth = shl(frameLength,tmp2);
+ hGrid->swb_offset_len = extract_l(L_shr(sampleRate, 2));
+ tmp1 = sub(norm_s(hGrid->swb_offset_len), 1);
+ hGrid->swb_offset_len = shl(hGrid->swb_offset_len, tmp1);
+ bandwidth = div_s(hGrid->swb_offset_len, bandwidth);
+ tmp2 = sub(add(tmp2, 1), tmp1);
+ bandwidth = shr(bandwidth, sub(15, tmp2));
+
+
+ hGrid->swb_offset_len = swb_offset_len;
+ move16();
+ hGrid->startSfb = 0;
+ move16();
+ hGrid->stopSfb = sub(hGrid->swb_offset_len, 1);
+ hGrid->startLine = hGrid->swb_offset[ hGrid->startSfb ];
+ move16();
+ hGrid->stopLine = hGrid->swb_offset[ hGrid->stopSfb ];
+ move16();
+ hGrid->startFrequency = imult1616(bandwidth, hGrid->startLine);
+ hGrid->stopFrequency = imult1616(bandwidth, hGrid->stopLine);
+
+ L_tmp1 = L_mult0(igfMinFq, frameLength);
+ tmp1 = sub(norm_l(L_tmp1), 1);
+ L_tmp1 = L_shl(L_tmp1, tmp1);
+
+ tmp2 = norm_l(sampleRate);
+ L_tmp2 = L_shl(sampleRate, tmp2);
+ tmp1 = add(WORD16_BITS-1, sub(tmp1, add(tmp2, 1))); /* takes into account sampleRate >> 1 */
+
+ hGrid->minSrcSubband = div_s(extract_h(L_tmp1), extract_h(L_tmp2));
+ hGrid->minSrcSubband = shr(hGrid->minSrcSubband, tmp1);
+
+
+ hGrid->minSrcSubband = add(hGrid->minSrcSubband, s_and(hGrid->minSrcSubband, 1));
+ hGrid->minSrcFrequency = imult1616(bandwidth, hGrid->minSrcSubband);
+ hGrid->infoGranuleLen = frameLength;
+ move16();
+ hGrid->infoTransFac = transFac;
+ move16();
+
+ hGrid->sfbWrap[0] = 0;
+ move16();
+ hGrid->tile[0] = hGrid->startLine;
+ move16();
+
+
+ /*************************************************************************/
+ SWITCH (bitRateIndex)
+ {
+ /* SWB 13200 */
+ case IGF_BITRATE_WB_9600:
+ hGrid->nTiles = 2;
+ move16();
+ wrp_sfb = 2;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[1] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[1+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+ BREAK;
+
+ case IGF_BITRATE_RF_WB_13200:
+ hGrid->nTiles = 2;
+ wrp_sfb = 2;
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = hGrid->stopSfb;
+ hGrid->sbWrap[1] = hGrid->minSrcSubband;
+ hGrid->tile[1+1] = hGrid->swb_offset[hGrid->stopSfb];
+
+ BREAK;
+ case IGF_BITRATE_SWB_9600:
+ hGrid->nTiles = 3;
+ wrp_sfb = 1;
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+
+ /*2nd*/
+ wrp_sfb = 2;
+ hGrid->sfbWrap[1+1] = wrp_sfb;
+ hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac(32, transFac);
+ hGrid->tile[1+1] = hGrid->swb_offset[wrp_sfb];
+
+ /*3rd*/
+ hGrid->sfbWrap[2+1] = hGrid->stopSfb;
+ hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac(46, transFac);
+ hGrid->tile[2+1] = hGrid->swb_offset[hGrid->stopSfb];
+
+ BREAK;
+ case IGF_BITRATE_RF_SWB_13200:
+ hGrid->nTiles = 3;
+ wrp_sfb = 1;
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+
+ /*2nd*/
+ wrp_sfb = 2;
+ hGrid->sfbWrap[1+1] = wrp_sfb;
+ hGrid->sbWrap[1] = hGrid->minSrcSubband + IGF_ApplyTransFac(32, transFac);
+ hGrid->tile[1+1] = hGrid->swb_offset[wrp_sfb];
+
+ /*3rd*/
+ hGrid->sfbWrap[2+1] = hGrid->stopSfb;
+ hGrid->sbWrap[2] = hGrid->minSrcSubband + IGF_ApplyTransFac(46, transFac);
+ hGrid->tile[2+1] = hGrid->swb_offset[hGrid->stopSfb];
+
+ BREAK;
+
+ case IGF_BITRATE_SWB_13200:
+ hGrid->nTiles = 2;
+ move16();
+ wrp_sfb = 4;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[1] = add(hGrid->minSrcSubband, IGF_ApplyTransFac(32, transFac));
+ move16();
+ hGrid->tile[1+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+ BREAK;
+
+ case IGF_BITRATE_SWB_16400:
+ hGrid->nTiles = 3;
+ move16();
+ wrp_sfb = 4;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = 6;
+ move16();
+ hGrid->sbWrap[1] = add(hGrid->minSrcSubband, IGF_ApplyTransFac(48, transFac));
+ move16();
+ hGrid->tile[1+1] = hGrid->swb_offset[6];
+ move16();
+
+ /*3nd*/
+ hGrid->sfbWrap[2+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[2] = add(hGrid->minSrcSubband, IGF_ApplyTransFac(64, transFac));
+ move16();
+ hGrid->tile[2+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+ BREAK;
+
+ case IGF_BITRATE_SWB_24400:
+ case IGF_BITRATE_SWB_32000:
+ hGrid->nTiles = 3;
+ move16();
+ wrp_sfb = 4;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = 7;
+ move16();
+ hGrid->sbWrap[1] = add(hGrid->minSrcSubband, IGF_ApplyTransFac(32, transFac));
+ move16();
+ hGrid->tile[1+1] = hGrid->swb_offset[7];
+ move16();
+
+ /*3nd*/
+ hGrid->sfbWrap[2+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[2] = add(hGrid->minSrcSubband, IGF_ApplyTransFac(64, transFac));
+ move16();
+ hGrid->tile[2+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+ BREAK;
+ case IGF_BITRATE_SWB_48000:
+ hGrid->nTiles = 1;
+ move16();
+ wrp_sfb = hGrid->stopSfb;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[0] = sub(shl(hGrid->startLine, 1), hGrid->stopLine);
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+
+ BREAK;
+ case IGF_BITRATE_FB_16400:
+ hGrid->nTiles = 3;
+ move16();
+ wrp_sfb = 4;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+ wrp_sfb = 7;
+ move16();
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[1] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[1+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+
+ /*3nd*/
+ hGrid->sfbWrap[2+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[2] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[2+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+
+ BREAK;
+
+ case IGF_BITRATE_FB_24400:
+ case IGF_BITRATE_FB_32000:
+ hGrid->nTiles = 4;
+ move16();
+ wrp_sfb = 4;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[0] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+ wrp_sfb = 6;
+ move16();
+
+ /*2nd*/
+ hGrid->sfbWrap[1+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[1] = add(hGrid->minSrcSubband, IGF_ApplyTransFac(32, transFac));
+ move16();
+ hGrid->tile[1+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+ wrp_sfb = 9;
+ move16();
+
+ /*3nd*/
+ hGrid->sfbWrap[2+1] = wrp_sfb;
+ move16();
+ hGrid->sbWrap[2] = hGrid->minSrcSubband;
+ move16();
+ hGrid->tile[2+1] = hGrid->swb_offset[wrp_sfb];
+ move16();
+
+ /*4nd*/
+ hGrid->sfbWrap[3+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[3] = add(hGrid->minSrcSubband, sub(hGrid->swb_offset[9], hGrid->swb_offset[8]));
+ move16();
+ hGrid->tile[3+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+ BREAK;
+ case IGF_BITRATE_FB_48000:
+ case IGF_BITRATE_FB_96000:
+ case IGF_BITRATE_FB_128000:
+ hGrid->nTiles = 1;
+ move16();
+
+ /*1st*/
+ hGrid->sfbWrap[0+1] = hGrid->stopSfb;
+ move16();
+ hGrid->sbWrap[0] = sub(shl(hGrid->startLine, 1), hGrid->stopLine);
+ move16();
+ hGrid->tile[0+1] = hGrid->swb_offset[hGrid->stopSfb];
+ move16();
+
+ BREAK;
+ default:
+ assert(0);
+ }/*switch*/
+
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ /* adapt level envelope: */
+ SWITCH (bitRateIndex)
+ {
+ case IGF_BITRATE_RF_WB_13200:
+ case IGF_BITRATE_WB_9600:
+ hGrid->gFactor = 13107/*0.80f Q14*/;
+ move16();
+ hGrid->fFactor = 11469/*0.70f Q14*/;
+ move16();
+ hGrid->lFactor = 9830/*0.60f Q14*/;
+ move16();
+ BREAK;
+ case IGF_BITRATE_SWB_13200:
+ case IGF_BITRATE_FB_16400:
+ case IGF_BITRATE_SWB_16400:
+ hGrid->gFactor = 15237/*0.93f Q14*/;
+ move16();
+ hGrid->fFactor = 3277/*0.20f Q14*/;
+ move16();
+ hGrid->lFactor = 13926/*0.85f Q14*/;
+ move16();
+ BREAK;
+ case IGF_BITRATE_FB_24400:
+ case IGF_BITRATE_SWB_24400:
+ case IGF_BITRATE_FB_32000:
+ case IGF_BITRATE_SWB_32000:
+ hGrid->gFactor = 15811/*0.965f Q14*/;
+ move16();
+ hGrid->fFactor = 3277/*0.20f Q14*/;
+ move16();
+ hGrid->lFactor = 13926/*0.85f Q14*/;
+ move16();
+ BREAK;
+ case IGF_BITRATE_FB_48000:
+ case IGF_BITRATE_SWB_48000:
+ hGrid->gFactor = 16384/*1.00f Q14*/;
+ move16();
+ hGrid->fFactor = 3277/*0.20f Q14*/;
+ move16();
+ hGrid->lFactor = 16384/*1.00f Q14*/;
+ move16();
+ BREAK;
+ case IGF_BITRATE_SWB_9600:
+ case IGF_BITRATE_RF_SWB_13200:
+ default:
+ hGrid->gFactor = 16384/*1.00f Q14*/;
+ move16();
+ hGrid->fFactor = 0/*0.00f Q14*/;
+ move16();
+ hGrid->lFactor = 16384/*1.00f Q14*/;
+ move16();
+ }
+
+ FOR (t = add(hGrid->nTiles, 1); t < IGF_MAX_TILES; t++)
+ {
+ hGrid->tile[t] = 0;
+ move16();
+ hGrid->sbWrap[t - 1] = 0;
+ move16();
+ hGrid->sfbWrap[t] = 0;
+ move16();
+ }
+
+}
+
+/**********************************************************************/ /*
+calculates energy per sfb via power spectrum
+**************************************************************************/
+void IGFCommonFuncsCalcSfbEnergyPowerSpec(const Word16 startSfb, /**< in: Q0 | start sfb index */
+ const Word16 stopSfb, /**< in: Q0 | stop sfb index */
+ const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */
+ Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */
+ Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */
+ Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */
+ Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */
+ )
+{
+ Word16/*Q0*/ sfb;
+ Word16/*Q0*/ line;
+ Word32 L_c;
+
+
+ FOR (sfb = startSfb; sfb < stopSfb; sfb++)
+ {
+ sfbEnergy[sfb] = L_deposit_l(0);
+ }
+ IF (NULL == pPowerSpectrum)
+ {
+ return;
+ }
+
+ FOR (sfb = startSfb; sfb < stopSfb; sfb++)
+ {
+ L_c = L_deposit_l(0);
+ FOR (line = swb_offset[sfb]; line < swb_offset[sfb+1]; line++)
+ {
+ Carry = 0;
+ sfbEnergy[sfb] = L_add_c(sfbEnergy[sfb], pPowerSpectrum[line]);
+ move32();
+ Overflow = 0;
+ L_c = L_macNs(L_c,0,0);
+ }
+ sfbEnergy[sfb] = norm_llQ31(L_c,sfbEnergy[sfb],&(sfbEnergy_exp[sfb]));
+ move32();
+ sfbEnergy_exp[sfb] = add(sfbEnergy_exp[sfb],*pPowerSpectrum_exp);
+ move16();
+ }
+}
+
+/**********************************************************************/ /*
+calculate the MDCT square spectrum in the IGF range
+**************************************************************************/
+void IGFCommonFuncsMDCTSquareSpec(const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */
+ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */
+ const Word32 *mdctSpec, /**< in: Q31 | MDCT spectrum to square */
+ const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */
+ Word32 *mdctSquareSpec, /**< out:Q31 | MDCT square spectrum */
+ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */
+ Word16 indexOffset /**< in: Q0 | index offset */
+ )
+{
+ Word16 i;
+ Word16 j;
+ Word16 s1;
+ Word16 tmp;
+
+
+ /* get headroom, only in IGF range */
+ s1 = getScaleFactor32(mdctSpec + sqrtBgn, sub(sqrtEnd, sqrtBgn));
+
+ /* set new exponent */
+ *mdctSquareSpec_e = add(shl(sub(mdctSpec_e, s1), 1), 1);
+ move16();
+
+ /* MDCT square spectrum: MDCT^2 */
+ j = add(sqrtBgn, indexOffset); /* handle indexOffset with care, otherwise memory overruns may occur! */
+
+
+ FOR (i = sqrtBgn; i < sqrtEnd; i++)
+ {
+ tmp = round_fx(L_shl(mdctSpec[i], s1));
+ mdctSquareSpec[j++] = L_mult0(tmp, tmp);
+ move32();
+ }
+
+
+}
+
+/**********************************************************************/ /*
+write bits to stream
+**************************************************************************/
+void IGFCommonFuncsWriteSerialBit(void *st, /**< in: | encoder/decoder state structure */
+ Word16 *pBitOffset, /**< out: Q0 | bit offset */
+ Word16 bit /**< in: Q0 | value of bit */
+ )
+{
+
+ IF (st)
+ {
+ push_next_indice_fx(st, bit, 1);
+ }
+ *pBitOffset = add(*pBitOffset, 1);
+ move16();
+
+ return;
+}
+
+/**********************************************************************/ /*
+changes the IGF configuration
+**************************************************************************/
+Word16 IGFCommonFuncsIGFConfiguration( /**< out: | error value: 0 -> error, 1 -> ok */
+ Word32 bitRate, /**< in: Q0 | bitrate in bs e.g. 9600 for 9.6kbs */
+ Word16 mode, /**< in: Q0 | bandwidth mode */
+ H_IGF_INFO hIGFInfo /**< out: | IGF info handle */
+ ,Word16 rf_mode /**< in: flag to signal the RF mode */
+)
+{
+ H_IGF_GRID hGrid;
+ Word16 retValue;
+ Word32 sampleRate;
+ Word16 frameLength;
+ Word16 igfMinFq;
+ Word16 maxHopsize;
+
+ retValue = 0; /* bitrate index is unknown -> error! */ move16();
+
+ /* interface call for reading in settings */
+ hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex(bitRate, mode
+ ,rf_mode
+ );
+
+ IF (NE_16(hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN))
+ {
+ retValue = 1; /* no error */ move16();
+
+ /* mapping to local values */
+ sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate;
+ move32();
+ frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength;
+ move16();
+ igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq;
+ move16();
+ maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize;
+ move16();
+
+ /* basic information */
+ hIGFInfo->sampleRate = sampleRate;
+ move32();
+ hIGFInfo->frameLength = frameLength;
+ move16();
+ hIGFInfo->maxHopsize = maxHopsize;
+ move16();
+ hIGFInfo->nfSeed = 0;
+ move16();
+
+ /* set up regular IGF grid for TCX 20 (transfac = 1.f) */
+ hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM];
+ IGF_gridSetUp(hGrid,
+ hIGFInfo->bitRateIndex,
+ sampleRate,
+ frameLength,
+ 16384/*1 Q14*/,
+ igfMinFq);
+
+ /* set up IGF grid for CELP->TCX 20 transitions (transfac = 1.25) */
+ hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN];
+ IGF_gridSetUp(hGrid,
+ hIGFInfo->bitRateIndex,
+ sampleRate,
+ frameLength,
+ 20480/*1.25 Q14*/,
+ igfMinFq);
+ /* set up IGF grid for TCX 10 (transfac = 0.5) */
+ hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT];
+ IGF_gridSetUp(hGrid,
+ hIGFInfo->bitRateIndex,
+ sampleRate,
+ frameLength,
+ 8192/*0.50f Q14*/,
+ igfMinFq);
+ }
+
+ return retValue;
+}
+
+/**********************************************************************/ /*
+selects cumulative frequency tables and offsets for the IGF SCF arithmetic coder
+**************************************************************************/
+Word16 IGFCommonFuncsIGFGetCFTables( /**< out: | error value: 0 -> error, 1 -> ok */
+ Word32 bitRate, /**< in: Q0 | bitrate in bs e.g. 9600 for 9.6kbs */
+ Word16 mode, /**< in: Q0 | bandwidth mode */
+ Word16 rf_mode, /**< in: | flag to signal the RF mode */
+ const Word16 **cf_se00, /**< out: | CF table for t == 0 and f == 0 */
+ const Word16 **cf_se01, /**< out: | CF table for t == 0 and f == 1 */
+ Word16 *cf_off_se01, /**< out: | offset for CF table above */
+ const Word16 **cf_se02, /**< out: | CF tables for t == 0 and f >= 2 */
+ const Word16 **cf_off_se02, /**< out: | offsets for CF tables above */
+ const Word16 **cf_se10, /**< out: | CF table for t == 1 and f == 0 */
+ Word16 *cf_off_se10, /**< out: | offset for CF table above */
+ const Word16 **cf_se11, /**< out: | CF tables for t == 1 and f >= 1 */
+ const Word16 **cf_off_se11 /**< out: | offsets for CF tables above */
+)
+{
+ Word16 retValue;
+ Word16 bitRateIndex;
+
+Word16 temp_var;
+
+ retValue = 0; /* bitrate index is unknown -> error! */ move16();
+ bitRateIndex = IGF_MapBitRateToIndex(bitRate, mode
+ ,rf_mode
+ );
+
+
+ IF (NE_16(bitRateIndex, IGF_BITRATE_UNKNOWN))
+ {
+ retValue = 1; /* no error */ move16();
+ SWITCH(bitRateIndex)
+ {
+ case IGF_BITRATE_WB_9600:
+ case IGF_BITRATE_RF_WB_13200:
+ case IGF_BITRATE_SWB_9600:
+ case IGF_BITRATE_SWB_13200:
+ case IGF_BITRATE_RF_SWB_13200:
+ case IGF_BITRATE_SWB_16400:
+ case IGF_BITRATE_SWB_24400:
+ case IGF_BITRATE_SWB_32000:
+ case IGF_BITRATE_SWB_48000:
+ *cf_se00 = cf_se00_tab;
+ *cf_se01 = cf_se01_tab[bitRateIndex];
+ *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
+ temp_var = bitRateIndex;
+ if ((bitRateIndex == 0) || (bitRateIndex == 1))
+ {
+ bitRateIndex = 0;
+ }
+ else if ((bitRateIndex == 2) || (bitRateIndex == 3) || (bitRateIndex == 4) || (bitRateIndex == 5))
+ {
+ bitRateIndex = 1;
+ }
+ else if ((bitRateIndex == 6) || (bitRateIndex == 7))
+ {
+ bitRateIndex = 2;
+ }
+ else if (bitRateIndex == 8)
+ {
+ bitRateIndex = 3;
+ }
+ *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
+ move16();
+ bitRateIndex = temp_var;
+ *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
+ move16();
+ *cf_se10 = &cf_se10_tab[0];
+ move16();
+ *cf_off_se10 = cf_off_se10_tab;
+ *cf_se11 = &cf_se11_tab[0][0][0];
+ move16();
+ *cf_off_se11 = &cf_off_se11_tab[0][0];
+ move16();
+ BREAK;
+ case IGF_BITRATE_FB_16400:
+ case IGF_BITRATE_FB_24400:
+ case IGF_BITRATE_FB_32000:
+ bitRateIndex = add(sub(bitRateIndex, IGF_BITRATE_FB_16400), IGF_BITRATE_SWB_16400);
+ *cf_se00 = cf_se00_tab;
+ *cf_se01 = cf_se01_tab[bitRateIndex];
+ *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
+ temp_var = bitRateIndex;
+ if (bitRateIndex == 5)
+ {
+ bitRateIndex = 1;
+ }
+ else if (bitRateIndex == 6 || bitRateIndex == 7)
+ {
+ bitRateIndex = 2;
+ }
+ *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
+ move16();
+ bitRateIndex = temp_var;
+ *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
+ move16();
+ *cf_se10 = &cf_se10_tab[0];
+ move16();
+ *cf_off_se10 = cf_off_se10_tab;
+ *cf_se11 = &cf_se11_tab[0][0][0];
+ move16();
+ *cf_off_se11 = &cf_off_se11_tab[0][0];
+ move16();
+ BREAK;
+ case IGF_BITRATE_FB_48000:
+ bitRateIndex = add(sub(bitRateIndex, IGF_BITRATE_FB_48000), IGF_BITRATE_SWB_48000);
+ *cf_se00 = cf_se00_tab;
+ *cf_se01 = cf_se01_tab[bitRateIndex];
+ *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
+ temp_var = bitRateIndex;
+ bitRateIndex = 3;
+ *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
+ move16();
+ bitRateIndex = temp_var;
+ *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
+ move16();
+ *cf_se10 = &cf_se10_tab[0];
+ move16();
+ *cf_off_se10 = cf_off_se10_tab;
+ *cf_se11 = &cf_se11_tab[0][0][0];
+ move16();
+ *cf_off_se11 = &cf_off_se11_tab[0][0];
+ move16();
+ BREAK;
+ case IGF_BITRATE_FB_96000:
+ case IGF_BITRATE_FB_128000:
+ bitRateIndex = IGF_BITRATE_SWB_48000;
+ move16();
+ *cf_se00 = cf_se00_tab;
+ *cf_se01 = cf_se01_tab[bitRateIndex];
+ *cf_off_se01 = cf_off_se01_tab[bitRateIndex];
+ temp_var = bitRateIndex;
+ bitRateIndex = 3;
+ *cf_se02 = &cf_se02_tab[bitRateIndex][0][0];
+ move16();
+ bitRateIndex = temp_var;
+ *cf_off_se02 = &cf_off_se02_tab[bitRateIndex][0];
+ move16();
+ *cf_se10 = &cf_se10_tab[0];
+ move16();
+ *cf_off_se10 = cf_off_se10_tab;
+ *cf_se11 = &cf_se11_tab[0][0][0];
+ move16();
+ *cf_off_se11 = &cf_off_se11_tab[0][0];
+ move16();
+ BREAK;
+ case IGF_BITRATE_UNKNOWN:
+ default:
+ assert(0);
+ }
+ }
+ return retValue;
+}
+
diff --git a/lib_com/index_pvq_opt_fx.c b/lib_com/index_pvq_opt_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..68297f4c2e275719115c42c1546021c32022cced
--- /dev/null
+++ b/lib_com/index_pvq_opt_fx.c
@@ -0,0 +1,1187 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+#include "basop_util.h"
+#include
+
+#define N_OPT_FX 5 /* complexity setting, direct functional calculation limit & low dim recursion limit */
+#define TABLE_LIM_OPT_FX 96 /* odd divisor table , N-row_recursion limit setting, due to dim */
+
+
+/* local typedefs for optimized pvq indexing, used locally c-file to vectorize common function calls */
+typedef void (*VEC2INDFUNCM) (const Word16* , Word16* , UWord32*, UWord32*);
+typedef UWord32 (*NFUNCM) (Word16);
+typedef UWord32 (*H_FUNCM) ( UWord32 );
+typedef void (*IND2VECFUNCM) ( Word16, Word16, UWord32, Word16* ) ;
+typedef void (*NDIM_FUNCM) ( Word16, Word16, UWord32, Word16* );
+
+/* local constants for indexing functions */
+#define SIGNBIT_FX 0x80000000u
+#define SIGNBIT_SHRT_FX 0x8000
+#define UDIVBY3_FX 2863311531U
+
+/*-------------------------------------------------------------------*
+ * f_odd_exact_div_opt_fx()
+ *
+ * find 1/(den1*2+1) * ( num1p*num2p - num3) ,
+ * if the result is known a priori to be exactly a 32bit UWord32
+ *-------------------------------------------------------------------*/
+static
+UWord32 f_odd_exact_div_opt_fx( /* o : see Eq. */
+ UWord32 num1p, /* i : see Eq. */ /* (2n-1) or n , i.e can be short also */
+ UWord32 num2p, /* i : see Eq. */
+ UWord32 num3, /* i : see Eq. */
+ Word16 den1 /* i : see Eq. */ /*range [0..127] can be made to short */
+)
+{
+ UWord32 UL_tmp;
+ UL_tmp = UL_Mpy_32_32(exactdivodd_fx[den1],UL_subNsD(UL_Mpy_32_32(num1p,num2p),num3));
+
+ return (UL_tmp);
+}
+
+/*---------------------------------------------------------------------------*
+ * f_even_exact_div_opt_fx()
+ *
+ * returns (num1p*num2p - num3 )/ den1
+ * if the result is known a priori to be exactly a 32bit unsigned integer
+ *--------------------------------------------------------------------------*/
+static
+UWord32 f_even_exact_div_opt_fx( /* o : see Eq. */
+ UWord32 UL_num1p, /* i : see Eq. 2n-1 or n can be short input */
+ UWord32 UL_num2p, /* i : see Eq. range should be larger than num1p */
+ UWord32 UL_num3, /* i : see Eq. */
+ Word16 den1 /* i : see Eq. */
+)
+{
+ UWord32 UL_tmp, UL_oddfactor;
+ Word16 den1_m1, even_sh;
+ UWord32 UL_tmp_h;
+ UWord16 sgn;
+
+ den1_m1 = sub(den1,1); /* remove top bit */
+ even_sh = sub(15, norm_s(s_xor(den1_m1, den1))); /* STL signed ops ok as den1 <= 127 */
+
+ UL_oddfactor = exactdivodd_fx[lshr(den1_m1,even_sh)];
+ move32();
+ even_sh = sub(even_sh,1);
+
+
+ Mpy_32_32_uu(UL_num1p, UL_num2p, &UL_tmp_h, &UL_tmp); /* cost ~4 */
+ UL_tmp = UL_subNs(UL_tmp,UL_num3,&sgn); /* may wrap for underflow */
+ if(sgn) /* underflow */
+ {
+ UL_tmp_h = UL_subNsD(UL_tmp_h,1U); /* single basicop -> if */
+ }
+ UL_tmp = UL_or(UL_lshl(UL_tmp_h,sub(32,even_sh)), UL_lshr(UL_tmp,even_sh));
+ /* total cost 9-11 , old solution had 15-16*/
+
+ /* now use tabled modular multiplicative inverse for the odd part division */
+ return UL_Mpy_32_32(UL_tmp, UL_oddfactor);
+}
+
+/* direct calculation functions for smaller dimensions to speed up indexing
+
+N_MPVQ(1,k) = 1;
+N_MPVQ(2,k) = k*2;
+N_MPVQ(3,k) = 1+2*(k^2);
+N_MPVQ(4,k) = k/3 * 4*(k^2+2);
+N_MPVQ(5,k) = 1 + 2*(k*k*(5+k*k))/3;
+N_MPVQ(*,k) = iterations = 1 + A(n,k) + A(n+1,k);
+
+N_PVQ(n,k) = 2*N_MPVQ(n,k);
+
+
+A(1,k) = 1;
+A(2,k) = -1 + 2k;
+A(3,k) = 1+2(k-1)k;
+A(4,k) = 1/3*(((4k-6)k+8)*k-3),
+A(5,k) = 1/3*(3+ k(10+2(k-2)k)k-8);
+A(*,k) = recursive iterations;
+
+
+U(n,k) = (A(n,k)-1)/2;
+U(1,k) = 0;
+U(2,k) = k-1;
+U(3,k) = k*(k-1)
+U(4,k) = (1/3)*((k - 1)*(2*k^2 - k + 3))
+U(5,k) = (1/3)*(k*(k - 1)*(k^2 - k + 4))
+U(*,k) = recursive iterations;
+
+U(n,k) = U(k,n);
+U(n,k) = func(n, U(n,k-1), U(n,k-2) , 1/(k-1) );
+U(n,k) = 1 + U(n-1,k-1) + U(n-1,k) + U(n,k-1);
+U(n,k) = 1 + A(n-1,k-1)>>1 + A(n-1,k)>>1 + A(n,k-1)>>1; A(n,k) is always odd if k>0
+*/
+
+/*-------------------------------------------------------------------*
+ * a_three_fx()
+ *-------------------------------------------------------------------*/
+static
+UWord32 a_three_fx( /* o: offset for dim 3 */
+ UWord32 k_val /* i: nb unit pulses */
+) /* k_val may be higher than 16 bit signed */
+{
+ IF( k_val )
+ {
+ /* return (ONE_U + k_val*((k_val - ONE_U) << ONE)); */
+ return UL_addNsD(1U,UL_Mpy_32_32(k_val,UL_lshl(UL_subNsD(k_val,1U),1)));
+ }
+ ELSE
+ {
+ return 0;
+ }
+}
+
+/*-------------------------------------------------------------------*
+ * a_four_fx()
+ *-------------------------------------------------------------------*/
+static
+UWord32 a_four_fx( /* o: offset for dim 4 */
+ UWord32 k_val /* i: nb unit pulses */
+)
+{
+ UWord32 UL_2k;
+ IF(k_val)
+ {
+ /* return UDIVBY3*((k_val<0,k=0) */
+ h_mem[1] = UL_deposit_l(1); /* A(*,k=1) */
+
+ UL_k_val_in = UL_deposit_l(k_val_in);
+ IF(EQ_16(dim_in,2))
+ {
+ FOR( k_val = 2 ; k_val <= UL_k_val_in ; k_val++ )
+ {
+ h_mem[k_val] = UL_subNsD(UL_lshl(k_val,1),1U);
+ move32(); /* A(2, 2 .. k ) */
+ }
+ h_mem[k_val] = UL_k_val_in;
+ move32(); /* U(2,k+1) */
+ }
+ ELSE
+ {
+ k_val_prev = UL_deposit_l(1U);
+ FOR(k_val_curr = 2; k_val_curr<=UL_k_val_in; k_val_curr++)
+ {
+ h_mem[k_val_curr] = UL_addNsD(1U , UL_Mpy_32_32(k_val_curr, UL_lshl(k_val_prev,1)));
+ move32();
+ k_val_prev = UL_addNsD(k_val_curr, 0U); /* 1 op*/
+ }
+ h_mem[k_val_curr] = UL_Mpy_32_32(k_val_curr,k_val_prev);
+ move32(); /* % U(3,k_val_in+1) u_three(k+1) */
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * a_fwd_fx()
+ *
+ * create offsets for A(n,k) from lower A(n-1,k)
+ *-------------------------------------------------------------------*/
+static
+void a_fwd_fx(
+ UWord32 *a_in, /* i/o: offsets */
+ Word16 n_items /* i : items, k's */
+)
+{
+ UWord32 a_1, a_in0 ;
+ Word16 i ;
+ UWord32* a_in_prev_ptr;
+
+ a_in0 = UL_deposit_l(1);
+
+ a_in_prev_ptr=&(a_in[-1]); /* single loop ptr setup not counted; */
+ FOR(i=1; i<=n_items; i++) /* basic A fwd row recursion */
+ {
+ a_1 = UL_addNsD(a_in0, UL_addNsD(a_in_prev_ptr[i], a_in[i])) ;
+ a_in_prev_ptr[i] = a_in0;
+ move32();
+ a_in0 = UL_addNsD(a_1, 0U);
+ }
+ a_in_prev_ptr[i] = a_in0;
+ move32();
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * a_bwd_fx()
+ *
+ * create offsets for A(n,k) from higher A(n+1,k)
+ *-------------------------------------------------------------------*/
+static
+void a_bwd_fx(
+ UWord32 *a_in, /* i/o: offsets */
+ Word16 n_items /* i: n_items */
+)
+{
+ UWord32 a_1, a_in0;
+ Word16 i;
+ UWord32* a_in_prev_ptr;
+
+ a_in0 = UL_deposit_l(0);
+ a_in_prev_ptr = &(a_in[-1]);
+
+ FOR(i = 1; i<=n_items; i++) /*basic A reverse row recursion */
+ {
+ /* 2x[i] ptr memory access below are treated as ptr access */
+ a_1 = UL_subNsD(UL_subNsD(a_in[i], a_in0), a_in_prev_ptr[i]);
+ a_in_prev_ptr[i] = a_in0;
+ move32();
+ a_in0 = UL_addNsD(a_1, 0U);
+
+ }
+ a_in_prev_ptr[i] = a_in0;
+ move32();
+ return;
+}
+
+static
+UWord32 direct_row_A2U_rec_calc_fx(Word16 dim_in , Word16 k_val_in, UWord32 a_km2, UWord32 a_km1)
+{
+ /* U(n,k) = (A(n,k-2)-1)/2 + ((2*n-1)*A(n,k-1) - A(n,k-2) )/2*(k-1) */
+ /* U(n,k) = floor(A(n,k-2)/2) + (n*A(n,k-1) - floor(A(n,k-1)/2) - floor(A(n,k-2)/2) +1 )/(k-1) */
+ /* U(n,k) = floor(A(n,k-2)/2) + (n*A(n,k-1) - (floor(A(n,k-1)/2) + floor(A(n,k-2)/2) +1) )/(k-1) */
+
+ UWord32 km2_size, UL_um2, UL_dim ;
+ Word16 divisor;
+
+ divisor = sub(k_val_in,1);
+ UL_um2 = UL_lshr(a_km2,1U);
+ UL_dim = UL_deposit_l(dim_in);
+ km2_size = UL_addNsD(UL_addNsD(UL_lshr(a_km1,1), UL_um2), 1U);
+ IF(s_and(divisor,0x1) != 0)
+ {
+ /* odd */
+ return UL_addNsD(UL_um2, f_odd_exact_div_opt_fx( UL_dim, a_km1, km2_size, shr(divisor,1)));
+ }
+ ELSE
+ {
+ /* even divisor, */
+ return UL_addNsD(UL_um2, f_even_exact_div_opt_fx(UL_dim, a_km1, km2_size, divisor));
+ }
+}
+
+static
+void a_u_fwd_fx(UWord32 *a_u_in,
+ Word16 k_val_in,
+ Word16 mem_size_m1)
+{
+ UWord32 u_kp1_prev, u_kp1;
+ UWord32 u_k_prev ;
+
+ u_kp1_prev = a_u_in[mem_size_m1];
+ move32(); /* previous n U (n,k+1) value*/
+ u_k_prev = UL_lshr(a_u_in[k_val_in],1); /* previous n A(n,k) value*/
+
+ a_fwd_fx(&a_u_in[1], k_val_in); /* a_u_in[k==ZERO] = zero if n>0 */
+
+ /* low dynamic last offset entry mixed recursion */
+ /* used for size calculation */
+ /* U(n,k+1) = 1 + U(n-1,k+1) + U(n-1,k) + U(n,k) */
+ /* U(n,k+1) = 1 + U(n-1,k+1) + (A(n-1,k)-1)/2 + (A(n,k)-1)/2 */
+ /* Note, A(n,k) always odd for k>0 , subtracted one always shifted out */
+
+ u_kp1 = UL_lshr(a_u_in[k_val_in],1);
+ a_u_in[mem_size_m1] = UL_addNsD(1U, UL_addNsD(u_kp1_prev, UL_addNsD(u_k_prev,u_kp1)));
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * nm_h_prep_opt_fx()
+ *
+ * find and return N_MPVQ(n,k) and also offsets A(n, 0 to k ) and U(n,k+1).
+ *-------------------------------------------------------------------*/
+static
+UWord32 nm_h_prep_opt_fx( /* o: msize for dim */
+ Word16 dim_in, /* i: dimension */
+ Word16 k_val_in, /* i: nb unit pulses */
+ UWord32 *h /* o: A/U offsets array */
+)
+{
+ Word16 mem_size_m1, k_val,tmp ;
+ Word16 dim_tmp, d_start;
+ UWord32 h_saveA, h_saveB, u_kp1,a_k; /* registers for alternating A(n,k-1), A(n,k-2)*/
+ UWord32 numDsub1;
+ Word16 end_loop, add_last_odd ;
+
+ h[0] = UL_deposit_l(0); /* % A(=>0,k=0) */
+ h[1] = UL_deposit_l(1); /* % A(*,k=1) */
+
+ mem_size_m1 = add(k_val_in,1);
+
+ assert(dim_in > N_OPT_FX); /* code now optimized with direct functions for dim <= N_OPT_FX ) */
+ IF( (GT_16(k_val_in, TABLE_LIM_OPT_FX)))
+ {
+ d_start = 2;
+ move16();
+ if( GE_16(dim_in,3))
+ {
+ /* start from A(3), U(3) */
+ d_start = 3;
+ move16(); /* single op */
+ }
+ initOffsets_fx(d_start, h, k_val_in);
+ FOR(dim_tmp = d_start; dim_tmp < dim_in; dim_tmp++)
+ {
+ a_u_fwd_fx(h, k_val_in, mem_size_m1);
+ }
+ a_k = h[k_val_in];
+ move32();
+ u_kp1 = h[mem_size_m1];
+ move32();
+ }
+ ELSE
+ {
+ numDsub1 = UL_deposit_l(sub(shl(dim_in,1),1));
+ h[2] = numDsub1;
+ move32();
+
+ /* interleaved " odd, even [odd]" divisor calls */
+ h_saveA = numDsub1;
+ move32();
+ h_saveB = UL_deposit_l(1);
+
+ /* OPT: makes sure that the STL FOR loop is not broken */
+ tmp = sub(k_val_in,3);
+ add_last_odd = 0;
+ move16() ; /*k_val_in=0 1 2*/
+ if(tmp == 0)
+ {
+ add_last_odd = 1;
+ move16(); /*k_val_in =3 */
+ }
+ k_val = 3;
+ move16();
+ IF( tmp > 0 )
+ {
+ /* k_val_in = 3,4, 5,6, 7 ... */
+ end_loop = mem_size_m1;
+ move16();
+ add_last_odd = s_and(k_val_in,0x1) ;
+ move16(); /* odd -> 0x00100*/
+ /* even loop limits, and odd tail exists , and */
+ if(NE_16(add_last_odd,0))
+ {
+ end_loop = sub(end_loop,1); /* make initial loop to even number of (odd-even )pairs *//* one basicop */
+ }
+ FOR(k_val = 3; k_val < end_loop ; k_val++ )
+ {
+ /* the optimized non broken loop k=(3,4)(5,6)...(odd,even)*/
+ /* A(n,k) = A(n,k-2) + ((2*n-1)*A(n,k-1)-A(n,k-2)) /(k-1) */
+ /* first odd k, even divisor */
+ h_saveB = UL_addNsD(h_saveB, f_even_exact_div_opt_fx(numDsub1, h_saveA, h_saveB, sub(k_val,1)));
+ h[k_val] = h_saveB;
+ move32();
+
+ /* next even k, odd divisor */
+ /*k_val++; */
+ h_saveA = UL_addNsD(h_saveA, f_odd_exact_div_opt_fx(numDsub1, h_saveB, h_saveA,shr(k_val,1)));
+ k_val++; /* ptr incr */
+ h[k_val] = h_saveA;
+ move32();
+ }
+ }
+
+ if(NE_16(add_last_odd,0))
+ {
+ /* add a last odd call as needed , not to be called if k_val_in is [0,1,2] */
+ h_saveB = UL_addNsD(h_saveB,f_even_exact_div_opt_fx(numDsub1, h_saveA, h_saveB, sub(k_val,1)));
+ h[k_val_in] = h_saveB;
+ move32();
+ }
+
+ /* always do the last (k+1) recursion based on U(n,k+1) = func( A(n-2,k+1), A(n-1,k+1) ) */
+ a_k = h[k_val_in] ;
+ move32();
+ u_kp1 = direct_row_A2U_rec_calc_fx(dim_in, mem_size_m1 , h[sub(mem_size_m1,2)], a_k );
+ h[mem_size_m1] = u_kp1;
+ move32();
+ }
+
+ /* N_MPVQ(n,k) = 1 + U(n,k+1) + U(n,k) = 1 + U(n,k+1) + floor(A(n,k))/2) ; */ /* as A(n,k) always odd */
+ return ( UL_addNsD(1U, UL_addNsD(u_kp1, UL_lshr(a_k,1))));
+}
+
+/*
+ find_amp_split_offset_func_mem_fx()
+ find first offset in range 0..k_val_in that is less than ind_in
+ using a tree search with direct function calls [ or memory iteration]
+*/
+static
+Word16 find_amp_split_offset_func_mem_fx( /* o: found k_value */
+ UWord32 ind_in,
+ Word16 high, /* i: k_val_in (high bound) */
+ H_FUNCM h_func_ptr, /* i: offset function pointer */
+ UWord32 *UL_tmp_offset) /* o: offset found */
+{
+ Word16 not_ready, low, k_test=0;
+ UWord16 sgn ;
+ UWord32 UL_tmp;
+ /* split over A(n,k) = h_mem(k), or use direct A function evaluation */
+
+ low = 0;
+ move16();
+ move32(); /* account for adaptive function ptr setup */
+ not_ready = 1 ;
+ move16();
+
+ WHILE( not_ready != 0)
+ {
+ k_test = shr(add(low,high),1); /*% split range in half */
+ *UL_tmp_offset = (*h_func_ptr)(UL_deposit_l(k_test)); /* call direct A offset-function */
+
+ UL_tmp = UL_subNs(*UL_tmp_offset, ind_in, &sgn );
+ IF ( sgn )
+ {
+ /* (*tmp_offset < ind_in) */
+ low = add(1, k_test) ;
+ if( GE_16(k_test ,high))
+ {
+ not_ready = 0;
+ move16(); /* single basicop */
+ }
+ }
+ ELSE
+ {
+ /* (ind_in <= *tmp_offset ) */
+ high = sub(k_test,1);
+ if( UL_tmp == 0)
+ {
+ /* (*tmp_offset == ind_in) */
+ not_ready = 0;
+ move16(); /* single basicop */
+ }
+ }
+ }
+ return k_test;
+}
+
+/*
+ get_lead_sign_fx()
+ updated index and return leading sign
+*/
+static
+Word16 get_lead_sign_fx(UWord32 *ind)
+{
+ Word16 leading_sign;
+
+ leading_sign = 1;
+ move16();
+ if( UL_and(*ind,1) != 0 )
+ {
+ /* leading sign stored in LSB */
+ leading_sign = -1;
+ move16();
+ }
+ (*ind) = UL_lshr(*ind,1);
+
+ return leading_sign;
+}
+
+/*-------------------------------------------------------------------*
+ * mind2vec_one_fx()
+ *-------------------------------------------------------------------*/
+static
+void mind2vec_one_fx(
+ Word16 k_val_in, /* i: nb unit pulses */
+ Word16 leading_sign, /* i: leading sign -1, 0, 1*/
+ UWord32 ind, /* i: index */ /* parameter needed as it is used in a function array */
+ Word16* vec_out /* o: pulse train */
+)
+{
+ /* NB input k_val_in can be zero */
+ /* *vec_out = leading_sign*k_val_in; */
+ *vec_out = (Word16)ind; /* dummy assignment to avoid gcc "unused parameter" warning for ind, i.e no move16() needed */
+
+ /* *vec_out = extract_l(L_mult0(leading_sign,k_val_in)); move16(); // 3 ops */
+ if( leading_sign < 0 )
+ {
+ k_val_in = negate(k_val_in); /* single basicop --> if */
+ }
+ *vec_out = k_val_in;
+ move16(); /* 1 op */
+}
+
+static
+void mind2vec_two_fx(
+ Word16 k_val_in, /* i: nb unit pulses */
+ Word16 leading_sign, /* i: leading sign -1,0, 1 */
+ UWord32 ind_in, /* i: index */
+ Word16 *vec_out /* o: pulse train */
+)
+{
+ UWord32 UL_ind_tmp;
+ Word16 val1;
+
+ IF (ind_in == 0)
+ {
+ /* ind_in == 0 */
+ mind2vec_one_fx( k_val_in,leading_sign,ind_in,vec_out);
+ }
+ ELSE IF ( EQ_16((Word16)u_extract_l(ind_in), sub(shl(k_val_in,1),1)))
+ {
+ /* signed ops fine as 2*KMAX << 32767) */
+ /* (ind_in == ( (unsigned int)(k_val_in<dim; i++)
+ {
+ vec_out[i]=0;
+ move16(); /* set all of short vector to zero , required for fast/early exit logic */
+ }
+
+ leading_sign = 1;
+ move16();
+ if(entry->lead_sign_ind != 0)
+ {
+ leading_sign = -1;
+ move16();
+ }
+
+ IF(entry->k_val != 0)
+ {
+ IF(GT_16(entry->dim,N_OPT_FX)) /* N_OPT_FX */
+ {
+ /* generic */
+ mind2vec_fx(entry->dim, entry->k_val, leading_sign, entry->index, vec_out, h_mem);
+ }
+ ELSE
+ {
+ /* specialized functions, with direct offset calculations */
+ (mind2vec_f_fx[entry->dim])(entry->k_val, leading_sign, entry->index, vec_out);
+ }
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+* vec2mind_one_fx()
+*-------------------------------------------------------------------*/
+static
+void vec2mind_one_fx(
+ const Word16* vec_in, /* i : PVQ pulse train */
+ Word16 *k_val_out_ptr , /* o : number of unit pulses */ /* parameter needed as it is used in a function array */
+ UWord32 *next_sign_ind, /* i/o: next sign ind */
+ UWord32* ind /* o: MPVQ index */
+)
+{
+ *ind = (Word32)(*k_val_out_ptr) ; /* dummy assignment to avoid gcc "unused parameter" warning for *k_val_out_ptr, i.e no move32 needed() */
+ *ind = UL_deposit_l(0);
+
+ *next_sign_ind = UL_deposit_l(0);
+ if( *vec_in < 0 )
+ {
+ *next_sign_ind = UL_deposit_l(1); /*single basicop */
+ }
+ return ;
+}
+
+/*-------------------------------------------------------------------*
+* vec2mind_two_fx()
+*-------------------------------------------------------------------*/
+static
+void vec2mind_two_fx(
+ const Word16* vec_in, /* i : PVQ pulse train */
+ Word16 *k_val_out_ptr , /* o : number of unit pulses */
+ UWord32 *next_sign_ind, /* i/o: next sign ind */
+ UWord32* ind /* o: MPVQ index */
+)
+{
+ UWord32 lead_sign_ind_add;
+ Word16 abs0,abs1,abs01,sptr;
+
+ abs0 = abs_s(vec_in[0]);
+ abs1 = abs_s(vec_in[1]);
+ abs01 = add(abs0, abs1);
+ *k_val_out_ptr = abs01;
+ move16(); /* can be zero */
+ *ind = UL_deposit_l(0); /* [KMAX 0 ] , and dual zeros */
+
+ *next_sign_ind = UL_deposit_h(SIGNBIT_SHRT_FX); /* "unset" sign flag set */ /* dual zeroes can happen in a recursive encoding call */
+
+
+ IF( abs01 != 0 )
+ {
+ sptr = 0;
+ move16(); /*used as ptr to vec0 or vec1 value */
+ *next_sign_ind = UL_deposit_l(sptr);
+
+ test();
+ IF(abs0 != 0 && abs1 != 0 )
+ {
+ /* likely most frequent/common case */
+ /* [ KMAX-1 1],[ KMAX-1 -1] ... [ 1 +(KMAX-1) ],[ 1 -(KMAX-1)] */
+ /* sign always shifted to first pos */
+ lead_sign_ind_add = UL_deposit_l(1) ;
+ if( vec_in[1] < 0)
+ {
+ lead_sign_ind_add = UL_deposit_l(2); /* single op */
+ }
+ *ind = UL_addNsD(UL_deposit_l((UWord16)lshl(sub(abs1,1),1)),lead_sign_ind_add);
+ }
+ ELSE
+ {
+ /* one value is a zero */
+ IF( abs0 == 0 )
+ {
+ /* [ 0 KMAX]*/
+ *ind = UL_deposit_l((UWord16) sub(lshl(abs1,1),1));
+ sptr = 1;
+ move16();
+ }
+ }
+
+ /* *next_sign_ind= (unsigned int)(vec_in[*next_sign_ind]<0); */
+ if( vec_in[sptr] < 0 )
+ {
+ *next_sign_ind = UL_deposit_l(1); /*single instruction */
+ }
+ }
+ return;
+}
+
+static
+void enc_push_sign(Word16 val, UWord32* next_sign_ind, UWord32 *index)
+{
+ /*
+ % Check if the leading sign 'bit' is to be added
+ % here the leading sign bit is put in LSB as it saves about 3 cycles in sign-decoding
+ % (one can also put it in the MSB , but then one needs to access h_mem twice and shift the sign bit into position )
+ */
+ test();
+ IF( (UL_and(*next_sign_ind,SIGNBIT_FX) == 0) && (val != 0))
+ {
+ *index = UL_addNsD(UL_lshl(*index,1),*next_sign_ind);
+ }
+
+ /* push sign to next non_zero position */
+ /* *next_sign_ind = *next_sign_ind ;*/ /* default is to keep stored sign index */
+ if( val < 0 )
+ {
+ *next_sign_ind = UL_deposit_l(1); /* single basicop */
+ }
+ if( val > 0)
+ {
+ *next_sign_ind = UL_deposit_l(0); /* single basicop */
+ }
+}
+
+/*-------------------------------------------------------------------*
+ * vec2mind_gen345_fx( vec_in kval, next_dim_func , offset_func,....)
+ * generic call saves PROM ,
+ *-------------------------------------------------------------------*/
+
+static
+void vec2mind_gen345_fx(
+ const Word16* vec_in, /* i : PVQ abs pulse train */
+ Word16 *k_val_out_ptr, /* o : number of unit pulses */
+ UWord32 *next_sign_ind , /* i/o: next sign ind */
+ UWord32* index , /* o: MPVQ index */
+ VEC2INDFUNCM vec2indfunc_ptr, /* i: */
+ H_FUNCM a_func_ptr /*i: offset function */
+)
+{
+ Word16 tmp_val;
+
+ tmp_val = vec_in[0];
+ move16();
+ move32(); /* adaptive function call setup */
+ (*vec2indfunc_ptr)(&vec_in[1], k_val_out_ptr, next_sign_ind, index);
+
+ enc_push_sign(tmp_val, next_sign_ind, index);
+
+ move32(); /* adaptive function call setup */
+ *index = UL_addNsD(*index,(*a_func_ptr)(UL_deposit_l(*k_val_out_ptr)));
+
+ *k_val_out_ptr = add(*k_val_out_ptr, abs_s(tmp_val));
+
+ return ;
+}
+
+/*-------------------------------------------------------------------*
+ * vec2mind_three_fx()
+ *-------------------------------------------------------------------*/
+static
+void vec2mind_three_fx(
+ const Word16* vec_in, /* i : PVQ pulse train */
+ Word16* k_val_out_ptr, /* o : number of unit pulses */
+ UWord32 *next_sign_ind, /* i/o: next sign ind */
+ UWord32 *index /* o: MPVQ index */
+)
+{
+ vec2mind_gen345_fx(vec_in,k_val_out_ptr, next_sign_ind, index, vec2mind_two_fx, a_three_fx);
+ return ;
+}
+
+
+/*-------------------------------------------------------------------*
+ * vec2mind_four_fx()
+ *-------------------------------------------------------------------*/
+static
+void vec2mind_four_fx(
+ const Word16* vec_in, /* i : PVQ pulse train */
+ Word16* k_val_out_ptr, /* o : number of unit pulses */
+ UWord32* next_sign_ind , /* i/o: next sign ind */
+ UWord32* index /* o: MPVQ index */
+)
+{
+ vec2mind_gen345_fx(vec_in, k_val_out_ptr, next_sign_ind, index, vec2mind_three_fx, a_four_fx);
+ return ;
+}
+
+/*-------------------------------------------------------------------*
+ * vec2mind_five_fx()
+ *-------------------------------------------------------------------*/
+static
+void vec2mind_five_fx(
+ const Word16* vec_in, /* i : PVQ abs pulse train */
+ Word16 *k_val_out_ptr, /* o : number of unit pulses */
+ UWord32 *next_sign_ind , /* i/o: next sign ind */
+ UWord32* index /* o: MPVQ index */
+)
+{
+ vec2mind_gen345_fx(vec_in,k_val_out_ptr, next_sign_ind, index, vec2mind_four_fx, a_five_fx);
+ return ;
+}
+
+/*-------------------------------------------------------------------*
+* vec2mind_fx()
+*-------------------------------------------------------------------*/
+static
+void vec2mind_fx(Word16 dim_in, /* i : dim */
+ Word16 k_val_in, /* i : number of unit pulses */
+ const Word16* vec_in, /* i : PVQ pulse train */
+ UWord32 *next_sign_ind, /* o : pushed leading sign */
+ UWord32 *index , /* o : MPVQ index */
+ UWord32 *N_MPVQ_ptr, /* o : size(N_MPVQ(dim,K_val_in))*/
+ UWord32* h_mem) /* o : offsets */
+{
+ Word16 pos, mem_size_m1, k_val_acc, tmp_val;
+ UWord32 tmp_h;
+
+ /*
+ %% main steps
+ % quick encode two rightmost pos
+ % for every position from dim-3 to 0 (right to left)
+ % check if an sign is to be encoded ,
+ % add its offset
+ % check(and add) amplitude offset(for accumulated pulse sum) up to this point
+ % update total pulse sum
+ % update offset vector recursively (except for pos==0 )
+ % end
+ % calculate size
+ */
+
+ mem_size_m1 = add(k_val_in,1);
+ *next_sign_ind = UL_deposit_h(SIGNBIT_SHRT_FX); /* highest bit set signals no sign found yet, should always be 0 or 1 out, */
+
+ pos = sub(dim_in,2); /* adress 2nd last sample */
+ vec2mind_two_fx(&vec_in[pos],&k_val_acc,next_sign_ind ,index);
+ initOffsets_fx( 3, h_mem, k_val_in) ; /* start recursions at 3rd sample */
+
+ tmp_h = h_mem[k_val_acc];
+ move32();
+ FOR (pos--; pos>=0; pos--)
+ {
+ tmp_val = vec_in[pos];
+ move16();
+ enc_push_sign(tmp_val, next_sign_ind, index);
+
+ /* now add indexing offset up to this reverse (r_l) accumulated amplitude point */
+ *index = UL_addNsD(*index, tmp_h); /* k_val_acc==0 ==>0 */
+
+ /* k_val_acc = k_val_acc + vec_abs[pos];*/ /* now increase acc k value for next N */
+ k_val_acc = add(k_val_acc, abs_s(tmp_val));
+
+ IF( pos != 0 )
+ {
+ a_u_fwd_fx(h_mem, k_val_in ,mem_size_m1);
+ /* update A(n,k=1:k_val_in) and U(n,k_val_in+1) */
+ /* NB here (k_val_in + 2 elements always has to be updated */
+ }
+ tmp_h = UL_addNsD(h_mem[k_val_acc], 0U);
+ }
+
+ /* size is needed for the subseqent arithmetic encoding/transmission of the index.
+ use relation N_MPVQ(n,K) = 1 + (A(n, K)-1)/2 + U(n, 1 + K)
+ = N_MPVQ(n,K) = 1 + (A(n, K)>>1) + U(n, 1 + K) , as A(n,K) is odd) */
+ *N_MPVQ_ptr = UL_addNsD(1U,UL_addNsD(UL_lshr(tmp_h,1),h_mem[ mem_size_m1]));
+ move32();/* calc total size */
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * mpvq_encode_vec_fx()
+ *
+ * returns struct with lead sign index, MPVQ-index, dim and N_MPVQ size
+ *-------------------------------------------------------------------------*/
+
+PvqEntry_fx mpvq_encode_vec_fx( /* o : leading_sign_index, index, size, k_val */
+ const Word16* vec_in, /* i : signed pulse train */
+ Word16 dim_in, /* i : dimension */
+ Word16 k_val_local /* i : nb unit pulses */
+)
+{
+ PvqEntry_fx result;
+ UWord32 h_mem[ 1 + KMAX_NON_DIRECT_FX + 1 ] ; /* now always assign max offset buffer for dim 6 ,
+ actually only 1+k_val_in+1 needed ) */
+ UWord32 lead_sign_ind;
+
+ VEC2INDFUNCM vec2mind_f[1+N_OPT_FX] = { (VEC2INDFUNCM)NULL, vec2mind_one_fx, vec2mind_two_fx, vec2mind_three_fx, vec2mind_four_fx, vec2mind_five_fx };
+
+ result.k_val = k_val_local;
+ move16();
+ result.dim = dim_in;
+ move16();
+ /* NB , k_val_local may be changed in some sub encoding routines */
+ IF( GT_16(dim_in, N_OPT_FX))
+ {
+ /* use the generic dimension function */
+ vec2mind_fx(dim_in, k_val_local, vec_in, &lead_sign_ind, &result.index, &result.size, h_mem);
+ }
+ ELSE /* if (dim_in<=N_OPT), h_mem not used */
+ {
+ move32(); /* adaptive function ptr setup */
+ (vec2mind_f[dim_in])(vec_in, &k_val_local, &lead_sign_ind, &result.index);
+ result.size = direct_msize_fx(dim_in, k_val_local);
+ }
+ result.lead_sign_ind = u_extract_l(lead_sign_ind);
+
+ return result;
+}
+
+
diff --git a/lib_com/int_lsp_fx.c b/lib_com/int_lsp_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f431ae38f5615693549c7c300716b7f7da068f91
--- /dev/null
+++ b/lib_com/int_lsp_fx.c
@@ -0,0 +1,173 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "stl.h"
+
+/*========================================================================*/
+/* FUNCTION : int_lsp4_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Interpolate LSPs find the A[z] parameters for all subframes */
+/* by interpolating between old end-frame LSPs, current */
+/* mid-frame LSPs and current end-frame LSPs */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) L_frame : length of the frame */
+/* _ (Word16) m : order of LP filter */
+/* _ (Word16) clas : signal frame class */
+/* _ (Word16[]) lsp_old : LSPs from past frame Q15 */
+/* _ (Word16[]) lsp_mid : LSPs from mid-frame Q15 */
+/* _ (Word16[]) lsp_new : LSPs from present frame Q15 */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) Aq : LP coefficients in both subframes Q12 */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*========================================================================*/
+void int_lsp4_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/
+ const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/
+ const Word16 lsp_new[], /* i : LSPs from present frame Q15*/
+ Word16 *Aq, /* o : LP coefficients in both subframes Q12*/
+ const Word16 m, /* i : order of LP filter */
+ Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
+)
+{
+ Word16 lsp[M16k];
+ Word16 i,j, k;
+ Word32 L_tmp;
+ const Word16 *pt_int_coeffs;
+
+ IF( EQ_16(L_frame,L_FRAME))
+ {
+ IF ( EQ_16(relax_prev_lsf_interp,1))
+ {
+ pt_int_coeffs = interpol_frac_mid_relaxprev_12k8_fx;
+ }
+ ELSE IF ( EQ_16(relax_prev_lsf_interp,2))
+ {
+ pt_int_coeffs = interpol_frac_mid_FEC_fx;
+ }
+ ELSE IF ( EQ_16(relax_prev_lsf_interp,-1))
+ {
+ pt_int_coeffs = interpol_frac_mid_relaxprev_pred_12k8_fx;
+ }
+ ELSE
+ {
+ pt_int_coeffs = interpol_frac_mid_fx;
+ }
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ IF ( EQ_16(relax_prev_lsf_interp,1))
+ {
+ pt_int_coeffs = interpol_frac_mid_relaxprev_16k_fx;
+ }
+ ELSE IF ( EQ_16(relax_prev_lsf_interp,2))
+ {
+ pt_int_coeffs = interpol_frac_mid_16k_FEC_fx;
+ }
+ ELSE IF ( EQ_16(relax_prev_lsf_interp,-1))
+ {
+ pt_int_coeffs = interpol_frac_mid_relaxprev_pred_16k_fx;
+ }
+ ELSE
+ {
+ pt_int_coeffs = interpol_frac_mid_16k_fx;
+ }
+ }
+ k = sub(shr(L_frame,6),1);
+ FOR( j=0; jcore_brate_fx,SID_1k75))
+ {
+
+ indice[0] = (Word16)get_next_indice_fx( st, 6 );
+ move16();
+ indice[1] = (Word16)get_next_indice_fx( st, 6 );
+ move16();
+ indice[2] = (Word16)get_next_indice_fx( st, 6 );
+ move16();
+ indice[3] = (Word16)get_next_indice_fx( st, 5 );
+ move16();
+ indice[4] = (Word16)get_next_indice_fx( st, 5 );
+ move16();
+
+ disf_ns_28b_fx( indice, isf_new );
+
+ reorder_isf_fx( isf_new, ISF_GAP_FX, M, Fs_2);
+
+ E_LPC_isf_isp_conversion( isf_new, isp_new, M);
+ /* return if SID frame (conversion to A(z) done in the calling function) */
+ return;
+ }
+
+ /*-----------------------------------------------------------------*
+ * ISF de-quantization of all other frames
+ *-----------------------------------------------------------------*/
+
+ IF( EQ_32(st->core_brate_fx,ACELP_6k60))
+ {
+ indice[0] = (Word16)get_next_indice_fx( st, 8 );
+ move16();
+ indice[1] = (Word16)get_next_indice_fx( st, 8 );
+ move16();
+ indice[2] = (Word16)get_next_indice_fx( st, 7 );
+ move16();
+ indice[3] = (Word16)get_next_indice_fx( st, 7 );
+ move16();
+ indice[4] = (Word16)get_next_indice_fx( st, 6 );
+ move16();
+
+ disf_2s_36b_fx( indice, isf_new, st->mem_AR_fx, st->mem_MA_fx, 1 );
+ }
+ ELSE
+ {
+ indice[0] = (Word16)get_next_indice_fx( st, 8 );
+ move16();
+ indice[1] = (Word16)get_next_indice_fx( st, 8 );
+ move16();
+ indice[2] = (Word16)get_next_indice_fx( st, 6 );
+ move16();
+ indice[3] = (Word16)get_next_indice_fx( st, 7 );
+ move16();
+ indice[4] = (Word16)get_next_indice_fx( st, 7 );
+ move16();
+ indice[5] = (Word16)get_next_indice_fx( st, 5 );
+ move16();
+ indice[6] = (Word16)get_next_indice_fx( st, 5 );
+ move16();
+
+ disf_2s_46b_fx( indice, isf_new, st->mem_AR_fx, st->mem_MA_fx,1 );
+ }
+ reorder_isf_fx( isf_new, ISF_GAP_FX, M, Fs_2 );
+ /* convert quantized ISFs to ISPs */
+ E_LPC_isf_isp_conversion( isf_new, isp_new, M);
+
+ /*-------------------------------------------------------------------------------------*
+ * FEC - update adaptive mean ISF vector
+ *-------------------------------------------------------------------------------------*/
+
+ FOR ( i=0; ilsf_adaptive_mean[i] = (st->lsfoldbfi1[i] + st->lsfoldbfi0[i] + isf_new[i]) / 3;*/
+ L_tmp = L_mult(st->lsfoldbfi1_fx[i], 10923);
+ L_tmp = L_mac(L_tmp, st->lsfoldbfi0_fx[i], 10923);
+ st->lsf_adaptive_mean_fx[i] = round_fx(L_mac(L_tmp, isf_new[i], 10923));
+ }
+
+ /*-------------------------------------------------------------------------------------*
+ * ISP interpolation
+ * A(z) calculation
+ *-------------------------------------------------------------------------------------*/
+
+ if(st->rate_switching_reset)
+ {
+ /*extrapolation instead of interpolation*/
+ Copy(isp_new, st->lsp_old_fx, M);
+ Copy(isf_new, st->lsf_old_fx, M);
+ }
+
+ /* ISP interpolation and A(z) calculation */
+ int_lsp_fx( L_FRAME, st->lsp_old_fx, isp_new, Aq, M, interpol_isp_amr_wb_fx, 1 );
+
+ /*------------------------------------------------------------------*
+ * Check ISF stability : distance between old ISF and current ISF
+ *------------------------------------------------------------------*/
+
+ st->stab_fac_fx = lsf_stab_fx( isf_new, st->lsf_old_fx, 1, st->L_frame_fx );
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * disf_ns_28b()
+ *
+ * ISF de-quantizer for SID_1k75 frames (only for AMR-WB IO mode)
+ *-------------------------------------------------------------------*/
+
+void disf_ns_28b_fx(
+ Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
+ Word16 *isf_q /* o : ISF in the frequency domain (0..6400) */
+)
+{
+ Word16 i;
+
+ FOR (i = 0; i < 2; i++)
+ {
+ isf_q[i] = dico1_ns_28b_fx[indice[0]*2+i];
+ move16();
+ }
+
+ FOR (i = 0; i < 3; i++)
+ {
+ isf_q[i+2] = dico2_ns_28b_fx[indice[1]*3+i];
+ move16();
+ isf_q[i+5] = dico3_ns_28b_fx[indice[2]*3+i];
+ move16();
+ }
+
+ FOR (i = 0; i < 4; i++)
+ {
+ isf_q[i+8] = dico4_ns_28b_fx[indice[3]*4+i];
+ move16();
+ isf_q[i+12] = dico5_ns_28b_fx[indice[4]*4+i];
+ move16();
+ }
+
+ FOR (i=0; i
+#include "prot_fx.h"
+#include "rom_com_fx.h"
+#include "basop_util.h"
+#include "stl.h"
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+#define kLagWinThGain1 19661 /* 0.6f in Q15 */
+#define kLagWinThGain2 9830 /* 0.3f in Q15 */
+
+/*-------------------------------------------------------------*
+ * procedure lag_wind: *
+ * ~~~~~~~~~ *
+ * lag windowing of the autocorrelations *
+ *-------------------------------------------------------------*/
+
+void lag_wind(
+ Word16 r_h[], /* in/out: autocorrelations */
+ Word16 r_l[], /* in/out: autocorrelations */
+ Word16 m, /* input : order of LP filter */
+ Word32 sr, /* input : sampling rate */
+ Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
+)
+{
+ Word16 i;
+ Word32 tmp;
+ const Word16 *wnd_h, *wnd_l;
+
+
+ assert(0 <= strength && strength <= NUM_LAGW_STRENGTHS);
+ SWITCH (sr)
+ {
+ case 8000:
+ assert(m <= 16);
+ assert(strength == LAGW_STRONG);
+ wnd_h = lag_window_8k[0];
+ wnd_l = lag_window_8k[1];
+ BREAK;
+ case 12800:
+ assert(m <= 16);
+ wnd_h = lag_window_12k8[strength][0];
+ wnd_l = lag_window_12k8[strength][1];
+ BREAK;
+ case 16000:
+ assert(m <= 16);
+ wnd_h = lag_window_16k[strength][0];
+ wnd_l = lag_window_16k[strength][1];
+ BREAK;
+ case 24000:
+ case 25600:
+ assert(m <= 16);
+ wnd_h = lag_window_25k6[strength][0];
+ wnd_l = lag_window_25k6[strength][1];
+ BREAK;
+ case 32000:
+ assert(m <= 16);
+ wnd_h = lag_window_32k[strength][0];
+ wnd_l = lag_window_32k[strength][1];
+ BREAK;
+ case 48000:
+ assert(m <= 16);
+ assert(strength == LAGW_STRONG);
+ wnd_h = lag_window_48k[0];
+ wnd_l = lag_window_48k[1];
+ BREAK;
+ default:
+ assert(!"Lag window not implemented for this sampling rate");
+ return;
+ }
+
+ FOR (i = 1; i <= m; i++)
+ {
+ tmp = Mpy_32(r_h[i], r_l[i], wnd_h[i-1], wnd_l[i-1]);
+ L_Extract(tmp, &r_h[i], &r_l[i]);
+ }
+
+}
+
+void adapt_lag_wind(
+ Word16 r_h[], /* in/out: autocorrelations */
+ Word16 r_l[], /* in/out: autocorrelations */
+ Word16 m, /* input : order of LP filter */
+ const Word16 Top, /* input : open loop pitch lag */
+ const Word16 Tnc, /* input : open loop pitch gain */
+ Word32 sr /* input : sampling rate */
+)
+{
+ Word16 strength, pitch_lag;
+ Word16 pitch_gain;
+
+ pitch_lag = Top;
+ move16();
+ pitch_gain = Tnc;
+ move16();
+
+ IF (LT_16(pitch_lag, 80))
+ {
+ strength = LAGW_STRONG;
+ move16();
+ if (LE_16(pitch_gain, kLagWinThGain1))
+ {
+ strength = LAGW_MEDIUM;
+ move16();
+ }
+ }
+ ELSE IF (LT_16(pitch_lag, 160))
+ {
+ strength = LAGW_MEDIUM;
+ move16();
+ if (LE_16(pitch_gain, kLagWinThGain2))
+ {
+ strength = LAGW_WEAK;
+ move16();
+ }
+ }
+ ELSE
+ {
+ strength = LAGW_WEAK;
+ move16();
+ }
+
+ lag_wind(r_h, r_l, m, sr, strength);
+}
diff --git a/lib_com/lerp.c b/lib_com/lerp.c
new file mode 100644
index 0000000000000000000000000000000000000000..e866e231cb7d93492567ffa6bbc420d66ddc6c4f
--- /dev/null
+++ b/lib_com/lerp.c
@@ -0,0 +1,179 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h"
+#include "basop_util.h"
+#include "prot_fx.h"
+#include
+#include "stl.h"
+
+
+
+#define shift_e (16-1)
+#define pos_e (16-1)
+
+static void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize);
+
+
+void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize)
+{
+ Word16 tmp1, tmp2, tmpexp;
+ BASOP_Util_Divide_MantExp(bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp);
+ tmp1 = shr(tmp1,3); /*Q12*/
+ tmp1 = shl(tmp1,tmpexp);
+
+ BASOP_Util_Divide_MantExp(bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp);
+ tmp2 = shr(tmp2,3); /*Q12*/
+ tmp2 = shl(tmp2,tmpexp);
+ test();
+ test();
+ IF(GT_16(tmp1,16224 /*3,9609375 in Q12*/))
+ {
+ Word16 tmpNewSize = shl(bufferOldSize,1);
+ WHILE(GT_16(bufferNewSize, bufferOldSize))
+ {
+ BASOP_Util_Divide_MantExp(bufferNewSize, 0, bufferOldSize, 0, &tmp1, &tmpexp);
+ tmp1 = shr(tmp1,3); /*Q12*/
+ tmp1 = shl(tmp1,tmpexp);
+ test();
+ IF(LE_16(tmp1,16224 /*3,9609375 in Q12*/))
+ {
+ tmpNewSize = bufferNewSize;
+ }
+
+ lerp_proc(f, f_out, tmpNewSize, bufferOldSize);
+
+ f = f_out;
+ bufferOldSize = tmpNewSize;
+ tmpNewSize = shl(tmpNewSize,1);
+ }
+ }
+ ELSE IF(GT_16(tmp2,16224 /*3,9609375 in Q12*/))
+ {
+ Word16 tmpNewSize = shr(bufferOldSize,1);
+ WHILE(LT_16(bufferNewSize, bufferOldSize))
+ {
+ BASOP_Util_Divide_MantExp(bufferOldSize, 0, bufferNewSize, 0, &tmp2, &tmpexp);
+ tmp2 = shr(tmp2,3); /*Q12*/
+ tmp2 = shl(tmp2,tmpexp);
+ test();
+ IF(LE_16(tmp2,16224 /*3,9609375 in Q12*/))
+ {
+ tmpNewSize = bufferNewSize;
+ }
+
+ lerp_proc(f, f_out, tmpNewSize, bufferOldSize);
+
+ f = f_out;
+ bufferOldSize = tmpNewSize;
+ tmpNewSize = shr(tmpNewSize,1);
+ }
+ }
+ else
+ {
+ lerp_proc(f, f_out, bufferNewSize, bufferOldSize);
+ }
+}
+
+void lerp_proc(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize)
+{
+
+ Word16 i, idx, n;
+ Word16 diff;
+ Word32 pos, shift;
+ Word16 buf[2*L_FRAME_MAX];
+ Word16 *ptr;
+
+
+ ptr = f_out;
+ test();
+ test();
+ test();
+ if ( ((f <= f_out) && (f + bufferOldSize >= f_out)) || ((f_out <= f) && (f_out + bufferNewSize >= f)) )
+ {
+ ptr = buf;
+ move16();
+ }
+
+ IF( EQ_16(bufferNewSize, bufferOldSize))
+ {
+ Copy(f, f_out, bufferNewSize);
+ return;
+ }
+
+ shift = L_shl(L_deposit_l(div_s( bufferOldSize, shl(bufferNewSize, 4))), 4-shift_e+16);
+
+ pos = L_sub(L_shr(shift, 1), 32768l/*1.0f Q15*/);
+
+ /* Adjust interpolation shift to avoid accessing beyond end of input buffer. */
+ if ( LT_32(shift, 19661l/*0.3f Q16*/))
+ {
+ pos = L_sub(pos, 8520l/*0.13f Q16*/);
+ }
+
+ assert(pos_e == shift_e);
+
+ /* first point of interpolation */
+ IF (pos<0)
+ {
+
+ diff = shr(extract_l(pos), 1);
+ /*buf[0]=f[0]+pos*(f[1]-f[0]);*/
+ move16();
+ *ptr++ = add(f[0], msu_r(L_mult(diff, f[1]),diff, f[0]));
+ }
+ ELSE
+ {
+
+ idx=extract_h(pos);
+
+ diff = lshr(extract_l(pos), 1);
+
+ move16();
+ *ptr++ = add(f[idx], msu_r(L_mult(diff, f[idx+1]), diff, f[idx]));
+ }
+
+ pos = L_add(pos, shift);
+ idx = s_max(0, extract_h(pos));
+
+ n = sub(bufferNewSize, 1);
+ FOR ( i=1; i= f_out)) || ((f_out <= f) && (f_out + bufferNewSize >= f)) )
+ {
+ Copy( buf, f_out, bufferNewSize );
+ }
+
+}
diff --git a/lib_com/limit_t0_fx.c b/lib_com/limit_t0_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..d5b31b19bb2c7097d93e2a804aa01dfcb8a41c54
--- /dev/null
+++ b/lib_com/limit_t0_fx.c
@@ -0,0 +1,259 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+#include "rom_basop_util.h"
+
+
+/*-------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------*/
+
+#define LIMIT_PIT_REL_LOWER 2 /* delta interval to extend pitch coding in relative Q */
+#define LIMIT_PIT_REL_UPPER 0
+
+/*-------------------------------------------------*
+ * limit_T0()
+ *
+ * Close-loop pitch lag search limitation
+ *-------------------------------------------------*/
+
+
+void limit_T0_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 delta, /* i : Half the close-loop searched interval */
+ const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */
+ const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */
+ const Word16 T0, /* i : rough pitch estimate around which the search is done */
+ const Word16 T0_frac, /* i : pitch estimate fractional part */
+ Word16 *T0_min, /* o : lower pitch limit */
+ Word16 *T0_max /* o : higher pitch limit */
+)
+{
+
+ Word16 delta2,T1;
+ Word16 pit_min, pit_max;
+
+ IF( limit_flag == 0 ) /* restrained Q limits */
+ {
+ /* set limits */
+ IF( EQ_16(L_frame,L_FRAME))
+ {
+ pit_max = PIT_MAX;
+ move16();
+ pit_min = PIT_MIN;
+ move16();
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ pit_max = PIT16k_MAX;
+ move16();
+ pit_min = PIT16k_MIN;
+ move16();
+ }
+
+ delta2 = sub(shl(delta,1),1);
+ T1 = T0;
+ move16();
+
+ if( GE_16(T0_frac,2))
+ {
+ T1 = add(T1,1);
+ }
+
+ *T0_min = sub(T1,delta);
+ move16();
+
+ *T0_min = s_max(*T0_min,pit_min);
+
+ *T0_max = add(*T0_min,delta2);
+ move16();
+
+ IF( GT_16(*T0_max,pit_max))
+ {
+ *T0_max = pit_max;
+ move16();
+ *T0_min = sub(*T0_max,delta2);
+ move16();
+ }
+ }
+ ELSE /* extended Q limits */
+ {
+ /* set limits */
+ IF( EQ_16(L_frame, L_FRAME))
+ {
+ pit_max = PIT_MAX;
+ move16();
+ pit_min = PIT_MIN_EXTEND;
+ move16();
+ if( EQ_16(limit_flag, 2))
+ {
+ pit_min = PIT_MIN_DOUBLEEXTEND;
+ move16();
+ }
+ }
+ ELSE /* L_frame == L_FRAME16k */
+ {
+ pit_max = PIT16k_MAX;
+ move16();
+ pit_min = PIT16k_MIN_EXTEND;
+ move16();
+ }
+
+ delta2 = sub(shl(delta,1),1) ;
+ move16();
+ T1 = T0;
+ move16();
+ if( GE_16(T0_frac,2))
+ {
+ T1 = add(T1,1);
+ }
+ *T0_min = sub(T1, delta);
+ move16();
+ IF( pit_flag == 0 )
+ {
+ /* subframes with absolute search: keep Q range */
+ *T0_min = s_max(*T0_min,pit_min);
+
+ *T0_max = add(*T0_min, delta2);
+ move16();
+ IF( GT_16(*T0_max,pit_max))
+ {
+ *T0_max = pit_max;
+ move16();
+ *T0_min = sub(*T0_max, delta2);
+ move16();
+ }
+ }
+ ELSE
+ {
+ /* subframes with relative search: extend Q range */
+ *T0_min = s_max(*T0_min,sub(pit_min, LIMIT_PIT_REL_LOWER));
+ move16();
+
+ *T0_min = s_max(*T0_min,L_INTERPOL);
+ *T0_max = *T0_min + delta2;
+ move16();
+
+ IF( GT_16(*T0_max, add(pit_max, LIMIT_PIT_REL_UPPER)))
+ {
+ *T0_max = add(pit_max, LIMIT_PIT_REL_UPPER);
+ move16();
+ *T0_min = sub(*T0_max, delta2);
+ move16();
+ }
+ }
+ }
+ return;
+}
+
+
+#define inv_T0_res InvIntTable
+
+/*-------------------------------------------------*
+* Routine limit_T0_voiced()
+*
+* Close-loop pitch lag search limitation
+*-------------------------------------------------*/
+void limit_T0_voiced(
+ const Word16 nbits,
+ const Word16 res,
+ const Word16 T0, /* i : rough pitch estimate around which the search is done */
+ const Word16 T0_frac, /* i : pitch estimate fractional part */
+ const Word16 T0_res, /* i : pitch resolution */
+ Word16 *T0_min, /* o : lower pitch limit */
+ Word16 *T0_min_frac, /* o : lower pitch limit */
+ Word16 *T0_max, /* o : higher pitch limit */
+ Word16 *T0_max_frac, /* o : higher pitch limit */
+ const Word16 pit_min, /* i : Minimum pitch lag */
+ const Word16 pit_max /* i : Maximum pitch lag */
+)
+{
+ Word16 T1, temp1, temp2, res2;
+
+
+ assert(res > 1 && res<=6);
+
+ res2 = res;
+ move16();
+ if(EQ_16(res,6))
+ {
+ res2 = shr(res2,1);
+ }
+
+ /* Mid-point */
+ T1 = T0;
+ test();
+ if( GT_16(T0_res,1)&&GE_16(T0_frac,(shr(T0_res,1))))
+ {
+ T1 = add(T1,1);
+ }
+
+ /* Lower-bound */
+ temp1 = sub(i_mult(T1,res),shl(1,sub(nbits,1)));
+
+ temp2 = mult(temp1,inv_T0_res[res2]);
+ if(EQ_16(res,6))
+ {
+ temp2 = shr(temp2,1);
+ }
+
+ *T0_min = temp2;
+ move16();
+
+ *T0_min_frac = sub(temp1,i_mult(temp2,res));
+ move16();
+
+ IF ( LT_16(*T0_min,pit_min))
+ {
+ *T0_min = pit_min;
+ move16();
+ *T0_min_frac = 0;
+ move16();
+ }
+
+ /* Higher-bound */
+ temp1 = add(i_mult(*T0_min,res),add(*T0_min_frac,sub(shl(1,nbits),1)));
+
+ temp2 = mult(temp1,inv_T0_res[res2]);
+ if(EQ_16(res,6))
+ {
+ temp2 = shr(temp2,1);
+ }
+
+ *T0_max = temp2;
+ move16();
+
+ *T0_max_frac = sub(temp1,i_mult(temp2,res));
+ move16();
+
+ IF ( GT_16(*T0_max,pit_max))
+ {
+ *T0_max = pit_max;
+ move16();
+
+ *T0_max_frac = sub(res,1);
+ move16();
+
+ temp1 = add(i_mult(*T0_max,res),sub(*T0_max_frac,sub(shl(1,nbits),1)));
+
+ temp2 = mult(temp1,inv_T0_res[res2]);
+ if(EQ_16(res,6))
+ {
+ temp2 = shr(temp2,1);
+ }
+ move16();
+ *T0_min = temp2;
+
+ *T0_min_frac = sub(temp1, i_mult(temp2,res));
+ move16();
+ }
+
+
+ return;
+}
diff --git a/lib_com/logqnorm_fx.c b/lib_com/logqnorm_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..957fcdfc6d3c965339f474960fa7dc874fd595b9
--- /dev/null
+++ b/lib_com/logqnorm_fx.c
@@ -0,0 +1,195 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "cnst_fx.h" /* Common constants */
+
+/* Local constants */
+#define THREN2POW 1518500250L
+
+/*--------------------------------------------------------------------------*
+ * logqnorm_fx
+ *
+ * Log quantization for norms of sub-vectors
+ *--------------------------------------------------------------------------*/
+
+void logqnorm_fx(
+ const Word32 *L_x, /* i : coefficient vector Qx */
+ const Word16 qx, /* i : Q value of input */
+ Word16 *k, /* o : index Q0 */
+ const Word16 L, /* i : codebook length Q0 */
+ const Word16 N, /* i : sub-vector size Q0 */
+ const Word16 hvq_flag /* i : HVQ flag Q0 */
+)
+{
+ Word16 i, m;
+ Word16 coefs_shift, power_shift, temp_shift;
+ Word32 L_temp, L_temp1, L_temp2;
+ Word16 coefs16[MAX_SFM_LEN_FX];
+ UWord16 lsb;
+
+ Word16 offset = add(3,shl(qx,1)); /* 3 + 2*qx */
+
+ lsb = 0U; /* to avoid compilation warnings */
+
+ L_temp1 = L_deposit_l(1);
+ FOR (i=0; i
+#include
+#include "prot_fx.h"
+#include "stl.h"
+
+
+/**
+ * \brief inplace long shift right: a[] = a[] >> bits
+ * Logical shift right of UWord32 vector a[] by 'bits' positions.
+ * BASOP cycles: FLC cycles
+ * len = 1: 8 lena = 2: 24
+ * len = 2: 13 lena = 4: 34
+ * len = 3: 18 lena = 6: 44
+ * len = 4: 23 lena = 8: 54
+ * \param UWord32 a[]
+ * Input: vector of the length len
+ * \param Word16 bits
+ * Input: number of bit positions to shift right in range 1..31
+ * Note: 'bits' must not be 0, this would cause a shift-overflow
+ * \param Word16 len
+ * Input: length of vector a[] in units of 'UWord32'
+ *
+ * \return void
+ */
+
+void longshr(UWord32 a[], Word16 bits, Word16 len)
+{
+ Word16 fracb_u, k;
+
+ assert ((bits > 0) && (bits < 32));
+
+ fracb_u = sub(32,bits);
+ len = sub(len,1);
+ FOR (k=0; k < len; k++)
+ {
+ a[k] = L_or(L_lshr(a[k],bits),L_lshl(a[k+1],fracb_u));
+ move32();
+ }
+ a[k] = L_lshr(a[k],bits);
+ move32();
+
+ return;
+}
diff --git a/lib_com/low_rate_band_att_fx.c b/lib_com/low_rate_band_att_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..680b95ed6324c7d6c0b9273213a3931791fecd21
--- /dev/null
+++ b/lib_com/low_rate_band_att_fx.c
@@ -0,0 +1,219 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h"
+#include "stl.h" /* required for wmc_tool */
+
+
+/*--------------------------------------------------------------------------*
+ * fine_gain_pred()
+ *
+ * Fine gain prediction
+ *--------------------------------------------------------------------------*/
+
+void fine_gain_pred_fx(
+ const Word16 *sfm_start, /* i : Sub band start indices */
+ const Word16 *sfm_end, /* i : Sub band end indices */
+ const Word16 *sfm_size, /* i : Sub band bandwidths */
+ const Word16 *i_sort, /* i : Energy sorting indices */
+ const Word16 *K, /* i : Number of pulses per band */
+ const Word16 *maxpulse, /* i : Maximum pulse per band */
+ const Word16 *R, /* i : Bits per sub band Q3 */
+ const Word16 num_sfm, /* i : Number of sub bands */
+ Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/
+ Word16 *y, /* i/o: Quantized vector (int) */
+ Word16 *fg_pred, /* o : Predicted fine gains Q12 */
+ const Word16 core /* i : Core */
+)
+{
+ Word16 i, band;
+ Word16 gp;
+ Word32 xx;
+ Word16 accuracy;
+ Word16 k, bw;
+
+ Word16 shift, bw_idx;
+ Word16 tmp, exp, exp2;
+ Word32 L_tmp;
+ UWord16 lsb;
+
+ FOR( band = 0; band < num_sfm; band++)
+ {
+ k = K[i_sort[band]];
+ move16();
+
+ IF( k > 0)
+ {
+ /* bw, bw_idx only used if k>0 */
+ bw = sfm_size[i_sort[band]];
+ move16(); /* allowed. 8, 16, 24,32,48,64,80,96 */
+ bw_idx = band_len_idx[ shr(bw,3) ];
+ move16(); /* bw_idx= 0: 7 */
+ xx = L_deposit_l(0);
+ shift = band_len_ener_shift[bw_idx];
+ FOR(i = sfm_start[i_sort[band]]; i < sfm_end[i_sort[band]]; i++)
+ {
+ /*xx += xq[i] * xq[i]; */
+ tmp = shr(xq[i], shift); /*15-shift */
+ xx = L_mac0(xx, tmp, tmp); /*30-2*shift */
+ }
+
+ IF ( xx > 0)
+ {
+ /* Normalize synthesis to RMS=1.0 */
+ /*gp = (float) sqrt(bw / xx); */
+ exp = norm_l(xx);
+ L_tmp = L_shl(xx, exp); /*2*(15-shift)+exp */
+ exp = sub(31, add(exp, sub(30, shl(shift,1))));
+ L_tmp = Isqrt_lc(L_tmp, &exp); /*31 - exp */
+ Mpy_32_16_ss(L_tmp, fine_gain_pred_sqrt_bw[bw_idx], &L_tmp, &lsb); /*31-exp+11-15=27-exp */
+ gp = round_fx(L_shl(L_tmp, add(1, exp))); /*27-exp+1+exp-16=12 */
+
+ test();
+ test();
+ IF (EQ_16(core, HQ_CORE)&&R!=NULL&&LE_16(R[i_sort[band]],256)) /* 256 is 32 in Q3 */
+ {
+ /*accuracy = ((float)k/(float)bw)*maxpulse[i_sort[band]]; */
+ L_tmp = L_mult(k, inv_tbl_fx[bw]); /*0+15+1 */
+ exp2 = norm_l(L_tmp);
+ tmp = round_fx(L_shl(L_tmp, exp2)); /*16+exp2-16 */
+ L_tmp = L_mult0(maxpulse[i_sort[band]], tmp); /*0+exp2 */
+ exp = norm_l(L_tmp);
+ accuracy = round_fx(L_shl(L_tmp, exp)); /*exp2+exp-16=exp-16 */
+ exp = add(exp, exp2);
+
+ /*gp *= 1.0f - 0.05f / accuracy; */
+ tmp = div_s(13107, accuracy); /* 0.05 in Q18 */
+ tmp = shr(tmp, sub(34, exp)); /*15+18-exp+16-15=34-exp */
+ tmp = sub(32767, tmp);
+ tmp = s_max(27554, tmp); /* Limit attenuation to norm quantizer error, 2^-0.25 in Q15 */
+ gp = mult_r(tmp, gp); /*15+12+1-16=12 */
+ }
+
+ fg_pred[band] = gp;
+ move16();
+ }
+ ELSE
+ {
+ fg_pred[band] = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ fg_pred[band] = 0;
+ move16();
+ FOR(i = sfm_start[i_sort[band]]; i < sfm_end[i_sort[band]]; i++)
+ {
+ y[i] = 0;
+ move16();
+ xq[i] = 0;
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * get_max_pulses()
+ *
+ * Find the maximum pulse height (in unit pulses) in each band
+ *--------------------------------------------------------------------------*/
+
+void get_max_pulses_fx(
+ const Word16 *band_start, /* i : Sub band start indices */
+ const Word16 *band_end, /* i : Sub band end indices */
+ const Word16 *k_sort, /* i : Indices for sorting by energy */
+ const Word16 *npulses, /* i : Pulses per sub band */
+ const Word16 BANDS, /* i : Number of bands */
+ Word16 *inp_vector, /* i/o: Encoded shape vectors (int)*/
+ Word16 *maxpulse /* o : Maximum pulse height per band */
+)
+{
+ Word16 i, k;
+ Word16 npul;
+ Word16 maxp;
+ Word16 tmp;
+
+ FOR (k = 0; k < BANDS; k++)
+ {
+ npul = npulses[k_sort[k]];
+ move16();
+ maxp = 0;
+ move16();
+ IF (npul > 0)
+ {
+ FOR (i = band_start[k_sort[k]]; i < band_end[k_sort[k]]; i++)
+ {
+ tmp = abs_s(inp_vector[i]);
+ if (GT_16(tmp, maxp))
+ {
+ maxp = tmp;
+ move16();
+ }
+ }
+ }
+ maxpulse[k_sort[k]] = maxp;
+ move16();
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * fine_gain_dec()
+ *
+ * Fine gain decoder. Decodes fine gain adjustments and applies correction to
+ * predicted fine gains
+ *--------------------------------------------------------------------------*/
+
+void fine_gain_dec_fx
+(
+ Decoder_State_fx *st,
+ const Word16 *ord, /* i : Indices for energy order */
+ const Word16 num_sfm, /* i : Number of bands */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */
+ Word16 *fg_pred /* i/o: Predicted gains / Corrected gains */
+)
+{
+ Word16 band;
+ Word16 gbits;
+ Word16 idx, tmp1, exp1;
+ Word16 gain_dbq;
+ Word32 L_tmp;
+
+
+ FOR ( band = 0; band < num_sfm; band++)
+ {
+ gbits = gain_bits[ord[band]];
+ IF (gbits > 0)
+ {
+ IF (fg_pred[band] != 0)
+ {
+ idx = get_next_indice_fx( st, gbits );
+ gain_dbq = finegain_fx[gbits-1][idx];
+
+ /* Update predicted gain with quantized correction */
+ L_tmp = L_mult0(gain_dbq, 21771); /* 21771=0.05*log2(10) */ /* 14+17=31 */
+ L_tmp = L_shr(L_tmp, 15);
+ tmp1 = L_Extract_lc(L_tmp, &exp1);
+ tmp1 = abs_s(tmp1);
+ tmp1 = extract_l(Pow2(14, tmp1));
+ exp1 = sub(14, exp1);
+
+ L_tmp = L_mult0(fg_pred[band], tmp1); /*12+exp1 */
+ fg_pred[band] = round_fx(L_shl(L_tmp, sub(16, exp1))); /*12+exp1+16-exp1-16=12 */
+ }
+ }
+ }
+
+ return;
+}
+
+
diff --git a/lib_com/lpc_tools_fx.c b/lib_com/lpc_tools_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..d690482f5693b31a3e1318e296d5952a95a33415
--- /dev/null
+++ b/lib_com/lpc_tools_fx.c
@@ -0,0 +1,1009 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h"
+#include "stl.h"
+#include "basop_mpy.h"
+#include "basop_util.h"
+
+
+/*-----------------------------------------------------------------*
+ * Local constants
+ *-----------------------------------------------------------------*/
+
+#define MAX_LEN_LP 960 /* maximum length in samples of the LP analysis window */
+
+/*---------------------------------------------------------------------*
+ * autocorr()
+ *
+ * Compute autocorrelations of input signal
+ *---------------------------------------------------------------------*/
+void autocorr_fx(
+ const Word16 x[], /* i : Input signal */
+ const Word16 m, /* i : LPC order Q0 */
+ Word16 r_h[], /* o : Autocorrelations (msb) Q15 */
+ Word16 r_l[], /* o : Autocorrelations (lsb) */
+ Word16 *Q_r, /* o : normalisation shift of r Q0 */
+ const Word16 len, /* i : Frame lenght */
+ const Word16* wind, /* i : Window used */
+ Word16 rev_flag,
+ const Word16 sym_flag /* i : symmetric window flag */
+)
+{
+ Word16 i, j, norm, shift, y[MAX_LEN_LP];
+ Word16 fact;
+ Word32 L_sum, L_tmp;
+
+ IF(EQ_16(rev_flag,1))
+ {
+ /* Windowing of signal */
+ FOR (i = 0; i < len; i++)
+ {
+ y[i] = mult_r(x[i], wind[len-i-1]);
+ move16();
+ }
+ }
+ ELSE IF( EQ_16(sym_flag,1))
+ {
+ /* symmetric window of even length */
+ FOR( i=0; i 0)
+ {
+ fact = lshr(-32768, shift);
+ FOR (i = 0; i < len; i++)
+ {
+ y[i] = mult_r(y[i], fact);
+ move16();
+ }
+ }
+ ELSE
+ {
+ shift = 0;
+ move16();
+ }
+
+ /* Compute and normalize r[0] */
+ L_sum = L_mac(1, y[0], y[0]);
+ FOR (i = 1; i < len; i++)
+ {
+ L_sum = L_mac(L_sum, y[i], y[i]);
+ }
+ norm = norm_l(L_sum);
+ L_sum = L_shl(L_sum, norm);
+ L_Extract(L_sum, &r_h[0], &r_l[0]); /* Put in DPF format (see oper_32b) */
+
+ /* Compute r[1] to r[m] */
+ FOR (i = 1; i <= m; i++)
+ {
+ L_sum = L_mult(y[0],y[i]);
+ FOR (j = 1; j < len - i; j++)
+ {
+ L_sum = L_mac(L_sum, y[j], y[j + i]);
+ }
+
+ L_sum = L_shl(L_sum, norm);
+ L_Extract(L_sum, &r_h[i], &r_l[i]); /* Put in DPF format (see oper_32b) */
+ }
+
+ *Q_r = sub(norm, shl(shift, 1));
+ move16();
+}
+
+/*****************************************************************************
+ * *
+ * Function Name : Div_32_opt *
+ * *
+ * Purpose : *
+ * Fractional integer division of two 32 bit numbers. *
+ * L_num / L_denom. *
+ * L_num and L_denom must be positive and L_num < L_denom. *
+ * L_denom = denom_hi<<16 + denom_lo<<1 *
+ * denom_hi is a normalize number. *
+ * *
+ * Inputs : *
+ * *
+ * L_num *
+ * 32 bit long signed integer (Word32) whose value falls in the *
+ * range : 0x0000 0000 < L_num < L_denom *
+ * *
+ * L_denom = denom_hi<<16 + denom_lo<<1 (DPF) *
+ * *
+ * denom_hi *
+ * 16 bit positive normalized integer whose value falls in the *
+ * range : 0x4000 < hi < 0x7fff *
+ * denom_lo *
+ * 16 bit positive integer whose value falls in the *
+ * range : 0 < lo < 0x7fff *
+ * *
+ * Return Value : *
+ * *
+ * L_div *
+ * 32 bit long signed integer (Word32) whose value falls in the *
+ * range : 0x0000 0000 <= L_div <= 0x7fff ffff. *
+ * *
+ * Algorithm: *
+ * *
+ * - find = 1/L_denom. *
+ * First approximation: approx = 1 / denom_hi *
+ * 1/L_denom = approx * (2.0 - L_denom * approx ) *
+ * *
+ * - result = L_num * (1/L_denom) *
+ *****************************************************************************
+*/
+static
+Word32 Div_32_opt (Word32 L_num, Word16 denom_hi, Word16 denom_lo)
+{
+ Word16 approx /*, hi, lo, n_hi , n_lo*/;
+ Word32 L_32;
+
+ /* First approximation: 1 / L_denom = 1/denom_hi */
+
+ approx = div_s ((Word16) 0x3fff, denom_hi);
+
+ /* 1/L_denom = approx * (2.0 - L_denom * approx) */
+
+ L_32 = Msu_32_16 ((Word32) 0x7fffffffL, denom_hi, denom_lo, approx);
+
+ L_32 = Mpy_32_16_1(L_32, approx);
+
+ /* L_num * (1/L_denom) */
+
+ L_32 = Mpy_32_32(L_num, L_32);
+
+ L_32 = L_shl (L_32, 2);
+
+ return (L_32);
+}
+
+/*
+ * E_LPC_lev_dur
+ *
+ * Parameters:
+ * Rh I: Rh[m+1] Vector of autocorrelations (msb)
+ * Rl I: Rl[m+1] Vector of autocorrelations (lsb)
+ * A O: A[m] LPC coefficients (m = 16) Qx (A[0] is always 1, so the format can be deduced in the caller with norm_s(A[0]))
+ * epsP O: error vector, msb
+ * order I: LPC order Q0
+ *
+ * Function:
+ * Levinson-Durbin algorithm to compute
+ * the LPC parameters from the autocorrelations of speech.
+ *
+ * Returns:
+ * void
+ */
+Word16 E_LPC_lev_dur(const Word16 Rh[], const Word16 Rl[], Word16 A[],
+ Word32 epsP[], const Word16 order
+ ,Word16 *mem
+ )
+{
+ return(E_LPC_lev_dur_stab(Rh, Rl, A, epsP, order, mem, 32750)); /* 0.99945 in Q15 */
+}
+
+Word16 E_LPC_lev_dur_stab(const Word16 Rh[], const Word16 Rl[], Word16 A[],
+ Word32 epsP[], const Word16 order,
+ Word16 *mem, Word16 k_max
+ )
+{
+ Word16 i, j, k;
+ Word16 hi, lo;
+ Word16 Kh, Kl; /* reflection coefficient; hi and lo */
+ Word16 alp_h, alp_l, alp_exp; /* Prediction gain; hi lo and exponent */
+ Word32 t0, t1, t2; /* temporary variables */
+ Word16 flag;
+ Word16 Ah[TCXLTP_LTP_ORDER + 1], Al[TCXLTP_LTP_ORDER + 1]; /* LPC coef. in double prec. */
+
+
+ BASOP_SATURATE_WARNING_OFF
+ if(epsP!=NULL)
+ {
+ epsP[0] = L_Comp(Rh[0], Rl[0]);
+ move32();
+ }
+
+ flag=0;
+ move16();
+
+ /* K = A[1] = -R[1] / R[0] */
+ t1 = L_Comp(Rh[1], Rl[1]); /* R[1] in Q31 */
+ t2 = L_abs(t1); /* abs R[1] */
+ t0 = L_deposit_l(0);
+ IF (Rh[0] != 0)
+ {
+ t0 = Div_32_opt(t2, Rh[0], Rl[0]); /* R[1]/R[0] in Q31 */
+ /* Cause a difference in MODE1 due to different implementation of div32*/
+ }
+ if (t1 > 0)
+ {
+ t0 = L_negate(t0); /* -R[1]/R[0] */
+ }
+ Kl = L_Extract_lc(t0, &Kh); /* K in DPF */
+ t0 = L_shr(t0, 4); /* A[1] in Q27 */
+ L_Extract(t0, &Ah[1], &Al[1]); /* A[1] in DPF */
+
+ /* Alpha = R[0] * (1-K**2) */
+ t0 = Sqr_32(Kh, Kl); /* K*K in Q31 */
+ t0 = L_abs(t0); /* Some case <0 !! */
+ t0 = L_sub((Word32) 0x7fffffffL, t0); /* 1 - K*K in Q31 */
+ lo = L_Extract_lc(t0, &hi); /* DPF format */
+ t0 = Mpy_32(Rh[0], Rl[0], hi, lo); /* Alpha in Q31 */
+ if(epsP!=NULL)
+ {
+ epsP[1] = t0;
+ move32();
+ }
+
+ /* Normalize Alpha */
+ alp_exp = norm_l(t0);
+ t0 = L_shl(t0, alp_exp);
+ alp_l = L_Extract_lc(t0, &alp_h);
+ /* DPF format */
+
+ /*--------------------------------------*
+ * ITERATIONS I=2 to m
+ *--------------------------------------*/
+
+ FOR (i = 2; i <= order; i++)
+ {
+ /* t0 = SUM(R[j]*A[i-j], j=1, i-1) + R[i] */
+ t0 = L_deposit_l(0);
+ FOR (j = 1; j < i; j++)
+ {
+ t0 = Mac_32(t0, Rh[j], Rl[j], Ah[i - j], Al[i - j]);
+ }
+
+ t0 = L_shl(t0, 4); /* result in Q27 -> convert to Q31 */
+ /* No overflow possible */
+
+ /* Compose and add R[i] in Q3 */
+ t0 = L_mac(t0, Rl[i], 1);
+ t0 = L_msu(t0, Rh[i], -32768);
+
+ /* K = -t0 / Alpha */
+ t1 = L_abs(t0);
+ t2 = L_deposit_l(0);
+ IF (alp_h != 0)
+ {
+ t2 = Div_32_opt(t1, alp_h, alp_l); /* abs(t0)/Alpha */
+ /* Cause a difference in MODE1 due to different implementation of div32*/
+ }
+
+ if (t0 > 0)
+ {
+ t2 = L_negate(t2); /* K =-t0/Alpha */
+ }
+ t2 = L_shl(t2, alp_exp); /* denormalize; compare to Alpha */
+ test();
+ if ((mem!=NULL) && ((GT_16(abs_s(extract_h(t2)), k_max))))
+ {
+ flag=1;
+ move16();/* Test for unstable filter. If unstable keep old A(z) */
+ }
+ if ((mem!=NULL) && ((LT_32(L_abs(t2), 5))))
+ {
+ flag=1;
+ move16(); /*R matrix not reliable (R saturated for many coeff), keep old A(z) */
+ }
+ Kl = L_Extract_lc(t2, &Kh); /* K in DPF */
+
+ /*------------------------------------------*
+ * Compute new LPC coeff. -> An[i]
+ * An[j]= A[j] + K*A[i-j] , j=1 to i-1
+ * An[i]= K
+ *------------------------------------------*/
+
+ k = mult_r(i, 16384);
+ FOR (j = 1; j < k; j++)
+ {
+ /* Do two Iterations Together to Allow Direct Update of Ah & Al */
+ t0 = Mac_32(L_Comp(Ah[j], Al[j]), Kh, Kl, Ah[i-j], Al[i-j]);
+ t1 = Mac_32(L_Comp(Ah[i-j], Al[i-j]), Kh, Kl, Ah[j], Al[j]);
+ L_Extract(t0, &Ah[j], &Al[j]);
+ L_Extract(t1, &Ah[i-j], &Al[i-j]);
+ }
+ IF (s_and(i, 1) == 0)
+ {
+ t0 = Mac_32(L_Comp(Ah[j], Al[j]), Kh, Kl, Ah[i-j], Al[i-j]);
+ L_Extract(t0, &Ah[j], &Al[j]);
+ }
+ t2 = L_shr(t2, 4); /* t2 = K in Q31 ->convert to Q27 */
+ L_Extract(t2, &Ah[i], &Al[i]); /* An[i] in Q27 */
+
+ /* Alpha = Alpha * (1-K**2) */
+ t1 = L_mult(Kh, Kh); /* K*K in Q31 */
+ t0 = L_mac(t1, mult(Kh, Kl), 2);
+ t0 = L_abs(t0); /* Some case <0 !! */
+ t0 = L_sub((Word32) 0x7fffffffL, t0); /* 1 - K*K in Q31 */
+ lo = L_Extract_lc(t0, &hi); /* DPF format */
+ t0 = Mpy_32(alp_h, alp_l, hi, lo); /* Alpha in Q31 */
+
+
+ /* store denormalized alpha in epsP */
+ t1 = L_shr(t0, alp_exp);
+ if(epsP!=NULL)
+ {
+ epsP[i] = t1;
+ move32();
+ }
+
+ /* Normalize Alpha */
+ j = norm_l(t0);
+ t0 = L_shl(t0, j);
+ alp_l = L_Extract_lc(t0, &alp_h);/* DPF format */
+ alp_exp = add(alp_exp, j); /* Add normalization to alp_exp */
+ }
+
+ /* Adaptive scaling */
+ t1 = L_deposit_l(0);
+ FOR (i = 1; i <= order; i++)
+ {
+ t0 = L_Comp(Ah[i], Al[i]);
+ t1 = L_max( t1, L_abs(t0) );
+ }
+ k = s_min( norm_l( t1 ), 3 );
+ A[0] = shl( 2048, k );
+ move16();
+ FOR (i = 1; i <= order; i++)
+ {
+ t0 = L_Comp(Ah[i], Al[i]);
+ A[i] = round_fx(L_shl(t0, k));
+ }
+
+ BASOP_SATURATE_WARNING_ON
+ IF (mem != NULL)
+ {
+ /* Enforce stable LPC filter - parcorr[0] and parcorr[1] are not LPC coeffiecients */
+ IF(flag)
+ {
+ Copy(mem, A, order + 1);
+ }
+ ELSE /* If stable LPC filter, store into memories */
+ {
+ Copy(A, mem, order + 1);
+ }
+ }
+
+
+ return(flag);
+}
+
+/*
+ * E_LPC_a_add_tilt
+ *
+ * Parameters:
+ * a I: LP filter coefficients (m+1 coeffs)
+ * ap O: modified LP filter coefficients (m+2 coeffs)
+ * gamma I: tilt factor
+ * m I: order of LP filter
+ *
+ * Function:
+ * Modified LP filter by adding 1st order pre-premphasis, Ap(z)=A(z).(1-gamma.z^(-1))
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_a_add_tilt(const Word16 *a, Word16 *ap, Word16 gamma, Word16 m)
+{
+ Word16 i;
+ Word32 Amax, Atmp[M+2];
+ Word16 shift;
+
+
+
+
+ Amax = L_mult( 16384, a[0] );
+ FOR (i = 1; i <= m; i++)
+ {
+ Atmp[i] = L_sub( L_mult(16384, a[i]), L_mult0(gamma, a[i-1]) );
+ move32();
+ Amax = L_max( Amax, L_abs( Atmp[i] ) );
+ }
+ Atmp[m+1] = L_negate( L_mult0(gamma, a[m]) );
+ move32();
+ Amax = L_max( Amax, L_abs( Atmp[m+1] ) );
+ shift = norm_l( Amax );
+ ap[0] = shl( a[0], sub(shift,1) );
+ move16();
+ FOR (i = 1; i <= m; i++)
+ {
+ ap[i] = round_fx( L_shl( Atmp[i], shift ) );
+ }
+ ap[m+1] = round_fx( L_shl( Atmp[m+1], shift ) );
+
+}
+
+void E_LPC_int_lpc_tcx(const Word16 lsp_old[], /* input : LSPs from past frame Q15 */
+ const Word16 lsp_new[], /* input : LSPs from present frame Q15 */
+ Word16 a[] /* output: interpolated LP coefficients Q12 */
+ )
+{
+ Word16 i, lsp[M];
+
+
+
+ FOR (i = 0; i < M; i++)
+ {
+ /*lsp[i] = lsp_old[i]*0.125f + lsp_new[i]*0.875f;*/
+ lsp[i] = round_fx(L_mac(L_mult(lsp_old[i],4096),lsp_new[i],28672));
+ }
+ E_LPC_f_lsp_a_conversion(lsp, a, M);
+
+
+ return;
+}
+
+static void lsp_reorder(
+ Word16 *lsp, /* (I/O): LSP vector (acos() domain) Q13*1.2732 */
+ Word16 min_dist, /* (I): minimum required distance Q13*1.2732 */
+ Word16 lpcorder /* (I): LPC order Q0 */
+)
+{
+ Word16 i;
+ Word16 lsp_min, lsp_max;
+
+
+ /* Verify the LSF ordering and minimum GAP */
+ lsp_min = min_dist;
+ move16();
+ FOR (i=0; i=0; --i)
+ {
+ lsp[i] = s_min(lsp[i], lsp_max);
+ move16();
+ lsp_max = sub(lsp[i], min_dist);
+ }
+ }
+
+}
+
+/* Approximate unweighting */
+Word16 E_LPC_lsp_unweight(
+ /* const */ Word16 lsp_w[], /* (I): weighted xSP Q15 */
+ Word16 lsp_uw[], /* (O): unweighted xSP Q15 */
+ Word16 lsf_uw[], /* (O): unweighted LSF Q1*1.28 */
+ Word16 inv_gamma, /* (I): inverse weighting factor Q14 */
+ Word16 lpcorder /* (I): prediction order Q0 */
+)
+{
+ Word16 lsp_w_orig[M], lsp_w_diff[M], mean, step; /* Q13*1.2732 */
+ const lsp_unw_triplet *unw_coeffs = NULL;
+ Word16 i;
+
+ step = 0; /* to avoid compilation warnings */
+
+
+ assert(lpcorder == 16);
+
+ /* Table selection */
+ IF (EQ_16(inv_gamma, GAMMA16k_INV))
+ {
+ unw_coeffs = p16_gamma0_94to1;
+ move16();
+ }
+ ELSE IF (EQ_16(inv_gamma, GAMMA1_INV))
+ {
+ unw_coeffs = p16_gamma0_92to1;
+ move16();
+ }
+ ELSE
+ {
+ assert(0);
+ }
+
+ /* step = M_PI/(float)(lpcorder+1); */
+ step = 1927;
+ move16();
+ mean = 0;
+ move16();
+
+ /* Apply acos() and get mean removed version */
+ FOR (i=0; i 0.01f*2^27/2^30 */
+ Word32 tmp_epsP;
+
+
+
+ mM1 = sub(m,1);
+
+ s = getScaleFactor32(r,add(m,1));
+ IF (s!=0)
+ {
+ scale_sig32(r,add(m,1),s); /* scale in-place */
+ }
+
+ g1 = r;
+ Copy32(r+1,g0,m);
+
+ /* compute g0[0]/g1[0], where g0[0] < g1[0] */
+ temp16 = negate(divide3232(g0[0], g1[0]));
+ reflCoeff[0] = temp16;
+ move16();
+ move32();
+ epsP[0] = r[0];
+
+
+ FOR (i=0; i= 0; specix++);*/
+ WHILE (mult(s,spec_r[specix]) >= 0) specix = add(specix, 1);
+
+ tmp = divide1616(spec_r[specix-1], sub(spec_r[specix-1],spec_r[specix] ) );
+ move16();
+ /*lsf[lsfix] = L_add(L_deposit_h(sub(specix,1)) , L_shl(L_deposit_l(tmp),1));*/ /*Q16*/
+ lsf[lsfix] = add(shl(sub(specix,1),7) , shr((tmp),8)); /*7Q8*/
+
+ lsfix++;
+
+ /*check for the next zero crossing*/
+ /*for (; s*spec_i[specix] >= 0; specix++);*/
+
+ WHILE (mult(s,spec_i[specix]) >= 0) specix = add(specix, 1);
+
+ tmp = divide1616(spec_i[specix-1], sub(spec_i[specix-1],spec_i[specix]) );
+ move16();
+ /*lsf[lsfix] = L_add(L_deposit_h(sub(specix,1)) , L_shl(L_deposit_l(tmp),1));*/ /*Q16*/
+ lsf[lsfix] = add(shl(sub(specix,1),7) , shr((tmp),8)); /*7Q8*/
+
+ lsfix++;
+
+ spec_r[speclen] = s;
+ move16();
+ spec_i[speclen] = s;
+ move16();
+
+ s = negate(s);
+ }
+
+ IF (LT_16(lsfix,16))
+ {
+ FOR(i=0; i<16; i++)
+ {
+ lsf[i] = old_lsf[i];
+ move16();
+ }
+ }
+
+ return;
+}
+
+void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 *old_lsf, Word16 lpcOrder, Word8 lpcRep)
+{
+ Word32 RealFFT[128];
+ Word32 ImagFFT[128];
+ Word16 RealOut[130];
+ Word16 ImagOut[130];
+ Word32 *ptrReal;
+ Word32 *ptrImag;
+ Word16 n, i, j, step, scale;
+ const PWord16 *ptwiddle, *pwn17, *pwn17i;
+ PWord16 *pwn15, *pwn15i, tmpw15;
+ Word16 N = 256;
+ Word16 s[4];
+ Word32 L_tmp, L_tmp1, L_tmp3;
+ Word16 lpc[19];
+
+
+ /* half length FFT */
+ scale = add(norm_s(lpcCoeffs[0]),1)+5;
+ move16();
+
+ /*s = [sum(a) ((-1).^(1:length(a)))*a];*/
+ L_tmp = L_deposit_h(0);
+ FOR(j=0; j<=lpcOrder; j++)
+ {
+ L_tmp = L_mac(L_tmp, lpcCoeffs[j], 0x800);
+ }
+ /*s[1] = round_fx(L_tmp); move16();*/
+
+ L_tmp1 = L_deposit_h(0);
+ FOR(j=0; jv.re), lpc[2*j+1],ptwiddle->v.im),scale);
+ move32();
+ ptrImag[j*8] = L_shl(L_mac(L_mult(lpc[2*j+1],ptwiddle->v.re), lpc[2*j],ptwiddle->v.im),scale);
+ move32();
+ ptwiddle++;
+ }
+
+ ptrReal[j*8] = L_shl(L_mac(0,lpc[2*j],ptwiddle->v.re),scale);
+ move32();
+ ptrImag[j*8] = L_shl(L_mac(0, lpc[2*j],ptwiddle->v.im),scale);
+ move32();
+ ptwiddle++;
+ j++;
+ FOR(; j<16; j++)
+ {
+ ptrReal[j*8] = L_deposit_h(0);
+ ptrImag[j*8] = L_deposit_h(0);
+ ptwiddle++;
+ }
+
+ fft16(ptrReal, ptrImag, 8, 0);
+
+ ptrReal++;
+ ptrImag++;
+
+ }
+
+ /* pre-twiddle */
+ BASOP_getTables(NULL, &ptwiddle, &step, 128);
+ IF (lpcRep != 0)
+ {
+ pwn17i = &w19N[126];
+ pwn17 = w19N;
+ }
+ ELSE
+ {
+ pwn17i = &w18N[126];
+ pwn17 = w18N;
+ }
+
+ pwn15 = &tmpw15;
+ pwn15i = &tmpw15;
+
+ RealOut[0] = round_fx(2*L_add(RealFFT[0], ImagFFT[0]));
+ ImagOut[0] = 0;
+ move16();
+
+ RealOut[128] = 0;
+ move16();
+ ImagOut[128] = round_fx(L_sub(L_add(RealFFT[0],RealFFT[0]), L_add(ImagFFT[0], ImagFFT[0])));
+
+ ptwiddle += 8;
+ FOR(i=1; i<=N/2/4; i++)
+ {
+ Word16 ReAr = extract_h(L_add(RealFFT[i],RealFFT[N/2-i]));
+ Word16 ReBr = extract_h(L_sub(RealFFT[N/2-i], RealFFT[i]));
+ Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N/2-i]));
+ Word16 ImBr = extract_h(L_add(ImagFFT[i], ImagFFT[N/2-i]));
+ BASOP_SATURATE_WARNING_OFF
+ tmpw15.v.re = mac_r(L_mult(ptwiddle->v.re, pwn17->v.re), ptwiddle->v.im, pwn17->v.im);
+ tmpw15.v.im = msu_r(L_mult(ptwiddle->v.re, pwn17->v.im), ptwiddle->v.im, pwn17->v.re);
+ BASOP_SATURATE_WARNING_ON
+ RealOut[i] = mac_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re),ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re);
+ move16();
+ ImagOut[i] = mac_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im);
+ move16();
+ BASOP_SATURATE_WARNING_OFF
+ tmpw15.v.re = msu_r(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re);
+ tmpw15.v.im = mac_r(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re);
+ BASOP_SATURATE_WARNING_ON
+ RealOut[N/2-i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17i->v.re), ImAr, pwn17i->v.im), ImBr, pwn15i->v.re), ReBr, pwn15i->v.im);
+ move16();
+ ImagOut[N/2-i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17i->v.im), ImAr, pwn17i->v.re), ReBr, pwn15i->v.re), ImBr, pwn15i->v.im);
+ move16();
+
+ ptwiddle += 8;
+ pwn17++;
+ pwn17i--;
+ }
+
+ ptwiddle -= 16;
+ /*change real with imaginary for ptwiddle*/
+ FOR(; iv.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im);
+ tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re);
+ BASOP_SATURATE_WARNING_ON
+ RealOut[i] = mac_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re),ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re);
+ move16();
+ ImagOut[i] = mac_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im);
+ move16();
+ BASOP_SATURATE_WARNING_OFF
+ tmpw15.v.re = msu_r(L_mult(ptwiddle->v.re, pwn17i->v.im), ptwiddle->v.im, pwn17i->v.re);
+ tmpw15.v.im = mac_r(L_mult(ptwiddle->v.im, pwn17i->v.im), ptwiddle->v.re, pwn17i->v.re);
+ BASOP_SATURATE_WARNING_ON
+ RealOut[N/2-i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17i->v.re), ImAr, pwn17i->v.im), ImBr, pwn15i->v.re), ReBr, pwn15i->v.im);
+ move16();
+ ImagOut[N/2-i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17i->v.im), ImAr, pwn17i->v.re), ReBr, pwn15i->v.re), ImBr, pwn15i->v.im);
+ move16();
+
+ ptwiddle -= 8;
+ pwn17++;
+ pwn17i--;
+ }
+ ptwiddle += 0;
+ {
+ Word16 ReAr = extract_h(L_add(RealFFT[i],RealFFT[N/2-i]));
+ Word16 ReBr = extract_h(L_sub(RealFFT[N/2-i], RealFFT[i]));
+ Word16 ImAr = extract_h(L_sub(ImagFFT[i], ImagFFT[N/2-i]));
+ Word16 ImBr = extract_h((L_negate(L_add(ImagFFT[i], ImagFFT[N/2-i]))));
+ BASOP_SATURATE_WARNING_OFF
+ tmpw15.v.re = mac_r(L_mult(ptwiddle->v.im, pwn17->v.re), ptwiddle->v.re, pwn17->v.im);
+ tmpw15.v.im = msu_r(L_mult(ptwiddle->v.im, pwn17->v.im), ptwiddle->v.re, pwn17->v.re);
+ BASOP_SATURATE_WARNING_ON
+ RealOut[i] = msu_r(L_msu(L_msu(L_mult(ReAr, pwn17->v.re), ImAr, pwn17->v.im), ReBr, pwn15->v.im), ImBr, pwn15->v.re);
+ move16();
+ ImagOut[i] = msu_r(L_mac(L_mac(L_mult(ReAr, pwn17->v.im), ImAr, pwn17->v.re), ReBr, pwn15->v.re), ImBr, pwn15->v.im);
+ move16();
+ }
+
+ spec2isf(RealOut, ImagOut, 128, lsf, old_lsf);
+ IF (lpcRep == 0)
+ {
+ lsf[lpcOrder - 1] = shl(lpcCoeffs[lpcOrder], add(norm_s(lpcCoeffs[0]),1));
+ move16(); /* From Qx to Q15 with saturation */
+ lsf[lpcOrder - 1] = xsp_to_xsf(lsf[lpcOrder - 1]);
+ move16();
+ lsf[lpcOrder - 1] = shr(lsf[lpcOrder - 1], 1);
+ move16();
+ }
+
+}
+
diff --git a/lib_com/lsf_dec_bfi_fx.c b/lib_com/lsf_dec_bfi_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..5c4796700a848a7cd603b6f368ab7393877bf2e1
--- /dev/null
+++ b/lib_com/lsf_dec_bfi_fx.c
@@ -0,0 +1,301 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+#include
+#include
+#include
+#include "stl.h"
+#include "basop_util.h"
+#include "rom_com_fx.h"
+#include "cnst_fx.h"
+#include "prot_fx.h"
+
+
+/*---------------------------------------------------------------------*
+* routine: lsf_dec_bfi()
+*
+* Estimate the LSFs in case of FER
+* Bad frame, all active speech coders
+*---------------------------------------------------------------------*/
+void lsf_dec_bfi(
+ const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */
+ Word16*lsf, /*!< o : 14Q1*1.28 quantized ISFs */
+ const Word16*lsfold, /*!< i : 14Q1*1.28 past quantized ISF */
+ Word16*lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */
+ const Word16 lsfBase[], /* i : base for differential lsf coding */
+ Word16*mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */
+ Word16*mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */
+ Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) */
+ const Word16 last_coder_type, /*!< i : coding type in last good received fr. */
+ Word16 L_frame,
+ const Word16 last_good, /*!< i : last good received frame */
+ const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */
+ Word8 plcBackgroundNoiseUpdated,
+ Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */
+ Word16 *lsf_cng,
+ Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise */
+ const Word16 Last_GSC_pit_band_idx,
+ const Word16 Opt_AMR_WB /* i : IO flag */
+ , const Word8 tcxonly
+ ,const short MODE1_bwidth /* i: coded bandwidth */
+)
+{
+ Word16 i;
+ Word16 alpha;
+ Word32 tmp;
+ Word16 lsf_mean[M];
+ const Word16* pt_meansForFading;
+ const Word16* pt_meansForMemUpdate;
+ Word16 beta;
+ Word16 gap;
+
+ IF (EQ_16(codec_mode,MODE1))
+ {
+ pt_meansForMemUpdate = lsf_mean;
+ /* Update inital guess to something stable, with proper sampling frequency and format (ISF/LSF)*/
+ IF ( Opt_AMR_WB)
+ {
+ pt_meansForFading = Mean_isf_wb;
+ }
+ ELSE
+ {
+ /* 12.8kHz ACELP sampling */
+ IF( EQ_16(L_frame,L_FRAME))
+ {
+ pt_meansForFading = GEWB_Ave_fx;
+
+ if (EQ_16(MODE1_bwidth,NB))
+ {
+ pt_meansForFading = GENB_Ave_fx;
+ }
+ }
+ /* 16kHz ACELP sampling */
+ ELSE
+ {
+ pt_meansForFading = GEWB2_Ave_fx;
+ }
+ }
+ }
+ ELSE
+ {
+ pt_meansForFading = pt_meansForMemUpdate = lsfBase;
+ test();
+ if (lsf_cng != NULL && plcBackgroundNoiseUpdated)
+ {
+ pt_meansForFading = lsf_cng;
+ }
+ }
+ IF( LE_16(nbLostCmpt, 3))
+ {
+ test();
+ test();
+ IF( (EQ_16(last_coder_type, UNVOICED))) /* Clear unvoiced last good frame */
+ {
+ move16();
+ alpha = _ALPHA_UU_FX;
+ }
+ ELSE IF( EQ_16(last_coder_type,AUDIO)||EQ_16(last_good,INACTIVE_CLAS))
+ {
+ alpha = 32604/*0.995f Q15*/;
+ move16();
+ test();
+ if( Last_GSC_pit_band_idx > 0 && GT_16(nbLostCmpt, 1))
+ {
+ alpha = 26214/*0.8f Q15*/;
+ move16();
+ }
+ }
+ ELSE IF( EQ_16(last_good,UNVOICED_CLAS))
+ {
+ IF( LE_16(nbLostCmpt,1))
+ {
+ /* If stable, do not flatten the spectrum in the 1st erased frame */
+ alpha = add(mult(stab_fac, 32768 - _ALPHA_U_FX_X_2), _ALPHA_U_FX_X_2);
+ }
+ ELSE IF(EQ_16(nbLostCmpt,2))
+ {
+ alpha = sub(_ALPHA_U_FX_X_2,shr(_ALPHA_U_FX,1)); /* 0.6 */
+ }
+ ELSE
+ {
+ alpha = _ALPHA_U_FX;
+ move16(); /* go rapidly to CNG spectrum */
+ }
+ }
+ ELSE IF( EQ_16(last_good ,UNVOICED_TRANSITION))
+ {
+ alpha = _ALPHA_UT_FX;
+ move16();
+ }
+ ELSE IF( (EQ_16(last_good,VOICED_CLAS))||(EQ_16(last_good,ONSET)))
+ {
+ /* clearly voiced - mild convergence to the CNG spectrum for the first 3 erased frames */
+ move16();
+ alpha = _ALPHA_V_FX;
+ }
+ ELSE IF( EQ_16(last_good ,SIN_ONSET))
+ {
+ alpha = _ALPHA_S_FX;
+ move16();
+ }
+ ELSE
+ {
+ alpha = _ALPHA_VT_FX; /* rapid convergence to the CNG spectrum (long erasure, ONSETS) */
+ }
+ }
+ ELSE
+ {
+ Word16 exp = 15;
+ alpha = Inv16(nbLostCmpt, &exp); /*1.f/bfi_cnt;*/
+ alpha = shl(alpha,exp);
+ }
+ IF(EQ_16(codec_mode,MODE1))
+ {
+ beta = BETA_FEC_FX;
+ move16();
+ }
+ ELSE
+ {
+ beta = 8192/*0.25f Q15*/;
+ move16();
+ if (plcBackgroundNoiseUpdated)
+ {
+ beta = 0/*0.f Q15*/;
+ move16();
+ }
+ }
+ FOR (i=0; i
+#include
+#include "cnst_fx.h"
+#include "rom_com_fx.h"
+#include "prot_fx.h"
+#include "stl.h"
+#include "basop_util.h"
+#include "prot_fx.h"
+#include "options.h"
+
+#define swap(x,y,type) {type u__p; u__p=x; x=y; y=u__p;}
+
+extern const Word16 tbl_mid_gen_wb_5b_fx[];
+extern const Word16 tbl_mid_unv_wb_5b_fx[];
+
+
+
+
+void midlsf_dec(
+ const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */
+ const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */
+ Word16 idx, /* i: codebook index */
+ Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */
+ Word16 coder_type,
+ Word16 *mid_lsf_int,
+ Word16 prev_bfi,
+ Word16 safety_net)
+{
+ const Word16 *ratio=NULL;
+ Word16 j;
+ Word32 L_tmp;
+ Word16 bad_spacing = 0;
+
+ move16();
+ /* Select codebook */
+ IF ( EQ_16(coder_type, UNVOICED))
+ {
+ ratio = tbl_mid_unv_wb_5b_fx;
+ }
+ ELSE
+ {
+ ratio = tbl_mid_gen_wb_5b_fx;
+ }
+ FOR (j=0; jQ(x2.56+14)*/
+ L_tmp = L_mac(L_tmp, ratio[idx*M+j], qlsf1[j]); /*Q(x2.56+14)*/
+ qlsf[j] = round_fx(L_shl(L_tmp,2)); /*Q(x2.56)*/
+ }
+
+
+ IF(mid_lsf_int != NULL) /*at the decoder*/
+ {
+ /* check for incorrect LSF ordering */
+ IF ( EQ_16(*mid_lsf_int, 1))
+ {
+ FOR (j=1; j 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX)))
+ {
+ qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX);
+ move16();
+ }
+
+ }
+ }
+ ELSE
+ {
+ /* otherwise, use regular LSF spacing and ordering as in the encoder */
+ FOR (j=0; j 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX)))
+ {
+ qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX);
+ move16();
+ }
+ }
+ }
+ if ( prev_bfi )
+ {
+ /* continue redoing mid-LSF interpolation with 0.4 in order not to propagate the error */
+ *mid_lsf_int = 1;
+ move16();
+ }
+ if ( safety_net )
+ {
+ /* safety-net encountered -> stop redoing mid-LSF interpolation with 0.4 */
+ *mid_lsf_int = 0;
+ move16();
+ }
+ }
+ ELSE
+ {
+ /* use regular LSF spacing */
+ FOR (j=0; j 0 && LT_16(j, M)&<_16(qlsf[j],add(qlsf[j-1],LSF_GAP_MID_FX)))
+ {
+ qlsf[j] = add(qlsf[j-1], LSF_GAP_MID_FX);
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+Word16 lsf_ind_is_active(
+ const Word16 lsf_q_ind[],
+ const Word16 means[],
+ Word16 narrowband,
+ Word16 cdk
+)
+{
+ Word16 lsf[2], min_distance;
+
+ lsf[0] = add(lsf_q_ind[0], means[0]);
+ move16();
+ lsf[1] = add(lsf_q_ind[1], means[1]);
+ move16();
+
+ min_distance = lsf[0];
+ move16();
+ min_distance = s_min(min_distance, sub(lsf[1], lsf[0]));
+
+ assert(narrowband == 0 || narrowband == 1);
+ assert(cdk == 0 || cdk == 1);
+
+ return sub(min_distance, min_distance_thr[narrowband][cdk]) < 0;
+}
+
diff --git a/lib_com/lsf_tools_fx.c b/lib_com/lsf_tools_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f5d593f4479442b2edd35557c1e09e8c07e21437
--- /dev/null
+++ b/lib_com/lsf_tools_fx.c
@@ -0,0 +1,3426 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include
+#include
+#include "options.h" /* Compilation switches */
+#include "stl.h"
+#include "basop_util.h"
+#include "rom_com_fx.h"
+#include "cnst_fx.h"
+#include "prot_fx.h"
+#include "rom_com_fx.h" /* Static table prototypes */
+
+
+
+#define NC_MAX 8
+#define GUESS_TBL_SZ 256
+
+#define depack_4_values(cbp, val0, val1, val2, val3) \
+ val0 = shr((cbp)[0], 4); \
+ val1 = shr((cbp)[1], 4); \
+ val2 = shr((cbp)[2], 4); \
+ val3 = add(add(shr(lshl((cbp)[2],12),4),lshr(lshl((cbp)[1],12),8)),s_and((cbp)[0],0xF));
+
+/*-------------------------------------------------------------------*
+ * Local constants
+ *-------------------------------------------------------------------*/
+
+#define NC ( M/2)
+#define NC16k ( M16k/2)
+
+#define SPC 0.0234952f
+#define SPC_plus SPC * 1.001f
+#define ALPHA_SQ ( ( 0.5f / PI2) * ( 0.5f / PI2))
+
+/*-------------------------------------------------------------------*
+ * Local functions
+ *-------------------------------------------------------------------*/
+Word16 root_search_fx( Word16 low, Word16 high, Word32 *v_low, Word32 *coef,Word16 order);
+Word32 calc_weight( Word16 delta1,Word16 delta2,Word16 *n1 );
+Word32 polynomial_eval_fx( Word16 f, Word32 *coef,Word16 order);
+void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m);
+void E_LPC_lsp_lsf_conversion(const Word16 lsp[],Word16 lsf[],const Word16 m);
+Word16 E_LPC_f_lsp_pol_get(const Word16 lsp[], Word32 f[], const Word16 n, const Word16 past_Ovf, const Word16 isMODE1);
+
+static Word16 chebyshev(Word16 x, Word32 *f, Word16 n, Word16 shift)
+{
+
+ Word16 cheb;
+ Word32 t0, b1, b2;
+
+ cheb = norm_s(x);
+ if (cheb)
+ {
+ x = shl(x,1);
+ }
+ t0 = Mpy_32_16_1(*f++, x); /* t0 = x*b2 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b2 */
+ b1 = L_add(t0, *f++); /* b1 = 2*x*b2 + f[1] */
+
+ /* i = 2 */
+ t0 = Mpy_32_16_1(b1, x); /* t0 = x*b1 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */
+ b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */
+
+ /* i = 3 */
+ t0 = Mpy_32_16_1(b2, x); /* t0 = x*b1 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */
+ t0 = L_sub(t0, b1); /* t0 = 2*x*b1 - b2 */
+ b1 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */
+
+ /* i = 4 */
+ t0 = Mpy_32_16_1(b1, x); /* t0 = x*b1 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */
+ t0 = L_sub(t0, b2); /* t0 = 2*x*b1 - b2 */
+
+ /* If the LP order is greater than 10 */
+ IF(GT_16(n, 5))
+ {
+ b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */
+ /* i = 5 */
+ t0 = Mpy_32_16_1(b2, x); /* t0 = x*b1 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */
+ t0 = L_sub(t0, b1); /* t0 = 2*x*b1 - b2 */
+ b1 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */
+
+ /* i = 6 */
+ t0 = Mpy_32_16_1(b1, x); /* t0 = x*b1 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */
+ t0 = L_sub(t0, b2); /* t0 = 2*x*b1 - b2 */
+ }
+ /* IF (sub(n,8) == 0) */
+ IF (n == 8)
+ {
+ b2 = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */
+ /* i = 7 */
+ t0 = Mpy_32_16_1(b2, x); /* t0 = x*b1 */
+ if (!cheb)
+ t0 = L_shl(t0, 1); /* t0 = 2*x*b1 */
+ t0 = L_sub(t0, b1); /* t0 = 2*x*b1 - b2 */
+ /*b1 = L_add(b2,0);*/
+ }
+ ELSE
+ {
+ b2 = b1;
+ move32();
+ }
+
+ t0/*b2*/ = L_add(t0, *f++); /* b0 = 2*x*b1 - b2 + f[i] */
+
+ t0 = Mpy_32_16_1(t0/*b2*/, x);/* t0 = x*b1 */
+ if (cheb)
+ t0 = L_shr(t0,1);
+ t0 = L_sub(t0, /*b1*/b2); /* t0 = x*b1 - b2 */
+ t0 = L_add(t0, *f++); /* t0 = x*b1 - b2 + 0.5*f[n] */
+
+
+ BASOP_SATURATE_WARNING_OFF
+ t0 = L_shl(t0, shift); /* Qx to Q30 with saturation */
+ cheb = round_fx(t0); /* Result in Q14 */
+ cheb = s_max(-32767,cheb); /* to avoid saturation */
+ BASOP_SATURATE_WARNING_ON
+ return (cheb);
+}
+
+void E_LPC_a_isp_conversion(const Word16 a[], Word16 isp[], const Word16 old_isp[], const Word16 m)
+{
+ Word16 i, nf, ip, order, nc;
+ Word16 xlow, ylow, xhigh, yhigh;
+ Word16 x, y, tmp, exp;
+ Word32 f[2][NC_MAX+1];
+ Word32 t0, t1;
+ Word16 scale=1024;
+
+
+ /*-------------------------------------------------------------*
+ * find the sum and diff polynomials F1(z) and F2(z)
+ * F1(z) = [A(z) + z^M A(z^-1)]
+ * F2(z) = [A(z) - z^M A(z^-1)]/(1-z^-2)
+ *
+ * for (i=0; i 1; i--)
+ {
+ /* f2[i] -= f2[i-2]; */
+ f2[i] = L_sub(f2[i], f2[i - 2]);
+ move32();
+ }
+
+ /*----------------------------------------------------------*
+ * Scale F1(z) by (1+isp[m-1]) and F2(z) by (1-isp[m-1]) *
+ *----------------------------------------------------------*/
+
+ FOR (i = 0; i < nc; i++)
+ {
+ /* f1[i] *= (1.0 + isp[m-1]); */
+ f1[i] = Madd_32_16(f1[i], f1[i], isp[m - 1]);
+ move32();
+
+ /* f2[i] *= (1.0 - isp[m-1]); */
+ f2[i] = Msub_32_16(f2[i], f2[i], isp[m - 1]);
+ move32();
+ }
+
+ /*-----------------------------------------------------*
+ * A(z) = (F1(z)+F2(z))/2 *
+ * F1(z) is symmetric and F2(z) is antisymmetric *
+ *-----------------------------------------------------*/
+
+ /* Maximum LPC */
+ tmax = L_deposit_l(1);
+ FOR (i = 1; i < nc; i++)
+ {
+ t0 = L_add(f1[i], f2[i]);
+ tmax = L_max( tmax, L_abs(t0) );
+ t0 = L_sub(f1[i], f2[i]);
+ tmax = L_max( tmax, L_abs(t0) );
+ }
+ q = s_min( norm_l(tmax), 6 );
+
+ DO
+ {
+
+ /* a[0] = 1.0 */
+ a[0] = shl(256,q);
+ move16();
+ j = sub(m, 1);
+ FOR (i = 1; i < nc; i++)
+ {
+ /* a[i] = 0.5*(f1[i] + f2[i]) */
+ t0 = L_add(f1[i], f2[i]); /* f1[i] + f2[i] */
+ t0 = L_shl(t0, q);
+ a[i] = round_fx(t0); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[j] = 0.5*(f1[i] - f2[i]) */
+ t0 = L_sub(f1[i], f2[i]); /* f1[i] - f2[i] */
+ t0 = L_shl(t0, q);
+ a[j] = round_fx(t0); /* from Q23 to Q12 and * 0.5 */
+
+ j = sub(j,1);
+ }
+
+ /* a[NC] = 0.5*f1[NC]*(1.0 + isp[m-1]) */
+ t0 = Madd_32_16(f1[nc], f1[nc], isp[m - 1]);
+
+ BASOP_SATURATE_WARNING_OFF /*overflow handling in loop expression*/
+ t0 = L_shl(t0, q);
+ t0n = L_sub(t0 , 0x7FFFFFFF); /*check for positive overflow*/
+ t0p = L_sub(t0, 0x80000000); /*check for negative overflow*/
+ BASOP_SATURATE_WARNING_ON
+
+ q = sub(q,1); /*decrease q in case of overflow*/
+ } WHILE(t0n == 0 || t0p == 0); /*in case of overflow, recalculate coefficients*/
+
+ a[nc] = round_fx(t0); /* from Q23 to Q12 and * 0.5 */
+
+ /* a[m] = isp[m-1] */
+ t0 = L_mult(a[0], isp[m - 1]); /* from Q15 to Q12 */
+ a[m] = round_fx(t0);
+
+
+ return;
+}
+
+/*===================================================================*/
+/* FUNCTION : lpc2lsp_fx () */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Convert LPC coefficients to LSP coefficients */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* */
+/* _ (Word32 []) a : LPC coefficients, Q27 */
+/* _ (Word16 []) old_freq: Previous frame LSP coefficients, Q15 */
+/* _ (Word16 []) order: LPC order */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 []) freq: LSP coefficients, Q15 */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word16) flag: 1 means all 10 LSPs are found, 0 otherwise */
+/*===================================================================*/
+Word16 lpc2lsp_fx(
+ Word32* a,
+ Word16* freq,
+ Word16* old_freq,
+ Word16 order
+)
+{
+ Word16 i;
+ Word16 rt, low, high, prev_rt, rc;
+ Word32 p[11], q[11]; /* Q26 */
+ Word32 Ltemp, v_low;
+ Word32 Lacc;
+ Word16 tfreq[21];
+
+ /* First construct the P,Q polynomial */
+ /* p[0] = q[0] = 1 */
+ /* p[i] = -lpcCoeff[i] - lpcCoeff[11-i] - p[i-1] ( 1<=i<=5)*/
+ /* q[i] = -lpcCoeff[i] + lpcCoeff[11-i] + q[i-1] ( 1<=i<=5)*/
+ Ltemp = L_deposit_h( 0x400 ); /* Ltemp is 1.0 in Q26 */
+
+ p[0] = Ltemp;
+ move32();
+ q[0] = Ltemp;
+ move32();
+
+ FOR ( i = 1; i < ( order / 2 ) + 1; i++ )
+ {
+ Lacc = a[order - i];
+ move32();/* Q27 */
+ Lacc = L_sub( Lacc, a[i - 1] ); /* Lacc=-lpcCoeff[i-1] + lpcCoeff[order-i]//Q27 */
+ q[i] = L_add( L_shr( Lacc, 1 ), q[i - 1] );
+ move32();/* Q26 */
+
+ Lacc = L_add( Lacc, L_shl( a[i - 1], 1 ) );/* Lacc=lpcCoeff[i-1] + lpcCoeff[order-i]//Q27 */
+
+ p[i] = L_sub( L_negate( L_shr( Lacc, 1 ) ), p[i - 1] );
+ move32();/* Q26 */
+ }
+
+ /* Search roots of the P and Q polynomials */
+
+ v_low = polynomial_eval_fx( 0, p, order ); /* Q25 */
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ move16();
+ low = 0;
+ high = 8;
+ prev_rt = 0;
+ rc = 0; /* root counter */
+ FOR ( i = 0; i < 32; i++ )
+ {
+ rt = root_search_fx( low, high, &v_low, p, order );
+ low = high;
+ move16();
+ high = add( high, 8 );
+
+ IF( GE_16( rt, prev_rt ))
+ {
+ tfreq[rc] = rt;
+ move16();
+ rc = add( rc, 2 );
+ }
+ prev_rt = add( rt, 6 );
+ } /* End for P roots */
+
+ tfreq[rc] = 0x3f80;
+ move16(); /* Set a high enough value as fake root for Q search */
+
+ IF ( LT_16( rc, order ))
+ {
+ /* lost P root */
+ /* copy from previous LSP and return */
+ FOR ( i = 0; i < order; i++ )
+ {
+ move16();
+ freq[i] = old_freq[i];
+ }
+ return ( 0 );
+ }
+ ELSE
+ {
+ /* Search for Q roots between P roots */
+ v_low = L_deposit_h( 0x800 ); /* Init a positive value for v_low */
+ rc = 1;
+ move16();
+ FOR ( i = 0; i < order / 2; i++ )
+ {
+ low = shr( tfreq[rc - 1], 6 );
+ high = add( shr( tfreq[rc + 1], 6 ), 1 );
+ rt = root_search_fx( low, high, &v_low, q, order );
+
+ IF ( rt < 0 )
+ {
+ /* No Q root in this interval */
+ /* copy from previous LSP and return */
+ FOR ( i = 0; i < order; i++ )
+ {
+ move16();
+ freq[i] = old_freq[i];
+ }
+ return ( 0 );
+ }
+ ELSE
+ {
+ move16();
+ tfreq[rc] = rt;
+ rc = add( rc, 2 );
+ } /* end else, find Q root */
+ } /* end for */
+ } /* end else */
+
+ FOR ( i = 0; i < order; i++ )
+ {
+ freq[i] = tfreq[i];
+ move16();
+ }
+
+ return ( 1 );
+}
+
+/*===================================================================*/
+/* FUNCTION : lsp2lpc_fx () */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Convert LSP coefficients to LPC coefficients */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* */
+/* _ (Word16 []) freq: LSP coefficients, Q15 */
+/* _ (Word16 []) prev_a : previous frame LPC coefficients, Q12 */
+/* _ (Word16 []) order : LPC order */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 []) a : LPC coefficients, Q12 */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*===================================================================*/
+void lsp2lpc_fx(
+ Word16 *a,
+ Word16 *freq,
+ Word16 *prev_a,
+ Word16 order
+)
+{
+ Word16 i;
+ Word32 pq[ LPC_SHB_ORDER ] ;
+ Word32 p[ LPC_SHB_ORDER ], q[ LPC_SHB_ORDER ];
+ Word32 Ltemp;
+ Word32 Lacc;
+ Word16 tmp_pci[M+1];
+ Word16 giOverflow;
+
+
+ FOR ( i = 0; i < order; i++ )
+ {
+ tmp_pci[i]=prev_a[i];
+ move16();
+ }
+
+ compute_poly_product_fx( freq, pq, order );
+ /*This change is to get funtionality if L_sub_sat*/
+ giOverflow = 0 ;
+ move16(); /* clear overflow flag */
+ Overflow = 0;
+ move16();
+ FOR ( i=0; i < order/2; i++ )
+ {
+ Ltemp = L_add( pq[ i ], pq[ i + 1 ] );
+ giOverflow = ( Word16 )Overflow;
+ move16();
+ IF ( EQ_16(giOverflow,1))
+ {
+ BREAK;
+ }
+
+ p[ i ] = Ltemp ;
+ move32();
+ }
+
+ IF ( EQ_16(giOverflow,1))
+ {
+ FOR (i=0; i < order; i++ )
+ {
+ a[i] = mult_r( prev_a[i], pwAlpha[i] );
+ move16();
+ }
+ return;
+ }
+
+ compute_poly_product_fx( freq+1, pq, order );
+
+
+ giOverflow = 0;
+ move16();
+ Overflow = 0;
+ move16();
+
+ FOR ( i=0; i < order/2; i++ )
+ {
+ Ltemp = L_sub( pq[ i+1 ], pq[i] );
+ giOverflow = ( Word16 ) Overflow;
+ move16();
+ IF ( EQ_16(giOverflow,1))
+ {
+ BREAK;
+ }
+
+ q[i] = Ltemp;
+ move32();
+ }
+
+ IF ( EQ_16(giOverflow,1))
+ {
+ FOR (i = 0; i < order; i++ )
+ {
+ a[i] = mult_r( prev_a[i], pwAlpha[i] );
+ move16();
+ }
+ }
+ ELSE
+ {
+ FOR (i = 0; i < order/2; i++ )
+ {
+ Overflow = 0;
+ move16();
+ Lacc = L_add( p[i], q[i] ); /* p[i], q[i] in Q24 */
+ if ( Overflow )
+ {
+ giOverflow = 1;
+ move16();
+ }
+
+ Lacc = L_negate( Lacc ); /* Lacc=-(p[i]-q[i])/2 in Q25 */
+ Overflow = 0;
+ move16();
+ Lacc = L_add( L_shl( Lacc, 3 ), 0x08000 ); /* rounding */
+ if ( Overflow )
+ {
+ giOverflow = 1;
+ move16();
+ }
+
+ a[i] = extract_h( Lacc ); /* a[i] in Q12 */
+
+ IF ( EQ_16(giOverflow,1))
+ {
+ BREAK;
+ }
+
+ }
+ FOR ( i=0; i < order/2; i++ )
+ {
+ Overflow = 0;
+ move16();
+ Lacc = L_sub( q[i], p[i] ); /* p[i], q[i] in Q24 */
+ if( Overflow )
+ {
+ giOverflow = 1;
+ move16();
+ }
+ Overflow = 0;
+ move16();
+ Lacc = L_add( L_shl( Lacc, 3 ), 0x08000); /* rounding */
+ if ( Overflow )
+ {
+ giOverflow = 1;
+ move16();
+ }
+
+ a[ order-1-i ] = extract_h( Lacc );
+
+
+ IF ( EQ_16(giOverflow,1))
+ {
+ BREAK;
+ }
+
+ }
+ }
+
+
+ IF ( EQ_16(giOverflow,1))
+ {
+ FOR ( i = 0; i < order; i++ )
+ {
+ a[i] = mult_r( tmp_pci[i], pwAlpha[i] );
+ move16();
+ }
+ }
+
+}
+
+/*
+ * E_LPC_f_lsp_pol_get
+ *
+ * Parameters:
+ * lsp/isp I: Line spectral pairs (cosine domaine) Q15
+ * f O: the coefficients of F1 or F2 Q23
+ * n I: no of coefficients (m/2)
+ * == NC for F1(z); == NC-1 for F2(z)
+ * fact I: scaling factor
+ *
+ *-----------------------------------------------------------*
+ * procedure E_LPC_f_lsp_pol_get: *
+ * ~~~~~~~~~~~ *
+ * Find the polynomial F1(z) or F2(z) from the LSPs. *
+ * This is performed by expanding the product polynomials: *
+ * *
+ * F1(z) = product ( 1 - 2 LSF_i z^-1 + z^-2 ) *
+ * i=0,2,4,6,8 *
+ * F2(z) = product ( 1 - 2 LSF_i z^-1 + z^-2 ) *
+ * i=1,3,5,7,9 *
+ * *
+ * where LSP_i are the LSPs in the cosine domain. *
+ * *
+ *-----------------------------------------------------------*
+ * R.A.Salami October 1990 *
+ *-----------------------------------------------------------*
+ */
+Word16 E_LPC_f_lsp_pol_get(const Word16 lsp[], Word32 f[], const Word16 n, const Word16 past_Ovf, const Word16 isMODE1)
+{
+ /* All computation in Q23 */
+ const Word16 *plsp;
+ Word16 i, j;
+ Word16 b;
+ Word32 b32;
+ Word16 Ovf = 0;
+ Word16 Q_out;
+ Word16 m2;
+
+
+ Q_out = 31-23;
+ move16();
+ Ovf = past_Ovf;
+ move16();
+
+ test();
+ if(past_Ovf && isMODE1) /* Currently this feature is implemented only in MODE1 */
+ {
+ /* In some NB cases, overflow where detectected
+ in f1 or f2 polynomial computation when it
+ happen we reduce the precision of the computing
+ to limit the risk of saturation*/
+ Q_out = add(Q_out, past_Ovf);
+ }
+ Overflow = 0;
+ move16();
+ plsp = lsp;
+ f[0] = L_shl(1, sub(31, Q_out));
+ move32();
+ /*b = -2.0f * *plsp;*/
+ b = *plsp;
+ move16();
+ m2 = shl(-2, sub(15, Q_out));
+ f[1] = L_mult(b, m2);
+ move32();
+
+ FOR (i = 2; i <= n; i++)
+ {
+ plsp += 2;
+ /*b = 2.0f * *plsp;*/
+ move16();
+ b = *plsp;
+ b32 = L_mult(b, m2);
+
+ /*f[i] = -b*f[i-1] + 2.0f*f[i-2];*/
+ move32();
+ f[i] = L_shl(L_sub(f[i-2], Mpy_32_16_1(f[i-1], b)),1);
+
+ FOR (j = i-1; j > 1; j--)
+ {
+ /*f[j] += b*f[j-1] + f[j-2];*/
+ move32();
+ f[j] = L_add(f[j], L_sub(f[j-2], L_shl(Mpy_32_16_1(f[j-1], b),1)));
+ }
+ move32();
+ f[1] = L_add(f[1], b32);
+ }
+
+
+ test();
+ IF (Overflow>0 && isMODE1)
+ {
+ /* If an overflow is detected, redo the computation with 1 bit less */
+ Ovf = add(Ovf,1);
+ Ovf = E_LPC_f_lsp_pol_get(lsp, f, n ,Ovf, isMODE1);
+ }
+ return Ovf;
+}
+
+void E_LPC_a_lsp_conversion(
+ const Word16 *a, /* input : LP filter coefficients (Qx) */
+ Word16 *lsp, /* output: Line spectral pairs (in the cosine domain)(0Q15) */
+ const Word16 *old_lsp, /* input : LSP vector from past frame (0Q15) */
+ const Word16 m /* input : length of the LP filter coefficients */
+)
+{
+ Word16 i, nf, ip, nc;
+ Word16 xlow, ylow, xhigh, yhigh;
+ Word16 x, y, tmp, exp;
+ Word32 f[2][NC_MAX+1];
+ Word32 t0, t1;
+ Word32 sum, diff;
+ Word16 scale;
+
+
+
+ nc = shr(m, 1);
+
+ scale = shl( 128, norm_s(a[0]) );
+
+ /*-------------------------------------------------------------*
+ * find the sum and diff polynomials F1(z) and F2(z) *
+ * F1(z) = [A(z) + z^11 A(z^-1)]/(1+z^-1) *
+ * F2(z) = [A(z) - z^11 A(z^-1)]/(1-z^-1) *
+ *-------------------------------------------------------------*/
+
+ f[0][0] = L_mult(a[0],scale); /*1.0f in Q23*/ move32();
+ f[1][0] = L_mult(a[0],scale); /*1.0f in Q23*/ move32();
+ FOR (i = 1; i < nc; i++)
+ {
+ t0 = L_mult(a[i],scale); /*Q23*/
+ sum = L_mac(t0, a[m+1-i],scale);
+ diff = L_msu(t0, a[m+1-i],scale);
+ f[0][i] = L_sub(sum,f[0][i-1]);
+ move32(); /*Q23*/
+ f[1][i] = L_add(diff,f[1][i-1]);
+ move32(); /*Q23*/
+ }
+ t1 = L_mult0(a[i],scale); /*Q23-1*/
+ sum = L_mac0(t1, a[m+1-i],scale);
+ diff = L_msu0(t1, a[m+1-i],scale);
+ f[0][nc] = L_sub(sum, L_shr(f[0][i-1],1));
+ move32(); /*Q23-1*/
+ f[1][nc] = L_add(diff,L_shr(f[1][i-1],1));
+ move32(); /*Q23-1*/
+
+ /* Precalculate difference to index 0 for index 2 */
+ f[0][2] = L_sub(f[0][2], f[0][0]);
+ move32();
+ f[1][2] = L_sub(f[1][2], f[1][0]);
+ move32();
+
+ /*---------------------------------------------------------------------*
+ * Find the LSPs (roots of F1(z) and F2(z) ) using the *
+ * Chebyshev polynomial evaluation. *
+ * The roots of F1(z) and F2(z) are alternatively searched. *
+ * We start by finding the first root of F1(z) then we switch *
+ * to F2(z) then back to F1(z) and so on until all roots are found. *
+ * *
+ * - Evaluate Chebyshev pol. at grid points and check for sign change.*
+ * - If sign change track the root by subdividing the interval *
+ * 4 times and ckecking sign change. *
+ *---------------------------------------------------------------------*/
+ nf = 0;
+ move16(); /* number of found frequencies */
+ ip = 0;
+ move16(); /* indicator for f1 or f2 */
+
+ xlow = Grid[0];
+ move16();
+ ylow = chebyshev(xlow, f[ip], nc, 8);
+
+ FOR (i = 1; i <= GRID100_POINTS; i++)
+ {
+ xhigh = xlow;
+ move16();
+ yhigh = ylow;
+ move16();
+ xlow = Grid[i];
+ move16();
+ ylow = chebyshev(xlow, f[ip], nc, 8);
+
+ IF (L_mult(ylow, yhigh) <= 0)
+ {
+ t0 = L_mult(xhigh, 0x4000);
+ /* divide 2 times the interval */
+ x = mac_r(t0, xlow, 0x4000); /* xmid = (xlow + xhigh)/2 */
+ y = chebyshev(x, f[ip], nc, 8);
+
+ IF (L_mult(ylow, y) <= 0)
+ {
+ yhigh = y;
+ move16();
+ xhigh = x;
+ move16();
+ y = ylow;
+ move16();
+ x = xlow;
+ move16();
+ /* 'xhigh' has changed, update 't0' */
+ t0 = L_mult(xhigh, 0x4000);
+ }
+ xlow = mac_r(t0, x, 0x4000); /* xmid = (xlow + xhigh)/2 */
+ ylow = chebyshev(xlow, f[ip], nc, 8);
+
+ IF (L_mult(y, ylow) <= 0)
+ {
+ yhigh = ylow;
+ move16();
+ xhigh = xlow;
+ move16();
+ ylow = y;
+ move16();
+ xlow = x;
+ move16();
+ }
+
+ /*--------------------------------------------------------*
+ * Linear interpolation
+ * xint = xlow - ylow*(xhigh-xlow)/(yhigh-ylow)
+ *--------------------------------------------------------*/
+ y = msu_r(L_mult(yhigh,0x4000), ylow,0x4000);
+
+ IF (y != 0)
+ {
+ x = sub(xhigh, xlow);
+ BASOP_SATURATE_WARNING_OFF
+ tmp = abs_s(y);
+ BASOP_SATURATE_WARNING_ON
+ exp = norm_s(tmp);
+ if (exp)
+ tmp = shl(tmp, exp);
+ tmp = div_s((Word16) 16383/2, tmp);
+ t0 = L_mult(x, tmp);
+ t0 = L_shr(t0, sub(20, exp));
+ tmp = extract_l(t0); /* y = (xhigh-xlow)/(yhigh-ylow) in Q11 */
+
+ /* Restore Sign */
+ if (y < 0)
+ tmp = negate(tmp);
+
+ t0 = L_mult(ylow, tmp); /* result in Q26 */
+ t0 = L_shr(t0, 11); /* result in Q15 */
+ xlow = sub(xlow, extract_l(t0));/* xint = xlow - ylow*y */
+ }
+ lsp[nf++] = xlow;
+ move16();
+
+ IF (GE_16(nf,m))
+ {
+ BREAK;
+ }
+
+ ip = s_xor(ip, 1);
+ ylow = chebyshev(xlow, f[ip], nc, 8);
+ }
+ }
+
+ /* Check if m roots found */
+ /* if not use the LSPs from previous frame */
+
+ IF (LT_16(nf,m))
+ {
+ FOR(i=0; i= 0; i--) /* Reverify the minimum LSF gap in the reverse direction */
+ {
+ if (GT_16(lsf[i], lsf_max))
+ {
+ lsf[i] = lsf_max;
+ move16();
+ }
+ lsf_max = sub(lsf[i], min_dist);
+ }
+ }
+}
+
+void space_lsfs_fx (
+ Word16* lsfs, /* i/o: Line spectral frequencies */
+ const Word16 order /* i : order of LP analysis */
+)
+{
+ Word16 delta; /* Q1.15 */
+ Word16 i, flag=1;
+
+ WHILE ( flag == 1 )
+ {
+ flag = 0;
+ move16();
+ FOR ( i = 0; i <= order; i++ )
+ {
+ IF( i == 0 )
+ {
+ delta = lsfs[0];
+ move16();
+ }
+ ELSE
+ {
+ IF( EQ_16(i,order))
+ {
+ delta = sub( HALF_POINT_FX, lsfs[i-1] );
+ move16();
+ }
+ ELSE
+ {
+ delta = sub( lsfs[i], lsfs[i-1] );
+ move16();
+ }
+ }
+ IF ( LT_16( delta, SPC_FX ))
+ {
+ flag = 1;
+ move16();
+ delta = sub( delta, SPC_PLUS_FX );
+
+ IF ( i == order )
+ {
+ lsfs[i - 1] = add( lsfs[i - 1], delta );
+ move16();
+ }
+ ELSE
+ {
+ IF ( i == 0 )
+ {
+ lsfs[i] = sub( lsfs[i], delta );
+ move16();
+ }
+ ELSE
+ {
+ delta = mult_r( delta, HALF_POINT_FX );
+ lsfs[i - 1] = add( lsfs[i - 1], delta );
+ move16();
+ lsfs[i] = sub( lsfs[i], delta );
+ move16();
+ }
+ }
+ }
+ }
+ }
+
+ return;
+}
+
+/*=================================================================== */
+/* FUNCTION : lsp_weights_fx () */
+/*------------------------------------------------------------------- */
+/* PURPOSE : This function computes the weights for the */
+/* given unquantized lsp vector */
+/*------------------------------------------------------------------- */
+/* INPUT ARGUMENTS :
+_ (Word16 []) lsp_nq_fx: input unquantized lsp vector */
+/* _(Word16 Order) FilterOrder */
+/*------------------------------------------------------------------- */
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 []) w: weight vector Q(9-n_max) */
+
+/*------------------------------------------------------------------- */
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None. */
+/*------------------------------------------------------------------- */
+/* RETURN ARGUMENTS : */
+/* _ None. */
+/*=================================================================== */
+
+void lsp_weights_fx(
+ Word16 lsp_nq_fx[],
+ Word16 w[],
+ Word16 Order,
+ Word16* Qout
+)
+{
+ Word16 lpcOrder =Order;
+
+ Word16 i, n1, tmp_loop;
+ Word16 norm[20];
+ Word32 Lsum1[20];
+ Word16 delta1, delta2, temp;
+ Word16 n_max =-32768;
+ move16();
+
+ temp = 0;
+ move16();
+
+ tmp_loop = sub( lpcOrder, 1 );
+ FOR ( i = 0; i < tmp_loop; i++ )
+ {
+ delta1 = sub( lsp_nq_fx[i], temp );
+ delta2 = sub( lsp_nq_fx[i + 1], lsp_nq_fx[i] );
+ Lsum1[i] = calc_weight( delta1, delta2, &n1 );
+ move32();/* Q( 26-n1) */
+ norm[i] = n1;
+ move16();
+
+ if (GT_16(norm[i],n_max))
+ {
+ n_max = norm[i];
+ move16();
+ }
+ temp = lsp_nq_fx[i];
+ move16();
+ }
+ delta1 = sub( lsp_nq_fx[i], temp );
+ delta2 = sub( 16384, lsp_nq_fx[i] );
+
+ Lsum1[i] = calc_weight( delta1, delta2, &n1 );
+ move32(); /* Q( 26-n1) */
+ norm[i] = n1;
+ move16();
+
+ if ( GT_16(norm[i], n_max))
+ {
+ n_max = norm[i];
+ move16();
+ }
+ FOR ( i = 0; i < lpcOrder; i++ )
+ {
+ w[i] = round_fx( L_shl( Lsum1[i], sub( norm[i], n_max + 1 ) ) ); /* Q( 9-n_max) */
+ }
+
+ IF ( lpcOrder != LPC_SHB_ORDER_WB )
+ {
+ w[3] = round_fx( L_shl( L_mult( w[3], 18022 ), 1 ) ); /* Q( 9-n_max) */
+ w[4] = round_fx( L_shl( L_mult( w[4], 18022 ), 1 ) ); /* Q( 9-n_max) */
+ }
+
+ *Qout = 9 - n_max;
+ move16();
+}
+
+/*
+ * E_LPC_isf_isp_conversion
+ *
+ * Parameters:
+ * isf I: isf[m] normalized (range: 0 <= val <= 0.5) 14Q1*1.28
+ * isp O: isp[m] (range: -1 <= val < 1) Q15
+ * m I: LPC order
+ *
+ * Function:
+ * Transformation isf to isp
+ *
+ * ISF are immitance spectral pair in frequency domain (0 to 6400).
+ * ISP are immitance spectral pair in cosine domain (-1 to 1).
+ *
+ * Returns:
+ * void
+ */
+void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m)
+{
+ Word16 i;
+
+ assert( m==16 || m==10 );
+
+
+ FOR (i = 1; i < m; i++)
+ {
+ *isp++ = xsf_to_xsp(*isf++);
+ move16();
+ }
+ *isp = xsf_to_xsp(shl(*isf, 1));
+ move16();
+
+
+ return;
+}
+
+/*
+ * E_LPC_isp_isf_conversion
+ *
+ * Parameters:
+ * isp I: isp[m] (range: -1 <= val < 1) Q15
+ * isf O: isf[m] normalized (range: 0 <= val <= 6400) x1.28
+ * m I: LPC order
+ *
+ * Function:
+ * Transformation isp to isf
+ *
+ * ISP are immitance spectral pair in cosine domain (-1 to 1).
+ * ISF are immitance spectral pair in frequency domain (0 to 6400).
+ *
+ * Returns:
+ * energy of prediction error
+ */
+void E_LPC_isp_isf_conversion(const Word16 isp[], Word16 isf[], const Word16 m)
+{
+ Word16 i;
+
+ assert( m==16 || m==10 );
+
+
+
+ FOR (i = 0; i < m; i++)
+ {
+ isf[i] = xsp_to_xsf(isp[i]);
+ move16();
+ }
+
+ isf[m - 1] = shr(isf[m - 1], 1);
+ move16();
+
+
+ return;
+}
+
+
+Word16 xsf_to_xsp(Word16 lsf)
+{
+ /* lsp = cos(lsf * 3.1415/6400); */
+ return getCosWord16R2(lsf);
+}
+
+Word16 xsp_to_xsf(Word16 lsp)
+{
+ Word16 ind, tmp;
+ Word32 L_tmp;
+
+
+ /*------------------------------------------------------*
+ * find value in table that is just greater than lsp
+ *------------------------------------------------------*/
+
+ /* Retrieve Index Guess */
+ /* Based on lsp */
+ ind = mac_r(GUESS_TBL_SZ/2*65536-0x8000, lsp, GUESS_TBL_SZ/2);
+ ind = Ind_Guess[ind];
+ move16();
+
+ /* Correct Index so that */
+ /* cos_table_129[ind] > isp[i] */
+ tmp = sub(lsp, cos_table_129[ind]);
+ /*
+ 69%: (Final Index - Index Guess) is <= 1
+ 28%: (Final Index - Index Guess) is 2
+ 2%: (Final Index - Index Guess) is >= 3
+ <1%: ...
+ */
+ IF (tmp > 0) /* possible range 0 to -5 (-1-2-2) */
+ {
+ ind = sub(ind, 1);
+ tmp = sub(lsp, cos_table_129[ind]);
+
+ IF (tmp > 0)
+ {
+ ind = sub(ind, 2);
+ tmp = sub(lsp, cos_table_129[ind]);
+ if (tmp > 0)
+ {
+ ind = sub(ind, 2);
+ }
+ tmp = sub(lsp, cos_table_129[ind+1]);
+ if (tmp <= 0)
+ {
+ ind = add(ind, 1);
+ }
+ tmp = sub(lsp, cos_table_129[ind]);
+ }
+ }
+
+ /* acos(lsp)= ind*128 + (lsp-cos_table_129[ind]) * acos_slope[ind] / 2048 */
+ L_tmp = L_mac(1L<<11, tmp, acos_slope[ind]);
+ L_tmp = L_shr(L_tmp, 12); /* (lsp-cos_table_129[ind]) * acos_slope[ind]) >> 11 */
+ L_tmp = L_mac0(L_tmp, ind, 128);
+
+
+ return extract_l(L_tmp);
+}
+
+/*-------------------------------------------------------------------*
+ * a2rc()
+ *
+ * Convert from LPC to reflection coeff
+ *-------------------------------------------------------------------*/
+
+void a2rc_fx( const Word16* a, /* i: can be any Q */
+ Word16* refl, /* o: Q15 */
+ Word16 lpcorder
+ )
+
+{
+ Word16 f_fx[M];
+ Word16 km_fx;
+ Word32 L_tmp1, L_tmp2;
+ Word16 tmp;
+ Word16 denom_mant, exp;
+ Word32 new_mant;
+ Word16 temp;
+ Word16 m, j, n;
+ Word16 q, q_a, q_a2, One_Qx;
+ Word32 One_Qx2;
+ q = add( norm_s(a[-1]), 1 );
+ q_a = sub(15, q);
+ q_a2 = add(shl(q_a,1),1);
+ /* copy into internal vars so they can be changed */
+
+ FOR ( m = 0; m < lpcorder; m++ )
+ {
+ /* f_fx[m] = p_fx[m]; */
+ f_fx[m] = negate(a[m]);
+ move16();
+ }
+ One_Qx = shl(1,q_a);
+ One_Qx2 = L_shl(1, q_a2);
+ FOR ( m = lpcorder - 1; m >= 0; m-- )
+ {
+ km_fx = f_fx[m];
+ move16();
+
+ test();
+ IF ( LE_16( km_fx, negate(One_Qx))||GE_16(km_fx,One_Qx))
+ {
+ FOR ( j = 0; j < lpcorder; j++ )
+ {
+ refl[j] = 0;
+ move16();
+ }
+
+ return;
+ }
+
+ refl[m] = negate( km_fx );
+ move16();
+ L_tmp1 = One_Qx2; /* 1 in 2xq_a+1 */
+ move32();
+ L_tmp1 = L_msu( L_tmp1, km_fx, km_fx ); /* 1-km*km in Q25 */
+
+ /* new_mant = invert_dp(L_tmp1,4, &tmp_denom_exp,1); sum in Q61-Q25-n=Q36-n */
+ exp = norm_l( L_tmp1 );
+ tmp = extract_h( L_shl( L_tmp1, exp ) );
+ exp = sub( sub( 30, exp ), q_a2 );
+ IF ( tmp )
+ {
+ tmp = div_s( 16384, tmp ); /* 15+exp */
+ }
+ ELSE
+ {
+ tmp = 0;
+ }
+ new_mant = L_deposit_h( tmp );
+ temp = round_fx( L_shl( new_mant, 0 ) ); /* in Q14 */
+ denom_mant = temp;
+ move16();
+ L_tmp1 = L_mult( km_fx, denom_mant ); /* km*denom. Q12*Q14 = Q27 */
+ L_tmp1 = L_shl( L_tmp1, q ); /* change to Q31. simulation showed no overflow */
+ tmp = round_fx( L_tmp1 ); /* extract in Q15 */
+
+ FOR ( j = 0; j < m / 2; j++ )
+ {
+ n = sub( sub( m, ( Word16 )1 ), j );
+ L_tmp1 = L_mult( denom_mant, f_fx[j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */
+ L_tmp1 = L_mac( L_tmp1, tmp, f_fx[n] ); /* denom*f[j]+km*denom*f[n] in Q28 (floating with exp) */
+ L_tmp2 = L_mult( denom_mant,f_fx[n] ); /* denom*f[n]. Q15*Q12 = Q28 (floating with exp) */
+ L_tmp2 = L_mac( L_tmp2, tmp,f_fx[j] ); /* denom*f[n]+km*denom*f[j] in Q28 (floating with exp) */
+ L_tmp1 = L_shr( L_tmp1, exp ); /* bringing to true Q28 */
+ L_tmp2 = L_shr( L_tmp2, exp ); /* bringing to true Q28 */
+ f_fx[j] = round_fx( L_tmp1 ); /* extracting in q_a */
+ f_fx[n] = round_fx( L_tmp2 ); /* extracting in q_a */
+ }
+
+ IF ( m & 1 )
+ {
+ L_tmp1 = L_mult( denom_mant, f_fx[ j] ); /* denom*f[j]. Q15*Q12 = Q28 (floating with exp) */
+ L_tmp1 = L_mac( L_tmp1, tmp,f_fx[j] ); /* denom*f[j]+km*denom*f[j] in Q28 (floating with exp) */
+ L_tmp1 = L_shr( L_tmp1, exp ); /* bringing to true Q28 */
+ f_fx[j] = round_fx( L_tmp1 ); /* extracting in q_a */
+ }
+ }
+
+ FOR ( j = 0; j < lpcorder; j++ )
+ {
+ refl[j] = shl( refl[j], q );
+ move16();
+ }
+
+
+ return;
+}
+Word16 vq_dec_lvq_fx (
+ Word16 sf_flag, /* i : safety net flag */
+ Word16 x[], /* o : Decoded vector Q(x2.56)*/
+ Word16 indices[], /* i : Indices */
+ Word16 stages, /* i : Number of stages */
+ Word16 N, /* i : Vector dimension */
+ Word16 mode, /* (i): mode_lvq, or mode_lvq_p */
+ Word16 no_bits, /* (i): no. bits for lattice */
+ Word32 *p_offset_scale1,
+ Word32 *p_offset_scale2,
+ Word32 *p_offset_scale1_p,
+ Word32 *p_offset_scale2_p,
+ Word16 *p_no_scales,
+ Word16 *p_no_scales_p
+)
+{
+ Word16 x_lvq[M];
+ Word16 i, stagesm1;
+ Word16 pt_fx;
+ Word16 ber_flag;
+
+ /* clear vector */
+ set16_fx(x, 0, N);
+
+ /*-----------------------------------------------*
+ * add contribution of each stage
+ *-----------------------------------------------*/
+ stagesm1 = sub(stages,1);
+ IF (EQ_16(sf_flag,1))
+ {
+ FOR(i=0; i0)
+ {
+ n_stages = 2;
+ move16();
+ levels0[0] = CBsizes_fx[nbits0];
+ move16();
+ bits0[0] = nbits0;
+ move16();
+ bits0[1] = sub(cumleft,nbits0);
+
+ IF ( bits0[1] == 0 )
+ {
+ n_stages = sub(n_stages,1);
+ }
+ ELSE
+ {
+ levels0[1] = CBsizes_fx[sub(cumleft,nbits0)];
+ move16();
+ }
+ }
+ ELSE /* no bits for VQ stage */
+ {
+ n_stages = 0;
+ move16();
+ }
+
+ *stages0 = n_stages;
+ move16();
+ IF (bits_lvq > 0)
+ {
+ bits0[n_stages] = bits_lvq;
+ move16();
+ levels0[n_stages] = bits_lvq;
+ move16();/* this is number of bits, not levels */
+ *stages0 = add(n_stages,1);
+ move16();
+ }
+ }
+ ELSE
+ {
+ *stages0 = 0;
+ move16();
+ }
+
+ /*---------------------------------------------------*
+ * Calculate bit allocation for predictive quantizer
+ *---------------------------------------------------*/
+ IF ( GT_16(framemode_p, -1))
+ {
+ cumleft = BitsVQ_p_fx[framemode_p];
+ move16();
+ bits_lvq = sub(nBits, cumleft);
+ nbits0 = CBbits_p_fx[framemode_p];
+ move16();
+
+ IF (GT_16(nbits0,-1))
+ {
+ IF ( nbits0 > 0 )
+ {
+ IF ( EQ_16(framemode_p, 7))
+ {
+ /* for UNVOICED_WB only */
+ n_stages = 3;
+ move16();
+ FOR( i=0; i0)
+ {
+ levels1[1] = CBsizes_fx[nbits0];
+ move16();
+ bits1[1] = nbits0;
+ move16();
+ n_stages = 2;
+ move16();
+ }
+
+ levels1[n_stages] = bits_lvq;
+ move16();/* this is number of bits, not levels */
+ bits1[n_stages] = bits_lvq;
+ move16();
+ *stages1 = add(n_stages ,1);
+ }
+ }
+ ELSE
+ {
+ *stages1 = 1;
+ move16();
+ bits1[0] = bits_lvq;
+ move16();
+ levels1[0] = bits_lvq;
+ move16();
+ }
+ }
+ ELSE
+ {
+ }
+ }
+
+ return;
+}
+
+Word16 find_pred_mode(
+ const Word16 coder_type, /* i: coding type */
+ const Word16 bwidth, /* i: bandwidth index */
+ const Word32 int_fs, /* i: sampling frequency */
+ Word16 * p_mode_lvq, /* o: index of LSF codebooks in safety net mode */
+ Word16 * p_mode_lvq_p, /* o: index of LSF codebooks in predictive mode (AR or MA) */
+ Word32 core_brate) /* i: core bit rate */
+{
+ Word16 idx, predmode;
+
+ /* bwidth = 0(NB), 1 (WB), 2(WB2); line index in predmode_tab[][] */
+ idx = bwidth;
+ move16();
+ if (GT_16(idx, 1))
+ {
+ idx = 1;
+ }
+ IF (EQ_32(int_fs, INT_FS_16k))
+ {
+ /* WB2 is actually used if sampling frequency is 16kHz */
+ idx = 2;
+ move16();
+ }
+ ELSE
+ {
+ test();
+ test();
+ if ((GE_32(core_brate, GENERIC_MA_LIMIT))&&(EQ_16(coder_type,GENERIC))&&(EQ_16(idx,1)))
+ {
+ idx = 3;
+ move16();
+ }
+ }
+ predmode = predmode_tab[idx][coder_type];
+ move16();
+ IF (LE_16(idx, 2))
+ {
+ *p_mode_lvq = add(i_mult2(NO_CODING_MODES, idx), coder_type);
+ IF (predmode>0)
+ {
+ *p_mode_lvq_p = *p_mode_lvq;
+ move16();
+ }
+ ELSE
+ {
+ *p_mode_lvq_p = -1;
+ move16();
+ }
+ }
+ ELSE /* WB 12.8 with MA pred in GENERIC*/
+ {
+ *p_mode_lvq = add(NO_CODING_MODES, coder_type);
+ IF (EQ_16(coder_type, GENERIC))
+ {
+ *p_mode_lvq_p = 18;
+ move16();
+ }
+ ELSE
+ {
+ IF (predmode>0)
+ {
+ *p_mode_lvq_p = *p_mode_lvq;
+ }
+ ELSE
+ {
+ *p_mode_lvq_p = -1;
+ }
+ }
+ }
+
+
+
+ return predmode;
+}
+
+/*---------------------------------------------------------------------------*
+ * reorder_isf
+ *
+ * To make sure that the isfs are properly ordered and to keep a certain
+ * minimum distance between consecutive isfs.
+ *--------------------------------------------------------------------------*/
+void reorder_isf_fx(
+ Word16 *isf, /* i/o: ISFs in the frequency domain (0..0.5) */
+ const Word16 min_dist, /* i : minimum required distance */
+ const Word16 n, /* i : LPC order */
+ const Word16 fs /* i : sampling frequency */
+)
+{
+ Word16 i, isf_min;
+ Word16 isf_max;
+
+ isf_min = min_dist;
+ move16();
+
+ /*-----------------------------------------------------------------------*
+ * Verify the ISF ordering and minimum GAP
+ *-----------------------------------------------------------------------*/
+
+ FOR (i = 0; i < n - 1; i++)
+ {
+ if (LT_16(isf[i], isf_min))
+ {
+ isf[i] = isf_min;
+ move16();
+ }
+ isf_min = add(isf[i], min_dist);
+ }
+
+ /*-----------------------------------------------------------------------*
+ * Reverify the ISF ordering and minimum GAP in the reverse order (security)
+ *-----------------------------------------------------------------------*/
+
+ /*isf_max = sub(shr(fs,1), min_dist);*/
+ isf_max = sub(fs, min_dist); /* Fs already divide per 2 */
+
+ IF (GT_16(isf[n-2], isf_max)) /* If danger of unstable filter in case of resonance in HF */
+ {
+ FOR (i = sub(n, 2); i >= 0; i--) /* Reverify the minimum ISF gap in the reverse direction */
+ {
+ if (GT_16(isf[i], isf_max))
+ {
+ isf[i] = isf_max;
+ move16();
+ }
+ isf_max = sub(isf[i], min_dist);
+ }
+ }
+}
+
+/*========================================================================*/
+/* FUNCTION : lsf_stab_fx() */
+/*------------------------------------------------------------------------*/
+/* PURPOSE : Check LSF stability (distance between old LSFs and */
+/* current LSFs) */
+/*------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) Opt_AMR_WB : flag indicating AMR-WB IO mode */
+/* _ (Word16*) lsf : LSPs from past frame Q(x2.56) */
+/* _ (Word16*) lsfold : LSPs from past frame Q(x2.56) */
+/*------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/*------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word16) stab_fac_fx : LP filter stability Q15 */
+/*========================================================================*/
+Word16 lsf_stab_fx( /* o : LP filter stability Q15*/
+ const Word16 *lsf, /* i : LSF vector Q(x2.56)*/
+ const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame /* i : frame length */
+)
+{
+ Word16 i, m;
+ Word32 L_tmp;
+ Word16 tmp, e;
+
+ /*-------------------------------------------------------------------*
+ * Check stability on lsf: distance between old lsf and current lsf
+ *-------------------------------------------------------------------*/
+ IF ( Opt_AMR_WB )
+ {
+ m = M-1;
+ move16();
+ tmp = sub(lsf[0], lsfold[0]);
+ L_tmp = L_mult(tmp, tmp); /* Q1 */
+ FOR (i = 1; i < m; i++)
+ {
+ tmp = sub(lsf[i], lsfold[i]);
+ L_tmp = L_mac(L_tmp, tmp, tmp); /* Q1 */
+ }
+ }
+ ELSE
+ {
+ m = M;
+ move16();
+ L_tmp = 0;
+ move32();
+ FOR (i = 0; i < m; i++)
+ {
+ tmp = sub(lsf[i], lsfold[i]);
+ L_tmp = L_mac(L_tmp, tmp, tmp); /* Q1 */
+ }
+ }
+
+ e = norm_l(L_tmp);
+ L_tmp = L_shl(L_tmp, e); /*Q(1+e)*/
+
+ IF( L_frame == L_FRAME16k)
+ {
+ /*stab_fac = (float)(1.25f - (tmp/625000.0f));*/
+ L_tmp = Mpy_32_16_1(L_tmp, 16777); /* 30-eQ(1+e)*-21Q36 = 30-21-eQ31-9+e */
+ }
+ ELSE
+ {
+ /* stab_fac = (float)(1.25f - (tmp1/400000.0f*2.56=1024000)) */
+ L_tmp = Mpy_32_16_1(L_tmp, 26214); /* 30-eQ(1+e)*-21Q36 = 30-21-eQ31-9+e */
+ }
+
+ e = sub(30-21-1,e);
+ tmp = round_fx(L_shl(L_tmp, e)); /*Q14*/
+
+ tmp = sub(20480, tmp); /* 1.25 - tmp in Q14 */
+ tmp = shl(tmp, 1); /* Q14 -> Q15 with saturation */
+
+ tmp = s_max(tmp, 0);
+
+ return tmp;
+}
+/*-------------------------------------------------------------------*
+ * lsp2isp()
+ *
+ * Convert LSPs to ISPs via predictor coefficients A[]
+ *-------------------------------------------------------------------*/
+
+void lsp2isp_fx(
+ const Word16 *lsp, /* i : LSP vector */
+ Word16 *isp, /* o : ISP filter coefficients */
+ Word16 *stable_isp, /* i/o: ISP filter coefficients */
+ const Word16 m /* i : order of LP analysis */
+)
+{
+ Word16 a[M+1];
+
+ /* LSP --> A */
+ /*lsp2a_stab( lsp, a, m );*/
+ E_LPC_f_lsp_a_conversion(lsp, a, m );
+
+ /* A --> ISP */
+ /*a2isp( a, isp, stable_isp, grid );*/
+ E_LPC_a_isp_conversion( a, isp, stable_isp, m);
+
+ /* Update to latest stable ISP */
+ Copy( isp, stable_isp, M );
+}
+/*-------------------------------------------------------------------*
+ * isp2lsp()
+ *
+ * Convert ISPs to LSPs via predictor coefficients A[]
+ *-------------------------------------------------------------------*/
+
+void isp2lsp_fx(
+ const Word16 *isp, /* i : LSP vector */
+ Word16 *lsp, /* o : ISP filter coefficients */
+ Word16 *stable_lsp, /* i/o: stable LSP filter coefficients */
+ const Word16 m /* i : order of LP analysis */
+)
+{
+ Word16 a[M+1];
+
+ /* ISP --> A */
+ /*isp2a( isp, a, m );*/
+ E_LPC_f_isp_a_conversion(isp, a, m );
+ /* A --> LSP */
+ /*a2lsp_stab( a, lsp, stable_lsp, grid );*/
+ E_LPC_a_lsp_conversion(a, lsp, stable_lsp, m );
+ /* Update to latest stable LSP */
+ Copy( lsp, stable_lsp, M );
+}
+
+/*-------------------------------------------------------------------*
+ * lsf2isf()
+ *
+ * Convert LSPs to ISPs
+ *-------------------------------------------------------------------*/
+
+void lsf2isf_fx(
+ const Word16 *lsf, /* i : LSF vector */
+ Word16 *isf, /* o : ISF vector */
+ Word16 *stable_isp, /* i/o: stable ISP filter coefficients */
+ const Word16 m /* i : order of LP analysis */
+)
+{
+ Word16 tmp_lsp[M];
+ Word16 tmp_isp[M];
+
+ /* LSF --> LSP */
+ /*lsf2lsp( lsf, tmp_lsp, m, int_fs );*/
+ E_LPC_lsf_lsp_conversion(lsf, tmp_lsp, m);
+
+ /* LSP --> ISP */
+ lsp2isp_fx( tmp_lsp, tmp_isp, stable_isp, m );
+
+ /* ISP --> ISF */
+ /*isp2isf( tmp_isp, isf, m, int_fs );*/
+ E_LPC_isp_isf_conversion(tmp_isp, isf, m);
+
+ return;
+}
+/*-------------------------------------------------------------------*
+ * isf2lsf()
+ *
+ * Convert ISFs to LSFs
+ *-------------------------------------------------------------------*/
+
+void isf2lsf_fx(
+ const Word16 *isf, /* i : ISF vector */
+ Word16 *lsf, /* o : LSF vector */
+ Word16 *stable_lsp /* i/o: stable LSP filter coefficients */
+)
+{
+ Word16 tmp_isp[M];
+ Word16 tmp_lsp[M];
+
+ /* ISF --> ISP */
+ /*isf2isp( isf, tmp_isp, m, int_fs );*/
+ E_LPC_isf_isp_conversion(isf, tmp_isp, M);
+ /* ISP --> LSP */
+ isp2lsp_fx( tmp_isp, tmp_lsp, stable_lsp, M);
+
+ /* LSP --> LSF */
+ /*lsp2lsf( tmp_lsp, lsf, m, int_fs );*/
+ E_LPC_lsp_lsf_conversion(tmp_lsp, lsf, M);
+ return;
+}
+/*==========================================================================*/
+/* FUNCTION : void lsp2lsf_fx () */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : */
+/* * Transformation of LSPs to LSFs */
+/* * LSP are line spectral pair in cosine domain (-1 to 1). */
+/* * LSF are line spectral frequencies (0 to fs/2). */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* Word16 lsp[] i : lsp[m] (range: -1<=val<1) Q15 */
+/* Word16 m i : LPC order Q0 */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* Word16 lsf[] o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)*/
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*--------------------------------------------------------------------------*/
+/* CALLED FROM : */
+/*==========================================================================*/
+void lsp2lsf_fx(
+ const Word16 lsp[], /* i : lsp[m] (range: -1<=val<1) Q15*/
+ Word16 lsf[], /* o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)*/
+ const Word16 m /* i : LPC order Q0*/
+ ,Word32 int_fs
+)
+{
+ Word16 i;
+ Word32 L_tmp;
+
+ FOR (i = 0; i < m; i++)
+ {
+ /*------------------------------------------------------*
+ * find value in table that is just greater than lsp[i]
+ *------------------------------------------------------*/
+
+ /* Retrieve Index Guess */
+ /* Based on lsp[i] */
+ L_tmp = sub_lsp2lsf_fx(lsp[i]);
+ IF(EQ_32(int_fs, INT_FS_16k_FX))
+ {
+ L_tmp = L_shr(L_mult0(extract_l(L_tmp),5),2);
+ }
+ lsf[i] = extract_l(L_tmp);
+ }
+}
+/*===========================================================================*/
+/* FUNCTION : lsf2lsp_fx() */
+/*---------------------------------------------------------------------------*/
+/* PURPOSE : Transformation of LSFs to LSPs */
+/* LSP are line spectral pairs in cosine domain (-1 to 1). */
+/* LSF are line spectral frequencies (0 to fs/2). */
+/*---------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16[]) lsf : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56) */
+/* _ (Word16) m : LPC order */
+/*---------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) lsp : lsp[m] (range: -1<=val<1) Q15 */
+/*---------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*===========================================================================*/
+void lsf2lsp_fx(
+ const Word16 lsf[], /* i : lsf[m] normalized (range: 0.0<=val<=0.5) x2.56 */
+ Word16 lsp[], /* o : lsp[m] (range: -1<=val<1) Q15 */
+ const Word16 m /* i : LPC order Q0 */
+ , Word32 int_fs
+)
+{
+ Word16 i, ind, offset;
+ Word32 L_tmp;
+ Word16 c, ind2;
+ Word16 const add_prec = 4;
+ Word16 lsf_tmp;
+
+
+ /* 0.75 = (1<clip_var_fx[0];
+ move16();
+
+ FOR(i=0; imem_AR_fx[i];
+ move16();
+ mem_MA[i] = st_fx->mem_MA_fx[i];
+ move16();
+ lsp_new_bck[i] = lsp_new[i];
+ move16();
+ lsf_new_bck[i] = lsf_new[i];
+ move16();
+ lsp_mid_bck[i] = lsp_mid[i];
+ move16();
+ }
+
+ *mCb1 = st_fx->mCb1_fx;
+ move16();
+ *streaklimit = st_fx->streaklimit_fx;
+ move16();
+ *pstreaklen = st_fx->pstreaklen_fx;
+ move16();
+
+ FOR(i=0; iBin_E_fx[i];
+ move32();
+ }
+
+ FOR(i=0; i<(L_FFT/2); i++)
+ {
+ Bin_E_old[i]=st_fx->Bin_E_old_fx[i];
+ move32();
+ }
+
+ /* back-up memories */
+ FOR(i=0; iLPDmem.mem_syn[i];
+ move16();
+ }
+
+ *mem_w0_bck = st_fx->LPDmem.mem_w0;
+ move16();
+
+
+ *btilt_code_fx = LPDmem->tilt_code;
+ *gc_threshold_fx = LPDmem->gc_threshold;
+ Copy( st_fx->clip_var_fx, clip_var_bck_fx, 6 );
+ *next_force_sf_bck_fx = st_fx->next_force_safety_net_fx;
+
+
+ return;
+}
+
+void lsf_update_memory(
+ Word16 narrowband, /* i : narrowband flag */
+ const Word16 qlsf[], /* i : quantized lsf coefficients */
+ Word16 old_mem_MA[], /* i : MA memory */
+ Word16 mem_MA[], /* o : updated MA memory */
+ Word16 lpcorder /* i : LPC order */
+)
+{
+ Word16 i;
+
+ FOR (i=0; iclip_var_fx[0] = clip_var;
+ move16();
+
+ FOR(i=0; imem_AR_fx[i] = mem_AR[i];
+ move16();
+ st_fx->mem_MA_fx[i] = mem_MA[i];
+ move16();
+ lsp_new[i] = lsp_new_bck[i];
+ move16();
+ lsf_new[i] = lsf_new_bck[i];
+ move16();
+ lsp_mid[i] = lsp_mid_bck[i];
+ move16();
+ }
+
+ st_fx->mCb1_fx = mCb1;
+ move16();
+ st_fx->streaklimit_fx = streaklimit;
+ move16();
+ st_fx->pstreaklen_fx = pstreaklen;
+ move16();
+
+ FOR(i=0; iBin_E_fx[i] = Bin_E[i];
+ move16();
+ }
+
+ FOR(i=0; i<(L_FFT/2); i++)
+ {
+ st_fx->Bin_E_old_fx[i]=Bin_E_old[i];
+ move32();
+ }
+
+ /* restoring memories */
+ st_fx->LPDmem.mem_w0 = mem_w0_bck;
+ move16();
+
+ FOR(i=0; iLPDmem.mem_syn[i] = mem_syn_bck[i];
+ move16();
+ }
+
+ move16();
+ move32();
+ move16();
+ LPDmem->tilt_code = btilt_code_fx;
+ LPDmem->gc_threshold = gc_threshold_fx;
+ Copy( clip_var_bck_fx, st_fx->clip_var_fx, 6 );
+ st_fx->next_force_safety_net_fx = next_force_sf_bck_fx;
+
+ return;
+}
+
+/* Returns: codebook index */
+Word16 tcxlpc_get_cdk(
+ Word16 acelp_ext_mode /* (I) GC/VC indicator */
+)
+{
+ Word16 cdk;
+
+ move16();
+ cdk = 0;
+ if ( EQ_16(acelp_ext_mode, VOICED))
+ {
+ cdk = 1;
+ move16();
+ }
+
+ return cdk;
+}
+
+void msvq_dec
+(
+ const Word16 *const*cb, /* i : Codebook (indexed cb[*stages][levels][p]) (14Q1*1.28)*/
+ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
+ const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
+ const Word16 stages,/* i : Number of stages */
+ const Word16 N, /* i : Vector dimension */
+ const Word16 maxN, /* i : Codebook dimension */
+ const Word16 Idx[], /* i : Indices */
+ Word16 *uq /* o : quantized vector (14Q1*1.28)*/
+)
+{
+ Word16 i,j,offset;
+ Word16 N34;
+ Word16 n, maxn, start;
+
+
+
+ set16_fx(uq, 0, N);
+
+ FOR ( i=0; i lsp[i] */
+ tmp = sub(lsp_i, cos_table_129[ind]);
+ /*
+ 69%: (Final Index - Index Guess) is <= 1
+ 28%: (Final Index - Index Guess) is 2
+ 2%: (Final Index - Index Guess) is >= 3
+ <1%: ...
+ */
+ IF (tmp > 0) /* possible range 0 to -5 (-1-2-2) */
+ {
+ ind = sub(ind, 1);
+ tmp = sub(lsp_i, cos_table_129[ind]);
+ IF (tmp > 0)
+ {
+ ind = sub(ind, 2);
+ tmp = sub(lsp_i, cos_table_129[ind]);
+ if (tmp > 0)
+ {
+ ind = sub(ind, 2);
+ }
+ tmp = sub(lsp_i, cos_table_129[ind+1]);
+ if (tmp <= 0)
+ {
+ ind = add(ind, 1);
+ }
+ tmp = sub(lsp_i, cos_table_129[ind]);
+ }
+ }
+
+ /* acos(lsp[i])= ind*128 + (lsp[i]-table[ind]) * acos_slope[ind] / 2048 */
+ L_tmp = L_mac(1L<<11, tmp, acos_slope[ind]);
+ L_tmp = L_shr(L_tmp, 12); /* (lsp[i]-table[ind]) * acos_slope[ind]) >> 11 */
+ L_tmp = L_mac0(L_tmp, ind, 128);
+
+ return L_tmp;
+}
+
+/*===================================================================*/
+/* FUNCTION : compute_poly_product_fx () */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Compute polynomial product for P(z) for LSP */
+/* to LPC conversion */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16[]) coef : LSP coefficients, Q15 */
+/* _ (Word16 []) order: LPC order */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word32[]) p : output sequence, Q24 */
+/* 1st entry is always 1.0, Q24 */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*===================================================================*/
+/* NOTE: */
+/* P(z)=(1+z^-1)*PI(j=1to(order/2)) (1 - 2*z^-1*cos(2*pi*w(2j-1)) + z^-2) */
+/* Q(z)=(1-z^-1)*PI(j=1to(order/2)) (1 - 2*z^-1*cos(2*pi*w(2j)) + z^-2) */
+/*===================================================================*/
+void compute_poly_product_fx(
+ Word16* coef, /* i : LSP coefficients, Q15 */
+ Word32* p, /* o : output sequence, Q24 */
+ Word16 order /* i : order */
+)
+{
+ Word16 i, len;
+ Word32 lspcos[LPC_SHB_ORDER];
+ Word32 p2[LPC_SHB_ORDER]; /* intermediate product, Q24*/
+ Word32* p_in, *p_out, *p_temp;
+
+ FOR ( i = 0; i < order / 2; i++ )
+ {
+ lspcos[i] = poscos_fx( coef[i * 2] );
+ move32(); /* lspcos =-cos(lsp) in Q30*/
+ }
+
+ /* Set up first polynomial for convolution (1 -2cos(w5) 1) */
+ /* First element of output is 1, all in Q24 */
+ p[0] = L_deposit_h( 0x100 ); /* 1.0 in Q24 */
+ p[2] = L_deposit_h( 0x100 ); /* 1.0 in Q24 */
+ p[1] = L_shr( lspcos[order / 2 - 1], 5 ); /* p2[1]=-2cos(w5), Q24 */
+ p2[0] = L_deposit_h( 0x100 ); /* 1.0 in Q24 */
+
+ len = 1;
+ move16();
+
+ len = 1;
+ p_in = p + 1; /* 2nd entry of input sequence */
+ p_out = p2 + 1; /* 2nd entry of output sequence */
+ FOR ( i = 0; i < ( order / 2 - 1 ); i++ )
+ {
+ lsp_convolve_fx( L_shr( lspcos[i], 5 ), p_in, p_out, len );
+
+ p_temp = p_in;
+ p_in = p_out;
+ p_out = p_temp; /* swap input/output buffer */
+ len = add( len, 1 );
+ }
+
+ /* if((order/2 - 1)%2 != 0) */
+ IF ( s_and( ( order / 2 - 1 ), 1 ) != 0 )
+ {
+ FOR ( i = 1; i <= order / 2; i++ )
+ {
+ p[i] = p_in[i - 1];
+ move32();
+ }
+ }
+
+}
+
+/*===================================================================*/
+/* FUNCTION : lsp_convolve_fx ( ) */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Convolution of LSP polynomial for LSP to LPC */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ ( Word32[]) p1 : 2nd entry of input sequence, Q24 */
+/* 1st entry is 1.0, Q24 */
+/* _ ( Word32) x : -2cos( w) in Q24 */
+/* _ ( Word16) len: length of output-2 */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ ( Word32[]) p2 : 2nd entry of output sequence, Q24 */
+/* 1st entry is 1.0, Q24 */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*===================================================================*/
+/* NOTE: Convolves ( 1 S 1) where S is the -2cos( w) value) with the */
+/* long sequence where the input long sequence on consecutive calls */
+/* is ( 1 X1 1), ( 1 X1 X2 X1), ( 1 X1 X2 X3 X2), ( 1 X1 X2 X3 X4 X3). */
+/* ( Since the sequence is symmetric, we only need to output one */
+/* entry beyond the center point for the next iteration). */
+/* The 1st entry of the convolution is 1, the 2nd is X1+S1, and */
+/* the rest have the form X( i-1) + X( i)*S + X( i+1). */
+/* Final output sequence is ( 1 X1 X2 X3 X4 X5 X4) */
+/*===================================================================*/
+void lsp_convolve_fx(
+ Word32 x,
+ Word32* p1,
+ Word32* p2,
+ Word16 len
+)
+{
+ Word16 i, d1h, d1l, d2h, d2l;
+ Word32 Ltemp;
+ Word32 Lacc;
+
+ d1h = extract_h( x ); /* d1h in Q8 */
+ d1l = extract_l( x ); /* d1l in Q24 */
+
+ Ltemp = L_add( x, p1[0] ); /* first output is p1[0]+x, Q24 */
+
+ p2[0] = Ltemp;
+ move32();
+ Ltemp = L_deposit_h( 0x100 ); /* Ltemp=1.0, Q24 */
+ FOR ( i = 0; i < len; i++ )
+ {
+ Ltemp = L_add( Ltemp, p1[i + 1] ); /* Ltemp2=p1[i-1]+p1[i+1], Q24 */
+ d2h = extract_h( p1[i] );
+ d2l = extract_l( p1[i] );
+
+ /* Lacc=L_mult_su( d1h,d2l); */
+ Lacc = L_mult0( d1h, ( UWord16 )d2l );
+ Lacc = L_mac0( Lacc, d2h, d1l );
+ Lacc = L_add( L_shr( Lacc, 16 ), L_shr( L_mult( d1h, d2h ), 1 ) );
+ /* Lacc=p1[i]* x, Q16 */
+ Lacc = L_add( L_shl( Lacc, 8 ), Ltemp ); /* Lacc=p1[i-1]+p1[i+1]+p1[i]*x, Q24 */
+
+ p2[i + 1] = Lacc;
+ move32();
+
+ Ltemp = p1[i];
+ move32();
+ } /* end for */
+
+ p2[i + 1] = p2[i - 1];
+ move32();
+}
+
+
+
+/*===================================================================*/
+/* FUNCTION : poscos_fx ( ) */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Compute cosine by approximation */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* */
+/* _ ( Word16) w: angle in radians/pi, Q14 ( 0<=w<=16384) */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ ( Word32) : -cos( w) in Q30 */
+/*===================================================================*/
+/* NOTE: This function uses 4 coefficients in the approx formula */
+/* Approx Formula: cos( w) = z + c1*z^3 + c2*z^5 + c3*z^7 + c4*z^9 */
+/* where z = pi/2 - w, c1=-.1666665668, c2=.8333025139E-2, */
+/* c3=-.198074182E-3, and c4=.2601903036E-5 */
+/*===================================================================*/
+
+
+Word32 poscos_fx( Word16 w )
+{
+ Word16 a, z, z2, z3, z5, z7, z9;
+ Word32 Ltemp;
+ Word32 Lacc;
+
+ IF ( w == 0 )
+ {
+ return ( 0xc0000004 ); /* -1.0 in Q30 */
+ }
+ ELSE
+ {
+ z = 0x2000;
+ move16(); /* z=0.5 in Q14 */
+ z = shl( sub( z, w ), 2 ); /* z = 0.5-w in Q16 */
+
+ a = 0x6488;
+ move16(); /* a=pi in Q13 */
+ z = mult_r( z, a ); /* z=pi*( 0.5-w), Q14 */
+ z2 = mult_r( z, z ); /* z2=z^2, Q13 */
+ z3 = round_fx( L_shl( L_mult0( z, z2 ), 0 ) ); /* z3=z^3, Q11 */
+ z5 = mult_r( z2, z3 ); /* z5=z^5, Q9 */
+ z7 = round_fx( L_shl( L_mult0( z2, z5 ), 0 ) ); /* z7=z^7, Q6 */
+ z9 = round_fx( L_shl( L_mult0( z2, z7 ), 0 ) ); /* z9=z^9, Q3 */
+
+ Lacc = L_mult( z9, cos_coef_new[0] ); /* Lacc=c4*z^9, Q31, c4 in Q28 */
+ Lacc = L_mac0( Lacc, z7, cos_coef_new[1] ); /* c3 in Q25 */
+ Ltemp = L_shl( L_mult( z3, cos_coef_new[3] ), 1 ); /* Ltemp=c1*z^3, Q31, c1 in Q17 */
+ Lacc = L_add( L_shr( Lacc, 1 ), Ltemp ); /* Lacc=c1*z^3+c3*z^7+c4*^z9, Q30 */
+ Lacc = L_add( Lacc, L_deposit_h( z ) );
+ Ltemp = L_mult( z5, cos_coef_new[2] ); /* Ltemp=-c2*z^5, Q29, cos_coef[2]=-c2 in Q19 */
+ Lacc = L_sub( Lacc, L_shl( Ltemp, 1 ) ); /* Lacc=cos( w) in Q30 */
+
+ return L_negate( Lacc ); /* return -cos( w), Q30 */
+ } /* end else */
+}
+/*===================================================================*/
+/* FUNCTION : root_search_fx ( ) */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Search root of the P or Q polynomial in a given */
+/* interval using binary search */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ ( Word16) low : Low index of the interval, Q9 ( 0-511) */
+/* _ ( Word16) high : High index of the interval, Q9 ( 0-511) */
+/* _ ( Word32 []) coef: polynomial coefficients, Q26 */
+/* _ ( Word16) order : LPC order */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ ( Word32) v_low: Polynomial value at low index, Q25 */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ ( Word16) root in Q15, or 0xffff if no root is found */
+/*===================================================================*/
+
+Word16 root_search_fx( Word16 low,
+ Word16 high,
+ Word32* v_low,
+ Word32* coef,
+ Word16 order
+ )
+{
+ Word16 f;
+ Word32 v_high, vh;
+ Word32 Ltemp, L_tmp1, L_tmp, Ltmp;
+ Word16 exp1, tmp;
+
+ v_high = polynomial_eval_fx( high, coef, order ); /* v_high has the value at high index */
+
+ IF ( v_high != 0 )
+ {
+ /* No exact root found */
+ test();
+ IF ( ( v_high ^ ( *v_low ) ) >= 0 )
+ {
+ /* No root in this interval ( low high] */
+ *v_low = v_high;
+ move32();
+ return ( -1 );
+ }
+ ELSE
+ {
+ /* there is a root in this interval */
+ /* Do binary search for root */
+ vh = v_high;
+ move16();
+
+ WHILE ( GE_16( sub( high, low ), 2 ))
+ {
+ /* high-low>=2 */
+ f = shr( add( high, low ), 1 ); /* f=( high+low)/2 */
+ Ltemp = polynomial_eval_fx( f, coef, order );
+ IF ( Ltemp == 0 )
+ {
+ *v_low = v_high;
+ move32();/* Set low value for next root search call */
+ return ( shl( f, 6 ) );
+ }
+ ELSE
+ {
+ test();
+ IF ( ( Ltemp ^ ( *v_low ) ) < 0 )
+ {
+ /* root between f & low */
+ high = f;
+ move16();
+ vh = Ltemp;
+ move32();
+ }
+ ELSE
+ {
+ *v_low = Ltemp;
+ move32();
+ low = f;
+ move16();
+ }
+ }
+ } /* end while */
+
+ /* do interpolation for root in between high and low */
+ /* Lacc=divide_dp( *v_low, L_sub( *v_low,vh),2,1); // Lacc in Q31 */
+ L_tmp = L_sub( *v_low, vh );
+
+ if ( LT_32( *v_low, vh ))
+ {
+ L_tmp = L_negate( L_tmp );
+ }
+
+ exp1 = norm_l( L_tmp );
+ L_tmp1 = L_shl( L_tmp, exp1 );
+ tmp = extract_h( L_tmp1 );
+ exp1 = sub(30 - 25, exp1);
+ tmp = div_s( 16384, tmp ); /* 15+exp1 */
+ Ltmp = Mult_32_16( *v_low, tmp ); /* 15+exp1+25-15 */
+ Ltemp = L_shl( Ltmp, ( 6 - exp1 ) ); /* Q31 */
+ if ( LT_32( *v_low, vh ))
+ {
+ Ltemp = L_negate( Ltemp );
+ }
+ Ltemp = L_shr( Ltemp, 9 ); /* Ltemp =quotient*1.0 in Q31 */
+
+ *v_low = v_high;
+ move16();
+ return ( add( round_fx( Ltemp ), shl( low, 6 ) ) );
+ } /* end else ( root in interval) */
+ } /* end else ( exact root at high) */
+
+ /* find the exact root */
+ *v_low = v_high;
+ move32(); /* Set low value for next root search call */
+ return ( shl( high, 6 ) ); /* return exact root at high in Q15 */
+}
+
+/*===================================================================*/
+/* FUNCTION : calc_weight( ) */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : This function computes the weight given delta1
+and delta2 */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) delta1: (Q15) */
+/* _ (Word16) delta2: (Q15) */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 *) n1: o/p weight is Q(31-n1) */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None. */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word32) Lsum1: computed weight Q(31-n1) */
+/* (alpha/(sqrt(delta1*delta2)) */
+/*===================================================================*/
+
+Word32 calc_weight(
+ Word16 delta1,
+ Word16 delta2,
+ Word16* n1
+)
+{
+ Word16 n;
+ Word32 L_tmp;
+ Word16 alpha=0x4F94;
+ move16(); /* ( 0.5*250/( 2*pi)) in Q10*/
+
+ L_tmp = L_mult0( delta1, delta2 ); /* Q30 */
+ n = norm_l( L_tmp );
+ L_tmp = L_shl( L_tmp, n );
+ n = sub(1, n);
+ L_tmp = Isqrt_lc( L_tmp, &n ); /* Q( 31-n)*/
+
+ L_tmp = Mult_32_16( L_tmp, alpha ); /* Q( 26-n) */
+
+ *n1 = n;
+ move16();
+
+ return L_tmp;
+}
+
+/*===================================================================*/
+/* FUNCTION : polynomial_eval_fx ( ) */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : Evaluate P or Q polynomial at given frequency */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (Word16) f : frequency used as index for cosine table lookup */
+/* Q9 */
+/* _ (Word32 []) coef: polynomial coefficients, Q26 */
+/* _ (Word16 []) order: LPC order */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ (Word32) polynomial value at given frequency f, Q25 */
+/*===================================================================*/
+/* Note: This function uses 512 entry cosine table cos_table[], Q15 */
+/*===================================================================*/
+/* if (K = order/2) */
+/* P(w)=cos(Kw)+p[1]*cos((K-1)w)+p[2]*cos((K-2)w)+...+p[(K-1)]*cos(w)+p[K]/2 */
+/* Q(w)=cos(Kw)+q[1]*cos((K-1)w)+q[2]*cos((K-2)w)+...+q[(K-1)]*cos(w)+q[K]/2 */
+/*===================================================================*/
+
+/* 40-32 bit conversion */
+Word32 polynomial_eval_fx( Word16 f,
+ Word32* coef,
+ Word16 order
+ )
+{
+ Word16 i, idx;
+ Word16 dh, dl, coslut;
+ Word32 Ltemp, L_tmp1, L_tmp;
+ Word32 Lacc;
+ idx = f;
+ move16();
+ dh = extract_h( coef[order / 2] ); /* Q10 */
+ dl = extract_l( coef[order / 2] ); /* Q16 */
+
+ coslut = 0x4000;
+ move16(); /* coslut=0.5 in Q15 */
+ Ltemp = L_mult0( coslut, dh ); /* Ltemp=MSW, coef[5]/2 in Q25 */
+
+ Lacc = L_mult0( coslut, dl ); /* Lacc=LSW, coef[5]/2 in Q41 //Q31 */
+ Lacc = L_shr( Lacc, 1 ); /* Q30 */
+ FOR ( i = ( order / 2 ) - 1; i > 0; i-- )
+ {
+ coslut = cos_table[idx];
+ move16(); /* coslut=cos( ( ( order/2)-i)f), Q15 */
+ dh = extract_h( coef[i] );/* Q10 */
+ dl = extract_l( coef[i] );/* Q16 */
+
+ Ltemp = L_add( Ltemp, L_mult0( dh, coslut ) ); /* Q25 */
+ IF ( dl < 0 )
+ {
+ L_tmp1 = L_shl( L_add( 65536, dl ), 14 );
+ L_tmp = Mult_32_16( L_tmp1, coslut );
+ Lacc = L_add( Lacc, L_tmp );
+ }
+ ELSE
+ {
+ Lacc = L_add( Lacc, L_shr( L_mult0( coslut, dl ), 1 ) );/* Q30 */
+ }
+
+ idx += f;
+ if ( GE_16(idx, 512)) idx=sub(idx, 512); /* modulo of 512 */
+ }
+
+ coslut = cos_table[idx];
+ move16(); /* coslut=cos( 5f), Q15 */
+ Ltemp = L_add( Ltemp, L_mult0( 0x400, coslut ) ); /* coef[0]=1.0, Q25 */
+
+ return ( L_add( Ltemp, L_shr( Lacc, 15 ) ) ); /* Q25 */
+}
+
+/*----------------------------------------------------------------------------------*
+* v_sort:
+*
+* This is very fast with almost ordered vectors. The first 15 ISF values
+* are almost always sorted.
+*----------------------------------------------------------------------------------*/
+void v_sort(
+ Word16 *r, /* i/o: Vector to be sorted in place */
+ const Word16 lo, /* i : Low limit of sorting range */
+ const Word16 up /* I : High limit of sorting range */
+)
+{
+ Word16 i, j;
+ Word16 tempr;
+
+
+ FOR (i=sub(up, 1); i>=lo; i--)
+ {
+ tempr = r[i];
+ move16();
+ FOR (j=i; j cos(pi/2) = 0.
+ *---------------------------------------------------------------------*/
+
+ FOR (i = 1; i <= iuni; i++)
+ {
+ Mpy_32_16_ss(R[0], x[i-1], &mh, &ml);
+ r0 = L_add(R[1], mh);
+
+ Mpy_32_16_ss(S[0], x[i-1], &mh, &ml);
+ s0 = L_add(S[1], mh);
+
+
+ FOR (j = 2; j <= NC; j++)
+ {
+ Mpy_32_16_ss(r0, x[i-1], &mh, &ml);
+ r0 = L_add(R[j], mh);
+
+ Mpy_32_16_ss(s0, x[i-1], &mh, &ml);
+ s0 = L_add(S[j], mh);
+ }
+
+ G[i] = inv_pow(r0, s0, x[i-1]);
+ move32();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Power spectrum at points other than x = -1, 0, and 1 and unique
+ * points is computed using the anti-symmetry of the grid relative
+ * to the midpoint x = 0 in order to reduce looping.
+ *---------------------------------------------------------------------*/
+
+ FOR ( ; i < imid; i++)
+ {
+ x2 = mult_r(x[i-1], x[i-1]);
+
+ Mpy_32_16_ss(R[0], x2, &mh, &ml);
+ re = L_add(R[2], mh);
+ Mpy_32_16_ss(R[1], x2, &mh, &ml);
+ ro = L_add(R[3], mh);
+
+ Mpy_32_16_ss(S[0], x2, &mh, &ml);
+ se = L_add(S[2], mh);
+ Mpy_32_16_ss(S[1], x2, &mh, &ml);
+ so = L_add(S[3], mh);
+
+ FOR (j = 4; j < NC; j+=2)
+ {
+ Mpy_32_16_ss(re, x2, &mh, &ml);
+ re = L_add(R[j], mh);
+ Mpy_32_16_ss(ro, x2, &mh, &ml);
+ ro = L_add(R[j+1], mh);
+ Mpy_32_16_ss(se, x2, &mh, &ml);
+ se = L_add(S[j], mh);
+ Mpy_32_16_ss(so, x2, &mh, &ml);
+ so = L_add(S[j+1], mh);
+ }
+
+ Mpy_32_16_ss(re, x2, &mh, &ml);
+ L_tmp = L_add(R[j], mh);
+ Mpy_32_16_ss(ro, x[i-1], &mh, &ml);
+ re = L_add(L_tmp, mh);
+ ro = L_sub(L_tmp, mh);
+
+ Mpy_32_16_ss(se, x2, &mh, &ml);
+ L_tmp = L_add(S[j], mh);
+ Mpy_32_16_ss(so, x[i-1], &mh, &ml);
+ se = L_add(L_tmp, mh);
+ so = L_sub(L_tmp, mh);
+
+ G[i] = inv_pow(re, se, x[i-1]);
+ move32();
+ G[N-i-1] = inv_pow(so, ro, x[i-1]);
+ move32();
+ }
+
+ return;
+}
+
+static Word32 b_inv_sq(
+ const Word32 in32, /* i : Input not normalized to inverse */
+ const Word16 exp_in /* i : input current exponent */
+)
+{
+ Word16 m_den, exp_den;
+ Word16 div_out;
+ Word32 Ltmp;
+
+ exp_den = norm_l(in32);
+ m_den = extract_h(L_shl(in32, exp_den));
+ exp_den = add(sub(30,exp_den),sub(16,exp_in));
+
+ m_den = mult_r(m_den, m_den);
+ exp_den = shl(exp_den,1);
+
+ div_out = div_s(8192,m_den);
+ Ltmp = L_shl(div_out, add(sub(30-13, exp_den),15)); /*Q15*/
+
+ return Ltmp;
+}
+
+static Word32 inv_pow(
+ const Word32 re,
+ const Word32 se,
+ const Word16 x
+)
+{
+ Word16 exp1, exp2;
+ Word16 tmp;
+ Word32 L_tmp;
+ Word32 mh;
+ UWord16 ml;
+ Word32 r0, s0;
+
+ IF(re==0)
+ {
+ exp1 = 30;
+ move16();
+ r0 = L_deposit_l(0);
+ }
+ ELSE
+ {
+ exp1 = norm_l(re);
+ tmp = extract_h(L_shl(re, exp1));
+ L_tmp = L_shr(L_mult(tmp, tmp), 1);
+ Mpy_32_16_ss(L_tmp, x, &mh, &ml);
+ r0 = L_add(L_tmp, mh);
+ }
+
+ IF(se==0)
+ {
+ exp2 = 30;
+ move16();
+ s0 = L_deposit_l(0);
+ }
+ ELSE
+ {
+ exp2 = norm_l(se);
+ tmp = extract_h(L_shl(se, exp2));
+ L_tmp = L_shr(L_mult(tmp, tmp), 1);
+ Mpy_32_16_ss(L_tmp, x, &mh, &ml);
+ s0 = L_sub(L_tmp, mh);
+ }
+
+ IF(exp1 > exp2)
+ {
+ exp1 = shl(sub(exp1, exp2), 1);
+ r0 = L_shr(r0, exp1);
+
+ exp2 = add(add(exp2, exp2), 8);
+ }
+ ELSE
+ {
+ exp2 = shl(sub(exp2, exp1), 1);
+ s0 = L_shr(s0, exp2);
+
+ exp2 = add(add(exp1, exp1), 8);
+ }
+
+ r0 = L_add(r0, s0);
+ exp1 = norm_l(r0);
+ L_tmp = L_shl(r0, exp1);
+ tmp = extract_h(L_tmp);
+ IF(tmp==0)
+ {
+ return MAX_32;
+ }
+ tmp = div_s((Word16)((1<<14)-1), tmp);
+ exp1 = add(exp1, exp2);
+ L_tmp = L_shr(tmp, sub(31, exp1)); /* result in Q15 */
+
+ return(L_tmp);
+}
+
+
+/*---------------------------------------------------------------------*
+ * spectautocorr()
+ *
+ * Computes the autocorrelation r[j] for j = 0, 1, ..., M from
+ * the power spectrum P(w) by using rectangle rule to approximate
+ * the integral
+ *
+ * 1 pi
+ * r[j] = --- I P(w) cos(j*w) dw.
+ * 2*pi -pi
+ *
+ * It is sufficient to evaluate the integrand only from w = 0 to
+ * w = pi due to the symmetry P(-w) = P(w). We can further
+ * employ the relation
+ *
+ * cos(j*(pi - w)) = (-1)^j cos(j*w)
+ *
+ * to use symmetries relative to w = pi/2.
+ *
+ * When applying the rectangle rule, it is useful to separate w = 0,
+ * w = pi/2, and w = pi. By using a frequency grid of N points, we
+ * can express the rectangle rule as
+ *
+ * r[j] = G[0] + 2*a*G[(N-1)/2] + b*G[N-1]
+ *
+ * M
+ * + 2 sum (G[i] - G[N-i-1]) cos(j*x[i])
+ * i=1
+ *
+ * where G[i] is the power spectrum at the grid point cos(i*pi/N)
+ * and M = (N-1)/2 - 1 is the number of the grid points in the
+ * interval(0, pi/2).
+ *
+ * The coefficients
+ *
+ * b = (-1)^j
+ * a = (1 + (-1)^(j+1))(-1)^floor(j/2)
+ *
+ * follow from the properties of cosine. The computation further
+ * uses the recursion
+ *
+ * cos(j*w) = 2*cos(w)*cos((j-1)*w) - cos((j-2)*w)
+ *
+ * Note that the autocorrelation can be scaled for convenience,
+ * because this scaling has no impact on the LP coefficients to be
+ * calculated from the autocorrelation. The expression of r[j] thus
+ * omits the division by N.
+ *
+ * See the powerspect function on the definition of the grid.
+ *
+ * References
+ * J. Makhoul, "Spectral linear prediction: properties and
+ * applications," IEEE Trans. on Acoustics, Speech and Signal
+ * Processing, Vol. 23, No. 3, pp.283-296, June 1975
+ *---------------------------------------------------------------------*/
+
+static void spectautocorr_fx(
+ const Word16 x[], /* i: Grid points x[0:m-1] */
+ const Word16 N, /* i: Number of grid points */
+ const Word32 G[], /* i: Power spectrum G[0:N-1] */
+ Word16 rh[], /* o: Autocorrelation r[0:M] */
+ Word16 rl[] /* o: Autocorrelation r[0:M] */
+)
+{
+ Word16 c[M+1]; /* c[j] = cos(j*w) */
+ Word32 gp, gn;
+ Word16 i, j;
+ Word16 imid;
+ Word32 mh;
+ UWord16 ml;
+ Word32 r[M+1];
+ Word16 exp0;
+
+ /*---------------------------------------------------------------------*
+ * The mid point of the cosine table x of m entries assuming an odd m.
+ * Only the entries x[0] = cos(pi/m), x[1] = cos(2*pi/m), ...,
+ * x[imid-1] = cos((imid-1)*pi/m) need to be stored due to trivial
+ * cos(0), cos(pi/2), cos(pi), and symmetry relative to pi/2.
+ * Here m = 51.
+ *---------------------------------------------------------------------*/
+
+ imid = (N - 1)/2;
+ move16();
+
+ /*---------------------------------------------------------------------*
+ * Autocorrelation r[j] at zero lag j = 0 for the upper half of the
+ * unit circle, but excluding the points x = cos(0) and x = cos(pi).
+ *---------------------------------------------------------------------*/
+
+ r[0] = G[1];
+ move32();
+ FOR (i = 2; i < N-1; i++)
+ {
+ r[0] = L_add(r[0], G[i]);
+ move32();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Initialize the autocorrelation r[j] at lags greater than zero
+ * by adding the midpoint x = cos(pi/2) = 0.
+ *---------------------------------------------------------------------*/
+
+ r[1] = L_deposit_l(0);
+ r[2] = -G[imid];
+ move32();
+
+ FOR (i = 3; i < M; i+=2)
+ {
+ r[i] = L_deposit_l(0);
+ r[i+1] = -r[i-1];
+ move32();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Autocorrelation r[j] at lags j = 1, 2, ..., M. The computation
+ * employes the relation cos(j*(pi - w)) = (-1)^j cos(j*w) and
+ * cos(j*w) = 2*cos(w)*cos((j-1)*w) - cos((j-2)*w) for obtaining
+ * the cosine c[j] = cos(j*w).
+ *---------------------------------------------------------------------*/
+
+ c[0] = (Word16)32767;
+ move16(); /* 1.0 in Q15 */
+ FOR (i = 1; i < imid; i++)
+ {
+ gp = L_add(G[i], G[N-i-1]);
+ gn = L_sub(G[i], G[N-i-1]);
+
+ /*r[1] = L_mac(r[1], x[i-1], gn);*/
+ Mpy_32_16_ss(gn, x[i-1], &mh, &ml);
+ r[1] = L_add(r[1], mh);
+ move32();
+ c[1] = x[i-1];
+ move16();
+
+ FOR (j = 2; j < M; j+=2)
+ {
+ c[j] = mult_r(c[j-1], x[i-1]);
+ move16();
+ c[j] = add(c[j], sub(c[j], c[j-2]));
+ move16();
+
+ /*r[j] = L_mac(r[j], c[j], gp);*/
+ Mpy_32_16_ss(gp, c[j], &mh, &ml);
+ r[j] = L_add(r[j], mh);
+ move32();
+
+ c[j+1] = mult_r(c[j], x[i-1]);
+ move16();
+ c[j+1] = add(c[j+1], sub(c[j+1], c[j-1]));
+ move16();
+
+ /*r[j+1] = L_mac(r[j+1], c[j+1], gn);*/
+ Mpy_32_16_ss(gn, c[j+1], &mh, &ml);
+ r[j+1] = L_add(r[j+1], mh);
+ move32();
+ }
+ c[j] = mult_r(c[j-1], x[i-1]);
+ move16();
+ c[j] = add(c[j], sub(c[j], c[j-2]));
+ move16();
+
+ Mpy_32_16_ss(gp, c[j], &mh, &ml);
+ r[j] = L_add(r[j], mh);
+ move32();
+ }
+
+ /*---------------------------------------------------------------------*
+ * Add the endpoints x = cos(0) = 1 and x = cos(pi) = -1 as
+ * well as the lower half of the unit circle.
+ *---------------------------------------------------------------------*/
+ gp = L_shr(L_add(G[0], G[N-1]), 1);
+ gn = L_shr(L_sub(G[0], G[N-1]), 1);
+
+ r[0]= L_add(r[0], gp);
+ move32();
+ exp0 = norm_l(r[0]);
+ L_Extract(L_shl(r[0], exp0), &rh[0], &rl[0]);
+
+ FOR (j = 1; j < M; j+=2)
+ {
+ L_Extract(L_shl(L_add(r[j], gn), exp0), &rh[j], &rl[j]);
+ L_Extract(L_shl(L_add(r[j+1], gp), exp0), &rh[j+1], &rl[j+1]);
+ }
+
+ return;
+}
+
+/*---------------------------------------------------------------------*
+ * zeros2poly()
+ *
+ * Computes the coefficients of the polynomials
+ *
+ * R(x) = prod (x - x[i]),
+ * i = 0,2,4,...
+ *
+ * S(x) = prod (x - x[i]),
+ * i = 1,3,5,...
+ *
+ * when their zeros x[i] are given for i = 0, 1, ..., n-1. The
+ * routine assumes n = 1 or even n greater than or equal to 4.
+ *
+ * The polynomial coefficients are returned in R[0:n/2-1] and
+ * S[0:n/2-1]. The leading coefficients are in R[0] and S[0].
+ *---------------------------------------------------------------------*/
+static void zeros2poly_fx(
+ Word16 x[], /* i: Q15 Zeros of R(x) and S(x) */
+ Word32 R[], /* o: Q22 Coefficients of R(x) */
+ Word32 S[] /* o: Q22 Coefficients of S(x) */
+)
+{
+ Word16 xr, xs;
+ Word16 i, j;
+ Word32 mh;
+ UWord16 ml;
+
+ R[0] = (1<<27)-1;
+ move32();
+ S[0] = (1<<27)-1;
+ move32();
+ R[1] = L_msu(0, x[0], 1<<11);
+ move32();
+ S[1] = L_msu(0, x[1], 1<<11);
+ move32();
+
+ FOR (i = 2; i <= NC; i++)
+ {
+ xr = negate(x[2*i-2]);
+ xs = negate(x[2*i-1]);
+
+ Mpy_32_16_ss(R[i-1], xr, &R[i], &ml);
+ Mpy_32_16_ss(S[i-1], xs, &S[i], &ml);
+
+ FOR (j = i-1; j > 0; j--)
+ {
+ Mpy_32_16_ss(R[j-1], xr, &mh, &ml);
+ R[j] = L_add(R[j], mh);
+ Mpy_32_16_ss(S[j-1], xs, &mh, &ml);
+ S[j] = L_add(S[j], mh);
+ }
+ }
+
+ return;
+}
+
+/*---------------------------------------------------------------------*
+ * polydecomp()
+ *
+ * Computes the coefficients of the symmetric and antisymmetric
+ * polynomials P(z) and Q(z) that define the line spectrum pair
+ * decomposition of a given polynomial A(z) of order n. For even n,
+ *
+ * P(z) = [A(z) + z^(n+1) A(1/z)]/(1/z + 1),
+ * Q(z) = [A(z) - z^(n+1) A(1/z)]/(1/z - 1),
+ *
+ * These polynomials are then expressed in their direct form,
+ * respectively, R(x) and S(x), on the real axis x = cos w using
+ * explicit Chebyshev polynomials of the first kind.
+ *
+ * The coefficients of the polynomials R(x) and S(x) are returned
+ * in R[0:n/2] and S[0:n/2] for the given linear prediction
+ * coefficients A[0:n/2]. Note that R(x) and S(x) are formed in
+ * place such that P(z) is stored in the same array than R(x),
+ * and Q(z) is stored in the same array than S(x).
+ *
+ * The routines assumes n = 16.
+ *---------------------------------------------------------------------*/
+
+static void polydecomp_fx(
+ Word16 A[], /* i: Q12 linear prediction coefficients */
+ Word32 R[], /* o: Q20 coefficients of R(x) */
+ Word32 S[] /* o: Q20 coefficients of S(x) */
+)
+{
+ Word16 scale;
+ Word16 i;
+ Word32 Ltmp1, Ltmp2;
+
+ scale = shl((1<<5), norm_s(A[0]));
+
+ R[0] = (1<<20)-1;
+ move32(); /* Q20 */
+ S[0] = (1<<20)-1;
+ move32();
+
+ FOR(i=0; i AMRWB_1825 */
+ 0x06, /* AMRWB_2305 -> AMRWB_1825 */
+ 0x04, /* AMRWB_2385 */
+ 0x07, /* invalid request -> none */
+ 0x07, /* invalid request -> none */
+ 0x07, /* invalid request -> none */
+ 0x07, /* invalid request -> none */
+ 0x07, /* invalid request -> none */
+ 0x07, /* invalid request -> none */
+ 0x07 /* invalid request -> none */
+};
+
+/* 3 bit to 4 bit AMR-WB CMR remapping table */
+static const Word16 amrwb_4bit_cmr[8] =
+{
+ 0x00, /* AMRWB_660 */
+ 0x01, /* AMRWB_885 */
+ 0x02, /* AMRWB_1265 */
+ 0x04, /* AMRWB_1585 */
+ 0x08, /* AMRWB_2385 */
+ 0x03, /* AMRWB_1425 */
+ 0x05, /* AMRWB_1825 */
+ 0x0f /* invalid */
+};
diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..e0929578f786590ca7871143f06fc337d4da2aaf
--- /dev/null
+++ b/lib_com/modif_fs_fx.c
@@ -0,0 +1,1297 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include
+#include "rom_enc_fx.h" /* prototypes */
+#include "stl.h"
+
+#include "basop_util.h"
+
+/*-----------------------------------------------------------------*
+ * Local functions
+ *-----------------------------------------------------------------*/
+
+
+
+/*==============================================================================*/
+/* FUNCTION : modify_Fs_fx ( ) */
+/*------------------------------------------------------------------------------*/
+/* PURPOSE : Modify sampling freq by interpolation */
+/*------------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* const Word16 sigIn_fx[] signal to decimate Q_syn2-1 */
+/* const Word16 lg length of input */
+/* const Word16 fin frequency of input Q0 */
+/* const Word16 fout frequency of output Q0 */
+/*------------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* Word16 sigOut_fx[] decimated signal Q_syn2-1 */
+/*------------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* Word16 mem_fx[] filter memory Q_syn2-1 */
+/*------------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None. */
+/*------------------------------------------------------------------------------*/
+/* CALLED FROM : TX/RX */
+/*==============================================================================*/
+Word16 modify_Fs_fx( /* o : length of output Q0 */
+ const Word16 sigIn_fx[], /* i : signal to decimate Q0 */
+ Word16 lg, /* i : length of input Q0 */
+ const Word32 fin, /* i : frequency of input Q0 */
+ Word16 sigOut_fx[], /* o : decimated signal Q0 */
+ const Word32 fout, /* i : frequency of output Q0 */
+ Word16 mem_fx[] /* i/o: filter memory Q0 */
+ ,const Word16 nblp /* i : flag indicating if NB low-pass is applied */
+)
+{
+ Word16 i;
+
+ Word16 lg_out, fac_num, fac_den, filt_len, frac, temp_n, mem_len;
+ Word16 num_den;
+ Word16 datastep, fracstep;
+ Word16 *sigIn_ptr, *sigPtr;
+ Word16 signal_tab_fx[3*L_FILT_MAX + L_FRAME48k], *signal_fx, *signal_ana_fx; /* 3* as 2* for memory and 1* for future prediction */
+ Word16 A_fx[M+1], r_fx_h[M+1], r_fx_l[M+1];
+ Word16 mem_len_ana;
+ Word16 plus_sample_in;
+ Word16 j;
+ Word16 mu_preemph_fx;
+ Word16 mem_preemph_fx;
+ Word16 Q_r;
+ Word16 mem_lev_fx[18];
+ Word32 t0, t1, t2, L_tmp; /* temporary variables */
+ Word32 LepsP[M+1];
+ Word16 flag_low_order = 0;
+ Word16 filt_len_tmp;
+
+ const Resampling_cfg_fx *cfg_ptr_fx;
+
+ /*-------------------------------------------------------------------*
+ * Find the resampling configuration
+ *-------------------------------------------------------------------*/
+
+ /* check if fin and fout are the same */
+ IF (EQ_32(fin,fout))
+ {
+ /* just copy the signal_fx and quit */
+ Copy(sigIn_fx, sigOut_fx, lg);
+
+ return lg;
+ }
+ ELSE
+ {
+ /* find the resampling configuration in the lookup table */
+ cfg_ptr_fx = &resampling_cfg_tbl_fx[0];
+ WHILE ( (cfg_ptr_fx->fin_fx != 0) && !(EQ_32(cfg_ptr_fx->fin_fx,fin)&&EQ_32(cfg_ptr_fx->fout_fx,fout)))
+ {
+ test();
+ test();
+ cfg_ptr_fx++;
+ }
+
+
+ /* find config with NB 4kHz low-pass */
+ test();
+ test();
+ IF ( nblp && (GT_32(fin, 8000))&&(EQ_32(fout,12800)))
+ {
+ flag_low_order = 1;
+ move16();
+ cfg_ptr_fx++;
+ WHILE ( (cfg_ptr_fx->fin_fx != 0) && !( (EQ_32(cfg_ptr_fx->fin_fx, fin))&&(EQ_32(cfg_ptr_fx->fout_fx,fout))))
+ {
+ test();
+ test();
+ cfg_ptr_fx++;
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Retrieve and/or calculate the resampling parameters
+ *-------------------------------------------------------------------*/
+ fac_num = cfg_ptr_fx->fac_num_fx;
+ move16();/*Q0*/
+ fac_den = cfg_ptr_fx->fac_den_fx;
+ move16();
+
+ IF(GE_16(lg,L_FRAME))
+ {
+ lg_out = cfg_ptr_fx->lg_out ;
+ move16();
+ }
+ ELSE
+ {
+ lg_out = idiv1616(i_mult2(lg, fac_num), fac_den);
+ }
+ filt_len = cfg_ptr_fx->filt_len_fx;
+ move16();
+ plus_sample_in = 0;
+ move16();/*default, regular delay*/
+ frac = 0;
+ move16();
+
+ test();
+ IF ( (EQ_32(fin, 8000))&&(EQ_32(fout,12800)))
+ {
+ plus_sample_in = 7;
+ move16();
+ frac = 4;
+ move16();
+ }
+
+ mem_len = shl(filt_len,1);
+ signal_fx = signal_tab_fx+2*L_FILT_MAX + sub(L_FRAME48k, add(mem_len, lg));
+ signal_ana_fx = signal_fx;
+ mem_len_ana = mem_len;
+ move16();
+ }
+
+
+ /*-------------------------------------------------------------------*
+ * Resample
+ *-------------------------------------------------------------------*/
+ /* append filter memory */
+ Copy(mem_fx, signal_fx, mem_len);
+
+ sigPtr = signal_fx + mem_len;
+ Copy(sigIn_fx, sigPtr, lg);
+
+ IF(plus_sample_in > 0)
+ {
+ autocorr_fx( signal_ana_fx+mem_len_ana+lg-LEN_WIN_SSS, 1, r_fx_h, r_fx_l, &Q_r, LEN_WIN_SSS, wind_sss_fx, 0, 0 );
+
+
+ t1 = L_Comp(r_fx_h[1], r_fx_l[1]); /* R[1] in Q31 */
+ t2 = L_abs(t1); /* abs R[1] */
+ t0 = L_deposit_l(0);
+ IF (r_fx_h[0] != 0)
+ {
+ t0 = Div_32(t2, r_fx_h[0], r_fx_l[0]); /* R[1]/R[0] in Q31 */
+ }
+ if (t1 < 0)
+ {
+ t0 = L_negate(t0); /* R[1]/R[0] */
+ }
+
+
+
+ mu_preemph_fx = extract_h(t0); /*r_fx[1] / r_fx[0]; */
+ mem_preemph_fx = signal_ana_fx[mem_len_ana+lg-LEN_WIN_SSS - 1];
+ move16();
+ preemph_fx(signal_ana_fx+mem_len_ana+lg-LEN_WIN_SSS, mu_preemph_fx, LEN_WIN_SSS, &mem_preemph_fx);
+
+
+ /* Autocorrelations */
+ autocorr_fx( signal_ana_fx+mem_len_ana+lg-LEN_WIN_SSS, M, r_fx_h, r_fx_l, &Q_r,
+ LEN_WIN_SSS, wind_sss_fx, 0, 0 );
+
+ /* Lag windowing */
+ lag_wind( r_fx_h, r_fx_l, M, fin, LAGW_STRONG );
+
+ /* Levinson-Durbin */
+ set16_fx(mem_lev_fx, 0, 18 );
+ E_LPC_lev_dur(r_fx_h, r_fx_l, A_fx, LepsP, M, NULL);
+
+ Copy_Scale_sig( A_fx, A_fx, M+1, sub(norm_s(A_fx[0]),2) );
+
+ FOR (i=0; ifilter_fx, frac, fac_num, filt_len_tmp ));
+
+ frac = add(frac,fracstep);
+
+ j = sub(fac_num, frac);
+ if (j < 0)
+ {
+ frac = sub(frac,fac_num);
+ }
+ sigIn_ptr += add(lshr(j, 15), datastep);
+ }
+ /* rescaling */
+ test();
+ IF ((GT_16(fac_num,fac_den))==((cfg_ptr_fx->flags_fx&RS_INV_FAC)!=0))
+ {
+ IF(LT_16(fac_num, fac_den))
+ {
+ num_den = div_s(fac_num,fac_den);/*Q15*/
+ test();
+ IF( GT_32(fin, 16000)&&EQ_16(lg_out,512))
+ {
+
+ FOR( i=0; iflags_fx&RS_INV_FAC)!=0))
+ {
+ FOR( i=0; i Q(-QSR) */
+ }
+
+ /* length of the interpolated signal */
+ /*lg_out = (short)(lg * fout / fin); */
+
+ /* cc[x][3]*s*s*s + cc[x][2]*s*s + cc[x][1]*s + cc[x][0]; indexes relatives of s : -1 0 1 2 */
+ /* d : cc[x][0] = s[0] */
+ /* b : cc[x][2] =(s[-1]+s[1])/2-s[0] */
+ /* a : cc[x][3] = (s[-1]+s[2]-s[0]-s[1]-4*cc[x][2]) / 6 */
+ /* c : cc[x][1] = s[1]-s[0]-cc[x][3]-cc[x][2] */
+
+ /* coef inits using memory (indexes < 0) */
+ /* cc[2][] : indexes -2 -1 0 1 */
+ cptr = &(cc[2][0]);
+ cptr[0] = mult_r(sigin_sr[-1], 10923);
+ move16(); /* sigIn[-1]/3 */
+ cptr[2] = sub(shr(add(sigin_sr[-2], sigin_sr[0]), 1), sigin_sr[-1]);
+ move16(); /* (sigIn[-2]+sigIn[0])/2-sigIn[-1]; */
+ cptr[3] = sub(mult_r(sub(add(sigin_sr[-2], sigin_sr[1]), add(sigin_sr[-1], sigin_sr[0])), 5461), mult_r(cptr[2],21845));
+ move16(); /*(sigIn[-2]+sigIn[1]-sigIn[-1]-sigIn[0]) / 6 - 4/6*cc[2][2]);*/
+ cptr[1] = sub(sub(sigin_sr[0], sigin_sr[-1]), add(cptr[3], cptr[2]));
+ move16();
+
+ /* cc[3][] : indexes -1 0 1 2 */
+ cptr = &(cc[3][0]);
+ cptr[0] = mult_r(sigin_sr[0], 10923);
+ move16();/* sigIn[-1]/3 */
+ cptr[2] = sub(shr(add(sigin_sr[-1], sigin_sr[1]), 1), sigin_sr[0]);
+ move16(); /* (sigIn[-1]+sigIn[1])/2-sigIn[0]; */
+ cptr[3] = sub(mult_r(sub(add(sigin_sr[-1], sigin_sr[2]), add(sigin_sr[0], sigin_sr[1])), 5461), mult_r(cptr[2],21845));
+ move16(); /*(sigIn[-2]+sigIn[1]-sigIn[-1]-sigIn[0]) / 6 - 4/6*cc[2][2]);*/
+ cptr[1] = sub(sub(sigin_sr[1], sigin_sr[0]), add(cptr[3], cptr[2]));
+ move16();
+
+ sigOutptr = sigOut;
+ cind = -1;
+ move16();
+ move16(); /* for the move */
+ IF( EQ_32(fin, 12800))
+ {
+ if( EQ_32(fout, 8000))
+ {
+ cind = 0;
+ move16();
+ }
+ if( EQ_32(fout, 16000))
+ {
+ cind = 1;
+ move16();
+ }
+ if( EQ_32(fout, 32000))
+ {
+ cind = 2;
+ move16();
+ }
+ if( EQ_32(fout, 48000))
+ {
+ cind = 3;
+ move16();
+ }
+ }
+ IF( EQ_32(fin, 16000))
+ {
+ if( EQ_32(fout, 12800))
+ {
+ cind = 4;
+ move16();
+ }
+ if( EQ_32(fout, 32000))
+ {
+ cind = 5;
+ move16();
+ }
+ if( EQ_32(fout, 48000))
+ {
+ cind = 6;
+ move16();
+ }
+
+ }
+ ctptr = &(ct2_fx[cind][0]);
+ lg_out = mult_r(shl(lg,2),ctptr[13]);
+ *delayout = ctptr[9];
+ move16();
+
+ if( EQ_16(ctptr[12], 15))
+ {
+ cu = cu15_fx;
+ move16();/*pointer*/
+ }
+
+ if( EQ_16(ctptr[12],4))
+ {
+ cu = cu4_fx;
+ move16();/*pointer*/
+ }
+
+ k2d = sub(ctptr[12], 1); /* shift of index in cu with respect to the next sample (ex 1.25 -> 0.25 ) */
+ fk1 = shl(k2d, 1);
+ k3d = sub(fk1, 1); /* to compurte index in cu with respect to the last sample with - sign (ex 1.25 -> -0.75 ) */
+
+ kk = 0;
+ move16();
+ i = 0;
+ move16();
+
+ lim = sub(lg, ctptr[11]);
+ lim2 = sub(lg, 3);
+ lim3 = ctptr[10];
+ move16();
+ WHILE(LT_16(i, lim2))
+ {
+ if(GE_16(i, lim))
+ {
+ lim3 = sub(ctptr[11], 3); /* last, incomplete period*/
+ }
+ *sigOutptr++ = sigIn[i];
+ move16();
+ FOR(k = 0; k < lim3; k++)
+ {
+ cptr = &(cc[kk][0]);
+ cptr[0] = mult_r(sigin_sr[i+1], 10923);
+ move16();/* sigIn[-1]/3 */
+ cptr[2] = sub(shr(add(sigin_sr[i], sigin_sr[i+2]), 1), sigin_sr[i+1]);
+ move16(); /* (sigIn[-1]+sigIn[1])/2-sigIn[0]; */
+ cptr[3] = sub(mult_r(sub(add(sigin_sr[i], sigin_sr[i+3]), add(sigin_sr[i+1], sigin_sr[i+2])), 5461), mult_r(cptr[2],21845));
+ move16(); /*(sigIn[-1]+sigIn[1]-sigIn[0]-sigIn[1]) / 6 - 4/6*cc[3][2]);*/
+ cptr[1] = sub(sub(sigin_sr[i+2], sigin_sr[i+1]), add(cptr[3], cptr[2]));
+ move16();
+ i = add(i,1);
+
+ i2 = sub(kk, 2);
+ i1 = sub(kk, 1);
+ if( i1 < 0 )
+ {
+ i1 = add(i1, 4);
+ }
+
+ if( i2 < 0 )
+ {
+ i2 = add(i2, 4);
+ }
+ inc = ctptr[8];
+ move16();
+ FOR(k1 = ctptr[k]; k1 < fk1; k1 += inc)
+ {
+ k2 = sub(k1, k2d);
+ k3 = sub(k3d, k1);
+ cptr = &(cc[i2][0]);
+ uptr = &(cu[k1][0]);
+ vv32 = L_mult( 8192, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++); /* Q13*Q(-QSR) -> Q(13-QSR+1) 32 bits*/
+ cptr = &(cc[i1][0]);
+ uptr = &(cu[k2][0]);
+ vv32 = L_mac(vv32, 8192, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ cptr = &(cc[kk][0]);
+ uptr = &(cu[k3][0]);
+ vv32 = L_mac(vv32, 8192, *cptr++);
+ vv32 = L_msu(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_msu(vv32, *uptr++, *cptr++);
+ vv32 = L_shl(vv32, (QSR+2)); /* Q(13-QSR+1) -> Q16 */
+ *sigOutptr++ = round_fx(vv32); /* Q16 -> Q0*/
+ }
+
+ kk = add(kk, 1);
+ if( EQ_16(kk, 4))
+ {
+ kk = 0;
+ move16();
+ }
+ }
+ }
+
+
+ kk = sub(kk, 1);
+ if( kk < 0 )
+ {
+ kk = 3;
+ move16();
+ }
+
+ if( EQ_16(ctptr[10], 1))
+ {
+ *sigOutptr++ = sigIn[i];
+ move16();
+ }
+
+ FOR(k1 = ctptr[k]; k1 < fk1; k1 += inc)
+ {
+ k2 = sub(k1, k2d);
+
+ cptr = &(cc[kk][0]);
+ uptr = &(cu[k2][0]);
+ vv32 = L_mult( 8192, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++); /* Q13*Q(-QSR) -> Q(13-QSR+1) 32 bits*/
+ vv32 = L_shl(vv32, (QSR+2)); /* Q(13-QSR+1) -> Q16 */
+ *sigOutptr++ = i_mult(round_fx(vv32), 3);
+ move16();/* Q16 -> Q0*/
+ }
+
+ if( LT_16(ctptr[10], 3))
+ {
+ *sigOutptr++ = sigIn[add(i, 1)];
+ move16();
+ }
+
+ FOR( k1 = ctptr[add(k, 1)]; k1 < fk1; k1 += inc )
+ {
+ cptr = &(cc[kk][0]);
+ uptr = &(cu[k1][0]);
+ vv32 = L_mult( 8192, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++);
+ vv32 = L_mac(vv32, *uptr++, *cptr++); /* Q13*Q(-QSR) -> Q(13-QSR+1) 32 bits*/
+ vv32 = L_shl(vv32, (QSR+2)); /* Q(13-QSR+1) -> Q16 */
+ *sigOutptr++ = i_mult(round_fx(vv32), 3);
+ move16();/* Q16 -> Q0*/
+ }
+
+ if( EQ_16(ctptr[10], 1))
+ {
+ *sigOutptr = sigIn[add(i, 2)];
+ move16();
+ }
+ }
+
+ free(sigin_sr_tab);
+
+ return lg_out;
+}
+
+/*====================================================================*/
+/* FUNCTION : Decimate_allpass_steep_fx1 () */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : decimation by a factor 2 */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* _ (const Word16 *) in_fx : input speech, Q0 */
+/* _ (Word16 []) state_fx: Stateinfo, Q0 */
+/* Size: 2*ALLPASSSECTIONS_STEEP+1 */
+/* _ (Word16) N: Number of Input samples */
+/* _ (Word16 []) out_fx :Output arry of size N/2 Q0 */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16 []) out_fx : output-signal, Q0 */
+/* _ (Word16 []) state_fx:gets updated, Q0 */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : _ None. */
+/*===================================================================*/
+
+
+void Decimate_allpass_steep_fx( const Word16 *in_fx,
+ Word16 state_fx[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
+ Word16 N, /* number of input samples */
+ Word16 out_fx[]) /* array of size N/2 */
+{
+
+ Word16 k;
+ Word16 temp[ ALLPASSSECTIONS_STEEP ];
+ Word32 Lacc, Lacc1;
+ Word16 temp1, temp2;
+ Word16 sum = 0;
+ move16();
+
+ /*upper allpass filter chain */
+
+
+ FOR ( k = 0; k < N/2; k++ )
+ {
+
+ Lacc = L_deposit_h( state_fx[0] ); /* Q(16+x) */
+ Lacc = L_mac( Lacc, AP1_STEEP_FX[0], in_fx[2*k] ); /* Q(16+x) */
+ Lacc1 = L_deposit_h( in_fx[2*k] ); /* Q16+Qx */
+ temp1 = extract_h( Lacc ); /* Qx */
+ Lacc1 = L_msu( Lacc1, AP1_STEEP_FX[0], temp1 ); /* Q16+Qx */
+
+ state_fx[0] = extract_h( Lacc1 ); /* Qx */
+ temp[0] = temp1;
+ move16();
+
+ Lacc1 = L_deposit_h( state_fx[1] ); /* Q16+Qx */
+ Lacc1 = ( L_mac( Lacc1, AP1_STEEP_FX[1], temp1 )); /* Q16+Qx */
+
+ temp2 = extract_h( Lacc1 ); /* Qx */
+ Lacc = L_msu( Lacc, AP1_STEEP_FX[1], temp2 ); /* Q16+Qx */
+ state_fx[1] = extract_h(Lacc); /* Qx */
+ temp[1] = temp2;
+ move16();
+
+
+ Lacc = L_deposit_h( state_fx[ ALLPASSSECTIONS_STEEP-1 ] ); /* Q(16+x) */
+ out_fx[ k ] = extract_h( L_mac( Lacc, AP1_STEEP_FX[ ALLPASSSECTIONS_STEEP-1 ], temp2 )); /* Qx format */
+ state_fx[ ALLPASSSECTIONS_STEEP-1 ] = extract_h( L_msu ( Lacc1, AP1_STEEP_FX[ ALLPASSSECTIONS_STEEP-1 ], out_fx[k] )); /* Qx */
+
+ }
+
+ /* lower allpass filter chain */
+
+ Lacc = L_deposit_h( state_fx[ ALLPASSSECTIONS_STEEP ] ); /* Q(16+x) */
+ Lacc = L_mac( Lacc, AP2_STEEP_FX[0], state_fx[2*ALLPASSSECTIONS_STEEP] ); /*Q(16+x) */
+ Lacc1 = L_deposit_h( state_fx[2*ALLPASSSECTIONS_STEEP] ); /* Q(16+x) */
+ temp1 = extract_h( Lacc ); /* Qx */
+ Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 ); /* Q(16+x) */
+
+ state_fx[ ALLPASSSECTIONS_STEEP ] = extract_h( Lacc1 );
+ temp[0] = temp1;
+ move16();
+
+ Lacc1 = L_deposit_h( state_fx[ ALLPASSSECTIONS_STEEP+1 ] ); /* Q(16+x) */
+ Lacc1 = L_mac( Lacc1, AP2_STEEP_FX[1], temp1 ); /* Q(16+x) */
+ temp2 = extract_h( Lacc1 ); /* Qx */
+ temp[1] = temp2;
+ move16();
+ Lacc = L_msu( Lacc, AP2_STEEP_FX[1], temp2 ); /* Q(16+x) */
+ state_fx[ALLPASSSECTIONS_STEEP+1] = extract_h( Lacc ); /* Qx */
+
+
+ Lacc = L_deposit_h( state_fx[2*ALLPASSSECTIONS_STEEP-1] ); /* Q(16+x) */
+ Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp2 ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
+ temp[2] = extract_h( Lacc ); /* temp[2] in Qx */
+ Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2] ); /* Q(16+x) */
+ state_fx[ 2*ALLPASSSECTIONS_STEEP-1 ] = extract_h( Lacc1 ); /* Qx */
+
+ sum = mult_r( out_fx[0], 16384 ); /* Qx */
+ out_fx[0] = add( sum, mult_r(temp[ALLPASSSECTIONS_STEEP-1], 16384 )); /* Qx */ move16();
+
+
+ FOR ( k = 1; k < N/2; k++)
+ {
+
+
+ Lacc = L_deposit_h( state_fx[ ALLPASSSECTIONS_STEEP ] ); /* Q(16+x) */
+ Lacc = L_mac(Lacc, AP2_STEEP_FX[0], in_fx[2*k-1] ); /* Q(16+x):temp[0] */
+ Lacc1 = L_deposit_h( in_fx[ 2*k-1 ] ); /* Q(16+x) */
+ temp1 = extract_h( Lacc ); /* Qx */
+ Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[0], temp1 ); /* Q(16+x) */
+
+ state_fx[ALLPASSSECTIONS_STEEP] = extract_h( Lacc1 ); /* Qx */
+ temp[0] = temp1;
+ move16();
+
+
+ Lacc1 = L_deposit_h( state_fx[ ALLPASSSECTIONS_STEEP+1 ] ); /* Q(16+x) */
+ Lacc1 = L_mac(Lacc1,AP2_STEEP_FX[1],temp1); /* Q(16+x) */
+ temp2 = extract_h( Lacc1 ); /* Qx */
+ temp[1] = temp2;
+ move16();
+ Lacc = L_msu(Lacc,AP2_STEEP_FX[1],temp2); /* Q(16+x) */
+ state_fx[ALLPASSSECTIONS_STEEP+1]= extract_h(Lacc); /* Qx */
+
+
+ Lacc = L_deposit_h( state_fx[2*ALLPASSSECTIONS_STEEP-1] ); /* Q(16+x) */
+ Lacc = L_mac( Lacc, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[1] ); /* Q(16+x) temp[ALLPASSSECTIONS_STEEP-1] */
+ temp[2] = extract_h( Lacc ); /*temp[2] in Qx */
+ Lacc1 = L_msu( Lacc1, AP2_STEEP_FX[ALLPASSSECTIONS_STEEP-1], temp[2] ); /* Q(16+x) */
+ state_fx[2*ALLPASSSECTIONS_STEEP-1] = extract_h( Lacc1 ); /* Qx */
+
+
+
+ sum = mult_r( out_fx[k], 16384 ); /* Qx */
+ out_fx[k] = add( sum, mult_r( temp[ALLPASSSECTIONS_STEEP-1], 16384 ) );
+ move16(); /* Qx */
+
+ }
+
+ /* z^(-1) */
+
+ state_fx[ 2*ALLPASSSECTIONS_STEEP ] = in_fx[ N-1 ];
+ move16(); /* Qx */
+
+}
+
+
+
+void Interpolate_allpass_steep_fx(const Word16 *in_fx,
+ Word16 state_fx[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
+ Word16 N, /* number of input samples */
+ Word16 out_fx[]) /* array of size 2*N */
+
+
+{
+
+ Word16 k;
+ Word32 Lacc=0, Lacc1=0;
+ Word16 temp1, temp2;
+
+ /*** State in Q0,in_fx Q0, AP1_STEEP in Q15 AP2_STEEP in Q15 OP in Q0 ************/
+ /*upper allpass filter chain */
+
+ FOR (k=0; k 0);
+
+ mem_fx_11 = mem_fx[11];
+ move16();
+ mem_fx_7 = mem_fx[7];
+ move16();
+ mem_fx_3 = mem_fx[3];
+ move16();
+ FOR (i = 0; i < loop_len; i++ )
+ {
+ /* Lower branch */
+ /*Vl0 = mem[8] + filt_coeff[6] * (*in - mem[9]);
+ Vl1 = mem[9] + filt_coeff[7] * (Vl0 - mem[10]);
+ mem[11] = mem[10] + filt_coeff[8] * (Vl1 - mem[11]); */
+ tmp = mult_r(filt_coeff_fx[6], sub(*in++, mem_fx[9]));
+ if (i == 0)
+ {
+ Vl0 = add(mem_fx[8] , tmp);
+ }
+ if (i != 0)
+ {
+ Vl0 = add(*(in-4) , tmp);
+ }
+ Vl1 = add(mem_fx[9] , mult_r(filt_coeff_fx[7], sub(Vl0, mem_fx[10])));
+ mem_fx_11 = add(mem_fx[10], mult_r(filt_coeff_fx[8], sub(Vl1, mem_fx_11)));
+
+ /* mem[8] = *in++;
+ mem[9] = Vl0;
+ mem[10] = Vl1;
+ *out1 = mem[11]; */
+
+ mem_fx[9] = Vl0;
+ move16();
+ mem_fx[10] = Vl1;
+ move16();
+
+ /* Middle branch */
+ /* Vm0 = mem[4] + filt_coeff[3] * (*in - mem[5]);
+ Vm1 = mem[5] + filt_coeff[4] * (Vm0-mem[6]);
+ mem[7] = mem[6] + filt_coeff[5] * (Vm1-mem[7]); */
+ tmp = mult_r(filt_coeff_fx[3], sub(*in++, mem_fx[5]));
+ if (i == 0)
+ {
+ Vm0 = add(mem_fx[4] , tmp);
+ }
+ if (i != 0)
+ {
+ Vm0 = add(*(in-4), tmp);
+ }
+ Vm1 = add(mem_fx[5] , mult_r(filt_coeff_fx[4], sub(Vm0, mem_fx[6])));
+ mem_fx_7 = add(mem_fx[6], mult_r(filt_coeff_fx[5], sub(Vm1, mem_fx_7)));
+
+ mem_fx[5] = Vm0;
+ move16();
+ mem_fx[6] = Vm1;
+ move16();
+ out = add(mem_fx_11, mem_fx_7);
+
+ /* Upper branch */
+ /* Vu0 = mem[0] + filt_coeff[0] * ( *in - mem[1] );
+ Vu1 = mem[1] + filt_coeff[1] * ( Vu0 - mem[2] );
+ mem[3] = mem[2] + filt_coeff[2] * ( Vu1 - mem[3] ); */
+ tmp = mult_r(filt_coeff_fx[0], sub(*in++, mem_fx[1]));
+ if (i == 0)
+ {
+ Vu0 = add(mem_fx[0] , tmp);
+ }
+ if (i != 0)
+ {
+ Vu0 = add(*(in-4), tmp);
+ }
+ Vu1 = add(mem_fx[1] , mult_r(filt_coeff_fx[1], sub(Vu0, mem_fx[2])));
+ mem_fx_3 = add(mem_fx[2] , mult_r(filt_coeff_fx[2], sub(Vu1, mem_fx_3)));
+
+ mem_fx[1] = Vu0;
+ move16();
+ mem_fx[2] = Vu1;
+ move16();
+ *out1++ = add(out, mem_fx_3);
+ move16();
+ }
+ mem_fx[8] = *(in-3);
+ move16();
+ mem_fx[4] = *(in-2);
+ move16();
+ mem_fx[0] = *(in-1);
+ move16();
+ mem_fx[11] = mem_fx_11;
+ move16();
+ mem_fx[7] = mem_fx_7;
+ move16();
+ mem_fx[3] = mem_fx_3;
+ move16();
+
+ Scale_sig(mem_fx, 12, negate(sc));
+ Scale_sig(out_fx, loop_len, negate(sc));
+ Scale_sig(lp_mem_fx, 6, negate(sc));
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * retro_interp4_5_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+void retro_interp4_5_fx(
+ const Word16 *syn_fx,
+ Word16 *pst_old_syn_fx
+)
+{
+ Word16 *pf5, *pf4;
+ Word16 c;
+
+ /* resample st->pst_old_syn in a reverse way to preserve time-alignment */
+ pf4 = (Word16*) &pst_old_syn_fx[58];
+ pf5 = (Word16*) pst_old_syn_fx;
+ FOR (c=0; c<57; c++)
+ {
+ *pf5++ = pf4[0];
+ move16();
+ /* *pf5++ = 0.2f * pf4[0] + 0.8f * pf4[1]; */
+ *pf5++ = mac_r(L_mult(6554, pf4[0]), 26214, pf4[1]);
+ move16();
+ /* *pf5++ = 0.4f * pf4[1] + 0.6f * pf4[2]; */
+ *pf5++ = mac_r(L_mult(13107, pf4[1]), 19661, pf4[2]);
+ move16();
+ /* *pf5++ = 0.6f * pf4[2] + 0.4f * pf4[3]; */
+ *pf5++ = mac_r(L_mult(19661, pf4[2]), 13107, pf4[3]);
+ move16();
+ /* *pf5++ = 0.8f * pf4[3] + 0.2f * pf4[4]; */
+ *pf5++ = mac_r(L_mult(26214, pf4[3]), 6554, pf4[4]);
+ move16();
+ pf4+=4;
+ }
+ *pf5++ = pf4[0];
+ move16();
+ /* *pf5++ = 0.2f * pf4[0] + 0.8f * pf4[1]; */
+ *pf5++ = mac_r(L_mult(6554, pf4[0]), 26214, pf4[1]);
+ move16();
+ /* *pf5++ = 0.4f * pf4[1] + 0.6f * pf4[2]; */
+ *pf5++ = mac_r(L_mult(13107, pf4[1]), 19661, pf4[2]);
+ move16();
+ /* *pf5++ = 0.6f * pf4[2] + 0.4f * pf4[3]; */
+ *pf5++ = mac_r(L_mult(19661, pf4[2]), 13107, pf4[3]);
+ move16();
+ /* *pf5++ = 0.8f * pf4[3] + 0.2f * syn[0]; */
+ *pf5++ = mac_r(L_mult(26214, pf4[3]), 6554, syn_fx[0]);
+ move16();
+ /* all samples processed: NBPSF_PIT_MAX = 290 = (58*5) */
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * retro_interp5_4_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+
+void retro_interp5_4_fx( Word16 *pst_old_syn_fx )
+{
+ Word16 *pf5, *pf4;
+ Word16 c;
+
+ /* resample st->pst_old_syn in a reverse way to preserve time-alignment */
+ pf4 = (Word16*) &pst_old_syn_fx[NBPSF_PIT_MAX-1];
+ pf5 = pf4;
+ FOR (c=0; c<58; c++)
+ {
+ /* *pf4-- = 0.75f * pf5[0] + 0.25f * pf5[-1]; */
+ *pf4-- = mac_r(L_mult(24576, pf5[0]), 8192, pf5[-1]);
+ move16();
+ /* *pf4-- = 0.50f * pf5[-1] + 0.50f * pf5[-2]; */
+ *pf4-- = mac_r(L_mult(16384, pf5[-1]), 16384, pf5[-2]);
+ move16();
+ /* *pf4-- = 0.25f * pf5[-2] + 0.75f * pf5[-3]; */
+ *pf4-- = mac_r(L_mult(8192, pf5[-2]), 24576, pf5[-3]);
+ move16();
+ *pf4-- = pf5[-4];
+ move16();
+ pf5-=5;
+ }
+ /* all samples processed: NBPSF_PIT_MAX = 290 = (58*5) */
+
+ return;
+}
+
diff --git a/lib_com/mslvq_com_fx.c b/lib_com/mslvq_com_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..473d67a7a34b99b8f353f78e635030bfbb57c8a3
--- /dev/null
+++ b/lib_com/mslvq_com_fx.c
@@ -0,0 +1,850 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "prot_fx.h"
+#include "rom_com_fx.h"
+#include "cnst_fx.h"
+#include "stl.h"
+
+/*-----------------------------------------------------------------*
+ * Local functions
+ *-----------------------------------------------------------------*/
+
+static void make_offset_scale_fx( Word16 j, const Word32 tab_no_cv[], const Word16 no_ld[],
+ Word16 no_scl, Word32 offset_scale[][MAX_NO_SCALES+1]);
+static void init_offset_fx( Word32 offset_scale1[][MAX_NO_SCALES+1], Word32 offset_scale2[][MAX_NO_SCALES+1],
+ Word32 offset_scale1_p[][MAX_NO_SCALES+1], Word32 offset_scale2_p[][MAX_NO_SCALES+1],
+ Word16 no_scales[][2], Word16 no_scales_p[][2]);
+static void decode_comb_fx(Word32 index,Word16 *cv,Word16 idx_lead);
+static void decode_sign_pc1_fx( Word16 *c, Word16 idx_sign, Word16 parity );
+static void put_value_fx(Word16 *cv, Word16 *p, Word16 val, Word16 dim, Word16 no_new_val);
+static void decode_leaders_fx(Word16 index, Word16 idx_lead, Word16 *cv );
+static void idx2c_fx(Word16 n, Word16 *p, Word16 k, Word16 val );
+static void divide_64_32_fx(Word16 *xs,Word32 y, Word32 *result, Word32 *rem);
+static Word16
+decode_indexes_fx(Word16 * index,Word16 no_bits,const Word16 * p_scales, Word16 * p_no_scales,
+ Word32 * p_offset_scale1, Word32 * p_offset_scale2,Word16 * x_lvq,Word16 mode_glb, Word16 *scales);
+static Word32 divide_32_32_fx(Word32 y, Word32 x, Word32 * rem);
+static Word16 divide_16_16_fx(Word16 y, Word16 x, Word16 *rem);
+
+/* used in CNG-LP coding */
+void permute_fx(
+ Word16 *pTmp1, /* i/o: vector whose components are to be permuted */
+ const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */
+)
+{
+ Word16 p1, p2;
+ Word16 tmp;
+
+ p1 = perm[0];
+ move16();
+ p2 = perm[1];
+ move16();
+ tmp = pTmp1[p1];
+ move16();
+ pTmp1[p1] = pTmp1[p2];
+ move16();
+ move16();
+ pTmp1[p2] = tmp;
+ move16();
+ p1 = perm[2];
+ move16();
+
+ IF ( GT_16(p1, -1) )
+ {
+ p2 = perm[3];
+ move16();
+ tmp = pTmp1[p1];
+ move16();
+ pTmp1[p1] = pTmp1[p2];
+ move16();
+ move16();
+ pTmp1[p2] = tmp;
+ move16();
+ }
+
+ return;
+}
+
+
+void init_lvq_fx(
+ Word32 offset_scale1[][MAX_NO_SCALES+1], /* o: lattice truncation index offset for the first LSF subvector - safety net structures*/
+ Word32 offset_scale2[][MAX_NO_SCALES+1], /* o: lattice truncation index offset for the second LSF subvector - safety net structures*/
+ Word32 offset_scale1_p[][MAX_NO_SCALES+1], /* o: lattice truncation index offset for the first LSF subvector - predictive structures*/
+ Word32 offset_scale2_p[][MAX_NO_SCALES+1], /* o: lattice truncation index offset for the second LSF subvector - predictive structures*/
+ Word16 no_scales[][2], /* o: number of truncations for each LSF subvector at each MSLVQ structure - safety net */
+ Word16 no_scales_p[][2] /* o: number of truncations for each LSF subvector at each MSLVQ structure - predictive */
+)
+{
+ Word16 i, j;
+ /* safety-net mode */
+ FOR(i=0; i0))
+ {
+ j++;
+ }
+ no_scales[i][0] = j;
+ move16();
+ j = MAX_NO_SCALES;
+ move16();
+ test();
+ WHILE ((LT_16(j,shl(MAX_NO_SCALES,1)))&&(no_lead_fx[i][j]>0))
+ {
+ j++;
+ }
+ no_scales[i][1] = sub(j, MAX_NO_SCALES);
+ move16();
+ }
+ /* predictive mode */
+ FOR(i=0; i0))
+ {
+ j++;
+ }
+ no_scales_p[i][0] = j;
+ move16();
+ j = MAX_NO_SCALES;
+ move16();
+ WHILE ((LT_16(j, shl(MAX_NO_SCALES,1)))&&(no_lead_p_fx[i][j]>0))
+ {
+ j++;
+ }
+ no_scales_p[i][1] = sub(j,MAX_NO_SCALES);
+ move16();
+ }
+ /* index offsets for each truncation */
+ init_offset_fx( offset_scale1, offset_scale2, offset_scale1_p, offset_scale2_p, no_scales, no_scales_p );
+}
+
+/* make_offset_scale_fx() - calculates scale offset values for a particular MSLVQ structure */
+static
+void make_offset_scale_fx(
+ Word16 j, /* i: MSLVQ structure index */
+ const Word32 tab_no_cv[], /* i: cummulated number of codevectors in each leader class */
+ const Word16 no_ld[], /* i: number of leaders in each truncation for the MSLVQ structure j*/
+ Word16 no_scl, /* i: number of truncations in the MSLVQ structure j */
+ Word32 offset_scale[][MAX_NO_SCALES+1]/* o: offset values */
+)
+{
+ Word16 i;
+
+ offset_scale[j][0] = L_deposit_l(1);
+ FOR( i=1; i<=no_scl; i++ )
+ {
+ offset_scale[j][i] = L_add(offset_scale[j][sub(i,1)], tab_no_cv[no_ld[sub(i,1)]]);
+ move32();
+ }
+
+ return;
+}
+
+void init_offset_fx(
+ Word32 offset_scale1[][MAX_NO_SCALES+1], /* o: lattice truncation index offset for the first LSF subvector - safety net structures*/
+ Word32 offset_scale2[][MAX_NO_SCALES+1], /* o: lattice truncation index offset for the second LSF subvector - safety net structures*/
+ Word32 offset_scale1_p[][MAX_NO_SCALES+1],/* o: lattice truncation index offset for the first LSF subvector - predictive structures*/
+ Word32 offset_scale2_p[][MAX_NO_SCALES+1],/* o: lattice truncation index offset for the second LSF subvector - predictive structures*/
+ Word16 no_scales[][2], /* i: number of truncations for each LSF subvector at each MSLVQ structure - safety net */
+ Word16 no_scales_p[][2] /* i: number of truncations for each LSF subvector at each MSLVQ structure - predictive */
+)
+{
+ Word16 j;
+ /* safety-net */
+ FOR( j=0; j 0 )
+ {
+ divide_64_32_fx( index, p_offset_scale2[tmp+ p_no_scales[add(shl(mode_glb,1),1)]], &index1, &index2 );
+ }
+ ELSE
+ {
+ index1 = L_deposit_l(index[0]); /* this is for very low bitrates, so there is no loss in truncation */
+ index2 = L_deposit_l(0);
+ }
+ IF ( index1 == 0 )
+ {
+ FOR( i=0; i 0)
+ {
+ /*if (idx_sign % 2) */
+ IF(s_and(idx_sign,1))
+ {
+ c[i] = negate(c[i]);
+ move16();
+ cnt_neg = negate(cnt_neg);
+ move16();
+ }
+ idx_sign = shr(idx_sign,1); /* >>= 1; */
+ }
+ }
+
+ IF ( LT_16(len, LATTICE_DIM))
+ {
+ IF (NE_16(cnt_neg, parity))
+ {
+ c[len] = negate(c[len]);
+ move16();
+ }
+ }
+
+ return;
+}
+
+
+static void decode_leaders_fx(
+ Word16 index, /* i : index to be decoded */
+ Word16 idx_lead, /* i : leader class index */
+ Word16 *cv /* o : decoded codevector Q1*/
+)
+{
+ Word16 i, no_vals_loc, no_vals_last, p[LATTICE_DIM], dim_loc, n_crt;
+ Word16 index1;
+ Word16 val_crt;
+
+ no_vals_loc = no_vals_fx[idx_lead];
+ move16();
+ val_crt = vals_fx[idx_lead][no_vals_loc-1];
+ move16(); /*Q1 */
+ no_vals_last = no_vals_ind_fx[idx_lead][no_vals_loc-1];
+ move16();
+
+ FOR( i=0; i= 0)
+ {
+ result = L_add(result,1);
+ t = L_add(L_tmp, 0);
+ }
+ }
+ *rem = t;
+ move32();
+ }
+ return result;
+}
+
+/* divide_32_32_fx() :Division reminder for Word16 - rem is the reminder of the division between y and x. */
+static Word16 divide_16_16_fx(Word16 y, /* i */
+ Word16 x, /* i */
+ Word16 *rem /* o */
+ )
+{
+ Word16 result, t, tmp;
+ Word16 i, ny, nx, nyx;
+
+
+ IF (LT_32(y, x))
+ {
+ result = 0;
+ move16();
+ *rem = y;
+ move16();
+ }
+ ELSE
+ {
+
+ result = 0;
+ move16();
+ IF (y==0)
+ {
+ ny = 0;
+ move16();
+ }
+ ELSE
+ {
+ ny = sub(15, norm_s(y));
+ }
+ IF (x==0)
+ {
+ nx = 0;
+ move16();
+ }
+ ELSE
+ {
+ nx = sub(15, norm_s(x));
+ }
+
+ nyx = sub(ny,nx);
+
+ t = s_and(shr(y, add(nyx,1)),sub(shl(1,sub(nx,1)),1));
+ FOR(i=0; i<=nyx; i++)
+ {
+ t = add(shl(t,1), s_and(shr(y,sub(nyx,i)),1)); /* L_and(y,L_shl(1, sub(nyx,i)))); */
+ result = shl(result,1);
+ tmp = sub(t,x);
+ IF(tmp >= 0)
+ {
+ result = add(result,1);
+ t = tmp;
+ move16();
+ }
+ }
+ *rem = t;
+ move16();
+ }
+ return result;
+}
+
+static void divide_64_32_fx(
+ Word16 *xs, /* i : denominator as array of two int32 */
+ Word32 y, /* i : nominator on 32 bits */
+ Word32 *result, /* o : integer division result on 32 bits */
+ Word32 *rem /* o : integer division reminder on 32 bits */
+)
+{
+ Word16 nb_x1;
+ Word32 r, x_tmp, x[2], q, q1;
+
+ x[0] = L_add(L_add(L_shl(L_deposit_l(s_and(xs[2],1)),2*LEN_INDICE),L_shl(L_deposit_l(xs[1]), LEN_INDICE)),L_deposit_l(xs[0]));
+ move32();
+ x[1] = L_shr(L_deposit_l(xs[2]),1);
+ move32();
+
+ /*x[0] = (((xs[2])&(1)<<(LEN_INDICE*2)) + (xs[1]<>1; */
+
+ IF (x[1] ==0)
+ {
+ nb_x1 = 0;
+ move16();
+ }
+ ELSE
+ {
+ nb_x1 = sub(31, norm_l(x[1])); /*get_no_bits_fx(x[1]); */
+ }
+ /* take the first 31 bits */
+ IF ( nb_x1 > 0 )
+ {
+ x_tmp = L_add(L_shl(x[1],sub(31,nb_x1)),L_shr(x[0], nb_x1));
+ /* x_tmp = (x[1]<<(32-nb_x1)) + (x[0]>>nb_x1); */
+
+ q = divide_32_32_fx(x_tmp,y, &r); /* q = x_tmp/y, reminder r */
+ r = L_add(L_shl(r, nb_x1), L_and(x[0],L_deposit_l(sub(shl(1,nb_x1),1)))); /* this is the first reminder */
+ /* r = (r<Q27 */
+ L_tmp = L_shr_r(L_tmp,11); /* Q16 */
+ frac = L_Extract_lc(L_tmp,&exp);
+ frac = extract_l(Pow2(14,frac));
+ G[i*5+k] = round_fx(L_shl(L_mult(frac,UVG2CB1[iG2[i]][k]),exp-sc)); /* Q0 */
+ }
+ ELSE IF (EQ_16(i,1))
+ {
+ L_tmp = L_mult(UVG1CB[iG1][i],27213); /* Q(13+13+1)->Q27 */
+ L_tmp = L_shr_r(L_tmp,11); /* Q16 */
+ frac = L_Extract_lc(L_tmp,&exp);
+ frac = extract_l(Pow2(14,frac));
+ G[i*5+k] = round_fx(L_shl(L_mult(frac,UVG2CB2[iG2[i]][k]),exp-sc)); /* Q0 */
+ }
+ }
+ }
+ return Q_gain;
+}
+
+/*===================================================================*/
+/* FUNCTION : generate_nelp_excitation_fx */
+/*-------------------------------------------------------------------*/
+/* PURPOSE : This function computes the random
+ excitation scaled by gain */
+/*-------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+
+/* _ (Word16*) Gains : Gain vector (Q_exc) */
+/* _ (Word16) gain_fac : gain factor (Q14) */
+/*-------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* _ (Word16*) seed : Random seed (Q0) */
+/* _ (Word16*) output : excitation output (Q_exc) */
+/*-------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/* _ None. */
+/*-------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None. */
+/*===================================================================*/
+void generate_nelp_excitation_fx(
+ Word16 *seed, /* i/o: random number seed */
+ Word16 *Gains, /* i : excitation gains Q_exc*/
+ Word16 *output, /* o : excitation output */
+ Word16 gain_fac /* i : gain factor */
+)
+{
+ Word16 i, len, j;
+ Word16 tmp[31], tmp1[31], tmpf, L16;
+ Word16 k1, k2, I[31], tmpi;
+ Word32 L32;
+ Word16 cnt;
+
+ FOR (i=0; i<10; i++)
+ {
+ IF (EQ_16(i,9))
+ {
+ len=31;
+ move16();
+ cnt=8;
+ move16();
+ }
+ ELSE
+ {
+ len=25;
+ move16();
+ cnt=6;
+ move16();
+ }
+
+ FOR (j=0; j
+#include "prot_fx.h"
+
+/********************************/
+/* Helper functions */
+/********************************/
+
+/** Put nBits long encoded value from *pStream into bitstream. Using the function EncodeValue for encoding. */
+static Word16 PutIntoBitstream(Word16 const ** pStream, TEncodeValue EncodeValue, Word16 index, Encoder_State_fx *st_fx, Word16 nBits)
+{
+ Word16 value;
+ Word16 codedValue;
+
+ move16();
+ value = *(*pStream)++;
+ codedValue = EncodeValue(value, index);
+
+ push_next_indice_fx(st_fx, codedValue, nBits);
+
+ return value;
+}
+
+
+/** Get nBits long value from bitstream into *pStream. */
+static Word16 GetFromBitstream(Decoder_State_fx *st, TDecodeValue DecodeValue, Word16 index, Word16 nFixedBits, Word16 ** pStream)
+{
+ Word16 value;
+
+ move16();
+ move16();
+ value = 0;
+
+ IF (DecodeValue != NULL)
+ {
+ DecodeValue(st, index, &value);
+ }
+ ELSE
+ {
+ value = get_next_indice_fx(st, nFixedBits);
+ }
+ move16();
+ *(*pStream)++ = value;
+
+ return value;
+}
+
+static Word16 FixedWidthEncoding(Word16 value, Word16 index)
+{
+ (void)index;
+ return value;
+}
+
+/********************************/
+/* Interface functions */
+/********************************/
+
+void GetParameters(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, void const * pParameter, Word16 ** pStream, Word16 * pnSize, Word16 * pnBits)
+{
+ Word16 index;
+ Word16 iParam, nParams;
+ Word16 value;
+ void const * pSubStruct;
+
+
+ assert((paramsBitMap != NULL) && (nArrayLength > 0) && (pParameter != NULL) && (pStream != NULL) && (pnSize != NULL) && (pnBits != NULL));
+
+ move16();
+ nParams = paramsBitMap->nParams;
+
+ FOR (index = 0; index < nArrayLength; index++)
+ {
+
+ FOR (iParam = 0; iParam < nParams; iParam++)
+ {
+ ParamBitMap const * param;
+
+ move16();
+ param = & paramsBitMap->params[iParam];
+
+ pSubStruct = param->GetParamValue(pParameter, index, &value);
+ /* If a function for encoding/decoding value is defined than it should take care of 0 */
+ IF ( s_or(param->fZeroAllowed != 0, param->EncodeValue != NULL) )
+ {
+ move16();
+ *(*pStream)++ = value;
+ }
+ ELSE
+ {
+ move16();
+ *(*pStream)++ = sub(value, 1);
+ }
+
+ move16();
+ *pnSize = add(*pnSize, 1);
+
+ IF (param->nBits != 0)
+ {
+ move16();
+ *pnBits = add(*pnBits, param->nBits);
+ }
+ ELSE
+ {
+ move16();
+ *pnBits = add(*pnBits, param->GetNumberOfBits(value, index));
+ }
+
+ IF ( s_and(param->pSubParamBitMap != NULL, value > 0) )
+ {
+ const void *pointer;
+
+ move16();
+ pointer = pParameter;
+ if (pSubStruct != NULL)
+ {
+ move16();
+ pointer = pSubStruct;
+ }
+ GetParameters(param->pSubParamBitMap, value, pointer, pStream, pnSize, pnBits);
+ }
+ }
+ }
+
+}
+
+void SetParameters(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, void * pParameter, Word16 const ** pStream, Word16 * pnSize)
+{
+ Word16 index;
+ Word16 iParam, nParams;
+ Word16 value;
+ void * pSubStruct;
+ void * pTmp;
+ assert((paramsBitMap != NULL) && (nArrayLength > 0) && (pParameter != NULL) && (pStream != NULL) && (pnSize != NULL));
+ nParams = paramsBitMap->nParams;
+
+ FOR (index = 0; index < nArrayLength; index++)
+ {
+ FOR (iParam = 0; iParam < nParams; iParam++)
+ {
+ ParamBitMap const *param;
+ /* If a function for encoding/decoding value is defined than it should take care of 0 */
+
+ move16();
+ param = ¶msBitMap->params[iParam];
+
+ move16();
+ value = 1;
+ if ( s_or(param->fZeroAllowed!=0, param->EncodeValue != NULL) )
+ {
+ move16();
+ value = 0;
+ }
+ value = add(value, *(*pStream)++);
+
+ pSubStruct = param->SetParamValue(pParameter, index, value);
+ move16();
+ *pnSize = add(*pnSize, 1);
+
+ IF ( s_and(param->pSubParamBitMap != NULL, value > 0) )
+ {
+ pTmp = pParameter;
+ if(pSubStruct != NULL) pTmp = pSubStruct;
+ SetParameters(param->pSubParamBitMap, value, pTmp, pStream, pnSize);
+ }
+ }
+ }
+
+}
+
+void WriteToBitstream(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, Word16 const ** pStream, Word16 * pnSize, Encoder_State_fx *st, Word16 * pnBits)
+{
+ Word16 index;
+ Word16 iParam, nParams;
+ assert((paramsBitMap != NULL) && (nArrayLength > 0) && (pStream != NULL) && (pnSize != NULL) && (st != NULL) && (pnBits != NULL));
+ nParams = paramsBitMap->nParams;
+
+ FOR (index = 0; index < nArrayLength; index++)
+ {
+
+ FOR (iParam = 0; iParam < nParams; iParam++)
+ {
+ ParamBitMap const *param;
+ Word16 nBits;
+ /* If a function for encoding/decoding value is defined than it should take care of 0 */
+ Word16 fShiftValue;
+ TEncodeValue EncodeValue;
+ Word16 value;
+
+ move16();
+ param = ¶msBitMap->params[iParam];
+
+ move16();
+ nBits = param->nBits;
+ IF (param->nBits == 0)
+ {
+ nBits = param->GetNumberOfBits(**pStream, index);
+ }
+
+ test();
+ test();
+ fShiftValue = s_and(param->fZeroAllowed==0, param->EncodeValue == NULL);
+ move16();
+ EncodeValue = param->EncodeValue;
+ if (param->EncodeValue == NULL)
+ {
+ move16();
+ EncodeValue = &FixedWidthEncoding;
+ }
+ value = PutIntoBitstream(pStream, EncodeValue, index, st, nBits);
+ if (fShiftValue)
+ {
+ value = add(value, 1);
+ }
+
+ move16();
+ *pnSize = add(*pnSize, 1);
+ move16();
+ *pnBits = add(*pnBits, nBits);
+
+ IF ((param->pSubParamBitMap != NULL) && (value > 0))
+ {
+ WriteToBitstream(param->pSubParamBitMap, value, pStream, pnSize, st, pnBits);
+ }
+
+ }
+ }
+}
+
+void ReadFromBitstream(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, Decoder_State_fx *st, Word16 ** pStream, Word16 * pnSize)
+{
+ Word16 index;
+ Word16 iParam, nParams;
+ Word16 fShiftValue;
+ Word16 value;
+ assert((paramsBitMap != NULL) && (nArrayLength > 0) && (pStream != NULL) && (pnSize != NULL) && (st != NULL));
+ move16();
+ nParams = paramsBitMap->nParams;
+
+ FOR (index = 0; index < nArrayLength; index++)
+ {
+
+ FOR (iParam = 0; iParam < nParams; iParam++)
+ {
+ ParamBitMap const * param;
+
+
+ /* If a function for encoding/decoding value is defined than it should take care of 0 */
+ move16();
+ param = & paramsBitMap->params[iParam];
+
+ test();
+ test();
+ fShiftValue = s_and(param->fZeroAllowed==0, param->EncodeValue == NULL);
+ value = GetFromBitstream(st, param->DecodeValue, index, param->nBits, pStream);
+ if (fShiftValue)
+ {
+ move16();
+ value = add(value, 1);
+ }
+
+ IF ((param->pSubParamBitMap != NULL) && (value > 0))
+ {
+
+ ReadFromBitstream(param->pSubParamBitMap, value, st, pStream, pnSize);
+ }
+ }
+ }
+ move16();
+ *pnSize = add(*pnSize, i_mult(nParams, nArrayLength));
+
+}
diff --git a/lib_com/phase_dispersion.c b/lib_com/phase_dispersion.c
new file mode 100644
index 0000000000000000000000000000000000000000..f2a5f67e91703f85fcbe39b2b32684d266d71b27
--- /dev/null
+++ b/lib_com/phase_dispersion.c
@@ -0,0 +1,177 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+
+#include
+#include "options.h" /* EV-VBR compilation switches */
+#include "prot_fx.h"
+#include "basop_util.h"
+#include "stl.h" /* Weighted mops computation related code */
+
+/*-----------------------------------------------------------------------*
+ * phase_dispersion:
+ *
+ * post-processing to enhance noise at low bit rate.
+ *-----------------------------------------------------------------------*/
+
+void phase_dispersion(
+ const Word32 gain_code, /* i : gain of code 15Q16 */
+ const Word16 gain_pit, /* i : gain of pitch Q14 */
+ Word16 code[], /* i/o: code vector */
+ Word16 *code_exp, /* i/o: exponent of code */
+ const Word16 mode, /* i : level, 0=hi, 1=lo, 2=off */
+ Word32 *prev_gain_code, /* i/o: static memory 15Q16 */
+ Word16 prev_gain_pit[], /* i/o: static memory Q14, size=6 */
+ Word16 *prev_state, /* i/o: static memory Q0 */
+ Word16 L_subfr /* i : subframe length [40,64,80]*/
+)
+{
+ Word16 i, j, state, scale2;
+ Word32 x32[2*L_SUBFR];
+ Word16 *code_real, *code_imag;
+ const Word16 *h_real, *h_imag;
+
+
+
+ move16();
+ state = 2;
+
+ if ( LT_16(gain_pit,14746/*0.9f Q14*/))
+ {
+ move16();
+ state = 1;
+ }
+ if ( LT_16(gain_pit, 9830/*0.6f Q14*/))
+ {
+ move16();
+ state = 0;
+ }
+
+ FOR (i=5; i>0; i--)
+ {
+ move16();
+ prev_gain_pit[i] = prev_gain_pit[i-1];
+ }
+ move16();
+ prev_gain_pit[0] = gain_pit;
+
+
+ IF ( GT_32(gain_code, L_add(*prev_gain_code, L_shl(*prev_gain_code,1))))
+ {
+ if (LT_16(state,2))
+ {
+ state = add(state, 1);
+ }
+ }
+ ELSE
+ {
+ j=0;
+ FOR (i=0; i<6; i++)
+ {
+
+ if ( LT_32(prev_gain_pit[i], 9830/*0.6f Q14*/))
+ {
+ j = add(j,1);
+ }
+ }
+
+ if (GT_16(j,2))
+ {
+ move16();
+ state = 0;
+ }
+
+ if ( GT_16(sub(state, *prev_state),1))
+ {
+ state = sub(state,1);
+ }
+ }
+
+ move32();
+ move16();
+ *prev_gain_code = gain_code;
+ *prev_state = state;
+
+ /*-----------------------------------------------------------------*
+ * circular convolution
+ *-----------------------------------------------------------------*/
+
+ state = add(state, mode); /* level of dispersion */
+ j = *code_exp;
+ move16();
+ IF( LT_16(state,2))
+ {
+ FOR(i=0; i 0)
+ {
+ frac = sub(frac,UP_SAMP);
+ x0--;
+ }
+
+ l = add(UP_SAMP-1, frac);
+ FOR (j = T0; j < L_SUBFR+1; j++)
+ {
+ k = l;
+ move16();
+ L_sum = L_mult(x0[0], win[k]);
+ FOR (i = 1; i < 2 * L_INTERPOL2; i++)
+ {
+ /*
+ * Here, additions with UP_SAMP are not counted
+ ki* because, the window could easily be modified
+ * so that the values needed are contiguous.
+ */
+ k += UP_SAMP;
+ L_sum = L_mac(L_sum, x0[i], win[k]); /*Q1 */
+ }
+ L_sum = L_shl(L_sum, 1); /*Q0h */
+
+ excO[j] = round_fx(L_sum);
+
+ x0++;
+ }
+ FOR (i = T0; i < L_SUBFR; i++)
+ {
+ exc[i+i_subfr] = add(exc[i+i_subfr], mult_r(PIT_SHARP_fx, excO[i]));
+ move16();
+ }
+ }
+
+ return;
+
+}
diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..b667eeca159b8cbdae843feef33730deec414d95
--- /dev/null
+++ b/lib_com/preemph_fx.c
@@ -0,0 +1,136 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+/*-------------------------------------------------------------*
+ * preemph_copy_fx()
+ *
+ * Preemphasis: filtering through 1 - mu z^-1
+ *-------------------------------------------------------------*/
+void preemph_copy_fx(
+ const Word16 x[], /* i : input signal Qx */
+ Word16 y[], /* o : output signal Qx */
+ const Word16 mu, /* i : preemphasis coefficient Q15 */
+ const Word16 lg, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (x[-1]) Qx */
+)
+{
+ Word16 i, temp;
+
+ temp = x[lg - 1];
+ move16();
+ FOR (i = sub(lg, 1); i > 0; i--)
+ {
+ y[i] = msu_r(L_deposit_h(x[i]), x[i - 1], mu);
+ move16();
+ }
+ y[0] = msu_r(L_deposit_h(x[0]), *mem, mu);
+ move16();
+
+ *mem = temp;
+ move16();
+}
+
+/*
+ * E_UTIL_f_preemph2
+ *
+ * Parameters:
+ * shift I: scale output
+ * signal I/O: signal Qx/Qx+shift
+ * mu I: preemphasis factor Q15
+ * L I: vector size
+ * mem I/O: memory (x[-1])
+ *
+ * Function:
+ * Filtering through 1 - mu z^-1
+ *
+ * Returns:
+ * void
+ */
+void E_UTIL_f_preemph2(Word16 shift, Word16 *signal, const Word16 mu, const Word16 lg, Word16 *mem)
+{
+ Word16 i, temp;
+ Word32 L_tmp;
+
+ temp = signal[lg - 1];
+ move16();
+
+ FOR (i = sub(lg, 1); i > 0; i--)
+ {
+ L_tmp = L_mult(signal[i], 16384);
+ L_tmp = L_msu0(L_tmp, signal[i - 1], mu);
+ L_tmp = L_shl(L_tmp, add(shift,1));
+ signal[i] = round_fx(L_tmp);
+ }
+
+ L_tmp = L_mult(signal[0], 16384);
+ L_tmp = L_msu0(L_tmp, *mem, mu);
+ L_tmp = L_shl(L_tmp, add(shift,1));
+ signal[0] = round_fx(L_tmp);
+
+ *mem = temp;
+ move16();
+
+ return;
+}
+
+
+Word16 E_UTIL_f_preemph3(Word16 *signal, const Word16 mu, const Word16 lg, Word16 *mem, Word16 bits)
+{
+ Word16 i, QVal, mus, tmp_fixed, Q_new;
+ Word32 L_tmp, L_maxloc;
+
+
+
+ QVal = shl(1, sub(15,bits));
+ mus = shr(mu, bits);
+
+ L_tmp = L_mult(signal[0], QVal);
+ L_tmp = L_msu(L_tmp, *mem, mus);
+ L_maxloc = L_abs(L_tmp);
+
+ FOR (i = 1; i < lg; i++)
+ {
+ L_tmp = L_mult(signal[i], QVal);
+ L_tmp = L_msu(L_tmp, signal[i - 1], mus);
+ L_tmp = L_abs(L_tmp);
+ L_maxloc = L_max(L_tmp, L_maxloc);
+ }
+
+ tmp_fixed = extract_h(L_maxloc);
+
+ Q_new = Q_MAX;
+ move16();
+ IF (tmp_fixed != 0)
+ {
+ Q_new = sub(norm_s(tmp_fixed), bits);
+ Q_new = s_max(Q_new, 0);
+ Q_new = s_min(Q_new, Q_MAX);
+ }
+
+ tmp_fixed = signal[lg - 1];
+ move16();
+
+ FOR (i = sub(lg,1); i > 0; i--)
+ {
+ L_tmp = L_mult(signal[i], QVal);
+ L_tmp = L_msu(L_tmp, signal[i - 1], mus);
+ L_tmp = L_shl(L_tmp, Q_new);
+ signal[i] = round_fx(L_tmp);
+ }
+
+ L_tmp = L_mult(signal[0], QVal);
+ L_tmp = L_msu(L_tmp, *mem, mus);
+ L_tmp = L_shl(L_tmp, Q_new);
+ signal[0] = round_fx(L_tmp);
+
+ *mem = tmp_fixed;
+ move16();
+
+ return Q_new;
+}
+
diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h
new file mode 100644
index 0000000000000000000000000000000000000000..ef9867907d52fa96a83ffb9f28e3d5dd9a365105
--- /dev/null
+++ b/lib_com/prot_fx.h
@@ -0,0 +1,11084 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#ifndef PROT_COM_FX_H
+#define PROT_COM_FX_H
+#include
+#include "options.h" /* Compilation switches */
+#include "rom_com_fx.h" /* Compilation switches */
+#include "typedefs.h"
+#include "stat_dec_fx.h"
+#include "stat_enc_fx.h"
+#include "stat_com.h"
+#include "cnst_fx.h"
+#include "basop_util.h"
+#include "complex_basop.h"
+/*----------------------------------------------------------------------------------*
+ * Prototypes of global macros
+ *----------------------------------------------------------------------------------*/
+
+void reset_preecho_dec_fx (
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+void preecho_sb_fx(
+ const Word32 brate, /* i Q0 : core bit-rate */
+ Word32 *wtda_audio_fx, /* i q_sig32 : imdct signal */
+ Word16 q_sig32, /* i Q value for wtda_audio_fx */
+ Word16 *rec_sig_fx, /* i q_sig16 : reconstructed signal, output of the imdct transform */
+ Word16 q_sig16, /* i Q value for rec_sig_fx and imdct_mem_fx */
+ const Word16 framelength, /* i Q0 : frame length */
+ Word16 *memfilt_lb_fx, /* i/o Q0 : memory */
+ Word32 *mean_prev_hb_fx, /* i/o Q0 : memory */
+ Word16 *smoothmem_fx, /* i/o Q15 : memory */
+ Word32 *mean_prev_fx, /* i/o Q0 : memory */
+ Word32 *mean_prev_nc_fx, /* i/o Q0 : memory */
+ Word16 *wmold_hb_fx, /* i/o Q15 : memory */
+ Word16 *prevflag, /* i/o Q0 : flag */
+ Word16 *pastpre, /* i/o Q0 : flag */
+ const Word16 bwidth /* i Q0 : bandwidth */
+);
+
+void calc_normal_length_fx_32(
+ const Word16 core, /* i : core : Q0 */
+ const Word32 *sp, /* i : input signal : Q12 */
+ const Word16 mode, /* i : input mode : Q0 */
+ const Word16 extl, /* i : extension layer : Q0 */
+ Word16 *L_swb_norm, /* o : normalize length : Q0 */
+ Word16 *prev_L_swb_norm /*i/o : last normalize length : Q0 */
+);
+
+void calc_norm_envelop_fx_32(
+ const Word32 SWB_signal_fx[], /* i : SWB spectrum : Q12 */
+ Word32 *envelope_fx, /* o : normalized envelope : Q16 */
+ const Word16 L_swb_norm, /* i : length of envelope : Q0 */
+ const Word16 SWB_flength, /* i : Length of input/output : Q0 */
+ const Word16 st_offset /* i : offset : Q0 */
+);
+
+void push_indice_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 id, /* i : ID of the indice */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+);
+
+void push_next_indice_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ UWord16 value, /* i : value of the quantized indice */
+ Word16 nb_bits /* i : number of bits used to quantize the indice */
+);
+
+void push_next_bits_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 bits[], /* i : bit buffer to pack, sequence of single bits */
+ Word16 nb_bits /* i : number of bits to pack */
+);
+void get_NextCoderType_fx(
+ UWord8 *bitsteam, /* i : bitstream */
+ Word16 *next_coder_type /* o : next coder type */
+);
+void evs_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 input_sp[], /* i : input signal */
+ const Word16 n_samples /* i : number of input samples */
+);
+
+void io_ini_enc_fx(
+ const int argc, /* i : command line arguments number */
+ char *argv[], /* i : command line arguments */
+ FILE **f_input, /* o : input signal file */
+ FILE **f_stream, /* o : output bitstream file */
+ FILE **f_rate, /* o : bitrate switching profile (0 if N/A) */
+ FILE **f_bwidth, /* o : bandwidth switching profile (0 if N/A) */
+ FILE **f_rf, /* o : channel aware config profile (0 if N/A) */
+ Word16 *quietMode, /* o : limit printouts */
+ Word16 *noDelayCmp, /* o : turn off delay compensation */
+ Encoder_State_fx *st /* o : state structure */
+);
+
+void read_next_rfparam_fx(
+ Word16* rf_fec_offset, /* o: rf offset */
+ Word16* rf_fec_indicator, /* o: rf FEC indicator */
+ FILE* f_rf /* i: file pointer to read parameters */
+);
+
+void read_next_brate_fx(
+ Word32 *total_brate, /* i/o: total bitrate */
+ const Word32 last_total_brate, /* i : last total bitrate */
+ FILE *f_rate, /* i : bitrate switching profile (0 if N/A) */
+ Word32 input_Fs, /* i : input sampling frequency */
+ Word16 *Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ Word16 *Opt_SC_VBR, /* i/o: SC-VBR flag */
+ Word16 *codec_mode /* i/o: MODE1 or MODE2 */
+);
+
+
+void read_next_bwidth_fx(
+ Word16 *max_bwidth, /* i/o: maximum encoded bandwidth */
+ FILE *f_bwidth, /* i : bandwidth switching profile (0 if N/A) */
+ Word32 *bwidth_profile_cnt, /* i/o: counter of frames for bandwidth switching profile file */
+ Word32 input_Fs /* i : input sampling frequency */
+);
+
+UWord16 get_next_indice_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
+);
+
+UWord16 get_next_indice_1_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+void get_next_indice_tmp_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
+);
+
+
+UWord16 get_indice_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 pos, /* i : absolute position in the bitstream */
+ Word16 nb_bits /* i : number of bits that were used to quantize the indice */
+);
+
+UWord16 get_indice_1_fx( /* o : value of the indice */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 pos /* i : absolute position in the bitstream */
+);
+
+void reset_indices_enc_fx(
+ Encoder_State_fx *st_fx /* i/o: encoder state structure */
+);
+
+
+void reset_indices_dec_fx(
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+void write_indices_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ FILE *file /* i : output bitstream file */
+ , UWord8 *pFrame, /* i: byte array with bit packet and byte aligned coded speech data */
+ Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */
+);
+
+Word16 read_indices_fx( /* o : 1 = OK, 0 = something wrong */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ FILE *file, /* i : bitstream file */
+ Word16 rew_flag /* i : rewind flag (rewind file after reading) */
+);
+
+Word16 read_indices_mime( /* o : 1 = reading OK, 0 = problem */
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ FILE *file, /* i : bitstream file */
+ Word16 rew_flag /* i : rewind flag (rewind file after reading)*/
+);
+
+void indices_to_serial(
+ const Encoder_State_fx *st_fx, /* i: encoder state structure */
+ UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */
+ Word16 *pFrame_size /* i: size of the binary encoded access unit [bits] */
+);
+
+void indices_to_serial_generic(
+ const Indice_fx *ind_list, /* i: indices list */
+ const Word16 num_indices, /* i: number of indices to write */
+ UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */
+ Word16 *pFrame_size /* i/o: number of bits in the binary encoded access unit [bits] */
+);
+
+void evs_dec_previewFrame(
+ UWord8 *bitstream, /* i : bitstream pointer */
+ Word16 bitstreamSize, /* i : bitstream size */
+ Word16 *partialCopyFrameType, /* o : frame type of the partial copy */
+ Word16 *partialCopyOffset /* o : offset of the partial copy relative to the primary copy */
+);
+
+void read_indices_from_djb_fx(
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ UWord8 *pt_stream, /* i : bitstream file */
+ Word16 nbits /* i : number of bits */
+ , Word16 isAMRWB_IOmode
+ , Word16 core_mode
+ , Word16 qbit
+ ,Word16 partialframe /* i : partial frame information */
+ ,Word16 next_coder_type /* i : next coder type information */
+);
+
+void reset_rf_indices(
+ Encoder_State_fx *st /* i: state structure - contains partial RF indices */
+);
+
+void getPartialCopyInfo(
+ Decoder_State_fx *st, /* i : decoder state structure */
+ Word16 *coder_type,
+ Word16 *sharpFlag
+);
+
+void get_rfFlag(
+ Decoder_State_fx *st, /* i : decoder state structure */
+ Word16 *rf_flag, /* o : check for the RF flag */
+ Word16 *nBits,
+ Word16 *ind
+);
+
+void get_rfFrameType(
+ Decoder_State_fx *st, /* i : decoder state structure */
+ Word16 *rf_frame_type /* o : RF frame type */
+);
+
+void get_rf_fec_offset(
+ Decoder_State_fx *st, /* i : decoder state structure */
+ Word16 *rf_fec_offset /* o : RF fec offset */
+);
+
+void get_rfTargetBits(
+ Word16 rf_frame_type, /* i : RF frame type */
+ Word16 *rf_target_bits /* o : Number of RF target bits */
+);
+
+
+Word16 BRATE2IDX_fx(Word32 brate);
+Word16 BRATE2IDX16k_fx(Word32 brate);
+
+Word32 BIT_ALLOC_IDX_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc);
+Word32 BIT_ALLOC_IDX_16KHZ_fx(Word32 brate, Word16 ctype, Word16 sfrm, Word16 tc);
+
+void save_old_syn_fx(
+ const Word16 L_frame, /* i : frame length */
+ const Word16 syn[], /* i : ACELP synthesis */
+ Word16 old_syn[], /* o : old synthesis buffer */
+ Word16 old_syn_mem[], /* i/o: old synthesis buffer memory */
+ const Word16 preemph_fac, /* i : preemphasis factor */
+ Word16 *mem_deemph /* i/o: deemphasis filter memory */
+);
+
+void evs_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o : Decoder state structure */
+ Word16 output_sp[], /* o : output synthesis signal */
+ frameMode_fx frameMode /* i : Decoder frame mode */
+);
+
+Word16 decodeVoip(
+ Decoder_State_fx *st_fx,
+ FILE *f_stream,
+ FILE *f_synth,
+#ifdef SUPPORT_JBM_TRACEFILE
+ const char *jbmTraceFileName,
+#endif
+ const char *jbmFECoffsetFileName, /* : Output file for Optimum FEC offset */
+ const Word16 quietMode
+);
+
+
+void io_ini_dec_fx(
+ const int argc, /* i : command line arguments number */
+ char *argv[], /* i : command line arguments */
+ FILE **f_stream, /* o : input bitstream file */
+ FILE **f_synth, /* o : output synthesis file */
+ Word16 *quietMode, /* o : limited printouts */
+ Word16 *noDelayCmp, /* o : turn off delay compensation */
+ Decoder_State_fx *st_fx, /* o : Decoder static variables structure */
+#ifdef SUPPORT_JBM_TRACEFILE
+ char **jbmTraceFileName, /* o : VOIP tracefilename */
+#endif
+ char **jbmFECoffsetFileName /* o : Output file for Optimum FEC offset */
+);
+Word16 deindex_lvq_cng_fx(
+ Word16 *index, /* i : index to be decoded, as an array of 3 short */
+ Word16 *x_lvq, /* o : decoded codevector Q9*/
+ Word16 idx_cv, /* i : relative mode_lvq, wrt START_CNG */
+ Word16 no_bits, /* i : number of bits for lattice */
+ Word32 * p_offset_scale1,
+ Word32 * p_offset_scale2,
+ Word16 * p_no_scales
+);
+
+void CNG_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: State structure */
+ const Word16 L_frame, /* i : length of the frame Q0 */
+ Word16 Aq[], /* o : LP coefficients Q12 */
+ const Word32 core_brate, /* i : core bitrate Q0 */
+ Word16 *lsp_new, /* i/o: current frame LSPs Q15 */
+ Word16 *lsf_new, /* i/o: current frame LSFs Qlog2(2.56) */
+ Word16 *allow_cn_step /* o : allow CN step Q0 */
+ ,Word16 *sid_bw /* o : 0-NB/WB, 1-SWB SID */
+ ,Word32 *q_env
+);
+
+void swb_CNG_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: State structure */
+ const Word16 *synth_fx, /* i : ACELP core synthesis at 32kHz */
+ Word16 *shb_synth_fx, /* o : high-band CNG synthesis */
+ const Word16 sid_bw, /* i : 0-NB/WB, 1-SWB SID */
+ const Word16 Qsyn /* i : Q value of ACELP core synthesis */
+);
+
+void CNG_reset_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ Word16 *pitch_buf, /* o : floating pitch for each subframe */
+ Word16 *voice_factors /* o : voicing factors */
+ ,Word16 VBR_cng_reset_flag
+);
+
+void CNG_reset_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 *pitch_buf, /* o : floating pitch for each subframe */
+ Word16 *voice_factors /* o : voicing factors */
+);
+
+void CNG_exc_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 L_frame, /* i : length of the frame */
+ Word32 *Enew, /* i/o: decoded SID energy Q6 */
+ Word16 *seed, /* i/o: random generator seed */
+ Word16 exc[], /* o : current non-enhanced excitation Q_new */
+ Word16 exc2[], /* o : current enhanced excitation Q_new */
+ Word32 *lp_ener, /* i/o: LP filtered E */
+ const Word32 last_core_brate, /* i : previous frame core bitrate */
+ Word16 *first_CNG, /* i/o: first CNG frame flag for energy init. */
+ Word16 *cng_ener_seed, /* i/o: random generator seed for CNG energy */
+ Word16 bwe_exc[], /* o : excitation for SWB TBE */
+ const Word16 allow_cn_step, /* i : allow CN step */
+ Word16 *last_allow_cn_step, /* i/o: last allow step */
+ const Word16 OldQ_exc, /* i : Old excitation scaling */
+ const Word16 Q_exc, /* i : excitation scaling */
+ const Word16 num_ho /* i : number of selected hangover frames */
+ ,Word32 q_env[]
+ ,Word32 *lp_env
+ ,Word32 *old_env
+ ,Word16 *exc_mem
+ ,Word16 *exc_mem1
+ ,Word16 *sid_bw
+ ,Word16 *cng_ener_seed1
+ ,Word16 exc3[]
+ ,Word16 Opt_AMR_WB
+);
+
+void CNG_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: State structure */
+ const Word16 L_frame, /* i : length of the frame Q0 */
+ Word16 Aq[], /* o : LP coefficients Q12 */
+ const Word16 *speech, /* i : pointer to current frame input speech buffer Q_new */
+ Word32 L_enr, /* i : residual energy from Levinson-Durbin Q6 */
+ Word16 *lsp_new, /* i/o: current frame ISPs Q15 */
+ Word16 *lsf_new, /* i/o: current frame ISFs Qlog2(2.56) */
+ Word16 *allow_cn_step, /* o : allow CN step Q0 */
+ Word16 burst_ho_cnt, /* i : hangover frames at end of speech burst Q0 */
+ Word16 Q_new /* i : Q value of speech */
+ ,Word32 *q_env
+ ,Word16 *sid_bw
+ ,Word16 *exc_mem2
+);
+
+void swb_CNG_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: State structure */
+ const Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
+ const Word16 *syn_12k8_16k_fx /* i : ACELP core synthesis at 12.8kHz or 16kHz */
+);
+
+void cng_params_upd_fx(
+ const Word16 lsp_new[], /* i : LSP parameters Q15 */
+ const Word16 exc2[], /* i : current enhanced excitation Q_exc */
+ const Word16 L_frame, /* i : frame length Q0 */
+ Word16 *ho_circ_ptr, /* i/o: pointer for CNG averaging buffers Q0 */
+ Word32 ho_ener_circ[], /* o : energy buffer for CNG averaging Q6 */
+ Word16 *ho_circ_size, /* i/o: size of DTX hangover history buffer for averaging Q0 */
+ Word16 ho_lsp_circ[], /* o : old LSP buffer for CNG averaging Q15 */
+ const Word16 Q_exc, /* i : Q value of excitation */
+ const Word16 enc_dec_flag, /* i : Flag indicating encoder or decoder (ENC,DEC) */
+ Word32 ho_env_circ[], /* i/o: Envelope buffer */
+ Word16 *cng_buf_cnt, /* i/o: Counter of postponed FFT-processing instances */
+ Word16 cng_exc2_buf[], /* i/o: Excitation buffer Q_exc */
+ Word16 cng_Qexc_buf[], /* i/o: Q_exc buffer Q0 */
+ Word32 cng_brate_buf[], /* i/o: last_active_brate buffer Q0 */
+ const Word32 last_active_brate /* i : Last active bit rate Q0 */
+);
+
+void cng_params_postupd_fx(
+ const Word16 ho_circ_ptr, /* i : pointer for CNG averaging buffers Q0 */
+ Word16 *cng_buf_cnt, /* i/o: counter for CNG store buffers Q0 */
+ const Word16 *const cng_exc2_buf, /* i : Excitation buffer Q_exc */
+ const Word16 *const cng_Qexc_buf, /* i : Q_exc buffer Q0 */
+ const Word32 *const cng_brate_buf, /* i : bit rate buffer Q0 */
+ Word32 ho_env_circ[] /* i/o: Envelope buffer */
+);
+Word32 get_delay_fx( /* o : delay value in ms */
+ const Word16 what_delay, /* i : what delay? (ENC or DEC) */
+ const Word32 io_fs /* i : input/output sampling frequency */
+);
+
+
+void signalling_enc_fx(
+ Encoder_State_fx *st_fx, /* i : encoder state structure */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 sharpFlag /* i : formant sharpening flag */
+);
+
+Word16 signalling_mode1_tcx20_enc(
+ Encoder_State_fx *st, /* i : encoder state structure */
+ Word16 push
+);
+
+void signalling_enc_rf(
+ Encoder_State_fx *st /* i : encoder state structure */
+);
+
+void decision_matrix_core_dec(
+ Decoder_State_fx *st /* i/o: decoder state structure */
+);
+
+void decision_matrix_enc_fx(
+ Encoder_State_fx *st_fx, /* i : encoder state structure */
+ const Word16 sp_aud_decision1, /* i : 1st stage speech/music classification */
+ const Word16 sp_aud_decision2, /* i : 2nd stage speech/music classification */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 vad_flag,
+ Word16 *hq_core_type /* o : HQ core_fx type */
+);
+
+void decision_matrix_dec_fx(
+ Decoder_State_fx *st, /* i/o: decoder state structure */
+ Word16 *coder_type, /* o : coder type */
+ Word16 *sharpFlag, /* o : formant sharpening flag */
+ Word16 *hq_core_type, /* o : HQ core type */
+ Word16 *core_switching_flag /* o : ACELP->HQ switching frame flag */
+);
+
+void init_gp_clip_fx(
+ Word16 mem[] /* o : memory of gain of pitch clipping algorithm */
+);
+
+void gp_clip_test_isf_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 isf[], /* i : isf values (in frequency domain) */
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+);
+
+void pitch_ol_init_fx(
+ Word16 *old_thres, /* o : threshold for reinforcement of past pitch influence */
+ Word16 *old_pitch, /* o : pitch of the 2nd half-frame of previous frame */
+ Word16 *delta_pit, /* o : pitch evolution extrapolation */
+ Word16 *old_corr /* o : correlation */
+);
+
+void noise_est_down_fx(
+ const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) */
+ Word32 bckr[], /* i/o: per band background noise energy estimate */
+ Word32 tmpN[], /* o : temporary noise update */
+ Word32 enr[], /* o : averaged energy over both subframes */
+ const Word16 min_band, /* i : minimum critical band */
+ const Word16 max_band, /* i : maximum critical band */
+ Word16 *totalNoise, /* o : noise estimate over all critical bands */
+ Word16 Etot, /* i : Energy of current frame */
+ Word16 *Etot_last, /* i/o: Energy of last frame Q8 */
+ Word16 *Etot_v_h2, /* i/o: Energy variations of noise frames Q8 */
+ Word16 Q_new,
+ const Word32 e_min /* i : minimum energy scaled Q_new + QSCALE */
+);
+
+void wb_vad_init_fx(
+ Word16 *nb_active_frames, /* o : nb of consecutive active speech frames */
+ Word16 *hangover_cnt,
+ Word16 *lp_speech, /* o : long-term active speech level */
+ Word16 *nb_active_frames_he, /* o : nb of consecutive active speech frames */
+ Word16 *hangover_cnt_he,
+ Word16 *bcg_flux, /* o : background noise fluctuation */
+ Word16 *soft_hangover, /* o : soft hangover counter */
+ Word16 *voiced_burst, /* o : consecutive voiced speech counter */
+ Word16 *bcg_flux_init, /* o : initialization period for noise fluctuation estimation */
+ Word16 *nb_active_frames_he1, /* o : nb of consecutive active speech frames 1 */
+ Word16 *hangover_cnt_he1,
+ Word32 *L_vad_flag_reg_H,
+ Word32 *L_vad_flag_reg_L,
+ Word32 *L_vad_prim_reg,
+ Word16 *vad_flag_cnt_50,
+ Word16 *vad_prim_cnt_16,
+ Word16 *hangover_cnt_dtx,
+ Word16 *hangover_cnt_music
+);
+
+Word16 wb_vad_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 fr_bands[], /* i : per band input energy (contains 2 vectors) Q_new+QSCALE*/
+ Word16 *localVAD,
+ Word16 *noisy_speech_HO, /* o : SC-VBR noisy speech HO flag */
+ Word16 *clean_speech_HO, /* o : SC-VBR clean speech HO flag */
+ Word16 *NB_speech_HO, /* o : SC-VBR NB speech HO flag */
+ Word16 *snr_sum_he, /* o : Output snr_sum as weighted spectral measure */
+ Word16 *localVAD_HE_SAD, /* o : HE_SAD decision without hangovers */
+ Word8 *flag_noisy_speech_snr, /* o : */
+ const Word16 Q_new /* i : scaling factor Q0 */
+);
+
+
+void dtx_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 vad, /* i : vad flag */
+ const Word16 speech[], /* i : Pointer to the speech frame */
+ Word16 Q_speech /* i : Q factor for speech */
+
+);
+
+void dtx_hangover_control_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 lsp_new_fx[M] /* i : current frame LSPs */
+);
+
+Word16 dtx_hangover_addition_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 localVAD, /* i Q0 */
+ const Word16 vad_flag, /* i Q0 */
+ const Word16 lp_snr, /* i Q8 */
+ const Word16 cldfb_subtraction, /* i Q0 */
+ Word16 *vad_hover_flag_ptr
+);
+
+void noise_est_init_fx(
+ Word16 *totalNoise, /* o : noise estimate over all critical bands */
+ Word16 *first_noise_updt, /* o : noise update initialization flag */
+ Word32 bckr[], /* o : per band background noise energy estimate */
+ Word32 enrO[], /* o : per band old input energy */
+ Word32 ave_enr[], /* o : per band long-term average energies */
+ Word16 *pitO, /* o : open-loop pitch values from preceed. frame */
+ Word16 *aEn, /* o : noise adaptation hangover counter */
+ Word16 *st_harm_cor_cnt, /* i/o: 1st harm correlation timer */
+ Word16 *bg_cnt, /* i/o: pause burst length counter */
+ Word16 *lt_tn_track, /* Q15 */
+ Word16 *lt_tn_dist, /* Q8 */
+ Word16 *lt_Ellp_dist, /* Etot low lp same domain as *Etot_l_lp, Q8 */
+ Word16 *lt_haco_ev, /* Q15 */
+ Word16 *low_tn_track_cnt /* Q0 */
+ ,Word16 *Etot_st_est, /* Q8: Short term Etot Estimate for variance calc */
+ Word16 *Etot_sq_st_est /* Q2 : Short term Etot^2 Estimate for variance calc */
+
+);
+
+
+void noise_est_pre_fx(
+ const Word16 Etot, /* i : Energy of current frame */
+ const Word16 ini_frame_fx, /* i : Frame number (init) */
+ Word16 *Etot_l, /* i/o: Track energy from below */ /*Q8 */
+ Word16 *Etot_h, /* i/o: Track energy from above */ /*Q8 */
+ Word16 *Etot_l_lp, /* i/o: Smoothed low energy */ /*Q8 */
+ Word16 *Etot_last, /* i/o: Energy of last frame */ /*Q8 */
+ Word16 *Etot_v_h2, /* i/o: Energy variations */ /*Q8*/
+ Word16 *sign_dyn_lp, /* i/o: Smoother signal dynamics */ /*Q8*/
+ Word16 harm_cor_cnt, /* i : correlation counter */
+ Word16 *Etot_lp /* i/o: Smoothed energy */
+);
+
+void Preemph_scaled(
+ Word16 new_speech[], /* i : Speech to scale already on 14 bits*/
+ Word16 *Q_new, /* o : Scaling factor */
+ Word16 *mem_preemph, /* i/o: Preemph memory */
+ Word16 *Q_max, /* i/o: Q_new limitation */
+ const Word16 Preemph_factor, /* i : Preemphasis factor Q15 */
+ const Word16 bits, /* i : Bit to remove from the output to (15-bits)*/
+ const Word16 bit1, /* i : Limit the output scaling to ((15-bits)-bit1) bits */
+ const Word16 L_Q_mem, /* i : Number of old scaling to take into account */
+ const Word16 Lframe, /* i : Frame length */
+ const Word16 last_coder_type, /* i : coder_type */
+ const Word16 Search_scaling /* i : enable the search of a proper scaling factor*/
+);
+Word32 Scale_mem_pre_proc( /* o : Min energy scaled */
+ Word16 ini_frame_fx, /* i : Frame number */
+ Word16 Q_exp, /* i : Diff scaling factor */
+ Word16 *Q_new, /* i/o: Absolute scaling factor */
+ Word16 *old_speech, /* i/o: Speech memory */
+ Word16 *mem_wsp, /* i/o: wsp vector memory */
+ Word32 *enrO, /* i/o: Enr mem */
+ Word32 *bckr, /* i/o: Back ground_fx ener mem */
+ Word32 *ave_enr, /* i/o: Ave_enr mem */
+ Word32 *ave_enr2, /* i/o: Ave_enr2 mem */
+ Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */
+ Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */
+ Word32 *st_Bin_E_old
+);
+void Scale_mem_enc(
+ Word16 Q_exp, /* i : Diff scaling factor */
+ Word16 *old_speech16k, /* i/o: Speech memory */
+ Word16 *old_exc, /* i/o: excitation memory */
+ Word16 *old_bwe_exc, /* i/o: BWE excitation memory */
+ Word16 *mem_w0, /* i/o: target vector memory */
+ Word16 *mem_syn, /* i/o: synthesis memory */
+ Word16 *mem_syn2, /* i/o: synthesis memory */
+ Word16 *mem_deemp_preQ_fx, /*i/o: deemphasis memory for the high rate celp codec */
+ Word16 *last_exc_dct_in,
+ Word16 *old_input_lp
+);
+
+void SetModeIndex(
+ Encoder_State_fx *st,
+ Word32 total_brate,
+ Word16 bwidth,
+ const Word16 shift
+);
+
+void init_encoder_fx(
+ Encoder_State_fx *st_fx /* i/o: Encoder static variables structure */
+);
+
+void destroy_encoder_fx( Encoder_State_fx *st_fx );
+
+void analysisCldfbEncoder_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *timeIn,
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 realBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word16 imagBuffer16[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX],
+ Word32 enerBuffSum[CLDFB_NO_CHANNELS_MAX],
+ Word16 *enerBuffSum_exp,
+ CLDFB_SCALE_FACTOR * scale
+);
+
+void cldfb_save_memory (HANDLE_CLDFB_FILTER_BANK hs); /* i/o: cldfb handle */
+void cldfb_restore_memory (HANDLE_CLDFB_FILTER_BANK hs); /* i/o: cldfb handle */
+void cldfb_reset_memory (HANDLE_CLDFB_FILTER_BANK hs); /* i/o: cldfb handle */
+
+Word16 gp_clip_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 *voicing, /* i : normalized correlations (from OL pitch) */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 coder_type, /* i : type of coder */
+ const Word16 xn[], /* i : target vector */
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 Q_new /* i : scaling factor */
+);
+
+void init_decoder_fx(
+ Decoder_State_fx *st_fx /* o: Decoder static variables structure */
+);
+
+void destroy_decoder(
+ Decoder_State_fx *st_fx /* o: Decoder static variables structure */
+);
+Word16 Enr_1_Az_fx( /* o : impulse response energy Q3 */
+ const Word16 Aq[], /* i : LP filter coefs Qx based on the fact that Aq[0] == 1.0 */
+ const Word16 len /* i : impulse response length Q0 */
+);
+void FEC_scale_syn_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *update_flg, /* o: flag indicating re-synthesis after scaling*/
+ Word16 clas, /* i/o: frame classification */
+ const Word16 last_good, /* i: last good frame classification */
+ Word16 *synth, /* i/o: synthesized speech at Fs = 12k8 Hz */
+ const Word16 *pitch, /* i: pitch values for each subframe */
+ Word32 L_enr_old, /* i: energy at the end of previous frame */
+ Word32 L_enr_q, /* i: transmitted energy for current frame */
+ const Word16 coder_type, /* i: coder type */
+ const Word16 LSF_Q_prediction, /* i : LSF prediction mode */
+ Word16 *scaling_flag, /* i/o: flag to indicate energy control of syn */
+ Word32 *lp_ener_FEC_av, /* i/o: averaged voiced signal energy */
+ Word32 *lp_ener_FEC_max, /* i/o: averaged voiced signal energy */
+ const Word16 bfi, /* i: current frame BFI */
+ const Word32 total_brate, /* i: total bitrate */
+ const Word16 prev_bfi, /* i: previous frame BFI */
+ const Word32 last_core_brate, /* i: previous frame core bitrate */
+ Word16 *exc, /* i/o: excitation signal without enhancement */
+ Word16 *exc2, /* i/o: excitation signal with enhancement */
+ Word16 Aq[], /* i/o: LP filter coefs (can be modified if BR) */
+ Word16 *old_enr_LP, /* i/o: LP filter E of last good voiced frame */
+ const Word16 *mem_tmp, /* i: temp. initial synthesis filter states */
+ Word16 *mem_syn, /* o: initial synthesis filter states */
+ Word16 Q_exc,
+ Word16 Q_syn
+ , Word16 avoid_lpc_burst_on_recovery /* i : if true the excitation energy is limited if LP has big gain */
+ , Word16 force_scaling /* i: force scaling */
+);
+
+void improv_amr_wb_gs_fx(
+ const Word16 clas, /* i : signal frame class */
+ const Word16 coder_type, /* i : coder type */
+ const Word32 core_brate, /* i : bitrate allocated to the core */
+ Word16 *seed_tcx, /* i/o: Seed used for noise generation */
+ Word16 *old_Aq_fx, /* i/o: old LPC filter coefficient */
+ Word16 *mem_syn2_fx, /* i/o: synthesis memory */
+ const Word16 lt_voice_fac_fx, /* i/o: long term voice factor Q15 */
+ const Word16 locattack, /* i : Flag for a detected attack */
+ Word16 *Aq_fx, /* i/o: Decoded LP filter coefficient */
+ Word16 *exc2_fx, /* i/o: Decoded complete excitation */
+ const Word16 Q_exc2, /* i : Exponent of Exc2 */
+ Word16 *mem_tmp_fx, /* i/o: synthesis temporary memory */
+ Word16 *syn_fx, /* o: Decoded synthesis to be updated */
+ const Word16 Q_syn, /* i : Synthesis scaling Q0 */
+ const Word16 *pitch_buf_fx, /* i : Decoded pitch buffer */
+ const Word16 Last_ener_fx, /* i : Last energy (Q8) */
+ const Word16 rate_switching_reset, /* i : rate switching reset flag */
+ const Word16 last_coder_type_fx /* i : Last coder_type */
+);
+
+void FEC_pitch_estim_fx(
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 last_core, /* i : last core */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 clas, /* i : current frame classification */
+ const Word16 last_good, /* i : last good clas information */
+ const Word16 pitch_buf[], /* i : Floating pitch for each subframe */
+ const Word32 old_pitch_buf[], /* i : buffer of old subframe pitch values 15Q16 */
+ Word16 *bfi_pitch, /* i/o: update of the estimated pitch for FEC */
+ Word16 *bfi_pitch_frame, /* o : frame length when pitch was updated */
+ Word16 *upd_cnt, /* i/o: update counter */
+ const Word16 coder_type /* i : coder_type */
+);
+
+Word16 div_s_ss( /* o: result of division (Word16 Q0) */
+ const Word16 n, /* i: numerator (Word16 Q0 */
+ const Word16 d /* i: denominator (Word16 Q0) */
+);
+
+Word16 detect_transient_fx(
+ const Word16 *in_fx, /*Q_new */
+ /*Encoder_State *st, */
+ const Word16 L,
+ const Word16 coder_type, /* i : coder type */
+ Word16 Q_new,
+ Encoder_State_fx *st_fx
+);
+
+Word16 detect_transient_fx32( /* o : transient flag */
+ const Word32* in_fx, /* i : input signal */
+ Encoder_State_fx *st_fx, /* i/o: Encoder state structure */
+ const Word16 L, /* i : length (32 or 48kHz) */
+ const Word16 coder_type /* i : coder type */
+);
+
+void ar_encoder_start_fx( PARCODEC_FX arInst, PBITSTREAM_FX bsInst, Word32 max_bits );
+void ar_encoder_done_fx( PARCODEC_FX arInst );
+void ar_decoder_start_fx( PARCODEC_FX arInst, PBITSTREAM_FX bsInst );
+void ar_decoder_done_fx( PARCODEC_FX arInst );
+
+void srt_vec_ind_fx (const Word32 *linear, Word32 *srt, Word16 *I, Word16 length);
+Word32 ar_div(Word32 num, Word32 denum);
+
+Word16 GetScale_fx( Word16 blen, Word32 bits_fx, Word32 *surplus_fx);
+Word32 encode_position_ari_fx(PARCODEC_FX parenc, Word16* quants, Word16 size, Word32* est_bits_frame_fx);
+Word32 encode_magnitude_usq_fx(ARCODEC_FX* parenc, Word16* magn, Word16 size, Word16 npulses, Word16 nzpos, Word32* est_frame_bits_fx);
+Word32 encode_magnitude_tcq_fx(ARCODEC_FX* parenc, Word16* magn, Word16 size, Word16 npulses, Word16 nzpos, Word32* savedstates, Word32* est_frame_bits_fx);
+Word32 GetISCScale_fx( Word32 *quants_fx, Word16 size, Word32 bits_fx, Word16 *magn_fx, Word32 *qscale_fx, Word32 *surplus_fx, Word16 *pulses, Word32* savedstates, Word32 noTCQ, Word16 *nzpout
+ , Word16 *bcount, Word32 *abuffer, Word16 *mbuffer, Word32 *sbuffer );
+Word32 encode_signs_fx(ARCODEC_FX* parenc, Word16* magn, Word16 size, Word16 npos, Word32* est_frame_bits_fx);
+
+void decode_position_ari_fx(PARCODEC_FX pardec, Word16 size, Word16 npulses, Word16* nz, Word16* position);
+void decode_magnitude_usq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16* positions, Word16* out);
+void decode_mangitude_tcq_fx(ARCODEC_FX* pardec, Word16 size, Word16 npulses, Word16 nzpos, Word16* positions, Word16* out, Word32* surplus_fx);
+void decode_signs_fx(ARCODEC_FX* pardec, Word16 size, Word16* out);
+
+void tcq_core_LR_enc_fx(
+ Encoder_State_fx* st_fx,
+ Word16 inp_vector_fx[],
+ const Word32 coefs_norm_fx[],
+ Word32 coefs_quant_fx[],
+ const Word16 bit_budget, /* number of bits */
+ const Word16 nb_sfm,
+ const Word16 *sfm_start,
+ const Word16 *sfm_end,
+ const Word16 *sfmsize,
+ Word32 *R_fx,
+ Word16 *npulses,
+ Word16 *k_sort,
+ const Word16 *p2a_flags,
+ const Word16 p2a_bands,
+ const Word16 *last_bitalloc,
+ const Word16 input_frame,
+ const Word16 adjustFlag,
+ const Word16 is_transient
+);
+
+void tcq_core_LR_dec_fx(
+ Decoder_State_fx *st_fx,
+ Word16 *inp_vector_fx,
+ const Word16 bit_budget,
+ const Word16 bands,
+ const Word16 *band_start,
+ const Word16 *band_width,
+ Word32 *Rk_fx,
+ Word16 *npulses,
+ Word16 *k_sort,
+ const Word16 *p2a_flags,
+ const Word16 p2a_bands,
+ const Word16 *last_bitalloc,
+ const Word16 input_frame,
+ const Word16 adjustFlag,
+ const Word16 *is_transient
+);
+
+void TCQLSB_fx(
+ Word16 bcount,
+ Word32 *abuffer_fx,
+ Word16 *mbuffer_fx,
+ Word32 *sbuffer_fx,
+ Word16 *dpath
+);
+
+void TCQLSBdec_fx(
+ Word16 *dpath,
+ Word16 *mbuffer,
+ Word16 bcount
+);
+
+void RestoreTCQ_fx(
+ Word16 * magn,
+ Word16 size,
+ Word16 *bcount,
+ Word16 *mbuffer
+);
+
+void RestoreTCQdec_fx(
+ Word16 * magn,
+ Word16 size,
+ Word16 *bcount,
+ Word16 *mbuffer
+);
+
+void InitLSBTCQ_fx(
+ Word16 *bcount
+);
+
+void SaveTCQdata_fx(
+ PARCODEC_FX arInst,
+ Word16 *dpath,
+ Word16 bcount
+);
+
+void LoadTCQdata_fx(
+ PARCODEC_FX arInst,
+ Word16 *dpath,
+ Word16 bcount
+);
+
+void bit_allocation_second_fx(
+ Word32 *Rk,
+ Word32 *Rk_sort,
+ Word16 BANDS,
+ const Word16 *band_width,
+ Word16 *k_sort,
+ Word16 *k_num,
+ const Word16 *p2a_flags,
+ const Word16 p2a_bands,
+ const Word16 *last_bitalloc,
+ const Word16 input_frame
+);
+
+void window_ola_fx(
+ Word32 *ImdctOut,
+ Word16 *auOut,
+ Word16 *Q_sig,
+ Word16 *OldauOut,
+ Word16 *Q_old,
+ const Word16 L,
+ const Word16 right_mode,
+ const Word16 left_mode,
+ const Word16 old_bfi,
+ const Word16 oldHqVoicing,
+ Word16 *oldgapsynth
+);
+
+void tcx_get_windows_mode1(
+ Word16 left_mode, /* i: overlap mode of left window half */
+ Word16 right_mode, /* i: overlap mode of right window half */
+ Word16 *left_win, /* o: left overlap window */
+ Word16 *right_win, /* o: right overlap window */
+ Word16 *left_win_int, /* o: left overlap window */
+ Word16 *right_win_int, /* o: right overlap window */
+ Word16 const L
+);
+
+void sinq_fx(
+ const Word16 tmp, /* i : sinus factor cos(tmp*i+phi) Q15*/
+ const Word16 phi, /* i : sinus phase cos(tmp*i+phi) Q15*/
+ const Word16 N, /* i : size of output */
+ Word16 x[] /* o : output vector Q15*/
+);
+
+Word16 FEC_phase_matching_fx(
+ Decoder_State_fx *st_fx, /* i : Decoder State */
+ Word32 *ImdctOut_fx, /* i : input */
+ Word16 *auOut_fx, /* o : output audio */
+ Word16 *OldauOut_fx,
+ Word16 OldauOut_pha_fx[2][N_LEAD_NB]
+);
+
+void FEC_phase_matching_nextgood_fx(
+ const Word32 *ImdctOut_fx, /* i : input */
+ Word16 *auOut_fx, /* o : output audio */
+ Word16 *OldauOut_fx, /* i/o: audio from previous frame */
+ Word16 OldauOut_pha_fx[2][N_LEAD_NB],
+ Word16 mean_en_high_fx /* Q5 */
+);
+
+void FEC_phase_matching_burst_fx(
+ const Word32 *ImdctOut_fx, /* i : input */
+ Word16 *auOut_fx, /* o : output audio */
+ Word16 *OldauOut_fx, /* i/o: audio from previous frame */
+ Word16 OldauOut_pha_fx[2][N_LEAD_NB],
+ Word16 *prev_oldauOut_fx /* i : OldauOut from previous frame */
+);
+
+void Repetition_smoothing_nextgood_fx(
+ const Word32 *ImdctOut_fx, /* i : input */
+ Word16 *auOut_fx, /* o : output audio */
+ Word32 *OldImdctOut_fx, /* i : input */
+ Word16 *OldauOut_fx, /* i/o: audio from previous frame */
+ Word16 cur_data_use_flag, /* i : current imdct data use flag */
+ Word16 overlap_time
+);
+
+Word16 Repetition_smoothing_fx(
+ const Word32 *ImdctOut_fx, /* i : input */
+ Word16 *auOut_fx, /* o : output audio */
+ Word32 *OldImdctOut_fx, /* i/o: audio from previous frame */
+ Word16 *OldauOut_fx, /* i/o: audio from previous frame */
+ const Word16 L, /* i : length */
+ Word16 *prev_oldauOut_fx, /* i/o: IMDCT output from previous old frame */
+ Word16 overlap_time /* i : overlapping time */
+);
+
+void time_domain_FEC_HQ_fx(
+ Decoder_State_fx *st_fx, /* i : Decoder State */
+ Word32 *wtda_audio_fx, /* i : input */
+ Word16 *out_fx, /* o : output audio */
+ Word16 mean_en_high_fx, /* i : transient flag */
+ const Word16 output_frame,
+ Word16 *Q_synth
+);
+
+void common_overlapping_fx(
+ Word16 *auOut_fx, /* i : Input */
+ Word16 *ImdctOutWin_fx, /* o : Output */
+ Word16 *OldauOut_fx, /* i : Window */
+ Word16 end1, /* i : Decay */
+ Word16 offset1,
+ Word16 start2,
+ Word16 end2,
+ Word16 offset_i2,
+ Word16 offset2
+);
+
+void Smoothing_vector_scaledown_NB_fx(
+ const Word16 OldauOutnoWin_fx[], /* i : Input vector 1 */
+ const Word16 ImdctOutWin_fx[], /* i : Input vector 2 */
+ const Word16 SmoothingWin_fx[], /* i : Smoothing window */
+ Word16 auOut_fx[], /* o : Output vector that contains vector 1 .* vector 2*/
+ const Word16 ol_size /* i : Overlap size */
+);
+
+void Scaledown_fx(
+ Word16 x[], /* i : Input vector */
+ Word16 y[], /* o : Output vector that contains vector 1 .* vector 2*/
+ Word16 scale_v,
+ const Word16 N /* i : Overlap size */
+);
+
+void Smoothing_vector_NB_fx(
+ const Word16 OldauOutnoWin_fx[], /* i : Input vector 1 */
+ const Word16 ImdctOutWin_fx[], /* i : Input vector 2 */
+ const Word16 SmoothingWin_fx[], /* i : Smoothing window */
+ Word16 auOut_fx[], /* o : Output vector that contains vector 1 .* vector 2 */
+ const Word16 ol_size /* i : Overlap size */
+);
+
+void Windowing_1st_NB_fx(
+ Word16 *ImdctOutWin_fx, /* o : Output */
+ const Word32 *ImdctOut_fx, /* i : Input */
+ const Word16 *win_fx, /* i : Window */
+ const Word16 *smoothingWin_fx, /* i : Smoothing Window */
+ Word16 smoothing_flag /* i : 1=Smoothing window, 0=Original window */
+);
+
+void Windowing_2nd_NB_fx(
+ Word16 *ImdctOutWin_fx, /* o : Output */
+ const Word32 *ImdctOut_fx, /* i : Input */
+ const Word16 *win_fx /* i : Window */
+);
+
+void Next_good_after_burst_erasures_fx(
+ const Word32 *ImdctOut_fx,
+ Word16 *auOut_fx,
+ Word16 *OldauOut_fx,
+ const Word16 ol_size
+);
+
+void subband_gain_bits_fx(
+ const Word16 *Rk, /* i : bit allocation per band Q3 */
+ const Word16 N, /* i : number of bands */
+ Word16 *bits, /* o : gain bits per band */
+ const Word16 *sfmsize /* i : Size of bands */
+);
+
+Word16 assign_gain_bits_fx( /* o : Number of assigned gain bits */
+ const Word16 core, /* i : HQ core */
+ const Word16 BANDS, /* i : Number of bands */
+ const Word16 *band_width, /* i : Sub band bandwidth */
+ Word16 *Rk, /* i/o: Bit allocation/Adjusted bit alloc. Q3 */
+ Word16 *gain_bits_array, /* o : Assigned gain bits */
+ Word16 *Rcalc /* o : Bit budget for shape quantizer Q3 */
+);
+
+void apply_gain_fx(
+ const Word16 *ord, /* i : Indices for energy order */
+ const Word16 *band_start, /* i : Sub band start indices */
+ const Word16 *band_end, /* i : Sub band end indices */
+ const Word16 num_sfm, /* i : Number of bands */
+ const Word16 *gains, /* i : Band gain vector Q12 */
+ Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Q12 */
+);
+
+void fine_gain_pred_fx(
+ const Word16 *sfm_start, /* i : Sub band start indices */
+ const Word16 *sfm_end, /* i : Sub band end indices */
+ const Word16 *sfm_size, /* i : Sub band bandwidths */
+ const Word16 *i_sort, /* i : Energy sorting indices */
+ const Word16 *K, /* i : Number of pulses per band */
+ const Word16 *maxpulse, /* i : Maximum pulse per band */
+ const Word16 *R, /* i : Bits per sub band Q3 */
+ const Word16 num_sfm, /* i : Number of sub bands */
+ Word16 *xq, /* i/o: Quantized vector /quantized vector with finegain adj Q15*/
+ Word16 *y, /* i/o: Quantized vector (int) */
+ Word16 *fg_pred, /* o : Predicted fine gains Q12 */
+ const Word16 core /* i : Core */
+);
+
+void fine_gain_quant_fx(
+ Encoder_State_fx *st_fx,
+ const Word16 *ord, /* i : Indices for energy order */
+ const Word16 num_sfm, /* i : Number of bands */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */
+ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */
+ const Word16 *gopt /* i : Optimal gains Q12 */
+);
+
+void fine_gain_dec_fx
+(
+ Decoder_State_fx *st,
+ const Word16 *ord, /* i : Indices for energy order */
+ const Word16 num_sfm, /* i : Number of bands */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */
+ Word16 *fg_pred /* i/o: Predicted gains / Corrected gains */
+);
+
+void get_max_pulses_fx(
+ const Word16 *band_start, /* i : Sub band start indices */
+ const Word16 *band_end, /* i : Sub band end indices */
+ const Word16 *k_sort, /* i : Indices for sorting by energy */
+ const Word16 *npulses, /* i : Pulses per sub band */
+ const Word16 BANDS, /* i : Number of bands */
+ Word16 *inp_vector, /* i/o: Encoded shape vectors (int)*/
+ Word16 *maxpulse /* o : Maximum pulse height per band */
+);
+
+Word16 pvq_core_enc_fx(
+ Encoder_State_fx *st_fx,
+ Word16 coefs_norm[],
+ Word16 coefs_quant[],
+ Word16 *Q_coefs,
+ Word16 bits_tot, /* total number of bits */
+ Word16 nb_sfm,
+ const Word16 *sfm_start,
+ const Word16 *sfm_end,
+ const Word16 *sfmsize,
+ Word16 *R, /* Q3 */
+ Word16 *Rs,
+ Word16 *npulses,
+ Word16 *maxpulse,
+ const Word16 core
+);
+
+void pvq_encode_frame_fx(
+ Encoder_State_fx *st_fx,
+ const Word16 *coefs_norm, /* i : normalized coefficients to encode */
+ Word16 Q_coefs,
+ Word16 *coefs_quant, /* o : quantized coefficients */
+ Word16 *gopt, /* o : optimal shape gains */
+ Word16 *npulses, /* o : number of pulses per band */
+ Word16 *pulse_vector, /* o : non-normalized pulse shapes */
+ const Word16 *sfm_start, /* i : indices of first coefficients in the bands */
+ const Word16 *sfm_end, /* i : indices of last coefficients in the bands */
+ const Word16 *sfmsize, /* i : band sizes */
+ const Word16 nb_sfm, /* i : total number of bands */
+ const Word16 *R, /* i : bitallocation per band */
+ const Word16 pvq_bits, /* i : number of bits avaiable */
+ const Word16 core /* i : core */
+);
+
+
+void encode_energies_fx(
+ Encoder_State_fx *st_fx,
+ const Word16 *coefs,
+ const Word16 Q_coefs,
+ Word16 Np,
+ Word16 *dim_part,
+ Word32 *E_part, /* 32-bit Q15 */
+ Word16 *bits_part,
+ Word16 *g_part, /* Q15 */
+ Word16 qband,
+ Word16 *bits_left,
+ Word32 enr, /* 32-bit Q15 */
+ Word16 dim,
+ const Word16 strict_bits
+);
+
+Word16 pvq_core_dec_fx(
+ Decoder_State_fx *st_fx,
+ const Word16 *sfm_start,
+ const Word16 *sfm_end,
+ const Word16 *sfmsize,
+ Word16 coefs_quant[], /* o : output MDCT */
+ Word16 *Q_coefs,
+ Word16 bits_tot,
+ Word16 nb_sfm,
+ Word16 *R,
+ Word16 *Rs,
+ Word16 *npulses,
+ Word16 *maxpulse,
+ const Word16 core
+);
+
+void pvq_decode_frame_fx(
+ Decoder_State_fx *st_fx,
+ Word16 *coefs_quant, /* o : quantized coefficients */
+ Word16 *npulses, /* o : number of pulses per band */
+ Word16 *pulse_vector, /* o : non-normalized pulse shapes */
+ const Word16 *sfm_start, /* i : indices of first coefficients in the bands */
+ const Word16 *sfm_end, /* i : indices of last coefficients in the bands */
+ const Word16 *sfmsize, /* i : band sizes */
+ const Word16 nb_sfm, /* i : total number of bands */
+ const Word16 *R, /* i : bitallocation per band */
+ const Word16 pvq_bits, /* i : number of bits avaiable */
+ const Word16 core /* i : core */
+);
+
+void decode_energies_fx(
+ Decoder_State_fx *st_fx,
+ Word16 Np,
+ Word16 *dim_part,
+ Word16 *bits_part,
+ Word16 *g_part, /* Q15 */
+ Word16 qband,
+ Word16 *bits_left,
+ Word16 dim,
+ const Word16 strict_bits
+);
+
+Word16 atan2_fx(
+ const Word32,
+ const Word32
+);
+
+void srt_vec_ind16_fx (
+ const Word16 *linear, /* linear input */
+ Word16 *srt, /* sorted output*/
+ Word16 *I, /* index for sorted output */
+ Word16 length
+);
+
+
+PvqEntry_fx mpvq_encode_vec_fx( /* o : leading_sign_index, index, size, k_val */
+ const Word16* vec_in, /* i : signed pulse train */
+ Word16 dim_in, /* i : dimension */
+ Word16 k_val_local /* i : nb unit pulses */
+);
+
+PvqEntry_fx get_size_mpvq_calc_offset_fx( /* o : size, dim, k_val */
+ Word16 dim_in, /* i : dimension */
+ Word16 k_val_in, /* i : nb unit pulses */
+ UWord32* h_mem /* o : offsets */
+);
+
+void mpvq_decode_vec_fx( /* o : void */
+ const PvqEntry_fx* entry, /* i : sign_ind, index, dim, k_val */
+ UWord32* h_mem, /* i : A/U offsets */
+ Word16* vec_out /* o : pulse train */
+);
+
+void rc_enc_init_fx(
+ Encoder_State_fx *st_fx, /* i/o: Encoder state */
+ Word16 tot_bits /* i : Total bit budget */
+);
+
+void rc_encode_fx(
+ Encoder_State_fx *st_fx, /* i/o: Encoder state */
+ UWord32 cum_freq, /* i : Cumulative frequency up to symbol */
+ UWord32 sym_freq, /* i : Symbol probability */
+ UWord32 tot /* i : Total cumulative frequency */
+);
+
+void rc_enc_uniform_fx(
+ Encoder_State_fx *st_fx, /* i/o: Encoder state */
+ UWord32 value, /* i : Value to encode */
+ UWord32 tot /* i : Maximum value */
+);
+
+void rc_enc_bits_fx(
+ Encoder_State_fx *st_fx, /* i/o: Encoder state */
+ UWord32 value, /* i : Value to encode */
+ Word16 bits /* i : Number of bits used */
+);
+
+void rc_enc_finish_fx(
+ Encoder_State_fx *st_fx /* i/o: Encoder state */
+);
+
+Word16 rc_get_bits2_fx( /* o: Number of bits needed */
+ const Word16 N, /* i: Number of bits currently used */
+ const UWord32 range /* i: Range of range coder */
+);
+
+
+void rangeCoderFinalizationFBits_fx(
+ Word16 Brc,
+ UWord32 INTrc,
+ Word16 *FBits
+);
+
+void conservativeL1Norm_fx(
+ Word16 L,
+ Word16 Qvec,
+ Word16 Fcons,
+ Word16 Qavail,
+ Word16 Qreserv,
+ Word16 Dspec,
+ Word16 *Dvec,
+ Word16 *Qspare,
+ Word16 *Qreservplus,
+ Word16 *Dspecplus
+);
+
+void bandBitsAdjustment_fx(
+ Word16 Brc,
+ UWord32 INTrc,
+ Word16 Bavail,
+ Word16 Nbands,
+ Word16 D,
+ Word16 L,
+ Word16 Bband,
+ Word16 Breserv,
+ Word16 *Bband_adj,
+ Word16 *Brem,
+ Word16 *Breservplus
+);
+
+
+UWord32 rc_decode_fx( /* o : Decoded cumulative frequency */
+ Decoder_State_fx *st_fx, /* i/o: Decoder State */
+ UWord32 tot /* i : Total cumulative frequency */
+);
+
+void rc_dec_update_fx(
+ Decoder_State_fx *st_fx, /* i/o: Decoder State */
+ UWord32 cum_freq, /* i : Cumulative frequency */
+ UWord32 sym_freq /* i : Symbol frequency */
+);
+
+UWord32 rc_dec_uniform_fx( /* i : Decoded value */
+ Decoder_State_fx *st_fx, /* i/o: Decoder State */
+ UWord32 tot /* i : Maximum value */
+);
+
+void rc_dec_init_fx(
+ Decoder_State_fx *st_fx, /* i/o: Decoder State */
+ Word16 tot_bits /* i : Total bit budget */
+);
+
+Word32 rc_dec_bits_fx( /* i : Decoded value */
+ Decoder_State_fx *st_fx, /* i/o: Decoder State */
+ Word16 bits /* i : Number of bits */
+);
+
+void rc_dec_finish_fx(
+ Decoder_State_fx *st_fx
+);
+
+UWord32 UL_inverse(
+ const UWord32 UL_val,
+ Word16 *exp
+);
+
+UWord32 UL_div(
+ const UWord32 UL_num,
+ const UWord32 UL_den
+);
+
+void hq_core_enc_fx(
+ Encoder_State_fx *st_fx,
+ const Word16 *audio, /* i : input audio signal Q0 */
+ const Word16 input_frame_orig,/* i : frame length */
+ const Word16 hq_core_type, /* i : HQ core type */
+ const Word16 Voicing_flag
+);
+
+void normalizecoefs_fx(
+ Word32 *coefs, /* i : Input vector (Q12) */
+ const Word16 *ynrm, /* i : quantization indices for norms */
+ const Word16 num_bands, /* i : Number of bands */
+ const Word16 *band_start, /* i : Start of bands */
+ const Word16 *band_end, /* i : End of bands */
+ Word16 *coefs_norm /* o : Normalized output vector (Q12) */
+);
+
+void calc_norm_fx(
+ const Word32 *L_x, /* i : Input vector. Qx */
+ const Word16 qx, /* i : Q value of input */
+ Word16 *norm, /* o : Quantization indices for norms Q0 */
+ Word16 *normlg, /* o : Quantized norms in log2 Q0 */
+ const Word16 start_band, /* i : Indice of band to start coding Q0 */
+ const Word16 num_bands, /* i : Number of bands Q0 */
+ const Word16 *band_len, /* i : Length of bands Q0 */
+ const Word16 *band_start /* i : Start of bands Q0 */
+);
+
+void diff_envelope_coding_fx(
+ const Word16 is_transient, /* i : transient indicator Q0 */
+ const Word16 num_env_bands, /* i : number of envelope bands to code Q0 */
+ const Word16 start_norm, /* i : start of envelope coding Q0 */
+ Word16 *ynrm, /* i/o: quantization indices for norms Q0 */
+ Word16 *normqlg2, /* i/o: quantized norms Q0 */
+ Word16 *difidx /* o : differential code Q0 */
+);
+
+void reordernorm_fx(
+ const Word16 *ynrm, /* i : quantization indices for norms Q0 */
+ const Word16 *normqlg2, /* i : quantized norms Q0 */
+ Word16 *idxbuf, /* o : reordered quantization indices Q0 */
+ Word16 *normbuf, /* o : reordered quantized norms Q0 */
+ const Word16 nb_sfm /* i : number of bands Q0 */
+);
+
+void hq_hr_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure fx */
+ Word32 *t_audio, /* i/o: transform-domain coefficients Q12? */
+ const Word16 length, /* i : length of spectrum Q0 */
+ Word16 *num_bits, /* i : number of available bits Q0 */
+ const Word16 is_transient /* i : transient flag Q0 */
+);
+
+Word16 hq_classifier_enc_fx( /* o : Consumed bits Q0 */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 length, /* i : Frame length Q0 */
+ const Word32 *coefs, /* i : Spectral coefficients Q12 */
+ const Word16 is_transient, /* i : Transient flag Q0 */
+ Word16 *Npeaks, /* o : Number of identified peaks Q0 */
+ Word16 *peaks, /* o : Peak indices Q0 */
+ Word32 *pe_gains, /* o : Peak gains Q12 */
+ Word32 *nf_gains, /* o : Noise-fill gains Q12 */
+ Word16 *hqswb_clas /* o : HQ class Q0 */
+);
+
+void hvq_classifier_fx(
+ const Word32 *input, /* i : input signal Q12 */
+ Word16 *prev_Npeaks, /* i/o: Peak number memory Q0 */
+ Word16 *prev_peaks, /* i/o: Peak indices memory Q0 */
+ Word16 *hqswb_clas, /* i/o: HQ class Q0 */
+ Word16 *Npeaks, /* o : Number of peaks Q0 */
+ Word16 *peaks, /* o : Peak indices Q0 */
+ const Word32 L_core_brate, /* i : Core bit-rate Q0 */
+ const Word16 last_core, /* i : Last core used Q0 */
+ Word32 *L_nf_gains, /* o : Noisefloor gains Q12 */
+ Word16 *hvq_hangover, /* i/o: Mode-switch hangover Q0 */
+ Word32 *L_pe_gains /* o : peak gains Q12 */
+);
+
+void limit_band_noise_level_calc_fx(
+ const Word16 *wnorm, /* i : reordered norm of sub-vectors */
+ Word16 *limit, /* o : highest band of bit allocation */
+ const Word32 core_brate, /* i : bit rate */
+ Word16 *noise_level /* o : noise level Q15 */
+);
+
+Word16 BitAllocWB_fx( /* o : t Q0*/
+ Word16 *y, /* i : norm of sub-vectors Q0*/
+ Word16 B, /* i : number of available bits Q0*/
+ Word16 N, /* i : number of sub-vectors Q0*/
+ Word16 *R, /* o : bit-allocation indicator Q0*/
+ Word16 *Rsubband_fx /* o : sub-band bit-allocation vector Q3*/
+);
+
+void hq_wb_nf_bwe_fx(
+ const Word16 *coeff_fx, /* i : coded/noisefilled normalized spectrum */
+ const Word16 is_transient,
+ const Word16 prev_bfi, /* i : previous bad frame indicator */
+ const Word32 *L_normq_v,
+ const Word16 num_sfm, /* i : Number of subbands */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ const Word16 *sfmsize, /* i : Subband band width */
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 *R, /* i : bit allocation */
+ const Word16 prev_is_transient, /* i : previous transient flag */
+ Word32 *prev_normq_fx, /* i/o: previous norms */
+ Word32 *prev_env_fx, /* i/o: previous noise envelopes */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input */
+ Word32 *prev_coeff_out_fx, /* i/o: decoded spectrum in previous frame */
+ Word16 *prev_R, /* i/o: bit allocation info. in previous frame */
+ Word32 *L_coeff_out, /* o : coded/noisefilled spectrum */
+ Word16 *prev_env_Q
+);
+
+void harm_bwe_fine_fx(
+ const Word16 *R, /* i : bit allocation */
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 high_sfm, /* i : higher transition band to BWE */
+ const Word16 num_sfm, /* i : total number of bands */
+ const Word16 *norm, /* i : quantization indices for norms */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length */
+ Word16 *coeff, /* i/o: coded/noisefilled normalized spectrum */
+ Word32 *coeff_out, /* o : coded/noisefilled spectrum */
+ Word16 *coeff_fine /* o : BWE fine structure */
+);
+
+void harm_bwe_fx(
+ const Word16 *coeff_fine, /* i : fine structure for BWE */
+ const Word16 *coeff, /* i : coded/noisefilled normalized spectrum */
+ const Word16 num_sfm, /* i : Number of subbands */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 *R, /* i : bit allocation */
+ const Word16 prev_hq_mode, /* i : previous hq mode */
+ Word16 *norm, /* i/o: quantization indices for norms */
+ Word16 *noise_level, /* i/o: noise levels for harmonic modes */
+ Word16 *prev_noise_level, /* i/o: noise factor in previous frame */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input */
+ Word32 *coeff_out /* o : coded/noisefilled spectrum */
+);
+
+void hq_generic_encoding_fx(
+ const Word32 *coefs_fx, /* i : MDCT coefficients of weighted original */
+ Word16 *hq_generic_fenv_fx, /* i/o: energy of SWB envelope */
+ const Word16 hq_generic_offset, /* i : frequency offset for extracting energy */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 *hq_generic_exc_clas /* o : bwe excitation class */
+);
+
+void hq_generic_fine_fx(
+ Word16 *coeff, /* i : coded/noisefilled normalized spectrum */
+ const Word16 last_sfm, /* i : Last coded band */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input */
+ Word16 *coeff_out1 /* o : HQ Generic input */
+);
+
+void hq_bwe_fx(
+ const Word16 HQ_mode, /* i : HQ mode */
+ Word32 *coeff_out1, /* i/o: BWE input & temporary buffer */
+ const Word16 *hq_generic_fenv, /* i : SWB frequency envelopes */
+ Word32 *coeff_out, /* o : SWB signal in MDCT domain */
+ const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic bwe*/
+ Word16 *prev_L_swb_norm, /*i/o : last normalize length */
+ const Word16 hq_generic_exc_clas,/* i : bwe excitation class */
+ const Word16 *sfm_end, /* i : End of bands */
+ const Word16 num_sfm,
+ const Word16 num_env_bands,
+ const Word16 *R
+);
+
+void hq_generic_decoding_fx(
+ const Word16 HQ_mode, /* i : HQ mode */
+ Word32 *coeff_out1_fx, /* i/o: BWE input & temporary buffer */
+ const Word16 *hq_generic_fenv_fx, /* i : SWB frequency envelopes */
+ Word32 *coeff_out_fx, /* o : SWB signal in MDCT domain */
+ const Word16 hq_generic_offset, /* i : frequency offset for representing hq generic*/
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length */
+ const Word16 hq_generic_exc_clas, /* i : bwe excitation class */
+ const Word16 *R
+);
+
+
+void map_hq_generic_fenv_norm_fx(
+ const Word16 hqswb_clas,
+ const Word16 *hq_generic_fenv, /* Q1, frequency-domain BWE envelope */
+ Word16 *ynrm,
+ Word16 *normqlg2,
+ const Word16 num_env_bands,
+ const Word16 nb_sfm,
+ const Word16 hq_generic_offset
+);
+
+Word16 get_nor_delta_hf_fx(
+ Decoder_State_fx *st,
+ Word16 *ynrm,
+ Word16 *Rsubband, /* Q3 */
+ const Word16 num_env_bands,
+ const Word16 nb_sfm,
+ const Word16 core_sfm
+);
+
+Word16 calc_nor_delta_hf_fx(
+ Encoder_State_fx *st,
+ const Word32 *t_audio,
+ Word16 *ynrm,
+ Word16 *Rsubband,
+ const Word16 num_env_bands,
+ const Word16 nb_sfm,
+ const Word16 *sfmsize,
+ const Word16 *sfm_start,
+ const Word16 core_sfm
+);
+
+void HQ_FEC_processing_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word32 *t_audio_q_fx, /* o : MDCT coeffs. (for synthesis) Q12 */
+ Word16 is_transient, /* i : Old flag for transient */
+ Word32 ynrm_values_fx[][MAX_PGF], /* i : Old average Norm values for each group of bands Q12 */
+ Word32 r_p_values_fx[][MAX_ROW], /* i : Computed y-intercept and slope by Regression Q5 */
+ Word16 num_Sb, /* i : Number of sub-band group */
+ Word16 nb_sfm, /* i : Number of sub-band */
+ Word16 *Num_bands_p, /* i : Number of coeffs. for each sub-band */
+ Word16 output_frame, /* i : Frame size */
+ const Word16 *sfm_start, /* i : Start of bands */
+ const Word16 *sfm_end /* i : End of bands */
+);
+
+void HQ_FEC_Mem_update_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word32 *t_audio_q_fx, /*Q12*/
+ Word32 *normq_fx, /*Q14*/
+ Word16 *ynrm,
+ Word16 *Num_bands_p,
+ Word16 is_transient,
+ Word16 hqswb_clas,
+ Word16 c_switching_flag,
+ Word16 nb_sfm,
+ Word16 num_Sb,
+ Word16 *mean_en_high_fx, /*Q5*/
+ Word16 hq_core_type, /* i : normal or low-rate MDCT(HQ) core */
+ Word16 output_frame
+);
+
+Word16 BitAllocF_fx (
+ Word16 *y, /* i : norm of sub-vectors :Q0 */
+ Word32 bit_rate, /* i : bitrate :Q0 */
+ Word16 B, /* i : number of available bits :Q0 */
+ Word16 N, /* i : number of sub-vectors :Q0 */
+ Word16 *R, /* o : bit-allocation indicator :Q0 */
+ Word16 *Rsubband_fx, /* o : sub-band bit-allocation vector :Q3 */
+ const Word16 hqswb_clas, /* i : hq swb class */
+ const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
+);
+
+void hq_bit_allocation_fx(
+ const Word32 core_brate, /* i : Core bit-rate */
+ const Word16 length, /* i : Frame length */
+ const Word16 hqswb_clas, /* i : HQ class */
+ Word16 *num_bits, /* i/o: Remaining bit budget */
+ const Word16 *normqlg2, /* i : Quantized norms */
+ const Word16 nb_sfm, /* i : Number sub bands to be encoded */
+ const Word16 *sfmsize, /* i : Sub band bandwidths */
+ Word16 *noise_level, /* o : HVQ noise level */
+ Word16 *R, /* o : Bit allocation per sub band */
+ Word16 *Rsubband, /* o : Fractional bit allocation */
+ Word16 *sum, /* o : Sum of allocated shape bits */
+ Word16 *core_sfm, /* o : Last coded band in core */
+ const Word16 num_env_bands /* i : Number sub bands to be encoded for HQ_SWB_BWE */
+);
+
+void hvq_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 num_bits, /* i : Number of available bits */
+ const Word32 core_brate, /* i : Core bit-rate */
+ const Word16 *ynrm, /* i : Envelope coefficients */
+ Word16 *R, /* i/o: Bit allocation/updated bit allocation */
+ Word16 *noise_level, /* o : Noise level in Q15 */
+ Word16 *peak_idx, /* o : Peak position vector */
+ Word16 *Npeaks, /* o : Total number of peaks */
+ Word32 *coefsq_norm, /* o : Output vector in Q12 */
+ const Word16 core
+);
+
+void peak_vq_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word32 *coefs_out, /* o : Output coefficient vector Q12 */
+ const Word16 brate, /* i : Core bitrate */
+ const Word16 num_bits, /* i : Number of bits for HVQ */
+ const Word16 *ynrm, /* i : Envelope coefficients */
+ Word16 *R, /* i/o: Bit allocation/updated bit allocation */
+ Word16 *vq_peak_idx, /* o : Peak position vector */
+ Word16 *Npeaks, /* o : Number of peaks */
+ const Word16 core
+);
+
+void hq_pred_hb_bws_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 *ynrm, /* i : norm quantization index vector */
+ const Word16 length, /* i : frame length */
+ const Word16 hqswb_clas, /* i : HQ SWB class */
+ const Word16 *SWB_fenv /* i : SWB frequency envelopes Q1 */
+);
+void hq_core_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure fx */
+ Word16 synth[], /* o : output synthesis */
+ Word16 *Q_synth, /* o : Q value of synth */
+ const Word16 output_frame, /* i : output frame length */
+ const Word16 hq_core_type, /* i : HQ core type */
+ const Word16 core_switching_flag /* i : ACELP->HQ switching frame flag */
+);
+
+void hq_hr_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure fx */
+ Word32 *L_coefsq, /* o : transform-domain coefficients Q12 */
+ const Word16 length, /* i : frame length Q0 */
+ Word16 num_bits, /* i : number of available bits Q0 */
+ Word16 *ynrm, /* o : norm quantization index vector Q0 */
+ Word16 *is_transient, /* o : transient flag Q0 */
+ Word16 *hqswb_clas, /* o : HQ SWB class Q0 */
+ Word16 *SWB_fenv /* o : SWB frequency envelopes Q1 */
+);
+
+void dequantize_norms_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 start_norm, /* i : First SDE encoded norm */
+ const Word16 num_sfm, /* i : Number of norms */
+ const Word16 is_transient, /* i : Transient flag */
+ Word16 *ynrm, /* o : Decoded norm indices */
+ Word16 *normqlg2 /* o : Log2 of decoded norms */
+);
+
+void huff_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 N, /* i : Number of codewords to decode */
+ const Word16 buffer_len, /* i : Number of bits to read */
+ const Word16 num_lengths, /* i : Number of different huffman codeword lengths */
+ const Word16 *thres, /* i : Threshold of first codeword of each length */
+ const Word16 *offset, /* i : Offset for first codeword */
+ const Word16 *huff_tab, /* i : Huffman table order by codeword lengths */
+ Word16 *index /* o : Decoded index */
+);
+
+Word16 hq_classifier_dec_fx( /* o : Consumed bits Q0 */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : Core bit rate Q0 */
+ const Word16 length, /* i : Frame length Q0 */
+ Word16 *is_transient, /* o : Transient flag Q0 */
+ Word16 *hqswb_clas /* o : HQ class Q0 */
+);
+
+void hq_configure_bfi_fx(
+ Word16 *nb_sfm, /* o : Number of sub bands Q0 */
+ Word16 *num_Sb, /* o : Number of FEC sub bands ? Q0 */
+ Word16 *num_bands_p, /* o : FEC sub bands Q0 */
+ Word16 const **sfmsize, /* o : Subband bandwidths */
+ Word16 const **sfm_start, /* o : Subband start coefficients */
+ Word16 const **sfm_end /* o : Subband end coefficients */
+);
+
+void hq_swb_harmonic_calc_norm_envelop_fx(
+ Word32 *L_SWB_signal, /* i : input signal Q=12*/
+ Word32 *L_envelope, /* o : output envelope Q=12*/
+ Word16 L_swb_norm, /* i : length of normaliztion */
+ Word16 SWB_flength /* i : length of input signal */
+);
+
+Word16 build_nf_codebook_fx( /* o : Number of coefficients in nf codebook */
+ const Word16 flag_32K_env_ho, /* i : Envelope attenuation hangover flag */
+ const Word16 *coeff, /* i : Coded spectral coefficients */
+ const Word16 *sfm_start, /* i : Subband start indices */
+ const Word16 *sfmsize, /* i : Subband widths */
+ const Word16 *sfm_end, /* i : Subband end indices */
+ const Word16 last_sfm, /* i : Last coded band */
+ const Word16 *R, /* i : Per-band bit allocation */
+ Word16 *CodeBook, /* o : Noise-fill codebook */
+ Word16 *CodeBook_mod /* o : Densified noise-fill codebook */
+);
+
+Word16 find_last_band_fx( /* o : index of last band */
+ const Word16 *bitalloc, /* i : bit allocation */
+ const Word16 nb_sfm /* i : number of possibly coded bands */
+);
+
+void apply_noisefill_HQ_fx(
+ const Word16 *R, /* i : bit allocation */
+ const Word16 length, /* i : input frame length */
+ const Word16 flag_32K_env_ho,/* i : envelope stability hangover flag*/
+ const Word32 L_core_brate, /* i : core bit rate */
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 *CodeBook, /* i : Noise-fill codebook */
+ const Word16 *CodeBook_mod, /* i : Densified noise-fill codebook */
+ const Word16 cb_size, /* i : Codebook length */
+ const Word16 *sfm_start, /* i : Subband start coefficient */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ const Word16 *sfmsize, /* i : Subband band width */
+ Word16 *coeff /* i/o: coded/noisefilled spectrum */
+);
+
+void hvq_bwe_fine_fx(
+ const Word16 last_sfm, /* i : last coded subband */
+ const Word16 num_sfm, /* i : total number of bands */
+ const Word16 *sfm_end, /* i : Subband end coefficient */
+ const Word16 *peak_idx, /* i : Peak index */
+ const Word16 Npeaks, /* i : Number of peaks */
+ Word16 *peak_pos, /* o : Peak positions */
+ Word16 *prev_L_swb_norm, /* i/o: last normalize length */
+ Word32 *L_coeff, /* i/o: coded/noisefilled normalized spectrum */
+ Word16 *bwe_peaks, /* o : Positions of peaks in BWE */
+ Word16 *coeff_fine /* o : HVQ BWE fine structure */
+);
+
+void hq_fold_bwe_fx(
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ const Word16 num_sfm, /* i : Number of subbands Q0 */
+ Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */
+);
+
+void apply_nf_gain_fx(
+ const Word16 nf_idx, /* i : noise fill gain index Q0 */
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 *R, /* i : bit allocation Q0 */
+ const Word16 *sfm_start, /* i : Subband start coefficient Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ Word16 *coeff /* i/o: coded/noisefilled normalized spectrum Q12 */
+);
+
+void logqnorm_fx(
+ const Word32 *x, /* i : coefficient vector Qx */
+ const Word16 qx, /* i : Q value of input */
+ Word16 *k, /* o : index Q0 */
+ const Word16 L, /* i : codebook length Q0 */
+ const Word16 N, /* i : sub-vector size Q0 */
+ const Word16 hvq_flag /* i : HVQ flag Q0 */
+);
+
+void logqnorm_2_fx(
+ const Word32 *env_fl, /* o : index */
+ const Word16 L, /* i : codebook length */
+ const Word16 n_env_band, /* i : sub-vector size */
+ const Word16 nb_sfm, /* i : sub-vector size */
+ Word16 *ynrm,
+ Word16 *normqlg2,
+ const Word32 *thren /* i : quantization thresholds */
+);
+
+void hvq_bwe_fx(
+ const Word32 *coeff,
+ const Word16 *coeff_fine, /* i : coded/noisefilled normalized spectrum Qin */
+ const Word16 *sfm_start, /* i : Subband start coefficient Q0 */
+ const Word16 *sfm_end, /* i : Subband end coefficient Q0 */
+ const Word16 *sfm_len, /* i : Subband length Q0 */
+ const Word16 last_sfm, /* i : last coded subband Q0 */
+ const Word16 prev_hq_mode, /* i : previous hq mode Q0 */
+ const Word16 *bwe_peaks, /* i : HVQ bwe peaks Q0 */
+ const Word16 bin_th, /* i : HVQ transition bin Q0 */
+ const Word16 num_sfm, /* i : Number of bands Q0 */
+ const Word32 core_brate, /* i : Core bit-rate Q0 */
+ const Word16 *R, /* i : Bit allocation */
+ Word16 *norm, /* i/o: quantization indices for norms Q0 */
+ Word16 *noise_level, /* i/o: noise levels for harmonic modes Q15 */
+ Word16 *prev_noise_level, /* i/o: noise factor in previous frame Q15 */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input Q0 */
+ Word32 *L_coeff_out, /* o : coded/noisefilled spectrum Qout*/
+ const Word16 qin,
+ const Word16 qout
+);
+
+void hvq_concat_bands_fx
+(
+ const Word16 pvq_bands, /* i : Number of bands in concatenated PVQ target */
+ const Word16 *sel_bnds, /* i : Array of selected high bands */
+ const Word16 n_sel_bnds, /* i : Number of selected high bands */
+ Word16 *hvq_band_start, /* i : Band start indices */
+ Word16 *hvq_band_width, /* i : Band widths */
+ Word16 *hvq_band_end /* i : Band end indices */
+);
+
+void noise_mix_fx(
+ const Word16 *coeff_fine, /* i : normalized fine structure spectrum Qin */
+ const Word32 L_E, /* i : normalization factor Q17 */
+ const Word32 L_normq, /* i : quantized norm Q14 */
+ Word16 *seed, /* i/o: random seed Q0 */
+ const Word16 istart, /* i : start coefficient Q0 */
+ const Word16 iend, /* i : end coefficient Q0 */
+ const Word16 noise_level, /* i : noise_level Q0 */
+ Word32 *L_coeff_out, /* o : noisemixed spectrum Qout */
+ const Word16 qin,
+ const Word16 qout
+);
+
+Word16 noise_adjust_fx( /* o : index of noise attenuation Q0 */
+ const Word16 *coeffs_norm, /* i : normalized coefficients Qx */
+ const Word16 qx, /* i : Q value of coeffs_norm */
+ const Word16 *bitalloc, /* i : bit allocation Q0 */
+ const Word16 *sfm_start, /* i : band start Q0 */
+ const Word16 *sfm_end, /* i : band end Q0 */
+ const Word16 core_sfm /* i : index of the end band for core Q0 */
+);
+
+Word16 peak_vq_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 *coefs, /* i : Input coefficient vector Q14 */
+ Word32 *coefs_out, /* o : Quantized output vector Q14 */
+ const Word32 brate, /* i : Core bitrate */
+ const Word16 num_bits, /* i : Number of bits for HVQ */
+ const Word16 vq_peaks, /* i : Number of identified peaks */
+ const Word16 *ynrm, /* i : Envelope coefficients */
+ Word16 *R, /* i/o: Bit allocation/updated bit allocation */
+ Word16 *vq_peak_idx, /* i : Peak index vector */
+ Word32 *nf_gains /* i : Estimated noise floor gains Q14 */
+);
+
+Word16 hvq_enc_fx( /* o : Consumed bits */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 brate, /* i : Total bit rate */
+ const Word16 hvq_bits, /* i : HVQ bit budget */
+ const Word16 Npeaks, /* i : Number of peaks */
+ const Word16 *ynrm, /* i : Envelope coefficients */
+ Word16 *R, /* i/o: Bit allocation/updated bit allocation */
+ Word16 *peaks, /* i : Peak pos. / Encoded peak pos. */
+ Word32 *nf_gains, /* i/o: Noise fill gains / Quant. nf gains */
+ Word16 *noise_level, /* o : Quantized noise level */
+ const Word32 *pe_gains, /* i : Peak gains */
+ const Word32 *coefs, /* i : spectrum coefficients in Q14 */
+ Word32 *coefs_out /* o : encoded spectrum coefficients in Q14 */
+);
+
+void enforce_zero_for_min_envelope_fx(
+ const Word16 hqswb_clas, /* i : HQ coding mode Q0 */
+ const Word16 *ynrm, /* i : Envelope indices Q0 */
+ Word32 *L_coefsq, /* i/o: Quantized spectrum/zeroed spectrum Q12 */
+ const Word16 nb_sfm, /* i : Number of coded sub bands Q0 */
+ const Word16 *sfm_start, /* i : Sub band start indices Q0 */
+ const Word16 *sfm_end /* i : Sub band end indices Q0 */
+);
+
+void apply_envelope_fx(
+ const Word16 *coeff, /* i : Coded/noisefilled normalized spectrum Q12 */
+ const Word16 *norm, /* i : Envelope */
+ const Word16 *norm_adj, /* i : Envelope adjustment Q15 */
+ const Word16 num_sfm, /* i : Total number of bands */
+ const Word16 last_sfm, /* i : Last coded band */
+ const Word16 HQ_mode, /* i : HQ mode */
+ const Word16 length, /* i : Frame length */
+ const Word16 *sfm_start, /* i : Sub band start indices */
+ const Word16 *sfm_end, /* i : Sub band end indices */
+ Word32 *normq_v, /* o : Envelope with adjustment Q14 */
+ Word32 *coeff_out, /* o : coded/noisefilled spectrum */
+ const Word16 *coeff1, /* i : coded/noisefilled spectrum Q12 */
+ Word32 *coeff_out1 /* o : coded/noisefilled spectrum Q12 */
+);
+
+void bitalloc_fx (
+ Word16 *y, /* i : reordered norm of sub-vectors Q0 */
+ Word16 *idx, /* i : reordered sub-vector indices Q0 */
+ Word16 sum, /* i : number of available bits Q0 */
+ Word16 N, /* i : number of norms Q0 */
+ Word16 K, /* i : maximum number of bits per dimension Q0 */
+ Word16 *r, /* o : bit-allacation vector Q0 */
+ const Word16 *sfmsize, /* i : band length Q0 */
+ const Word16 hqswb_clas /* i : signal classification flag Q0 */
+);
+
+void bitallocsum_fx(
+ Word16 *R, /* i : bit-allocation vector Q0 */
+ const Word16 nb_sfm, /* i : number of sub-vectors Q0 */
+ Word16 *sum, /* o : total number of bits allocated Q0 */
+ Word16 *Rsubband, /* o : rate per subband Q3 */
+ const Word16 v, /* i : bit rate Q0 */
+ const Word16 length, /* i : length of spectrum (32 or 48 kHz samplerate) Q0 */
+ const Word16 *sfmsize /* i : band length Q0 */
+);
+
+void env_adj_fx
+(
+ const Word16 *pulses, /* i : number of pulses per band Q0 */
+ const Word16 length, /* i : length of spectrum Q0 */
+ const Word16 last_sfm, /* i : index of the last band Q0 */
+ Word16 *adj, /* o : adjustment factors for the envelope Q15 */
+ const Word16 env_stab, /* i : envelope stability Q15 */
+ const Word16 *sfmsize /* i : subband sizes Q0 */
+);
+
+Word16 env_stability_fx( /* in Q15 */
+ const Word16 *ynrm, /*i: Norm vector for current frame */
+ const Word16 nb_sfm, /*i: Number of sub-bands */
+ Word16 *mem_norm, /*i/o: Norm vector memory from past frame */
+ Word16 *mem_env_delta /*i/o: Envelope stability memory for smoothing in Q11 */
+);
+
+Word16 env_stab_smo_fx( /* Q0 */
+ Word16 env_stab, /*i : env_stab value Q15 */
+ Word16 *env_stab_state_p, /*i/o: env_stab state probabilities Q15 */
+ Word16 *ho_cnt /*i/o: hangover counter for speech state */
+);
+
+void env_stab_transient_detect_fx(
+ const Word16 is_transient, /* i: Transient flag */
+ const Word16 length, /* i : Length of spectrum (32 or 48 kHz) */
+ const Word16 norm[], /* i : quantization indices for norms */
+ Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover (Q0) */
+ Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection (Q13) */
+ const Word16 HQ_mode, /* i : HQ coding mode */
+ const Word16 bin_th, /* i : HVQ cross-over frequency bin */
+ const Word32 *L_coeff, /* i : Coded spectral coefficients */
+ const Word16 Qcoeff /* i : Q of coded spectral coefficients */
+);
+
+void hq_configure_fx(
+ const Word16 length, /* i : Frame length Q0 */
+ const Word16 hqswb_clas, /* i : HQ SWB class Q0 */
+ const Word32 core_brate, /* i : Codec bitrate Q0 */
+ Word16 *num_sfm, /* o : Total number of subbands Q0 */
+ Word16 *nb_sfm, /* o : Total number of coded bands Q0 */
+ Word16 *start_norm, /* o : First norm to be SDE encoded Q0 */
+ Word16 *num_env_bands, /* o : Number coded envelope bands Q0 */
+ Word16 *numnrmibits, /* o : Number of bits in fall-back norm encoding Q0 */
+ Word16 *hq_generic_offset, /* o : Freq offset for HQ GENERIC Q0 */
+ Word16 const **sfmsize, /* o : Subband bandwidths Q0 */
+ Word16 const **sfm_start, /* o : Subband start coefficients Q0 */
+ Word16 const **sfm_end /* o : Subband end coefficients Q0 */
+);
+
+Word16 hvq_pvq_bitalloc_fx(
+ Word16 num_bits, /* i/o: Number of available bits (including gain bits) */
+ const Word32 brate, /* i : bitrate */
+ const Word16 bwidth_fx, /* i : Encoded bandwidth */
+ const Word16 *ynrm, /* i : Envelope coefficients */
+ const Word32 manE_peak, /* i : Peak energy mantissa */
+ const Word16 expE_peak, /* i : Peak energy exponent */
+ Word16 *Rk, /* o : bit allocation for concatenated vector */
+ Word16 *R, /* i/o: Global bit allocation */
+ Word16 *sel_bands, /* o : Selected bands for encoding */
+ Word16 *n_sel_bands /* o : No. of selected bands for encoding */
+);
+
+void disf_ns_28b_fx(
+ Word16 *indice,
+ Word16 *isf_q
+);
+
+void isf_enc_amr_wb_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ Word16 *isf_new, /* o : quantized ISF vector */
+ Word16 *isp_new, /* i/o: ISP vector to quantize/quantized */
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes */
+ Word16 *stab_fac /* o : ISF stability factor */
+);
+
+void pvq_encode_fx(
+ Encoder_State_fx *st_fx,
+ const Word16 *x, /* i: vector to quantize Q15-3=>Q12 */
+ Word16 *y, /* o: raw pulses (non-scaled short) Q0 */
+ Word16 *xq, /* o: quantized vector Q15 */
+ Word32 *L_xq, /* o: quantized vector Q31 */
+ const Word16 pulses, /* i: number of allocated pulses */
+ const Word16 dim, /* i: Length of vector */
+ const Word16 neg_gain /* i: - Gain use - negative gain in Q15 0 ..1 */
+);
+
+void pvq_decode_fx(
+ Decoder_State_fx *st_fx,
+ Word16 *xq, /* o: decoded vector (Q15) */
+ Word16 *y, /* o: decoded vector (non-scaled int) */
+ const Word16 k_val, /* i: number of allocated pulses */
+ const Word16 dim, /* i: Length of vector */
+ const Word16 neg_gain /* i: Gain (negated to fit 1.0 in Q15 as -1.0) */
+);
+
+UWord32 intLimCDivPos_fx(
+ UWord32 NUM,
+ Word16 DEN
+);
+
+Word32 intLimCDivSigned_fx(
+ Word32 NUM,
+ Word16 DEN
+);
+
+Word16 shrtCDivSignedApprox(
+ const Word16 num,
+ const Word16 den
+);
+void de_interleave_spectrum_fx(
+ Word32 *coefs, /* i/o: input and output coefficients Q? */
+ const Word16 length /* i : length of spectrum Q0 */
+);
+
+void interleave_spectrum_fx(
+ Word32 *coefs, /* i/o: input and output coefficients Q? */
+ const Word16 length /* i : length of spectrum Q0 */
+);
+
+void recovernorm_fx(
+ Word16 *idxbuf, /* i : reordered quantization indices */
+ Word16 *ynrm, /* o : recovered quantization indices */
+ Word16 *normqlg2, /* o : recovered quantized norms */
+ Word16 nb_sfm /* i : number of SFMs */
+);
+
+void map_quant_weight_fx(
+ const Word16 normqlg2[], /* i : quantized norms */
+ Word16 wnorm[], /* o : weighted norm */
+ const Word16 is_transient /* i : transient flag */
+);
+
+void fill_spectrum_fx(
+ Word16 *coeff, /* i/o: normalized MLT spectrum / nf spectrum Q12 */
+ Word32 *L_coeff_out, /* i/o: Noisefilled MLT spectrum Q12 */
+ const Word16 *R, /* i : number of pulses per band Q0 */
+ const Word16 is_transient, /* i : transient flag Q0 */
+ Word16 norm[], /* i : quantization indices for norms Q0 */
+ const Word16 *hq_generic_fenv, /* i : HQ GENERIC envelope Q1 */
+ const Word16 hq_generic_offset, /* i : HQ GENERIC offset Q0 */
+ const Word16 nf_idx, /* i : noise fill index Q0 */
+ const Word16 length, /* i : Length of spectrum (32 or 48 kHz) Q0 */
+ const Word16 env_stab, /* i : Envelope stability measure [0..1] Q15 */
+ Word16 *no_att_hangover, /* i/o: Frame counter for attenuation hangover Q0 */
+ Word32 *L_energy_lt, /* i/o: Long-term energy measure for transient detection Q13 */
+ Word16 *bwe_seed, /* i/o: random seed for generating BWE input Q0 */
+ const Word16 hq_generic_exc_clas, /* i : BWE excitation class Q0 */
+ const Word16 core_sfm, /* i : index of the end band for core Q0 */
+ const Word16 HQ_mode, /* i : HQ mode Q0 */
+ Word16 noise_level[], /* i : noise levels for harmonic modes Q15 */
+ const Word32 L_core_brate, /* i : target bit-rate Q0 */
+ Word16 prev_noise_level[], /* i/o: noise factor in previous frame Q15 */
+ Word16 *prev_R, /* i/o: bit allocation info. in previous frame Q0 */
+ Word32 *prev_coeff_out, /* i/o: decoded spectrum in previous frame Q12 */
+ const Word16 *peak_idx, /* i : peak indices for hvq Q0 */
+ const Word16 Npeaks, /* i : number of peaks in hvq Q0 */
+ const Word16 *npulses, /* i : number of pulses per band Q0 */
+ const Word16 prev_is_transient, /* i : previous transient flag Q0 */
+ Word32 *prev_normq, /* i/o: previous norms Q14 */
+ Word32 *prev_env, /* i/o: previous noise envelopes Q(prev_env_Q) */
+ const Word16 prev_bfi, /* i : previous bad frame indicator Q0 */
+ const Word16 *sfmsize, /* i : Length of bands Q0 */
+ const Word16 *sfm_start, /* i : Start of bands Q0 */
+ const Word16 *sfm_end, /* i : End of bands Q0 */
+ Word16 *prev_L_swb_norm, /* i/o: HVQ/Harmonic mode normalization length Q0 */
+ const Word16 prev_hq_mode, /* i : Previous HQ mode Q0 */
+ const Word16 num_sfm, /* i : Total number of bands Q0 */
+ Word16 *prev_env_Q,
+ const Word16 num_env_bands
+);
+
+Word16 FEC_pos_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 last_good, /* i : last good classfication */
+ Word16 *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */
+ Word16 *clas, /* o : decoded classification */
+ Word32 *enr_q, /* o : decoded energy in Q0 */
+ const Word32 core_brate /* i : decoded bitrate */
+);
+
+void pit16k_Q_dec_fx(
+ const Word16 pitch_index, /* i : pitch index */
+ const Word16 nBits, /* i : # of Q bits */
+ const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */
+ Word16 *T0, /* o : integer pitch lag */
+ Word16 *T0_frac, /* o : pitch fraction */
+ Word16 *T0_min, /* i/o: delta search min */
+ Word16 *T0_max /* i/o: delta search max */
+ ,Word16 *BER_detect /* o : BER detect flag */
+);
+
+Word16 frame_ener_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 clas, /* i : frame classification */
+ const Word16 *synth, /* i : synthesized speech at Fs = 12k8 Hz Q_new */
+ const Word16 pitch, /* i : pitch period Q0 */
+ Word32 *enr_q, /* o : pitch-synchronous or half_frame energy Q0 */
+ const Word16 offset, /* i : speech pointer offset (0 or L_FRAME) */
+ const Word16 Q_new, /* i : Scaling factor */
+ Word16 shift, /* i : Shift need to obtain 12 bits vectors */
+ const Word16 enc /* i : Encoder/decoder */
+);
+
+Word16 frame_energy_fx( /* o : Frame erergy in Q8 */
+ Word16 L_frame,
+ const Word16 *pitch, /* i : pitch values for each subframe Q6 */
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_syn*/
+ const Word16 lp_speech, /* i : long term active speech energy average Q8 */
+ Word16 *frame_ener, /* o : pitch-synchronous energy at frame end Q8 */
+ const Word16 Q_syn /* i : Synthesis scaling */
+);
+
+void int_lsp_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 lsp_old[], /* i : LSPs from past frame */
+ const Word16 lsp_new[], /* i : LSPs from present frame */
+ Word16 *Aq, /* o : LP coefficients in both subframes */
+ const Word16 m, /* i : order of LP filter */
+ const Word16 *int_coeffs, /* i : interpolation coefficients */
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+);
+
+void reorder_isf_fx(
+ Word16 *isf, /* i/o: ISFs in the frequency domain (0..0.5) */
+ const Word16 min_dist, /* i : minimum required distance */
+ const Word16 n, /* i : LPC order */
+ const Word16 fs /* i : sampling frequency */
+);
+
+void reorder_lsf_fx(
+ Word16 *lsf, /* i/o: LSFs in the frequency domain (0..0.5) Q(x2.56)*/
+ const Word16 min_dist, /* i : minimum required distance x2.56*/
+ const Word16 n, /* i : LPC order */
+ const Word32 fs /* i : sampling frequency */
+);
+
+Word16 FEC_synchro_exc_fx( /* o : do_WI flag */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *exc, /* i/o: exc vector to modify */
+ const Word16 desire_puls_pos, /* i : Pulse position send by the encoder */
+ const Word16 true_puls_pos, /* i : Present pulse location */
+ const Word16 Old_pitch /* i : Pitch use to create temporary adaptive codebook */
+);
+
+Word16 findpulse_fx( /* o : pulse position */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 res[], /* i : Residual signal <12 bits */
+ const Word16 T0, /* i : Pitch estimation Q0 */
+ const Word16 enc, /* i : enc = 1 -> encoder side; enc = 0 -> decoder side */
+ Word16 *sign /* i/o: sign of the maximum */
+);
+
+void FEC_exc_estim_fx(
+ Decoder_State_fx *st_fx, /* i/o: Decoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *exc, /* o : pointer to excitation buffer (with past) */
+ Word16 *exc2, /* o : total excitation (for synthesis) */
+ Word16 dct_exc_tmp[], /* o : GSC excitation in DCT domain */
+ Word16 *pitch_buf, /* o : Floating pitch for each subframe */
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 *tmp_tc, /* o : FEC pitch Q6 */
+ Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ Word16 *lsf_new, /* i : ISFs at the end of the frame */
+ Word16 *Q_exc,
+ Word16 *tmp_noise /* o : long-term noise energy Q0 */
+);
+
+void FEC_lsf2lsp_interp(
+ Decoder_State_fx *st, /* i/o: Decoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *Aq, /* o : calculated A(z) for 4 subframes */
+ Word16 *lsf, /* o : estimated LSF vector */
+ Word16 *lsp /* o : estimated LSP vector */
+);
+void FEC_lsf_estim_enc_fx(
+ Encoder_State_fx *st_fx, /* i : Encoder static memory */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *lsf /* o : estimated LSF vector */
+);
+
+void FEC_clas_estim_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state handle */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */ /*A*/
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 *clas, /* i/o: frame classification */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 *pitch, /* i : pitch values for each subframe (Q6) */
+ Word16 *syn, /* i : synthesis buffer */
+ Word16 *lp_speech, /* i/o: long term active speech energy average Q8 */
+ Word16 *decision_hyst, /* i/o: hysteresis of the music/speech decision */ /*A*/
+ Word16 *UV_cnt, /* i/o: number of consecutives frames classified as UV */ /*A*/
+ Word16 *LT_UV_cnt, /* i/o: long term consecutives frames classified as UV */ /*A*/
+ Word16 *Last_ener, /* i/o: last_energy frame */ /*A*/
+ Word16 *locattack, /* i/o: detection of attack (mainly to localized speech burst) */ /*A*/
+ Word16 *lt_diff_etot, /* i/o: long-term total energy variation */ /*A*/
+ Word16 *amr_io_class, /* i/o: classification for AMR-WB IO mode */ /*A*/
+ const Word32 bitrate, /* i : Decoded bitrate */ /*A*/
+ Word16 Q_syn, /* i : Synthesis scaling */
+ Word16 *class_para, /* o : classification para. fmerit1 */ /*A*/
+ Word16 *mem_syn_clas_estim, /* i/o: memory of the synthesis signal for frame class estimation */
+ Word16 *Q_mem_syn, /*i/o : exponent for memory of synthesis signal for frame class estimation */ /*B*/
+ Word16 LTP_Gain, /* i : LTP gain is 0..0.6 or negative Q15*/ /*B*/
+ Word16 mode, /* i : signal classifier mode *//*B*/
+ Word16 bfi, /* i : bad frame indicator *//*B*/
+ Word32 last_core_brate /* i : bitrate of previous frame */
+);
+
+void non_linearity_fx(
+ const Word16 input[], /* i : input signal Q_inp */
+ Word32 output[], /* o : output signal 2*Q_inp */
+ const Word16 length, /* i : input length */
+ Word32 *prev_scale, /* i/o: memory Q30 */
+ Word16 Q_inp,
+ Word16 coder_type, /* i : Coder Type */
+ Word16 *voice_factors, /* i : Voice Factors */
+ const Word16 L_frame /* i : ACELP frame length */
+);
+
+void stat_noise_uv_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: Decoder static memory */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *lsp_new, /* i : end-frame LSP vector */
+ Word16 *lsp_mid, /* i : mid-frame LSP vector */
+ Word16 *Aq, /* o : A(z) quantized for the 4 subframes */
+ Word16 *exc2 /* i/o: excitation buffer */
+);
+
+void stat_noise_uv_mod_fx(
+ const Word16 coder_type, /* i : Coder type */
+ Word16 noisiness, /* i : noisiness parameter */
+ const Word16 *lsp_old, /* i : old LSP vector at 4th sfr */
+ const Word16 *lsp_new, /* i : LSP vector at 4th sfr */
+ const Word16 *lsp_mid, /* i : LSP vector at 2nd sfr */
+ Word16 *Aq, /* o : A(z) quantized for the 4 subframes */
+ Word16 *exc2, /* i/o: excitation buffer */
+ Word16 Q_exc, /* i : Q of exc2 excitation buffer [11..-1] expected */
+ const Word16 bfi , /* i : Bad frame indicator */
+ Word32 *ge_sm, /* i/o: smoothed excitation gain */
+ Word16 *uv_count, /* i/o: unvoiced counter */
+ Word16 *act_count, /* i/o: activation counter */
+ Word16 lspold_s[], /* i/o: old LSP */
+ Word16 *noimix_seed, /* i/o: mixture seed */
+ Word16 *st_min_alpha, /* i/o: minimum alpha */
+ Word16 *exc_pe, /* i/o: scale Q_stat_noise */
+ const Word32 bitrate, /* i : core bitrate */
+ const Word16 bwidth_fx, /* i : input bandwidth */
+ Word16 *Q_stat_noise, /* i/o: noise scaling */
+ Word16 *Q_stat_noise_ge /* i/o: noise scaling */
+);
+
+/* Just call preemph_copy_fx(), it does the same thing and that saves PROM */
+#define preemph_fx(signal,mu,L,mem) preemph_copy_fx((signal),(signal),(mu),(L),(mem))
+
+void preemph_copy_fx(
+ const Word16 x[], /* i : input signal Qx */
+ Word16 y[], /* o : output signal Qx */
+ const Word16 mu, /* i : preemphasis coefficient Q15 */
+ const Word16 lg, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (x[-1]) Qx */
+);
+
+Word16 vquant_fx( /* o: index of the winning codevector */
+ Word16 x[], /* i: vector to quantize Q13 */
+ const Word16 x_mean[], /* i: vector mean to subtract (0 if none)Q13*/
+ Word16 xq[], /* o: quantized vector Q13 */
+ const Word16 cb[], /* i: codebook Q13 */
+ const Word16 dim, /* i: dimension of codebook vectors */
+ const Word16 cbsize /* i: codebook size */
+);
+
+Word16 w_vquant_fx(
+ Word16 x[], /* i: vector to quantize in Q10 */
+ Word16 Qx,
+ const Word16 weights[], /* i: error weights in Q0 */
+ Word16 xq[], /* o: quantized vector in Q15 */
+ const Word16 cb[], /* i: codebook in Q15 */
+ const Word16 cbsize, /* i: codebook size */
+ const Word16 rev_vect /* i: reverse codebook vectors */
+);
+
+void Vr_subt(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ Word16 y[], /* o : Output vector that contains vector 1 - vector 2 */
+ Word16 N /* i : Vector lenght */
+);
+
+Word16 gsc_gainQ_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 y_gain4[], /* i : Energy per band Q13 */
+ Word16 y_gainQ[], /* o : quantized energy per band Q13 */
+ const Word32 core_brate, /* i : Core rate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth /* i : input signal bandwidth */
+);
+
+Word16 emaximum_fx( /* o : return index with max energy value in vector Q0 */
+ const Word16 Qvec, /* i : Q of input vector Q0 */
+ const Word16 *vec, /* i : input vector Qx */
+ const Word16 lvec, /* i : length of input vector Q0 */
+ Word32 *ener_max /* o : maximum energy value Q0 */
+);
+
+void set16_fx(
+ Word16 y[], /* i/o: Vector to set */
+ const Word16 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Lenght of the vector */
+);
+
+void set32_fx(
+ Word32 y[], /* i/o: Vector to set */
+ const Word32 a, /* i : Value to set the vector to */
+ const Word16 N /* i : Lenght of the vector */
+);
+
+void Copy(
+ const Word16 x[], /* i : input vector */
+ Word16 y[], /* o : output vector */
+ const Word16 L /* i : vector length */
+);
+
+void Copy32(
+ const Word32 x[], /* i : input vector */
+ Word32 y[], /* o : output vector */
+ const Word16 L /* i : vector length */
+);
+
+void Scale_sig32(
+ Word32 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Copy_Scale_sig(
+ const Word16 x[], /* i : signal to scale input Qx */
+ Word16 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Copy_Scale_sig_16_32(
+ const Word16 x[], /* i : signal to scale input Qx */
+ Word32 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void Copy_Scale_sig_32_16(
+ const Word32 x[], /* i : signal to scale input Qx */
+ Word16 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void init_lvq_fx(
+ Word32 offset_scale1[][MAX_NO_SCALES+1],
+ Word32 offset_scale2[][MAX_NO_SCALES+1],
+ Word32 offset_scale1_p[][MAX_NO_SCALES+1],
+ Word32 offset_scale2_p[][MAX_NO_SCALES+1],
+ Word16 no_scales[][2],
+ Word16 no_scales_p[][2]
+);
+
+void hf_synth_reset_fx(
+ Word16 *seed2, /* i/o: random seed for HF noise gen */
+ Word16 mem_hf[], /* o : HF band-pass filter memory */
+ Word16 mem_syn_hf[], /* o : HF synthesis memory */
+ Word16 mem_hp400[], /* o : memory of hp 400 Hz filter */
+ Word16 mem_hp_interp[], /* o : interpol. memory */
+ Word16 delay_syn_hf[] /* o : HF synthesis memory */
+);
+
+void hf_synth_init_fx(
+ Word16 mem_hp400[], /* o : 400 Hz high pass filter memory initialization */
+ Word16 mem_hf[] /* o : band pass 6kHz to 7kHz FIR filter initialization */
+);
+
+Word16 Random( /* o : output random value */
+ Word16 *seed /* i/o: random seed */
+);
+
+Word16 own_random2_fx( /* o : output random value */
+ Word16 seed /* i : random seed */
+);
+
+void Random_Fill(
+ Word16 *seed, /* i/o: random seed */
+ Word16 n, /* i : number of values */
+ Word16 *y, /* o : output values */
+ Word16 scaling /* i : scaling of values */
+);
+
+void iDiv_and_mod_32(
+ const Word32 Numer, /* i : 32 bits numerator */
+ const Word16 Denom, /* i : 16 bits denominator */
+ Word32 * Int_quotient, /* o : integer result of the division (int)(num/den) */
+ Word32 * Int_mod, /* o : modulo result of the division num-((int)(num/den)*den)*/
+ const Word16 rshift /* i : 0 if no right shift / 1 if the denom is right shifted by 1*/
+);
+
+void lsf2lsp_fx(
+ const Word16 lsf[], /* i : lsf[m] normalized (range: 0.0<=val<=0.5) x2.56 */
+ Word16 lsp[], /* o : lsp[m] (range: -1<=val<1) Q15 */
+ const Word16 m, /* i : LPC order Q0 */
+ Word32 int_fs
+);
+
+void bass_psfilter_init_fx(
+ Word16 old_syn[], /* o : Old synthesis buffer 1 */
+ Word16 *mem_deemph_err, /* o : Error deemphasis memory */
+ Word16 *lp_ener /* o : long_term error signal energy */
+);
+
+void decod_gen_voic_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 do_WI_fx, /* i : do interpolation after a FER */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ Word16 *unbits, /* number of unused bits */
+ Word16* gain_buf /*Q14*/
+);
+
+Word16 tc_classif_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 L_frame /* i : length of the frame */
+);
+
+void transition_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ Word16 *Jopt_flag, /* i : joint optimization flag */
+ Word16 *exc, /* o : excitation signal */
+ Word16 *T0, /* o : close loop integer pitch */
+ Word16 *T0_frac, /* o : close loop fractional part of the pitch */
+ Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
+ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
+ Word16 **pt_pitch, /* o : floating pitch values */
+ Word16 *position, /* i/o: first glottal impulse position in frame */
+ Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ Word16 *Q_exc /*i/o : scaling of excitation */
+);
+
+void decod_tran_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 tc_subfr_fx, /* i : TC subframe index */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ Word16 *unbits, /* i/o: number of unused bits */
+ const Word16 sharpFlag, /* i : formant sharpening flag */
+ Word16 *gain_buf /*Q14*/
+);
+
+void interp_code_4over2_fx(
+ const Word16 inp_code_fx[], /* i : input vector Qx */
+ Word16 interp_code_fx[], /* o : output vector Qx */
+ const Word16 inp_length /* i : length of input vector */
+);
+
+void pred_lt4_tc_fx(
+ Word16 exc[], /* i/o: excitation buffer */
+ const Word16 T0, /* i : integer pitch lag */
+ Word16 frac, /* i: fraction of lag */
+ const Word16 *win, /* i : interpolation window */
+ const Word16 imp_pos, /* i : glottal impulse position */
+ const Word16 i_subfr /* i : subframe index */
+);
+
+void gaus_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word32 core_brate, /* i */ /*1 : core bitrate */
+ const Word16 i_subfr, /* i */ /*2 : subframe index */
+ Word16 *code, /* o */ /*3 : unvoiced excitation Q12 */
+ Word32 *L_norm_gain_code, /* o */ /*4 : gain of normalized gaussian excitation Q16 */
+ Word16 *lp_gainp, /* i/o */ /*5 : lp filtered pitch gain(FER) Q14 */
+ Word16 *lp_gainc, /* i/o */ /*6 : lp filtered code gain (FER) Q3 */
+ Word16 *inv_gain_inov, /* o */ /*7 : unscaled innovation gain Q12 */
+ Word16 *tilt_code, /* o */ /*8 : synthesis excitation spectrum tilt Q15 */
+ Word16 *voice_fac, /* o */ /*9 : estimated voicing factor Q15 */
+ Word16 *gain_pit, /* o */ /*10 : pitch gain Q14 */
+ Word16 *pt_pitch_1, /* o */ /*11 : floating pitch buffer Q6 */
+ Word16 *exc, /* o */ /*12 : excitation signal frame */
+ Word32 *L_gain_code, /* o */ /*13 : gain of the gaussian excitation Q16 */
+ Word16 *exc2, /* o */ /*14 : Scaled excitation signal frame */
+ Word16 *bwe_exc_fx,
+ Word16 *sQ_exc, /* i/o */ /*15 : Excitation scaling factor (Decoder state) */
+ Word16 *sQsubfr /* i/o */ /*16 : Past excitation scaling factors (Decoder State) */
+);
+
+void decod_unvoiced_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* Q12 i : LP filter coefficient */
+ const Word16 coder_type_fx, /* Q0 i : coding type */
+ Word16 *tmp_noise_fx, /* Q5 o : long term temporary noise energy */
+ Word16 *pitch_buf_fx, /* Q6 o : floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* Q15 o : voicing factors */
+ Word16 *exc_fx, /* Q_X o : adapt. excitation exc */
+ Word16 *exc2_fx, /* Q_X o : adapt. excitation/total exc */
+ Word16 *bwe_exc_fx, /* Q_X i/o: excitation for SWB TBE */
+ Word16 *gain_buf
+);
+
+Word32 gain_dec_gaus_fx( /* o : quantized codebook gain Q16 */
+ Word16 index, /* i : quantization index */
+ const Word16 bits, /* i : number of bits to quantize */
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) */
+ const Word16 topBound, /* i : upper bound of quantizer (dB) */
+ const Word16 inv_gain_inov, /* o : unscaled innovation gain Q12 */
+ Word32 *L_norm_gain_code /* o : gain of normalized gaussian excitation Q16 */
+);
+
+void AVQ_demuxdec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 xriq[], /* o: decoded subvectors [0..8*Nsv-1] */
+ Word16 *nb_bits, /* i/o: number of allocated bits */
+ const Word16 Nsv, /* i: number of subvectors */
+ Word16 nq_out[] /* i/o: AVQ nq index */
+);
+
+void re8_decode_base_index_fx(Word16 n, UWord16 I, Word16 *x);
+
+void re8_k2y_fx(
+ const Word16 *k, /* i : Voronoi index k[0..7] */
+ const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) */
+ Word16 *y /* o : 8-dimensional point y[0..7] in RE8 */
+);
+
+void re8_vor_fx(
+ const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) */
+ Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */
+ Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4*/
+ Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */
+ Word16 *ka /* o : identifier of absolute leader (to index c) */
+);
+
+void re8_cod_fx(
+ Word16 x[], /* i : point in RE8 (8-dimensional integer vector) */
+ Word16 *n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
+ UWord16 *I, /* o : index of c (pointer to unsigned 16-bit word) */
+ Word16 k[] /* o : index of v (8-dimensional vector of binary indices) = Voronoi index */
+);
+
+void re8_PPV_fx(
+ const Word32 x[], /* i : point in R^8Q15 */
+ Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */
+);
+
+void re8_dec_fx(
+ Word16 n, /* i : codebook number (*n is an integer defined in {0,2,3,4,..,n_max}) */
+ const UWord16 I, /* i : index of c (pointer to unsigned 16-bit word) */
+ const Word16 k[], /* i : index of v (8-dimensional vector of binary indices) = Voronoi index */
+ Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */
+);
+
+void gain_dec_SQ_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe number */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 *code, /* i : algebraic code excitation Q12*/
+ const Word16 Es_pred, /* i : predicted scaled innov. energy Q8 */
+ Word16 *gain_pit, /* o : Quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : Quantized codeebook gain Q16*/
+ Word16 *gain_inov, /* o : unscaled innovation gain Q12*/
+ Word32 *norm_gain_code /* o : norm. gain of the codebook excitation Q16*/
+);
+
+void gain_dec_amr_wb_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ Word16 *gain_pit, /* o : Quantized pitch gain */
+ Word32 *gain_code, /* o : Quantized codeebook gain */
+ Word16 *past_qua_en, /* i/o: gain quantization memory (4 words) */
+ Word16 *gain_inov, /* o : unscaled innovation gain */
+ const Word16 *code, /* i : algebraic code excitation */
+ Word32 *norm_gain_code /* o : norm. gain of the codebook excitation */
+);
+
+void isf_dec_amr_wb_fx(
+ Decoder_State_fx *st, /* i/o: State structure */
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes */
+ Word16 *isf_new, /* o : de-quantized ISF vector */
+ Word16 *isp_new /* o : de-quantized ISP vector */
+);
+
+void syn_output_fx(
+ const Word16 codec_mode, /* i : MODE1 or MODE2 */
+ Word16 *synth, /* i/o: float synthesis signal */
+ const Word16 output_frame, /* i : output frame length */
+ Word16 *synth_out, /* o : integer 16 bits synthesis signal */
+ const Word16 Q_syn2 /* i : Synthesis scaling factor */
+);
+
+void amr_wb_dec_fx(
+ Word16 output_sp[], /* o : synthesis output */
+ Decoder_State_fx *st_fx /* o : Decoder static variables structure */
+);
+
+void decod_amr_wb_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* i : LP filter coefficients */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *gain_buf /*Q14*/
+);
+
+void disf_2s_46b_fx(
+ Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
+ Word16 *isf_q, /* o : quantized ISFs in the cosine domain */
+ Word16 *mem_AR, /* o : quantizer memory for AR model */
+ Word16 *mem_MA, /* i/o: quantizer memory for MA model */
+ const Word16 enc_dec /* i : encoder (0), decoder (1) G722.2 FER */
+);
+
+void disf_2s_36b_fx(
+ Word16 *indice, /* i : quantized indices (use indice[0] = -1 in the decoder) */
+ Word16 *isf_q, /* o : quantized ISFs in the cosine domain */
+ Word16 *mem_AR, /* i/o: quantizer memory for AR model */
+ Word16 *mem_MA, /* i/o: quantizer memory for MA model */
+ const Word16 enc_dec /* i : encoder (0), decoder (1) G722.2 FER */
+);
+
+void transf_cdbk_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 harm_flag_acelp,/* i : harmonic flag for higher rates ACELP */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 Es_pred, /* i : predicited scaled innovation energy (Q8) */
+ const Word32 gain_code, /* i : innovative excitation gain (Q16) */
+ Word16 *mem_preemp, /* i/o: dequantizer preemhasis memory */
+ Word16 *gain_preQ, /* o : prequantizer excitation gain (Q2) */
+ Word32 *norm_gain_preQ,/* o : normalized prequantizer excitation gain (Q16) */
+ Word16 code_preQ[], /* o : prequantizer excitation (Q8) */
+ Word16 *unbits /* o : number of AVQ unused bits */
+);
+
+void gain_enc_SQ_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 *xn, /* i : target vector Q_xn */
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation Q_xn */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9 */
+ const Word16 *code, /* i : algebraic excitation Q9 */
+ const Word16 Es_pred, /* i : predicted scaled innovation energy Q8 */
+ Word16 *gain_pit, /* o : quantized pitch gain Q14 */
+ Word32 *gain_code, /* o : quantized codebook gain Q16 */
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12 */
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16 */
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
+ const Word16 Q_xn /* i : xn and y1 scaling */
+);
+
+void AVQ_cod_fx( /* o: comfort noise gain factor */
+ const Word16 xri[], /* i: vector to quantize */
+ Word16 xriq[], /* o: quantized normalized vector (assuming the bit budget is enough) */
+ const Word16 NB_BITS, /* i: number of allocated bits */
+ const Word16 Nsv, /* i: number of subvectors (lg=Nsv*8) */
+ const Word16 Q_in /* i: Scaling input */
+);
+
+void AVQ_encmux_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 extl, /* i : extension layer */
+ Word16 xriq[], /* i/o: rounded subvectors [0..8*Nsv-1] followed
+ by rounded bit allocations [8*Nsv..8*Nsv+Nsv-1] */
+ Word16 *nb_bits, /* i/o: number of allocated bits */
+ const Word16 Nsv, /* i: number of subvectors */
+ Word16 nq_out[] /* o : AVQ nq index */
+);
+
+Word32 Dot_product( /* o : Sum */
+ const Word16 x[], /* i : 12bits: x vector */
+ const Word16 y[], /* i : 12bits: y vector */
+ const Word16 lg /* i : vector length */
+);
+
+Word16 usquant_fx( /* o: index of the winning codeword */
+ const Word16 x, /* i: scalar value to quantize Qx*/
+ Word16 *xq, /* o: quantized value Qx*/
+ const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word16 delta, /* i: quantization step Qx-1*/
+ const Word16 cbsize /* i: codebook size */
+);
+
+Word16 gain_quant_fx( /* o: quantization index */
+ Word32 *gain, /* i/o: quantized gain */
+ Word16 *gain16,
+ const Word16 c_min, /* i: log10 of lower limit in Q14 */
+ const Word16 c_max, /* i: log10 of upper limit in Q13 */
+ const Word16 bits, /* i: number of bits to quantize */
+ Word16 *expg
+);
+
+void gain_enc_mless_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 *xn, /* i : target vector */
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation */
+ const Word16 Q_xn, /* i : xn and y1 scaling */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
+ const Word16 *code, /* i : algebraic excitation */
+ const Word16 Es_pred, /* i : predicted scaled innovation energy */
+ Word16 *gain_pit, /* o : quantized pitch gain */
+ Word32 *gain_code, /* o : quantized codebook gain */
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 */
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+);
+
+Word16 gain_enc_gaus_fx( /* o : Return index of quantization */
+ Word32 *gain, /* i/o: Code gain to quantize */
+ const Word16 bits, /* i : number of bits to quantize */
+ const Word16 lowBound, /* i : lower bound of quantizer (dB) Q8 */
+ const Word16 stepSize, /* i : Step size choice Q14 */
+ const Word16 inv_stepSize /* i : Step size choice Q15 */
+);
+
+void gain_enc_tc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 xn_fx[], /* i : target vector */
+ const Word16 y2_fx[], /* i : zero-memory filtered algebraic codebook excitation */
+ const Word16 code_fx[], /* i : algebraic excitation */
+ const Word16 Es_pred_fx, /* i : predicted scaled innovation energy */
+ Word16 *gain_pit_fx, /* o : Pitch gain / Quantized pitch gain */
+ Word32 *gain_code_fx, /* o : quantized codebook gain */
+ Word16 *gain_inov_fx, /* o : innovation gain */
+ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation */
+ const Word16 Q_xn /* i : xn and y1 scaling Q0 */
+);
+
+Word16 gaus_encode_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 *h1, /* i : weighted filter input response */
+ const Word16 *xn, /* i : target vector */
+ Word16 *exc, /* o : pointer to excitation signal frame */
+ Word16 *mem_w0, /* o : weighting filter denominator memory */
+ Word16 *clip_gain, /* o : memory of gain of pitch clipping algorithm */
+ Word16 *tilt_code, /* o : synthesis excitation spectrum tilt */
+ Word16 *code, /* o : algebraic excitation Q9 */
+ Word32 *gain_code, /* o : Code gain. Q16 */
+ Word16 *y2, /* o : zero-memory filtered adaptive excitation Q9 */
+ Word16 *gain_inov, /* o : innovation gain Q12 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
+ const Word16 Q_new, /* i : scaling factor */
+ const Word16 shift, /* i : scaling factor */
+ Word32 *norm_gain_code, /* o : normalized innovative cb. gain Q16 */
+ const Word32 core_brate /* i : core bitrate */
+);
+
+void encod_unvoiced_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 *speech_fx, /* i : Input speech */
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 *Aq_fx, /* i : 12k8 Lp coefficient */
+ const Word16 vad_flag_fx,
+ const Word16 *res_fx, /* i : residual signal */
+ Word16 *syn_fx, /* o : core synthesis */
+ Word16 *tmp_noise_fx, /* o : long-term noise energy */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 Q_new,
+ const Word16 shift
+);
+
+void transf_cdbk_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 extl, /* i : extension layer */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 harm_flag_acelp, /* i : harmonic flag for higher rates ACELP */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ Word16 cn[], /* i/o: target vector in residual domain */
+ Word16 exc[], /* i/o: pointer to excitation signal frame */
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient */
+ const Word16 Ap[], /* i : weighted LP filter coefficients */
+ const Word16 h1[], /* i : weighted filter input response */
+ Word16 xn[], /* i/o: target vector */
+ Word16 xn2[], /* i/o: target vector for innovation search */
+ Word16 y1[], /* i/o: zero-memory filtered adaptive excitation */
+ const Word16 y2[], /* i : zero-memory filtered innovative excitation */
+ const Word16 Es_pred, /* i : predicited scaled innovation energy */
+ Word16 *gain_pit, /* i/o: adaptive excitation gain */
+ const Word32 gain_code, /* i : innovative excitation gain */
+ Word16 g_corr[], /* o : ACELP correlation values */
+ const Word16 clip_gain, /* i : adaptive gain clipping flag */
+ Word16 *mem_deemp, /* i/o: prequantizer deemhasis memory */
+ Word16 *mem_preemp, /* i/o: prequantizer preemhasis memory */
+ Word16 *gain_preQ, /* o : prequantizer excitation gain */
+ Word16 code_preQ[], /* o : prequantizer excitation */
+ Word16 *unbits, /* o : number of AVQ unused bits */
+ const Word16 Q_new, /* i : Current frame scaling */
+ const Word16 shift /* i : shifting applied to y1, xn,... */
+);
+
+Word16 encod_tran_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 speech_fx[], /* i : input speech */
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 T_op_fx[], /* i : open loop pitch */
+ const Word16 voicing_fx[], /* i : voicing */
+ const Word16 *res_fx, /* i : residual signal */
+ Word16 *syn_fx, /* i/o: core synthesis */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *exc2_fx, /* i/o: current enhanced excitation */
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 *bwe_exc_fx, /* i/o: excitation for SWB TBE */
+ const Word16 gsc_attack_flag, /* i : Flag to indicate when an audio attack is deal with TM */
+ Word16 *unbits, /* i/o: number of unused bits */
+ Word16 sharpFlag, /* o : formant sharpening flag */
+ const Word16 shift, /* i : Scaling to get 12 bits */
+ const Word16 Q_new /* i : Input scaling */
+);
+
+Word16 est_tilt_fx( /* o : tilt of the code Q15 */
+ const Word16 *exc, /* i : adaptive excitation vector Qx */
+ const Word16 gain_pit, /* i : adaptive gain Q14 */
+ const Word16 *code, /* i : algebraic exctitation vector Q9 */
+ const Word32 gain_code, /* i : algebraic code gain Q16 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
+);
+
+Word16 Est_tilt2( /* o : tilt of the code */
+ const Word16 *exc, /* i : adaptive excitation vector Qx */
+ const Word16 gain_pit, /* i : adaptive gain Q14 */
+ const Word16 *code, /* i : algebraic exctitation vector Q9 */
+ const Word32 gain_code, /* i : algebraic code gain Q16 */
+ Word16 *voice_fac, /* o : voicing factor Q15 */
+ const Word16 Q_exc /* i : Scaling factor of excitation Q0 */
+);
+
+void transition_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe index */
+ Word16 *tc_subfr, /* i/o: TC subframe index */
+ Word16 *Jopt_flag, /* i : joint optimization flag */
+ Word16 *position, /* i/o: maximum of residual signal index */
+ const Word16 voicing_fx[], /* i : normalized correlations (from OL pitch) Q15*/
+ const Word16 T_op_fx[], /* i : open loop pitch estimates in current frame Q0*/
+ Word16 *T0, /* i/o: close loop integer pitch Q0*/
+ Word16 *T0_frac, /* i/o: close loop fractional part of the pitch Q0*/
+ Word16 *T0_min, /* i/o: lower limit for close-loop search Q0*/
+ Word16 *T0_max, /* i/o: higher limit for close-loop search Q0*/
+ Word16 *exc_fx, /* i/o: pointer to excitation signal frame Q_new*/
+ Word16 *y1_fx, /* o : zero-memory filtered adaptive excitation Q_new-1+shift*/
+ const Word16 *res_fx, /* i : pointer to the LP residual signal frame Q_new*/
+ const Word16 *h1_fx, /* i : weighted filter input response Q(14+shift)*/
+ const Word16 *xn_fx, /* i : target vector Q_new-1+shift*/
+ Word16 *xn2_fx, /* o : target vector for innovation search Q_new-1+shift*/
+ Word16 *gp_cl_fx, /* i/o: memory of gain of pitch clipping algorithm */
+ Word16 *gain_pit_fx, /* o : adaptive excitation gain Q14*/
+ Word16 *g_corr_fx, /* o : ACELP correlation values */
+ Word16 *clip_gain, /* i/o: adaptive gain clipping flag */
+ Word16 **pt_pitch_fx, /* o : floating pitch values */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE Q_new*/
+ Word16 Q_new, /* i : Current scaling */
+ Word16 shift /* i : downscaling needs for 12 bits convolutions */
+);
+
+Word16 abs_pit_enc_fx( /* o : pitch index */
+ const Word16 fr_steps, /* i : fractional resolution steps (2 or 4) for shortest pitches*/
+ const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */
+ const Word16 T0, /* i : integer pitch lag */
+ const Word16 T0_frac /* i : pitch fraction */
+);
+
+Word16 delta_pit_enc_fx( /* o : pitch index */
+ const Word16 fr_steps, /* i : fractional resolution steps (2 or 4)*/
+ const Word16 T0, /* i : integer pitch lag */
+ const Word16 T0_frac, /* i : pitch fraction */
+ const Word16 T0_min /* i : delta search min */
+);
+
+void set_impulse_fx(
+ const Word16 xn_fx[], /* i : target signal */
+ const Word16 h_orig_fx[], /* i : impulse response of weighted synthesis filter */
+ Word16 exc_fx[], /* o : adaptive codebook excitation */
+ Word16 yy1_fx[], /* o : filtered adaptive codebook excitation */
+ Word16 *imp_shape, /* o : adaptive codebook index */
+ Word16 *imp_pos, /* o : position of the glotal impulse center index */
+ Word32 *gain_trans_fx, /* o : transition gain Q7 */
+ Word16 Q_new /* i : Current scaling */
+);
+
+void pit16k_Q_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 nBits, /* i : # of Q bits */
+ const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */
+ const Word16 T0, /* i : integer pitch lag */
+ const Word16 T0_frac, /* i : pitch fraction */
+ Word16 *T0_min, /* i/o: delta search min */
+ Word16 *T0_max /* o : delta search max */
+);
+
+void gain_enc_amr_wb_fx(
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 *xn, /* i : target vector */
+ const Word16 Q_xn, /* i : xn and yy1 format Q0 */
+ const Word16 *yy1, /* i : zero-memory filtered adaptive excitation */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation */
+ const Word16 *code, /* i : algebraic excitation */
+ const Word32 core_brate, /* i : core bitrate */
+ Word16 *gain_pit, /* i/o: pitch gain / Quantized pitch gain */
+ Word32 *gain_code, /* o : quantized codebook gain */
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) */
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation */
+ Word16 *g_coeff, /* i/o: correlations , -2,, -2 and 2 */
+ const Word16 clip_gain, /* i : gain pitch clipping flag (1 = clipping) */
+ Word16 *past_qua_en /* i/o: gain quantization memory (4 words) */
+);
+
+void gain_enc_lbr_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 *xn, /* i : target vector Q_xn*/
+ const Word16 *y1, /* i : zero-memory filtered adaptive excitation Q_xn*/
+ const Word16 Q_xn, /* i : xn and y1 format */
+ const Word16 *y2, /* i : zero-memory filtered algebraic codebook excitation Q9*/
+ const Word16 *code, /* i : algebraic excitation Q9*/
+ Word16 *gain_pit, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code, /* o : norm. gain of the codebook excitation Q16*/
+ Word16 *g_corr, /* i/o: correlations , -2,, -2 and 2 mant/exp*/
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes */
+ Word16 gp_mem[], /* i/o: gain_pitch from previous subframes */
+ const Word16 clip_gain /* i : gain pitch clipping flag (1 = clipping) */
+);
+
+void gp_clip_test_gain_pit_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 gain_pit, /* i : gain of quantized pitch Q14 */
+ Word16 mem[] /* i/o: memory of gain of pitch clipping algorithm */
+);
+
+void gp_clip_test_lsf_fx(
+ const Word16 lsf[], /* i : lsf values (in frequency domain) */
+ Word16 mem[], /* i/o: memory of gain of pitch clipping algorithm */
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+);
+
+Word16 inov_encode_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 last_L_frame, /* i : length of the last frame */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 sharpFlag, /* i : formant sharpening flag */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 *p_Aq, /* i : LP filter coefficients Q12*/
+ const Word16 gain_pit, /* i : adaptive excitation gain Q14*/
+ Word16 *cn, /* i/o: target vector in residual domain Q_new*/
+ const Word16 *exc, /* i : pointer to excitation signal frame Q_new*/
+ Word16 *h2, /* i/o: weighted filter input response Q12*/
+ const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15*/
+ const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/
+ const Word16 *xn2, /* i : target vector for innovation search Q_new-1+shift*/
+ Word16 *code, /* o : algebraic excitation Q9*/
+ Word16 *y2, /* o : zero-memory filtered algebraic excitation Q9*/
+ Word16 *unbits, /* o : number of unused bits for PI */
+ Word16 shift
+);
+
+Word32 sum2_fx( /* o : sum of all squared vector elements Q(2x+1)*/
+ const Word16 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word32 sum2_fx_mod( /* o : sum of all squared vector elements Q(2x+1)*/
+ const Word16 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word16 usdequant_fx( /* Qx*/
+ const Word16 idx, /* i: quantizer index Q0*/
+ const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word16 delta /* i: quantization step Qy*/
+);
+
+Word16 gain_dequant_fx( /* o: decoded gain */
+ Word16 index, /* i: quantization index */
+ const Word16 min, /* i: value of lower limit */
+ const Word16 max, /* i: value of upper limit */
+ const Word16 bits, /* i: number of bits to dequantize */
+ Word16 *expg
+);
+
+void Es_pred_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8*/
+ const Word16 coder_type, /* i : coder type */
+ const Word32 core_brate /* i : core bitrate */
+);
+
+void gain_dec_tc_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate_fx, /* i : core bitrate */
+ const Word16 *code_fx, /* i : algebraic code excitation */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 i_subfr_fx, /* i : subframe number */
+ const Word16 tc_subfr_fx, /* i : TC subframe index */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ Word16 *gain_pit_fx, /* o : pitch gain */
+ Word32 *gain_code_fx, /* o : Quantized codeebook gain */
+ Word16 *gain_inov_fx, /* o : unscaled innovation gain */
+ Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excit. */
+);
+
+void gain_dec_mless_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate_fx, /* i : core bitrate */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 i_subfr_fx, /* i : subframe number */
+ const Word16 tc_subfr_fx, /* i : TC subframe index */
+ const Word16 *code_fx, /* i : algebraic code excitation */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ Word16 *gain_pit_fx, /* o : Quantized pitch gain Q14*/
+ Word32 *gain_code_fx, /* o : Quantized codeebook gain Q16*/
+ Word16 *gain_inov_fx, /* o : unscaled innovation gain Q12*/
+ Word32 *norm_gain_code_fx /* o : norm. gain of the codebook excitation Q16*/
+);
+
+void pre_echo_att_fx(
+ Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
+ Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
+ const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) */
+ const Word16 Q_new
+ ,const Word16 last_coder_type_fx /* i : Last coding mode */
+);
+
+void gain_dec_lbr_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 *code_fx, /* i : algebraic excitation Q12*/
+ Word16 *gain_pit_fx, /* o : quantized pitch gain Q14*/
+ Word32 *gain_code_fx, /* o : quantized codebook gain Q16*/
+ Word16 *gain_inov_fx, /* o : gain of the innovation (used for normalization) Q12*/
+ Word32 *norm_gain_code_fx, /* o : norm. gain of the codebook excitation Q16*/
+ Word32 gc_mem[], /* i/o: gain_code from previous subframes */
+ Word16 gp_mem[] /* i/o: gain_pitch from previous subframes */
+);
+
+void lp_gain_updt_fx(
+ const Word16 i_subfr, /* i : subframe number Q0 */
+ const Word16 gain_pit, /* i : Decoded gain pitch Q14 */
+ const Word32 norm_gain_code, /* i : Normalised gain code Q16 */
+ Word16 *lp_gainp, /* i/o: LP-filtered pitch gain(FEC) Q14 */
+ Word16 *lp_gainc, /* i/o: LP-filtered code gain (FEC) Q3 */
+ const Word16 L_frame /* i : length of the frame */
+);
+
+void pit_Q_dec_fx(
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 pitch_index, /* i : pitch index */
+ const Word16 nBits, /* i : # of Q bits */
+ const Word16 delta, /* i : Half the CL searched interval */
+ const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */
+ const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */
+ Word16 *T0, /* o : integer pitch lag */
+ Word16 *T0_frac, /* o : pitch fraction */
+ Word16 *T0_min, /* i/o: delta search min */
+ Word16 *T0_max /* i/o: delta search max */
+ ,Word16 *BER_detect /* o : BER detect flag */
+);
+
+void abs_pit_dec_fx(
+ const Word16 fr_steps, /* i: fractional resolution steps (0, 2, 4) */
+ Word16 pitch_index, /* i: pitch index */
+ const Word16 limit_flag, /* i : restrained(0) or extended(1) limits */
+ Word16 *T0, /* o: integer pitch lag */
+ Word16 *T0_frac /* o: pitch fraction */
+);
+
+void limit_T0_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 delta, /* i : Half the close-loop searched interval */
+ const Word16 pit_flag, /* i : selecting absolute(0) or delta(1) pitch quantization */
+ const Word16 limit_flag, /* i : flag for Q limits (0=restrained, 1=extended) */
+ const Word16 T0, /* i : rough pitch estimate around which the search is done */
+ const Word16 T0_frac, /* i : pitch estimate fractional part */
+ Word16 *T0_min, /* o : lower pitch limit */
+ Word16 *T0_max /* o : higher pitch limit */
+);
+
+void delta_pit_dec_fx(
+ const Word16 fr_steps, /* i : fractional resolution steps (0, 2, 4) */
+ const Word16 pitch_index, /* i : pitch index */
+ Word16 *T0, /* o : integer pitch lag */
+ Word16 *T0_frac, /* o : pitch fraction */
+ const Word16 T0_min /* i : delta search min */
+);
+
+Word16 pit_decode_fx( /* o : floating pitch value */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ Word16 i_subfr, /* i : subframe index */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
+ Word16 *T0, /* o : close loop integer pitch */
+ Word16 *T0_frac, /* o : close loop fractional part of the pitch */
+ Word16 *T0_min, /* i/o: delta search min for sf 2 & 4 */
+ Word16 *T0_max, /* i/o: delta search max for sf 2 & 4 */
+ const Word16 L_subfr /* i : subframe length */
+);
+
+void pred_lt4(
+ const Word16 excI[], /* in: excitation buffer */
+ Word16 excO[], /* out: excitation buffer */
+ Word16 T0, /* input : integer pitch lag */
+ Word16 frac, /* input : fraction of lag */
+ Word16 L_subfr, /* input : subframe size */
+ const Word16 *win, /* i : interpolation window */
+ const Word16 nb_coef, /* i : nb of filter coef */
+ const Word16 up_sample /* i : up_sample */
+);
+
+void lp_filt_exc_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 codec_type, /* i : coder type */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 L_subfr, /* i : subframe size */
+ const Word16 L_frame, /* i : frame size */
+ Word16 lp_flag, /* i : operation mode signalling */
+ Word16 *exc
+);
+
+void inov_decode_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 sharpFlag, /* i : formant sharpening flag */
+ const Word16 i_subfr, /* i : subframe index */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 *p_Aq, /* i : LP filter coefficients Q12 */
+ const Word16 tilt_code, /* i : tilt of the excitation of previous subframe Q15 */
+ const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch Q6*/
+ Word16 *code /* o : algebraic excitation */
+);
+
+void dec_acelp_1t64_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 code[] /* o: algebraic (fixed) codebook excitation Q12*/
+);
+
+void dec_acelp_2t32_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 code[] /* o: algebraic (fixed) codebook excitation */
+);
+
+void dec_acelp_4t64_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 nbbits, /* i : number of bits per codebook */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
+ const Word16 Opt_AMR_WB
+);
+
+void weight_a_lc_fx(
+ const Word16 a[], /* i: LP filter coefficients Q12 */
+ Word16 ap[], /* o: weighted LP filter coefficients Q12 */
+ const Word16 *gammatbl, /* i: weighting factor Q15 */
+ const Word16 m /* i: order of LP filter Q0 */
+);
+
+void weight_a_fx(
+ const Word16 a[], /* i: LP filter coefficients Q12 */
+ Word16 ap[], /* o: weighted LP filter coefficients Q12 */
+ const Word16 gamma, /* i: weighting factor Q15 */
+ const Word16 m /* i: order of LP filter Q0 */
+);
+
+void Residu3_lc_fx(
+ const Word16 a[], /* i : prediction coefficients Q12 */
+ const Word16 m, /* i : order of LP filter Q0 */
+ const Word16 x[], /* i : input signal (usually speech) Qx */
+ Word16 y[], /* o : output signal (usually residual) Qx */
+ const Word16 lg, /* i : vector size Q0 */
+ const Word16 shift /* i : 0=residu2, 1=residu */
+);
+
+void Residu3_10_fx(
+ const Word16 a[], /* i : prediction coefficients Q12 */
+ const Word16 x[], /* i : input signal (usually speech) Qx */
+ /* (note that values x[-10..-1] are needed) */
+ Word16 y[], /* o : output signal (usually residual) Qx */
+ const Word16 lg, /* i : vector size Q0 */
+ const Word16 shift /* i : 0=residu2, 1=residu */
+);
+
+void Residu3_fx(
+ const Word16 a[], /* i : prediction coefficients Q12 */
+ const Word16 x[], /* i : input signal (usually speech) Qx */
+ /* (note that values x[-M..-1] are needed) */
+ Word16 y[], /* o : output signal (usually residual) Qx */
+ const Word16 lg, /* i : vector size Q0 */
+ const Word16 shift /* i : 0=residu2, 1=residu */
+);
+
+void pre_exc_fx(
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 *speech, /* i : input speech Q_new-1*/
+ const Word16 *p_Aq, /* i : 12k8 Lp coefficient Q12*/
+ const Word16 *p_A, /* i : unquantized A(q) filter with bandwidth expansion Q12*/
+ const Word16 coder_type, /* i : coding type */
+ const Word16 i_subfr, /* i : current sub frame indicator */
+ Word16 *Ap, /* o : weighted LP filter coefficients Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ Word16 *exc, /* o : excitation signal Q_new*/
+ Word16 *h1, /* o : impulse response of weighted synthesis filter Q(14+shift)*/
+ Word16 *h2, /* o : impulse response of weighted synthesis filter Q(12+shift), for codebook search*/
+ Word16 *xn, /* o : close-loop Pitch search target vector Q_new-1+shift*/
+ Word16 *cn, /* o : target vector in residual domain Q_new*/
+ Word16 *mem_syn, /* i/o: memory of the synthesis filter Q_new-1*/
+ Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
+ const Word16 L_subfr, /* i : subframe length */
+ Word16 shift
+);
+
+void encod_audio_fx(
+ Encoder_State_fx *st_fx, /* i/o: State structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 speech[], /* i : input speech Q_new */
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ const Word16 T_op[], /* i : open loop pitch */
+ const Word16 voicing[], /* i : voicing Q15 */
+ const Word16 *res, /* i : residual signal Q_new */
+ Word16 *synth, /* i/o: core synthesis Q-1 */
+ Word16 *exc, /* i/o: current non-enhanced excitation Q_new */
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe Q6 */
+ Word16 *voice_factors, /* o : voicing factors Q15 */
+ Word16 *bwe_exc, /* o : excitation for SWB TBE Q0 */
+ const Word16 gsc_attack_flag, /* i : Flag that point to an attack coded with AC mode (GSC) */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *lsf_new, /* i : current frame ISF vector */
+ Word16 *tmp_noise, /* o : noise energy */
+ Word16 Q_new,
+ Word16 shift
+);
+
+Word16 pit_encode_fx( /* o : Fractional pitch for each subframe */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *limit_flag, /* i/o: restrained(0) or extended(1) Q limits */
+ const Word16 i_subfr, /* i : subframe index */
+ Word16 *exc, /* i/o: pointer to excitation signal frame */
+ const Word16 L_subfr, /* i : subframe length */
+ const Word16 *T_op, /* i : open loop pitch estimates in current frame */
+ Word16 *T0_min, /* i/o: lower limit for close-loop search */
+ Word16 *T0_max, /* i/o: higher limit for close-loop search */
+ Word16 *T0, /* i/o: close loop integer pitch */
+ Word16 *T0_frac, /* i/o: close loop fractional part of the pitch */
+ const Word16 *h1, /* i : weighted filter input response */
+ const Word16 *xn /* i : target vector */
+);
+
+Word32 dotp_fx( /* o : dot product of x[] and y[] */
+ const Word16 x[], /* i : vector x[] */
+ const Word16 y[], /* i : vector y[] */
+ const Word16 n, /* i : vector length */
+ Word16 * exp /* (o) : exponent of result (0..+30) */
+);
+
+Word32 syn_kern_16(
+ Word32 L_tmp,
+ const Word16 a[],
+ const Word16 y[]
+);
+
+void syn_filt_s_lc_fx(
+ const Word16 shift, /* i : scaling to apply Q0 */
+ const Word16 a[], /* i : LP filter coefficients Q12 */
+ const Word16 x[], /* i : input signal Qx */
+ Word16 y[], /* o : output signal Qx-s */
+ const Word16 lg /* i : size of filtering Q0 */
+);
+
+void acelp_2t32_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 dn[], /* i : corr. between target and h[]. */
+ const Word16 h[], /* i : impulse response of weighted synthesis filter */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation */
+ Word16 y[] /* o : filtered fixed codebook excitation */
+);
+
+Word16 acelp_4t64_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 dn[], /* i : corr. between target and h[]. */
+ const Word16 cn[], /* i : residual after long term prediction Q_new*/
+ const Word16 H[], /* i : impulse response of weighted synthesis filter Q12*/
+ Word16 R[], /* i : autocorrelation values */
+ const Word16 acelpautoc, /* i : autocorrealtion flag */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation Q9*/
+ Word16 y[], /* o : filtered fixed codebook excitation Q9*/
+ Word16 nbbits, /* i : number of bits per codebook */
+ const Word16 cmpl_flag, /* i : coomplexity reduction flag */
+ const Word16 Opt_AMR_WB /* i : flag indicating AMR-WB IO mode */
+);
+
+void acelp_1t64_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 dn[], /* i : corr. between target and h[]. */
+ const Word16 h[], /* i : impulse response of weighted synthesis filter */
+ Word16 code[], /* o : algebraic (fixed) codebook excitation */
+ Word16 y[] /* o : filtered fixed codebook excitation */
+);
+
+void cb_shape_fx(
+ const Word16 preemphFlag, /* i : flag for pre-emphasis */
+ const Word16 pitchFlag, /* i : flag for pitch sharpening */
+ const Word16 scramblingFlag, /* i : flag for phase scrambling */
+ const Word16 sharpFlag, /* i : flag for formant sharpening */
+ const Word16 formantTiltFlag, /* i : flag for formant tilt */
+ const Word16 g1, /* i : formant sharpening numerator weighting */
+ const Word16 g2, /* i : formant sharpening denominator weighting */
+ const Word16 *p_Aq, /* i : LP filter coefficients */
+ Word16 *code, /* i/o: signal to shape */
+ const Word16 tilt_code, /* i : tilt of code */
+ const Word16 pt_pitch, /* i : pointer to current subframe fractional pitch */
+ const Word16 shift
+);
+
+void corr_xh_fx(
+ const Word16 x[], /* i : target signal */
+ Word16 dn[], /* o : correlation between x[] and h[] */
+ const Word16 h[] /* i : impulse response (of weighted synthesis filter) */
+);
+
+void corr_xh_jopt_fx(
+ const Word16 h[], /* i : impulse response of weighted synthesis filter Q12 */
+ const Word16 x[], /* i : target vector Q0 */
+ Word16 dn[], /* o : correlation between target and h[] Q12 */
+ Word16 gain, /* i : Unquantized ACB gain Q14 */
+ Word16 clip, /* i : clip Q0 */
+ Word16 shift /* i : scaling of x Q0 */
+);
+
+void enhancer_fx(
+ const Word32 core_brate, /* i : decoder bitrate */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 i_subfr, /* i : subframe number */
+ const Word16 L_frame, /* i : frame size */
+ const Word16 voice_fac, /* i : subframe voicing estimation Q15 */
+ const Word16 stab_fac, /* i : LP filter stablility measure Q15 */
+ Word32 norm_gain_code,/* i : normalised innovative cb. gain Q16 */
+ const Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */
+ Word32 *gc_threshold, /* i/o: gain code threshold Q16 */
+ Word16 *code, /* i/o: innovation Q12 */
+ Word16 *exc2, /* i/o: adapt. excitation/total exc. Q_exc*/
+ const Word16 gain_pit, /* i : quantized pitch gain Q14 */
+ struct dispMem_fx *dm_fx, /* i/o: phase dispersion algorithm memory */
+ const Word16 Q_exc /* i : Q of the excitation */
+);
+
+Word16 Rescale_exc(
+ Word16 dct_post_old_exc_fx[], /* i/o: Music post processing memory */
+ Word16 exc[], /* i/o: excitation to rescale Q_exc */
+ Word16 bwe_exc[],
+ Word16 *last_exc_dct_in,
+ Word16 lg, /* i : frame size */
+ Word16 lg32,
+ Word32 L_gain_code, /* i : decoded codebook gain Q16 */
+ Word16 *sQ_exc, /* i/o: Excitation scaling factor */
+ Word16 *sQsubfr, /* i/o: Past excitation scaling factors */
+ Word16 exc2[], /* o : local excitation vector */
+ Word16 i_subfr, /* i : subframe number */
+ const Word16 coder_type
+);
+
+void Prep_music_postP_fx(
+ Word16 exc_buffer_in[], /* i/o: excitation buffer Q_exc*/
+ Word16 dct_buffer_out[], /* o : DCT output buffer (qdct)*/
+ Word16 filt_lfE[], /* i/o: long term spectrum energy Q15 */
+ const Word16 last_core, /* i : last core */
+ const Word16 *pitch_buf, /* i : current frame pitch information Q6*/
+ Word16 *LDm_enh_lp_gbin, /* o : smoothed suppression gain, per bin FFT Q15*/
+ const Word16 Q_exc, /* i : excitation scaling */
+ Word16 *qdct /* o : Scaling factor of dct coefficient */
+);
+
+void Post_music_postP_fx(
+ Word16 dct_buffer_in[], /* i/o: excitation buffer */
+ Word16 *exc2, /* i/o: Current excitation to be overwriten */
+ const Word16 *mem_tmp, /* i : previous frame synthesis memory */
+ Word16 *st_mem_syn2, /* i/o: current frame synthesis memory */
+ const Word16 *Aq, /* i : LPC filter coefficients */
+ Word16 *syn, /* i/o: 12k8 synthesis */
+ Word16 *Q_exc, /* i : excitation scaling */
+ Word16 *prev_Q_syn, /* i : previsous frame synthesis scaling */
+ Word16 *Q_syn, /* i : Current frame synthesis scaling */
+ Word16 *mem_syn_clas_estim_fx, /* i : old 12k8 synthesis used for frame classification*/
+ const Word16 IsIO, /* i: Flag to indicate IO mode */
+ Word16 *mem_deemph, /* i/o: speech deemph filter memory */
+ Word16 *st_pst_old_syn_fx, /* i/o: psfiler */
+ Word16 *st_pst_mem_deemp_err_fx, /* i/o: psfiler */
+ Word16 *mem_agc,
+ PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */
+ const Word16 *tmp_buffer /* tmp_buffer in Q-1 */
+ ,Word16 *mem_tmp2 /* Temporary memory used with scale_syn */
+);
+
+void unscale_AGC(
+ const Word16 x[],
+ const Word16 Qx,
+ Word16 y[],
+ Word16 mem[],
+ const Word16 n
+);
+
+void LD_music_post_filter_fx(
+ const Word16 dtc_in[], /* i : input synthesis Qdct */
+ Word16 dtc_out[], /* o : output synthesis Qdct */
+ const Word32 core_brate, /* i : core bitrate Q0 */
+ Word16 *last_music_flag, /* i/o : Previous music detection ouptut Q0 */
+ Word16 *thresh, /* i/o : Detection thresold Q0 */
+ Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 Q0 */
+ Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 Q0 */
+ Word16 *lt_diff_etot, /* i/o : Long term total energy variation Q8 */
+ Word16 *mem_etot, /* i/o : Total energy memory Q8 */
+ const Word16 min_ns_gain, /* i : minimum gain for inter-harm noise red. Q15 */
+ Word32 bckr[], /* i/o : per band bckgnd. noise energy estimate */
+ Word32 lf_EO[], /* i/o : old per bin E for previous half frame 2*Qdct+10 */
+ Word16 lp_gbin[], /* i/o : smoothed suppression gain, per FFT bin Q15 */
+ Word16 *filt_lfE, /* i : post filter weighting coefficient Q15 */
+ Word16 *last_nonfull_music, /* i : Number of frames sinces la "speech like" frame Q0*/
+ Word16 *Old_ener_Q, /* i/o : Old energy scaling factor */
+ const Word16 coder_type, /* i : Coder type : -1 in case of IO Q0 */
+ const Word16 Last_coder_type, /* i : input scaling Q0 */
+ const Word16 Qdct /* i : input scaling Q0 */
+);
+
+void Rescale_mem(
+ const Word16 Q_exc, /* i : current excitation scaling (>=0) */
+ Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */
+ Word16 *Q_syn, /* i/o : scaling factor of frame */
+ Word16 *mem_syn2, /* i/o : modified synthesis memory */
+ Word16 *mem_syn_clas_estim_fx, /* i/o : old 12k8 core memory for classification */
+ const Word16 MaxScaling, /* i: Minimal difference between excitation scaling and synthesis scaling */
+ Word16 *mem_deemph, /* i/o: speech deemph filter memory */
+ Word16 *pst_old_syn, /* i/o: psfiler */
+ Word16 *pst_mem_deemp_err, /* i/o: psfiler */
+ Word16 *mem_agc,
+ PFSTAT *pf_stat, /* i/o: All memories related to NB post filter */
+ const Word16 Vad_flag,
+ const Word16 Cna_flag,
+ const Word16 *tmp_buffer /* tmp_buffer in Q-1 */
+);
+
+void Scale_sig(
+ Word16 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void isf2lsf_fx(
+ const Word16 *isf, /* i : ISF vector */
+ Word16 *lsf, /* o : LSF vector */
+ Word16 *stable_lsp /* i/o: stable LSP filter coefficients */
+);
+
+void isp2lsp_fx(
+ const Word16 *isp, /* i : LSP vector */
+ Word16 *lsp, /* o : ISP filter coefficients */
+ Word16 *stable_lsp, /* i/o: stable LSP filter coefficients */
+ const Word16 m /* i : order of LP analysis */
+);
+
+void lsf2isf_fx(
+ const Word16 *lsf, /* i : LSF vector */
+ Word16 *isf, /* o : ISF vector */
+ Word16 *stable_isp, /* i/o: stable ISP filter coefficients */
+ const Word16 m /* i : order of LP analysis */
+);
+
+void lsp2isp_fx(
+ const Word16 *lsp, /* i : LSP vector */
+ Word16 *isp, /* o : ISP filter coefficients */
+ Word16 *stable_isp, /* i/o: ISP filter coefficients */
+ const Word16 m /* i : order of LP analysis */
+);
+
+void updt_IO_switch_dec_fx(
+ const Word16 output_frame, /* i : output frame length */
+ Decoder_State_fx *st_fx /* o : Decoder static variables structure */
+);
+
+void prep_tbe_exc_fx(
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 i_subfr_fx, /* i : subframe index */
+ const Word16 gain_pit_fx, /* i : Pitch gain Q14*/
+ const Word32 gain_code_fx, /* i : algebraic codebook gain 16+Q_exc*/
+ const Word16 code_fx[], /* i : algebraic excitation Q9*/
+ const Word16 voice_fac_fx, /* i : voicing factor Q15*/
+ Word16 *voice_factors_fx, /* o : TBE voicing factor Q15*/
+ Word16 bwe_exc_fx[], /* i/o: excitation for TBE Q_exc*/
+ const Word16 gain_preQ_fx, /* i : prequantizer excitation gain */
+ const Word16 code_preQ_fx[], /* i : prequantizer excitation */
+ const Word16 Q_exc, /* i : Excitation, bwe_exc Q-factor */
+ Word16 T0, /* i : integer pitch variables Q0 */
+ Word16 T0_frac, /* i : Fractional pitch variables Q0*/
+ const Word16 coder_type, /* i : coding type */
+ Word32 core_brate /* i :core bitrate */
+);
+
+void interp_code_5over2_fx(
+ const Word16 inp_code[], /* i : input vector */
+ Word16 interp_code[], /* o : output vector */
+ const Word16 inp_length /* i : length of input vector */
+);
+
+void lsp2lsf_fx(
+ const Word16 lsp[], /* i : lsp[m] (range: -1<=val<1) Q15*/
+ Word16 lsf[], /* o : lsf[m] normalized (range: 0.0<=val<=0.5) Q(x2.56)*/
+ const Word16 m, /* i : LPC order Q0*/
+ Word32 int_fs
+);
+
+void lsf_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *lsf_new, /* o : quantized LSF vector */
+ Word16 *lsp_new, /* i/o: LSP vector to quantize/quantized */
+ Word16 *lsp_mid, /* i/o : mid-frame LSP vector */
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes */
+ Word16 *stab_fac, /* o : LSF stability factor */
+ const Word16 Nb_ACELP_frames,
+ const Word16 Q_new
+);
+
+void lsf_mid_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 int_fs, /* i : internal (ACELP) sampling frequency */
+ Word16 qlsp0[], /* i : quantized LSPs from frame beginning Q15*/
+ Word16 qlsp1[], /* i : quantized LSPs from frame endSQ15*/
+ Word16 coder_type, /* i : Coder type */
+ Word16 qlsp[], /* o : quantized LSPs Q15*/
+ const Word32 core_brate, /* i : core bitrate */
+ Word16 ppp_mode,
+ Word16 nelp_mode,
+ Word16 prev_bfi,
+ Word16 *mid_lsf_int,
+ Word16 safety_net
+);
+
+Word16 lsf_stab_fx( /* o : LP filter stability Q15*/
+ const Word16 *lsf, /* i : LSF vector Q(x2.56)*/
+ const Word16 *lsfold, /* i : old LSF vector Q(x2.56)*/
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 L_frame /* i : frame length */
+);
+
+void lsf_allocate_fx(
+ const Word16 nBits, /* i : Number of bits to use for quantization */
+ const Word16 framemode, /* i : ISF quantizer mode */
+ const Word16 framemode_p, /* i : ISF quantizer mode predmode (mode_lvq_p) */
+ Word16 *stages0, /* o : Number of stages for safety-net quantizer */
+ Word16 *stages1, /* o : Number of stages for predictive quantizer */
+ Word16 levels0[], /* o : Number of vectors for each stage for SFNET */
+ Word16 levels1[], /* o : Number of vectors for each stage for pred */
+ Word16 bits0[], /* o : Number of bits for each stage safety net */
+ Word16 bits1[] /* o : Number of bits for each stage pred */
+);
+Word16 vq_dec_lvq_fx (
+ Word16 sf_flag, /* i : safety net flag */
+ Word16 x[], /* o : Decoded vector Q(x2.56)*/
+ Word16 indices[], /* i : Indices */
+ Word16 stages, /* i : Number of stages */
+ Word16 N, /* i : Vector dimension */
+ Word16 mode, /* (i): mode_lvq, or mode_lvq_p */
+ Word16 no_bits, /* (i): no. bits for lattice */
+ Word32 *p_offset_scale1,
+ Word32 *p_offset_scale2,
+ Word32 *p_offset_scale1_p,
+ Word32 *p_offset_scale2_p,
+ Word16 *p_no_scales,
+ Word16 *p_no_scales_p
+);
+
+Word16 qlsf_ARSN_tcvq_Dec_16k_fx (
+ Word16 *y_fx, /* o : Quantized LSF vector */
+ Word16 *indice, /* i : Indices */
+ const Word16 nBits /* i : number of bits */
+);
+
+void tcvq_Dec_fx(Word16 *ind,
+ /*float *d_out, */
+ Word16 *d_out_fx,
+ Word16 safety_net
+ );
+
+Word32 qlsf_ARSN_tcvq_Enc_16k_fx(
+ const Word16 *x_fx, /* i : Vector to be encoded x2.65 */
+ Word16 *y_fx, /* o : Quantized LSF vector x2.65 */
+ Word16 *indice, /* o : Indices */
+ const Word16 *w_fx, /* i : LSF Weights Q10 */
+ const Word16 nBits, /* i : number of bits */
+ Word16 safety_net /* i : safety_net flag */
+);
+
+void Vr_add(
+ const Word16 *in1, /* i : Input vector 1 */
+ const Word16 *in2, /* i : Input vector 2 */
+ Word16 *out, /* o : Output vector that contains vector 1 + vector 2 */
+ Word16 Len /* i : Vector lenght */
+);
+
+void Vr_subt(
+ const Word16 *in1, /* i : Input vector 1 */
+ const Word16 *in2, /* i : Input vector 2 */
+ Word16 *out, /* o : Output vector that contains vector 1 + vector 2 */
+ Word16 Len /* i : Vector lenght */
+);
+
+void index_lvq_fx (
+ Word16 *quant, /* i : codevector to be indexed (2 8-dim subvectors) Q13*/
+ Word16 *idx_lead, /* i : leader class index for each subvector */
+ Word16 *idx_scale, /* i : scale index for each subvector */
+ Word16 mode, /* i : integer signalling the quantizer structure for the current bitrate */
+ Word16 *index, /* o : encoded index (represented on 3 short each with 15 bits ) */
+ Word32 * p_offset_scale1,
+ Word32 * p_offset_scale2,
+ Word16 * p_no_scales
+);
+
+void multiply32_32_64_fx(
+ Word32 x,
+ Word32 y,
+ Word32 *res
+);
+
+void permute_fx(
+ Word16 *pTmp1, /* i/o: vector whose components are to be permuted */
+ const Word16 *perm /* i : permutation info (indexes that should be interchanged), max two perms */
+);
+
+Word32 mslvq_fx (
+ Word16 *pTmp, /* i : M-dimensional input vector */
+ Word16 *quant, /* o : quantized vector */
+ Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) */
+ Word16 *idx_lead, /* o : leader index for each 8-dim subvector */
+ Word16 *idx_scale, /* o : scale index for each subvector */
+ Word16 *w, /* i : weights for LSF quantization */
+ Word16 mode, /* i : number indicating the coding type (V/UV/G...)*/
+ Word16 mode_glb, /* i : LVQ coding mode */
+ Word16 pred_flag, /* i : prediction flag (0: safety net, 1 - predictive )*/
+ Word16 no_scales[][2]
+);
+
+Word32 mslvq_cng_fx (
+ Word16 idx_cv, /* i : index of cv from previous stage */
+ Word16 *pTmp, /* i : 16 dimensional input vector x2.56*/
+ Word16 *quant, /* o : quantized vector x2.56*/
+ Word16 *cv_out, /* o : corresponding 8-dim lattice codevectors (without the scaling) Q13*/
+ Word16 *idx_lead, /* o : leader index for each 8-dim subvector */
+ Word16 *idx_scale, /* o : scale index for each subvector */
+ const Word16 *w, /* i : weights for LSF quantization Q10*/
+ Word16 * no_scales
+);
+
+void sort_fx(
+ Word16 *r, /* i/o: Vector to be sorted in place */
+ Word16 lo, /* i : Low limit of sorting range */
+ Word16 up /* I : High limit of sorting range */
+);
+
+void lsf_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: State structure */
+ const Word16 tc_subfr, /* i : TC subframe index */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ Word16 *Aq, /* o : quantized A(z) for 4 subframes */
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode */
+ Word16 *lsf_new, /* o : de-quantized LSF vector */
+ Word16 *lsp_new, /* o : de-quantized LSP vector */
+ Word16 *lsp_mid /* o : de-quantized mid-frame LSP vector */
+);
+
+void lsf_end_enc_fx(
+ Encoder_State_fx *st,
+ const Word16 *lsf,
+ Word16 *qlsf,
+ Word16 *mem_AR,
+ Word16 * mem_MA,
+ const Word16 nBits,
+ const Word16 coder_type_org,
+ const Word16 bwidth,
+ Word32 *Bin_Ener,
+ Word16 Q_ener,
+ const Word32 int_fs,
+ Word32 core_brate,
+ Word16 *streaklimit,
+ Word16 *pstreaklen,
+ Word16 force_sf,
+ Word16 RF_flag,
+ Word16 mode2_flag,
+ Word16 * lpc_param,
+ Word16 * no_stages,
+ Word16 * bits_param_lpc,
+ Word16 coder_type_raw
+);
+
+void lsf_end_dec_fx(
+ Decoder_State_fx *st,
+ Word16 mode2_flag,
+ const Word16 coder_type_org,
+ const Word16 bwidth,
+ const Word16 nBits,
+ Word16 *qlsf,
+ Word16 *mem_AR,
+ Word16 *mem_MA,
+ const Word32 int_fs,
+ Word32 core_brate,
+ Word32 *p_offset_scale1,
+ Word32 *p_offset_scale2,
+ Word32 *p_offset_scale1_p,
+ Word32 *p_offset_scale2_p,
+ Word16 *p_no_scales,
+ Word16 *p_no_scales_p,
+ Word16 *safety_net,
+ Word16 *lpc_param,
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode */
+ Word16 * nb_indices
+);
+
+Word16 find_pred_mode(
+ const Word16 coder_type,
+ const Word16 bwidth,
+ const Word32 int_fs,
+ Word16 * p_mode_lvq,
+ Word16 * p_mode_lvq_p,
+ Word32 core_brate
+);
+
+Word16 xsf_to_xsp(
+ Word16 lsf
+);
+
+Word16 xsp_to_xsf(
+ Word16 lsp
+);
+
+void int_lsp4_fx(
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 lsp_old[], /* i : LSPs from past frame Q15*/
+ const Word16 lsp_mid[], /* i : LSPs from mid-frame Q15*/
+ const Word16 lsp_new[], /* i : LSPs from present frame Q15*/
+ Word16 *Aq, /* o : LP coefficients in both subframes Q12*/
+ const Word16 m, /* i : order of LP filter */
+ Word16 relax_prev_lsf_interp /* i : relax prev frame lsf interp after erasure */
+);
+
+Word16 modify_Fs_fx( /* o : length of output Q0 */
+ const Word16 sigIn_fx[], /* i : signal to decimate Q0 */
+ Word16 lg, /* i : length of input Q0 */
+ const Word32 fin, /* i : frequency of input Q0 */
+ Word16 sigOut_fx[], /* o : decimated signal Q0 */
+ const Word32 fout, /* i : frequency of output Q0 */
+ Word16 mem_fx[], /* i/o: filter memory Q0 */
+ const Word16 nblp /* i : flag indicating if NB low-pass is applied */
+);
+
+void addBassPostFilterFx(
+ const Word16 *harm_timeIn_Fx,
+ Word32 **rAnalysis_Fx,
+ Word32 **iAnalysis_Fx,
+ HANDLE_CLDFB_FILTER_BANK cldfbBank_bpf_Fx,
+ Word32 *workBuffer,
+ const Word16 timeIn_e,
+ const Word16 nTimeSlots,
+ const Word16 nTimeSlotsTotal,
+ const Word16 nBandsTotal,
+ CLDFB_SCALE_FACTOR *cldfb_scale
+);
+
+void bass_psfilter_fx(
+ const Word16 Opt_AMR_WB, /* i : AMR-WB IO flag */
+ Word16 synth_in_fx[], /* i : input synthesis (at 16kHz) */
+ const Word16 L_frame, /* i : length of the last frame */
+ Word16 pitch_buf_fx[], /* i : pitch for every subfr [0,1,2,3] */
+ Word16 old_syn_fx[], /* i/o: NBPSF_PIT_MAX */
+ Word16 *mem_deemph_err, /* o : Error deemphasis memory */
+ Word16 *lp_ener, /* o : long_term error signal energy */
+ const Word16 bpf_off, /* i : do not use BPF when set to 1 */
+ Word16 v_stab_fx, /* i : stability factor */
+ Word16 *v_stab_smooth_fx, /* i/o: smoothed stability factor */
+ Word16 *mem_mean_pit, /* i/o: average pitch memory */
+ Word16 *Track_on_hist, /* i/o: History of half frame usage */
+ Word16 *vibrato_hist, /* i/o: History of frames declared as vibrato*/
+ Word16 *psf_att, /* i/o: Post filter attenuation factor */
+ const Word16 coder_type, /* i : coder_type */
+ Word16 Q_syn,
+ Word16 bpf_noise_buf[] /* o : BPF error signal (at int_fs) */
+);
+
+void speech_music_classif_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ Word16 *sp_aud_decision0,
+ Word16 *sp_aud_decision1, /* o : 1st stage speech/music */
+ Word16 *sp_aud_decision2, /* o : 2nd stage speech/music */
+ const Word16 *new_inp, /* i : new input signal */
+ const Word16 *inp, /* i : input signal to locate attach position */
+ const Word16 vad_flag,
+ const Word16 localVAD,
+ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
+ const Word16 pitch[3], /* i : open-loop pitch estimate in three subframes */
+ const Word16 voicing[3], /* i : voicing estimate in three subframes Q15 */
+ const Word16 lsp_new[M], /* i : LSPs in current frame Q15 */
+ const Word16 cor_map_sum, /* i : correlation map sum (from multi-harmonic anal.)Q8*/
+ const Word32 epsP[M+1], /* i : LP prediciton error Q_esp*/
+ const Word32 PS[], /* i : energy spectrum Q_new+QSCALE*/
+ const Word16 Etot, /* i : total frame energy Q8 */
+ const Word16 old_cor, /* i : max correlation from previous frame Q15 */
+ Word16 *coder_type, /* i/o: coding type */
+ Word16 *attack_flag, /* o : flag to indicate if attack is to be treated by TC or GSC */
+ Word16 non_sta, /* i : unbound non-stationarity for sp/mus classifier */
+ Word16 relE, /* i : relative frame energy */
+ Word16 Q_esp, /* i : scaling of esP */
+ Word16 Q_inp /* i : scaling of input */
+ ,Word16 *high_lpn_flag_ptr /* o : noise log prob flag for NOISE_EST */
+ ,Word16 flag_spitch /* i: flag to indicate very short stable pitch */
+);
+
+Word32 sub_lsp2lsf_fx(
+ const Word16 lsp_i /* i : lsp[m] (range: -1<=val<1) Q15*/
+);
+Word16 lsp_convert_poly_fx(
+ Word16 w[], /* i/o: LSP or ISP parameters */
+ const Word16 L_frame, /* i : flag for up or down conversion */
+ const Word16 Opt_AMRWB /* i : flag for the AMR-WB IO mode */
+);
+
+void StableHighPitchDetect_fx(
+ Word16 *flag_spitch, /* o : flag to indicate very short stable pitch */
+ Word16 pitch[], /* i/o: OL pitch buffer */
+ const Word16 voicing[], /* i : OL pitch gains */
+ const Word16 wsp[], /* i : weighted speech */
+ const Word16 localVAD,
+ Word16 *voicing_sm, /* i/o: smoothed open-loop pitch gains */
+ Word16 *voicing0_sm, /* i/o: smoothed high pitch gains */
+ Word16 *LF_EnergyRatio_sm, /* i/o: smoothed [0, 300Hz] relative peak energy*/
+ Word16 *predecision_flag, /* i/o: predecision flag */
+ Word32 *diff_sm, /* i/o: smoothed pitch frequency difference */
+ Word32 *energy_sm , /* i/o: smoothed energy around pitch frequency */
+ Word16 Q_new,
+ Word16 EspecdB[]
+);
+
+void Es_pred_enc_fx(
+ Word16 *Es_pred, /* o : predicited scaled innovation energy Q8 */
+ Word16 *indice, /* o : indice of quantization */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 *res, /* i : residual signal */
+ const Word16 *voicing, /* i : normalized correlation in three 1/2frames */
+ const Word16 nb_bits, /* i : allocated number of bits */
+ const Word16 no_ltp, /* i : no_ltp flag */
+ Word16 Q_new /* i : Scaling in speech Q0 */
+);
+
+void calc_residu_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ const Word16 *speech, /* i : weighted speech signal */
+ Word16 *res, /* o : residual signal */
+ const Word16 *p_Aq, /* i : quantized LP filter coefficients */
+ const Word16 vad_hover_flag,
+ const Word16 vad_flag_dtx
+);
+void updt_IO_switch_enc_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ const Word16 input_frame /* i : input frame length */
+);
+/*-------------------------------------------------------------------*
+ * pre_proc()
+ *
+ * Pre-processing (spectral analysis, LP analysis, VAD, OL pitch calculation, coder mode selection, ...)
+ *--------------------------------------------------------------------*/
+
+void pre_proc_fx(
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 input_frame, /* i : frame length */
+ const Word16 signal_in[], /* i : new samples */
+ Word16 old_inp_12k8[], /* i/o: buffer of old input signal */
+ Word16 old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */
+ Word16 **inp, /* o : ptr. to inp. signal in the current frame */
+ Word16 *sp_aud_decision1, /* o : 1st stage speech/music classification */
+ Word16 *sp_aud_decision2, /* o : 2nd stage speech/music classification */
+ Word32 fr_bands[2*NB_BANDS], /* o : energy in frequency bands */
+ Word16 *vad_flag,
+ Word16 *localVAD,
+ Word16 *Etot, /* o : total energy */
+ Word32 *ener, /* o : residual energy from Levinson-Durbin */
+ Word16 pitch[3], /* o : open-loop pitch values for quantiz. */
+ Word16 voicing[3], /* o : OL maximum normalized correlation */
+ Word16 A[NB_SUBFR16k*(M+1)], /* o : A(z) unquantized for the 4 subframes */
+ Word16 Aw[NB_SUBFR16k*(M+1)], /* o : weighted A(z) unquantized for subframes */
+ Word16 epsP_h[M+1], /* o : LP prediction errors */
+ Word16 epsP_l[M+1], /* o : LP prediction errors */
+ Word32 epsP[M+1], /* o : LP prediction errors */
+ Word16 lsp_new[M], /* o : LSPs at the end of the frame */
+ Word16 lsp_mid[M], /* o : LSPs in the middle of the frame */
+ Word16 *coder_type, /* o : coder type */
+ Word16 *sharpFlag, /* o : formant sharpening flag */
+ Word16 *vad_hover_flag,
+ Word16 *attack_flag, /* o : flag signalling attack encoded by AC mode (GSC) */
+ Word16 *new_inp_resamp16k, /* o : new input signal @16kHz, non pre-emphasised, used by the WB TBE/BWE */
+ Word16 *Voicing_flag, /* o : voicing flag for HQ FEC */
+
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb real buffer */
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i/o : cldfb imag buffer */
+ CLDFB_SCALE_FACTOR *cldfbScale, /* o : cldfb scale */
+ Word16 *old_exc, /* i/o: static excitation memory */
+ Word16 *hq_core_type, /* o : HQ core type */
+ Word16 *Q_new,
+ Word16 *shift,
+ Word16 *Q_r
+);
+
+Word16 mdct_classifier_fx( /* o: MDCT A/B decision */
+ const Word16 *Y, /* i: re[0], re[1], ..., re[n/2], im[n/2 - 1], im[n/2 - 2], ..., im[1] */
+ Encoder_State_fx *st_fx, /* i/o: Encoder state variable */
+ Word16 vadflag
+ ,Word32 *cldfbBuf_Ener
+ ,Word16 enerBuffer_exp
+);
+
+void floating_point_add(
+ Word32 *mx, /* io: mantissa of the addend Q31 */
+ Word16 *ex, /* io: exponent of the addend Q0 */
+ const Word32 my, /* i: mantissa of the adder Q31 */
+ const Word16 ey /* i: exponent of the adder Q0 */
+);
+
+void MDCT_selector(
+ Encoder_State_fx *st /* i/o: Encoder State */
+ , Word16 sp_floor /* i : Noise floor estimate Q7 */
+ , Word16 Etot /* i : Total energy Q8 */
+ , Word16 cor_map_sum /* i : harmonicity factor Q8 */
+ , const Word16 voicing[] /* i : voicing factors Q15*/
+ , const Word32 enerBuffer[] /* i : CLDFB buffers */
+ , Word16 enerBuffer_exp /* i : exponent of enerBuffer */
+ , Word16 vadflag
+);
+
+void MDCT_selector_reset(
+ Encoder_State_fx *st); /* i/o: Encoder State */
+
+Word16 minimum_fx( /* o : index of the minimum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx, /* i : length of input vector */
+ Word16 *min_fx /* o : minimum value in the input vector */
+);
+Word16 minimum_32_fx( /* o : index of the minimum value in the input vector */
+ const Word32 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx, /* i : length of input vector */
+ Word32 *min_fx /* o : minimum value in the input vector */
+);
+Word16 maximum_32_fx( /* o : index of the maximum value in the input vector */
+ const Word32 *vec, /* i : input vector */
+ const Word16 lvec, /* i : length of input vector */
+ Word32 *max /* o : maximum value in the input vector */
+);
+Word16 maximum_fx( /* o : index of the maximum value in the input vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx, /* i : length of input vector */
+ Word16 *max_fx /* o : maximum value in the input vector */
+);
+Word16 Exp32Array(
+ const Word16 n, /* (i): Array size */
+ const Word32 *sx /* (i): Data array */
+);
+Word16 Exp16Array(
+ const Word16 n, /* (i): Array size */
+ const Word16 *sx /* (i): Data array */
+);
+
+Word32 sum16_32_fx( /* o : sum of all vector elements Qx*/
+ const Word16 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+Word32 dot_product_mat_fx( /* o : the dot product x'*A*x */
+ const Word16 *x, /* i : vector x Q15 */
+ const Word32 *A, /* i : matrix A Q0*/
+ const Word16 m /* i : vector & matrix size */
+
+);
+
+Word16 std_fx( /* o: standard deviation */
+ const Word16 *x, /* i: input vector */
+ const Word16 len /* i: length of the input vector */
+);
+
+Word16 stab_est_fx(
+ Word16 etot, /* i : Total energy of the current frame */
+ Word16 *lt_diff_etot, /* i/o : Long term total energy variation */
+ Word16 *mem_etot, /* i/o : Total energy memory */
+ Word16 *nb_thr_3, /* i/o : Number of consecutives frames of level 3 */
+ Word16 *nb_thr_1, /* i/o : Number of consecutives frames of level 1 */
+ Word16 *thresh, /* i/o : Detection thresold */
+ Word16 *last_music_flag,/* i/o : Previous music detection ouptut */
+ Word16 vad_flag
+);
+Word16 var_fx( /* o: variance of vector Qx*/
+ const Word16 *x, /* i: input vector Qx*/
+ const Word16 Qx,
+ const Word16 len /* i: length of inputvector */
+);
+void conv_fx(
+ const Word16 x[], /* i : input vector Q_new*/
+ const Word16 h[], /* i : impulse response (or second input vector) Q(15)*/
+ Word16 y[], /* o : output vetor (result of convolution) 12 bits*/
+ const Word16 L /* i : vector size */
+);
+void norm_corr_fx(
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t_min, /* i : minimum value of searched range */
+ const Word16 t_max, /* i : maximum value of searched range */
+ Word16 ncorr[], /* o : normalized correlation Q15 */
+ const Word16 L_subfr /* i : subframe size */
+);
+void pit_Q_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode */
+ const Word16 nBits, /* i : # of Q bits */
+ const Word16 delta, /* i : Half the CL searched interval */
+ const Word16 pit_flag, /* i : absolute(0) or delta(1) pitch Q */
+ const Word16 limit_flag, /* i : restrained(0) or extended(1) Q limits */
+ const Word16 T0, /* i : integer pitch lag */
+ const Word16 T0_frac, /* i : pitch fraction */
+ Word16 *T0_min, /* i/o: delta search min */
+ Word16 *T0_max /* o : delta search max */
+);
+/*void pit16k_Q_enc_fx( */
+/*Encoder_State_fx *st_fx, */ /* i/o: encoder state structure */
+/* const Word16 nBits, */ /* i : # of Q bits */
+/* const Word16 i_subfr, */ /* i : subframe index */
+/* const Word16 limit_flag, */ /* i : restrained(0) or extended(1) Q limits */
+/* const Word16 T0, */ /* i : integer pitch lag */
+/* const Word16 T0_frac, */ /* i : pitch fraction */
+/* Word16 *T0_min, */ /* i/o: delta search min */
+/* Word16 *T0_max */ /* o : delta search max */
+/*); */
+
+Word16 pitch_fr4_fx( /* o : chosen integer pitch lag */
+ const Word16 exc[], /* i : excitation buffer Q_new*/
+ const Word16 xn[], /* i : target signal Q_new-1+shift*/
+ const Word16 h[], /* i : weighted synthesis filter impulse response Q(14+shift)*/
+ const Word16 t0_min, /* i : minimum value in the searched range. Q0*/
+ const Word16 t0_max, /* i : maximum value in the searched range. Q0*/
+ Word16 *pit_frac, /* o : chosen fraction (0, 1, 2 or 3) */
+ const Word16 i_subfr, /* i : flag to first subframe */
+ const Word16 limit_flag, /* i : flag for limits (0=restrained, 1=extended) */
+ const Word16 t0_fr2, /* i : minimum value for resolution 1/2 */
+ const Word16 t0_fr1, /* i : minimum value for resolution 1 */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_subfr /* i : size of subframe */
+);
+
+Word32 var_fx_32( /* o: variance of vector Qx+16*/
+ const Word16 *x, /* i: input vector Qx*/
+ const Word16 Qx,
+ const Word16 len /* i: length of inputvector */
+);
+
+Word16 sum16_fx( /* o : sum of all vector elements Qx*/
+ const Word16 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word32 sum32_fx( /* o : sum of all vector elements Qx*/
+ const Word32 *vec, /* i : input vector Qx*/
+ const Word16 lvec /* i : length of input vector */
+);
+
+Word32 Mean32( /* o : mean of the elements of the vector */
+ const Word32 in[], /* i : input vector */
+ const Word16 L /* i : length of input vector */
+);
+
+void Deemph2(
+ Word16 x[], /* i/o: input signal overwritten by the output Qx/Qx-1 */
+ const Word16 mu, /* i : deemphasis factor Q15 */
+ const Word16 L, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (y[-1]) Qx-1 */
+);
+
+void deemph_fx(
+ Word16 *signal, /* i/o: signal Qx */
+ const Word16 mu, /* i : deemphasis factor Q15 */
+ const Word16 L, /* i : vector size Q0 */
+ Word16 *mem /* i/o: memory (y[-1]) Qx */
+);
+Word16 deindex_lvq_fx(
+ Word16 *index, /* i : index to be decoded, as an array of 3 short */
+ Word16 *x_lvq, /* o : decoded codevector Q(x2.56)*/
+ Word16 mode, /* i : LVQ coding mode (select scales & no_lead ), or idx_cv */
+ Word16 sf_flag, /* i : safety net flag */
+ Word16 no_bits, /* i : number of bits for lattice */
+ Word32 *p_offset_scale1, /* i : offset for first subvector */
+ Word32 *p_offset_scale2, /* i : offset for the second subvector */
+ Word16 *p_no_scales
+);
+void Syn_filt_s(
+ const Word16 shift, /* i : scaling to apply Q0 */
+ const Word16 a[], /* i : LP filter coefficients Q12 */
+ const Word16 m, /* i : order of LP filter Q0 */
+ const Word16 x[], /* i : input signal Qx */
+ Word16 y[], /* o : output signal Qx-s */
+ const Word16 lg, /* i : size of filtering Q0 */
+ Word16 mem[], /* i/o: memory associated with this filtering. Qx-s */
+ const Word16 update /* i : 0=no update, 1=update of memory. Q0 */
+);
+void hp400_12k8_fx(
+ Word16 signal[], /* i/o: input signal / output is divided by 16 */
+ const Word16 lg, /* i : lenght of signal */
+ Word16 mem[] /* i/o: filter memory [6] */
+);
+Word16 dot_prod_satcontr(const Word16 *x, const Word16 *y, Word16 qx, Word16 qy, Word16 *qo, Word16 len);
+void syn_12k8_fx(
+ Word16 L_frame,
+ const Word16 *Aq, /* i : LP filter coefficients Q12 */
+ const Word16 *exc, /* i : input signal Q_exc */
+ Word16 *synth, /* o : output signal Q_syn */
+ Word16 *mem, /* i/o: initial filter states Q_syn */
+ const Word16 update_m, /* i : update memory flag: 0 --> no memory update Q0 */
+ /* 1 --> update of memory */
+ const Word16 Q_exc, /* i : Excitation scaling Q0 */
+ const Word16 Q_syn /* i : Synthesis scaling Q0 */
+);
+void updt_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: state structure */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 *old_exc_fx, /* i : buffer of excitation */
+ const Word16 *pitch_buf_fx, /* i : floating pitch values for each subframe */
+ const Word16 Es_pred, /* i : predicited scaled innovation energy */
+ const Word16 *Aq, /* i : A(z) quantized for all subframes */
+ const Word16 *lsf_new_fx, /* i : current frame LSF vector */
+ const Word16 *lsp_new_fx, /* i : current frame LSP vector */
+ const Word16 voice_factors[], /* i : voicing factors */
+ const Word16 *old_bwe_exc_fx /* i : buffer of excitation */
+ , const Word16 *gain_buf /*Q14*/
+);
+Word32 Interpol_lc_fx( /* o : interpolated value Qx+16 */
+ const Word16 *x, /* i : input vector Q0 */
+ const Word16 *win, /* i : interpolation window Q14 */
+ const Word16 frac, /* i : fraction (0..up_samp) Q0 */
+ const Word16 up_samp, /* i : upsampling factor Q0 */
+ const Word16 nb_coef /* i : number of coefficients Q0 */
+);
+
+Word16 corr_xy1_fx( /* o : pitch gain (0..GAIN_PIT_MAX) */
+ const Word16 xn_1[], /* i : target signal */
+ const Word16 y1_1[], /* i : filtered adaptive codebook excitation */
+ Word16 g_corr[], /* o : correlations and -2 */
+ const Word16 L_subfr, /* i : vector length */
+ const Word16 norm_flag /* i : flag for constraining pitch contribution */
+);
+
+void updt_tar_fx(
+ const Word16 *x, /* i : old target (for pitch search) */
+ Word16 *x2, /* o : new target (for codebook search) */
+ const Word16 *y, /* i : filtered adaptive codebook vector */
+ const Word16 gain, /* i : adaptive codebook gain */
+ const Word16 L /* i : subframe size */
+);
+void updt_tar_HR_fx(
+ const Word16 *x, /* i : old target (for pitch search) */
+ Word16 *x2, /* o : new target (for codebook search) */
+ const Word16 *y, /* i : filtered adaptive codebook vector */
+ const Word16 gain, /* i : adaptive codebook gain */
+ const Word16 Qx, /* i : Scaling factor to adapt output to input */
+ const Word16 L /* i : subframe size */
+);
+
+Word16 lp_filt_exc_enc_fx(
+ const Word16 codec_mode, /* i : MODE1 or MODE2 Q0 */
+ const Word32 core_brate, /* i : core bitrate Q0 */
+ const Word16 Opt_AMR_WB, /* i : flag indicating AMR-WB IO mode Q0 */
+ const Word16 coder_type, /* i : coding type Q0 */
+ const Word16 i_subfr, /* i : subframe index Q0 */
+ Word16 *exc, /* i/o: pointer to excitation signal frame Q_new */
+ const Word16 *h1, /* i : weighted filter input response Q(14+shift) */
+ const Word16 *xn, /* i : target vector Q_new-1+shift */
+ Word16 *y1, /* o : zero-memory filtered adaptive excitation Q_new-1+shift */
+ Word16 *xn2, /* o : target vector for innovation search Q_new-1+shift */
+ const Word16 L_subfr, /* i : length of vectors for gain quantization Q0 */
+ const Word16 L_frame, /* i : frame size Q0 */
+ Word16 *g_corr, /* o : ACELP correlation values mant/exp */
+ const Word16 clip_gain, /* i : adaptive gain clipping flag Q0 */
+ Word16 *gain_pit, /* o : adaptive excitation gain Q14 */
+ Word16 *lp_flag /* i/o: mode selection Q0 */
+);
+
+Word16 Interpol_4( /* o : interpolated value */
+ Word16 * x, /* i : input vector */
+ Word16 frac /* i : fraction (-4..+3) */
+);
+
+void r_fft_fx_lc(
+ const Word16 *phs_tbl, /* i : Table of phase */
+ const Word16 SIZE, /* i : Size of the FFT */
+ const Word16 SIZE2, /* i : Size / 2 */
+ const Word16 NUM_STAGE, /* i : Number of stage */
+ const Word16 *in_ptr, /* i : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */
+ Word16 *out_ptr, /* o : coeffients in the order re[0], re[1], ... re[n/2], im[1], im[2], ..., im[n/2-1] */
+ const Word16 isign /* i : 1=fft, otherwize it's ifft */
+);
+
+void hf_synth_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 output_frame, /* i : output frame length */
+ const Word16 *Aq, /* i : quantized Az */
+ const Word16 *exc, /* i : excitation at 12.8 kHz */
+ Word16 *synth, /* i : 12.8kHz synthesis signal */
+ Word16 *synth16k, /* o : 16kHz synthesis signal */
+ Word16 *seed2, /* i/o: random seed for HF noise gen */
+ Word16 *mem_hp400, /* i/o: memory of hp 400 Hz filter */
+ Word16 *mem_syn_hf, /* i/o: HF synthesis memory */
+ Word16 *mem_hf, /* i/o: HF band-pass filter memory */
+ const Word16 Q_exc, /* i : excitation scaling */
+ const Word16 Q_syn2, /* i : synthesis scaling */
+ Word16 *delay_syn_hf, /*i/o: HF synthesis memory */
+ Word16 *memExp1, /* o : HF excitation exponent */
+ Word16 *mem_hp_interp, /* i/o: interpol. memory */
+ const Word16 extl, /* i : flag indicating BWE */
+ const Word16 CNG_mode /* i : CNG_mode */
+);
+void acelp_core_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 synth_out[], /* o : synthesis */
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 old_syn_12k8_16k[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
+ Word16 coder_type_fx, /* i : coder type */
+ Word16 sharpFlag,
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
+ Word16 *unbits /* o : number of unused bits */
+ ,Word16 *sid_bw /* o : 0-NB/WB, 1-SWB SID */
+);
+void Inac_swtch_ematch_fx(
+ Word16 exc2[], /* i/o: CELP/GSC excitation buffer Q_exc*/
+ Word16 dct_exc_tmp[], /* i : GSC excitation in DCT domain */
+ Word16 lt_ener_per_band[], /* i/o: Long term energy per band Q12 */
+ const Word16 coder_type, /* i : Coding mode */
+ const Word16 L_frame, /* i : Frame lenght */
+ const Word32 core_brate, /* i : Core bit rate */
+ const Word16 Q_exc /* i : input and output format of exc2 */
+ ,const Word16 bfi /* i : frame lost indicator */
+ ,const short last_core, /* i : Last core used */
+ const short last_codec_mode /* i : Last codec mode */
+);
+void stat_noise_uv_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ const Word16 coder_type, /* i : coding type */
+ const Word32 *LepsP, /* i : LP prediction errors */
+ Word16 *isp_new, /* i : immittance spectral pairs at 4th sfr */
+ Word16 *isp_mid, /* i : immittance spectral pairs at 2nd sfr */
+ Word16 *Aq, /* i : A(z) quantized for the 4 subframes */
+ Word16 *exc2, /* i/o: excitation buffer */
+ Word16 Q_new
+);
+
+void updt_enc_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 coder_type, /* i : speech coder type */
+ const Word16 *old_exc, /* i : buffer of excitation */
+ const Word16 *pitch_buf, /* i : floating pitch for each subframe */
+ const Word16 Es_pred, /* i : predicited scaled innovation energy */
+ const Word16 *Aq, /* i : A(z) quantized for all subframes */
+ const Word16 *lsf_new, /* i : current frame LSF vector */
+ const Word16 *lsp_new, /* i : current frame LSP vector */
+ const Word16 *old_bwe_exc /* i : buffer of excitation */
+);
+void FEC_encode_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *synth, /* i : pointer to synthesized speech for E computation */
+ const Word16 coder_type, /* i : type of coder */
+ Word16 clas, /* i : signal clas for current frame */
+ const Word16 *fpit, /* i : close loop fractional pitch buffer */
+ const Word16 *res, /* i : LP residual signal frame */
+ Word16 *last_pulse_pos, /* i/o: Position of the last pulse */
+ const Word16 L_frame, /* i : Frame length */
+ const Word32 total_brate, /* i : total codec bitrate */
+ const Word32 core_brate, /* i : total codec bitrate */
+ const Word16 Q_new, /* i : input scaling */
+ const Word16 shift /* i : scaling to get 12bits */
+);
+void Ener_per_band_comp_fx(
+ const Word16 exc_diff[], /* i : target signal Q_exc_diff */
+ Word16 y_gain4[], /* o : Energy per band to quantize Q12 */
+ const Word16 Q_exc_diff,
+ const Word16 Mband, /* i : Max band */
+ const Word16 Eflag
+);
+void acelp_core_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 inp_fx[], /* i : input signal of the current frame */
+ const Word16 vad_flag_fx,
+ const Word32 ener_fx, /* i : residual energy from Levinson-Durbin*/
+ const Word16 pitch[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 voicing_fx[3], /* i : Open-loop pitch gains */
+ Word16 A_fx[NB_SUBFR16k*(M+1)], /* i : A(z) unquantized for the 4 subframes*/
+ Word16 Aw_fx[NB_SUBFR16k*(M+1)], /* i : weighted A(z) unquant. for subframes*/
+ const Word16 epsP_h_fx[M+1], /* i : LP prediction errors */
+ const Word16 epsP_l_fx[M+1], /* i : LP prediction errors */
+ Word16 lsp_new_fx[M], /* i : LSPs at the end of the frame */
+ Word16 lsp_mid_fx[M], /* i : LSPs in the middle of the frame */
+ Word16 coder_type_fx, /* i : coding type */
+ const Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ Word16 vad_hover_flag_fx,
+ const Word16 gsc_attack_flag_fx, /* i : flag signalling attack encoded by AC mode (GSC) */
+ Word32 bwe_exc_extended_fx[], /* i/o: bandwidth extended excitation */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 old_syn_12k8_16k_fx[], /* o : intermediate ACELP synthesis at 12.8kHz or 16kHz to be used by SWB BWE */
+ Word16 pitch_buf_fx[NB_SUBFR16k], /* o : floating pitch for each subframe */
+ Word16 *unbits_fx, /* o : number of unused bits */
+ const Word16 Q_new,
+ const Word16 shift
+);
+
+#define EDCT_FACTOR_SCALE 2
+void edct_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length */
+ Word16 *q /* i : Q value of input signal */
+);
+
+void edst_fx(
+ const Word32 *x, /* i : input signal Qq */
+ Word32 *y, /* o : output transform Qq */
+ Word16 length, /* i : length */
+ Word16 *q /* i : Q value of input signal */
+);
+
+void DoRTFTn_fx(
+ Word32 *x, /* i/o : real part of input and output data */
+ Word32 *y, /* i/o : imaginary part of input and output data */
+ const Word16 n /* i : size of the FFT up to 1024 */
+);
+
+void edct2_fx(
+ Word16 n,
+ Word16 isgn,
+ Word16 *in,
+ Word32 *a,
+ Word16 *q,
+ const Word16 *ip,
+ const Word16 *w
+);
+void DoRTFT160_16fx(
+ Word16 x[], /* i/o : real part of input and output data */
+ Word16 y[] /* i/o : imaginary part of input and output data */
+);
+void DoRTFT320_16fx(
+ Word16 *x, /* i/o : real part of input and output data */
+ Word16 *y /* i/o : imaginary part of input and output data */
+);
+void DoRTFT128_16fx(
+ Word16 *x, /* i/o : real part of input and output data Q(Qx+Q_edct)*/
+ Word16 *y /* i/o : imaginary part of input and output data Q(Qx+Q_edct)*/
+);
+void edct_16fx(
+ const Word16 *x, /* i : input signal Qx */
+ Word16 *y, /* o : output transform Qx */
+ Word16 length, /* i : length */
+ Word16 bh /* bit-headroom */
+);
+void highband_exc_dct_in_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 *mfreq_bindiv_loc, /* i : bin per bands tables */
+ Word16 last_bin, /* i : last bin of bit allocation */
+ Word16 Diff_len, /* i : number of bin before cut-off frequency */
+ Word16 noise_lev, /* i : pulses dynamic */
+ Word16 pit_band_idx, /* i : bin position of the cut-off frequency */
+ Word16 *exc_diffQ, /* i : frequency coefficients of per band */
+ Word16 *seed_tcx, /* i : Seed for noise */
+ Word16 *Ener_per_bd_iQ, /* i : Quantized energy of targeted vector */
+ Word16 nb_subfr, /* i : Number of subframe considered */
+ Word16 *exc_dct_in, /* o : dct of residual signal */
+ Word16 last_coder_type, /* i : coding type of last frame */
+ Word16 *bitallocation_band, /* i : bit allocation flag of each band */
+ Word16 *lsf_new, /* i : LSFs at the end of the frame */
+ Word16 *last_exc_dct_in, /* i : dct of residual signal of last frame */
+ Word16 *last_ener, /* i : frequency energy of last frame */
+ Word16 *last_bitallocation_band, /* i : bit allocation flag of each band of last frame */
+ Word16 *bitallocation_exc, /* i : flag of decoded coefficients */
+ Word16 bfi, /* i : bad frame indicator */
+ const Word16 coder_type, /* i : coder type */
+ Word16 bwidth,
+ Word16 *exc_wo_nf , /* o : temporal excitation (in f domain) without noisefill */
+ Word16 Qexc_diffQ,
+ Word16 Q_exc,
+ const Word16 GSC_noisy_speech
+ ,Word16 *lt_ener_per_band_fx /* i/o: Average per band energy */
+);
+
+
+void long_enr_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ const Word16 Etot, /* i : total channel E (see lib_enc\analy_sp.c) */
+ const Word16 localVAD_HE_SAD, /* i : HE-SAD flag without hangover */
+ Word16 high_lpn_flag
+);
+
+Word16 correlation_shift_fx( /* o : noise dependent voicing correction Q15 */
+ Word16 totalNoise_fx /* i/o: noise estimate over all critical bands Q8 */
+);
+
+void analy_lp_fx(
+ const Word16 speech[], /* i : pointer to the speech frame */
+ const Word16 L_frame, /* i : length of the frame */
+ const Word16 L_look, /* i : look-ahead */
+ Word32 *ener, /* o : residual energy from Levinson-Durbin */
+ Word16 A[], /* o : A(z) filter coefficients */
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
+ Word16 lsp_new[], /* o : current frame LSPs */
+ Word16 lsp_mid[], /* o : current mid-frame LSPs */
+ Word16 lsp_old[], /* i/o: previous frame unquantized LSPs */
+ const Word16 Top[2], /* i : open loop pitch lag */
+ const Word16 Tnc[2], /* i : open loop pitch gain */
+ const Word32 Core_sr, /* i : Internal core sampling rate */
+ Word16 Q_new,
+ Word16 *Q_r
+);
+
+void analy_lp_AMR_WB_fx(
+ const Word16 speech[], /* i : pointer to the speech frame */
+ Word32 *ener, /* o : residual energy from Levinson-Durbin */
+ Word16 A[], /* o : A(z) filter coefficients */
+ Word16 epsP_h[], /* o : LP analysis residual energies for each iteration */
+ Word16 epsP_l[], /* o : LP analysis residual energies for each iteration */
+ Word16 isp_new[], /* o : current frame ISPs */
+ Word16 isp_old[], /* i/o: previous frame unquantized ISPs */
+ Word16 isf_new[], /* o : current frame ISPs */
+ Word16 Top, /* i : open loop pitch lag */
+ Word16 Tnc, /* i : open loop pitch gain */
+ Word16 Q_new,
+ Word16 *Q_r
+);
+
+void a2rc_fx(const Word16 *a, Word16 *refl,Word16 lpcorder);
+
+Word32 invert_dp(Word40 Linput, Word16 n, Word16 *Qout, Word16 wb_mode_bit);
+
+void vad_param_updt_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ Word16 pitch[3], /* i : open loop pitch lag for each half-frame Q0*/
+ Word16 voicing[3], /* i : maximum normalized correlation for each half-frame Q15*/
+ const Word16 old_pitch1,/* i : OL pitch value from last frame */
+ Word16 corr_shift, /* i : correlation shift Q15*/
+ Word16 vad_flag, /* i : vad flag Q0*/
+ const Word16 Az[] /* i: a coeffs */
+);
+
+void pitch_ol2_fx(
+ const Word16 pit_min, /* i : minimum pitch value (20 or 29) */
+ const Word16 pitch_ol, /* i : pitch to be improved */
+ Word16 *pitch_fr_fx, /* o : adjusted 1/4 fractional pitch */ /*Q7 */
+ Word16 *voicing_fr_fx, /* o : adjusted 1/4 fractional voicing */ /*Q15 */
+ const Word16 pos, /* i : position in frame where to calculate the improv. */
+ const Word16 *wsp_fx, /* i : weighted speech for current frame and look-ahead */ /*Q_new-1+shift*/
+ const Word16 delta /* i : delta for pitch search (2 or 7) */
+);
+
+void pitch_ol_fx(
+ Word16 pitch[3], /* o : open loop pitch lag for each half-frame in range [29,231] Q0 */
+ Word16 voicing[3], /* o : maximum normalized correlation for each half-frame in [0,1.0[ Q15 */
+ Word16 *old_pitch, /* i/o: pitch of the 2nd half-frame of previous frame (i.e. pitch[1]) Q0 */
+ Word16 *old_corr, /* i/o: correlation of old_pitch (i.e. voicing[1] or corr_mean) Q15 */
+ Word16 corr_shift, /* i : normalized correlation correction Q15 */
+ Word16 *old_thres, /* i/o: maximum correlation weighting with respect to past frame pitch Q15 */
+ Word16 *delta_pit, /* i/o: old pitch extrapolation correction in range [-14,+14] Q0 */
+ Word16 *st_old_wsp2, /* i/o: weighted speech memory qwsp */
+ const Word16 *wsp, /* i : weighted speech for current frame and look-ahead qwsp */
+ Word16 mem_decim2[3], /* i/o: wsp decimation filter memory qwsp */
+ const Word16 relE, /* i : relative frame energy Q8 */
+ const Word16 last_class, /* i : frame classification of last frame */
+ const Word16 bwidth, /* i : bandwidth */
+ const Word16 Opt_SC_VBR /* i : SC-VBR flag */
+);
+
+void Scale_wsp(
+ Word16 *wsp, /* i : Weigthed speech */
+ Word16 *old_wsp_max, /* i : Last weigthed speech maximal valu */
+ Word16 *shift, /* i/o: Scaling of current frame */
+ Word16 *Q_exp, /* i/o: Differential scaling factor */
+ Word16 *old_wsp_shift, /* i/o: Last wsp scaling */
+ Word16 *old_wsp, /* i/o: Old weighted speech buffer */
+ Word16 *mem_decim2, /* i/o: Decimation buffer */
+ Word16 *old_wsp12k8, /* i/o: wsp memory @ 12.8 kHz used in pitol2 */
+ const Word16 Len_p_look /* i : L_frame + look ahead */
+);
+
+Word16 multi_harm_fx( /* o : frame multi-harmonicity (1-harmonic, 0-not) */
+ const Word16 Bin_E[], /* i : log-energy spectrum of the current frame Q7 */
+ Word16 old_S[], /* i/o: prev. log-energy spectrum w. subtracted floor Q7 */
+ Word16 cor_map_LT[], /* i/o: LT correlation map Q15 */
+ Word16 *multi_harm_limit, /* i/o: multi harminic threshold Q9 */
+ const Word32 total_brate, /* i : total bitrate Q0 */
+ const Word16 bwidth, /* i : input signal bandwidth Q0 */
+ Word16 *cor_strong_limit, /* i/o: HF correlation indicator Q0 */
+ Word16 *st_mean_avr_dyn, /* i/o: long term average dynamic Q7 */
+ Word16 *st_last_sw_dyn, /* i/o: last dynamic Q7 */
+ Word16 *cor_map_sum /* Q8 */
+ , Word16 *sp_floor /* o : noise floor estimate Q7 */
+);
+
+Word16 find_uv_fx( /* o : coding type */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *T_op_fr, /* i : pointer to adjusted fractional pitch (4 val.) Q6 */
+ const Word16 *voicing_fr, /* i : refined correlation for each subframes Q15 */
+ const Word16 *voicing, /* i : correlation for 3 half-frames Q15 */
+ const Word16 *speech, /* i : pointer to speech signal for E computation Q_new*/
+ const Word16 localVAD, /* i : vad without hangover */
+ const Word32 *ee, /* i : lf/hf Energy ratio for present frame Q6 */
+ const Word16 corr_shift, /* i : normalized correlation correction in noise Q15 */
+ const Word16 relE, /* i : relative frame energy Q8 */
+ const Word16 Etot, /* i : total energy Q8 */
+ const Word32 hp_E[], /* i : energy in HF Q_new + Q_SCALE */
+ const Word16 Q_new,
+ Word16 *flag_spitch, /* i/o: flag to indicate very short stable pitch and high correlation */
+ const Word16 voicing_sm /* i : smoothed open-loop pitch gains */
+ , const Word16 shift
+ , const Word16 last_core_orig /* i : original last core */
+);
+
+Word16 signal_clas_fx( /* o : classification for current frames */
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ Word16 *coder_type, /* i/o: coder type */
+ const Word16 voicing[3], /* i : normalized correlation for 3 half-frames */
+ const Word16 *speech, /* i : pointer to speech signal for E computation */
+ const Word16 localVAD, /* i : vad without hangover */
+ const Word16 pit[3], /* i : open loop pitch values for 3 half-frames */
+ const Word32 *ee, /* i : lf/hf E ration for 2 half-frames */
+ const Word16 relE, /* i : frame relative E to the long term average */
+ const Word16 L_look , /* i : look-ahead */
+ Word16 *uc_clas /* o : temporary classification used in music/speech class*/
+);
+
+void find_tilt_fx(
+ const Word32 fr_bands[], /* i : energy in frequency bands Q_new + Q_SCALE*/
+ const Word32 bckr[], /* i : per band background noise energy estimate Q_new + Q_SCALE*/
+ Word32 ee[2], /* o : lf/hf E ration for present frame Q6*/
+ const Word16 pitch[3], /* i : open loop pitch values for 3 half-frames Q0*/
+ const Word16 voicing[3], /* i : normalized correlation for 3 half-frames Q15*/
+ const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE - 2*/
+ const Word16 corr_shift, /* i : normalized correlation correction Q15*/
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 max_band, /* i : maximum critical band */
+ Word32 hp_E[], /* o : energy in HF Q_new + Q_SCALE*/
+ const Word16 codec_mode, /* i : MODE1 or MODE2 */
+ const Word16 Q_new, /* i : scaling factor */
+ Word32 *bckr_tilt_lt
+ ,Word16 Opt_vbr_mode
+);
+void synth_mem_updt2(
+ const Word16 L_frame, /* i : frame length */
+ const Word16 last_L_frame, /* i : frame length */
+ Word16 old_exc[], /* i/o: excitation buffer */
+ Word16 mem_syn_r[], /* i/o: synthesis filter memory */
+ Word16 mem_syn2[], /* o : synthesis filter memory for find_target */
+ Word16 mem_syn[], /* o : synthesis filter memory for find_target */
+ const Word16 dec /* i : flag for decoder indication */
+);
+void swb_hr_noise_fill_fx(
+ const Word16 is_transient, /* i : transient flag */
+ const Word16 spect_start, /* i : spectrum start point */
+ const Word16 spect_end, /* i : spectrum end point */
+ const Word16 tilt_wb, /* i : tilt of wideband signal */
+ const Word16 pitch, /* i : pitch value */
+ const Word16 nq[], /* i : AVQ nq index */
+ Word16 Nsv, /* i : number of subband */
+ Word16 *bwe_highrate_seed, /* i/o: seed of random noise */
+ Word16 *t_audio, /* i/o: mdct spectrum */
+ Word16 Q_audio
+);
+Word16 swb_bwe_dec_hr_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 *syn_12k8_16k_fx, /* i : ACELP core synthesis @16kHz */
+ const Word16 old_syn_exp, /* i : Exponent of core synthesis */
+ Word16 *hb_synth_fx, /* o : SHB synthesis */
+ const Word16 output_frame, /* i : frame length */
+ const Word16 unbits, /* i : number of core unused bits */
+ const Word16 pitch_buf[] /* i : pitch buffer */
+);
+Word32 calc_tilt_bwe_fx( /* o : Tilt in Q24 */
+ const Word16 *sp0, /* i : input signal */
+ const Word16 exp, /* i : Exp of inp signal */
+ const Word16 N /* i : signal length */
+);
+void Inverse_Transform(
+ const Word32 *in_mdct, /* i : input MDCT vector */
+ Word16 *Q, /* i/o: Q value of input */
+ Word32 *out, /* o : output vector */
+ const Word16 is_transient, /* i : transient flag */
+ const Word16 L, /* i : output frame length */
+ const Word16 L_inner /* i : length of the transform */
+);
+void iedct_short_fx(
+ const Word32 *in, /* i : input vector */
+ Word16 *Q, /* i/o: Q value of input */
+ Word32 *out, /* o : output vector */
+ const Word16 segment_length /* i : length */
+);
+
+void swb_bwe_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 *old_input_12k8_fx, /* i : input signal @12.8kHz for SWB BWE */
+ Word16 *old_input_16k_fx, /* i : input signal @16kHz for SWB BWE */
+ const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */
+ const Word16 *new_swb_speech_fx, /* i : original input signal at 32kHz */
+ Word16 *shb_speech_fx, /* i : SHB target signal (6-14kHz) at 16kHz */
+ const Word16 coder_type, /* i : coding type */
+ Word16 Q_shb_speech,
+ Word16 Q_slb_speech
+);
+void wb_bwe_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *new_wb_speech_fx, /* i : original input signal at 16kHz */
+ Word16 coder_type /* i : coding type */
+);
+
+Word16 WB_BWE_encoding_fx( /* o : classification of wb signal */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 *yos_fx, /* i : MDCT coefficients of weighted original */
+ Word16 *WB_fenv_fx, /* i/o: energy of WB envelope */
+ Encoder_State_fx *st_fx, /* i/o: Encoder structure */
+ Word16 Q_synth,
+ Word16 Q_synth_lf
+);
+
+
+Word16 wb_bwe_dec_fx(
+ Word16 *synth_fx, /* i/o: ACELP core synthesis/final synthesis */
+ Word16 *hb_synth_fx, /* o : SHB synthesis/final synthesis */
+ const Word16 output_frame, /* i : frame length */
+ Word16 coder_type, /* i : coding type */
+ Word16 *voice_factors_fx, /* i : voicing factors */
+ const Word16 pitch_buf_fx[], /* i : pitch buffer */
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+ ,Word16 * Qpost
+);
+
+Word16 WB_BWE_gain_deq_fx(
+ Decoder_State_fx *st_fx , /* i/o: decoder state structure */
+ Word16 *WB_fenv
+);
+Word16 swb_bwe_gain_deq_fx( /* o : BWE class */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 core, /* i : core */
+ Word16 *SWB_tenv, /* o : Q0, time-domain BWE envelope */
+ Word16 *SWB_fenv, /* o : Q1, frequency-domain BWE envelope */
+ const Word16 hr_flag, /* i : high rate flag */
+ const Word16 hqswb_clas /* i : HQ BWE class */
+);
+
+Word16 swb_bwe_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 *synth_fx, /* i : ACELP core synthesis/final synthesis */
+ Word16 *hb_synth, /* o : SHB synthesis/final synthesis */
+ const Word16 output_frame /* i : frame length */
+ ,Word16 * Qpost
+ ,Word16 coder_type /* i : coding type */
+);
+
+Word16 WB_BWE_gain_pred_fx(
+ Word16 *WB_fenv, /* o : WB frequency envelopes */
+ const Word16 *core_dec_freq, /* i : Frequency domain core decoded signal */
+ const Word16 coder_type, /* i : coding type */
+ Word16 prev_coder_type, /* i : coding type of last frame */
+ Word16 prev_WB_fenv, /* i : envelope for last frame */
+ Word16 *voice_factors, /* i : voicing factors Q15 */
+ const Word16 pitch_buf[], /* i : pitch buffer Q6 */
+ Word32 last_core_brate, /* i : previous frame core bitrate */
+ Word16 last_wb_bwe_ener , /* i : previous frame wb bwe signal energy */
+ Word16 Q_syn
+ ,Word16 last_extl_fx,
+ Word16 tilt_wb_fx
+);
+void calc_normal_length_fx(
+ const Word16 core, /* i : core */
+ const Word16 *sp, /* i : input signal */
+ const Word16 mode, /* i : input mode */
+ const Word16 extl, /* i : extension layer */
+ Word16 *L_swb_norm, /* o : normalize length */
+ Word16 *prev_L_swb_norm, /*i/o : last normalize length */
+ Word16 Q_syn
+);
+
+void calc_norm_envelop_fx(
+ const Word16 SWB_signal[], /* i : SWB spectrum Q_syn*/
+ Word32 *envelope, /* o : normalized envelope Q_syn*/
+ const Word16 L_swb_norm, /* i : length of envelope Q0 */
+ const Word16 SWB_flength, /* i : Length of input/output */
+ const Word16 st_offset /* i : offset */
+);
+
+void WB_BWE_decoding_fx(
+ const Word16 *core_dec_freq, /* i : Frequency domain core decoded signal */
+ Word16 *WB_fenv, /* i : WB frequency envelopes */
+ Word32 *WB_signal32, /* o : WB signal in MDCT domain */
+ const Word16 WB_flength, /* i : Length of input/output */
+ const Word16 mode, /* i : classification for WB signal */
+ const Word16 last_extl, /* i : extl. layer for last frame */
+ Word32 *prev_Energy, /* i/o: energy for last frame */
+ Word16 *prev_WB_fenv, /* i/o: envelope for last frame */
+ Word16 *prev_L_wb_norm, /* i/o: length for last frame wb norm */
+ const Word16 extl, /* i : extension layer */
+ const Word16 coder_type, /* i : coding type */
+ const Word32 total_brate, /* i : core layer bitrate */
+ Word16 *Seed, /* i/o: random generator seed */
+ Word16 *prev_flag, /* i/o: attenu flag of last frame */
+ Word16 prev_coder_type , /* i : coding type of last frame */
+ Word16 Q_syn,
+ Word16 *Q_syn_hb /*o : Q value of WB_signal_32 */
+);
+
+void SWB_BWE_decoding_fx(
+ const Word16 *core_dec_freq, /* i : Frequency domain core decoded signal */
+ Word16 *SWB_fenv, /* i/o: SWB frequency envelopes */
+ Word32 *SWB_signal, /* o : SWB signal in MDCT domain */
+ const Word16 SWB_flength, /* i : Length of input/output */
+ const Word16 mode, /* i : classification for SWB signal */
+ Word16 *frica_flag, /* o : fricative signal flag */
+ Word16 *prev_Energy, /* i/o: energy for last frame */
+ Word16 *prev_SWB_fenv, /* i/o: envelope for last frame */
+ Word16 *prev_L_swb_norm, /* i/o: length for last frame wb norm */
+ const Word16 tilt_nb, /* i : tilt of synthesis wb signal */
+ Word16 *Seed, /* i/o: random generator seed */
+ const Word16 st_offset, /* i : offset value due to different core */
+ Word16 *prev_weight, /* i/o: excitation weight value of last frame */
+ const Word16 extl , /* i : extension layer */
+ Word16 Q_syn
+ ,const Word16 last_extl /* i : extension layer of last frame */
+);
+void time_envelop_shaping_fx(
+ Word16 werr[], /* i/o: SHB synthesis Q_synth*/
+ Word32 SWB_tenv[], /* i/o: frequency envelope Q15*/
+ const Word16 L , /* i : frame length */
+ Word16 *Q_synth
+);
+void time_reduce_pre_echo_fx(
+ const Word16 *synth, /* i : ACELP core synthesis Q_syn*/
+ Word16 *error, /* i/o: SHB BWE synthesis Q0*/
+ Word16 prev_td_energy, /* o : last td energy Q0*/
+ const Word16 L, /* i : subframe length */
+ Word16 Q_syn,
+ Word16 Q_synth
+);
+/*Word16 detect_transient_fx( */
+/* const Word16 *in_fx, *//*Q_new */
+/* Encoder_State *st, */
+/* const Word16 L, */
+/* const Word16 coder_type , */ /* i : coder type */
+/* Word16 Q_new, */
+/*Encoder_State_fx *st_fx */
+/*); */
+
+
+void preset_hq2_swb_fx
+(
+ const Word16 hqswb_clas_fx, /* i : HQ2 class information */
+ const Word16 band_end_fx[], /* i : band end of each SB */
+ Word16 *har_bands_fx, /* i/o : Number of LF harmonic bands */
+ Word16 p2a_bands_fx, /* i : flag for peakness */
+ const Word16 length_fx, /* i : processed band length */
+ const Word16 bands_fx, /* i : Total number of Subbands in a frame */
+ Word16 *lowlength_fx, /* o : lowband length */
+ Word16 *highlength_fx, /* o : highband length */
+ Word32 L_m[] /* o : MDCT */
+);
+void post_hq2_swb_fx
+(
+ const Word32 L_m[], /* i : input_signal */
+ const Word16 lowlength_fx, /* i : lowband length */
+ const Word16 highlength_fx, /* i : highband length */
+ const Word16 hqswb_clas_fx, /* i : HQ2 class information */
+ const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
+ const Word16 bands_fx, /* i : Total number of Subbands in a frame */
+ const Word16 p2a_flags_fx[], /* i : HF tonal indicator */
+ const Word16 band_start_fx[], /* i : band start of each SB */
+ const Word16 band_end_fx[], /* i : band end of each SB */
+ Word32 L_y2[], /* o : output signal */
+ Word16 npulses_fx[] /* i/o : Number of coded spectrum */
+);
+
+void swb_bwe_enc_lr_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word32 L_m_core[], /* i : lowband synthesis */
+ Word16 QsL,
+ const Word32 L_m_orig[], /* i/o: scaled orig signal (MDCT) */
+ Word32 L_m[], /* o : highband synthesis with lowband zeroed */
+ const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */
+ Word16 BANDS_fx, /* i : Total number of Subbands in a frame */
+ Word16 *band_start_fx, /* i : band start of each SB */
+ Word16 *band_end_fx, /* i : band end of each SB */
+ Word32 *L_band_energy, /* i : band_energy of each SB */
+ Word16 Qbe, /* i : Q value of band energy */
+ Word16 *p2a_flags_fx, /* i : HF tonal indicator */
+ const Word16 hqswb_clas_fx, /* i : HQ_NORMAL2 or HQ_HARMONIC mode */
+ Word16 lowlength_fx, /* i : lowband length */
+ Word16 highlength_fx, /* i : highband length */
+ Word16 *prev_frm_index_fx, /* i/o: previous frame lag index for harmonic mode */
+ const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
+ Word16 *prev_frm_hfe2, /* i/o: */
+ Word16 *prev_stab_hfe2, /* i/o: */
+ const Word16 band_width_fx[], /* i : band_width information */
+ const Word32 L_y2_ni[], /* i : band_width information */
+ Word16 *ni_seed_fx /* i/o: random seed for search buffer NI */
+);
+
+void swb_bwe_dec_lr_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word32 L_m_core[], /* i : lowband synthesis */
+ const Word16 QsL, /* i : Q value of m_core */
+ Word32 L_m[], /* o : highband synthesis with lowband zeroed */
+ const Word32 L_total_brate, /* i : total bitrate for selecting subband pattern */
+ Word16 BANDS_fx, /* i : Number subbands/Frame */
+ Word16 *band_start_fx, /* i : Band Start of each SB */
+ Word16 *band_end_fx, /* i : Band end of each SB */
+ Word32 *L_band_energy, /* i : Band energy of each SB : Qbe */
+ Word16 Qbe, /* i : Q value of band energy */
+ Word16 *p2a_flags_fx, /* i : HF tonal Indicator */
+ const Word16 hqswb_clas_fx, /* i : class information */
+ Word16 lowlength_fx, /* i : Lowband Length */
+ Word16 highlength_fx, /* i : Highband Length */
+ const Word16 har_bands_fx, /* i : Number of LF harmonic bands */
+ Word16 *prev_frm_hfe2_fx, /* i/o: */
+ Word16 *prev_stab_hfe2_fx, /* i/o: */
+ Word16 band_width_fx[], /* i : subband bandwidth */
+ const Word32 L_y2_ni[], /* i/o: Sparse filled corecoder */
+ Word16 *ni_seed_fx /* i/o: random seed */
+);
+
+void GetPredictedSignal_fx(
+ const Word16 *predBuf_fx, /* i: Q8 */
+ Word32 *L_outBuf, /* o: Q9 */
+ const Word16 lag_fx, /* i: Q0 */
+ const Word16 fLen_fx, /* i: Q0 */
+ const Word16 lagGains_fx, /* i: Qgain */
+ const Word16 Qgain /* i: Q0 */
+);
+
+void Get20Log10Spec_fx(
+ const Word32 *L_inBuf, /* i : input Q_inBuf */
+ Word16 *outBuf_fx, /* o : output Q7 */
+ const Word16 fLen, /* i : loop length */
+ const Word16 Q_inBuf /* i : Qvalue of L_inBuf */
+);
+
+void convert_lagIndices_pls2smp_fx(
+ Word16 lagIndices_in_fx[],
+ Word16 nBands_search_fx,
+ Word16 lagIndices_out_fx[],
+ const Word16 sspectra_fx[],
+ const Word16 sbWidth_fx[],
+ const Word16 fLenLow_fx
+);
+
+Word16 get_usebit_npswb_fx(
+ Word16 hqswb_clas_fx
+);
+
+void SpectrumSmoothing_nss_fx(
+ const Word32 *L_inBuf, /* i : lowband MDCT */
+ Word16 *outBuf_fx, /* o : output */
+ Word16 *Qss, /* o : Q value for output vector */
+ const Word16 fLen /* i : length */
+);
+
+void SpectrumSmoothing_fx(
+ const Word32 *L_inBuf, /* i : Qs Low band MDCT */
+ Word16 *outBuf_fx, /* o : Qss output */
+ Word16 *Qss, /* o : Q0 Q value of output vector */
+ const Word16 fLen, /* i : Q0 length */
+ const Word16 th_cut_fx /* i : Qss threshold of cut */
+);
+
+void GetSynthesizedSpecThinOut_fx(
+ const Word16 *predBuf_fx, /* i : Qss: prediction buffer (i.e., lowband) */
+ const Word16 Qss, /* i : Q value of input vector */
+ Word32 *L_outBuf, /* o : QsL: synthesized spectrum */
+ Word16 QsL, /* o : Q value of synthesized spectrum */
+ const Word16 nBands_fx, /* i : Q0: number of subbands calculated */
+ const Word16 *sbWidth_fx, /* i : Q0: subband lengths */
+ const Word16 *lagIndices_fx, /* i : Q0: lowband index for each subband */
+ const Word16 *lagGains_fx, /* i : Qgain: lagGain for each subband */
+ const Word16 *QlagGains_fx, /* i : Q0: Q value of lagGains_fx */
+ const Word16 predBufLen_fx /* i : Q0: lowband length */
+);
+
+Word32 hq2_bit_alloc_fx (
+ const Word32 L_band_energy[], /* i : band energy of each subband */
+ const Word16 bands, /* i : total number of subbands in a frame */
+ Word32 L_Rk[], /* i/o: Bit allocation/Adjusted bit alloc. */
+ Word16 *bit_budget_fx, /* i/o: bit bugdet */
+ Word16 *p2a_flags, /* i : HF tonal indicator */
+ const Word16 weight_fx, /* i : weight */
+ const Word16 band_width[], /* i : Sub band bandwidth */
+ const Word16 num_bits, /* i : available bits */
+ const Word16 hqswb_clas, /* i : HQ2 class information */
+ const Word16 bwidth, /* i : input bandwidth */
+ const Word16 is_transient /* i : indicator HQ_TRANSIENT or not */
+);
+
+void hq2_noise_inject_fx(
+ Word32 L_y2[],
+ const Word16 band_start[],
+ const Word16 band_end[],
+ const Word16 band_width[],
+ Word32 Ep_fx[],
+ Word32 Rk_fx[],
+ const Word16 npulses[],
+ Word16 ni_seed,
+ const Word16 bands,
+ const Word16 ni_start_band,
+ const Word16 bw_low,
+ const Word16 bw_high,
+ const Word32 enerL_fx,
+ const Word32 enerH_fx,
+ Word32 last_ni_gain_fx[],
+ Word16 last_env_fx[],
+ Word16 *last_max_pos_pulse,
+ Word16 *p2a_flags,
+ Word16 p2a_bands,
+ const Word16 hqswb_clas,
+ const Word16 bwidth,
+ const Word32 bwe_br
+);
+
+void reordvct_fx(
+ Word16 *y, /* i/o: vector to rearrange */
+ const Word16 N, /* i : dimensions */
+ Word16 *idx /* o : reordered vector index */
+);
+
+void Bits2indvsb_fx (
+ const Word32 *L_be, /* i : Q14 Band Energy of sub-band */
+ const Word16 start_band, /* i : Q0 start band indices */
+ const Word16 end_band, /* i : Q0 end band indices */
+ const Word16 Bits, /* i : Q0 Total number of bits allocated to a group */
+ const Word32 L_Bits_needed, /* i : Q0 smallest bit number for allocation in group */
+ Word32 *L_Rsubband, /* o : Q18 bit allocation of sub-band */
+ Word16 *p2aflags_fx /* i/o: Q0 peaky/noise subband flag */
+);
+
+void hq2_bit_alloc_har_fx (
+ const Word32 *L_y, /* i : Q14 band energy of sub-vectors */
+ Word16 B_fx, /* i : Q0 number of available bits */
+ const Word16 N_fx, /* i : Q0 number of sub-vectors */
+ Word32 *L_Rsubband, /* o : Q18 sub-band bit-allocation vector */
+ Word16 p2a_bands_fx, /* i : Q0 highfreq bands */
+ const Word32 L_core_brate, /* i : Q0 core bit rate */
+ Word16 p2a_flags_fx[], /* i/o: Q0 p2a_flags */
+ const Word16 band_width_fx[] /* i : Q0 table of band_width */
+);
+
+void hq2_core_configure_fx (
+ const Word16 frame_length,
+ const Word16 num_bits,
+ const Word16 is_transient,
+ Word16 *bands,
+ Word16 *length,
+ Word16 band_width[],
+ Word16 band_start[],
+ Word16 band_end[],
+ Word32 *L_qint,
+ Word16 *eref,
+ Word16 *bit_alloc_weight,
+ Word16 *gqlevs,
+ Word16 *Ngq,
+ Word16 *p2a_bands,
+ Word16 *p2a_th,
+ Word16 *pd_thresh,
+ Word16 *ld_slope,
+ Word16 *ni_coef,
+ Word32 L_bwe_br
+);
+
+void hq_lr_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: : encoder state structure */
+ Word32 L_t_audio[], /* i/o: Q12 : transform-domain coefs. */
+ const Word16 inner_frame_fx, /* i : Q0 : inner frame length */
+ Word16 *num_bits_fx, /* i/o: Q0 : number of available bits */
+ const Word16 is_transient_fx /* i : Q0 : transient flag */
+);
+
+void hq_lr_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: : decoder state structure */
+ Word32 L_yout[], /* o : Q12 : transform-domain output coefs. */
+ const Word16 inner_frame, /* i : Q0 : inner frame length */
+ Word16 num_bits, /* i : Q0 : number of available bits */
+ Word16 *is_transient_fx /* o : Q0 : transient flag */
+);
+
+void reverse_transient_frame_energies_fx(
+ Word32 L_band_energy[], /* o : Q14 : band energies */
+ const Word16 bands /* i : Q0 : number of bands */
+);
+
+Word16 har_est_fx(
+ Word32 L_spectra[], /* i : coded spectrum */
+ Word16 N, /* i : length of the desired spectrum */
+ Word16 *har_freq_est1, /* i/o: Estimation harmonics 1 */
+ Word16 *har_freq_est2, /* o : Estimation harmonics 2 */
+ Word16 *flag_dis, /* i/o: flag for BWE reconstruction */
+ Word16 *prev_frm_hfe2, /* i/o: Estimated harmonic update */
+ const Word16 subband_search_offset[], /* i : Subband Search range */
+ const Word16 sbWidth[], /* i : Subband Search range */
+ Word16 *prev_stab_hfe2 /* i/o: Estimated harmonic position */
+);
+
+typedef struct GainItemStr_fx
+{
+ Word16 nmrValue_fx;
+ Word16 gainIndex_fx;
+} GainItem_fx;
+
+void genhf_noise_fx(
+ Word16 noise_flr_fx[], /* i : Qss smoothed non tonal */ /* sspectra_diff_fx:Qss */
+ Word16 Qss, /* i : Q0 Q value */
+ Word32 L_xSynth_har[], /* o : QsL hf non tonal components */ /* xSynth_har:QsL */
+ Word16 QsL, /* i : Q0 Q value */
+ Word16 *predBuf_fx, /* i : Qss smoothed tonal compone */ /* sspectra:Qss */
+ Word16 bands, /* i : Q0 total number of subbands in a frame */
+ Word16 harmonic_band, /* i : Q0 Number of LF harmonic frames */
+ Word16 har_freq_est2, /* i : Q0 harmonic signal parameter */
+ Word16 pos_max_hfe2, /* i : Q0 last pulse in core coder */
+ Word16 *pul_res, /* o : Q0 pulse resolution */
+ GainItem_fx pk_sf_fx[], /* o : representative region */
+ const Word16 fLenLow, /* i : Q0 low frequency length */
+ const Word16 fLenHigh, /* i : Q0 high frequency length */
+ const Word16 sbWidth[], /* i : Q0 bandwidth for high bands */
+ const Word16 lagIndices[], /* i : Q0 correlation indices for most representative */
+ const Word16 subband_offsets[], /* i : Q0 band offsets for HF reconstruction */
+ const Word16 subband_search_offset[] /* i : Q0 most representative regions offsets in LF */
+);
+
+void spt_shorten_domain_pre_fx(
+ const Word16 band_start[], /* i: Starting position of sub band */
+ const Word16 band_end[], /* i: End position of sub band */
+ const Word16 prev_SWB_peak_pos[], /* i: Spectral peak */
+ const Word16 BANDS, /* i: total number of bands */
+ const Word32 L_bwe_br, /* i: bitrate information */
+ Word16 new_band_start[], /* o: Starting position of new shorten sub band */
+ Word16 new_band_end[], /* o: End position of new shorten sub band */
+ Word16 new_band_width[] /* o: new sub band bandwidth */
+);
+
+void spt_shorten_domain_band_save_fx(
+ const Word16 bands, /* i: total subband */
+ const Word16 band_start[], /* i: starting position of subband */
+ const Word16 band_end[], /* i: end position of subband */
+ const Word16 band_width[], /* i: band width of subband */
+ Word16 org_band_start[], /* o: starting position of subband */
+ Word16 org_band_end[], /* o: end position of subband */
+ Word16 org_band_width[] /* o: band width of subband */
+);
+
+void spt_shorten_domain_band_restore_fx(
+ const Word16 bands, /* i: total subband */
+ Word16 band_start[], /* i/o: starting position of subband */
+ Word16 band_end[], /* i/o: end position of subband */
+ Word16 band_width[], /* i/o: band width of subband */
+ const Word16 org_band_start[], /* o: starting position of subband */
+ const Word16 org_band_end[], /* o: end position of subband */
+ const Word16 org_band_width[] /* o: band width of subband */
+);
+
+void spt_swb_peakpos_tmp_save_fx(
+ const Word32 L_y2[], /* i: coded spectral information */
+ const Word16 bands, /* i: total number of bands */
+ const Word16 band_start[], /* i: starting position of subband */
+ const Word16 band_end[], /* i: end position of subband */
+ Word16 prev_SWB_peak_pos_tmp[] /* o: spectral peaks */
+);
+
+Word16 div_s_ss( /* o: result of division (Word16 Q0) */
+ const Word16 n, /* i: numerator (Word16 Q0 */
+ const Word16 d /* i: denominator (Word16 Q0) */
+);
+
+void updat_prev_frm_fx(
+ Word32 L_y2[], /* i/o: core coder buffer */
+ Word32 L_t_audio[], /* o: core coder buffer */
+ Word32 L_bwe_br, /* i: core bitrate */
+ Word16 length_fx, /* i: frame length coded bw */
+ const Word16 inner_frame_fx, /* i: input frame length */
+ Word16 bands_fx, /* i: sub band resolution */
+ Word16 bwidth_fx, /* i: NB/WB/SWB indicator */
+ const Word16 is_transient_fx, /* i: signal class information */
+ Word16 hqswb_clas_fx, /* i: signal class information */
+ Word16 *prev_hqswb_clas_fx, /* o: update signal class information */
+ Word16 prev_SWB_peak_pos_fx[], /* o: update core coder last coded peaks*/
+ Word16 prev_SWB_peak_pos_tmp_fx[], /* o: update core coder last coded peaks*/
+ Word16 *prev_frm_hfe2_fx, /* o: update harmonics */
+ Word16 *prev_stab_hfe2_fx, /* o: update harmonics */
+ Word16 bws_cnt_fx /* i: band width detector */
+);
+
+void hf_parinitiz_fx(
+ const Word32 L_total_brate,
+ const Word16 hqswb_clas_fx,
+ Word16 lowlength_fx,
+ Word16 highlength_fx,
+ Word16 wBands_fx[],
+ const Word16 **subband_search_offset_fx,
+ const Word16 **subband_offsets_fx,
+ Word16 *nBands_fx,
+ Word16 *nBands_search_fx,
+ Word16 *swb_lowband_fx,
+ Word16 *swb_highband_fx
+);
+
+void GetlagGains_fx(
+ const Word16 *predBuf_fx, /* i: Qss Low freq. Smoothed Spectrum */
+ const Word16 Qss, /* i: Q0 Q value of predBuf */
+ const Word32 *L_band_energy, /* i: Qbe Band Energy */
+ const Word16 Qbe, /* i: Q0 Q value of band energy */
+ const Word16 nBands, /* i: Q0 number of SWB subbands */
+ const Word16 *sbWidth, /* i: Q0 width of SWB subbands */
+ const Word16 *lagIndices, /* i: Q0 lagIndices */
+ const Word16 predBufLen, /* i: Q0 length of predBuf */
+ Word16 *lagGains_fx, /* o: QlagGains lagGains */
+ Word16 *QlagGains /* o: Q0 Q value of lagGains */
+);
+
+void noise_extr_corcod_fx(
+ Word32 L_spectra[], /* i : QsL core coder */
+ const Word32 L_spectra_ni[], /* i : QsL core coder with sparse filling */
+ Word16 sspectra_fx[], /* o : Qss Smoothed tonal information from core coder */
+ Word16 sspectra_diff_fx[], /* o : Qss non tonal infomration for gap filling */
+ Word16 sspectra_ni_fx[], /* o : Qss smoothed core coder */
+ const Word16 fLenLow_fx, /* i : Q0 low frequency bands width */
+ Word16 prev_hqswb_clas_fx, /* i : Q0 classification information */
+ Word16 *prev_ni_ratio_fx, /* i : Q15 noise paraemeter */
+ Word16 *Qss /* o : Q0 Q value for sspectra_*_fx */
+);
+
+void ton_ene_est_fx(
+ Word32 L_xSynth_har[], /* i : QsL buffer with non tonal compoents */
+ Word16 QsL, /* i : Q0 Q value for xSynth_har */
+ Word32 L_be_tonal[], /* o : QbeL tonal energy of the missing bands */
+ Word16 *QbeL, /* o : Q0 Q value for be_tonal */
+ Word32 L_band_energy[], /* i : Qbe subband energies */
+ Word16 Qbe, /* i : Q0 Q value for band_energy */
+ const Word16 band_start[], /* i : Q0 subband start indices */
+ const Word16 band_end[], /* i : Q0 subband end indices */
+ const Word16 band_width[], /* i : Q0 subband widths */
+ const Word16 fLenLow, /* i : Q0 low frequency width */
+ const Word16 fLenHigh, /* i : Q0 High frequency width */
+ Word16 bands, /* i : Q0 total subbands */
+ Word16 har_bands, /* i : Q0 total number of harmonics bands */
+ Word16 ni_lvl_fx, /* i : Q11 noise enve for the hf bands */
+ GainItem_fx pk_sf_fx[], /* i : */
+ Word16 Qss, /* i : Q0 Q value for GainItem_fx->nmrValue */
+ Word16 *pul_res /* i : Q0 tonal resolution */
+);
+
+void Gettonl_scalfact_fx
+(
+ Word32 *L_outBuf, /* i/o: QsL synthesized spectrum */
+ Word16 QsL, /* i : Q0 Q value for outBuf */
+ const Word32 *L_codbuf, /* i : QsL core coder */
+ const Word16 fLenLow, /* i : Q0 lowband length */
+ const Word16 fLenHigh, /* i : Q0 highband length */
+ const Word16 harmonic_band, /* i : Q0 total number of Low frequency bands */
+ const Word16 bands, /* i : Q0 total number of subbands in a frame */
+ Word32 *L_band_energy, /* i : Qbe band energy of each subband */
+ Word16 Qbe, /* i : Q0 Q value for band_energy */
+ const Word16 *band_start, /* i : Q0 subband start indices */
+ const Word16 *band_end, /* i : Q0 subband end indices */
+ const Word16 p2aflags[], /* i : Q0 missing bands in the core coder */
+ Word32 L_be_tonal[], /* i : QbeL tonal energy */
+ Word16 QbeL, /* i : Q0 Q value for be_tonal */
+ GainItem_fx *pk_sf_fx, /* i : toanl information for Sparse filling */
+ Word16 Qss, /* i : Q0 Q value for pk_sf.nmrValue */
+ Word16 *pul_res_pk /* i : Q0 pulse resolution information */
+);
+
+
+void get_sigma_fx_har(
+ const Word32 L_x_abs[], /* i: Qi absolute input */
+ const Word16 Qi, /* i: Q0 Q value of x_abs */
+ const Word16 avg_fx, /* i: Qavg average of x_abs */
+ const Word16 Qavg, /* i: Q0 Q value of avg */
+ const Word16 length_fx, /* i: Q0 length */
+ Word16 *sigma_fx, /* o: Qsigma sigma */
+ Word16 *Qsigma /* o: Q0 Q value of sigma */
+);
+
+void FindNBiggest2_simple_fx_har(
+ const Word32 *L_inBuf, /* i : input buffer (searched) */
+ const Word16 Qabs_in, /* i : Q value of input buffer */
+ GainItem_fx *pk_sf_fx, /* o : N biggest components found */
+ const Word16 nIdx_fx, /* i : search length */
+ Word16 *n_fx, /* i : number of components searched (N biggest) */
+ Word16 n_nbiggestsearch
+);
+
+Word16 spectrumsmooth_noiseton_fx( /* o : Qss ss_min */
+ Word32 L_spectra[], /* i : Qs core coder */
+ /*Word16 Qs,*/ /* i : Q0 Q value for spectra, spectra_ni */
+ const Word32 L_spectra_ni[], /* i : Qs core coder with sparse filling */
+ Word16 sspectra_fx[], /* o : Qss Smoothed tonal information from core coder */
+ Word16 sspectra_diff_fx[], /* o : Qss non tonal infomration for gap filling */
+ Word16 sspectra_ni_fx[], /* o : Qss smoothed core coder */
+ Word16 *Qss, /* o : Q0 Q value for sspectra* */
+ const Word16 fLenLow_fx, /* i : Q0 low frequency boundaries */
+ Word16 *ni_seed_fx /* io : Q0 random seed */
+);
+
+void noiseinj_hf_fx(
+ Word32 L_xSynth_har[], /* i/o : Qs gap filled information */
+ Word16 Qs, /* i : Q0 Q value for xSynth_har */
+ Word32 L_th_g[], /* i : Qs level adjustment information */
+ Word32 L_band_energy[], /* i : Qbe subband energies */
+ Word16 Qbe, /* i : Q0 Q value for band_energy */
+ Word16 *prev_En_sb_fx, /* i/o : QsEn smoothed sqrt band Energies */
+ const Word16 p2a_flags_fx[], /* i : Q0 Missing bands in the core coder */
+ const Word16 BANDS_fx, /* i : Q0 total bands */
+ const Word16 band_start_fx[], /* i : Q0 band start indices */
+ const Word16 band_end_fx[], /* i : Q0 band end indices */
+ const Word16 fLenLow_fx, /* i : Q0 low frequency bandwidth */
+ const Word16 fLenHigh_fx /* i : Q0 SWB frequency bandwidth */
+);
+
+void sqrt_32n_16_fx(
+ Word32 L_in, /* i : input vector (Word32) */
+ Word16 Qin, /* i : Q value for L_in */
+ Word16 *out_fx, /* o : sqrt input vector (Word16) */
+ Word16 *Qout /* o : Q value for out_fx */
+);
+
+void norm_vec_32_16_scale_fx(
+ Word32 *L_vec_in, /* i : input vector */
+ Word16 Qin, /* i : Q value for input vector */
+ Word16 length_fx, /* i :vector size */
+ Word16 *vec_out_fx, /* o : output vectror */
+ Word16 *Qout, /* o : Q value for output vectro */
+ Word16 exp_safe /* i : suppress left shift: for prevend overflow on sum */
+);
+
+void return_bits_normal2_fx(
+ Word16 *bit_budget_fx, /* i/o : bit budget */
+ const Word16 p2a_flags_fx[], /* i : HF tonal indicator */
+ const Word16 bands_fx, /* i : Total number of Subbands in a frame */
+ const Word16 bits_lagIndices_fx[] /* i : bits for lagIndices */
+);
+
+Word16 peak_avrg_ratio_fx(
+ const Word32 total_brate,
+ const Word32 *input_hi_fx, /* i : input signal */
+ const Word16 length, /* i : number of coefficients */
+ Word16 *mode_count, /* i/o: HQ_HARMONIC mode count */
+ Word16 *mode_count1, /* i/o: HQ_NORMAL mode count */
+ Word16 Q_coeff
+);
+
+void diffcod_fx(
+ const Word16 N, /* (i) number of sub-vectors */
+ Word16 *y, /* (i/o) indices of quantized norms */
+ Word16 *difidx /* (o) differential code */
+);
+
+void diffcod_lrmdct_fx(
+ const Word16 N, /* i : number of sub-vectors */
+ const Word16 be_ref, /* i : band energy reference */
+ Word16 *y, /* i/o: indices of quantized norms */
+ Word16 *difidx, /* o : differential code */
+ const Word16 is_transient /* i : transient flag */
+);
+
+Word16 encode_envelope_indices_fx( /* o : Number of bits if flag_pack=0,0 if flag_pack=1 Q0 */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 num_sfm, /* i : Number of subbands Q0 */
+ const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode Q0 */
+ Word16 *difidx, /* i/o: Diff indices/encoded diff indices Q0 */
+ Word16 *LCmode, /* o : Coding mode if flag_pack=0, i : if flag_pack=1 Q0 */
+ const Word16 flag_pack, /* i : indicator of packing or estimating bits Q0 */
+ const Word16 flag_HQ2 /* i : indicator of HQ2 core Q0 */
+ ,
+ const Word16 is_transient /* i : indicator of HQ_TRANSIENT Q0 */
+);
+Word16 decode_envelope_indices_fx( /* o : Number of bits */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 start_norm, /* i : starting band index */
+ const Word16 num_sfm, /* i : Number of subbands */
+ const Word16 numnrmibits, /* i : Bitrate of fall-back coding mode */
+ Word16 *difidx, /* o : Diff indices/encoded diff indices */
+ const Word16 flag_HQ2 /* i : indicator of HQ2 core */
+ ,
+ const Word16 is_transient /* i : indicator of HQ_TRANSIENT */
+);
+
+void hdecnrm_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 numNorms, /* (i) number of norms */
+ Word16 *index); /* (o) indices of quantized norms */
+
+Word16 decode_huff_context_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 *hufftab,
+ Word16 *rbits
+);
+
+void hdecnrm_context_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 N,
+ Word16 *index,
+ Word16 *n_length
+);
+
+void hdecnrm_resize_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 N, /* (i) number of SFMs */
+ Word16 *index /* (o) norm quantization index vector */
+);
+
+void hdecnrm_tran_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 N, /* i : number of norms */
+ Word16 *index /* o : indices of quantized norms */
+);
+
+void mdct_spectrum_denorm_fx(
+ const Word16 inp_vector[], /* i : Q0 : */
+ Word32 L_y2[], /* i/o : Qs : decoded spectrum */
+ const Word16 band_start[], /* i : Q0 : table of start freq for every subband */
+ const Word16 band_end[], /* i : Q0 : table of end freq for every subband */
+ const Word16 band_width[], /* i : Q0 : table of bandwidth for every subband */
+ const Word32 L_band_energy[], /* i : Qbe : band energy */
+ const Word16 npulses[], /* i : Q0 : number of coded spectrum */
+ const Word16 bands, /* i : Q0 : numbers of subbands */
+ const Word16 ld_slope_fx, /* i : Q15 : */
+ const Word16 pd_thresh_fx /* i : Q15 : */
+);
+
+/* y(n)(Qx) = alpha(Q15) * x(Qx) + (1.0f-alpha)* y(n-1) (Qx) */
+Word16 noise_est_AR1_Qx( /* o: Qx y(n) */
+ Word16 x, /* i : Qx x(n) */
+ Word16 y, /* i : Qx y(n-1) */
+ Word16 alpha /*i : Q15 scaling of driving x(n) */
+);
+void noise_est_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ const Word32 tmpN[], /* i : temporary noise update Q_new + QSCALE */
+ const Word16 *pit, /* i : open-loop pitch values for each half-frame Q0 */
+ const Word16 cor[], /* i : normalized correlation for all half-frames Q15 */
+ const Word16 epsP_h[], /* i : msb prediction error energies Q_r-1 */
+ const Word16 epsP_l[], /* i : msb prediction error energies Q_r-1 */
+ const Word16 Etot, /* i : total channel E (see find_enr_fx.c) Q8 */
+ const Word16 relE, /* i : (VA_CHECK addition) relative frame energy Q8? */
+ const Word16 corr_shift, /* i : normalized correlation correction Q15 */
+ const Word32 enr[], /* i : averaged energy over both subframes Q_new + Q_SCALE */
+ Word32 fr_bands[], /* i : spectrum per critical bands of the current frame Q_new + Q_SCALE */
+ Word16 *cor_map_sum, /* o : Q8 */
+ Word16 *sp_div, /* o : Q_sp_div */
+ Word16 *Q_sp_div, /* o : Q factor for sp_div */
+ Word16 *non_staX, /* o : non-stationarity for sp/mus classifier */
+ Word16 *loc_harm , /* o : multi-harmonicity flag for UV classifier */
+ const Word32 *lf_E, /* i : per bin energy for low frequencies Q_new + Q_SCALE -2 */
+ Word16 *st_harm_cor_cnt, /* i/o : 1st harm correlation timer Q0 */
+ const Word16 Etot_l_lp, /* i : Smoothed low energy Q8 */
+ const Word16 Etot_v_h2, /* i : Energy variations Q8 */
+ Word16 *bg_cnt, /* i : Background burst length timer Q0 */
+ Word16 EspecdB[], /* i/o: log E spectrum (with f=0) of the current frame Q7 */
+ Word16 Q_new , /* i : Scaling of current frame */
+
+ const Word32 Le_min_scaled /*i : Minimum energy value */
+ , Word16 *sp_floor /* o : noise floor estimate Q7 */
+);
+
+
+void autocorr_fx(
+ const Word16 x[], /* i : Input signal */
+ const Word16 m, /* i : LPC order Q0 */
+ Word16 r_h[], /* o : Autocorrelations (msb) Q15 */
+ Word16 r_l[], /* o : Autocorrelations (lsb) */
+ Word16 *Q_r, /* o : normailsation shift of r Q0 */
+ const Word16 len, /* i : Frame lenght */
+ const Word16* wind, /* i : Window used */
+ Word16 rev_flag,
+ const Word16 sym_flag /* i : symmetric window flag */
+);
+void freq_dnw_scaling_fx(
+ const Word16 cor_strong_limit, /* i : HF correlation */
+ const Word16 coder_type, /* i : coder type */
+ const Word16 noise_lev, /* i : Noise level */
+ const Word32 core_brate, /* i : Core bitrate */
+ Word16 fy_norm[], /* i/o: Frequency quantized parameter */
+ Word16 Qx /* Q format of fy_norm*/
+);
+void Comp_and_apply_gain_fx(
+ Word16 exc_diffQ[], /* i/o: Quantized excitation */
+ Word16 Ener_per_bd_iQ[], /* i : Target ener per band Q13 */
+ Word16 Ener_per_bd_yQ[], /* i/o : Ener per band for norm vector i->Q13/o->Q13 */
+ Word16 Mbands_gn, /* i : number of bands */
+ const Word16 ReUseGain , /* i : Reuse the gain in Ener_per_bd_yQ */
+ Word16 Qexc_diff,
+ Word16 Q_exc
+);
+void dec_pit_exc_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word16 *Aq_fx, /* i : LP filter coefficient */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16 *code_fx, /* o : innovation */
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ const Word16 nb_subfr_fx /* i : Number of subframe considered */
+ , Word16 *gain_buf /*Q14*/
+);
+Word16 mean_fx( /* o : mean of vector */
+ const Word16 *vec_fx, /* i : input vector */
+ const Word16 lvec_fx /* i : length of input vector */
+);
+void gsc_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: State structure */
+ Word16 exc_dct_in[], /* i/o: dct of pitch-only excitation / total excitation */
+ const Word16 pit_band_idx, /* i : bin position of the cut-off frequency */
+ const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
+ const Word16 bits_used, /* i : Number of bit used before frequency Q */
+ const Word16 nb_subfr, /* i : Number of subframe considered */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *last_bin, /* i : last bin of bit allocation */
+ Word16 *lsf_new, /* i : ISFs at the end of the frame */
+ Word16 *exc_wo_nf, /* o : excitation (in f domain) without noisefill */
+ Word16 Q_exc
+);
+void fft_rel_fx(
+ Word16 x[], /* i/o: input/output vector */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+);
+void ifft_rel_fx(
+ Word16 io[], /* i/o: input/output vector */
+ const Word16 n, /* i : vector length */
+ const Word16 m /* i : log2 of vector length */
+);
+
+Word16 gsc_gaindec_fx( /* o : average frequency gain */
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 y_gainQ_fx[], /* o : quantized gain per band */
+ const Word32 core_brate_fx, /* i : core used */
+ Word16 old_y_gain_fx[], /* i/o: AR gain quantizer for low rate */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 bwidth_fx /* i : input signal bandwidth */
+);
+void Copy_Scale_sig(
+ const Word16 x[], /* i : signal to scale input Qx */
+ Word16 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+
+void bands_and_bit_alloc_fx(
+ const Word16 cor_strong_limit, /* i : HF correlation */
+ const Word16 noise_lev, /* i : dwn scaling factor */
+ const Word32 core_brate, /* i : core bit rate */
+ const Word16 Diff_len, /* i : Lenght of the difference signal (before pure spectral)*/
+ const Word16 bits_used, /* i : Number of bit used before frequency Q */
+ Word16 *bit, /* i/o: Number of bit allowed for frequency quantization */
+ const Word16 *Ener_per_bd_iQ, /* i/o: Quantized energy vector */
+ Word16 *max_ener_band, /* o : Sorted order */
+ Word16 *bits_per_bands, /* i/o: Number of bit allowed per allowed subband Q3 */
+ Word16 *nb_subbands, /* o : Number of subband allowed */
+ const Word16 *exc_diff, /* i : Difference signal to quantize (encoder side only) */
+ Word16 *concat_in, /* o : Concatened PVQ's input vector (encoder side only) */
+ Word16 *pvq_len, /* o : Number of bin covered with the PVQ */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 bwidth, /* i : input signal bandwidth */
+ const Word16 GSC_noisy_speech
+);
+
+
+void decod_audio_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ Word16 dct_epit[], /* o : GSC excitation in DCT domain */
+ const Word16 *Aq, /* i : LP filter coefficient */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *pitch_buf, /* o : floating pitch values for each subframe */
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 *exc, /* i/o: adapt. excitation exc */
+ Word16 *exc2, /* i/o: adapt. excitation/total exc */
+ Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ Word16 *lsf_new /* i : ISFs at the end of the frame */
+ , Word16 *gain_buf /*Q14*/
+);
+Word16 Pit_exc_contribution_len_fx( /* o : bin where pitch contribution is significant */
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ const Word16 *dct_res, /* i : DCT of residual */
+ Word16 *dct_pitex, /* i/o: DCT of pitch contribution */
+ Word16 *pitch_buf, /* i/o: Pitch per subframe */
+ const Word16 nb_subfr, /* i : Number of subframe considered */
+ Word16 *hangover, /* i : hangover for the time contribution switching */
+ const Word16 coder_type, /* i : coding type */
+ Word16 Qnew
+);
+void enc_pit_exc_fx(
+ Encoder_State_fx *st_fx, /* i/o: State structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 *speech, /* i : Input speech */
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 Aq[], /* i : 12k8 Lp coefficient */
+ const Word16 Es_pred, /* i : predicted scaled innov. energy */
+ const Word16 *T_op, /* i : open loop pitch */
+ const Word16 *voicing, /* i : voicing */
+ const Word16 *res, /* i : residual signal */
+ Word16 *synth, /* i/o: core synthesis */
+ Word16 *exc, /* i/o: current non-enhanced excitation */
+ Word16 *T0, /* i/o: close loop integer pitch */
+ Word16 *T0_frac, /* i/o: close-loop pitch period - fractional part */
+ Word16 *pitch_buf, /* i/o: Fractionnal per subframe pitch */
+ const Word16 nb_subfr, /* i : Number of subframe considered */
+ Word16 *gpit, /* o : pitch mean gpit */
+ Word16 *saved_bit_pos, /* o : saved position in the bitstream before pitch contribution */
+ Word16 Q_new,
+ Word16 shift
+);
+void encod_amr_wb_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 speech[], /* i : input speech */
+ const Word16 Aw[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 Aq[], /* i : 12k8 Lp coefficient */
+ const Word16 pitch[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 voicing[], /* i : voicing */
+ const Word16 *res, /* i : residual signal */
+ Word16 *syn, /* i/o: core synthesis */
+ Word16 *exc, /* i/o: current non-enhanced excitation */
+ Word16 *exc2, /* i/o: current enhanced excitation */
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subframe */
+ Word16 hf_gain_fx[NB_SUBFR], /* o : decoded HF gain */
+ const Word16 *speech16k_fx,
+ Word16 shift,
+ Word16 Q_new
+);
+void amr_wb_enc_fx(
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 input_sp[], /* i : input signal */
+ const Word16 n_samples /* i : number of input samples */
+);
+void encod_gen_voic_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 L_frame_fx, /* i : length of the frame */
+ const Word16 sharpFlag_fx, /* o : formant sharpening flag */
+ const Word16 speech_fx[], /* i : input speech */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ const Word16 A_fx[], /* i : unquantized A(z) filter with bandwidth expansion */
+ const Word16 coder_type_fx, /* i : coding type */
+ const Word16 Es_pred_fx, /* i : predicted scaled innov. energy */
+ const Word16 T_op_fx[], /* i : open loop pitch */
+ const Word16 voicing_fx[], /* i : voicing */
+ const Word16 *res_fx, /* i : residual signal */
+ Word16 *syn_fx, /* i/o: core synthesis */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *exc2_fx, /* i/o: current enhanced excitation */
+ Word16 *pitch_buf_fx, /* i/o: floating pitch values for each subframe */
+ Word16 *voice_factors_fx, /* o : voicing factors */
+ Word16 *bwe_exc_fx, /* o : excitation for SWB TBE */
+ Word16 *unbits_fx, /* i/o: number of unused bits */
+ Word16 shift,
+ Word16 Q_new
+);
+void bw_detect_fx(
+ Encoder_State_fx *st, /* i/o: Encoder State */
+ const Word16 signal_in[], /* i : input signal */
+ const Word16 localVAD,
+ Word32 *enerBuffer, /* i : CLDFB Energy */
+ Word16 *cldfbBuf_Ener_Exp /* i : CLDFB Energy Exponent */
+);
+void hf_synth_amr_wb_init_fx(
+ Word16 *prev_r, /* o : previous sub-frame gain */
+ Word16 *fmerit_w_sm, /* o : 1 sample memory fmerit_w param */
+ Word16 mem_syn_hf_fx[], /* o : HF LPC synthesis filter initialization */
+ Word16 *frame_count, /* o : frame counter initialization */
+ Word16 *ne_min, /* o : minimum Noise gate - short-term energy initialization*/
+ Word16 *fmerit_m_sm, /* o : 1 sample memory fmerit_m param */
+ Word16 *voice_fac, /* o : voice factor initialization */
+ Word16 *unvoicing, /* o : unvoiced parameter */
+ Word16 *unvoicing_sm, /* o : smoothed unvoiced parameter */
+ Word16 *unvoicing_flag, /* o : unvoiced flag */
+ Word16 *voicing_flag, /* o : voiced flag */
+ Word16 *start_band_old, /* o : previous start point for copying frequency band */
+ Word32 *OptCrit_old /* o : previous criterion value for deciding the start point */
+);
+
+void hf_synth_amr_wb_reset_fx(
+ Word16 *seed2, /* i/o: random seed for HF noise gen */
+ Word16 mem_syn_hf[], /* o : HF synthesis memory */
+ Word16 mem_hp_interp[], /* o : interpol. memory */
+ Word16 *prev_r, /* o : previous sub-frame gain */
+ Word16 *fmerit_w_sm, /* o : 1 sample memory fmerit_w param */
+ Word16 delay_syn_hf[], /* o : HF synthesis memory */
+ Word16 *frame_count, /* o : frame counter memory */
+ Word16 *ne_min, /* o : minimum Noise gate - short-term energy memory */
+ Word16 *fmerit_m_sm, /* o : 1 sample memory fmerit_m param */
+ Word16 *voice_fac, /* o : voice factor memory */
+ Word16 *unvoicing, /* o : unvoiced parameter */
+ Word16 *unvoicing_sm, /* o : smoothed unvoiced parameter */
+ Word16 *unvoicing_flag, /* o : unvoiced flag */
+ Word16 *voicing_flag, /* o : voiced flag */
+ Word16 *start_band_old, /* o : previous start point for copying frequency band */
+ Word32 *OptCrit_old /* o : previous criterion value for deciding the start point */
+);
+
+void hf_synth_amr_wb_fx(
+ const Word32 core_brate, /* i : core bitrate */
+ const Word16 output_frame, /* i : output frame length */
+ const Word16 *Aq, /* i : quantized Az : Q12 */
+ const Word16 *exc, /* i : excitation at 12.8 kHz : Qexc */
+ Word16 *synth, /* i/o: synthesis signal at 12.8k : Qsyn */
+ Word16 *mem_syn_hf, /* i/o: HF synthesis memory : Qout */
+ Word16 *delay_syn_hf, /* i/o: HF synthesis memory : Qout */
+ Word16 *prev_r, /* i/o : previous sub-frame gain : Q10 */
+ Word16 *fmerit_w_sm, /* i/o: smoothed fmerit_w : Q14 */
+ Word16 *amr_io_class, /* i : signal class (determined by FEC algorithm) */
+ Word16 *mem_hp_interp, /* i/o: interpol. memory : Qout */
+ Word16 *synth_out, /* i/o: output signal at output Fs : Qout */
+ Word16 fmerit, /* i : classify parameter from FEC : Q14 */
+ const Word16 *hf_gain, /* i : decoded HF gain */
+ const Word16 *voice_factors, /* i : voicing factors : Q15 */
+ const Word16 pitch_buf[], /* i : pitch buffer : Q5 */
+ const Word16 ng_ener_ST, /* i : Noise gate - short-term energy : Q8 */
+ const Word16 *lsf_new, /* i : ISF vector : Q2 */
+ Word16 *frame_count, /* i/o: frame counter */
+ Word16 *ne_min, /* i/o: minimum Noise gate : Q8 */
+ Word16 *fmerit_m_sm, /* i/o: smoothed fmerit_m : Q14 */
+ Word16 *voice_facor_sm, /* o : voice factor memory : Q15 */
+ Word16 *unvoicing, /* o : unvoiced parameter : Q15 */
+ Word16 *unvoicing_sm, /* o : smoothed unvoiced parameter : Q15 */
+ Word16 *unvoicing_flag, /* o : unvoiced flag */
+ Word16 *voicing_flag, /* o : voiced flag */
+ Word16 *start_band_old, /* o : previous start point for copying frequency band */
+ Word32 *OptCrit_old, /* o : previous criterion value for deciding the start point */
+ const Word16 Q_exc, /* i : exc scaling */
+ const Word16 Q_out /* i : synth_out scaling */
+);
+
+void hf_cod_init_fx(
+ Word16 *mem_hp400_enc, /* o: memory of hp 400 Hz filter */
+ Word16 *mem_hf1_enc, /* o: HF band-pass filter memory */
+ Word16 *mem_syn_hf_enc, /* o: HF synthesis memory */
+ Word16 *mem_hf2_enc, /* o: HF band-pass filter memory */
+ Word16 *gain_alpha_fx /* o: smoothing gain for transitions between active and inactive frames */
+);
+
+void hf_cod_fx(
+ const Word32 core_brate_fx, /* i : core bitrate */
+ const Word16 *speech16k_fx, /* i : original speech at 16 kHz */
+ const Word16 Aq_fx[], /* i : quantized Aq */
+ const Word16 exc_fx[], /* i : excitation at 12.8 kHz */
+ Word16 synth_fx[], /* i : 12.8kHz synthesis signal */
+ Word16 *seed2_enc_fx, /* i/o: random seed for HF noise gen */
+ Word16 *mem_hp400_enc_fx, /* i/o: memory of hp 400 Hz filter */
+ Word16 *mem_syn_hf_enc_fx, /* i/o: HF synthesis memory */
+ Word16 *mem_hf1_enc_fx, /* i/o: HF band-pass filter memory */
+ Word16 *mem_hf2_enc_fx, /* i/o: HF band-pass filter memory */
+ const Word16 dtxHangoverCount_fx,
+ Word16 *gain_alpha_fx, /* i/o: smoothing gain for transitions between active and inactive frames */
+ Word16 *hf_gain_fx, /* o : HF gain to be transmitted to decoder */
+ Word16 Q_exc,
+ Word16 Q_syn
+);
+
+void re8_compute_base_index_fx(
+ const Word16 *x, /* i : Elemen of Q2, Q3 or Q4 */
+ const Word16 ka, /* i : Identifier of the absolute leader related to x */
+ UWord16 *I /* o : index */
+);
+
+void InitSWBencBuffer_fx(
+ Encoder_State_fx* st_fx /* i/o: SHB encoder structure */
+);
+
+void ResetSHBbuffer_Enc_fx(
+ Encoder_State_fx* st_fx /* i/o: SHB encoder structure */
+);
+void wb_tbe_extras_reset_synth_fx( Word16 state_lsyn_filt_shb[], Word16 state_lsyn_filt_dwn_shb[],
+ Word16 state_32and48k_WB_upsample[]
+ ,Word16 state_resamp_HB[]
+ );
+
+void pz_filter_sp_fx (
+ const Word16 b [],
+ const Word16 a [],
+ Word16 x [],
+ Word16 y [],
+ Word16 buf [],
+ Word16 PNR,
+ Word16 PDR,
+ Word16 N,
+ Word16 Qa
+);
+
+void Decimate_allpass_steep_fx(
+ const Word16 *in_fx,
+ Word16 state_fx[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
+ Word16 N, /* number of input samples */
+ Word16 out_fx[] /* array of size N/2 */
+);
+
+Word32 root_a_fx(
+ Word32 a,
+ Word16 Q_a,
+ Word16 *exp_out
+);
+
+Word32 root_a_over_b_fx(
+ Word32 a,
+ Word16 Q_a,
+ Word32 b,
+ Word16 Q_b,
+ Word16 *exp_out
+);
+
+
+void fir_fx(
+ const Word16 x[], /* i : input vector */
+ const Word16 h[], /* i : impulse response of the FIR filter */
+ Word16 y[], /* o : output vector (result of filtering) */
+ Word16 mem[], /* i/o: memory of the input signal (M samples) */
+ const Word16 L, /* i : input vector size */
+ const Word16 K, /* i : order of the FIR filter (M+1 coefs.) */
+ const Word16 upd, /* i : 1 = update the memory, 0 = not */
+ Word16 shift /* i : difference between Q15 and scaling of h[] */
+);
+
+
+void Interpolate_allpass_steep_fx(
+ const Word16 *in_fx, /* i : input signal */
+ Word16 state_fx[], /* array of size: 2*ALLPASSSECTIONS_STEEP+1 */
+ Word16 N, /* number of input samples */
+ Word16 out_fx[] /* o : output signal, size 2*N */
+);
+
+void interpolate_3_over_2_allpass_fx(
+ const Word16 *input_fx,
+ const Word16 len,
+ Word16 *out_fx,
+ Word16 *mem_fx,
+ const Word16 *filt_coeff_fx
+);
+void interpolate_3_over_1_allpass_fx(
+ const Word16 *input_fx,
+ const Word16 len,
+ Word16 *out_fx,
+ Word16 *mem_fx,
+ const Word16 *filt_coeff_fx
+);
+void decimate_2_over_3_allpass_fx(
+ const Word16 *input_fx,
+ const Word16 len,
+ Word16 *out_fx,
+ Word16 *mem_fx,
+ const Word16 *filt_coeff_fx,
+ const Word16 *lp_num_fx,
+ const Word16 *lp_den_fx,
+ Word16 *lp_mem_fx
+);
+
+void retro_interp4_5_fx(
+ const Word16 *syn_fx,
+ Word16 *pst_old_syn_fx
+);
+void retro_interp5_4_fx(
+ Word16 *pst_old_syn_fx
+);
+
+void lsp2lpc_fx(
+ Word16 *a,
+ Word16 *freq,
+ Word16 *prev_a,
+ Word16 order
+);
+
+void PostShortTerm_fx(
+ Word16 *sig_in, /* i : input signal (pointer to current subframe */
+ Word16 *lpccoeff, /* i : LPC coefficients for current subframe */
+ Word16 *sig_out, /* o : postfiltered output */
+ Word16 *mem_stp, /* i/o: postfilter memory*/
+ Word16 *ptr_mem_stp, /* i/o: pointer to postfilter memory*/
+ Word16 *ptr_gain_prec, /* i/o: for gain adjustment*/
+ Word16 *mem_zero, /* i/o: null memory to compute h_st*/
+ Word16 formant_fac_fx /* i : Strength of post-filter*/
+);
+
+void GenShapedWBExcitation_fx(
+ Word16 *excSHB, /* o : synthesized shaped shb exctiation */
+ const Word16 *lpc_shb, /* i : lpc coefficients */
+ Word16 *exc4kWhtnd, /* o : whitened synthesized shb excitation */
+ Word32 *mem_csfilt, /* i/o : memory */
+ Word16 *mem_genSHBexc_filt_down1, /* i/o : memory */
+ Word16 *mem_genSHBexc_filt_down2, /* i/o : memory */
+ Word16 *mem_genSHBexc_filt_down3, /* i/o : memory */
+ Word16 *state_lpc_syn, /* i/o : memory */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 *bwe_exc_extended, /* i : bandwidth extended exciatation */
+ const Word16 Q_bwe_exc,
+ Word16 bwe_seed[], /* i/o : random number generator seed */
+ const Word16 voice_factors[], /* i : voicing factor */
+ const Word16 signal_type
+ , const Word16 igf_flag
+);
+
+void GenWBSynth_fx(
+ const Word16 *input_synspeech, /* i : input synthesized speech */
+ Word16 *shb_syn_speech_16k, /* o : output highband compnent */
+ Word16 *state_lsyn_filt_shb1, /* i/o: memory */
+ Word16 *state_lsyn_filt_shb2 /* i/o: memory */
+);
+
+void GenSHBSynth_fx(
+ const Word16 *shb_target_speech, /* i : input synthesized speech */
+ Word16 *shb_syn_speech_32k, /* o : output highband component */
+ Word32 Hilbert_Mem[], /* i/o: memory */
+ Word16 genSHBsynth_allpass_mem[], /* i/o: memory */
+ const Word16 L_frame, /* i : ACELP Frame length */
+ Word16 *syn_dm_phase
+);
+
+Word16 swb_formant_fac_fx( /* o : Formant filter strength [0,1] */
+ const Word16 lpc_shb2, /* Q12 i : 2nd HB LPC coefficient */
+ Word16* tilt_mem /* i/o: Tilt smoothing memory */
+);
+
+void compute_poly_product_fx(Word16 *coef, Word32 *p,Word16 order);
+
+void ScaleShapedSHB_fx(
+ const Word16 length, /* i : SHB overlap length */
+ Word16 *synSHB, /* i/o: synthesized shb signal */
+ Word16 *overlap, /* i/o: buffer for overlap-add */
+ const Word16 *subgain, /* i : subframe gain */
+ const Word32 frame_gain, /* i : frame gain */
+ const Word16 *win, /* i : window */
+ const Word16 *subwin, /* i : subframes window */
+ Word16 *Q_bwe_exc
+ ,Word16 *Qx
+ ,Word16 n_mem3
+ ,Word16 prev_Q_bwe_syn2
+);
+
+void ScaleShapedWB_fx(
+ const Word16 length, /* i : SHB overlap length */
+ Word16* synSHB, /* i/o : synthesized shb signal */
+ Word16* overlap, /* i/o : buffer for overlap-add */
+ const Word16* subgain, /* i : subframe gain */
+ const Word32 frame_gain, /* i : frame gain */
+ const Word16* win, /* i : window */
+ const Word16* subwin, /* i : subframes window */
+ const Word16 Q_bwe_exc
+ ,Word16 L_frame /* i : Frame length - determines whether 12.8 or 16kHz core in-use */
+ ,Word16 dynQ /* i : indicate whether output is dynamic Q, or Q0 */
+ ,Word16* Qx /* o : newly computed Q factor for synSHB */
+ ,Word16 prev_Qx /* i : prev_Qx for memory scaling */
+ ,Word32* Hilbert_Mem /* i : Hilbert memory used for computing Qx */
+);
+
+void GenShapedSHBExcitation_fx(
+ Word16 *excSHB, /* o : synthesized shaped shb excitation Q_bwe_exc*/
+ const Word16 *lpc_shb, /* i : lpc coefficients Q12*/
+ Word16 *White_exc16k_FB, /* o : white excitation for the Fullband extension Q_bwe_exc */
+ Word32 *mem_csfilt, /* i/o: memory */
+ Word16 *mem_genSHBexc_filt_down_shb, /* i/o: memory */
+ Word16 *state_lpc_syn, /* i/o: memory */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 *bwe_exc_extended, /* i : bandwidth extended excitation */
+ Word16 bwe_seed[], /* i/o: random number generator seed */
+ Word16 voice_factors[], /* i : voicing factor*/
+ const Word16 extl, /* i : extension layer */
+ Word16 *tbe_demph, /* i/o: de-emphasis memory */
+ Word16 *tbe_premph, /* i/o: pre-emphasis memory */
+ Word16 *lpc_shb_sf, /* i: LP coefficients */
+ const Word32 shb_ener_sf_32,
+ Word16 *shb_res_gshape,
+ Word16 *shb_res,
+ Word16 *vf_ind,
+ const Word16 formant_fac, /* i : Formant sharpening factor [0..1] */
+ Word16 fb_state_lpc_syn[], /* i/o: memory */
+ Word16 *fb_tbe_demph, /* i/o: fb de-emphasis memory */
+ Word16 *Q_bwe_exc,
+ Word16 *Q_bwe_exc_fb,
+ const Word16 Q_shb,
+ Word16 n_mem2, /* i : n_mem2 scale factor to adjust 24.4/32kbps memories */
+ Word16 prev_Q_bwe_syn, /* i : st_fx->prev_Q_bwe_syn */
+ const Word32 bitrate,
+ const Word16 prev_bfi
+);
+
+
+void space_lsfs_fx (
+ Word16 *lsfs, /* i/o: Line spectral frequencies */
+ const Word16 order /* i : order of LP analysis */
+);
+
+
+void lsp_weights_fx(
+ Word16 lsp_nq_fx[],
+ Word16 w[],
+ Word16 Order,
+ Word16 *Qout
+);
+
+
+void lsp_convolve_fx(Word32 x, Word32 *p1, Word32 *p2, Word16 len);
+Word32 poscos_fx(Word16 w);
+
+void flip_spectrum_and_decimby4_fx(
+ const Word16 input[], /* i : input spectrum */
+ Word16 output[], /* o : output spectrum */
+ const Word16 length, /* i : vector length */
+ Word16 mem1[], /* i/o : memory */
+ Word16 mem2[], /* i/o : memory */
+ const Word16 ramp_flag /* i : flag to trigger slow ramp-up of output following change of core */
+);
+
+
+Word16 lpc2lsp_fx(
+ Word32 *a,
+ Word16 *freq,
+ Word16 *old_freq,
+ Word16 order
+);
+
+Word16 usquant_fx( /* o: index of the winning codeword */
+ const Word16 x, /* i: scalar value to quantize Qx*/
+ Word16 *xq, /* o: quantized value Qx*/
+ const Word16 qlow, /* i: lowest codebook entry (index 0) Qx*/
+ const Word16 delta, /* i: quantization step Qx-1*/
+ const Word16 cbsize /* i: codebook size */
+);
+
+void wb_tbe_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 *hb_speech, /* i : HB target signal (6-8kHz) at 16kHz */
+ const Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */
+ const Word16 Q_new, /* i : input HB speech Q factor */
+ const Word16 voice_factors[], /* i : voicing factors */
+ const Word16 pitch_buf[], /* i : pitch for each subframe */
+ const Word16 voicing[] /* i : OL maximum normalized correlation */
+);
+
+void wb_pre_proc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *new_inp_resamp16k, /* i : original input signal */
+ Word16 *hb_speech /* o : HB target signal (6-8kHz) at 16kHz */
+);
+
+
+void pz_filter_dp_fx (
+ const Word16 b [],
+ const Word16 a [],
+ Word16 x [],
+ Word16 y [],
+ Word32 buf [],
+ Word16 PNR,
+ Word16 PDR,
+ Word16 N,
+ Word16 Qa
+);
+
+void flip_and_downmix_generic_fx(
+ Word16 input[], /* i : input spectrum */
+ Word16 output[], /* o : output spectrum */
+ const Word16 length, /* i : length of spectra */
+ Word32 mem1_ext[HILBERT_ORDER1], /* i/o: Hilbert filter memory */
+ Word32 mem2_ext[2*HILBERT_ORDER2], /* i/o: memory */
+ Word32 mem3_ext[2*HILBERT_ORDER2], /* i/o: memory */
+ Word16 *phase_state /* i/o: Phase state in case frequency isn't multiple of 50 Hz */
+);
+
+
+void wb_tbe_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 coder_type, /* i : coding type */
+ Word32 *bwe_exc_extended, /* i : bandwidth extended exciatation */
+ const Word16 Q_exc,
+ const Word16 voice_factors[], /* i : voicing factors */
+ Word16 *synth, /* i/o: ACELP core synthesis/final synthesis */
+ Word16 *Q_synth
+);
+
+void swb_tbe_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 coder_type_fx, /* i : coding type */
+ Word16 *new_speech_fx, /* i : original input signal */
+ Word32 *bwe_exc_extended_fx, /* i : bandwidth extended excitation */
+ const Word16 voice_factors_fx[], /* i : voicing factors */
+ Word16 *White_exc16k_fx, /* o : shaped white excitation for the FB TBE */
+ Word16 *Q_white_exc, /* o : generated white noise for FB Q factor */
+ Word16 Q_bwe_exc, /* i : bandwidth extended excitation Q factor */
+ Word16 Q_shb, /* i : SHB target Q factor */
+ Word16 *voicing_fx, /* i : OL maximum normalized correlation */
+ const Word16 pitch_buf[] /* i : pitch for each subframe */
+);
+
+void swb_pre_proc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 *input_fx, /* i : original input signal */
+ Word16 *new_swb_speech_fx, /* o : original input signal at 32kHz */
+ Word16 *shb_speech_fx, /* o : SHB target signal (6-14kHz) at 16kHz */
+ Word16 *Q_shb_spch /* o : shb target signal Q factor */
+ , Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* i : real buffer */
+ , Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX] /* i : imag buffer */
+ ,const CLDFB_SCALE_FACTOR *cldfbScale /* i : scale data of real and imag CLDFB buffers */
+);
+
+void wb_tbe_extras_reset_fx(
+ Word16 mem_genSHBexc_filt_down_wb2[],
+ Word16 mem_genSHBexc_filt_down_wb3[]
+);
+
+void swb_tbe_reset_synth_fx(
+ Word32 genSHBsynth_Hilbert_Mem[],
+ Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[]
+);
+
+void swb_tbe_reset_fx(
+ Word32 mem_csfilt[],
+ Word16 mem_genSHBexc_filt_down_shb[],
+ Word16 state_lpc_syn[],
+ Word16 syn_overlap[],
+ Word16 state_syn_shbexc[],
+ Word16 *tbe_demph,
+ Word16 *tbe_premph,
+ Word16 mem_stp_swb[],
+ Word16 *gain_prec_swb
+);
+
+void InitSWBdecBuffer_fx(
+ Decoder_State_fx *swb_dnc_fx /* i/o: SHB decoder structure */
+);
+
+void ResetSHBbuffer_Dec_fx(
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+Word16 squant_fx( /* o: index of the winning codeword */
+ const Word16 x, /* i: scalar value to quantize */
+ Word16* xq, /* o: quantized value */
+ const Word16 cb[], /* i: codebook */
+ const Word16 cbsize /* i: codebook size */
+);
+
+void swb_tbe_dec_fx(
+ Decoder_State_fx* st_fx, /* i/o: decoder state structure */
+ const Word16 coder_type, /* i : coding type */
+ Word32* bwe_exc_extended, /* i : bandwidth extended exciatation 2*Q_exc*/
+ Word16 Q_exc,
+ const Word16 voice_factors[], /* i : voicing factors */
+ const Word16 old_syn_12k8_16k[], /* i : low band synthesis*/
+ Word16* White_exc16k, /* o : shaped white excitation for the FB TBE */
+ Word16* Q_white_exc,
+ Word16* synth, /* o : SHB synthesis/final synthesis */
+ Word16* Q_synth,
+ Word16* pitch_buf
+);
+
+
+void tbe_write_bitstream_fx(
+ Encoder_State_fx *st_fx /* i/o: encoder state structure */
+);
+
+void tbe_read_bitstream_fx(
+ Decoder_State_fx *st_fx /* i/o: encoder state structure */
+);
+
+Word16 get_tbe_bits_fx( /* o : TBE bit consumption per frame */
+ Word32 bitrate, /* i : overall bitrate */
+ Word16 bandwidth /* i : bandwidht mode */
+ ,Word16 rf_mode
+);
+
+void GenTransition_fx(
+ const Word16 *input, /* i : gain shape overlap buffer */
+ const Word16 *old_hb_synth, /* i : synthesized HB from previous frame */
+ Word16 length, /* i : targeted length of transition signal */
+ Word16 *output, /* o : synthesized transitions signal */
+ Word32 Hilbert_Mem[], /* i/o: memory */
+ Word16 state_lsyn_filt_shb_local[],/* i/o: memory */
+ Word16 mem_resamp_HB_32k[], /* i/o: memory */
+ Word16 *syn_dm_phase,
+ Word32 output_Fs,
+ Word16 *up_mem,
+ Word16 rf_flag
+ , Word32 bitrate
+);
+
+void GenTransition_WB_fx(
+ const Word16 *input, /* i : gain shape overlap buffer */
+ const Word16 *old_hb_synth, /* i : synthesized HB from previous frame */
+ const Word16 prev_Qx, /* i : scaling of old_hb_synth */
+ Word16 length, /* i : targeted length of transition signal */
+ Word16 *output, /* o : synthesized transitions signal */
+ Word16 state_lsyn_filt_shb1[],
+ Word16 state_lsyn_filt_shb2[],
+ Word32 output_Fs,
+ Word16 *up_mem
+);
+
+void TBEreset_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 bandwidth /* i : bandwidth mode */
+);
+
+void TBEreset_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 bandwidth /* i : bandwidth mode */
+);
+
+void fb_tbe_enc_fx(
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 new_input[], /* i : input speech at 48 kHz sample rate */
+ const Word16 fb_exc[], /* i : FB excitation from the SWB part */
+ Word16 Q_fb_exc
+);
+
+void fb_tbe_dec_fx(
+ Decoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 fb_exc[], /* i : FB excitation from the SWB part */
+ Word16 Q_fb_exc,
+ Word16 *hb_synth, /* o : high-band synthesis */
+ Word16 hb_synth_exp
+);
+
+void elliptic_bpf_48k_generic_fx(
+ const Word16 input_fx[], /* i : input signal */
+ Word16 *Q_input_fx,
+ Word16 output_fx[], /* o : output signal */
+ Word32 memory_fx[][4], /* i/o: 4 arrays of 4 for memory */
+ Word16 memory_fx_Q[],
+ const Word16 full_band_bpf[][5] /* i : filter coefficients b0,b1,b2,a0,a1,a2 Q13 */
+);
+void synthesise_fb_high_band_fx(
+ const Word16 excitation_in[], /* i : full band excitation */
+ Word16 Q_fb_exc,
+ Word16 output[], /* o : high band speech - 14.0 to 20 kHz */
+ const Word32 fb_exc_energy, /* i : full band excitation energy */
+ const Word16 ratio, /* i : energy ratio */
+ const Word16 L_frame, /* i : ACELP frame length */
+ const Word16 bfi, /* i : fec flag */
+ Word16 *prev_fbbwe_ratio, /* o : previous frame energy for FEC */
+ Word32 bpf_memory[][4], /* i/o: memory for elliptic bpf 48k */
+ Word16 bpf_memory_Q[],
+ Word16 Qout
+);
+
+void lsf_syn_mem_restore_fx(
+ Encoder_State_fx *st_fx, /* o: state structure */
+ LPD_state* LPDmem, /* o: LPD_state vewctor */
+ Word16 btilt_code_fx, /* i: */
+ Word32 gc_threshold_fx, /* i: */
+ Word16 *clip_var_bck_fx, /* i: */
+ Word16 next_force_sf_bck_fx, /* i: */
+ Word16 *lsp_new, /* o: LSP vector to quantize */
+ Word16 *lsf_new, /* o: quantized LSF vector */
+ Word16 *lsp_mid, /* o: mid-frame LSP vector */
+ Word16 clip_var, /* i: pitch clipping state var */
+ Word16 *mem_AR, /* i: quantizer memory for AR model */
+ Word16 *mem_MA, /* i: quantizer memory for MA model */
+ Word16 *lsp_new_bck, /* i: LSP vector to quantize- backup */
+ Word16 *lsf_new_bck, /* i: quantized LSF vector - backup */
+ Word16 *lsp_mid_bck, /* i: mid-frame LSP vector - backup */
+ Word16 mCb1, /* i: counter for stationary frame after a transition frame */
+ Word32 *Bin_E, /* i: FFT Bin energy 128 *2 sets */
+ Word32 *Bin_E_old, /* i: FFT Bin energy 128 sets */
+ Word16 *mem_syn_bck, /* i: synthesis filter memory */
+ Word16 mem_w0_bck, /* i: memory of the weighting filter */
+ Word16 streaklimit, /* i:LSF quantizer */
+ Word16 pstreaklen /* i:LSF quantizer */
+);
+
+void encod_nelp_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 *speech_fx, /* i : input speech */
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ Word16 *res_fx, /* o : residual signal */
+ Word16 *synth_fx, /* o : core synthesis */
+ Word16 *tmp_noise_fx, /* o : long-term noise energy */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *exc2_fx, /* i/o: current enhanced excitation */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe */
+ Word16* voice_factors_fx, /* o : voicing factors */
+ Word16* bwe_exc_fx, /* o : excitation for SWB TBE */
+ Word16 Q_new,
+ Word16 shift
+);
+
+void nelp_encoder_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state */
+ Word16 *in_fx, /* i : residual signal */
+ Word16 *exc_fx, /* o : NELP quantized excitation signal */
+ Word16 *qIn1
+ ,Word16 reduce_gains
+);
+
+Word16 dequantize_uvg_fx(
+ Word16 iG1, /* i: gain 1 index */
+ Word16 *iG2, /* i: gain 2 index */
+ Word16 *G, /* o: quantized gain */
+ Word16 bandwidth /* i: bandwidth */
+ ,Word16 do_scale
+);
+
+void quantize_uvg_fx(
+ Word16 *G,
+ Word16 *iG1,
+ Word16 *iG2,
+ Word16 *quantG,
+ Word16 bandwidth
+);
+
+
+void generate_nelp_excitation_fx(
+ Word16 *seed,
+ Word16 *Gains,
+ Word16 *output,
+ Word16 gain_fac
+);
+
+
+Word16 find_rem(
+ Word16 n,
+ Word16 m,
+ Word16 *r
+);
+
+Word32 find_remd(
+ Word32 n,
+ Word32 m,
+ Word32 *r
+);
+
+void set_ppp_mode_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ Word16 *coder_type /* i : coding type */
+ ,const Word16 noisy_speech_HO, /* i : SC-VBR noisy speech HO flag */
+ const Word16 clean_speech_HO, /* i : SC-VBR clean speech HO flag */
+ const Word16 NB_speech_HO, /* i : SC-VBR NB speech HO flag */
+ const Word16 localVAD,
+ const Word16 localVAD_he, /* i : HE-SAD flag without hangover */
+ Word16 *vad_flag
+ ,Word16 T_op_fx[] /* i : open loop pitch lag */
+ ,Word16 sp_aud_decision1 /* i : Speech Audio Decision */
+);
+
+void update_average_rate_fx(
+ Encoder_State_fx *st_fx /* i/o: encoder state structure */
+);
+
+
+void encod_ppp_fx(
+ Encoder_State_fx * st_fx, /* i/o: state structure */
+ LPD_state *mem, /* i/o: acelp memories */
+ const Word16 speech_fx[], /* i : input speech Q_new*/
+ const Word16 Aw_fx[], /* i : weighted A(z) unquantized for subframes */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ Word16 *coder_type, /* i/o : coding type */
+ Word16 sharpFlag_fx, /* i : formant sharpening flag */
+ const Word16 T_op_fx[], /* i : open loop pitch */
+ const Word16 voicing_fx[], /* i : voicing Q14*/
+ Word16 *res_fx, /* i/o: residual signal Q_new*/
+ Word16 *synth_fx, /* i/o: core synthesis Q-1*/
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation Q_new*/
+ Word16 *exc2_fx, /* o: current enhanced excitation Q0*/
+ Word16 *pitch_buf_fx, /* o: floating pitch values for each subframe Q6*/
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 *bwe_exc, /* o : excitation for SWB TBE */
+ Word16 Q_new,
+ Word16 shift
+);
+
+void ppp_voiced_encoder_fx(
+ Encoder_State_fx *st_fx, /* i/o: state structure */
+ Word16 *in_fx, /* i : residual signal */
+ Word16 *out_fx, /* o : Quantized residual signal */
+ Word16 delay_fx, /* i : open loop pitch */
+ Word16 *lpc1_fx, /* i : prev frame de-emphasized LPC */
+ Word16* lpc2_fx, /* i : current frame de-emphasized LPC */
+ Word16 *exc_fx, /* i: previous frame quantized excitation */
+ Word16 *pitch_fx, /* o: floating pitch values for each subframe */
+ Word16 vadsnr_fx, /* i: current frame SNR Q7*/
+ Word16 Qres
+);
+
+Word16 rint_new_fx(
+ Word32 x /* i/o: Round to the nearest integer with mid point exception */
+);
+
+void decod_nelp_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder static memory */
+ const Word16 coder_type, /* i : coding type */
+ Word16 *tmp_noise_fx, /* o : long term temporary noise energy */
+ Word16 *pitch_buf_fx, /* o : floating pitch values for each subframe*/
+ Word16 *exc_fx, /* o : adapt. excitation exc */
+ Word16 *exc2_fx, /* o : adapt. excitation/total exc */
+ Word16 *voice_factors, /* o : Voice factor */
+ Word16 *bwe_exc,
+ Word16 *Q_exc,
+ Word16 bfi /* i : frame error rate */
+ , Word16 *gain_buf /*Q14*/
+);
+
+void nelp_decoder_fx(
+ Decoder_State_fx *st, /* i/o: decoder static memory */
+ Word16 *exc_nelp, /* o : adapt. excitation/total exc */
+ Word16 *exc, /* o : adapt. excitation exc */
+ Word16 *Q_exc,
+ Word16 bfi, /* i : frame error rate */
+ const Word16 coder_type /* i : coding type */
+ , Word16 *gain_buf /*Q14*/
+);
+
+void core_switching_pre_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 output_frame /* i : frame length */
+);
+
+void fb_tbe_reset_synth_fx(
+ Word32 fbbwe_hpf_mem_fx[][4],
+ Word16 fbbwe_hpf_mem_fx_Q[],
+ Word16 *prev_fbbwe_ratio_fx
+);
+
+void core_switching_post_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 *synth, /* i/o: output synthesis Qsynth */
+ const Word16 output_frame, /* i : frame length */
+ const Word16 core_switching_flag, /* i : ACELP->HQ switching flag */
+ const Word16 coder_type, /* i : ACELP coder type */
+ Word16 *Qsynth
+);
+void acelp_core_switch_dec_bfi_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 synth_out[], /* o : synthesis Q_syn */
+ const Word16 coder_type /* i : coder type */
+);
+void acelp_core_switch_dec_fx(
+ Decoder_State_fx *st_fx, /* decoder state structure */
+ Word16 *synth_subfr_out, /* o synthesized ACELP subframe Q_syn*/
+ Word16 *tmp_synth_bwe, /* o synthesized ACELP subframe BWE Q_syn*/
+ const Word16 output_frame, /* i : input frame legth */
+ const Word16 core_switching_flag, /* i : core switching flag */
+ Word16 *mem_synth, /* o : synthesis to overlap */
+ Word16 *Q_syn
+);
+
+void core_switching_hq_prepare_dec_fx(
+ Decoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 *num_bits, /* i/o: bit budget update */
+ const Word16 output_frame /* i : output frame length */
+);
+void fb_tbe_reset_enc_fx(
+ Word32 elliptic_bpf_2_48k_mem_fx[][4],
+ Word32 *prev_fb_energy_fx,
+ Word16 elliptic_bpf_2_48k_mem_fx_Q[],
+ Word16 *prev_fb_energy_fx_Q
+);
+
+void core_switching_OLA_fx(
+ Word16 *mem_over_hp, /* i : upsampling filter memory Q0 */
+ const Word16 last_L_frame, /* i : last L_frame lengthture */
+ const Word32 output_Fs, /* i : output sampling rate */
+ Word16 *synth, /* i/o: synthesized signal from HQ core Q0 */
+ Word16 *synth_subfr_out, /* i : synthesized signal from ACELP core Q0 */
+ Word16 *synth_subfr_bwe, /* i : synthesized BWE from ACELP core Q0 */
+ const Word16 output_frame, /* i : output frame length */
+ const Word16 bwidth, /* i : output bandwidth */
+ Word16* Qsynth,
+ Word16* Qsubfr
+);
+
+void acelp_core_switch_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ LPD_state *mem,
+ const Word16 inp12k8[], /* i : input signal @12.8 kHz Q0 */
+ const Word16 inp16k[], /* i : input signal @16 kHz Q0 */
+ const Word16 T_op_orig[2], /* i : open-loop pitch values for quantiz. Q0*/
+ const Word16 voicing[3], /* i : Open-loop pitch gains Q15 */
+ const Word16 A[NB_SUBFR16k*(M+1)], /* i : A(z) unquantized for the 4 subframes Q12*/
+ Word16 shift,
+ Word16 Q_new
+);
+
+void core_switching_hq_prepare_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 *num_bits, /* i/o: bit budget update */
+ const Word16 input_frame, /* i : frame length */
+ Word32 *wtda_audio, /* shall be q_audio + 15, audio allready scalled in wtda function */
+ const Word16 *audio
+);
+
+void core_switching_pre_enc_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ LPD_state *mem, /* i/o: encoder state structure */
+ const Word16 *old_inp_12k8, /* i : old input signal @12.8kHz */
+ const Word16 *old_inp_16k /* i : old input signal @16kHz */
+);
+
+void core_switching_post_enc_fx( /*done */
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ const Word16 inp12k8[], /* i : input signal @12.8 kHz */
+ const Word16 inp16k[], /* i : input signal @16 kHz */
+ const Word16 T_op[2], /* i : open-loop pitch values for quantiz. */
+ const Word16 voicing[3], /* i : Open-loop pitch gains */
+ const Word16 A[], /* i : unquant. LP filter coefs. (Q12) */
+ Word16 Qshift,
+ Word16 Q_new,
+ const Word16 Qsp, /* i/o : Q from acelp synthsis */
+ Word16 *Qmus /* i/o : Q from mdct synthsis / Q of output synthesis */
+);
+
+Word16 modify_Fs_intcub3m_sup_fx( /* o : length of output */
+ const Word16 sigIn[], /* i : signal to decimate with memory of 2 samples (indexes -2 & -1) */
+ const Word16 lg, /* i : length of input (suppose that lg is such that lg_out is integer, ex multiple of 5 in case of 16kHz to 12.8 kHz) */
+ const Word32 fin, /* i : frequency of input */
+ Word16 sigOut[], /* o : decimated signal */
+ const Word32 fout, /* i : frequency of output */
+ Word16 *delayout /* o : delay of output */
+);
+void add_vec_fx(
+ const Word16 x1[], /* i : Input vector 1 */
+ const Word16 Qx1, /* i : SCaling of iput 1 */
+ const Word16 x2[], /* i : Input vector 2 */
+ const Word16 Qx2, /* i : SCaling of iput 1 */
+ Word16 y[], /* o : Output vector that contains vector 1 + vector 2 */
+ const Word16 Qy, /* i : SCaling of output 1 */
+ const Word16 N /* i : Vector lenght */
+);
+
+/******************************* wrappers related functions **************/
+void convert_fl_2_fx(const float *var_fl, Word16 *var_fx, Word16 count, Word16 Q_format);
+void convert_fl_2_fx_32(const float *var_fl, Word32 *var_fx, Word16 count, Word16 Q_format);
+void convert_fl_2_fx_32_MIN(const float *var_fl, Word32 *var_fx, Word16 count, Word16 Q_format, Word32 MIN_VAL);
+void convert_sh_2_fx(const short *var_fl, Word16 *var_fx, Word16 count, Word16 Q_format);
+void convert_dl_2_fx_32(double *var_fl, Word32 *var_fx, Word16 count, Word16 Q_format);
+void convert_fx_2_fl(float *var_fl, const Word16 *var_fx, Word16 count, Word16 Q_format);
+void convert_fx_2_sh(short *var_fl, const Word16 *var_fx, Word16 count, Word16 Q_format);
+void convert_fx_2_dl_32(double *var_fl, const Word32 *var_fx, Word16 count, Word16 Q_format);
+void convert_fx_2_fl_32(float *var_fl, const Word32 *var_fx, Word16 count, Word16 Q_format);
+void convert_fx_2_fl_32_floor(float *var_fl, const Word32 *var_fx, Word16 count, Word16 Q_format);
+/* void pre_proc_acelp_core_dec(Decoder_State *st,Decoder_State_fx *st_fx); */
+/* void post_proc_acelp_core_dec(Decoder_State *st,Decoder_State_fx *st_fx); */
+
+void convert_fl_2_fx_q(const float *x, Word16 *x_fx, Word16 len, Word16 *q);
+/******************************* END OF wrappers related functions **************/
+
+/******************************* END of temporary Hybride function related functions **************/
+
+void Copy_Scale_sig32_16(
+ const Word32 *src, /* i : signal to scale Qx */
+ Word16 *dst, /* o : scaled signal Qx */
+ Word16 len, /* i : size of x[] Q0 */
+ Word16 exp0 /* i : exponent: x = round(x << exp) Qx ?exp */
+);
+Word32 Add_flt32_flt32(/* o: Result */
+ Word32 a, /* i: 1st Value */
+ Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */
+ Word32 b, /* i: 2nd Value */
+ Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */
+ Word16 *exp_out /* o: Exponent of Result */
+);
+Word32 Mul_flt32_Q15( /* o: Result (Normalized) */
+ Word32 value, /* i: Pseudo_float Value */
+ Word16 *exp_v, /*i/o: Exponent of Value (Q of Value) */
+ Word16 frac /* i: Q15 value */
+);
+Word32 Div_flt32_flt32(/* o: Result (Normalized) */
+ Word32 a, /* i: 1st Value */
+ Word16 exp_a, /* i: Exponent of 1st Value (Q of Value) */
+ Word32 b, /* i: 2nd Value */
+ Word16 exp_b, /* i: Exponent of 2nd Value (Q of Value) */
+ Word16 *exp_out /* o: Exponent of Result */
+);
+Word32 Calc_Energy_Autoscaled(/* o: Result (Energy) */
+ const Word16 *signal, /* i: Signal */
+ Word16 signal_exp, /* i: Exponent of Signal (Q of Signal) */
+ Word16 len, /* i: Frame Length */
+ Word16 *energy_exp /* o: Exponent of Energy (Q of Energy) */
+);
+Word16 Find_Max_Norm16(const Word16 *src, Word16 len);
+Word16 Find_Max_Norm32(const Word32 *src, Word16 len);
+Word32 Sqrt_Ratio32(Word32 L_val1, Word16 exp1, Word32 L_val2, Word16 exp2, Word16 *exp);
+Word16 Invert16( /* result in Q'15 + 'exp' */
+ Word16 val,
+ Word16 *exp);
+
+void swb_bwe_enc_hr_fx(
+ Encoder_State_fx *st_fx, /* i/o: encoder state structure */
+ Word16 *new_input_fx, /* i : input signal */
+ Word16 new_input_fx_exp, /* i : Exponent of input signal */
+ const Word16 input_frame, /* i : frame length */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 unbits /* i : number of core unused bits */
+);
+
+void wtda_fx(
+ Word16 *new_audio, /* i : input audio Q0 */
+ Word16 *Q, /* i/o : Q of Output Audio (use 15 for 'qout' for backward compatibility - NON SWB ENC HR FX MODULES) */
+ Word32 *wtda_audio, /* o : windowed audio Qout */
+ Word16 *old_wtda, /* i/o: windowed audio from previous frame Qout */
+ Word16 *Qold_wtda,
+ Word16 left_mode,
+ Word16 right_mode, /* window overlap of current frame (0: full, 2: none, or 3: half) */
+ const Word16 L
+);
+
+void direct_transform_fx(
+ const Word32 in32_fx[],
+ Word32 out32_fx[],
+ const Word16 is_transient,
+ const Word16 L,
+ Word16 *Q
+);
+
+
+void r_fft_4_fx(Word16 * farray_ptr_fx, Word16 size, Word16 stage, Word16 isign);
+
+DTFS_STRUCTURE_FX* DTFS_new_fx(
+ void
+);
+
+void DTFS_copy_fx(
+ DTFS_STRUCTURE_FX *Xout_fx, /* o: DTFS structure */
+ DTFS_STRUCTURE_FX Xinp_fx /* i: DTFS structure */
+);
+
+DTFS_STRUCTURE_FX DTFS_sub_fx(
+ DTFS_STRUCTURE_FX X1, /* i: DTFS input 1 */
+ DTFS_STRUCTURE_FX X2 /* i: DTFS input 2 */
+); /* o: X1 - X2 */
+
+
+void DTFS_to_fs_fx(
+ const Word16 *x, /* i : time domain signal */
+ Word16 N, /* i : Length of input vector */
+ DTFS_STRUCTURE_FX *X_fx, /* o : DTFS structure with a, b, lag */
+ Word16 Fs, /* i : sampling rate */
+ Word16 FR_flag, /* i: FR flag */
+ Word16 *S_fx,
+ Word16 *C_fx
+);
+
+void DTFS_fast_fs_inv_fx( DTFS_STRUCTURE_FX *This,Word16 *out_fx, Word16 N_fx, Word16 LOG2N);
+
+void DTFS_car2pol_fx(
+ DTFS_STRUCTURE_FX *X_fx /* i/o : DTFS structure a, b, lag */
+);
+void copy_phase_fx( DTFS_STRUCTURE_FX *X1_fx, DTFS_STRUCTURE_FX X2_fx, DTFS_STRUCTURE_FX *retX_fx);
+Word32 getSpEngyFromResAmp_fx( DTFS_STRUCTURE_FX *X_fx,Word16 lband, Word16 hband,
+ const Word16 *curr_lpc, Word16 *sin_tab,
+ Word16 *cos_tab);
+
+Word32 DTFS_setEngyHarm_fx(
+ Word16 f1_fx, /* i : lower band freq of input to control energy */
+ Word16 f2_fx, /* i : upper band freq of input to control energy */
+ Word16 g1_fx, /* i : lower band freq of output to control energy */
+ Word16 g2_fx, /* i : upper band freq of output to control energy */
+ Word32 en2_fx, /* i : Target Energy to set the DTFS to */
+ Word16 Qen2_fx, /* i : Input Q format for en2 */
+ Word16 *Qa_fx, /* i : Output Q format for x->a */
+ DTFS_STRUCTURE_FX *X_fx /* i/o: DTFS to adjust the energy of */
+);
+
+void rshiftHarmBand_fx( DTFS_STRUCTURE_FX *X_fx,Word16 lband_fx, Word16 hband_fx, Word16 shift_fx);
+void quant_target_fx( DTFS_STRUCTURE_FX *X_fx,const Word16 *curr_lpc, Word16 *w, Word16 *target,
+ Word16 *sin_tab, Word16 *cos_tab);
+
+void GetSinCosTab_fx(Word16 L, Word16 *sinTab, Word16 *cosTab);
+
+void DTFS_to_erb_fx(
+ const DTFS_STRUCTURE_FX X_fx, /* i : DTFS input */
+ Word16 *out_fx /* o : ERB output */
+);
+
+void DTFS_zeroPadd_fx(Word16 N_fx,DTFS_STRUCTURE_FX *X_fx);
+
+Word32 DTFS_getEngy_fx( DTFS_STRUCTURE_FX *X_fx);
+
+Word32 DTFS_getEngy_P2A_fx( DTFS_STRUCTURE_FX *X_fx);
+
+
+Word32 DTFS_getEngy_band_fx(
+ DTFS_STRUCTURE_FX X_fx,
+ Word16 lband,
+ Word16 hband
+);
+
+Word32 DTFS_getEngy_band_wb_fx(
+ DTFS_STRUCTURE_FX X_fx,
+ Word16 lband,
+ Word16 hband
+);
+
+Word32 DTFS_freq_corr_fx(
+ DTFS_STRUCTURE_FX X1_DTFS_fx, /* i : X1 DTFS */
+ DTFS_STRUCTURE_FX X2_DTFS_fx, /* i : X2 DTFS */
+ Word16 lband, /* i : low cutoff */
+ Word16 hband, /* i : high cutoff */
+ Word16 *Qout /* o : Correlation Q format */
+); /* o : Correlation */
+
+Word32 DTFS_setEngy_fx( DTFS_STRUCTURE_FX *X_DTFS_FX,Word32 en2_fx);
+
+void DTFS_adjustLag_fx(
+ DTFS_STRUCTURE_FX *X_DTFS_FX, /* i/o : DTFS to adjust lag for */
+ Word16 N_fx /* i : Target lag */
+);
+
+void DTFS_poleFilter_fx( DTFS_STRUCTURE_FX *X_fx,Word16 *LPC, Word16 N, Word16 *S_fx, Word16 *C_fx);
+void DTFS_poleFilter_fx_9( DTFS_STRUCTURE_FX *X_fx, Word16 *pf_temp1, Word16 *pf_temp2, Word16 *pf_temp, Word16 *pf_n2_temp1);
+void poleFilter_setup_fx(const Word16 *LPC, Word16 N, DTFS_STRUCTURE_FX X_fx, Word16 *S_fx, Word16 *C_fx, Word16 *pf_temp1, Word16 *pf_temp2, Word16 *pf_temp, Word16 *pf_n2_temp1);
+
+void DTFS_zeroFilter_fx(
+ DTFS_STRUCTURE_FX *X_fx,
+ Word16 *LPC,
+ Word16 N,
+ Word16 *S_fx,
+ Word16 *C_fx
+);
+
+Word16 DTFS_alignment_full_fx(
+ DTFS_STRUCTURE_FX X1_DTFS_fx, /* i : reference DTFS */
+ DTFS_STRUCTURE_FX X2_DTFS_fx, /* i : DTFS to shift */
+ Word16 ph_offset_fx, /* i : resolution */
+ Word16 *S_fx,
+ Word16 *C_fx
+ , Word16 FR_flag
+);
+
+Word16 DTFS_alignment_extract_td_fx(Word16 *x1, Word16 *x2, Word16 lag);
+
+Word16 DTFS_alignment_weight_fx(
+ DTFS_STRUCTURE_FX *X_fx,
+ DTFS_STRUCTURE_FX X2,
+ Word16 Eshift,
+ const Word16 *LPC1,
+ const Word16 *LPC2,
+ Word16 *S_fx,
+ Word16 *C_fx,
+ Word16 *pf_temp1,
+ Word16 *pf_temp2,
+ Word16 *pf_temp,
+ Word16 *pf_n2
+);
+
+
+Word16 DTFS_alignment_fine_new_fx( DTFS_STRUCTURE_FX X1_fx, DTFS_STRUCTURE_FX X2_fx, Word16 *S_fx, Word16 *C_fx);
+
+
+void DTFS_phaseShift_fx( DTFS_STRUCTURE_FX *X_fx,Word16 ph, Word16 Lag, Word16 *S_fx, Word16 *C_fx);
+void Q2phaseShift_fx( DTFS_STRUCTURE_FX *X_fx,Word16 ph, Word16 Lag, Word16 *S_fx, Word16 *C_fx);
+
+
+void DTFS_erb_inv_fx(
+ Word16 *in_fx, /* i : ERB inpt */
+ Word16 *slot_fx, /* i : ERB slots filled based on lag */
+ Word16 *mfreq_fx, /* i : erb frequence edges */
+ DTFS_STRUCTURE_FX *X_fx, /* o : DTFS after erb-inv */
+ Word16 num_erb_fx /* i : Number of ERB bands */
+);
+
+void erb_add_fx(
+ Word16 *curr_erb_fx, /* i/o: current ERB */
+ Word16 l_fx, /* i : current lag */
+ const Word16 *prev_erb_fx, /* i : previous ERB */
+ Word16 pl_fx, /* i : previous lag */
+ const Word16 *index_fx, /* i : ERB index */
+ Word16 num_erb_fx /* i : number of ERBs */
+);
+
+void LPCPowSpect_fx(Word16 *freq, Word16 Nf, Word16 *LPC, Word16 Np,
+ Word16 *out);
+
+void erb_slot_fx(
+ Word16 lag_fx, /* i : input lag */
+ Word16 *out_fx, /* o : ERB slots */
+ Word16 *mfreq_fx, /* i : ERB frequencies */
+ Word16 num_erb_fx /* i : number of ERBs */
+);
+
+Word16 DTFS_quant_cw_fx(
+ DTFS_STRUCTURE_FX *X_fx, /* i/o: DTFS unquant inp, quant out */
+ Word16 pl, /* i : Previous lag */
+ const Word16 *curr_lpc_fx, /* i : LPC */
+ Word16 *POWER_IDX, /* o : Power index */
+ Word16 *AMP_IDX, /* o : Amplitude index */
+ Word16 *lastLgainE_fx, /* i/o: last frame lowband gain */
+ Word16 *lastHgainE_fx, /* i/o: last frame highband gain */
+ Word16 *lasterbE_fx, /* i/o: last frame ERB vector */
+ Word16 *sin_tab,
+ Word16 *cos_tab
+);
+
+
+void DTFS_dequant_cw_fx(
+ Word16 pl_fx, /* i : Previous lag */
+ Word16 POWER_IDX_fx, /* i : POWER index */
+ const Word16 *AMP_IDX_fx, /* i : Amp Shape index */
+ Word16 *lastLgainD_fx, /* i/o: low band last gain */
+ Word16 *lastHgainD_fx, /* i/o: high band last gain */
+ Word16 *lasterbD_fx, /* i/o: last frame ERB vector */
+ DTFS_STRUCTURE_FX *X_fx, /* o : DTFS structure dequantized */
+ Word16 num_erb_fx
+);
+
+void DTFS_transform_fx(
+ DTFS_STRUCTURE_FX X_fx, /* i : Starting DTFS to use in WI */
+ DTFS_STRUCTURE_FX X2_fx, /* i : Ending DTFS to use in WI */
+ const Word32 *phase_fx, /* i : Phase contour */
+ Word16 *out_fx, /* o : Output time domain waveform */
+ Word16 N, /* i : Number of samples to generate */
+ Word16 FR_flag /* i : Flag to indicate called in FR context */
+);
+
+void DTFS_peaktoaverage_fx(
+ DTFS_STRUCTURE_FX X_fx, /* i : DTFS */
+ Word32 *pos_fx, /* o : positive peak to ave */
+ Word16 *Qpos, /* o : positive peak to ave Q format */
+ Word32 *neg_fx, /* o : negative peak to ave */
+ Word16 *Qneg /* o : negative peak to ave Q format */
+);
+
+
+
+Word16 ppp_extract_pitch_period_fx(
+ const Word16 *in, /* i : input residual */
+ Word16 *out, /* o : output residual */
+ Word16 l, /* i : lag */
+ Word16 *out_of_bound, /* o : out of bound flag */
+ Word16 Qres
+
+);
+
+void Interpol_delay_fx(
+ Word16 *out_fx,
+ Word16 last_fx,
+ Word16 current_fx,
+ Word16 SubNum,
+ const Word16* frac_fx
+);
+
+
+Word16 ppp_quarter_encoder_fx(
+ DTFS_STRUCTURE_FX *CURRCW_Q_FX, /* o : Quantized (amp/phase) DTFS */
+ DTFS_STRUCTURE_FX *TARGETCW_FX, /* o : DTFS with quant phase but unquant Amp */
+ Word16 prevCW_lag, /* i : previous lag */
+ DTFS_STRUCTURE_FX CURRCW_NQ_FX, /* i : Unquantized DTFS */
+ const Word16 *curr_lpc_fx, /* i : LPCS */
+ Word16 *lastLgainE_fx, /* i/o: last low band gain */
+ Word16 *lastHgainE_fx, /* i/o: last high band gain */
+ Word16 *lasterbE_fx, /* i/o: last ERB vector */
+ DTFS_STRUCTURE_FX PREV_CW_E_FX, /* i : past DTFS */
+ Word16 *S_fx, /* i : sin table, Q15 */
+ Word16 *C_fx, /* i : cos table, Q15 */
+ Encoder_State_fx *st_fx
+);
+
+
+void WIsyn_fx(
+ DTFS_STRUCTURE_FX PREVCW_FX,
+ DTFS_STRUCTURE_FX *CURR_CW_DTFS_FX,
+ const Word16 *curr_lpc_fx,
+ Word16 *ph_offset_fx,
+ Word16 *out_fx,
+ Word16 N,
+ Word16 FR_flag, /* i : called for post-smoothing in FR */
+ Word16 *S_fx,
+ Word16* C_fx,
+ Word16 *pf_temp1,
+ Word16 *pf_temp2,
+ Word16 *pf_temp,
+ Word16 *pf_n2
+);
+
+void deemph_lpc_fx(
+ Word16 *p_Aq_curr_fx, /* i : LP coefficients current frame */
+ Word16 *p_Aq_old_fx, /* i : LP coefficients previous frame */
+ Word16 *LPC_de_curr_fx, /* o : De-emphasized LP coefficients current frame */
+ Word16 *LPC_de_old_fx, /* o : De-emphasized LP coefficients previous frame */
+ Word16 deemph_old
+
+);
+
+Word16 erb_diff_search_fx(Word16 *prev_erb, const Word16 *curr_erb, Word16 *dif_erb,
+ Word16 *pow_spec, const Word16 *cb_fx,
+ Word16 cb_size, Word16 cb_dim, Word16 offset
+ );
+
+
+void Acelp_dec_total_exc(
+ Word16 *exc_fx, /* i/o: adapt. excitation exc */
+ Word16 *exc2_fx, /* i/o: adapt. excitation/total exc */
+ const Word16 gain_code16, /* i : Gain code Q0 */
+ const Word16 gain_pit_fx, /* i ; Pitch gain in Q14 */
+ const Word16 i_subfr, /* i ; subfr */
+ const Word16 *code_fx /* i : code in Q12 */
+);
+void tbe_celp_exc(
+ const Word16 L_frame_fx, /* i : Frame lenght */
+ const Word16 i_subfr_fx, /* i : sub frame */
+ const Word16 T0_fx, /* i : Integer pitch */
+ const Word16 T0_frac_fx, /* i : Fractional part of the pitch */
+ Word16 *error_fx, /* i/o: Error */
+ Word16 *bwe_exc_fx /* i/o: bandwitdh extension signal */
+);
+Word16 tbe_celp_exc_offset(
+ const Word16 T0_fx, /* i : Integer pitch */
+ const Word16 T0_frac_fx, /* i : Fractional part of the pitch */
+ const Word16 L_frame /* i : frame lenght */
+);
+void lsf_syn_mem_backup_fx(
+ Encoder_State_fx *st_fx, /* i: state structure */
+ LPD_state* LPDmem, /* i: LPD state memory structure */
+ Word16 *btilt_code, /* i: tilt code */
+ Word32 *bgc_threshold, /* i: */
+ Word16 *clip_var_bck, /* o: */
+ Word16 *next_force_sf_bck, /* o: */
+ Word16 *lsp_new, /* i: LSP vector to quantize */
+ Word16 *lsf_new, /* i: quantized LSF vector */
+ Word16 *lsp_mid, /* i: mid-frame LSP vector */
+ Word16 *clip_var, /* o: pitch clipping state var */
+ Word16 *mem_AR, /* o: quantizer memory for AR model */
+ Word16 *mem_MA, /* o: quantizer memory for AR model */
+ Word16 *lsp_new_bck, /* o: LSP vector to quantize- backup */
+ Word16 *lsf_new_bck, /* o: quantized LSF vector - backup */
+ Word16 *lsp_mid_bck, /* o: mid-frame LSP vector - backup */
+ Word16 *mCb1, /* o: counter for stationary frame after a transition frame */
+ Word32 *Bin_E, /* o: FFT Bin energy 128 *2 sets */
+ Word32 *Bin_E_old, /* o: FFT Bin energy 128 sets */
+ Word16 *mem_syn_bck, /* o: synthesis filter memory */
+ Word16 *mem_w0_bck, /* o: memory of the weighting filter */
+ Word16 *streaklimit,
+ Word16 *pstreaklen
+);
+
+void decod_ppp_fx(
+ Decoder_State_fx *st_fx, /* i/o: state structure */
+ const Word16 Aq_fx[], /* i : 12k8 Lp coefficient */
+ Word16 *pitch_buf_fx, /* i/o: fixed pitch values for each subframe */
+ Word16 *exc_fx, /* i/o: current non-enhanced excitation */
+ Word16 *exc2_fx, /* i/o: current enhanced excitation */
+ Word16 bfi /* i : bad frame indicator */
+ ,Word16 *gain_buf /*Q14*/
+ ,Word16 *voice_factors, /* o : voicing factors */
+ Word16 *bwe_exc_fx /* o : excitation for SWB TBE */
+);
+
+void ppp_quarter_decoder_fx(
+ DTFS_STRUCTURE_FX *CURRCW_Q_DTFS_FX, /* i/o: Current CW DTFS */
+ Word16 prevCW_lag_fx, /* i : Previous lag */
+ Word16 *lastLgainD_fx, /* i/o: Last gain lowband Q11 */
+ Word16 *lastHgainD_fx, /* i/o: Last gain highwband Q11 */
+ Word16 *lasterbD_fx, /* i/o: Last ERB vector Q13 */
+ Word16 bfi, /* i : FER flag */
+ Word16 *S_fx, /* i : sine table, Q15 */
+ Word16 *C_fx, /* i : cosine table, Q15 */
+ DTFS_STRUCTURE_FX PREV_CW_D_FX /* i : Previous DTFS */
+ ,Decoder_State_fx *st
+);
+
+
+void ppp_voiced_decoder_fx(
+ Decoder_State_fx *st_fx, /* i/o: state structure */
+ Word16 *out_fx, /* o : residual signal */
+ const Word16 *lpc2_fx, /* i : current frame LPC */
+ Word16 *exc_fx, /* i : previous frame excitation */
+ Word16 *pitch, /* o : floating pitch values for each subframe */
+ Word16 bfi /* i : Frame error rate */
+);
+
+
+void bandwidth_switching_detect_fx(
+ Decoder_State_fx *st_fx /* i/o: encoder state structure */
+);
+
+void bw_switching_pre_proc_fx(
+ const Word16 *old_syn_12k8_16k_fx, /* i : ACELP core synthesis at 12.8kHz or 16kHz */
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+void updt_bw_switching_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ const Word16 *synth, /* i : float synthesis signal */
+ const Word16 Qpost
+);
+void updt_dec_common_fx(
+ Decoder_State_fx *st_fx, /* i/o: decoder state structure */
+ Word16 hq_core_type_fx, /* i : HQ core type */
+ const Word16 *synth /* i : decoded synthesis */
+);
+
+void sort_32_fx(
+ Word32 *r, /* i/o: Vector to be sorted in place */
+ const Word16 lo, /* i : Low limit of sorting range */
+ const Word16 up /* I : High limit of sorting range */
+);
+Word16 FEC_SinOnset_fx (
+ Word16 *exc, /* i/o : exc vector to modify */
+ Word16 puls_pos, /* i : last pulse position desired */
+ const Word16 T0, /* i : Pitch information of the 1 subfr */
+ Word32 enr_q, /* i : energy provide by the encoder */
+ Word16 *Aq, /* i : A(z) filter Q12 */
+ const Word16 L_frame /* i : frame length */
+ ,const Word16 Qold
+);
+Word16 FEC_enhACB_fx(
+ const Word16 L_frame, /* i : frame length */
+ const Word16 last_L_frame, /* i : frame length of previous frame */
+ Word16 *exc_io, /* i/o : adaptive codebook memory */
+ const Word16 new_pit, /* i : decoded first frame pitch */
+ const Word16 puls_pos, /* i : decoder position of the last glottal pulses decoded in the previous frame */
+ const Word16 bfi_pitch /* i : Q6 pitch used for concealment */
+);
+
+
+void fft3_fx(const Word16 [], Word16 [], const Word16);
+void ifft3_fx(const Word16 [], Word16 [], const Word16);
+void hq_ecu_fx(
+ const Word16 *prevsynth, /* i : buffer of previously synthesized signal */
+ Word32 *ecu_rec, /* o : reconstructed frame in tda domain */
+ Word16 *time_offs,
+ Word16 *X_sav,
+ Word16 *Q_spec, /* i/o : Q value of stored spectrum */
+ Word16 *num_p,
+ Word16 *plocs,
+ Word32 *plocsi, /* o : Interpolated positions of the identified peaks (Q16) */
+ const Word16 env_stab,
+ Word16 *last_fec,
+ const Word16 ph_ecu_HqVoicing,
+ Word16 *ph_ecu_active, /* i : Phase ECU active flag */
+ Word16 *gapsynth,
+ const Word16 prev_bfi, /* i : indicating burst frame error */
+ const Word16 old_is_transient[2], /* i : flags indicating previous transient frames */
+ Word16 *mag_chg_1st, /* i/o: per band magnitude modifier for transients*/
+ Word16 *Xavg, /* i/o: Frequency group average gain to fade to */
+ Word16 *beta_mute, /* o : Factor for long-term mute */
+ const Word16 output_frame, /* i : frame length */
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+void hq_timedomain_conc_fx(
+ Word32 *ecu_rec, /* o : reconstructed frame in tda domain */
+ Word16 *gapsynth, /* o : Gap synthesis */
+ const Word16 output_frame, /* i : frame length */
+ const Word16 *prevsynth, /* i : buffer of previously synthesized signal */
+ Decoder_State_fx *st_fx /* i/o: decoder state structure */
+);
+
+Word16 ratio(const Word32, const Word32, Word16 *);
+
+
+void nearProjQ15_fx(
+ Word16 x,
+ Word16 *result
+);
+
+void Ratio_rQ3_fx(
+ Word16 opp,
+ Word16 near,
+ Word16 *result
+);
+
+void densityAngle2RmsProjDec_fx(
+ Word16 D, /* i: density */
+ Word16 indexphi, /* i: decoded index from AR dec */
+ Word16 *oppQ15, /* o: proj*/
+ Word16 *nearQ15, /* o: */
+ Word16 *oppRatioQ3 /* o: */
+) ;
+
+void densityAngle2RmsProjEnc_fx (
+ Word16 D,
+ Word16 phiQ14uq,
+ Word16 *indexphi, /* o: index to send to AR */
+ Word16 *oppQ15, /* o: proj*/
+ Word16 *nearQ15,
+ Word16 *oppRatioQ3
+) ;
+void dsDiracPerQuanta_fx(
+ const Word16 td,
+ const Word16 t_quanta,
+ const Word16 dsm,
+ const unsigned char* const *frQuanta,
+ Word16 *DsIdx
+);
+
+void QuantaPerDsDirac_fx(
+ Word16 td,
+ Word16 dsDiracIndex,
+ const unsigned char* const* dimFrQuanta,
+ Word16 *Quanta
+);
+
+void obtainEnergyQuantizerDensity_fx(
+ const Word16 L,
+ const Word16 R,
+ Word16 *Density
+);
+
+void dsDirac2Dirac_fx(
+ const Word16 dsDiracIndex,
+ Word16 *diracs
+);
+
+
+void NearOppSplitAdjustment_fx(
+ const Word16 qband,
+ const Word16 qzero,
+ const Word16 Qac,
+ const UWord32 INTac,
+ const Word16 qglobal,
+ const Word16 FlagCons,
+ const Word16 Np,
+ const Word16 Nhead,
+ const Word16 Ntail,
+ const Word16 Nnear,
+ const Word16 Nopp,
+ Word16 oppRQ3,
+ Word16 *qnear,
+ Word16 *qopp,
+ Word16 *qglobalupd
+) ;
+
+
+
+
+/* IGFEnc.c */
+void IGFEncApplyMono(const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ const Word16 igfGridIdx, /**< in: Q0 | IGF grid index */
+ Encoder_State_fx *st, /**< in: | Encoder state */
+ Word32 *pMDCTSpectrum, /**< in: Q31 | MDCT spectrum */
+ Word16 MDCTSpectrum_e, /**< in: | exponent of MDCT spectrum */
+ Word32 *pPowerSpectrum, /**< in: Q31 | MDCT^2 + MDST^2 spectrum, or estimate */
+ Word16 PowerSpectrum_e, /**< in: | exponent of pPowerSpectrum */
+ Word16 isTCX20, /**< in: Q0 | flag indicating if the input is TCX20 or TCX10/2xTCX5 */
+ Word16 isTNSActive, /**< in: Q0 | flag indicating if the TNS is active */
+ Word16 last_core_acelp /**< in: Q0 | indictaor if last frame was acelp coded */
+ );
+
+void IGFEncConcatenateBitstream(const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ Word16 bsBits, /**< in: Q0 | number of IGF bits written to list of indices */
+ Word16 *next_ind, /**< in/out: | pointer to actual bit indice */
+ Word16 *nb_bits, /**< in/out: | total number of bits already written */
+ Indice_fx *ind_list_fx /**< in: | pointer to list of indices */
+ );
+
+void IGFEncResetTCX10BitCounter(const IGF_ENC_INSTANCE_HANDLE hInstance /**< in: | instance handle of IGF Encoder */
+ );
+
+void IGFEncSetMode(const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ const Word32 bitRate, /**< in: Q0 | encoder bitrate */
+ const Word16 mode /**< in: Q0 | encoder bandwidth mode */
+ , const Word16 rf_mode /**< in: | flag to signal the RF mode */
+
+ );
+
+Word16 IGFEncWriteBitstream( /**< out: | number of bits written per frame */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ Encoder_State_fx *st, /**< in: | encoder state */
+ Word16 *pBitOffset, /**< in: | ptr to bitOffset counter */
+ const Word16 igfGridIdx, /**< in: Q0 | igf grid index see declaration of IGF_GRID_IDX for details */
+ const Word16 isIndepFlag /**< in: Q0 | if 1 frame is independent, 0 = frame is coded with data from previous frame */
+);
+
+Word16 IGFEncWriteConcatenatedBitstream( /**< out: Q0 | total number of bits written */
+ const IGF_ENC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Encoder */
+ void *st /**< in: | encoder state */
+);
+
+/* IGFDec.c */
+void IGFDecApplyMono(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */
+ Word32 *spectrum, /**< in/out: | MDCT spectrum */
+ Word16 *spectrum_e, /**< in/out: | exponent of spectrum */
+ const Word16 igfGridIdx, /**< in: | in case of CELP->TCX switching, use 1.25 framelength */
+ Word16 bfi /**< in: | frame loss == 1, frame good == 0 */
+ );
+
+void IGFDecCopyLPCFlatSpectrum(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */
+ const Word32 *pSpectrumFlat, /**< in: Q31 | LPC flattend spectrum from TCX dec */
+ const Word16 pSpectrumFlat_exp, /**< in: | exponent of pSpectrumFlat */
+ const Word16 igfGridIdx /**< in: Q0 | IGF grid index */
+ );
+
+void IGFDecReadData(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */
+ Decoder_State_fx *st, /**< in: | decoder state */
+ const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */
+ const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */
+ );
+
+void IGFDecReadLevel( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Deccoder */
+ Decoder_State_fx *st, /**< in: | decoder state */
+ const Word16 igfGridIdx, /**< in: Q0 | in case of CELP->TCX switching, use 1.25 framelength */
+ const Word16 isIndepFrame /**< in: Q0 | if 1: arith dec force reset, if 0: no reset */
+ );
+
+void IGFDecRestoreTCX10SubFrameData(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */
+ const Word16 subFrameIdx /**< in: Q0 | index of subframe */
+ );
+
+void IGFDecSetMode(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */
+ const Word32 bitRate, /**< in: Q0 | bitrate */
+ const Word16 mode, /**< in: Q0 | bandwidth mode */
+ const Word16 defaultStartLine, /**< in: Q0 | default start subband index */
+ const Word16 defaultStopLine /**< in: Q0 | default stop subband index */
+ , const Word16 rf_mode /**< in: | flag to signal the RF mode */
+ );
+
+void IGFDecStoreTCX10SubFrameData(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */
+ const Word16 subFrameIdx /**< in: Q0 | index of subframe */
+ );
+
+void IGFDecUpdateInfo(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */
+ const Word16 igfGridIdx /**< in: | IGF grid index */
+ );
+
+/* iisBaseLib.c */
+void IGFCommonFuncsCalcSfbEnergyPowerSpec(const Word16 startSfb, /**< in: Q0 | start sfb index */
+ const Word16 stopSfb, /**< in: Q0 | stop sfb index */
+ const Word16 *swb_offset, /**< in: Q0 | IGF swb offset table */
+ Word32 *pPowerSpectrum, /**< in: Q31 | power spectrum */
+ Word16 *pPowerSpectrum_exp, /**< in: | Exponent of PowerSpectrum */
+ Word32 *sfbEnergy, /**< out:Q31 | SFB energies , will be initialized inside this function */
+ Word16 *sfbEnergy_exp /**< out: | Exponent of PowerSpectrum */
+ );
+
+Word16 IGFCommonFuncsIGFConfiguration( /**< out: | error value: 0 -> error, 1 -> ok */
+ Word32 bitRate, /**< in: Q0 | bitrate in bs e.g. 9600 for 9.6kbs */
+ Word16 mode, /**< in: Q0 | bandwidth mode */
+ H_IGF_INFO hIGFInfo /**< out: | IGF info handle */
+ ,Word16 rf_mode /**< in: flag to signal the RF mode */
+);
+
+Word16 IGFCommonFuncsIGFGetCFTables( /**< out: | error value: 0 -> error, 1 -> ok */
+ Word32 bitRate, /**< in: Q0 | bitrate in bs e.g. 9600 for 9.6kbs */
+ Word16 mode, /**< in: Q0 | bandwidth mode */
+ Word16 rf_mode, /**< in: | flag to signal the RF mode */
+ const Word16 **cf_se00, /**< out: | CF table for t == 0 and f == 0 */
+ const Word16 **cf_se01, /**< out: | CF table for t == 0 and f == 1 */
+ Word16 *cf_off_se01, /**< out: | offset for CF table above */
+ const Word16 **cf_se02, /**< out: | CF tables for t == 0 and f >= 2 */
+ const Word16 **cf_off_se02, /**< out: | offsets for CF tables above */
+ const Word16 **cf_se10, /**< out: | CF table for t == 1 and f == 0 */
+ Word16 *cf_off_se10, /**< out: | offset for CF table above */
+ const Word16 **cf_se11, /**< out: | CF tables for t == 1 and f >= 1 */
+ const Word16 **cf_off_se11 /**< out: | offsets for CF tables above */
+);
+
+void IGFCommonFuncsMDCTSquareSpec(const Word16 sqrtBgn, /**< in: Q0 | start MDCT subband index */
+ const Word16 sqrtEnd, /**< in: Q0 | stop MDCT subband index */
+ const Word32 *mdctSpec, /**< in: Q31 | MDCT spectrum to square */
+ const Word16 mdctSpec_e, /**< in: | exponent of mdctSpectrum */
+ Word32 *mdctSquareSpec, /**< out:Q31 | MDCT square spectrum */
+ Word16 *mdctSquareSpec_e, /**< out: | exponent of mdctSquareSpec */
+ Word16 indexOffset /**< in: Q0 | index offset */
+ );
+
+void IGFCommonFuncsWriteSerialBit(void *st, /**< in: | encoder/decoder state structure */
+ Word16 *pBitOffset, /**< out: Q0 | bit offset */
+ Word16 bit /**< in: Q0 | value of bit */
+ );
+
+/* IGFSCFEncoder.c */
+void IGFSCFEncoderOpen(
+ IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */
+ Word16 scfCountLongBlock, /* i: number of SCFs for a long block */
+ Word32 bitRate, /* i: bitrate in bps */
+ Word16 mode /* i: operating mode */
+ , Word16 rf_mode /**< in: flag to signal the RF mode */
+);
+
+void IGFSCFEncoderReset(
+ IGFSCFENC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */
+);
+
+Word16 IGFSCFEncoderEncode(
+ IGFSCFENC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */
+ Encoder_State_fx *st, /* i/o: pointer to encoder state */
+ Word16 bitCount, /* i: offset to the first bit in bitbuffer which should be written by the raw AC functions */
+ Word16 *sfe, /* i: pointer to an array which contains the quantized SCF energies to be encoded */
+ Word16 indepFlag, /* i: 1 if the block is an independent block, 0 otherwise */
+ Word16 doRealEncoding /* i: whether the real encoding is needed, otherwise only the number of bits is used */
+);
+
+void IGFSCFEncoderSaveContextState(
+ IGFSCFENC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */
+);
+
+void IGFSCFEncoderRestoreContextState(
+ IGFSCFENC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */
+);
+
+/* IGFSCFDecoder.c */
+void IGFSCFDecoderOpen(
+ IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */
+ Word16 scfCountLongBlock, /* i: number of SCFs for a long block */
+ Word32 bitRate, /* i: bitrate in bps */
+ Word16 mode /* i: operating mode */
+ ,Word16 rf_mode
+);
+
+void IGFSCFDecoderReset(
+ IGFSCFDEC_INSTANCE_HANDLE hPublicData /* i/o: handle to public data */
+);
+
+void IGFSCFDecoderDecode(
+ IGFSCFDEC_INSTANCE_HANDLE hPublicData, /* i/o: handle to public data */
+ Decoder_State_fx *st, /* i/o: pointer to decoder state */
+ Word16 *sfe, /* o: pointer to an array which will contain the decoded quantized SCFs */
+ Word16 indepFlag /* i: 1 if the block is an independent block, 0 otherwise */
+);
+
+Word32 SFM_Cal(Word32 magn[], Word16 n);
+
+
+void Unified_weighting_fx(
+ Word32 Bin_Ener_128_fx[], /* i : FFT Bin energy 128 bins in two sets Q_ener */
+ Word16 Q_ener,
+ const Word16 lsf_fx[], /* i : LSF vector x2.56 */
+ Word16 w_fx[], /* o : LP weighting filter (numerator) Q8 */
+ const Word16 narrowBand, /* i : flag for Narrowband */
+ const Word16 unvoiced, /* i : flag for Unvoiced frame */
+ const Word32 sr_core, /* i : sampling rate of core-coder */
+ const Word16 order /* i : LP order */
+);
+
+void lsf_dec_bfi(
+ const Word16 codec_mode, /* i: : codec mode: MODE1 | MODE2 */
+ Word16*lsf, /*!< o : 14Q1*1.28 quantized ISFs */
+ const Word16*lsfold, /*!< i : 14Q1*1.28 past quantized ISF */
+ Word16*lsf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */
+ const Word16 lsfBase[], /* i : base for differential lsf coding */
+ Word16*mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */
+ Word16*mem_AR, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */
+ Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) */
+ const Word16 last_coder_type, /*!< i : coding type in last good received fr. */
+ Word16 L_frame,
+ const Word16 last_good, /*!< i : last good received frame */
+ const Word16 nbLostCmpt, /*!< i : counter of consecutive bad frames */
+ Word8 plcBackgroundNoiseUpdated,
+ Word16 *lsf_q_cng, /* o : quantized ISFs for background noise (14Q1*1.28) */
+ Word16 *lsf_cng,
+ Word16 *old_lsf_q_cng, /* o : old quantized ISFs for background noise */
+ const Word16 Last_GSC_pit_band_idx,
+ const Word16 Opt_AMR_WB, /* i : IO flag */
+ const Word8 tcxonly
+ ,const short MODE1_bwidth /* i: coded bandwidth */
+);
+
+
+void lpc_quantization(
+ Encoder_State_fx * st,
+ const Word16 core,
+ const Word16 lpcQuantization,
+ const Word16 lsfold_q[],
+ const Word16 lsp[],
+ const Word16 lspmid[],
+ Word16 lsp_q[],
+ Word16 lsf_q[], /* 14Q1*1.28 */
+ Word16 lspmid_q[],
+ Word16 lspq_ind[],
+ Word16 clip_var[],
+ Word16 mem_MA[],
+ Word16 mem_AR[],
+ const Word8 narrowBand,
+ const Word16 coder_type,
+ const Word8 acelp_midLpc,
+ Word16 param_lpc[],
+ Word16 nbits_lpc[],
+ Word16 * bits_param_lpc,
+ Word16 *no_param_lpc,
+ Word16 *seed_acelp,
+ Word32 * Bin_Ener_fx,
+ Word32 * Bin_Ener_old_fx,
+ const Word16 Q_ener
+);
+
+
+
+/* enc_util.c */
+void Scale_sig(
+ Word16 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx xx exp */
+);
+void E_UTIL_f_preemph(Word16 *signal, const Word16 mu, const Word16 lg, Word16 *mem);
+void E_UTIL_f_preemph2(Word16 shift, Word16 *signal, const Word16 mu, const Word16 lg, Word16 *mem);
+Word16 E_UTIL_f_preemph3(Word16 *signal, const Word16 mu, const Word16 lg, Word16 *mem, Word16 bits);
+void deemph_fx(Word16 * signal, const Word16 mu, const Word16 L, Word16 * mem);
+void E_UTIL_deemph2(Word16 shift, Word16 *x, const Word16 mu, const Word16 L, Word16 *mem);
+void E_UTIL_synthesis(const Word16 shift, const Word16 a[], const Word16 x[], Word16 y[],
+ const Word16 lg, Word16 mem[], const Word16 update, const Word16 m);
+void E_UTIL_f_convolve(const Word16 x[], const Word16 h[], Word16 y[], const Word16 size);
+
+Word16 E_ACELP_hh_corr(Word16 *x, Word16 *y, Word16 L_subfr, Word16 bits);
+Word16 E_ACELP_toeplitz_mul(const Word16 R[], const Word16 c[], Word16 d[], const Word16 L_subfr, const Word16 highrate);
+
+void E_ACELP_weighted_code(
+ const Word16 code[], /* i: code */
+ const Word16 H[], /* i: impulse response */
+ Word16 Q, /* i: Q format of H */
+ Word16 y[] /* o: weighted code */
+);
+
+void E_ACELP_conv(
+ const Word16 xn2[], /* i */
+ const Word16 h2[], /* i */
+ Word16 cn2[] /* o */
+);
+
+void E_ACELP_build_code(
+ Word16 nb_pulse, /* i */
+ const Word16 codvec[], /* i */
+ const Word16 sign[], /* i */
+ Word16 code[], /* o */
+ Word16 ind[] /* o */
+);
+
+void E_ACELP_setup_pulse_search_pos(
+ const PulseConfig *config, /* i: pulse configuration */
+ Word16 k, /* i: interation number */
+ UWord8 ipos[] /* o: pulse search positions */
+);
+
+void find_wsp(
+ const Word16 Az[],
+ const Word16 speech[],
+ Word16 wsp[],
+ Word16 *mem_wsp,
+ const Word16 preemph_fac,
+ const Word16 L_frame,
+ const Word16 lookahead,
+ const Word16 L_subfr,
+ Word16 Aw[], /* o : weighted A(z) filter coefficients */
+ const Word16 gamma, /* i : weighting factor */
+ const Word16 nb_subfr /* i : number of subframes */
+);
+
+void init_sig_buffers( Encoder_State_fx *st, const Word16 L_frame_old, const Word16 L_subfr );
+
+void E_UTIL_cb_shape(
+ const Word16 preemphFlag, /* i : flag for pre-emphasis */
+ const Word16 pitchFlag, /* i : flag for pitch sharpening */
+ const Word16 scramblingFlag, /* i : flag for phase scrambling */
+ const Word16 formant_enh, /* i : use formant enhancement Q15 */
+ const Word16 formant_tilt, /* i : use tilt of formant enhancement Q0 */
+ const Word16 g1, /* i : formant sharpening numerator weighting */
+ const Word16 g2, /* i : formant sharpening denominator weighting */
+ const Word16 *Aq, /* i : quantized LPC coefficients 3Q12 */
+ Word16 *code, /* i/o: <14b */
+ const Word16 tilt_code, /* i : tilt factor Q15 */
+ const Word16 pitch /* i : pointer to current subframe fractional pitch */
+);
+
+void E_UTIL_voice_factor( Word16 *exc, /* i : pointer to the excitation frame Q_new */
+ Word16 i_subfr, /* i : subframe index */
+ Word16 *code, /* i : innovative codebook Q9 */
+ Word16 gain_pit, /* i : adaptive codebook gain 1Q14 */
+ Word32 gain_code, /* i : innovative cb. gain 15Q16 */
+ Word16 *voice_fac, /* o : subframe voicing estimation Q15 */
+ Word16 *tilt_code, /* o : tilt factor Q15 */
+ Word16 L_subfr, /* i : subframe length */
+ Word16 flag_tilt, /* i : Flag for triggering new voice factor tilt*/
+ Word16 Q_new, /* i : excitation buffer format */
+ Word16 shift /* i : scaling to get 12bit */
+ );
+
+Word16 E_UTIL_enhancer(
+ Word16 voice_fac, /* i : subframe voicing estimation Q15 */
+ Word16 stab_fac, /* i : LP filter stability measure Q15 */
+ Word32 gain_code, /* i : innovative cb. gain 15Q16 */
+ Word16 gain_inov, /* i : gain of the unscaled innovation Q12 */
+ Word32 *gc_threshold, /* i/o: gain code threshold 15Q16 */
+ Word16 *code, /* i/o: innovation(in: Q9) code_exp */
+ Word16 *exc2, /* i/o: adapt. excitation/total exc. Q15 */
+ Word16 gain_pit, /* i : Quantized pitch gain 1Q14 */
+ Word32 *prev_gain_code, /* i/o: previous codebook gain 15Q16 */
+ Word16 prev_gain_pit[], /* i/o: previous pitch gain, size=6 1Q14 */
+ Word16 *prev_state, /* i/o: Phase dispersion algorithm memory Q0 */
+ Word16 coder_type, /* i : coder type */
+ Word16 cdk_index, /* i : */
+ Word16 L_subfr, /* i : */
+ Word16 L_frame, /* i : frame size */
+ Word16 Q_new
+);
+
+Word32 E_LPC_schur(Word32 r[], Word16 reflCoeff[], Word32 epsP[], const Word16 m);
+Word16 E_LPC_lev_dur_stab(const Word16 Rh[], const Word16 Rl[], Word16 A[],
+ Word32 epsP[], const Word16 order, Word16 *parcorr, Word16 k_max
+ );
+Word16 E_LPC_lev_dur(const Word16 Rh[], const Word16 Rl[], Word16 A[],
+ Word32 epsP[], const Word16 order, Word16 *parcorr
+ );
+
+void E_LPC_a_weight_inv(const Word16 *a, Word16 *ap, const Word16 gamma, const Word16 m);
+void E_LPC_a_add_tilt(const Word16 *a, Word16 *ap, Word16 gamma, Word16 m);
+void E_LPC_a_lsf_isf_conversion(Word16 *lpcCoeffs, Word16 *lsf, const Word16 *old_lsf, Word16 lpcOrder, Word8 lpcRep);
+void E_LPC_a_lsp_conversion(
+ const Word16 *a, /* input : LP filter coefficients */
+ Word16 *lsp, /* output: Line spectral pairs (in the cosine domain) */
+ const Word16 *old_lsp, /* input : LSP vector from past frame */
+ const Word16 m /* input : LPC order */
+);
+void E_LPC_lsp_lsf_conversion(
+ const Word16 lsp[], /* input: lsp[m] (range: -1<=val<1) */
+ Word16 lsf[], /* output : lsf[m] normalized (range: 0<=val<=6400) */
+ const Word16 m /* input : LPC order */
+);
+void E_LPC_lsf_lsp_conversion(
+ const Word16 lsf[], /* input : lsf[m] normalized (range: 0<=val<=6400) */
+ Word16 lsp[], /* output: lsp[m] (range: -1<=val<1) */
+ const Word16 m /* input : LPC order */
+);
+
+void E_LPC_f_lsp_a_conversion(const Word16 *lsp, Word16 *a, const Word16 m);
+void E_LPC_a_isp_conversion(
+ const Word16 *a, /* input : LP filter coefficients */
+ Word16 *isp, /* output: Line spectral pairs (in the cosine domain) */
+ const Word16 *old_isp,/* input : LSP vector from past frame */
+ const Word16 m /* input : LPC order */
+);
+void E_LPC_isp_isf_conversion(const Word16 isp[], Word16 isf[], const Word16 m);
+void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m);
+void E_LPC_f_isp_a_conversion(const Word16 *isp, Word16 *a, const Word16 m);
+void E_LPC_int_lpc_tcx(const Word16 lsp_old[], /* input : LSPs from past frame (1Q14) */
+ const Word16 lsp_new[], /* input : LSPs from present frame (1Q14) */
+ Word16 a[] /* output: interpolated LP coefficients (4Q11) */
+ );
+
+/* enc_gain.c */
+
+Word16 E_GAIN_closed_loop_search(Word16 exc[],
+ Word16 xn[], Word16 h[],
+ Word16 t0_min, Word16 t0_min_frac, Word16 t0_max, Word16 t0_max_frac, Word16 t0_min_max_res, Word16 *pit_frac, Word16 *pit_res, Word16 pit_res_max,
+ Word16 i_subfr, Word16 pit_min, Word16 pit_fr2, Word16 pit_fr1, Word16 L_subfr);
+void E_GAIN_norm_corr(Word16 exc[], Word16 xn[], Word16 h[],
+ Word16 t_min, Word16 t_max, Word16 corr_norm[], Word16 L_subfr);
+
+/* enc_acelp.c */
+void E_ACELP_xy2_corr(Word16 xn[], Word16 y1[], Word16 y2[], ACELP_CbkCorr *g_corr, Word16 L_subfr, Word16 exp_xn);
+Word16 E_ACELP_xy1_corr(Word16 xn[], Word16 y1[], ACELP_CbkCorr *g_corr, Word16 norm_flag, Word16 L_subfr, Word16 exp_xn);
+void E_ACELP_codebook_target_update(Word16 *x, Word16 *x2, Word16 *y, Word16 gain, Word16 L_subfr);
+void E_ACELP_h_vec_corr1(Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 (*rrixix)[16], Word16 cor[], Word16 dn2_pos[], Word16 nb_pulse);
+void E_ACELP_h_vec_corr2(Word16 h[], Word16 vec[], UWord8 track, Word16 sign[], Word16 (*rrixix)[16], Word16 cor[]);
+void E_ACELP_4tsearch(Word16 dn[], const Word16 cn[], const Word16 H[], Word16 code[], const PulseConfig *config, Word16 ind[], Word16 y[]);
+void E_ACELP_4tsearchx(Word16 dn[], const Word16 cn[], Word16 Rw[], Word16 code[], const PulseConfig *config, Word16 ind[]);
+void E_ACELP_pulsesign(const Word16 cn[], Word16 dn[], Word16 dn2[], Word16 sign[], Word16 vec[], const Word16 alp, Word16 const sign_val, const Word16 L_subfr);
+
+Word16 E_ACELP_indexing(const Word16 code[], const PulseConfig *config, Word16 num_tracks, Word16 prm[]);
+void E_ACELP_findcandidates(Word16 dn2[], Word16 dn2_pos[], Word16 pos_max[]);
+void E_ACELP_vec_neg(Word16 h[], Word16 h_inv[], Word16 L_subfr);
+void E_ACELP_corrmatrix(Word16 h[], Word16 sign[], Word16 vec[], Word16 rrixix[4][16], Word16 rrixiy[4][256]);
+void E_ACELP_codearithp(const Word16 v[], UWord32 *n, UWord32 *ps, Word16 *p);
+
+void find_targets_fx(
+ const Word16 *speech, /* i : pointer to the speech frame Q_new-1*/
+ const Word16 *mem_syn, /* i : memory of the synthesis filter Q_new-1*/
+ const Word16 i_subfr, /* i : subframe index */
+ Word16 *mem_w0, /* i/o: weighting filter denominator memory Q_new-1*/
+ const Word16 *p_Aq, /* i : interpolated quantized A(z) filter Q12*/
+ const Word16 *res, /* i : residual signal Q_new*/
+ const Word16 L_subfr, /* i : length of vectors for gain quantization */
+ const Word16 *Ap, /* i : unquantized A(z) filter with bandwidth expansion Q12*/
+ Word16 tilt_fac, /* i : tilt factor Q15 */
+ Word16 *xn, /* o : Close-loop Pitch search target vector Q_new-1*/
+ Word16 *cn /* o : target vector in residual domain Q_new*/
+ ,Word16 *h1 /* Q14 ?*/
+);
+
+void E_ACELP_adaptive_codebook(
+ Word16 *exc, /* i : pointer to the excitation frame */
+ Word16 T0, /* i : integer pitch lag */
+ Word16 T0_frac, /* i : fraction of lag */
+ Word16 T0_res, /* i : pitch resolution */
+ Word16 T0_res_max, /* i : maximum pitch resolution */
+ Word16 mode, /* i : filtering mode (0: no, 1: yes, 2: adaptive) */
+ Word16 i_subfr, /* i : subframe index */
+ Word16 L_subfr, /* i : subframe length */
+ Word16 L_frame, /* i : subframe length */
+ Word16 *h1, /* i : impulse response of weighted synthesis filter */
+ Word16 clip_gain,
+ Word16 *xn, /* i : Close-loop Pitch search target vector */
+ Word16 *y1, /* o : zero-memory filtered adaptive excitation */
+ ACELP_CbkCorr *g_corr, /* o : ACELP correlation values */
+ Word16 **pt_indice, /* i/o: quantization indices pointer */
+ Word16 *pitch_gain, /* o : adaptive codebook gain */
+ Word16 exp_xn
+ ,Word16 rf_mode
+ ,Word16 use_prev_sf_pit_gain
+ ,Word16* lp_select
+);
+
+void E_ACELP_innovative_codebook(
+ Word16 *exc, /* i : pointer to the excitation frame */
+ Word16 T0, /* i : integer pitch lag */
+ Word16 T0_frac, /* i : fraction of lag */
+ Word16 T0_res, /* i : pitch resolution */
+ Word16 gain_pit, /* i : adaptive codebook gain */
+ Word16 tilt_code, /* i : tilt factor */
+ Word16 mode, /* i : innovative codebook mode */
+ Word16 formant_enh, /* i : use formant enhancement Q15 */
+ Word16 formant_tilt, /* i : use tilt of formant enhancement */
+ const Word16 formant_enh_num, /* i : formant sharpening numerator weighting */
+ const Word16 foramnt_enh_den, /* i : formant sharpening denominator weighting */
+ Word16 pitch_sharpening,/* i : use pitch sharpening */
+ Word16 pre_emphasis,
+ Word16 phase_scrambling,
+ Word16 i_subfr, /* i : subframe index */
+ const Word16 *Aq, /* i : quantized LPC coefficients */
+ Word16 *h1, /* i : impulse response of weighted synthesis filter */
+ Word16 *xn, /* i : Close-loop Pitch search target vector */
+ Word16 *cn, /* i : Innovative codebook search target vector */
+ Word16 *y1, /* i : zero-memory filtered adaptive excitation */
+ Word16 *y2, /* o : zero-memory filtered algebraic excitation */
+ Word8 acelpautoc, /* i : autocorrelation mode enabled */
+ Word16 **pt_indice, /* i/o: quantization indices pointer */
+ Word16 *code, /* o : innovative codebook Q9 */
+ Word16 shift /* i : Scaling to get 12 bits */
+ ,const Word16 L_frame, /* i : length of the frame */
+ const Word16 last_L_frame, /* i : length of the last frame */
+ const Word32 total_brate /* i : total bit-rate */
+);
+
+Word16 E_ACELP_code43bit(const Word16 code[], UWord32 *ps, Word16 *p, UWord16 idxs[]);
+void fcb_pulse_track_joint(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num);
+
+void encode_acelp_gains(
+ Word16 *code, /* Q9 */
+ Word16 gains_mode,
+ Word16 mean_ener_code,
+ Word16 clip_gain,
+ ACELP_CbkCorr *g_corr,
+ Word16 *gain_pit, /* Q14 */
+ Word32 *gain_code, /* 15Q16 */
+ Word16 **pt_indice,
+ Word32 *past_gcode, /* 15Q16 */
+ Word16 *gain_inov, /* Q12 */
+ Word16 L_subfr,
+ Word16 *code2,
+ Word32 *gain_code2,
+ Word8 noisy_speech_flag /* (i) : noisy speech flag */
+);
+
+extern const long int pulsestable[6][7];
+extern const PulseConfig PulseConfTable[];
+extern const Word16 ACELP_CDK_BITS[];
+
+void D_ACELP_indexing(
+ Word16 code[],
+ PulseConfig config,
+ Word16 num_tracks,
+ Word16 index[]
+ ,Word16 *BER_detect
+);
+
+void D_ACELP_decode_43bit(UWord16 idxs[], Word16 code[], Word16 *pulsestrack);
+void fcb_pulse_track_joint_decode(UWord16 *idxs, Word16 wordcnt, UWord32 *index_n, Word16 *pulse_num, Word16 track_num);
+
+/* lag window lag_wind.c */
+void lag_wind(
+ Word16 r_h[], /* in/out: autocorrelations */
+ Word16 r_l[], /* in/out: autocorrelations */
+ Word16 m, /* input : order of LP filter */
+ Word32 sr, /* input : sampling rate */
+ Word16 strength /* input : LAGW_WEAK, LAGW_MEDIUM, or LAGW_STRONG */
+);
+
+void adapt_lag_wind(
+ Word16 r_h[], /* in/out: autocorrelations */
+ Word16 r_l[], /* in/out: autocorrelations */
+ Word16 m, /* input : order of LP filter */
+ const Word16 Top, /* input : open loop pitch lag */
+ const Word16 Tnc, /* input : open loop pitch gain */
+ Word32 sr /* input : sampling rate */
+);
+
+void hp20(Word16 signal[], /* i/o: signal to filter any */
+ const Word16 stride, /* i : stride to be applied accessing signal */
+ const Word16 lg, /* i : length of signal (integer) Q0 */
+ Word32 mem[5], /* i/o: static filter memory with this layout: */
+ /* mem[0]: y[-2] (32-bit) */
+ /* mem[1]; y[-1] (32-bit) */
+ /* mem[2]: x[-2] << 16 */
+ /* mem[3]: x[-1] << 16 */
+ /* Note: mem[0..3] need to be scaled per frame */
+ /* mem[4]: states scale */
+ const Word32 sFreq); /* i : input sampling rate Q0 */
+
+/* pit_fr4.c */
+void Mode2_pred_lt4(Word16 exc[], /* in/out: excitation buffer */
+ Word16 T0, /* input : integer pitch lag */
+ Word16 frac, /* input : fraction of lag */
+ Word16 T0_res, /* input : pitch lag resolution */
+ Word16 T0_res_max, /* input : maximum resolution */
+ Word16 L_subfr); /* input : subframe size */
+
+
+#define mvr2r_Word32(x,y,n) Copy32(x,y,n)
+#define mvr2r_Word16(x,y,n) Copy(x,y,n)
+#define vr_intset(val, vector, count) { Word16 i; FOR(i=0; i<(count); i++) { vector[i]=val; } }
+
+float mean( /* o : the mean of the elements of the vector */
+ const float *vec, /* i : input vector */
+ const short lvec /* i : length of input vector */
+);
+
+/* window.c */
+void ham_cos_window(Word16 *fh, const Word16 n1, const Word16 n2);
+
+
+/*---------------------------------------------------------------------*
+ * main routines *
+ *---------------------------------------------------------------------*/
+
+void init_coder_ace_plus( Encoder_State_fx* st,const Word16 shift);
+void core_coder_reconfig( Encoder_State_fx *st);
+void core_coder_mode_switch( Encoder_State_fx *st, const Word16 bandwidth_in, const Word32 bitrate, const Word16 shift);
+
+void enc_acelp_tcx_main(
+ const Word16 new_samples[], /* i : new samples */
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 pitch[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 voicing[3], /* i : open-loop pitch gains */
+ Word16 Aw[NB_SUBFR16k*(M+1)], /* i : weighted A(z) unquant. for subframes*/
+ const Word16 lsp_new[M], /* i : LSPs at the end of the frame */
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
+ HANDLE_FD_CNG_ENC hFdCngEnc, /* i/o: FD CNG handle */
+ Word32 bwe_exc_extended[], /* i/o: bandwidth extended excitation */
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 pitch_buf[], /* o : floating pitch for each subframe */
+ Word16 vad_hover_flag,
+ const Word16 vad_flag_dtx,
+ Word16 *Q_new,
+ Word16 *shift
+);
+
+/*-----------------------------------------------------------------*
+ * Pitch prediction for frame erasure *
+ *-----------------------------------------------------------------*/
+void pitch_pred_linear_fit(
+ const Word16 /*short*/ bfi_cnt, /* i: bfi counter */ /*Q0 */
+ const Word16 /*short*/ last_good, /* i: last classification type */ /*Q0 */
+ Word32 /*float*/ *old_pitch_buf, /* i: pitch lag buffer */ /*Q16*/
+ Word32 /*float*/ *old_fpitch, /* i: */ /*Q16*/
+ Word32 /*float*/ *T0_out, /* o: estimated close loop pitch */ /*Q16*/
+ Word16 /* int*/ pit_min, /* i: Minimum pitch lag */ /*Q0 */
+ Word16 /* int*/ pit_max, /* i: Maximum pitch lag */ /*Q0 */
+ Word16 /*float*/ *mem_pitch_gain, /* i: pitch gain [0] is the most recent subfr gain */ /*Q0*/
+ Word16 /* int*/ limitation,
+ Word8 /*short*/ plc_use_future_lag, /* i: */ /*Q0 */
+ Word16 /*short*/ *extrapolationFailed, /* o: flag if extrap decides not to change the pitch *//*Q0 */
+ Word16 nb_subfr /* i: number of ACELP subframes */
+);
+
+void get_subframe_pitch(
+ Word16 nSubframes, /* i: number of subframes */ /* Q0 */
+ Word32 pitchStart, /* i: starting pitch lag (in subframe -1) */ /*15Q16*/
+ Word32 pitchEnd, /* i: ending pitch lag (in subframe nSubframes-1) */ /*15Q16*/
+ Word32 *pitchBuf /* o: interpolated pitch lag per subframe */ /*15Q16*/
+);
+
+void core_encode_openloop(
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 coder_type, /* i : coding type */
+ const Word16 pitch[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 voicing[3], /* i : open-loop pitch gains */
+ const Word16 Aw[NB_SUBFR16k*(M+1)], /* i : weighted A(z) unquant. for subframes*/
+ const Word16 *lsp_new, /* i : LSPs at the end of the frame */
+ const Word16 *lsp_mid, /* i : LSPs at the middle of the frame */
+ Word16 *pitch_buf, /* i/o: floating pitch values for each subfr*/
+ Word16 *voice_factors, /* o : voicing factors */
+ Word16 *ptr_bwe_exc, /* o : excitation for SWB TBE */
+ const Word16 vad_hover_flag,
+ const Word16 vad_flag_dtx,
+ Word16 Q_new,
+ Word16 shift
+);
+
+void core_acelp_tcx20_switching(
+ Encoder_State_fx *st, /* i/o: encoder state structure */
+ const Word16 vad_flag,
+ Word16 sp_aud_decision0,
+ Word16 non_staX,
+ Word16 *pitch, /* i : open-loop pitch values for quantiz. */
+ Word16 *pitch_fr, /* i/o: fraction pitch values */
+ Word16 *voicing_fr, /* i/o: fractional voicing values */
+ const Word16 currFlatness, /* i : flatness */
+ const Word16 lsp_mid[M], /* i : LSPs at the middle of the frame */
+ const Word16 stab_fac, /* i : LP filter stability */
+ Word16 Q_new,
+ Word16 shift
+);
+
+void core_encode_twodiv(
+ const Word16 new_samples[],
+ Encoder_State_fx *st,
+ const Word16 coder_type, /* i : coding type */
+ const Word16 pitch[3], /* i : open-loop pitch values for quantiz. */
+ const Word16 voicing[3], /* i : open-loop pitch gains */
+ Word16 Aw[NB_SUBFR16k*(M+1)], /* i : weighted A(z) unquant. for subframes*/
+ Word16 *Q_new,
+ Word16 *shift
+);
+
+void core_encode_update( Encoder_State_fx *st);
+
+void core_encode_update_cng( Encoder_State_fx *st,
+ Word16 *timeDomainBuffer,
+ Word16 *A,
+ Word16 *Aw,
+ Word16 Q_new,
+ Word16 shift
+ );
+
+/* core_sig_ana.c */
+void core_signal_analysis_post(const Word16 *new_samples, Encoder_State_fx *st);
+
+/* ext_sig_ana.c */
+void core_signal_analysis_enc(const Word16 *new_samples, /*, -2,, -2 and 2*/
+ Word16 mean_ener, /*, -2,, -2 and 2*/
+ Word16 mean_ener, /*syn */
+ Word8 fb /* i: fullband flag */
+);
+
+Word16 tcx_get_segSnr(Word16 *wsig, Word16 wsig_e,
+ Word32 *X, Word16 X_e,
+ Word32 *Xq, Word16 Xq_e,
+ Word8 *memQuantZeros,
+ const Word16 snrPenalty, /* 1Q14 */
+ Word16 gainlpc_reweight[], Word16 gainlpc_reweight_e[],
+ Word16 fdns_npts,
+ Word8 narrowBand,
+ Word16 gain_tcx, Word16 gain_tcx_e,
+ Word16 L_frame,
+ Word16 L_frame_glob,
+ Word16 L_subfr
+ );
+
+/* Returns: number of bits used (including "bits") Q0 */
+Word16 tcx_ari_res_Q_spec(
+ const Word32 x_orig[], /* i: original spectrum Q31-e */
+ Word16 x_orig_e, /* i: original spectrum exponent Q0 */
+ const Word16 signs[], /* i: signs (x_orig[.]<0) Q0 */
+ Word32 x_Q[], /* i/o: quantized spectrum Q31-e */
+ Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */
+ Word16 L_frame, /* i: number of lines Q0 */
+ Word16 gain, /* i: TCX gain Q15-e */
+ Word16 gain_e, /* i: TCX gain exponent Q0 */
+ Word16 prm[], /* o: bit-stream Q0 */
+ Word16 target_bits, /* i: number of bits available Q0 */
+ Word16 bits, /* i: number of bits used so far Q0 */
+ Word16 deadzone, /* i: quantizer deadzone Q15 */
+ const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */
+);
+
+/* Returns: number of bits used (including "bits") */
+Word16 tcx_ari_res_invQ_spec(
+ Word32 x_Q[], /* i/o: quantized spectrum Q31-e */
+ Word16 x_Q_e, /* i: quantized spectrum exponent Q0 */
+ Word16 L_frame, /* i: number of lines Q0 */
+ const Word16 prm[], /* i: bit-stream Q0 */
+ Word16 target_bits, /* i: number of bits available Q0 */
+ Word16 bits, /* i: number of bits used so far Q0 */
+ Word16 deadzone, /* i: quantizer deadzone Q15 */
+ const Word16 x_fac[] /* i: spectrum post-quantization factors Q14 */
+);
+
+Word16 tcx_res_Q_gain(
+ Word16 sqGain,
+ Word16 sqGain_e,
+ Word16 *gain_tcx,
+ Word16 *gain_tcx_e,
+ Word16 *prm,
+ Word16 sqTargetBits
+);
+
+Word16 tcx_res_Q_spec(
+ Word32 *x_orig,
+ Word16 x_orig_e,
+ Word32 *x_Q,
+ Word16 x_Q_e,
+ Word16 L_frame,
+ Word16 sqGain,
+ Word16 sqGain_e,
+ Word16 *prm,
+ Word16 sqTargetBits,
+ Word16 bits,
+ Word16 sq_round,
+ const Word16 lf_deemph_factors[]
+);
+
+Word16 tcx_res_invQ_gain(
+ Word16 *gain_tcx,
+ Word16 *gain_tcx_e,
+ Word16 *prm,
+ Word16 resQBits
+);
+
+Word16 tcx_res_invQ_spec(
+ Word32 *x,
+ Word16 x_e,
+ Word16 L_frame,
+ Word16 *prm,
+ Word16 resQBits,
+ Word16 bits,
+ Word16 sq_round,
+ const Word16 lf_deemph_factors[]
+);
+
+void InitTnsConfigs(
+ Word32 nSampleRate,
+ Word16 L_frame,
+ STnsConfig tnsConfig[2][2]
+ ,Word16 igfStopFreq
+ ,Word32 bitrate
+);
+
+void SetTnsConfig(TCX_config * tcx_cfg, Word8 isTCX20, Word8 isAfterACELP);
+
+
+/* ari.c */
+Word32 L_multi31x16_X2(Word16 xh, Word16 xl, Word16 y);
+Word32 mul_sbc_14bits(Word32 r, Word16 c);
+
+void ari_copy_states(
+ TastatEnc *source,
+ TastatEnc *dest
+);
+
+void ari_start_encoding_14bits(
+ TastatEnc *s
+);
+
+Word16 ari_done_encoding_14bits(
+ Word16 *ptr,
+ Word16 bp,
+ TastatEnc *s
+);
+
+Word16 ari_encode_14bits_ext(
+ Word16 *ptr,
+ Word16 bp,
+ TastatEnc *s,
+ Word32 symbol,
+ UWord16 const *cum_freq
+);
+
+void ari_start_decoding_14bits(
+ Decoder_State_fx *st,
+ TastatDec *s
+);
+
+Word16 ari_decode_14bits_s17_ext(
+ Decoder_State_fx *st,
+ TastatDec *s,
+ UWord16 const *cum_freq
+);
+
+Word16 ari_decode_14bits_s27_ext(
+ Decoder_State_fx *st,
+ TastatDec *s,
+ UWord16 const *cum_freq
+);
+
+Word16 ari_decode_14bits_bit_ext(
+ Decoder_State_fx *st,
+ TastatDec *s
+);
+
+
+Word16 ari_encode_overflow(TastatEnc *s);
+Word16 ari_encode_14bits_range(Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 cum_freq_low, Word16 cum_freq_high);
+Word16 ari_encode_14bits_sign(Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s, Word16 sign);
+Word16 ari_done_cbr_encoding_14bits(Word16 *ptr, Word16 bp, Word16 bits, TastatEnc *s);
+Word16 ari_decode_overflow(TastatDec *s);
+Word16 ari_decode_14bits_pow(Word16 *ptr, Word16 bp, Word16 bits, Word16 *res, TastatDec *s, Word16 base);
+Word16 ari_decode_14bits_sign(Word16 *ptr, Word16 bp, Word16 bits, Word16 *res, TastatDec *s);
+Word16 ari_start_decoding_14bits_prm(const Word16 *ptr, Word16 bp, TastatDec *s);
+
+/*arith_code.c*/
+Word32 expfp( /* o: Q31 */
+ Word16 x, /* i: mantissa Q-e */
+ Word16 x_e); /* i: exponent Q0 */
+
+void powfp_odd2(Word16 base, /* Q15 */
+ Word16 exp, /* Q0 */
+ Word16 *pout1, /* Q15 */
+ Word16 *pout2); /* Q15 */
+
+void tcx_arith_scale_envelope(
+ Word16 L_spec_core, /* i: number of lines to scale Q0 */
+ Word16 L_frame, /* i: number of lines Q0 */
+ Word32 env[], /* i: unscaled envelope Q16 */
+ Word16 target_bits, /* i: number of available bits Q0 */
+ Word16 low_complexity, /* i: low-complexity flag Q0 */
+ Word16 s_env[], /* o: scaled envelope Q15-e */
+ Word16 *s_env_e /* o: scaled envelope exponent Q0 */
+);
+
+void tcx_arith_render_envelope(
+ const Word16 A_ind[], /* i: LPC coefficients of signal envelope */
+ Word16 L_frame, /* i: number of spectral lines */
+ Word16 L_spec,
+ Word16 preemph_fac, /* i: pre-emphasis factor */
+ Word16 gamma_w, /* i: A_ind -> weighted envelope factor */
+ Word16 gamma_uw, /* i: A_ind -> non-weighted envelope factor */
+ Word32 env[] /* o: shaped signal envelope */
+);
+
+void tcx_get_gain(Word32 *x, /* i: spectrum 1 */
+ Word16 x_e, /* i: spectrum 1 exponent */
+ Word32 *y, /* i: spectrum 2 */
+ Word16 y_e, /* i: spectrum 2 exponent */
+ Word16 n, /* i: length */
+ Word16 *gain, /* o: gain */
+ Word16 *gain_e, /* o: gain exponent */
+ Word32 *en_y, /* o: energy of y (optional) */
+ Word16 *en_y_e /* o: energy of y exponent (optional) */
+ );
+
+void init_TCX_config(TCX_config *tcx_cfg,
+ Word16 L_frame,
+ Word16 fscale
+ ,Word16 L_frameTCX
+ ,Word16 fscaleFB
+ );
+
+void tcx_arith_encode_envelope(
+ Word32 spectrum[], /* i/o: MDCT coefficients Q31-e */
+ Word16 *spectrum_e, /* i/o: MDCT exponent Q0 */
+ Word16 signs[], /* o: signs (spectrum[.]<0) Q0 */
+ Word16 L_frame, /* i: frame or MDCT length Q0 */
+ Word16 L_frame_orig, /* i: length w/o BW limitation Q0 */
+ Encoder_State_fx *st, /* i/o: coder state */
+ const Word16 A_ind[], /* i: quantised LPC coefficients Q12 */
+ Word16 target_bits, /* i: number of available bits Q0 */
+ Word16 prm[], /* o: bitstream parameters Q0 */
+ Word8 use_hm, /* i: use HM in current frame? */
+ Word16 prm_hm[], /* o: HM parameter area Q0 */
+ Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a Q0*/
+ Word16 *arith_bits, /* o: bits used for ari. coding Q0 */
+ Word16 *signaling_bits, /* o: bits used for signaling Q0 */
+ Word16 *nf_seed /* o: noise filling seed Q0 */
+ ,Word16 low_complexity /* i: low-complexity flag Q0 */
+);
+void tcx_arith_decode_envelope(
+ Word32 q_spectrum[], /* o: quantised MDCT coefficients Q31-e */
+ Word16 *q_spectrum_e, /* o: MDCT exponent Q0 */
+ Word16 L_frame, /* i: frame or MDCT length */
+ Word16 L_frame_orig, /* i: length w/o BW limitation */
+ Decoder_State_fx *st,
+ const Word16 A_ind[], /* i: quantised LPC coefficients */
+ Word16 target_bits, /* i: number of available bits */
+ Word16 prm[], /* i: bitstream parameters */
+ Word8 use_hm, /* i: use HM in current frame? */
+ Word16 prm_hm[], /* i: HM parameter area */
+ Word16 tcxltp_pitch, /* i: TCX LTP pitch in FD, -1 if n/a*/
+ Word16 *arith_bits, /* o: bits used for ari. coding */
+ Word16 *signaling_bits, /* o: bits used for signaling */
+ Word16 *nf_seed /* o: noise filling seed Q0 */
+ ,Word16 low_complexity /* i: low-complexity flag Q0 */
+
+);
+
+# define GET_ADJ2(T,L,F) (((L) << (F)) - (T))
+
+int tcx_hm_render(
+ Word32 lag, /* i: pitch lag Q0 */
+ Word16 fract_res, /* i: fractional resolution of the lag Q0 */
+ Word16 p[] /* o: harmonic model Q13 */
+);
+
+void tcx_hm_modify_envelope(
+ Word16 gain, /* i: HM gain Q11 */
+ Word32 lag, /* i: pitch lag Q0 */
+ Word16 fract_res, /* i: fractional resolution of the lag Q0 */
+ Word16 p[], /* i: harmonic model Q13 */
+ Word32 env[], /* i/o: envelope Q16 */
+ Word16 L_frame /* i: number of spectral lines Q0 */
+);
+
+void UnmapIndex(
+ Word16 PeriodicityIndex,
+ Word16 Bandwidth,
+ Word16 LtpPitchLag,
+ Word8 SmallerLags,
+ Word16 *FractionalResolution,
+ Word32 *Lag);
+
+/* Returns: PeriodicityIndex */
+Word16 SearchPeriodicityIndex(
+ const Word32 Mdct[], /* (I) Coefficients, Mdct[0..NumCoeffs-1] */
+ const Word32 UnfilteredMdct[], /* (I) Unfiltered coefficients, UnfilteredMdct[0..NumCoeffs-1] */
+ Word16 NumCoeffs, /* (I) Number of coefficients */
+ Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) */
+ Word16 LtpPitchLag,
+ Word16 LtpGain, /* (I) LTP gain */
+ Word16 *RelativeScore /* (O) Energy concentration factor */
+);
+
+void ConfigureContextHm(
+ Word16 NumCoeffs, /* (I) Number of coefficients */
+ Word16 TargetBits, /* (I) Target bit budget (excl. Done flag) */
+ Word16 PeriodicityIndex, /* (I) Pitch related index */
+ Word16 LtpPitchLag, /* (I) TCX-LTP pitch in F.D. */
+ CONTEXT_HM_CONFIG *hm_cfg /* (O) Context-based harmonic model configuration */
+);
+
+Word16 EncodeIndex(
+ Word16 Bandwidth, /* 0: NB, 1: (S)WB */
+ Word16 PeriodicityIndex,
+ Encoder_State_fx *st);
+
+Word16 CountIndexBits(
+ Word16 Bandwidth, /* 0: NB, 1: (S)WB */
+ Word16 PeriodicityIndex);
+
+Word16
+DecodeIndex(
+ Decoder_State_fx *st,
+ Word16 Bandwidth,
+ Word16 *PeriodicityIndex);
+
+
+void tcx_hm_analyse(
+ const Word32 abs_spectrum[], /* i: absolute spectrum Q31-e */
+ Word16 *spectrum_e, /* i: absolute spectrum exponent Q0 */
+ Word16 L_frame, /* i: number of spectral lines Q0 */
+ Word32 env[], /* i/o: envelope shape Q16 */
+ Word16 targetBits, /* i: target bit budget Q0 */
+ Word16 coder_type, /* i: coder type Q0 */
+ Word16 prm_hm[], /* o: HM parameters Q0 */
+ Word16 LtpPitchLag, /* i: LTP pitch lag or -1 if none Q0 */
+ Word16 LtpGain, /* i: LTP gain Q15 */
+ Word16 *hm_bits /* o: bit consumption Q0 */
+);
+
+void tcx_hm_decode(
+ Word16 L_frame, /* i: number of spectral lines Q0 */
+ Word32 env[], /* i/o: envelope shape Q16 */
+ Word16 targetBits, /* i: target bit budget Q0 */
+ Word16 coder_type, /* i: coder_type Q0 */
+ Word16 prm_hm[], /* i: HM parameters Q0 */
+ Word16 LtpPitchLag, /* i: LTP pitch lag or -1 if none Q0 */
+ Word16 *hm_bits /* o: bit consumption Q0 */
+);
+
+void coder_tcx(
+ Word16 n,
+ TCX_config *tcx_cfg, /*input: configuration of TCX*/
+ Word16 A[], /* input: quantized coefficients NxAz_q[M+1] */
+ Word16 Aqind[], /* input: frame-independent quantized coefficients (M+1) */
+ Word16 synth[],
+ Word16 L_frame_glob, /* input: frame length */
+ Word16 L_frameTCX_glob,
+ Word16 L_spec,
+ Word16 nb_bits, /*input: bit budget*/
+ Word8 tcxonly, /*input: only TCX flag*/
+ Word32 spectrum[], /* i/o: MDCT spectrum */
+ Word16 *spectrum_e, /* i/o: MDCT spectrum exponent */
+ LPD_state *LPDmem, /*i/o: memories*/
+ Word16 prm[], /* output: tcx parameters */
+ Encoder_State_fx *st,
+ CONTEXT_HM_CONFIG *hm_cfg
+);
+
+void coder_tcx_post(Encoder_State_fx *st,
+ LPD_state *LPDmem,
+ TCX_config *tcx_cfg,
+ Word16 *synth,
+ const Word16 *A,
+ const Word16 *Ai,
+ Word16 *wsig,
+ Word16 Q_new,
+ Word16 shift
+ );
+
+void decoder_tcx(
+ TCX_config *tcx_cfg, /* input: configuration of TCX */
+ Word16 prm[], /* input: parameters */
+ Word16 A[], /* input: coefficients NxAz[M+1] */
+ Word16 Aind[], /* input: frame-independent coefficients Az[M+1] */
+ Word16 L_frame_glob, /* input: frame length */
+ Word16 L_frameTCX,
+ Word16 L_spec,
+ Word16 synth[], /* in/out: synth[-M-LFAC..lg] */
+ Word16 synthFB[],
+ Decoder_State_fx*st,
+ Word16 coder_type, /* input : coder type */
+ Word16 bfi, /* input: Bad frame indicator */
+ Word16 frame_cnt, /* input: frame counter in the super_frame */
+ Word16 stab_fac /* input: stability of isf */
+);
+
+void decoder_tcx_post(Decoder_State_fx *st_fx,
+ Word16 *synth,
+ Word16 *synthFB,
+ Word16 *A,
+ Word16 bfi
+ );
+
+/* cod_ace.c */
+Word16 coder_acelp( /* output SEGSNR for CL decision */
+ ACELP_config *acelp_cfg, /*input/output: configuration of the ACELP coding*/
+ const Word16 coder_type, /* input: coding type */
+ const Word16 A[], /* input: coefficients 4xAz[M+1] */
+ const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] */
+ Word16 speech[], /* input: speech[-M..lg] */
+ Word16 synth[],
+ LPD_state *LPDmem,
+ const Word16 voicing[], /* input: open-loop LTP gain */
+ const Word16 T_op[], /* input: open-loop LTP lag */
+ Word16 *prm, /* output: acelp parameters */
+ Word16 stab_fac,
+ Encoder_State_fx *st,
+ HANDLE_PLC_ENC_EVS hPlc_Ext,
+ Word16 target_bits, /* i/o : coder memory state */
+ Word16 Q_new,
+ Word16 shift,
+ Word16 *pitch_buf, /* output : pitch values for each subfr.*/
+ Word16 *voice_factors, /* output : voicing factors */
+ Word16 *bwe_exc /* output : excitation for SWB TBE */
+);
+
+
+void decoder_acelp(
+ Decoder_State_fx *st,
+ Word16 coder_type, /* input: coder type */
+ Word16 prm[], /* input: parameters */
+ Word16 A[], /* input: coefficients NxAz[M+1] */
+ ACELP_config acelp_cfg, /* input: ACELP config */
+ Word16 synth[], /* i/o: synth[-2*LFAC..L_DIV] Q0 */
+ Word16 *pT, /* out: pitch for all subframe Q0 */
+ Word16 *pgainT, /* out: pitch gain for all subfr 1Q14 */
+ Word16 stab_fac, /* input: stability of isf */
+ Word16 *pitch_buffer, /* out: pitch values for each subfr.*/
+ Word16 *voice_factors, /* out: voicing factors */
+ const Word16 LSF_Q_prediction,/* i : LSF prediction mode */
+ Word16 *bwe_exc /* out: excitation for SWB TBE */
+);
+
+void enc_prm(
+ const Word16 coder_type, /* (i) : coding type */
+ Word16 param[], /* (i) : parameters */
+ Word16 param_lpc[], /* (i) : LPC parameters */
+ Encoder_State_fx *st, /* io: quantization Analysis values */
+ Word16 L_Frame,
+ CONTEXT_HM_CONFIG hm_cfg[],
+ Word16 * bits_param_lpc,
+ Word16 no_param_lpc
+);
+
+void enc_prm_rf(
+ Encoder_State_fx *st,
+ const Word16 rf_frame_type,
+ const Word16 fec_offset
+);
+
+void dec_prm(
+ Word16 *coder_type,
+ Word16 param[], /* (o) : decoded parameters */
+ Word16 param_lpc[], /* (o) : LPC parameters */
+ Word16 *total_nbbits, /* i/o : number of bits / decoded bits */
+ Decoder_State_fx *st,
+ Word16 L_frame,
+ Word16 *bitsRead
+);
+
+void dec_prm_core(
+ Decoder_State_fx *st
+);
+
+void analy_sp( /* o: fft0 bin energy Q0 */
+ Word16 *speech, /* i: speech buffer Q_new - preemph_bits */
+ const Word16 Q_new, /* i: current scaling exp Q0 */
+ Word32 *fr_bands, /* o: energy in critical frequency bands Q_new + QSCALE */
+ Word32 *lf_E, /* o: per bin E for first... Q_new + QSCALE - 2*/
+ Word16 *Etot, /* o: total input energy Q8 */
+ const Word16 min_band, /* i: minimum critical band Q0 */
+ const Word16 max_band, /* i: maximum critical band Q0 */
+ const Word32 e_min_scaled, /* i: minimum energy scaled Q_new + QSCALE */
+ Word16 Scale_fac[2], /* o: FFT scales factors (2 values by frame) Q0 */
+ Word32 *Bin_E, /* o : per bin log energy spectrum */
+ Word32 *Bin_E_old, /* o : per bin log energy spectrum for mid-frame */
+ Word32 *PS, /* o : Per bin energy spectrum */
+ Word16 *EspecdB, /* o : log E spectrum (with f=0) of the current frame Q7 */
+ Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN */
+ Word16 *fft_buff /* o : FFT coefficients */
+);
+
+void E_UTIL_copy_scale_sig(
+ const Word16 x[], /* i : signal to scale input Qx */
+ Word16 y[], /* o : scaled signal output Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx xx exp */
+);
+
+void scale_sig32(
+ Word32 x[], /* i/o: signal to scale Qx */
+ const Word16 lg, /* i : size of x[] Q0 */
+ const Word16 exp0 /* i : exponent: x = round(x << exp) Qx xx exp */
+);
+
+
+Word32 scale_mem( /* o : Min energy scaled */
+ Word16 ini_frames, /* i : Frame number */
+ Word16 Q_exp, /* i : Diff scaling factor */
+ Word16 *Q_new, /* i/o: Absolute scaling factor */
+ Word16 *old_speech, /* i/o: Speech memory */
+ Word16 *old_speech_ns, /* i/o: Speech denoised memory */
+ Word16 *mem_wsp, /* i/o: wsp vector memory */
+ Word32 *enrO, /* i/o: Enr mem */
+ Word32 *bckr, /* i/o: Back ground_fx ener mem */
+ Word32 *lf_EO, /* i/o: Energy per low freq bin mem */
+ Word32 *ave_enr, /* i/o: Ave_enr mem */
+ Word32 *st_fr_bands1, /* i/o: spectrum per critical bands of the previous frame */
+ Word32 *st_fr_bands2, /* i/o: spectrum per critical bands 2 frames ago */
+ Word32 *ave_enr2 /* i/o: LT average E per crit. band (for non_sta2) Q_new + QSCALE */
+);
+
+Word16 rescale_exc(
+ Word16 exc[], /* i/o: excitation to rescale Q_exc */
+ Word16 lg, /* i : frame size */
+ Word32 L_gain_code, /* i : decoded codebook gain Q16 */
+ Word16 *sQ_exc, /* i/o: Excitation scaling factor */
+ Word16 *sQsubfr, /* i/o: Past excitation scaling factors */
+ Word16 exc2[], /* o : local excitation vector */
+ Word16 i_subfr /* i : subframe number */
+);
+
+Word16 rescale_mem(
+ const Word16 *Q_exc, /* i : current excitation scaling (>=0) */
+ Word16 *prev_Q_syn, /* i/o : scaling factor of previous frame */
+ Word16 *Q_syn, /* i/o : scaling factor of frame */
+ Word16 *mem_syn2, /* i/o : modified synthesis memory */
+ Word16 *syn, /* i/o : synthesis to rescale Q_syn */
+ Word16 mem_len, /* i : lenght of modified synthesis memory */
+ Word16 i_subfr /* i : subframe number */
+);
+
+void gauss_L2(
+ const Word16 h[], /* i : weighted LP filter impulse response Q14+s */
+ Word16 code2[], /* o : gaussian excitation Q9 */
+ const Word16 y2[], /* i : zero-memory filtered code. excitation Q9 */
+ Word16 y11[], /* o : zero-memory filtered gauss. excitation Q9 */
+ Word32 *gain, /* o : excitation gain */
+ ACELP_CbkCorr *g_corr, /*i/o : correlation structure for gain coding */
+ const Word16 gain_pit, /* i : unquantized gain of code */
+ const Word16 tilt_code, /* i : tilt of code Q15 */
+ const Word16 *Aq, /* i : quantized LPCs Q12 */
+ const Word16 formant_enh, /* i : formant enhancement factor Q15 */
+ Word16 *seed_acelp, /*i/o : random seed Q0 */
+ const Word16 shift
+);
+
+void gaus_L2_dec(
+ Word16 *code, /* o : decoded gaussian codevector Q9 */
+ Word16 tilt_code, /* i : tilt of code Q15 */
+ const Word16 *A, /* i : quantized LPCs Q12 */
+ Word16 formant_enh, /* i : formant enhancement factor Q15 */
+ Word16 *seed_acelp /*i/o : random seed Q0 */
+);
+
+void tcx_ltp_get_lpc(
+ Word16 *x,
+ Word16 L,
+ Word16 *A,
+ Word16 order
+);
+
+void predict_signal(
+ const Word16 excI[], /* i : input excitation buffer */
+ Word16 excO[], /* o : output excitation buffer */
+ const Word16 T0, /* i : integer pitch lag */
+ Word16 frac, /* i : fraction of lag */
+ const Word16 frac_max, /* i : max fraction */
+ const Word16 L_subfr /* i : subframe size */
+);
+
+void tcx_ltp_pitch_search(
+ Word16 pitch_ol,
+ Word16 *pitch_int,
+ Word16 *pitch_fr,
+ Word16 *index,
+ Word16 *norm_corr,
+ const Word16 len,
+ Word16 *wsp,
+ Word16 pitmin,
+ Word16 pitfr1,
+ Word16 pitfr2,
+ Word16 pitmax,
+ Word16 pitres
+);
+
+void tcx_ltp_encode( Word8 tcxltp_on,
+ Word8 tcxOnly,
+ Word16 tcxMode,
+ Word16 L_frame,
+ Word16 L_subfr,
+ Word16 *speech,
+ Word16 *speech_ltp,
+ Word16 *wsp,
+ Word16 Top,
+ Word16 *ltp_param,
+ Word16 *ltp_bits,
+ Word16 *pitch_int,
+ Word16 *pitch_fr,
+ Word16 *gain,
+ Word16 *pitch_int_past,
+ Word16 *pitch_fr_past,
+ Word16 *gain_past,
+ Word16 *norm_corr_past,
+ Word16 last_core,
+ Word16 pitmin,
+ Word16 pitfr1,
+ Word16 pitfr2,
+ Word16 pitmax,
+ Word16 pitres,
+ struct TransientDetection const * pTransientDetection,
+ Word8 SideInfoOnly,
+ Word16 *A,
+ Word16 lpcorder
+ );
+
+void tcx_ltp_post( Word8 tcxltp_on,
+ Word16 core,
+ Word16 L_frame,
+ Word16 L_frame_core,
+ Word16 delay,
+ Word16 *sig,
+ Word16 *tcx_buf,
+ Word16 tcx_buf_len,
+ Word16 bfi,
+ Word16 pitch_int,
+ Word16 pitch_fr,
+ Word16 gain,
+ Word16 *pitch_int_past,
+ Word16 *pitch_fr_past,
+ Word16 *gain_past,
+ Word16 *filtIdx_past,
+ Word16 pitres,
+ Word16 *pitres_past,
+ Word16 damping,
+ Word16 SideInfoOnly,
+ Word16 *mem_in,
+ Word16 *mem_out,
+ Word32 bitrate
+ );
+
+Word16 tcx_ltp_decode_params( Word16 *ltp_param,
+ Word16 *pitch_int,
+ Word16 *pitch_fr,
+ Word16 *gain,
+ Word16 pitmin,
+ Word16 pitfr1,
+ Word16 pitfr2,
+ Word16 pitmax,
+ Word16 pitres
+ );
+
+/*isf_msvq_ma.c, lsf_msvq_ma.c*/
+void msvq_enc
+(
+ const Word16 *const*cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */
+ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
+ const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
+ const Word16 u[], /* i : Vector to be encoded (prediction and mean removed)(14Q1*1.28) */
+ const Word16 *levels, /* i : Number of levels in each stage */
+ const Word16 maxC, /* i : Tree search size (number of candidates kept from */
+ /* one stage to the next == M-best) */
+ const Word16 stages, /* i : Number of stages */
+ const Word16 w[], /* i : Weights Q8 */
+ const Word16 N, /* i : Vector dimension */
+ const Word16 maxN, /* i : Codebook dimension */
+ Word16 Idx[] /* o : Indices */
+);
+void msvq_dec
+(
+ const Word16 *const*cb, /* i : Codebook (indexed cb[*stages][levels][p]) (0Q15) */
+ const Word16 dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */
+ const Word16 offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */
+ const Word16 stages, /* i : Number of stages */
+ const Word16 N, /* i : Vector dimension */
+ const Word16 maxN, /* i : Codebook dimension */
+ const Word16 Idx[], /* i : Indices */
+ Word16 *uq /* o : quantized vector (3Q12) */
+);
+
+
+/*-------------------------------------------------------------------------
+* Recovery tools for resynchronization
+*------------------------------------------------------------------------*/
+/*er_sync_exc.c*/
+/** Resynchronize glotal pulse positions of the signal in src_exc and store it in dst_exc.
+ * src_exc holds on call the harmonic part of the signal with the constant pitch, constructed by repeating the last pitch cycle of length pitchStart.
+ * dst_exc holds on return the harmonic part of the signal with the pitch changing from pitchStart to pitchEnd.
+ * src_exc and dst_exc can overlap, but src_exc < dst_exc must be fullfiled.
+ * @param src_exc Input excitation buffer.
+ * @param dst_exc Output excitation buffer.
+ * @param nFrameLength Length of the frame, that is the length of the valid data in the excitation buffer on return.
+ * @param nSubframes Number of subframes in the excitation buffer. nFrameLength must be divisible by nSubframes.
+ * @param pitchStart Pitch at the end of the last frame.
+ * @param pitchEnd Pitch at the end of the current frame.
+ */
+void PulseResynchronization(
+ Word16 /*float*/ const * const src_exc, /*i Q15*/
+ Word16 /*float*/ * const dst_exc, /*o Q15*/
+ Word16 /*int*/ const nFrameLength, /*i Q0 */
+ Word16 /*int*/ const nSubframes, /*i Q0 */
+ Word32 /*float*/ const pitchStart, /*i Q16*/
+ Word32 /*float*/ const pitchEnd /*i Q16*/
+);
+
+/* er_util.c*/
+/* PLC: [TCX: TD PLC]
+ * PLC: FindSubframePitchInTCX: function to find the pitch per half a frame for the last TCX */
+/*VERSIONINFO: This port is up to date with trunk rev. 30479*/
+/*VERSIONINFO: This port is up to date with trunk rev. 7611*/
+
+void con_acelp(
+ const Word16 A[], /*mem_syn >rescaling done */
+ , Word16 *pitch_buffer
+ , Word16 *voice_factors
+ , Word16 *bwe_exc
+);
+
+void con_tcx(
+ Decoder_State_fx *st, /* i/o: coder memory state */
+ Word16 /*float*/ synth[] /* i/o: synth[] *//*Q0 */
+);
+
+
+/* isf_msvq_ma.c */
+void isf_msvq_ma_enc(const Word16 *isf, /* i: isf coefficients (3Q12) */
+ Word16 *isfq, /* o: quantized isf */
+ Word16 *isfq_ind,
+ Word16 *indices, /* o: quantizer indices */
+ Word16 *nb_indices, /* o: number of bits for the indices */
+ Word16 *mem_MA, /* i/o: moving average filter buffer (3Q12) */
+ Word16 *parcorr,
+ const Word16 m, /* i: lpc order */
+ const Word16 acelp_mode, /* i: acelp mode */
+ const Word8 narrow_band /* i: narrow-band flag */
+ );
+void isf_msvq_ma_dec( Word16 *isfq,
+ Word16 *isfq_ind,
+ Word16 *indices,
+ Word16 *nb_indices,
+ Word16 *mem_MA,
+ Word16 m,
+ Word16 acelp_mode,
+ Word8 narrow_band /* i: narrow-band flag */
+ );
+Word16 isf_msvq_ma_encprm( Encoder_State_fx *st, Word16 *param_lpc, Word16 core, Word16 acelp_mode, Word16 acelp_midLpc, Word16 m );
+Word16 isf_msvq_ma_decprm( Decoder_State_fx *st, Word16 *param_lpc, Word16 core, Word16 acelp_mode, Word16 acelp_midLpc, Word16 m );
+
+/* Returns: non-zero on conversion error, 0 otherwise */
+Word16 E_LPC_lsp_unweight(
+ /* const */ Word16 xsp_w[], /* (I): weighted xSP */
+ Word16 xsp_uw[], /* (O): unweighted xSP */
+ Word16 xsf_uw[], /* (O): unweighted xSF */
+ Word16 inv_gamma, /* (I): inverse weighting factor */
+ Word16 lpcorder /* (I): prediction order */
+);
+
+Word16 lsf_ind_is_active(
+ const Word16 lsf_q_ind[],
+ const Word16 means[],
+ Word16 bandwidth,
+ Word16 cdk);
+
+void lsf_update_memory(
+ Word16 narrowband, /* i : narrowband flag */
+ const Word16 qisf[], /* i : quantized xSF coefficients */
+ Word16 old_mem_MA[], /* i : MA memory */
+ Word16 mem_MA[], /* o : updated MA memory */
+ Word16 lpcorder /* i : LPC order */
+);
+
+/* Returns: number of indices */
+Word16 Q_lsf_tcxlpc(
+ /* const */ Word16 xsf[], /* (I) original xSF */
+ Word16 xsf_q[], /* (O) quantized xSF */
+ Word16 xsf_q_ind[], /* (O) quantized xSF (w/o MA prediction) */
+ Word16 indices[], /* (O) VQ indices */
+ Word16 lpcorder, /* (I) LPC order */
+ Word16 narrowband, /* (I) narrowband flag */
+ Word16 cdk, /* (I) codebook selector */
+ Word16 mem_MA[], /* (I) MA memory */
+ Word16 coder_type,
+ Word32 * Bin_Ener,
+ const Word16 Q_ener
+);
+
+/* Returns: number of indices */
+Word16 D_lsf_tcxlpc(
+ const Word16 indices[], /* (I) VQ indices */
+ Word16 xsf_q[], /* (O) quantized xSF */
+ Word16 xsf_q_ind[], /* (O) quantized xSF (w/o MA prediction) */
+ Word16 narrowband, /* (I) narrowband flag */
+ Word16 cdk, /* (I) codebook selector */
+ Word16 mem_MA[] /* (I) MA memory */
+);
+
+/* Returns: number of bits written */
+Word16 enc_lsf_tcxlpc(
+ Word16 **indices, /* (I) Ptr to VQ indices */
+ Encoder_State_fx *st /* (I/O) Encoder state */
+);
+
+/* Returns: number of bits read */
+Word16 dec_lsf_tcxlpc(
+ Decoder_State_fx *st, /* (I/O) Decoder state */
+ Word16 **indices, /* (O) Ptr to VQ indices */
+ Word16 narrowband, /* (I) narrowband flag */
+ Word16 cdk /* (I) codebook selector */
+);
+
+/* Returns: codebook index */
+Word16 tcxlpc_get_cdk(
+ Word16 coder_type /* (I) VOICED indicator */
+);
+
+/* lsf_msvq_ma.c */
+void lsf_msvq_ma_enc(
+ const Word16 *lsf, /* i: lsf coefficients (14Q1*1.28)*/
+ Word16 *lsfq, /* o: quantized lsf */
+ Word16 *lsfq_ind,
+ Word32 * Bin_Ener_128_fx,
+ const Word16 Q_ener,
+ Word16 *indices, /* o: quantizer indices */
+ Word16 *nb_indices, /* o: number of bits for the indices */
+ Word16 *mem_MA, /* i/o: moving average filter buffer (3Q12*1.28)*/
+ const Word16 m, /* i: lpc order */
+ const Word16 acelp_mode /* i: acelp mode */
+);
+
+void lsf_msvq_ma_dec( Word16 *lsfq,
+ Word16 *lsfq_ind,
+ Word16 *indices,
+ Word16 *nb_indices,
+ Word16 *mem_MA,
+ Word16 m,
+ Word16 acelp_mode
+ );
+
+Word16 lsf_msvq_ma_encprm( Encoder_State_fx * st,
+ Word16 *param_lpc,
+ Word16 core,
+ Word16 acelp_mode,
+ Word16 acelp_midLpc,
+ Word16 * bits_param_lpc,
+ Word16 no_indices
+ );
+Word16 lsf_msvq_ma_decprm( Decoder_State_fx *st, Word16 *param_lpc, Word16 core, Word16 acelp_mode, Word16 acelp_midLpc
+ ,Word16 narrowBand
+ ,Word32 sr_core
+ );
+
+Word16 lsf_bctcvq_encprm(
+ Encoder_State_fx *st,
+ Word16 *param_lpc,
+ Word16 * bits_param_lpc,
+ Word16 no_indices
+);
+
+Word16 lsf_bctcvq_decprm(
+ Decoder_State_fx * st,
+ Word16 *param_lpc
+);
+void lpc_unquantize(
+ Decoder_State_fx * st,
+ Word16 *lsfold,
+ Word16 *lspold,
+ Word16 *lsf,
+ Word16 *lsp,
+ const Word16 m,
+ const Word16 lpcQuantization,
+ Word16 *param_lpc,
+ const Word16 numlpc,
+ const Word16 core,
+ Word16 *mem_MA,
+ Word16 *mem_AR,
+ Word16 *lspmid,
+ Word16 *lsfmid,
+ Word16 coder_type,
+ Word16 acelp_midLpc,
+ Word8 narrow_band,
+ Word16 *seed_acelp,
+ Word32 sr_core,
+ Word16 *mid_lsf_int,
+ Word16 prev_bfi,
+ Word16 *LSF_Q_prediction, /* o : LSF prediction mode */
+ Word16 *safety_net
+);
+
+void midlsf_enc(const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */
+ const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */
+ const Word16 lsf[], /* i: lsf coefficients (3Q12) */
+ Word16 *idx, /* o: codebook index */
+ const Word16 lpcorder /* i: order of the lpc */
+ , Word32 * Bin_Ener_128_fx
+ ,const Word16 Q_ener
+ ,Word8 narrowBand
+ ,Word32 sr_core
+ ,Word16 coder_type
+ );
+
+
+void midlsf_dec(
+ const Word16 qlsf0[], /* i: quantized lsf coefficients (3Q12) */
+ const Word16 qlsf1[], /* i: quantized lsf coefficients (3Q12) */
+ Word16 idx, /* i: codebook index */
+ Word16 qlsf[], /* o: decoded lsf coefficients (3Q12) */
+ Word16 coder_type,
+ Word16 *mid_lsf_int,
+ Word16 prev_bfi,
+ Word16 safety_net);
+
+
+Word16 const * PlcGetLsfBase (Word16 const lpcQuantization,
+ Word16 const narrowBand,
+ Word32 const sr_core);
+
+/* tcx_mdct.h */
+#define MDCT_A_E 1
+
+#define TCX_IMDCT_SCALE 15
+#define TCX_IMDCT_HEADROOM 1
+
+void TCX_MDCT(const Word16 *x, Word32 *y, Word16 *y_e, Word16 l, Word16 m, Word16 r);
+
+void TCX_MDST(const Word16 *x, Word32 *y, Word16 *y_e, Word16 l, Word16 m, Word16 r);
+
+void TCX_MDCT_Inverse(Word32 *x, Word16 x_e, Word16 *y, Word16 l, Word16 m, Word16 r);
+
+
+/* post_dec.h */
+void post_decoder(
+ Decoder_State_fx *st,
+ Word16 coder_type,
+ Word16 synth_buf[],
+ Word16 pit_gain[],
+ Word16 pitch[],
+ Word16 signal_out[],
+ Word16 * bpf_noise_buf
+);
+
+Word16 bass_pf_enc(
+ Word16 *orig, /* (i) : 12.8kHz original signal Q0 */
+ Word16 *syn, /* (i) : 12.8kHz synthesis to postfilter Q0 */
+ Word16 *T_sf, /* (i) : Pitch period for all subframes (T_sf[16]) Q0 */
+ Word16 *gainT_sf, /* (i) : Pitch gain for all subframes (gainT_sf[16]) Q14 */
+ Word16 l_frame, /* (i) : frame length (should be multiple of l_subfr) Q0 */
+ Word16 l_subfr, /* (i) : sub-frame length (60/64) Q0 */
+ Word16 *gain_factor_param, /* (o) : quantized gain factor Q0 */
+ Word16 mode, /* (i) : coding mode of adapt bpf */
+ struct MEM_BPF *mem_bpf /* i/o : memory state */
+);
+void cldfb_synth_set_bandsToZero(
+ Decoder_State_fx *st,
+ Word32 **rAnalysis,
+ Word32 **iAnalysis,
+ const Word16 nTimeSlots,
+ const CLDFB_SCALE_FACTOR scaleFactor
+);
+/* fd_cng_common.h */
+/* Create an instance of type FD_CNG */
+void createFdCngCom(HANDLE_FD_CNG_COM* hFdCngCom);
+
+void initFdCngCom(HANDLE_FD_CNG_COM hFdCngCom, Word16 scale);
+
+/* Delete the instance of type FD_CNG */
+void deleteFdCngCom(HANDLE_FD_CNG_COM * hFdCngCom);
+
+void resetFdCngEnc( Encoder_State_fx * st);
+
+/* Initialize the spectral partitioning */
+void initPartitions( const Word16* part_in,
+ Word16 npart_in,
+ Word16 startBand,
+ Word16 stopBand,
+ Word16* part_out,
+ Word16* npart_out,
+ Word16* midband,
+ Word16* psize,
+ Word16* psize_norm,
+ Word16* psize_norm_exp,
+ Word16* psize_inv,
+ Word16 stopBandFR);
+
+/* Noise estimation using Minimum Statistics (MS) */
+void compress_range(Word32 *in,
+ Word16 in_exp,
+ Word16 *out,
+ Word16 len
+ );
+
+void expand_range(Word16 *in,
+ Word32 *out,
+ Word16 *out_exp,
+ Word16 len
+ );
+
+void minimum_statistics(Word16 len, /* i : Total number of partitions (CLDFB or FFT) */
+ Word16 lenFFT, /* i : Number of FFT partitions */
+ Word16 *psize, /* i : Partition sizes, fractional */
+ Word16 *msPeriodog, /* i : Periodogram (energies) */
+ Word16 *msNoiseFloor, /* i/o: Noise floors (energies) */
+ Word16 *msNoiseEst, /* i/o: Noise estimates (energies) */
+ Word32 *msAlpha, /* i/o: Forgetting factors */
+ Word16 *msPsd, /* i/o: Power Spectral Density (smoothed periodogram => energies) */
+ Word16 *msPsdFirstMoment, /* i/o: PSD statistics of 1st order (energy means) */
+ Word32 *msPsdSecondMoment, /* i/o: PSD statistics of 2nd order (energy variances) */
+ Word32 *msMinBuf, /* i/o: Buffer of minima (energies) */
+ Word32 *msBminWin, /* o : Bias correction factors */
+ Word32 *msBminSubWin, /* o : Bias correction factors */
+ Word32 *msCurrentMin, /* i/o: Local minima (energies) */
+ Word32 *msCurrentMinOut, /* i/o: Local minima (energies) */
+ Word32 *msCurrentMinSubWindow, /* i/o: Local minima (energies) */
+ Word16 *msLocalMinFlag, /* i : Binary flag */
+ Word16 *msNewMinFlag, /* i : Binary flag */
+ Word16 *msPeriodogBuf, /* i/o: Buffer of periodograms (energies) */
+ Word16 *msPeriodogBufPtr, /* i/o: Counter */
+ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing buffers and variables */
+ );
+
+/* Generate the comfort noise based on the target noise level */
+void generate_comfort_noise_enc (Encoder_State_fx *stcod,
+ Word16 Q_new,
+ Word16 gen_exc
+ );
+void generate_comfort_noise_dec (Word32 **bufferReal, /* o : matrix to real part of input bands */
+ Word32 **bufferImag, /* o : matrix to imaginary part of input bands */
+ Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */
+ Decoder_State_fx *stdec,
+ Word16 *Q_new,
+ Word16 gen_exc
+ );
+void
+generate_comfort_noise_dec_hf (Word32 **bufferReal, /* o : matrix to real part of input bands */
+ Word32 **bufferImag, /* o : matrix to imaginary part of input bands */
+ Word16 *bufferScale, /* o : pointer to scalefactor for real and imaginary part of input bands */
+ Decoder_State_fx *stdec
+ );
+
+/* Generate the comfort noise based on the target noise level */
+void generate_masking_noise (Word16 *timeDomainBuffer, /* i/o: time-domain signal */
+ Word16 Q,
+ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
+ ,Word16 length
+ ,Word16 core
+ );
+
+void generate_masking_noise_update_seed (
+ HANDLE_FD_CNG_COM st /* i/o : pointer to FD_CNG_COM structure */
+);
+
+void generate_masking_noise_mdct (Word32 *mdctBuffer, /* i/o: time-domain signal */
+ Word16 *mdctBuffer_e, /* i/o: exponent time-domain signal */
+ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
+ ,Word16 L_frame
+ );
+
+/* Apply bitrate-dependant scale */
+void apply_scale(Word32 *scale,
+ Word16 bwmode,
+ Word32 bitrate
+ );
+
+/* Compute the power for each partition */
+void bandcombinepow(Word32* bandpow, /* i : Power for each band */
+ Word16 exp_bandpow, /* i : exponent of bandpow */
+ Word16 nband, /* i : Number of bands */
+ Word16* part, /* i : Partition upper boundaries (band indices starting from 0) */
+ Word16 npart, /* i : Number of partitions */
+ Word16* psize_inv, /* i : Inverse partition sizes */
+ Word32* partpow, /* o : Power for each partition */
+ Word16* exp_partpow
+ );
+
+/* Scale partitions (with smoothing) */
+void scalebands (Word32 *partpow, /* i : Power for each partition */
+ Word16 *part, /* i : Partition upper boundaries (band indices starting from 0) */
+ Word16 npart, /* i : Number of partitions */
+ Word16 *midband, /* i : Central band of each partition */
+ Word16 nFFTpart, /* i : Number of FFT partitions */
+ Word16 nband, /* i : Number of bands */
+ Word32 *bandpow, /* o : Power for each band */
+ Word16 flag_fft_en
+ );
+
+/* Get central band for each partition */
+void getmidbands(Word16* part, /* i : Partition upper boundaries (band indices starting from 0) */
+ Word16 npart, /* i : Number of partitions */
+ Word16* midband, /* o : Central band of each partition */
+ Word16* psize, /* o : Partition sizes */
+ Word16* psize_norm, /* o : Partition sizes, fractional values */
+ Word16* psize_norm_exp, /* o : Exponent for fractional partition sizes */
+ Word16* psize_inv /* o : Inverse of partition sizes */
+ );
+
+/* STFT analysis filterbank */
+void AnalysisSTFT (const Word16 *timeDomainInput, /* i : pointer to time signal */
+ Word16 Q,
+ Word32 *fftBuffer, /* o : FFT bins */
+ Word16 *fftBuffer_exp, /* i : exponent of FFT bins */
+ HANDLE_FD_CNG_COM st /* i/o: FD_CNG structure containing all buffers and variables */
+ );
+
+/* STFT synthesis filterbank */
+void SynthesisSTFT (Word32 *fftBuffer, /* i : pointer to FFT bins */
+ Word16 fftBufferExp, /* i : exponent of FFT bins */
+ Word16 *timeDomainOutput, /* o : pointer to time domain signal */
+ Word16 *olapBuffer, /* i/o : pointer to overlap buffer */
+ const PWord16 *olapWin, /* i : pointer to overlap window */
+ Word16 tcx_transition,
+ HANDLE_FD_CNG_COM st, /* i/o : pointer to FD_CNG structure containing all buffers and variables */
+ Word16 gen_exc,
+ Word16 *Q_new
+ );
+
+/* Compute some calues used in the bias correction of the minimum statistics algorithm */
+void mhvals(Word16 d, Word16 * m/*, float * h*/);
+
+/* Random generator with Gaussian distribution with mean 0 and std 1 */
+Word32 rand_gauss (Word16 *seed);
+
+void lpc_from_spectrum (Word32 *powspec,
+ Word16 powspec_exp,
+ Word16 start,
+ Word16 stop,
+ Word16 fftlen,
+ Word16 *A,
+ Word16 lpcorder,
+ Word16 preemph_fac);
+
+void msvq_decoder(const Word16 *const cb[], /* i : Codebook (indexed cb[*stages][levels][p]) */
+ Word16 stages, /* i : Number of stages */
+ Word16 N, /* i : Vector dimension */
+ Word16 maxN, /* i : Codebook vector dimension */
+ Word16 Idx[], /* i : Indices */
+ Word16 *uq /* o : quantized vector */
+ );
+
+/*fd_cng_dec.h*/
+/* Create an instance of type FD_CNG */
+void createFdCngDec(HANDLE_FD_CNG_DEC* hFdCngDec);
+
+Word16 initFdCngDec(HANDLE_FD_CNG_DEC hFdCngDec, Word16 scale);
+extern void E_LPC_isf_isp_conversion(const Word16 isf[], Word16 isp[], const Word16 m);
+extern void E_LPC_f_isp_a_conversion(const Word16 *isp, Word16 *a, const Word16 m);
+
+/* Delete the instance of type FD_CNG */
+void deleteFdCngDec(HANDLE_FD_CNG_DEC * hFdCngDec);
+
+/* Configure CLDFB-CNG */
+void configureFdCngDec(HANDLE_FD_CNG_DEC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */
+ Word16 bandwidth,
+ Word32 bitrate,
+ Word16 cng_type);
+
+
+/* Apply the CLDFB-based CNG */
+Word16 ApplyFdCng (Word16 * timeDomainInput, /* i : pointer to time domain input */
+ Word16 Q,
+ Word32 ** cldfbBufferReal, /* i/o: real part of the CLDFB buffer */
+ Word32 ** cldfbBufferImag, /* i/o: imaginary part of the CLDFB buffer */
+ Word16 * cldfbBufferScale, /* o : pointer to the scalefactor for real and imaginary part of the CLDFB buffer */
+ HANDLE_FD_CNG_DEC st, /* i/o: pointer to FD_CNG structure containing all buffers and variables */
+ Word16 m_frame_type, /* i : type of frame at the decoder side */
+ Decoder_State_fx *stdec,
+ const Word16 concealWholeFrame, /* i : binary flag indicating frame loss */
+ Word16 is_music
+ );
+
+/* Perform noise estimation */
+void perform_noise_estimation_dec(const Word16 *timeDomainInput, /* i: pointer to time domain input */
+ Word16 Q,
+ HANDLE_FD_CNG_DEC st /* i/o: FD_CNG structure containing all buffers and variables */
+ );
+
+/* Decode the CLDFB-CNG bitstream */
+void FdCng_decodeSID(HANDLE_FD_CNG_COM st, /* i/o: FD_CNG structure containing all buffers and variables */
+ Decoder_State_fx *corest); /* i/o: decoder state structure */
+
+void FdCng_exc(
+ HANDLE_FD_CNG_COM hs,
+ Word16 *CNG_mode,
+ Word16 L_frame,
+ Word16 *lsp_old,
+ Word16 first_CNG,
+ Word16 *lsp_CNG,
+ Word16 *Aq, /* o: LPC coeffs */
+ Word16 *lsp_new, /* o: lsp */
+ Word16 *lsf_new, /* o: lsf */
+ Word16 *exc, /* o: LP excitation */
+ Word16 *exc2, /* o: LP excitation */
+ Word16 *bwe_exc /* o: LP excitation for BWE */
+);
+
+void noisy_speech_detection(
+ const Word16 vad,
+ const Word16 *ftimeInPtr, /* i : input time-domain frame */
+ const Word16 frameSize, /* i : frame size */
+ const Word16 Q,
+ const Word32 *msNoiseEst, /* i : noise estimate over all critical bands */
+ const Word16 msNoiseEst_exp, /* i : exponent for noise estimate over all critical bands */
+ const Word16 *psize_norm,
+ const Word16 psize_norm_exp,
+ const Word16 nFFTpart, /* i : Number of partitions taken into account */
+ Word32 *lp_noise, /* i/o: pointer to long term total Noise energy average */
+ Word32 *lp_speech, /* i/o: pointer to long term active speech energy average */
+ Word16 *flag_noisy_speech
+);
+
+/* Create an instance of type FD_CNG */
+void createFdCngEnc(HANDLE_FD_CNG_ENC* hFdCngEnc);
+
+void initFdCngEnc(HANDLE_FD_CNG_ENC hsEnc, Word32 input_Fs, Word16 scale);
+
+/* Delete the instance of type FD_CNG */
+void deleteFdCngEnc(HANDLE_FD_CNG_ENC * hFdCngEnc);
+
+/* Configure CLDFB-CNG */
+void configureFdCngEnc(HANDLE_FD_CNG_ENC hs, /* i/o: Contains the variables related to the CLDFB-based CNG process */
+ Word16 bandwidth, /* i: bandwidth */
+ Word32 bitrate);
+
+/* Perform noise estimation */
+void perform_noise_estimation_enc(
+ Word32 *band_energies, /* i: energy in critical bands without minimum noise floor MODE2_E_MIN */
+ Word16 exp_band_energies,
+ Word32 *enerBuffer,
+ Word16 enerBuffer_exp,
+ HANDLE_FD_CNG_ENC st); /* i/o: FD_CNG structure containing all buffers and variables */
+
+/* Adjust the noise estimator at the beginning of each CNG phase (encoder-side) */
+Word16
+AdjustFirstSID(Word16 npart,
+ Word32 *msPeriodog,
+ Word16 msPeriodog_exp,
+ Word32 *energy_ho,
+ Word16 *energy_ho_exp,
+ Word32 *msNoiseEst,
+ Word16 *msNoiseEst_exp,
+ Word32 *msNoiseEst_old,
+ Word16 *msNoiseEst_old_exp,
+ Word16 *active_frame_counter,
+ Encoder_State_fx *stcod
+ );
+
+/* Generate a bitstream out of the partition levels */
+void FdCng_encodeSID (HANDLE_FD_CNG_ENC st, /* i/o: FD_CNG structure containing all buffers and variables */
+ Encoder_State_fx *corest,
+ Word16 preemph_fac /* i : preemphase factor */
+ );
+
+/*parameter_bitmaping.h*/
+/** Writes parameters from paramsBitMap into a stream.
+ * @param paramsBitMap Definition of parameters and mappings to a bitstream.
+ * @param nParam Size of paramsBitMap.
+ * @param pParameter A parameter to be used in get and set functions from paramsBitMap.
+ * @param pStream Pointer to a stream where parameters should be stored.
+ * @param pnSize Set to the number of elements written to the stream.
+ * @param pnBits Set to the number of required bits.
+ */
+void GetParameters(ParamsBitMap const * paramsBitMap, Word16 nParams, void const * pParameter, Word16 ** pStream, Word16 * pnSize, Word16 * pnBits);
+
+/** Reads parameters from a stream into paramsBitMap.
+ * @param paramsBitMap Definition of parameters and mappings to a bitstream.
+ * @param nParam Size of paramsBitMap.
+ * @param pParameter A parameter to be used in get and set functions from paramsBitMap.
+ * @param pStream Pointer to a stream from which parameters are read.
+ * @param pnSize Set to the number of elements read from the stream.
+ */
+void SetParameters(ParamsBitMap const * paramsBitMap, Word16 nParams, void * pParameter, Word16 const ** pStream, Word16 * pnSize);
+
+/** Writes parameters from a stream into a bitstream.
+ * @param paramsBitMap Definition of parameters and mappings to a bitstream.
+ * @param nParam Size of paramsBitMap.
+ * @param pStream Pointer to a stream from which parameters are read.
+ * @param pnSize Set to the number of elements read from the stream.
+ * @param st Encoder state.
+ * @param pnBits Set to the number of bits written.
+ */
+void WriteToBitstream(ParamsBitMap const * paramsBitMap, Word16 nParams, Word16 const ** pStream, Word16 * pnSize, Encoder_State_fx *st, Word16 * pnBits);
+
+/** Reads parameters from a bitstream into a stream.
+ * @param paramsBitMap Definition of parameters and mappings to a bitstream.
+ * @param nArrayLength Size of paramsBitMap.
+ * @param st Decoder state.
+ * @param pStream Pointer to a stream where parameters should be stored.
+ * @param pnSize Set to the number of elements written to the stream.
+ */
+void ReadFromBitstream(ParamsBitMap const * paramsBitMap, Word16 nArrayLength, Decoder_State_fx *st, Word16 ** pStream, Word16 * pnSize);
+
+void const * GetTnsFilterOrder(void const * p, Word16 index, Word16 * pValue);
+void * SetTnsFilterOrder(void * p, Word16 index, Word16 value);
+void const * GetNumOfTnsFilters(void const * p, Word16 index, Word16 * pValue);
+void * SetNumOfTnsFilters(void * p, Word16 index, Word16 value);
+void const * GetTnsEnabled(void const * p, Word16 index, Word16 * pValue);
+void * SetTnsEnabled(void * p, Word16 index, Word16 value);
+void const * GetTnsEnabledSingleFilter(void const * p, Word16 index, Word16 * pValue);
+void * SetTnsEnabledSingleFilter(void * p, Word16 index, Word16 value);
+void const * GetTnsFilterCoeff(void const * p, Word16 index, Word16 * pValue);
+void * SetTnsFilterCoeff(void * p, Word16 index, Word16 value);
+
+
+Word16 GetSWBTCX10TnsFilterCoeffBits(Word16 value, Word16 index);
+Word16 EncodeSWBTCX10TnsFilterCoeff(Word16 value, Word16 index);
+Word16 DecodeSWBTCX10TnsFilterCoeff(Decoder_State_fx *st, Word16 index, Word16 * pValue);
+Word16 GetSWBTCX20TnsFilterCoeffBits(Word16 value, Word16 index);
+Word16 EncodeSWBTCX20TnsFilterCoeff(Word16 value, Word16 index);
+Word16 DecodeSWBTCX20TnsFilterCoeff(Decoder_State_fx *st, Word16 index, Word16 * pValue);
+
+Word16 GetWBTCX20TnsFilterCoeffBits(Word16 value, Word16 index);
+Word16 EncodeWBTCX20TnsFilterCoeff(Word16 value, Word16 index);
+Word16 DecodeWBTCX20TnsFilterCoeff(Decoder_State_fx *st, Word16 index, Word16 * pValue);
+
+Word16 GetTnsFilterOrderBitsSWBTCX10(Word16 value, Word16 index);
+Word16 EncodeTnsFilterOrderSWBTCX10(Word16 value, Word16 index);
+Word16 DecodeTnsFilterOrderSWBTCX10(Decoder_State_fx *st, Word16 index, Word16 * pValue);
+Word16 GetTnsFilterOrderBitsSWBTCX20(Word16 value, Word16 index);
+Word16 EncodeTnsFilterOrderSWBTCX20(Word16 value, Word16 index);
+Word16 DecodeTnsFilterOrderSWBTCX20(Decoder_State_fx *st, Word16 index, Word16 * pValue);
+Word16 GetTnsFilterOrderBits(Word16 value, Word16 index);
+Word16 EncodeTnsFilterOrder(Word16 value, Word16 index);
+Word16 DecodeTnsFilterOrder(Decoder_State_fx *st, Word16 index, Word16 * pValue);
+
+
+/*tns_base.h*/
+/** Reset TNS data.
+ * Resets TNS data to the initial state.
+ * @param pTnsData pointer to a TNS data to be reset.
+ */
+void ResetTnsData(STnsData * pTnsData);
+
+/** Clear TNS filter data.
+ * Resets TNS filter order and all coefficients to 0.
+ * @param pTnsFilter pointer to a TNS filter to be cleared.
+ */
+void ClearTnsFilterCoefficients(STnsFilter * pTnsFilter);
+
+/** Init TNS configuration.
+ * Fills STnsConfig structure with sensible content.
+ * @param nSampleRate Sampling rate of the input.
+ * @param nFrameLength Frame length.
+ * @param pTnsConfig TNS configuration to be initialized.
+ * @return 0 on success, otherwise 1.
+ */
+Word16 InitTnsConfiguration(Word32 nSampleRate,
+ Word16 frameLength,
+ STnsConfig * pTnsConfig
+ ,Word16 igfStopFreq
+ ,Word32 bitrate
+ );
+
+/** Detect TNS parameters.
+ * Detects if TNS should be used and fills TNS data in pTnsData.
+ * @param pTnsConfig TNS configuration.
+ * @param pSpectrum Spectrum lines.
+ TNS is tested on the spectrum defined by pSpectrum.
+ * @param sbCnt Number of active subbands.
+ * @param pTnsData TNS data is filled with sensible information.
+ * @return Returns 1 if Tns should be used, otherwise 0.
+ */
+Word16 DetectTnsFilt(STnsConfig const * pTnsConfig,
+ Word32 const pSpectrum[],
+ STnsData * pTnsData,
+ Word16 *predictionGain);
+
+/** Modify spectrum using TNS filter.
+ * Modifies spectrum unsing TNS filter defined by pTnsData.
+ * If fIsAnalyses is true considers spectrum to be
+ * an input of encoder and returns residum.
+ * If fIsAnalyses is false considers spectrum to be
+ * a residum from decoder and returns output spectrum.
+ * @param pTnsConfig TNS configuration.
+ * @param pTnsData TNS data describing filters.
+ * @param spectrum Input/output spectrum.
+ * @param fIsAnalysis Defines if TNS filter is applied
+ * in encoder (TRUE) or in decoder (FALSE).
+ * @return 0 on success, otherwise 1.
+ */
+Word16 ApplyTnsFilter(STnsConfig const * pTnsConfig,
+ STnsData const * pTnsData,
+ Word32 spectrum[],
+ Word8 fIsAnalysis);
+
+Word16 ITF_Detect_fx(Word32 const pSpectrum[],
+ Word16 startLine,
+ Word16 stopLine,
+ Word16 maxOrder,
+ Word16* A,
+ Word16* Q_A,
+ Word16* predictionGain,
+ Word16* curr_order,
+ Word16 Q);
+
+TNS_ERROR ITF_Apply_fx(Word32 spectrum[],
+ Word16 startLine, Word16 stopLine, const Word16* A,
+ Word16 Q_A,
+ Word16 curr_order);
+
+/** Write TNS data into a stream of integers.
+ * Writes TNS data into a stream of integers.
+ * @param pTnsConfig TNS configuration.
+ * @param pTnsData TNS data to be written to a bitstream.
+ * @param stream Output stream of integers.
+ * @param pnSize Set to the number of elements written to the stream.
+ * @param pnBits Set to the number of required.
+ * @return 0 on success, otherwise 1.
+ */
+Word16 EncodeTnsData(STnsConfig const * pTnsConfig,
+ STnsData const * pTnsData,
+ Word16 * stream,
+ Word16 * pnSize,
+ Word16 * pnBits);
+
+/** Read TNS data from a stream of integers.
+ * Reads TNS data from a stream of integers.
+ * @param pTnsConfig TNS configuration.
+ * @param stream Input stream of integers.
+ * @param pnSize Set to the number of elements read from stream.
+ * @param pTnsData TNS data to be read from the bitstream.
+ * @return 1 if TNS is active, otherwise 0.
+ */
+Word16 DecodeTnsData(STnsConfig const * pTnsConfig,
+ Word16 const * stream,
+ Word16 * pnSize,
+ STnsData * pTnsData);
+
+/** Write TNS data into a bitstream.
+ * Writes TNS data into a bitstream.
+ * @param pTnsConfig TNS configuration.
+ * @param stream Contains TNS data written with EncodeTnsData.
+ * @param pnSize Set to the number of used elements from stream.
+ * @param st Encoder state.
+ * @param pnBits Set to the number of bits written.
+ * @return 0 on success, otherwise 1.
+ */
+Word16 WriteTnsData(STnsConfig const * pTnsConfig,
+ Word16 const * stream,
+ Word16 * pnSize,
+ Encoder_State_fx *st,
+ Word16 * pnBits);
+
+/** Read TNS data from a bitstream.
+ * Reads TNS data from a bitstream using bin2int.
+ * @param pTnsConfig TNS configuration.
+ * @param st Decoder state.
+ * @param pnBits Set to the number of bits written.
+ * @param stream Contains TNS data that can be decoded with DecodeTnsData.
+ * @param pnSize Set to the number of used elements from stream.
+ * @return 0 on success, otherwise 1.
+ */
+Word16 ReadTnsData(STnsConfig const * pTnsConfig,
+ Decoder_State_fx *st,
+ Word16 * pnBits,
+ Word16 * stream,
+ Word16 * pnSize);
+
+Word16
+CLDFB_getNumChannels(Word32 sampleRate);
+
+void
+cldfbAnalysisFiltering( HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Analysis Bank */
+ Word32 **cldfbReal, /*!< Pointer to real subband slots */
+ Word32 **cldfbImag, /*!< Pointer to imag subband slots */
+ CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */
+ const Word16 *timeIn, /*!< Time signal */
+ const Word16 timeIn_e, /*!< Time signal */
+ const Word16 nTimeSlots, /*!< Time slots to be processed */
+ Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
+ );
+
+void
+cldfbSynthesisFiltering(HANDLE_CLDFB_FILTER_BANK synCldfb, /*!< Handle of Cldfb Synthesis Bank */
+ Word32 **CldfbBufferReal, /*!< Pointer to 32 bit real subband slots */
+ Word32 **CldfbBufferImag, /*!< Pointer to 32 bit imag subband slots */
+ const CLDFB_SCALE_FACTOR *scaleFactor, /*!< Scale factors of CLDFB data */
+ Word16 *timeOut, /*!< Time signal */
+ const Word16 timeOut_e, /*!< Target exponent for output signal */
+ const Word16 nTimeSlots, /*!< number of time slots to be processed */
+ Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
+ );
+
+Word16
+cldfbInitAnalysisFilterBank(HANDLE_CLDFB_FILTER_BANK h_Cldfb, /*!< CLDFB Handle */
+ Word16 *pFilterStates, /*!< Pointer to filter state buffer */
+ Word16 frameSize, /*!< FrameSize */
+ Word16 lsb, /*!< Number of lower bands */
+ Word16 usb, /*!< Number of upper bands */
+ Word16 no_channels, /*!< Number of critically sampled bands */
+ UWord16 flags /*!< Flags */
+ );
+
+void
+cldfbAnalysisFilteringSlot(HANDLE_CLDFB_FILTER_BANK anaCldfb, /*!< Handle of Cldfb Synthesis Bank */
+ Word32 *cldfbReal, /*!< Low and High band, real */
+ Word32 *cldfbImag, /*!< Low and High band, imag */
+ Word32 *pWorkBuffer /*!< pointer to temporal working buffer */
+ );
+
+Word16
+cldfbInitSynthesisFilterBank(HANDLE_CLDFB_FILTER_BANK h_Cldfb, /*!< CLDFB Handle */
+ Word16 *pFilterStates, /*!< Pointer to filter state buffer */
+ Word16 noCols, /*!< Number of time slots */
+ Word16 lsb, /*!< Number of lower bands */
+ Word16 usb, /*!< Number of upper bands */
+ Word16 no_channels, /*!< Number of critically sampled bands */
+ UWord16 flags /*!< Flags */
+ );
+
+void cldfbSynthesisFilteringSlot(HANDLE_CLDFB_FILTER_BANK synCldfb,
+ const Word32 *realSlot,
+ const Word32 *imagSlot,
+ const Word16 scaleFactorLowBand,
+ const Word16 scaleFactorHighBand,
+ Word16 *timeOut,
+ const Word16 stride,
+ Word32 *pWorkBuffer
+ );
+
+
+void configureCldfb ( HANDLE_CLDFB_FILTER_BANK h_cldfb, /*!< CLDFB Handle */
+ const Word16 no_channels, /*!< Number of critically sampled bands */
+ const Word16 frameSize /*!< FrameSize */
+ );
+
+void openCldfb ( HANDLE_CLDFB_FILTER_BANK *h_cldfb, /*!< CLDFB Handle */
+ const Word16 type, /*!< analysis or synthesis */
+ const Word16 maxCldfbBands, /*!< number of cldfb bands */
+ const Word16 frameSize /*!< FrameSize */
+ );
+
+void resampleCldfb (
+ HANDLE_CLDFB_FILTER_BANK hs, /*!< CLDFB Handle */
+ const Word16 newCldfbBands, /*!< number of cldfb bands */
+ const Word16 frameSize, /*!< FrameSize */
+ const Word8 firstFrame
+);
+
+void
+deleteCldfb (HANDLE_CLDFB_FILTER_BANK * h_cldfb); /*!< CLDFB Handle */
+
+Word16
+CreateCldfbAnalysisFilterBank (HANDLE_CLDFB_FILTER_BANK *hAnalysisCldfb,
+ const Word16 maxCldfbBands,
+ const Word16 frameSize,
+ UWord16 flags
+ );
+
+Word16
+DestroyCldfbAnalysisFilterBank (HANDLE_CLDFB_FILTER_BANK *hAnalysisCldfb
+ );
+
+Word16
+CreateCldfbSynthesisFilterBank (HANDLE_CLDFB_FILTER_BANK *hSynthesisCldfb,
+ const Word16 maxCldfbBands,
+ const Word16 frameSize,
+ UWord16 flags
+ );
+
+Word16
+DestroyCldfbSynthesisFilterBank (HANDLE_CLDFB_FILTER_BANK *hSynthesisCldfb
+ );
+
+Word16
+ResampleCldfbAnalysisFilterBank (HANDLE_CLDFB_FILTER_BANK hs,
+ const Word16 newCldfbBands,
+ Word16 newFrameSize,
+ UWord16 flags,
+ Word8 firstFrame
+ );
+
+
+
+Word16
+AnalysisPostSpectrumScaling_Fx (HANDLE_CLDFB_FILTER_BANK cldfbBank,
+ Word32 **rSubband32,
+ Word32 **iSubband32,
+ Word16 **rSubband16,
+ Word16 **iSubband16,
+ Word16 *cldfbScale
+ );
+
+void
+GetEnergyFromCplxCldfbData_Fx(Word32 **energyValues,
+ Word32 *energyLookahead,
+ Word16 *sf_energyLookahead,
+ const Word16 numLookahead,
+ Word16 **realValues,
+ Word16 **imagValues,
+ Word16 sf_Values,
+ Word16 numberBands,
+ Word16 numberCols,
+ Word32 *energyHF,
+ Word16 *energyHF_Exp
+ );
+
+void
+GetEnergyCldfb( Word32 *energyLookahead, /*!< o: Q31 | pointer to the result in the core look-ahead slot */
+ Word16 *sf_energyLookahead, /*!< o: pointer to the scalefactor of the result in the core look-ahead slot - apply as negative exponent*/
+ const Word16 numLookahead, /*!< i: Q0 the number of look-ahead time-slots */
+ Word16 **realValues, /*!< i: Q15 | the real part of the CLDFB subsamples */
+ Word16 **imagValues, /*!< i: Q15 | the imaginary part of the CLDFB subsamples */
+ Word16 sf_Values, /*!< i: scalefactor of the CLDFB subcamples - apply as a negated Exponent */
+ Word16 numberBands, /*!< i: Q0 | number of CLDFB bands */
+ Word16 numberCols, /*!< i: Q0 | number of CLDFB subsamples */
+ Word32 *energyHF, /*!< o: Q31 | pointer to HF energy */
+ Word16 *energyHF_Exp, /*!< o: pointer to exponent of HF energy */
+ Word32 *energyValuesSum, /*!< o: Q31 | pointer to sum array of energy values, not initialized*/
+ Word16 *energyValuesSum_Exp /*!< o: pointer to exponents of energyValuesSum, not initialized */
+ , HANDLE_TEC_ENC_FX hTecEnc
+ );
+
+/*bits_alloc.h*/
+Word16 BITS_ALLOC_get_rate_mode(
+ const Word16 frame_size_index /*i: frame_size_index*/
+);
+
+void BITS_ALLOC_init_config_acelp(
+ const Word32 bit_rate,
+ const Word8 narrowBand,
+ const Word16 nb_subfr,
+ ACELP_config *pConfigAcelp /*o: configuration structure of ACELP*/
+);
+
+Word16 BITS_ALLOC_config_acelp(
+ const Word16 bits_frame, /*i: remaining bit budget for the frame */
+ const Word16 coder_type, /*i: coder type */
+ ACELP_config *pConfigAcelp, /*i/o: configuration structure of ACELP*/
+ const Word16 narrowband,
+ const Word16 nb_subfr
+);
+
+void BITS_ALLOC_ACELP_config_rf(const Word16 coder_type,
+ Word16 *tilt_code,
+ Word16 *rf_frame_type,
+ Word16 *rf_target_bits,
+ Word16 nb_subfr
+ , Word16 rf_fec_indicator
+ , Word16 *pitch_buf
+ );
+void BITS_ALLOC_TCX_config_rf(
+ Word16 *rf_frame_type,
+ Word16 *rf_target_bits,
+ Word16 PLC_Mode,
+ Word16 coder_type,
+ Word16 last_core,
+ Word16 TD_mode
+);
+
+Word16 BITS_ALLOC_adjust_acelp_fixed_cdk(
+ const Word16 bits_frame, /*i: bit budget */
+ Word16 *fixed_cdk_index, /*o: codebook index */
+ const Word16 nb_subfr /*i: number of subframes*/
+);
+
+
+
+Word16 BITS_ALLOC_adjust_acelp_fixed_16KHZ_cdk(
+ const Word16 bits_frame, /*i: bit budget */
+ Word16 *fixed_cdk_index, /*o: codebook index */
+ const Word16 nb_subfr /*i: number of subframes*/
+);
+
+/*transient_detection.h*/
+/** Init transient detection.
+ * Fills TransientDetection structure with sensible content.
+ * @param nFrameLength Frame length.
+ * @param nTCXDelay Delay for the TCX Long/Short transient detector.
+ * Don't include the delay of the MDCT overlap.
+ * @param pTransientDetection Structure to be initialized. It contains all transient detectors to be used.
+ */
+void InitTransientDetection(Word16 nFrameLength,
+ Word16 nTCXDelay,
+ struct TransientDetection * pTransientDetection);
+
+/** Runs transient detection.
+ * Runs all transient detectors defined in pTransientDetection
+ * and calculates mean zero crossing.
+ * @param input New input samples.
+ * @param nSamplesAvailable Number of new input samples available.
+ * @param pTransientDetection Structure that contains transient detectors to be run.
+ */
+void RunTransientDetection(Word16 const * input, Word16 nSamplesAvailable, struct TransientDetection * pTransientDetection);
+
+
+/** Get the average temporal flatness measure using subblock energies aligned with the TCX.
+ * @param pTransientDetection Structure that contains transient detectors to be run.
+ * @param nCurrentSubblocks Number of the subblocks from the current frame to use for the calculation.
+ A lookeahead can also be use if it exists.
+ * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation.
+ * @return average temporal flatness measure with exponent AVG_FLAT_E
+ */
+Word16 GetTCXAvgTemporalFlatnessMeasure(struct TransientDetection const * pTransientDetection, Word16 nCurrentSubblocks, Word16 nPrevSubblocks);
+
+
+/** Get the maximum energy change using subblock energies aligned with the TCX.
+ * @param pTransientDetection Structure that contains transient detectors to be run.
+ * @param nCurrentSubblocks Number of the subblocks from the current frame to use for the calculation.
+ A lookeahead can also be use if it exists.
+ * @param nPrevSubblocks Number of subblocks from the previous frames to use for the calculation.
+ * @param maximum energy change with exponent NRG_CHANGE_E
+ */
+Word16 GetTCXMaxenergyChange(struct TransientDetection const * pTransientDetection,
+ const Word8 isTCX10,
+ const Word16 nCurrentSubblocks, const Word16 nPrevSubblocks);
+
+/** Set TCX window length and overlap configuration
+ * @param prevEnergyHF previous HF energy. Exponent must be the same as for currEnergyHF.
+ * @param currEnergyHF current HF energy. Exponent must be the same as for prevEnergyHF.
+ */
+void SetTCXModeInfo(Encoder_State_fx *st,
+ struct TransientDetection const * pTransientDetection,
+ Word16 * tcxModeOverlap);
+
+/* Tonal Concealment */
+
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Init( TonalMDCTConcealPtr self,
+ Word16 nSamples,
+ Word16 nSamplesCore,
+ Word16 nScaleFactors,
+ TCX_config * tcx_cfg
+ );
+
+
+/* Must be called only when a good frame is recieved - concealment is inactive */
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_SaveFreqSignal( TonalMDCTConcealPtr self,
+ Word32 const *mdctSpectrum,
+ Word16 const mdctSpectrum_exp,
+ Word16 nNewSamples,
+ Word16 nNewSamplesCore,
+ Word16 const *scaleFactors,
+ Word16 const *scaleFactors_exp,
+ Word16 const gain_tcx_exp
+ );
+
+/* The call to TonalMDCTConceal_UpdateState() should be called after TonalMDCTConceal_Apply. */
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_UpdateState(TonalMDCTConcealPtr self,
+ Word16 nNewSamples,
+ Word32 pitchLag,
+ Word16 badBlock,
+ Word8 tonalConcealmentActive
+ );
+
+/* The call to TonalMDCTConceal_SaveTimeSignal() should be at the
+ * place where the TD signal corresponds to the FD signal stored with TonalMDCTConceal_SaveFreqSignal. */
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_SaveTimeSignal( TonalMDCTConcealPtr self,
+ Word16 *timeSignal,
+ Word16 numSamples
+ );
+
+/* Calculates MDST, power spectrum and performs peak detection.
+ * Uses the TD signal in pastTimeSignal; if pastTimeSignal is NULL, uses the
+ * TD signal stored using TonalMDCTConceal_SaveTimeSignal. If the
+ * second last frame was also lost, it is expected that pastTimeSignal
+ * could hold a signal somewhat different from the one stored in
+ * TonalMDCTConceal_SaveTimeSignal (e.g. including fade-out).*/
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Detect( TonalMDCTConcealPtr const self, /*IN */
+ Word32 const pitchLag, /*IN */
+ Word16 * const umIndices /*OUT*/
+ );
+
+/* Conceals the lost frame using the FD signal previously stored using
+ * TonalMDCTConceal_SaveFreqSignal. Stores the concealed harmonic part of
+ * the signal in mdctSpectrum, the rest of the spectrum is unchanged. */
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_Apply( TonalMDCTConcealPtr self, /*IN */
+ Word32 * mdctSpectrum, /*OUT*/
+ Word16 * mdctSpectrum_exp /*OUT*/
+ );
+
+/* Conceals the lost frame using the FD signal previously stored using
+ * TonalMDCTConceal_SaveFreqSignal. Stores the concealed noise part of
+ * the signal in mdctSpectrum, the rest of the spectrum is unchanged. */
+TONALMDCTCONCEAL_ERROR TonalMDCTConceal_InsertNoise( TonalMDCTConcealPtr self, /*IN */
+ Word32* mdctSpectrum, /*OUT*/
+ Word16* mdctSpectrum_exp, /*OUT*/
+ Word8 tonalConcealmentActive,
+ Word16* pSeed, /*IN/OUT*/
+ Word16 tiltCompFactor,
+ Word16 crossfadeGain,
+ Word16 crossOverFreq);
+
+/* Detect tonal components in the lastMDCTSpectrum, use
+ * secondLastPowerSpectrum for the precise location of the peaks and
+ * store them in indexOfTonalPeak. Updates lowerIndex, upperIndex,
+ * pNumIndexes accordingly. */
+void DetectTonalComponents(Word16 indexOfTonalPeak[], /* OUT */
+ Word16 lowerIndex[], /* OUT */
+ Word16 upperIndex[], /* OUT */
+ Word16 * pNumIndexes, /* OUT */
+ Word32 lastPitchLag, Word32 currentPitchLag, /* IN */
+ Word16 const lastMDCTSpectrum[], /* IN */
+ Word16 lastMDCTSpectrum_exp, /* IN */
+ Word16 const scaleFactors[], /* IN */
+ Word16 const scaleFactors_exp[], /* IN */
+ Word16 const scaleFactors_max_e, /* IN */
+ Word32 const secondLastPowerSpectrum[], /* IN */
+ Word16 nSamples /* IN */
+ ,Word16 nSamplesCore
+ ,Word16 floorPowerSpectrum /* IN */
+ );
+
+/* When called, the tonal components are already stored in
+ * indexOfTonalPeak. Detect tonal components in the lastMDCTSpectrum,
+ * use secondLastPowerSpectrum for the precise location of the peaks and
+ * then keep in indexOfTonalPeak only the tonal components that are
+ * again detected Updates indexOfTonalPeak, lowerIndex, upperIndex,
+ * phaseDiff, phases, pNumIndexes accordingly. */
+void RefineTonalComponents(Word16 indexOfTonalPeak[], /* OUT */
+ Word16 lowerIndex[], /* OUT */
+ Word16 upperIndex[], /* OUT */
+ Word16 phaseDiff[], /* OUT */
+ Word16 phases[], /* OUT */
+ Word16 * pNumIndexes, /* OUT */
+ Word32 lastPitchLag, /* IN */
+ Word32 currentPitchLag, /* IN */
+ Word16 const lastMDCTSpectrum[], /* IN */
+ Word16 const lastMDCTSpectrum_exp, /* IN */
+ Word16 const scaleFactors[], /* IN */
+ Word16 const scaleFactors_exp[], /* IN */
+ Word16 const scaleFactors_max_e, /* IN */
+ Word32 const secondLastPowerSpectrum[], /* IN */
+ Word16 nSamples /* IN */
+ ,Word16 nSamplesCore
+ ,Word16 floorPowerSpectrum /* IN */
+ );
+
+void set_state(Word16 *state, Word16 num, Word16 N);
+void concealment_init_x(Word16 N, void *_plcInfo);
+void concealment_update_x(Word16 bfi, Word16 curr_mode, Word16 harmonic, Word32 *invkoef, Word16 *invkoef_scale, void *_plcInfo);
+
+void waveform_adj2_fix( Word16 *overlapbuf,
+ Word16 *outx_new,
+ Word16 *data_noise,
+ Word16 *outx_new_n1,
+ Word16 *nsapp_gain,
+ Word16 *nsapp_gain_n,
+ Word16 *recovery_gain,
+ Word16 step_concealgain,
+ Word16 pitch,
+ Word16 Framesize,
+ Word16 delay,
+ Word16 bfi_cnt,
+ Word16 bfi
+ );
+
+Word16 ffr_getSfWord16(Word16 *vector, /*!< Pointer to input vector */
+ Word16 len); /*!< Length of input vector */
+
+void concealment_decode_fix(Word16 curr_mode, Word32 *invkoef, Word16 *invkoef_scale,void *_plcInfo);
+
+void concealment_signal_tuning_fx(Word16 bfi,
+ Word16 curr_mode,
+ Word16 *outx_new_fx,
+ void *_plcInfo,
+ Word16 nbLostCmpt,
+ Word16 pre_bfi,
+ Word16 *OverlapBuf_fx,
+ Word16 past_core_mode,
+ Word16 *outdata2_fx,
+ Decoder_State_fx *st);
+
+Word16 Spl_GetScalingSquare_x(Word16 *in_vector, Word16 in_vector_length, Word16 times);
+Word32 Spl_Energy_x(Word16* vector, Word16 vector_length, Word16* scale_factor);
+void Log10OfEnergy_x(Word16 *s, Word32 *enerlogval, Word16 len);
+void concealment_update2_x(Word16 *outx_new, void *_plcInfo, Word16 FrameSize);
+Word16 Sqrt_x_fast(Word32 value);
+
+Word32 dot_w32_accuracy_x(Word16 *s1, Word16 *s2, Word16 nbits, Word16 N);
+
+Word16 int_div_s_x(Word16 a, Word16 b);
+
+Word16 GetW32Norm_x(Word32 *s, Word16 N);
+
+Word16 harmo_x(Word32 *X, Word16 Framesize, Word16 pitch);
+
+
+void LpFilter2_x(Word16 *x, Word16 *y, Word16 N);
+
+void sig_tilt_x(Word16 *s, Word16 FrameSize, Word32 *enr1, Word32 *enr2) ;
+
+void get_maxConv_and_pitch_x(Word16 *s_LP, Word16 s, Word16 e, Word16 N,
+ Word32 *maxConv, Word16 *maxConv_bits, Word16 *pitch);
+
+Word16 get_voicing_x(Word16 *s_LP, Word16 pitch, Word32 covMax,Word16 maxConv_bits, Word16 Framesize);
+
+void pitch_modify_x(Word16 *s_LP, Word16 *voicing, Word16 *pitch, Word16 FrameSize);
+
+Word16 Is_Periodic_x(Word32 *mdct_data, Word16 cov_max, Word16 zp, Word32 ener,
+ Word32 ener_mean, Word16 pitch, Word16 Framesize);
+
+Word16 get_conv_relation_x(Word16 *s_LP, Word16 shift, Word16 N);
+
+
+
+/* 14Q1*1.28 */
+#define LSF_GAP_VAL(x) (Word16)((x)*2.0f*1.28f)
+
+/*longarith.h*/
+
+/**
+ * \brief inplace long shift right: a[] = a[] >> bits
+ * Logical shift right of UWord32 vector a[] by 'bits' positions.
+ */
+
+void longshr (UWord32 a[], Word16 bits, Word16 len);
+
+
+/*qlpc_avq.h*/
+void lsf_weight_2st(const Word16 *lsfq, /* input: quantized lsf coefficients (3Q12) */
+ Word16 *w, /* output: weighting function (0Q15) */
+ const Word16 mode /* input: operational mode */
+ );
+
+
+
+void qlpc_avq(
+ const Word16 *lsf, /* (i) Input LSF vectors */
+ const Word16 *lsfmid, /* (i) Input LSF vectors */
+ Word16 *lsf_q, /* (o) Quantized LFS vectors */
+ Word16 *lsfmid_q, /* (o) Quantized LFS vectors */
+ Word16 *index, /* (o) Quantization indices */
+ Word16 *nb_indices, /* (o) Number of quantization indices */
+ Word16 *nbbits, /* (o) Number of quantization bits */
+ const Word16 core, /* (i) TCX10 or TCX20 */
+ Word32 sr_core
+);
+
+Word16 encode_lpc_avq( Encoder_State_fx *st, Word16 numlpc, Word16 *param_lpc, Word16 mode );
+
+Word16 dlpc_avq(
+ Word16 *index, /* (i) Quantization indices */
+ Word16 *LSF_Q, /* (o) Quantized LSF vectors */
+ Word16 numlpc, /* (i) Number of sets of lpc */
+ Word32 sr_core
+);
+
+Word16 decode_lpc_avq( Decoder_State_fx *st, Word16 numlpc, Word16 *param_lpc );
+
+Word16 vlpc_1st_cod(const Word16 *lsf, /* input: vector to quantize */
+ Word16 *lsfq /* i/o: i:prediction o:quantized lsf */
+ ,Word16 *wout /* o: lsf weights */
+ ,Word16 rf_mode
+ );
+
+Word16 vlpc_2st_cod( /* output: number of allocated bits */
+ const Word16 *lsf, /* input: normalized vector to quantize (3Q12) */
+ Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage (3Q12) */
+ Word16 *indx, /* output: index[] (4 bits per words) */
+ Word16 mode, /* input: 0=abs, >0=rel */
+ Word32 sr_core
+);
+
+void vlpc_2st_dec(
+ Word16 *lsfq, /* i/o: i:1st stage o:1st+2nd stage */
+ Word16 *indx, /* input: index[] (4 bits per words) */
+ Word16 mode, /* input: 0=abs, >0=rel */
+ Word32 sr_core);
+
+void open_decoder_LPD(
+ Decoder_State_fx *st,
+ Word32 bitrate,
+ Word16 bandwidth
+);
+
+
+void update_decoder_LPD_cng(
+ Decoder_State_fx *st,
+ Word16 coder_type,
+ Word16 *timeDomainBuffer,
+ Word16 *A,
+ Word16 *bpf_noise_buf
+);
+
+void reconfig_decoder_LPD( Decoder_State_fx *st, Word16 bits_frame, Word16 bandwidth_mode, Word32 bitrate, Word16 L_frame_old);
+
+void mode_switch_decoder_LPD( Decoder_State_fx *st, Word16 bandwidth_in, Word32 bitrate, Word16 frame_size_index
+ );
+
+void decoder_LPD(
+ Word16 signal_out[], /* output: signal with LPD delay (7 subfrs) */
+ Word16 signal_outFB[],
+ Word16 *total_nbbits, /* i/o: number of bits / decoded bits */
+ Decoder_State_fx *st , /* i/o: decoder memory state pointer */
+ Word16 *bpf_noise_buf,
+ Word16 bfi,
+ Word16 *bitsRead,
+ Word16 *coder_type,
+ Word16 param[],
+ Word16 *pitch_buf,
+ Word16 *voice_factors,
+ Word16 *ptr_bwe_exc
+);
+
+Word16 dec_acelp_tcx_frame(
+ Decoder_State_fx *st,
+ Word16 *coder_type,
+ Word16 *concealWholeFrame,
+ Word16 *pcmBuf,
+ Word16 * bpf_noise_buf,
+ Word16 * pcmbufFB,
+ Word32 bwe_exc_extended[],
+ Word16 *voice_factors,
+ Word16 pitch_buf[]
+);
+
+
+Word16 tcxGetNoiseFillingTilt(Word16 A[],
+ Word16 lpcorder,
+ Word16 L_frame,
+ Word16 mode,
+ Word16 *noiseTiltFactor
+ );
+
+
+void tcxFormantEnhancement(
+ Word16 xn_buf[],
+ Word16 gainlpc[], Word16 gainlpc_e[],
+ Word32 spectrum[], Word16 *spectrum_e,
+ Word16 L_frame
+ ,Word16 L_frameTCX
+);
+
+
+void tcxInvertWindowGrouping(TCX_config *tcx_cfg,
+ Word32 xn_buf[],
+ Word32 spectrum[],
+ Word16 L_frame,
+ Word8 fUseTns,
+ Word16 last_core,
+ Word16 index,
+ Word16 frame_cnt,
+ Word16 bfi);
+
+/*lerp.h*/
+
+void lerp(Word16 *f, Word16 *f_out, Word16 bufferNewSize, Word16 bufferOldSize);
+
+void attenuateNbSpectrum(Word16 L_frame, Word32 *spectrum);
+
+Word8 getTcxonly(const Word32 bitrate);
+Word8 getCtxHm(const Word32 bitrate, const Word16 rf_flag);
+Word8 getResq(const Word32 bitrate);
+
+Word8 getTnsAllowed(const Word32 bitrate
+ ,const Word16 igf
+ );
+
+Word8 getRestrictedMode(const Word32 bitrate, const Word16 Opt_AMR_WB);
+
+Word16 sr2fscale(const Word32 sr);
+
+Word32 getCoreSamplerateMode2(const Word32 bitrate, const Word16 bandwidth, const Word16 rf_flag);
+Word16 getTcxBandwidth(const Word16 bandwidth);
+
+Word8 getIgfPresent(
+ const Word32 bitrate,
+ const Word16 bandwidth
+ , const Word16 rf_mode
+);
+
+Word8 getCnaPresent(
+ const Word32 bitrate,
+ const Word16 bandwidth
+);
+
+Word8 getTcxLtp(
+ const Word32 sr_core
+);
+
+Word16 initPitchLagParameters(
+ const Word32 sr_core,
+ Word16 *pit_min,
+ Word16 *pit_fr1,
+ Word16 *pit_fr1b,
+ Word16 *pit_fr2,
+ Word16 *pit_max
+);
+
+Word16 getNumTcxCodedLines(const Word16 bwidth);
+
+Word16 getTcxLpcShapedAri(
+ const Word32 total_brate,
+ const Word16 bwidth
+ ,const Word16 rf_mode
+);
+
+
+Word16 vad_init(T_CldfbVadState *vad_state);
+
+void subband_FFT(
+ Word32 ** Sr, /*(i) real part of the CLDFB*/
+ Word32 ** Si, /*(i) imag part of the CLDFB*/
+ Word32 *spec_amp, /*(o) spectral amplitude*/
+ Word32 Offset, /*(i) offset of the CLDFB*/
+ Word16 *fftoQ /*(o) the Scaling */
+);
+
+void UpdateState( T_CldfbVadState *vad_state,
+ Word16 vad_flag,
+ Word32 frame_energy, /*(i) current frame energy*/
+ Word16 sacle_sbpower, /*(i) the Scaling of current frame energy*/
+ Word32 update_flag, /*(i) current frame update flag*/
+ Word16 music_backgound_f, /*(i) backgound music flag*/
+ Word32 HB_Power, /*(i) current frame high frequency energy*/
+ Word16 HB_Power_Q /*(i) the Scaling of current frame high frequency energy*/
+ ,Word32 snr
+ );
+
+void calc_snr_flux( Word32 tsnr_fix, /*(i) time-domain SNR*/
+ Word32 *pre_snr, /*(io)time-domain SNR storage*/
+ Word32 *snr_flux /*(o) average tsnr*/
+ );
+
+Word16 update_decision(
+ T_CldfbVadState *st,
+ Word32 frame_energy, /*(i) current frame energy*/
+ Word32 HB_Power, /*(i) current frame high frequency energy*/
+ Word16 frameloop, /*(i) amount of frames*/
+ Word16 bw, /*(i) band width index*/
+ Word16 frame_energy_Q, /*(i) the Scaling of current frame energy*/
+ Word16 HB_Power_Q, /*(i) the Scaling of current frame high frequency energy*/
+ Word32 snr, /*(i) frequency domain SNR */
+ Word32 tsnr, /*(i) time domain SNR */
+ Word16 vad_flag,
+ Word16 music_backgound_f /*(i) background music flag*/
+);
+
+void frame_spec_dif_cor_rate( T_CldfbVadState *st, /*(io) vad state*/
+ Word32 *spec_amp, /*(i) spectral amplitude*/
+ Word16 sacle, /*(i) the scaling of spec_amp*/
+ Word16 f_tonality_rate[3] /*(o) tonality rate*/
+ );
+
+void ltd_stable( T_CldfbVadState *st, /*(io) vad state*/
+ Word16 *ltd_stable_rate, /*(o) time-domain stable rate*/
+ Word32 frame_energy, /*(i) current frame energy*/
+ Word16 frameloop, /*(i) amount of frames*/
+ Word16 Q_frames_power /*(i) the Scaling of frames_power*/
+ );
+
+void snr_calc( T_CldfbVadState *st, /*(io) vad state*/
+ Word16 sacle_sbpower, /*(i) the Scaling of sbpower*/
+ Word32 *snr, /*(o) frequency domain SNR */
+ Word32 *tsnr, /*(o) time domain SNR */
+ Word32 frame_energy, /*(i) current frame energy */
+ Word32 bandwith /*(i) band width*/
+ );
+
+void bg_music_decision( T_CldfbVadState *st,
+ Word16 *music_backgound_f, /*(i) background music flag*/
+ Word32 frame_energy, /*(i) current frame energy 1*/
+ Word16 frame_energy_Q /*(i) the Scaling of current frame energy*/
+ );
+
+void background_update( T_CldfbVadState *st,
+ Word16 scale, /*(i) the Scaling of frame energy*/
+ Word32 frame_energy, /*(i) current frame energy*/
+ Word32 update_flag, /*(i) update flag*/
+ Word16 music_backgound_f /*(i) background music flag*/
+ ,Word32 snr
+ );
+
+void spec_center( Word32* sb_power, /*(i) energy of sub-band divided uniformly*/
+ Word16* sp_center, /*(o) spectral center*/
+ Word32 bandwith, /*(i) band width*/
+ Word16 Q_sb_p /*(i) the Scaling of sb_power*/
+ );
+
+void spec_flatness( Word32 *spec_amp, /*(i) spectral amplitude*/
+ Word32 smooth_spec_amp[], /*(i) smoothed spectral amplitude*/
+ Word16 sSFM[5] /*(o) spectral flatness rate*/
+ );
+
+void calc_lt_snr( T_CldfbVadState *st, /*(io) vad state*/
+ Word32 *lt_snr_org, /*(o) original long time SNR*/
+ Word32 *lt_snr, /*(o) long time SNR calculated by fg_energy and bg_energy*/
+ Word32 fg_energy, /*(i) foreground energy sum */
+ Word16 fg_energy_count, /*(i) amount of the foreground energy frame */
+ Word32 bg_energy, /*(i) background energy sum */
+ Word16 bg_energy_count, /*(i) amount of the background energy frame */
+ Word16 bw_index, /*(i) band width index*/
+ Word16 lt_noise_sp_center0 /*(i) long time noise spectral center by 0*/
+ );
+
+Word16 vad_decision( T_CldfbVadState *st,
+ Word32 l_snr, /*(i) long time frequency domain*/
+ Word32 lt_snr_org, /*(i) original long time SNR*/
+ Word32 lt_snr, /*(i) long time SNR calculated by fg_energy and bg_energy*/
+ Word32 snr_flux, /*(i) average tsnr of several frames*/
+ Word32 snr, /*(i) frequency domain SNR */
+ Word32 tsnr, /*(i) time domain SNR */
+ Word32 frame_energy, /*(i) current frame energy */
+ Word16 music_backgound_f, /*(i) background music flag*/
+ Word16 frame_energy_Q /*(i) the scaling of current frame energy*/
+ );
+
+Word16 comvad_decision( T_CldfbVadState *st,
+ Word32 l_snr, /*(i) long time frequency domain*/
+ Word32 lt_snr_org, /*(i) original long time SNR*/
+ Word32 lt_snr, /*(i) long time SNR calculated by fg_energy and bg_energy*/
+ Word32 snr_flux, /*(i) average tsnr of several frames*/
+ Word32 snr, /*(i) frequency domain SNR */
+ Word32 tsnr, /*(i) time domain SNR */
+ Word32 frame_energy, /*(i) current frame energy */
+ Word16 music_backgound_f, /*(i) background music flag*/
+ Word16 frame_energy_Q, /*(i) the Scaling of current frame energy*/
+ Word16 *cldfb_addition, /*(o) adjust the harmonized hangover */
+ Word16 vada_flag
+ );
+
+void calc_lf_snr(
+ Word32 *lf_snr_smooth, /*(o) smoothed lf_snr*/
+ Word32 *lf_snr, /*(o) long time frequency domain SNR calculated by l_speech_snr and l_silence_snr*/
+ Word32 l_speech_snr, /*(i) sum of active frames snr */
+ Word32 l_speech_snr_count, /*(i) amount of the active frame */
+ Word32 l_silence_snr, /*(i) sum of the nonactive frames snr*/
+ Word32 l_silence_snr_count, /*(i) amount of the nonactive frame */
+ Word16 fg_energy_count, /*(i) amount of the foreground energy frame */
+ Word16 bg_energy_count, /*(i) amount of the background energy frame */
+ Word16 bw_index /*(i) band width index*/
+);
+
+Word32 construct_snr_thresh( Word16 sp_center[], /*(i) spectral center*/
+ Word32 snr_flux, /*(i) snr flux*/
+ Word32 lt_snr, /*(i) long time time domain snr*/
+ Word32 l_snr, /*(i) long time frequency domain snr*/
+ Word32 continuous_speech_num, /*(i) amount of continuous speech frames*/
+ Word16 continuous_noise_num, /*(i) amount of continuous noise frames*/
+ Word32 fg_energy_est_start, /*(i) whether if estimated energy*/
+ Word16 bw_index /*(i) band width index*/
+ );
+
+Word16 vad_proc(T_CldfbVadState *vad_st,
+ Word32 realBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i: real values */
+ Word32 imagBuffer[CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i: imag values */
+ Word16 riBuffer_exp, /* i: exponent of real & imag Buffer */
+
+ Word16 *cldfb_addition, /*o: adjust the harmonized hangover */
+ Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i: energy vector per band */
+ Word16 enerBuffer_exp, /* i: exponent of energy vector */
+ Word16 bandwidth, /* 1: NB; 2:WB;3:SWB;4:FB*/
+ Word16 vada_flag
+ );
+
+void est_energy(Word32 enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i: energy vector per band */
+ Word16 enerBuffer_exp, /* i: exponent of energy vector */
+ Word32 *frame_sb_energy, /*(o) energy of sub-band divided non-uniformly*/
+ Word32 *frame_energy2_p, /*(o) frame energy 2*/
+ Word32 *HB_Power_p, /*(o) high frequency energy*/
+ Word32 *frame_energy_p, /*(o) frame energy 1*/
+ Word16 *sb_power_Q, /*(o) the scaling of sb_power*/
+ Word16 *frame_energy2_Q, /*(o) the scaling of frame_energy*/
+ Word16 *HB_Power_Q, /*(o) the scaling of HB_Power*/
+ Word16 *frame_energy_Q, /*(o) the Scaling of frame_energy*/
+ Word16 *frame_sb_energy_scale, /*(o) the Scaling of frame_sb_energy[]*/
+ Word32 bandwidth /*(i) band width*/
+ );
+
+/**
+ * \brief Function performs a complex 16-point FFT
+ * The FFT is performed inplace. The result of the FFT
+ * is scaled by SCALEFACTOR16 bits.
+ *
+ * WOPS FLC version: 196 cycles
+ * WOPS with 32x16 bit multiplications (scale on ): 288 cycles
+ * WOPS with 32x16 bit multiplications (scale off): 256 cycles
+ *
+ * \param [i/o] re real input / output
+ * \param [i/o] im imag input / output
+ * \param [i ] s stride real and imag input / output
+ *
+ * \return void
+ */
+void fft16(Word32 *re, Word32 *im, Word16 s, Word16 bScale);
+
+
+
+void dlpc_bfi(
+ const Word16 L_frame,
+ Word16 *lsf_q, /* o : quantized LSFs */
+ const Word16 *lsfold, /* i : past quantized LSF */
+ const Word16 last_good, /* i : last good received frame */
+ const Word16 nbLostCmpt, /* i : counter of consecutive bad frames */
+ Word16 mem_MA[], /* i/o: quantizer memory for MA model */
+ Word16 mem_AR[], /* i/o: quantizer memory for AR model */
+ Word16 *stab_fac, /* i : LSF stability factor */
+ Word16 *lsf_adaptive_mean,/* i : LSF adaptive mean, updated when BFI==0 */
+ Word16 numlpc, /* i : Number of division per superframe */
+ Word16 lsf_cng[],
+ Word8 plcBackgroundNoiseUpdated,
+ Word16 *lsf_q_cng, /* o : quantized LSFs */
+ Word16 *old_lsf_q_cng, /* o : old quantized LSFs for background noise */
+ const Word16* lsfBase, /* i : base for differential LSF coding */
+ Word8 tcxonly
+);
+
+void isf_dec_bfi(
+ const Word16 last_type, /*!< i : coding type in last good received fr. */
+ Word16*isf_q, /*!< o : 14Q1*1.28 quantized ISFs */
+ const Word16*isfold, /*!< i : 14Q1*1.28 past quantized ISF */
+ const Word16 last_good, /*!< i : last good received frame */
+ const Word16 bfi_cnt, /*!< i : counter of consecutive bad frames */
+ Word16*mem_MA, /*!< i/o: 14Q1*1.28 quantizer memory for MA model */
+ Word16 stab_fac, /*!< i : ISF stability factor (shifted right by 1) */
+ Word16*isf_adaptive_mean, /*!< i : 14Q1*1.28 ISF adaptive mean, updated when BFI==0 */
+ const Word16 coder_type, /*!< i : Coders frame type */
+ Word16 lpcorder, /*!< i: : lpc order */
+ Word16 *isf_cng,
+ Word8 plcBackgroundNoiseUpdated,
+ Word16 *isf_q_cng, /* o : quantized ISFs for background noise */
+ Word16 *old_isf_q_cng, /* o : old quantized ISFs for background noise */
+ const Word16 xsfBase[] /* i : base for differential XSF coding */
+);
+
+void tfaCalcEnv_fx(const Word16* shb_speech, Word32* enr);
+Word16 tfaEnc_TBE_fx(Word32* enr,
+ Word16 last_core,
+ Word16* voicing, /* Q15 */
+ Word16* pitch_buf, /* Q6 */
+ Word16 Q_enr
+ );
+
+void tecEnc_TBE_fx(Word16* corrFlag, const Word16* voicing, Word16 coder_type);
+
+void set_TEC_TFA_code_fx(const Word16 corrFlag, Word16* tec_flag, Word16* tfa_flag);
+
+Word16 procTecTfa_TBE_Fx(Word16 *hb_synth_Fx,
+ Word16 hb_synth_fx_exp,
+ Word16 *gain_m,
+ Word16 *gain_e,
+ Word16 flat_flag,
+ Word16 last_core
+ , Word16 l_subfr
+ , Word16 code
+ );
+
+
+void
+calcGainTemp_TBE_Fx(
+ Word32** pCldfbRealSrc_Fx,
+ Word32** pCldfbImagSrc_Fx,
+ Word16 cldfb_exp,
+ Word16* loBuffer_Fx,
+ Word16 startPos, /*!< Start position of the current envelope. */
+ Word16 stopPos, /*!< Stop position of the current envelope. */
+ Word16 lowSubband, /* lowSubband */
+ Word16* pGainTemp_m,
+ Word16* pGainTemp_e
+ , Word16 code
+);
+
+void resetTecEnc_Fx(
+ HANDLE_TEC_ENC_FX hTecEnc,
+ Word16 flag
+
+);
+
+void
+resetTecDec_Fx(
+ HANDLE_TEC_DEC_FX hTecDec
+);
+
+void calcHiEnvLoBuff_Fix(
+ Word16 noCols,
+ Word16* pFreqBandTable, /*!< freqbandTable. */
+ Word16 nSfb, /*!< Number of scalefactors. */
+ Word32** pCldfbPow_Fix /*float** pCldfbPow*/,
+ Word16* loBuffer_Fix /*float* loBuffer Q8*/,
+ Word16* hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/,
+ Word16 pCldfbPow_FixScale
+);
+
+void calcLoEnvCheckCorrHiLo_Fix(
+ Word16 noCols,
+ Word16* pFreqBandTable, /*!< freqbandTable. */
+ Word16* loBuffer_Fix /*float* loBuffer*/,
+ Word16* loTempEnv_Fix /*float* loTempEnv*/,
+ Word16* loTempEnv_ns_Fix /* float* loTempEnv_ns*/,
+ Word16* hiTempEnvOrig_Fix /*float* hiTempEnvOrig*/,
+ Word16* corrFlag /*int* corrFlag*/
+);
+
+
+
+/**************************** Moved from er_util.h: ********************************/
+
+/*----------------------------------------------------------------------*
+ * PLC: [ACELP: Fade-out]
+ * PLC: getLevelSynDeemph: derive on subframe basis the level of LPC
+ * synthesis and deeemphasis based on the given input
+ *----------------------------------------------------------------------*/
+
+Word16 getLevelSynDeemph( /*10Q5*/
+ Word16 h1Init[], /* i: input value or vector to be processed */ /* Q15 */
+ Word16 const A[], /* i: LPC coefficients */ /* Qx */
+ Word16 const lpcorder, /* i: LPC order */ /* Q0 */
+ Word16 const lenLpcExc, /* i: length of the LPC excitation buffer */ /* Q0 */
+ Word16 const preemph_fac, /* i: preemphasis factor */ /* Q15 */
+ Word16 const numLoops, /* i: number of loops */ /* Q0 */
+ Word16 *Exp /* o: exponent of return value Q15 */
+);
+
+
+/*-----------------------------------------------------------------*
+ * PLC: [ACELP: general]
+ * PLC: high pass filtering
+ *-----------------------------------------------------------------*/
+void highPassFiltering(
+ const Word16 last_good, /* i: short last classification type */
+ const Word16 L_buffer, /* i: int buffer length */
+ Word16 exc2[], /* i/o: Qx unvoiced excitation before the high pass filtering */
+ const Word16 hp_filt[], /* i: Q15 high pass filter coefficients */
+ const Word16 l_fir_fer); /* i: high pass filter length */
+
+
+/*----------------------------------------------------------------------------------*
+ * PLC: [Common: mode decision]
+ * PLC: Decide which Concealment to use. Update pitch lags if needed
+ *----------------------------------------------------------------------------------*/
+Word16 GetPLCModeDecision( Decoder_State_fx *st
+ );
+
+/* PLC: [Common: Fade-out]
+ * PLC: and for PLC fade out */
+
+void minimumStatistics(Word16* noiseLevelMemory, /* Q15, internal state */
+ Word16* noiseLevelIndex, /* Q0, internal state */
+ Word16* currLevelIndex, /* Q0, internal state (circular buffer) */
+ Word16* noiseEstimate, /* Q15, previous estimate of background noise */
+ Word16* lastFrameLevel, /* Q15, level of the last frame */
+ Word16 currentFrameLevel, /* Q15, level of the current frame */
+ Word16* noiseLevelMemory_e, /* scaling factor for noiseLevelMemory */
+ Word16 const noiseEstimate_e, /* exponent of noiseEstimate */
+ Word16* new_noiseEstimate_e, /* new exponent of noise Estimate*/
+ Word16* const lastFrameLevel_e, /* exponent of lastFrameLevel */
+ Word16 currentFrameLevel_e); /* exponent of currentFrameLevel */
+
+/*-----------------------------------------------------------------------------------*
+ * PLC: [ACELP: innovative codebook]
+ * PLC: genPlcFiltBWAdapt : deriuve filter coefficients for filtering
+ the first pitch cycle, bitrate dependent
+ *-----------------------------------------------------------------------------------*/
+
+void genPlcFiltBWAdap(
+ Word32 const sr_core, /*Qold) */
+ Word16 *old_exc, /* i: input excitation in Q(st->Qold) */
+ Word16 L_frame /* i: input frame length */
+);
+
+void encoderSideLossSimulation(
+ Encoder_State_fx *st,
+ HANDLE_PLC_ENC_EVS hPlc_Ext,
+ Word16 *isf_q, /* Q1*1.28 */
+ Word16 stab_fac, /* Q15 */
+ Word8 calcOnlyISF,
+ const Word16 L_frame
+);
+
+void enc_prm_side_Info( HANDLE_PLC_ENC_EVS hPlc_Ext, Encoder_State_fx *st );
+
+void GplcTcxEncSetup(Encoder_State_fx *st,
+ HANDLE_PLC_ENC_EVS hPlc_Ext,
+ Word16 Q_new);
+Word16 encSideSpecPowDiffuseDetector(
+ Word16 *isf_ref,
+ Word16 *isf_con,
+ Word32 sr_core,
+ Word16 *prev_isf4_mean,
+ Word8 sw
+ , Word16 coder_type
+);
+
+void updateSpecPowDiffuseIdx( Encoder_State_fx *st);
+
+void blend_subfr2(
+ Word16 *sigIn1, /* i : input signal for fade-out */
+ Word16 *sigIn2, /* i : input signal for fade-in */
+ Word16 *sigOut /* o : output signal */
+);
+
+
+void BASOP_cfft(cmplx *pComplexBuf, Word16 sizeOfFft, Word16 *scale, Word32 workBuffer[2*BASOP_CFFT_MAX_LENGTH]);
+void BASOP_cfft16(Word16 *re, Word16 *im, Word16 sizeOfFft, Word16 s, Word16 *scale);
+void BASOP_rfft(Word32 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign);
+void BASOP_rfft16(Word16 *x, Word16 sizeOfFft, Word16 *scale, Word16 isign);
+
+void open_PLC_ENC_EVS(
+ HANDLE_PLC_ENC_EVS hPlcExt,
+ Word32 sampleRate
+);
+
+void gPLC_encInfo (
+ HANDLE_PLC_ENC_EVS self,
+ Word32 modeBitrate,
+ Word16 modeBandwidth,
+ Word16 old_clas,
+ Word16 acelp_ext_mode
+);
+
+void v_sort(Word16 *r, const Word16 lo, const Word16 up);
+
+void coder_acelp_rf(
+ ACELP_config *acelp_cfg_rf, /*input/output: configuration of the ACELP coding*/
+ const Word16 coder_type, /* input: coding type */
+ const Word16 A[], /* input: coefficients 4xAz[M+1] */
+ const Word16 Aq[], /* input: coefficients 4xAz_q[M+1] */
+ Word16 speech[], /* input: speech[-M..lg] */
+ const Word16 voicing[], /* input: open-loop LTP gain */
+ const Word16 T_op[], /* input: open-loop LTP lag */
+ Word16 stab_fac,
+ Encoder_State_fx *st,
+ Word16 target_bits, /* i/o : coder memory state */
+ const Word16 rf_frame_type, /* i : rf_frame_type */
+ Word16 *exc_rf, /* i/o: pointer to RF excitation */
+ Word16 *syn_rf, /* i/o: pointer to RF synthesis */
+ Word16 Q_new,
+ Word16 shift
+);
+
+
+#endif /*PROT_COM_FX_H */
diff --git a/lib_com/pvq_com_fx.c b/lib_com/pvq_com_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..69b5518c44bdf254826f3c853dd523557cf6b4dd
--- /dev/null
+++ b/lib_com/pvq_com_fx.c
@@ -0,0 +1,753 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "stl.h" /* required for wmc_tool */
+
+
+#include "options.h"
+
+
+UWord32 intLimCDivPos_fx(
+ UWord32 NUM,
+ Word16 DEN
+)
+{
+ UWord32 UL_ru, UL_rl;
+ Mpy_32_32_uu(UL_lshl(NUM, 1), intLimCDivInvDQ31[DEN], &UL_ru, &UL_rl);
+ return UL_ru;
+}
+
+
+Word32 intLimCDivSigned_fx(
+ Word32 NUM,
+ Word16 DEN)
+{
+ Word32 L_tmp;
+
+ L_tmp = intLimCDivPos_fx( L_abs(NUM) , DEN);
+ if (NUM < 0)
+ {
+ L_tmp= L_negate(L_tmp); /* one op */
+ }
+ return L_tmp;
+}
+
+
+Word16 shrtCDivSignedApprox( const Word16 num,
+ const Word16 den
+ )
+{
+ Word16 pool_part;
+
+ pool_part = extract_h( L_mult( negate(abs_s(num)), lim_neg_inv_tbl_fx[den] ));
+ /* neg_in always, positive out always, so that positive truncation(rounding) is used */
+ if ( num < 0 )
+ {
+ pool_part = negate(pool_part); /* make negative, one op */
+ }
+ return pool_part;
+}
+
+void nearProjQ15_fx(
+ Word16 x,
+ Word16 *result
+)
+{
+ const Word16 a[4] = {14967, -25518, 3415, 32351};
+ Word32 b;
+ UWord16 lsb;
+
+ b = L_deposit_l(a[0]);
+ b = L_shl((Word32)add(a[1], extract_h(L_mult0((Word16)b, x))), 1);
+ Mpy_32_16_ss(b, x, &b, &lsb);
+ b = L_add((Word32)a[2], b);
+ Mpy_32_16_ss(b, x, &b, &lsb);
+ b = L_add((Word32)a[3], b);
+ *result = extract_l(b);
+ return ;
+}
+
+/*-------------------------------------------------------------------*
+ * obtainEnergyQuantizerDensity_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+void obtainEnergyQuantizerDensity_fx(
+ const Word16 L,
+ const Word16 R,
+ Word16 *Density )
+{
+ Word16 Rnrg, den, n;
+
+ den = sub(shl(L, 1), 1);
+ IF( den <= 67 )
+ {
+ Rnrg = extract_l(intLimCDivPos_fx( L_deposit_l(R) , den));
+ }
+ ELSE
+ {
+ n = norm_s(den);
+ Rnrg = shr(div_s(R, shl(den, n)), sub(15, n));
+ }
+ Rnrg = add(Rnrg, 28);
+
+ Rnrg = s_min(Rnrg, 56);
+ Rnrg = s_min(Rnrg, sub(R, 96));
+
+ Rnrg = s_max(Rnrg, 3);
+ *Density = obtainEnergyQuantizerDensity_f[Rnrg];
+ return;
+}
+
+
+/*-------------------------------------------------------------------*
+ * dsDirac2Dirac_fx()
+ *
+ *
+ *-------------------------------------------------------------------*/
+void dsDirac2Dirac_fx(
+ const Word16 dsDiracIndex,
+ Word16 *diracs
+)
+{
+ *diracs = dsDiracsTab[dsDiracIndex];
+ return;
+}
+
+void dsDiracPerQuanta_fx(
+ const Word16 td,
+ const Word16 t_quanta,
+ const Word16 dsm,
+ const unsigned char* const *frQuanta,
+ Word16 *DsIdx
+)
+{
+ const unsigned char *sv;
+ Word16 nsv;
+ Word16 t_quanta_o;
+ Word16 dsIndex;
+ Word16 i;
+
+ sv = frQuanta[td];
+ nsv = sv[0];
+
+ t_quanta_o = sub(t_quanta, QUANTAQ3OFFSET);
+
+ IF (GE_16(t_quanta_o, sv[nsv]))
+ {
+ *DsIdx = nsv;
+ move16();
+ return ;
+ }
+
+ IF (LE_16(t_quanta_o, sv[1]))
+ {
+ *DsIdx = 1;
+ move16();
+ return ;
+ }
+
+
+ dsIndex = shl(1, frQuanta[0][td]);
+ if (GT_16(t_quanta_o, sv[shr(nsv, 1) ]))
+ {
+ dsIndex = sub(nsv, dsIndex );
+ }
+ FOR (i = sub(frQuanta[0][td], 1); i >= 0; i--)
+ {
+ dsIndex = add(dsIndex, shl(sub(shl(lshr(sub(sv[dsIndex], t_quanta_o), 15), 1), 1), i));
+ }
+
+ dsIndex = add(dsIndex, lshr(sub(sv[dsIndex], t_quanta_o), 15));
+ dsIndex = sub(dsIndex, lshr(sub(1, dsIndex), 15));
+
+ IF (dsm > 0)
+ {
+ *DsIdx=dsIndex;
+ move16();
+ return;
+ }
+ *DsIdx = add(dsIndex, lshr(sub(add(sv[add(dsIndex,1)], sv[dsIndex]), shl(t_quanta_o, 1)), 15));
+ return;
+}
+
+void QuantaPerDsDirac_fx(
+ Word16 td,
+ Word16 dsDiracIndex,
+ const unsigned char* const* dimFrQuanta,
+ Word16 *Quanta
+)
+{
+ *Quanta = dimFrQuanta[td][dsDiracIndex];
+ move16();
+ if(dsDiracIndex == 0)
+ {
+ *Quanta = -1; /* single op */ move16();
+ }
+ *Quanta = add(*Quanta, QUANTAQ3OFFSET);
+ return ;
+}
+
+void conservativeL1Norm_fx(
+ Word16 L,
+ Word16 Qvec,
+ Word16 Fcons,
+ Word16 Qavail,
+ Word16 Qreserv,
+ Word16 Dspec,
+ Word16 *Dvec,
+ Word16 *Qspare,
+ Word16 *Qreservplus,
+ Word16 *Dspecplus
+)
+{
+
+ Word16 Minit, Mprime;
+ Word16 Qtestminus;
+ const unsigned char *frQuantaL;
+
+ frQuantaL = hBitsN[L];
+
+ *Qreservplus = add(Qreserv, sub(Qvec, QUANTAQ3OFFSET));
+
+ dsDiracPerQuanta_fx(L, Qvec, Fcons, hBitsN, &Minit);
+
+ Mprime = Minit;
+ move16();
+ DO
+ {
+ Qtestminus = (short)frQuantaL[Mprime];
+ move16();
+ *Qspare = sub(Qavail, Qtestminus);
+ Mprime = sub(Mprime, 1);
+ }
+ WHILE ( (Mprime >= 0) && LT_16(*Qspare, QUANTAQ3OFFSET ));
+
+ if(Mprime < 0)
+ {
+ *Qspare = add(Qavail, QUANTAQ3OFFSET); /* single op */
+ }
+ dsDirac2Dirac_fx(add(Mprime, 1), Dvec);
+
+ *Dspecplus = add(Dspec, *Dvec);
+ *Qreservplus = sub(*Qreservplus, (short)frQuantaL[Minit]);
+ *Qspare = sub(*Qspare, QUANTAQ3OFFSET);
+
+ return;
+}
+
+
+
+
+
+void bandBitsAdjustment_fx(
+ Word16 Brc,
+ UWord32 INTrc,
+ Word16 Bavail,
+ Word16 Nbands,
+ Word16 D,
+ Word16 L,
+ Word16 Bband,
+ Word16 Breserv,
+ Word16 *Bband_adj,
+ Word16 *Brem,
+ Word16 *Breservplus)
+{
+ Word16 Btemp;
+ Word16 Bff;
+ Word32 L_tmp;
+
+ rangeCoderFinalizationFBits_fx(Brc, INTrc, &Bff);
+
+ IF(LT_16(D, Nbands))
+ {
+ L_tmp = L_deposit_l(sub(Breserv, Bff));
+ Btemp = extract_l(intLimCDivSigned_fx(L_tmp, s_min(D, 3))); /* result always fits in Word16 */
+ *Breservplus = add(Bband, Breserv);
+ }
+ ELSE
+ {
+ Btemp = 0;
+ move16();
+ *Breservplus = add(Bband, Bff);
+ }
+ *Bband_adj = s_min(extract_l(L_mult(L, 40)), Bband);
+ *Brem = sub(Bavail, Bff);
+ *Bband_adj = s_min(*Brem, add(*Bband_adj, Btemp));
+ *Bband_adj = s_max(0, *Bband_adj);
+}
+
+
+
+static Word16 Ratio_base2Q11_fx( /* o : Q11 */
+ const Word16 opp, /* i : Q15 */
+ const Word16 near /* i : Q15 */
+)
+{
+ Word16 mc, nc, ms, ns, d, z;
+ Word16 result;
+ Word32 acc;
+
+ ns = norm_s(opp ); /* exponent */
+ nc = norm_s(near ); /* exponent */
+
+ ms = shl(opp, ns); /* mantissa */
+ mc = shl(near, nc); /* mantissa */
+
+ acc = L_mac(538500224L, mc, -2776); /* a0*mc + a1, acc(Q27), a0(Q11), a1(Q27) */
+ z = mac_r(acc, ms, -2776); /* z in Q11, a0 in Q11 */
+ d = sub(ms, mc); /* d in Q15 */
+ z = mult_r(z, d); /* z in Q11 */
+
+ result = add(z, shl(sub(nc, ns), 11));
+
+ return result;
+}
+
+void Ratio_rQ3_fx(
+ Word16 opp,
+ Word16 near,
+ Word16 *result
+)
+{
+ Word16 tmp;
+
+ tmp = add(1<<7 , Ratio_base2Q11_fx(opp, near));
+ *result = shr(tmp, 8);
+ return ;
+}
+
+
+void densityAngle2RmsProjDec_fx(
+ Word16 D,
+ Word16 indexphi,
+ Word16 *oppQ15,
+ Word16 *nearQ15,
+ Word16 *oppRatioQ3
+)
+{
+ Word16 phiQ14q;
+ Word16 oppTail, nearTail;
+
+ phiQ14q = (Word16)intLimCDivPos_fx(L_shl(L_deposit_l(indexphi), 13), shr(D, 1));
+ if (indexphi < 0)
+ {
+ phiQ14q = 1 << 13; /* one op */ move16();
+ }
+
+ oppTail = shr(sub(16320, phiQ14q), 15);
+ nearTail = shr(sub(phiQ14q, 64), 15);
+
+ IF (s_or(oppTail, nearTail) < 0)
+ {
+ *oppQ15 = s_and(oppTail, (1 << 15) - 1);
+ *nearQ15 = s_and(nearTail, (1 << 15) - 1);
+ *oppRatioQ3 = shl(add(1, shl(nearTail, 1)), 14);
+ }
+ ELSE
+ {
+ nearProjQ15_fx( shl(sub(1 << 14, phiQ14q), 1), oppQ15);
+ nearProjQ15_fx(shl(phiQ14q, 1), nearQ15);
+ Ratio_rQ3_fx(*oppQ15, *nearQ15, oppRatioQ3);
+ }
+
+ return;
+}
+
+void densityAngle2RmsProjEnc_fx(
+ Word16 D,
+ Word16 phiQ14uq,
+ Word16 *indexphi,
+ Word16 *oppQ15,
+ Word16 *nearQ15,
+ Word16 *oppRatioQ3
+)
+{
+ *indexphi = mult_r(shl(D, 1), phiQ14uq);
+ if (s_and(D, 1) > 0)
+ {
+ *indexphi = -1; /* one op */ move16();
+ }
+ densityAngle2RmsProjDec_fx(D, *indexphi, oppQ15, nearQ15, oppRatioQ3);
+
+ return;
+}
+
+void NearOppSplitAdjustment_fx(
+ const Word16 qband,
+ const Word16 qzero,
+ const Word16 Qac,
+ const UWord32 INTac,
+ const Word16 qglobal,
+ const Word16 FlagCons,
+ const Word16 Np,
+ const Word16 Nhead,
+ const Word16 Ntail,
+ const Word16 Nnear,
+ const Word16 Nopp,
+ Word16 oppRQ3,
+ Word16 *qnear,
+ Word16 *qopp,
+ Word16 *qglobalupd
+)
+{
+
+ Word16 qac, qboth, qskew, qavg, qmin, Midx;
+ Word32 L_QIb, L_qnum;
+ Word16 QIb, QIa;
+
+ rangeCoderFinalizationFBits_fx(Qac, INTac, &qac);
+ qboth = sub(qband, sub(qac, qzero));
+ /* skew calc code */
+ qskew = 0 ;
+ move16();
+ IF (GT_16(Nhead, 1))
+ {
+ qavg = extract_h(L_shl(intLimCDivSigned_fx((Word32)qboth, Np),16)); /* qboth may be negative */
+ dsDiracPerQuanta_fx(Ntail, qavg, FlagCons, hBitsN, &Midx );
+ QuantaPerDsDirac_fx(Nhead, Midx, hBitsN, &qmin);
+ qskew = sub(qavg, qmin);
+ qskew = s_max(0, qskew);
+ } /* end of skew calc code*/
+
+ QIa = add(extract_l(intLimCDivPos_fx((UWord32)L_deposit_l(Nopp), Nnear)), 1); /* always positive Word16 out */
+ L_qnum = L_sub( L_deposit_l(sub(sub(add(qband, qzero), qac), qskew)), L_mult0(Nopp, oppRQ3));
+
+ L_QIb = L_deposit_l(0);
+ IF (L_qnum > 0)
+ {
+ L_QIb = (Word32) intLimCDivPos_fx(L_qnum, QIa);
+ }
+ *qnear = qboth;
+ QIb = extract_h(L_shl(L_QIb, 16)); /* may saturate */
+ if (LE_16(QIb, qboth))
+ {
+ *qnear = QIb;
+ }
+ *qopp = sub(qboth, *qnear);
+ *qglobalupd = sub(qglobal, sub(qac, qzero));
+
+ return;
+}
+
+
+/*--------------------------------------------------------------------------*
+ * apply_gain()
+ *
+ * Apply gain
+ *--------------------------------------------------------------------------*/
+
+void apply_gain_fx(
+ const Word16 *ord, /* i : Indices for energy order */
+ const Word16 *band_start, /* i : Sub band start indices */
+ const Word16 *band_end, /* i : Sub band end indices */
+ const Word16 num_sfm, /* i : Number of bands */
+ const Word16 *gains, /* i : Band gain vector Q12 */
+ Word16 *xq /* i/o: Float synthesis / Gain adjusted synth Q15/Q12 */
+)
+{
+ Word16 band,i;
+ Word16 g; /* Q12 */
+
+ FOR ( band = 0; band < num_sfm; band++)
+ {
+ g = gains[ord[band]];
+
+ FOR( i = band_start[band]; i < band_end[band]; i++)
+ {
+ /*xq[i] *= g; */
+ xq[i] = mult_r(g, xq[i]);
+ move16(); /*12+15+1-16=12 */
+ }
+ }
+
+ return;
+}
+
+/*--------------------------------------------------------------------------*
+ * fine_gain_quant()
+ *
+ * Fine gain quantization
+ *--------------------------------------------------------------------------*/
+
+void fine_gain_quant_fx(
+ Encoder_State_fx *st_fx,
+ const Word16 *ord, /* i : Indices for energy order */
+ const Word16 num_sfm, /* i : Number of bands */
+ const Word16 *gain_bits, /* i : Gain adjustment bits per sub band */
+ Word16 *fg_pred, /* i/o: Predicted gains / Corrected gains Q12 */
+ const Word16 *gopt /* i : Optimal gains Q12 */
+)
+{
+ Word16 band;
+ Word16 gbits;
+ Word16 idx;
+ Word16 gain_db,gain_dbq;
+ Word16 err;
+
+ Word16 tmp1, tmp2, exp1, exp2;
+ Word32 L_tmp;
+ UWord16 lsb;
+
+ FOR ( band = 0; band < num_sfm; band++)
+ {
+ gbits = gain_bits[ord[band]];
+ test();
+ IF ( fg_pred[band] != 0 && gbits > 0 )
+ {
+ exp1 = norm_s(gopt[band]);
+ exp1 = sub(exp1, 1);
+ tmp1 = shl(gopt[band], exp1);
+ exp2 = norm_s(fg_pred[band]);
+ tmp2 = shl(fg_pred[band], exp2);
+ exp1 = add(15, sub(exp1, exp2));
+ err = div_s(tmp1, tmp2);
+ tmp1 = norm_s(err);
+ exp2 = Log2_norm_lc(L_deposit_h(shl(err, tmp1)));
+ tmp1 = sub(14, tmp1);
+ tmp1 = sub(tmp1, exp1);
+ L_tmp = L_Comp(tmp1, exp2);
+ Mpy_32_16_ss(L_tmp, 24660, &L_tmp, &lsb); /* 24660 = 20*log10(2) in Q12 */ /*16+12-15=13 */
+ gain_db = round_fx(L_shl(L_tmp, 17));
+
+ idx = squant_fx(gain_db, &gain_dbq, finegain_fx[gbits-1], gain_cb_size[gbits-1]);
+ push_indice_fx( st_fx, IND_PVQ_FINE_GAIN, idx, gbits );
+
+ L_tmp = L_mult0(gain_dbq, 21771); /* 21771=0.05*log2(10) */ /* 14+17=31 */
+ L_tmp = L_shr(L_tmp, 15);
+ tmp1 = L_Extract_lc(L_tmp, &exp1);
+ tmp1 = abs_s(tmp1);
+ tmp1 = extract_l(Pow2(14, tmp1));
+ exp1 = sub(14, exp1);
+
+ L_tmp = L_mult0(fg_pred[band], tmp1); /*12+exp1 */
+ fg_pred[band] = round_fx(L_shl(L_tmp, sub(16, exp1))); /*12+exp1+16-exp1-16=12 */
+ }
+ }
+
+ return;
+}
+
+/*-------------------------------------------------------------------*
+ * srt_vec_ind()
+ *
+ * sort vector and save sorting indeces
+ *-------------------------------------------------------------------*/
+
+void srt_vec_ind16_fx (
+ const Word16 *linear, /* linear input */
+ Word16 *srt, /* sorted output*/
+ Word16 *I, /* index for sorted output */
+ Word16 length
+)
+{
+ Word16 pos,npos;
+ Word16 idxMem;
+ Word16 valMem;
+
+ /*initilize */
+ FOR (pos = 0; pos < length; pos++)
+ {
+ I[pos] = pos;
+ move16();
+ }
+
+ Copy(linear, srt,length);
+
+ /* now iterate */
+ FOR (pos = 0; pos < (length - 1); pos++)
+ {
+ FOR (npos = (pos + 1); npos < length; npos++)
+ {
+ IF (LT_16(srt[npos], srt[pos]))
+ {
+ idxMem = I[pos];
+ move16();
+ I[pos] = I[npos];
+ move16();
+ I[npos] = idxMem;
+ move16();
+
+ valMem = srt[pos];
+ move16();
+ srt[pos] = srt[npos];
+ move16();
+ srt[npos] = valMem;
+ move16();
+ }
+ }
+ }
+
+ return;
+}
+
+/*-----------------------------------------------------------------------------
+ * atan2_fx():
+ *
+ * Approximates arctan piecewise with various 4th to 5th order least square fit
+ * polynomials for input in 5 segments:
+ * - 0.0 to 1.0
+ * - 1.0 to 2.0
+ * - 2.0 to 4.0
+ * - 4.0 to 8.0
+ * - 8.0 to infinity
+ *---------------------------------------------------------------------------*/
+Word16 atan2_fx( /* o: Angle between 0 and PI/2 radian (Q14) */
+ const Word32 y, /* i: Argument must be positive (Q15) */
+ const Word32 x /* i: Q15 */
+)
+{
+ Word32 acc, arg;
+ Word16 man, expo, reciprocal;
+ Word16 angle, w, z;
+
+ IF (x == 0)
+ {
+ return 25736; /* PI/2 in Q14 */
+ }
+ man = ratio(y, x, &expo); /* man in Q14 */
+ expo = sub(expo, (15 - 14)); /* Now, man is considered in Q15 */
+ arg = L_shr((Word32)man, expo);
+
+ IF (L_shr(arg, 3+15) != 0)
+ /*===============================*
+ * 8.0 <= x < infinity *
+ *===============================*/
+ {
+ /* atan(x) = PI/2 - 1/x + 1/(3x^3) - 1/(5x^5) + ...
+ * ~ PI/2 - 1/x, for x >= 8.
+ */
+ expo = norm_l(arg);
+ man = extract_h(L_shl(arg, expo));
+ reciprocal = div_s(0x3fff, man);
+ expo = sub(15 + 1, expo);
+ reciprocal = shr(reciprocal, expo); /* Q14 */
+ angle = sub(25736, reciprocal); /* Q14 (PI/2 - 1/x) */
+
+ /* For 8.0 <= x < 10.0, 1/(5x^5) is not completely negligible.
+ * For more accurate result, add very small correction term.
+ */
+ if (LT_32(L_shr(arg, 15), 10L))
+ {
+ angle = add(angle, 8); /* Add tiny correction term. */
+ }
+ }
+ ELSE IF (L_shr(arg, 2+15) != 0)
+ /*==========================*
+ * 4.0 <= x < 8.0 *
+ *==========================*/
+ {
+ /* interval: [3.999, 8.001]
+ * atan(x) ~ (((a0*x + a1)*x + a2)*x + a3)*x + a4
+ * = (((a0*8*y + a1)*8*y + a2)*8*y + a3)*8*y + a4 Substitute 8*y -> x
+ * = (((a0*8^3*y + a1*8^2)*y + a2*8)*y + a3)*8*y + a4
+ * = ((( c0*y + c1)*y + c2)*y + c3)*8*y + c4,
+ * where y = x/8
+ * and a0 = -1.28820869667651e-04, a1 = 3.88263533346295e-03,
+ * a2 = -4.64216306484597e-02, a3 = 2.75986060068931e-01,
+ * a4 = 7.49208077809799e-01.
+ */
+ w = extract_l(L_shr(arg, 3)); /* Q15 y = x/8 */
+ acc = L_add(533625337L, 0); /* Q31 c1 = a1*8^2 */
+ z = mac_r(acc, w, -2161); /* Q15 c0 = a0*8^3 */
+ acc = L_add(-797517542L, 0); /* Q31 c2 = a2*8 */
+ z = mac_r(acc, w, z); /* Q15 */
+ acc = L_add(592675551L, 0); /* Q31 c3 = a3 */
+ z = mac_r(acc, w, z); /* z (in:Q15, out:Q12) */
+ acc = L_add(201114012L, 0); /* Q28 c4 = a4 */
+ acc = L_mac(acc, w, z); /* Q28 */
+ angle = extract_l(L_shr(acc, (28 - 14))); /* Q14 result of atan(x), where 4 <= x < 8 */
+ }
+ ELSE IF (L_shr(arg, 1+15) != 0)
+ /*==========================*
+ * 2.0 <= x < 4.0 *
+ *==========================*/
+ {
+ /* interval: [1.999, 4.001]
+ * atan(x) ~ (((a0*x + a1)*x + a2)*x + a3)*x + a4
+ * = (((a0*4*y + a1)*4*y + a2)*4*y + a3)*4*y + a4 Substitute 4*y -> x
+ * = (((a0*16*y + a1*4)*y + a2)*4*y + a3)*4*y + a4
+ * = (((a0*32*y + a1*8)*y + a2*2)*2*y + a3)*4*y + a4
+ * = ((( c0*y + c1)*y + c2)*2*y + c3)*4*y + c4,
+ * where y = x/4
+ * and a0 = -0.00262378195660943, a1 = 0.04089687039888652,
+ * a2 = -0.25631148958325911, a3 = 0.81685854627399479,
+ * a4 = 0.21358070563097167
+ * */
+ w = extract_l(L_shr(arg, 2)); /* Q15 y = x/4 */
+ acc = L_add(702602883L, 0); /* Q31 c1 = a1*8 */
+ z = mac_r(acc, w, -2751); /* Q15 c0 = a0*32 */
+ acc = L_add(-1100849465L, 0); /* Q31 c2 = a2*2 */
+ z = mac_r(acc, w, z); /* z (in:Q15, out:Q14) */
+ acc = L_add(877095185L, 0); /* Q30 c3 = a3 */
+ z = mac_r(acc, w, z); /* z (in:Q14, out:Q12) */
+ acc = L_add(57332634L, 0); /* Q28 c4 = a4 */
+ acc = L_mac(acc, w, z); /* Q28 */
+ angle = extract_l(L_shr(acc, (28 - 14))); /* Q14 result of atan(x) where 2 <= x < 4 */
+ }
+ ELSE IF (L_shr(arg, 15) != 0)
+ /*==========================*
+ * 1.0 <= x < 2.0 *
+ *==========================*/
+ {
+ /* interval: [0.999, 2.001]
+ * atan(x) ~ (((a0*x + 1)*x + a2)*x + a3)*x + a4
+ * = (((a0*2*y + a1)*2*y + a2)*2*y + a3)*2*y + a4 Substitute 2*y -> x
+ * = (((a0*4*y + a1*2)*y + a2)*2*y + a3)*2*y + a4
+ * = (((a0*4*y + a1*2)*y + a2)*y + a3/2)*4*y + a4
+ * = ((( c0*y + c1)*y + c2)*y + c3)*4*y + c4,
+ * where y = x/2
+ * and a0 = -0.0160706457245251, a1 = 0.1527106504065224,
+ * a2 = -0.6123208404800871, a3 = 1.3307896976322915,
+ * a4 = -0.0697089375247448
+ */
+ w = extract_l(L_shr(arg, 1)); /* Q15 y= x/2 */
+ acc = L_add(655887249L, 0); /* Q31 c1 = a1*2 */
+ z = mac_r(acc, w, -2106); /* Q15 c0 = a0*4 */
+ acc = L_add(-1314948992L, 0); /* Q31 c2 = a2 */
+ z = mac_r(acc, w, z);
+ acc = L_add(1428924557L, 0); /* Q31 c3 = a3/2 */
+ z = mac_r(acc, w, z); /* z (in:Q15, out:Q13) */
+ acc = L_add(-37424701L, 0); /* Q29 c4 = a4 */
+ acc = L_mac(acc, w, z); /* Q29 */
+ angle = extract_l(L_shr(acc, (29 - 14))); /* Q14 result of atan(x) where 1 <= x < 2 */
+ }
+ ELSE
+ /*==========================*
+ * 0.0 <= x < 1.0 *
+ *==========================*/
+ {
+ /* interval: [-0.001, 1.001]
+ * atan(x) ~ ((((a0*x + a1)*x + a2)*x + a3)*x + a4)*x + a5
+ * = ((((a0*2*x + a1*2)*x/2 + a2)*x + a3)*x + a4)*x + a5
+ * = (((( c0*x + c1)*x/2 + c2)*x + c3)*x + c4)*x + c5
+ * where
+ * a0 = -5.41182677118661e-02, a1 = 2.76690449232515e-01,
+ * a2 = -4.63358392562492e-01, a3 = 2.87188466598566e-02,
+ * a4 = 9.97438122814383e-01, a5 = 5.36158556179092e-05.
+ */
+ w = extract_l(arg); /* Q15 */
+ acc = L_add(1188376431L, 0); /* Q31 c1 = a1*2 */
+ z = mac_r(acc, w, -3547); /* Q15 c0 = a0*2 */
+ acc = L_add(-995054571L, 0); /* Q31 c2 = a2 */
+ z = extract_h(L_mac0(acc, w, z)); /* Q15 non-fractional mode multiply */
+ acc = L_add(61673254L, 0); /* Q31 c3 = a3 */
+ z = mac_r(acc, w, z);
+ acc = L_add(2141982059L, 0); /* Q31 c4 = a4 */
+ z = mac_r(acc, w, z);
+ acc = L_add(115139L, 0); /* Q31 c5 = a5 */
+ acc = L_mac(acc, w, z); /* Q31 */
+ angle = extract_l(L_shr(acc, 31 - 14)); /* Q14 result of atan(x), where 0 <= x < 1 */
+ }
+
+ return angle; /* Q14 between 0 and PI/2 radian. */
+}
+
+
+
diff --git a/lib_com/range_com_fx.c b/lib_com/range_com_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..1e7aa09b07e312f64eb1b6eb928e3df574bc1044
--- /dev/null
+++ b/lib_com/range_com_fx.c
@@ -0,0 +1,62 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h" /* required for wmc_tool */
+
+
+/*-------------------------------------------------------------------*
+ * rc_get_bits2()
+ *
+ * Get number of bits needed to finalize range coder
+ *-------------------------------------------------------------------*/
+
+Word16 rc_get_bits2_fx( /* o: Number of bits needed */
+ const Word16 N, /* i: Number of bits currently used */
+ const UWord32 range /* i: Range of range coder */
+)
+{
+ return add(add(N, 2), norm_ul(range));
+}
+
+void rangeCoderFinalizationFBits_fx(
+ Word16 Brc,
+ UWord32 INTrc,
+ Word16 *FBits
+)
+{
+ Word32 L_Bq15;
+ UWord32 h, UL_tmp;
+ UWord16 Bq15ui16, l;
+ Word16 B, E, x, k;
+ *FBits = shl(add(Brc, 32), 3);
+
+ B = sub(30, norm_ul(INTrc));
+ x = sub(B, RCF_INIT_SHIFT );
+ L_Bq15 = 0;
+ move16();
+ if (x >= 0)
+ {
+ L_Bq15 = (Word32)UL_lshr(INTrc, x);
+ }
+
+ E = 2;
+ move16();
+ FOR(k = 1; k < 4; k++)
+ {
+ Bq15ui16 = u_extract_l(L_shr(L_Bq15, s_and(E, 1)));
+ UL_tmp = UL_lshl(UL_deposit_l(Bq15ui16), 1);
+ Mpy_32_16_uu(UL_tmp, Bq15ui16, &h , &l);
+ L_Bq15 = (Word32) h;
+ E = add(shl(B, 1), extract_l(L_lshr(L_sub(((1L << 16) - 1L), L_Bq15), 31)));
+ B = E;
+ move16();
+ }
+ *FBits = sub(*FBits, B);
+ return;
+}
+
diff --git a/lib_com/re8_ppv_fx.c b/lib_com/re8_ppv_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..873ff54dac05bbc30a5d62585081fb39844980c0
--- /dev/null
+++ b/lib_com/re8_ppv_fx.c
@@ -0,0 +1,193 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+/*-------------------------------------------------------------------*
+ * Prototypes
+ *-------------------------------------------------------------------*/
+
+static void nearest_neighbor_2D8_fx( const Word32 x[], Word16 y[] );
+static Word32 compute_error_2D8_fx( const Word32 x[], const Word16 y[] );
+
+/*--------------------------------------------------------------*
+ * RE8_PPV:
+ *
+ * NEAREST NEIGHBOR SEARCH IN INFINITE LATTICE RE8
+ * the algorithm is based on the definition of RE8 as
+ * RE8 = (2D8) U (2D8+[1,1,1,1,1,1,1,1])
+ * it applies the coset decoding of Sloane and Conway
+ * --------------------------------------------------------------*/
+
+void re8_PPV_fx(
+ const Word32 x[], /* i : point in R^8Q15 */
+ Word16 y[] /* o : point in RE8 (8-dimensional integer vector) */
+)
+{
+ Word16 i, y0[8];
+ Word32 e0, e1, x1[8];
+
+ /*--------------------------------------------------------------*
+ * find the nearest neighbor y0 of x in 2D8
+ *--------------------------------------------------------------*/
+ nearest_neighbor_2D8_fx( x, y0 );
+
+ /*--------------------------------------------------------------*
+ * find the nearest neighbor y1 of x in 2D8+(1,...,1) (by coset decoding)
+ *--------------------------------------------------------------*/
+
+ FOR( i=0; i<8; i++ )
+ {
+ x1[i] = L_sub(x[i], QR);
+ move32();
+ }
+ nearest_neighbor_2D8_fx( x1, y );
+
+ FOR ( i = 0; i < 8; i++ )
+ {
+ y[i] = add(y[i], 1);
+ move16();
+ }
+
+ /*--------------------------------------------------------------*
+ * compute e0=||x-y0||^2 and e1=||x-y1||^2
+ *--------------------------------------------------------------*/
+
+ e0 = compute_error_2D8_fx( x, y0 );
+ e1 = compute_error_2D8_fx( x, y );
+
+
+ /*--------------------------------------------------------------*
+ * select best candidate y0 or y1 to minimize distortion
+ *--------------------------------------------------------------*/
+ IF( LT_32(e0, e1))
+ {
+ Copy( y0, y, 8 );
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------*
+ * Nearest_neighbor_2D8(x,y)
+ *
+ * NEAREST NEIGHBOR SEARCH IN INFINITE LATTICE 2D8
+ * algorithm: nn_2D8(x) = 2*nn_D8(x/2)
+ * nn_D8 = decoding of Z^8 with Wagner rule
+ * (see Conway and Sloane's paper in IT-82)
+ --------------------------------------------------------------*/
+
+static void nearest_neighbor_2D8_fx(
+ const Word32 x[], /* i : point in R^8 */
+ Word16 y[] /* o : point in 2D8 (8-dimensional integer vector) */
+)
+{
+ Word16 i,j;
+ Word16 sum, tmp16, tmp16b;
+ Word32 s, e, em;
+
+ /*--------------------------------------------------------------*
+ * round x into 2Z^8 i.e. compute y=(y1,...,y8) such that yi = 2[xi/2]
+ * where [.] is the nearest integer operator
+ * in the mean time, compute sum = y1+...+y8
+ *--------------------------------------------------------------*/
+ sum = 0;
+ move16();
+
+ FOR( i=0; i<8; i++ )
+ {
+ /* round to ..., -2, 0, 2, ... ([-1..1[ --> 0) */
+ tmp16 = round_fx(L_add(x[i], L_shr(x[i], 31)));
+ y[i] = shl(tmp16, 1);
+ move16();
+ /* sum += y[i] */
+ sum = add(sum, y[i]);
+ }
+
+ /*--------------------------------------------------------------*
+ * check if y1+...+y8 is a multiple of 4
+ * if not, y is not round xj in the wrong way where j is defined by
+ * j = arg max_i | xi -yi|
+ * (this is called the Wagner rule)
+ *--------------------------------------------------------------*/
+ IF( s_and(sum, 2) != 0 )
+ {
+ /* find j = arg max_i | xi -yi| */
+ em = L_deposit_l(0);
+ j = 0;
+ move16();
+
+ FOR( i=0; i<8; i++ )
+ {
+ /* compute ei = xi-yi */
+ /* e[i]=x[i]-y[i] */
+ e = L_msu(x[i], y[i], QR/2);
+
+ /* compute |ei| = | xi-yi | */
+ s = L_abs(e);
+
+ /* check if |ei| is maximal, if so, set j=i */
+ if( LT_32(em, s))
+ {
+ j = i;
+ move16();
+ }
+ em = L_max(s, em);
+ }
+
+ /* round xj in the "wrong way" */
+ e = L_msu(x[j], y[j], QR/2);
+ tmp16 = extract_h(e);
+ tmp16b = add(y[j], 2);
+
+ if( tmp16 < 0 )
+ {
+ tmp16b = sub(tmp16b, 2+2);
+ }
+ y[j] = tmp16b;
+ move16();
+ }
+
+ return;
+}
+
+
+/*--------------------------------------------------------------*
+ * Compute_error_2D8(x,y)
+ *
+ * Compute mean square error between input vector and
+ * (quantized) point in 2D8.
+ --------------------------------------------------------------*/
+
+static Word32 compute_error_2D8_fx( /* o : mean squared error */
+ const Word32 x[], /* i : input vector */
+ const Word16 y[] /* i : point in 2D8 (8-dimensional integer vector) */
+)
+{
+ Word16 i, hi, lo;
+ Word32 err, Ltmp;
+
+ err = L_deposit_l(0);
+ FOR( i=0; i<8; i++ )
+ {
+ /*tmp = x[i]-y[i];*/
+ Ltmp = L_msu(x[i], y[i], 16384);
+ hi = extract_h(L_shl(Ltmp, 1));
+ lo = extract_l(L_msu(Ltmp, hi, 16384));
+
+ Ltmp = L_mult(hi, hi);
+ Ltmp = L_shl(Ltmp, 14);
+ Ltmp = L_mac(Ltmp, hi, lo);
+ Ltmp = L_mac0(Ltmp, mult(lo, lo), 1);
+
+ /* err+=tmp*tmp */
+ err = L_add(Ltmp, err);
+ }
+
+ return( err );
+}
diff --git a/lib_com/re8_util_fx.c b/lib_com/re8_util_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..b67c73f59edcdbb076bb9902b338d07d8ba886a9
--- /dev/null
+++ b/lib_com/re8_util_fx.c
@@ -0,0 +1,387 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "prot_fx.h" /* Function prototypes */
+#include "stl.h"
+
+
+/*-------------------------------------------------------------------*
+ * Prototypes
+ *-------------------------------------------------------------------*/
+
+static Word16 re8_identify_absolute_leader_fx( const Word16 y[] );
+static void re8_coord_fx( const Word16 *y, Word16 *k) ;
+
+
+/*----------------------------------------------------------------*
+ * re8_vor_fx()
+ *
+ * MULTI-RATE RE8 INDEXING BY VORONOI EXTENSION
+ *----------------------------------------------------------------*/
+void re8_vor_fx(
+ const Word16 y[], /* i : point in RE8 (8-dimensional integer vector) */
+ Word16 *n, /* o : codebook number n=0,2,3,4,... (scalar integer) */
+ Word16 k[], /* o : Voronoi index (integer vector of dimension 8) used only if n>4*/
+ Word16 c[], /* o : codevector in Q0, Q2, Q3, or Q4 if n<=4, y=c */
+ Word16 *ka /* o : identifier of absolute leader (to index c) */
+)
+{
+ Word16 i, r, iter, ka_tmp, n_tmp, mask;
+ Word16 k_tmp[8], v[8], c_tmp[8], k_mod[8];
+ Word32 Ltmp, Lsphere;
+
+ /*----------------------------------------------------------------*
+ * verify if y is in Q0, Q2, Q3 or Q4
+ * (a fast search is used here:
+ * the codebooks Q0, Q2, Q3 or Q4 are specified in terms of RE8 absolute leaders
+ * (see FORinstance Xie and Adoul's paper in ICASSP 96)
+ * - a unique code identifying the absolute leader related to y is computed
+ * in re8_identify_absolute_leader()
+ * this code is searched FORin a pre-defined list which specifies Q0, Q2, Q3 or Q4)
+ * the absolute leader is identified by ka
+ * - a translation table maps ka to the codebook number n)
+ *----------------------------------------------------------------*/
+ *ka = re8_identify_absolute_leader_fx( y );
+ move16();
+
+ /*----------------------------------------------------------------*
+ * compute codebook number n of Qn (by table look-up)
+ * at this stage, n=0,2,3,4 or out=100
+ *----------------------------------------------------------------*/
+ *n = Da_nq_fx[*ka];
+ move16();
+
+ /*----------------------------------------------------------------*
+ * decompose y into :
+ * (if n<=4:)
+ * y = c where c is in Q0, Q2, Q3 or Q4
+ * or
+ * (if n>4:)
+ * y = m c + v where c is in Q3 or Q4, v is a Voronoi codevector
+ * m=2^r (r integer >=2)
+ *
+ * in the latter case (if n>4), as a side-product, compute the (Voronoi) index k[] of v
+ * and replace n by n = n' + 2r where n' = 3 or 4 (c is in Qn') and r is defined above
+ *----------------------------------------------------------------*/
+
+ IF( LE_16(*n, 4))
+ {
+ Copy( y, c, 8 );
+ }
+ ELSE
+ {
+ /*------------------------------------------------------------*
+ * initialize r and m=2^r based on || y ||^2/8
+ *------------------------------------------------------------*/
+ Ltmp = L_mult(y[0], y[0]);
+ FOR( i = 1; i < 8; i++ )
+ {
+ Ltmp = L_mac( Ltmp, y[i], y[i]);
+ }
+
+ Lsphere = L_shr(Ltmp, 5+1); /* *0.125*0.25 / 2 to remove L_mac effect */
+
+ r = 1;
+ move16();
+ FOR( ; Lsphere > 11; Lsphere >>= 2 )
+ {
+ r = add(r, 1);
+ }
+ /*------------------------------------------------------------*
+ * compute the coordinates of y in the RE8 basis
+ *------------------------------------------------------------*/
+ re8_coord_fx( y, k_mod );
+
+ /*------------------------------------------------------------*
+ * compute m and the mask needed for modulo m (for Voronoi coding)
+ *------------------------------------------------------------*/
+ mask = sub(shl(1, r), 1); /* 0x0..011...1 */
+
+ /*------------------------------------------------------------*
+ * find the minimal value of r (or equivalently of m) in 2 iterations
+ *------------------------------------------------------------*/
+
+ FOR( iter=0; iter<2; iter++ )
+ {
+ /*--------------------------------------------------------*
+ * compute v such that y is in m RE_8 +v (by Voronoi coding)
+ *--------------------------------------------------------*/
+ FOR( i=0; i<8; i++ )
+ {
+ k_tmp[i] = s_and( k_mod[i], mask);
+ move16();
+ }
+
+ re8_k2y_fx( k_tmp, r, v );
+
+ /*--------------------------------------------------------*
+ * compute c = (y-v)/m
+ * (y is in RE8, c is also in RE8 by definition of v)
+ *--------------------------------------------------------*/
+
+ FOR( i=0; i<8; i++ )
+ {
+ c_tmp[i] = shr(sub(y[i], v[i]), r);
+ move16();
+ }
+
+ /*--------------------------------------------------------*
+ * verify if c_tmp is in Q2, Q3 or Q4
+ *--------------------------------------------------------*/
+ ka_tmp = re8_identify_absolute_leader_fx( c_tmp );
+
+ /*--------------------------------------------------------*
+ * at this stage, n_tmp=2,3,4 or out = 100 -- n=0 is not possible
+ *--------------------------------------------------------*/
+ n_tmp = Da_nq_fx[ka_tmp];
+ move16();
+
+ IF( GT_16(n_tmp, 4))
+ {
+ /*--------------------------------------------------------*
+ * if c is not in Q2, Q3, or Q4 (i.e. n_tmp>4), use m = 2^(r+1) instead of 2^r
+ *--------------------------------------------------------*/
+ r = add(r, 1);
+ mask = add(shl(mask, 1), 1); /* mask = m-1 <- this is less complex */
+ }
+ ELSE
+ {
+ /*--------------------------------------------------------*
+ * c is in Q2, Q3, or Q4 -> the decomposition of y as y = m c + v is valid
+ *
+ * since Q2 is a subset of Q3, indicate n=3 instead of n=2 (this is because
+ * for n>4, n=n'+2r with n'=3 or 4, so n'=2 is not valid)
+ *--------------------------------------------------------*/
+ n_tmp = s_max(n_tmp, 3);
+
+ /*--------------------------------------------------------*
+ * save current values into ka, n, k and c
+ *--------------------------------------------------------*/
+ *ka = ka_tmp;
+ move16();
+ *n = add(n_tmp, shl(r, 1));
+ move16();
+ Copy( k_tmp, k, 8 );
+ Copy( c_tmp, c, 8 );
+
+ /*--------------------------------------------------------*
+ * try m = 2^(r-1) instead of 2^r to be sure that m is minimal
+ *--------------------------------------------------------*/
+ r = sub(r, 1);
+ mask = shr(mask, 1);
+ }
+ }
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------
+ * re8_k2y_fx()
+ *
+ * VORONOI INDEXING (INDEX DECODING) k -> y
+ -------------------------------------------------------------------------*/
+void re8_k2y_fx(
+ const Word16 *k, /* i : Voronoi index k[0..7] */
+ const Word16 m, /* i : Voronoi modulo (m = 2^r = 1<=2) */
+ Word16 *y /* o : 8-dimensional point y[0..7] in RE8 */
+)
+{
+ Word16 i, v[8], *ptr1, *ptr2, m_tmp, mm;
+ Word32 ytp[8], z[8], Ltmp, Lsum ;
+
+ /*---------------------------------------------------------------*
+ * compute y = k M and z=(y-a)/m, where
+ * M = [4 ]
+ * [2 2 ]
+ * [| \ ]
+ * [2 2 ]
+ * [1 1 _ 1 1]
+ * a=(2,0,...,0)
+ *---------------------------------------------------------------*/
+ m_tmp = sub(15, m);
+
+ Lsum = L_deposit_l(k[7]);
+ ytp[7] = Lsum;
+ move32();
+ z[7] = L_shl(Lsum, m_tmp);
+ move32(); /* (int)(floor(y[7]*QR+0.5))>>m */
+
+ FOR( i=6; i>=1; i-- )
+ {
+ Ltmp = L_deposit_l( shl(k[i],1) );
+ Lsum = L_add (Lsum, Ltmp);
+ ytp[i] = L_add(ytp[7], Ltmp);
+ move32();
+ z[i] = L_shl(ytp[i], m_tmp);
+ move32(); /* (int)(floor(y[7]*QR+0.5))>>m */
+ }
+
+ Lsum = L_add( Lsum, L_deposit_l(shl(k[0],2) ));
+ ytp[0] = Lsum;
+ move32();
+ z[0] = L_shl(L_sub(Lsum, 2), m_tmp);
+ move32(); /* (int)(floor(y[7]*QR+0.5))>>m */
+
+ /*---------------------------------------------------------------*
+ * find nearest neighbor v of z in infinite RE8
+ *---------------------------------------------------------------*/
+ re8_PPV_fx( z, v );
+
+ /*---------------------------------------------------------------*
+ * compute y -= m v
+ *---------------------------------------------------------------*/
+ ptr1=y;
+ ptr2=v;
+
+ mm = shr(shl(1, m), 1); /* shr to remove effect of L_mult in L_msu */
+
+ FOR( i=0; i<8; i++ )
+ {
+ Ltmp = L_msu(ytp[i], *ptr2++, mm);
+ *ptr1++ = extract_l(Ltmp);
+ }
+
+ return;
+}
+
+
+/*-----------------------------------------------------------------------*
+ * re8_identify_absolute_leader:
+ *
+ * IDENTIFY THE ABSOLUTE LEADER RELATED TO y USING A PRE-DEFINED TABLE WHICH
+ * SPECIFIES THE CODEBOOKS Q0, Q2, Q3 and Q4
+ -----------------------------------------------------------------------*/
+
+static Word16 re8_identify_absolute_leader_fx( /* o : integer indicating if y if in Q0, Q2, Q3 or Q4 (or if y is an outlier) */
+ const Word16 y[] /* i : point in RE8 (8-dimensional integer vector) */
+)
+{
+ Word16 i,s,id,nb,pos,ka, tmp16;
+ Word32 Ltmp, Ls;
+ Word32 C;
+ const Word16 *ptr;
+
+ /*-----------------------------------------------------------------------*
+ * compute the RE8 shell number s = (y1^2+...+y8^2)/8 and C=(y1^2, ..., y8^2)
+ *-----------------------------------------------------------------------*/
+ Ls = L_mult(y[0], y[0]);
+ FOR( i = 1; i < 8; i++ )
+ {
+ Ls = L_mac( Ls, y[i], y[i]);
+ }
+ s = extract_h(L_shl(Ls, 16-(3+1))); /* s can saturate here */
+
+ /*-----------------------------------------------------------------------*
+ * compute the index 0 <= ka <= NB_LEADER+1 which identifies an absolute leader of Q0, Q2, Q3 or Q4
+ *
+ * by default, ka=index of last element of the table (to indicate an outlier)
+ *-----------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------*
+ * if s=0, y=0 i.e. y is in Q0 -> ka=index of element indicating Q0
+ *-------------------------------------------------------------------*/
+ ka = NB_LEADER;
+ move16();
+ IF( s != 0 )
+ {
+ ka = NB_LEADER+1;
+ move16();
+ /*-------------------------------------------------------------------*
+ * the maximal value of s for y in Q0, Q2, Q3 or Q4 is NB_SPHERE
+ * if s> NB_SPHERE, y is an outlier (the value of ka is set correctly)
+ *-------------------------------------------------------------------*/
+ IF( LE_16(s, NB_SPHERE))
+ {
+ /*---------------------------------------------------------------*
+ * compute the unique identifier id of the absolute leader related to y:
+ * s = (y1^4 + ... + y8^4)/8
+ *---------------------------------------------------------------*/
+ C = L_mult(y[0], y[0]);
+ tmp16 = extract_h(L_shl(C, 16-1));
+ Ltmp = L_mult(tmp16, tmp16);
+ FOR( i=1; i<8; i++ )
+ {
+ C = L_mult(y[i], y[i]);
+ tmp16 = extract_h(L_shl(C, 16-1));
+ Ltmp = L_mac(Ltmp, tmp16, tmp16);
+ }
+ id = extract_h(L_shl(Ltmp, 16-(3+1))); /* id can saturate to 8192 */
+
+ /*---------------------------------------------------------------*
+ * search for id in table Da_id
+ * (containing all possible values of id if y is in Q2, Q3 or Q4)
+ * this search is focused based on the shell number s so that
+ * only the id's related to the shell of number s are checked
+ *---------------------------------------------------------------*/
+
+ nb = Da_nb_fx[s - 1]; /* get the number of absolute leaders used on the shell of number s */
+ pos = Da_pos_fx[s - 1]; /* get the position of the first absolute leader of shell s in Da_id */
+ move16();
+ move16();
+
+ ptr = &Da_id_fx[pos];
+ move16();
+ FOR( i=0; i=1; i-- )
+ {
+ /* apply factor 2/4 from M^-1 */
+ k[i] = shr(sub(y[i], tmp), 1);
+ move16();
+ sum = sub(sum, y[i]);
+ }
+ /* apply factor 1/4 from M^-1 */
+ k[0]= shr(add(y[0], sum), 2);
+ move16();
+
+ return;
+}
diff --git a/lib_com/recovernorm_fx.c b/lib_com/recovernorm_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..f061c71eff8a959140fb851019764ce5ad92743a
--- /dev/null
+++ b/lib_com/recovernorm_fx.c
@@ -0,0 +1,62 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "stl.h" /* required for wmc_tool */
+#include "prot_fx.h" /* Function prototypes */
+#include "cnst_fx.h" /* Common constants */
+#include "rom_com_fx.h" /* Static table prototypes */
+
+/*--------------------------------------------------------------------------*
+ * recovernorm_fx()
+ *
+ * Recover reordered quantization indices and norms
+ *--------------------------------------------------------------------------*/
+
+void recovernorm_fx(
+ Word16 *idxbuf, /* i : reordered quantization indices */
+ Word16 *ynrm, /* o : recovered quantization indices */
+ Word16 *normqlg2, /* o : recovered quantized norms */
+ Word16 nb_sfm /* i : number of SFMs */
+)
+{
+ Word16 i,j,k;
+ const Word16 *order = NULL;
+ move16();
+
+ SWITCH (nb_sfm)
+ {
+ case NB_SFM:
+ order = norm_order_48;
+ move16();
+ BREAK;
+ case SFM_N_SWB:
+ order = norm_order_32;
+ move16();
+ BREAK;
+ case SFM_N_WB:
+ order = norm_order_16;
+ move16();
+ BREAK;
+ default:
+ order = norm_order_48;
+ move16();
+ BREAK;
+ }
+
+ FOR (i = 0; i < nb_sfm; i++)
+ {
+ j = order[i];
+ move16();
+ k = idxbuf[i];
+ move16();
+ ynrm[j] = k;
+ move16();
+ normqlg2[j] = dicnlg2[k];
+ move16();
+ }
+
+ return;
+}
+
diff --git a/lib_com/reordvct_fx.c b/lib_com/reordvct_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..952c483d000c9838059d047c59c8c328d8161415
--- /dev/null
+++ b/lib_com/reordvct_fx.c
@@ -0,0 +1,58 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "stl.h"
+#include "prot_fx.h" /* Function prototypes */
+
+
+/*--------------------------------------------------------------------------*
+ * reordvct()
+ *
+ * Rearrange a vector in decreasing order
+ *--------------------------------------------------------------------------*/
+
+void reordvct_fx(
+ Word16 *y, /* i/o: vector to rearrange */
+ const Word16 N, /* i : dimensions */
+ Word16 *idx /* o : reordered vector index */
+)
+{
+ Word16 i, j, k, n, im, temp;
+
+ n = sub(N, 1);
+ move16();
+ FOR (i=0; i 0)
+ q = add(q, shift);
+ *y++ = shl(x[0], shift);
+ move16();
+
+ FOR (i = 1; i < m; i++)
+ {
+ s = L_mult(x[i], a[0]);
+ /* Stop at i to Avoid Mults with Zeros */
+ FOR (j = 1; j <= i; j++)
+ {
+ s = L_mac(s, x[i-j], a[j]);
+ }
+
+ s = L_shl(s, q);
+ *y++ = round_fx(s);
+ }
+
+ FOR (; i < lg; i++)
+ {
+ s = L_mult(x[i], a[0]);
+ FOR (j = 1; j <= m; j++)
+ {
+ s = L_mac(s, x[i-j], a[j]);
+ }
+
+ s = L_shl(s, q);
+ *y++ = round_fx(s);
+ }
+}
+
+/*--------------------------------------------------------------------*
+ * Residu3_10_fx:
+ *
+ * Compute the LP residual by filtering the input speech through A(z)
+ * Output is in Qx
+ *--------------------------------------------------------------------*/
+void Residu3_10_fx(
+ const Word16 a[], /* i : prediction coefficients Q12 */
+ const Word16 x[], /* i : input signal (usually speech) Qx */
+ /* (note that values x[-10..-1] are needed) */
+ Word16 y[], /* o : output signal (usually residual) Qx */
+ const Word16 lg, /* i : vector size Q0 */ const Word16 shift
+)
+{
+ Word16 i,j;
+ Word32 s;
+ Word64 s64;
+ Word16 q;
+ q = add( norm_s(a[0]), 1 );
+ if (shift != 0)
+ q = add(q, shift);
+ FOR (i = 0; i < lg; i++)
+ {
+ s64 = 0;
+ FOR (j = 0; j <= 10; j++)
+ {
+ s64 = W_mac_16_16(s64, x[i-j], a[j]);
+ }
+ s = W_shl_sat_l(s64, q);
+ y[i] = round_fx(s);
+ }
+}
+/*--------------------------------------------------------------------*
+ * Residu3_fx:
+ *
+ * Compute the LP residual by filtering the input speech through A(z)
+ * Output is in Qx
+ *--------------------------------------------------------------------*/
+void Residu3_fx(
+ const Word16 a[], /* i : prediction coefficients Q12 */
+ const Word16 x[], /* i : input signal (usually speech) Qx */
+ /* (note that values x[-M..-1] are needed) */
+ Word16 y[], /* o : output signal (usually residual) Qx */
+ const Word16 lg, /* i : vector size Q0 */
+ const Word16 shift
+)
+{
+ Word16 i, j;
+ Word64 s64;
+ Word32 s32;
+ Word16 q;
+ q = add( norm_s(a[0]), 1 );
+ if (shift != 0)
+ q = add(q, shift);
+ FOR (i = 0; i < lg; i++)
+ {
+ s64 = 0;
+ FOR (j = 0; j <= 15; j++)
+ {
+ s64 = W_mac_16_16(s64, x[i-j], a[j]);
+ }
+ s64 = W_mac_16_16(s64, x[i-16], a[16]);
+ s32 = W_shl_sat_l(s64, q);
+ y[i] = round_fx( s32 );
+ }
+}
+/*==========================================================================*/
+/* FUNCTION : void calc_residu() */
+/*--------------------------------------------------------------------------*/
+/* PURPOSE : Compute the LP residual by filtering the input through */
+/* A(z) in all subframes */
+/*--------------------------------------------------------------------------*/
+/* INPUT ARGUMENTS : */
+/* Word16 *speech i : weighted speech signal Qx */
+/* Word16 L_frame i : order of LP filter Q0 */
+/* Word16 *p_Aq i : quantized LP filter coefficients Q12 */
+/*--------------------------------------------------------------------------*/
+/* OUTPUT ARGUMENTS : */
+/* Word16 *res o : residual signal Qx+1 */
+/*--------------------------------------------------------------------------*/
+/* INPUT/OUTPUT ARGUMENTS : */
+/*--------------------------------------------------------------------------*/
+/* RETURN ARGUMENTS : */
+/* _ None */
+/*--------------------------------------------------------------------------*/
+/* CALLED FROM : */
+/*==========================================================================*/
+
+void calc_residu_fx(
+ Encoder_State_fx *st, /* i/o: state structure */
+ const Word16 *speech, /* i : weighted speech signal */
+ Word16 *res, /* o : residual signal */
+ const Word16 *p_Aq, /* i : quantized LP filter coefficients */
+ const Word16 vad_hover_flag,
+ const Word16 vad_flag_dtx
+)
+{
+ Word16 i_subfr;
+ Word16 i;
+ Word16 att;
+ Word16 offset;
+
+ FOR( i_subfr = 0; i_subfr < st->L_frame_fx; i_subfr += L_SUBFR )
+ {
+ /* calculate the residual signal */
+ Residu3_fx( p_Aq, &speech[i_subfr], &res[i_subfr], L_SUBFR, 1 );
+
+ /* next subframe */
+ p_Aq += (M+1);
+ }
+ /* smoothing in case of CNG */
+ test();
+ IF( (st->Opt_DTX_ON_fx != 0 ) && (vad_hover_flag != 0) ) /* corresponds to line 504 in FLT acelp_core_enc.c */
+ {
+ st->burst_ho_cnt_fx = add(st->burst_ho_cnt_fx,1);
+ st->burst_ho_cnt_fx = s_min(st->burst_ho_cnt_fx, HO_HIST_SIZE);
+ IF( NE_16(st->bwidth_fx, NB))
+ {
+ offset = 5;
+ test();
+ if( EQ_16(st->bwidth_fx, WB)&&st->CNG_mode_fx>=0)
+ {
+ offset = st->CNG_mode_fx;
+ move16();
+ }
+
+ att = CNG_burst_att_fx[offset][sub(st->burst_ho_cnt_fx,1)]; /*Q15*/
+
+ FOR( i = 0; i < st->L_frame_fx; i++ )
+ {
+ res[i] = mult_r(res[i], att);
+ move16();
+ }
+ }
+ }
+ ELSE
+ {
+ test();
+ IF( (st->Opt_DTX_ON_fx != 0) && (vad_flag_dtx != 0) )
+ {
+ st->burst_ho_cnt_fx = 0;
+ move16();
+ }
+ }
+ return;
+}
+
diff --git a/lib_com/rom_basop_util.c b/lib_com/rom_basop_util.c
new file mode 100644
index 0000000000000000000000000000000000000000..646653e87904352f6a82778bfed2190f429728e9
--- /dev/null
+++ b/lib_com/rom_basop_util.c
@@ -0,0 +1,991 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "rom_basop_util.h"
+#include "stl.h"
+#include
+#include
+#include "options.h"
+
+
+/**
+ * \brief Lookup-Table for binary logarithm
+ */
+const Word16 ldCoeff[7] =
+{
+ -32768, -16384, -10923, -8192, -6554, -5461, -4681
+ /* -4096, -3641, -3277 */
+};
+
+/**
+ \brief Lookup-Table for binary power algorithm
+
+ This table is used for lookup 2^x with
+ x in range [0...1.0[ in steps of 1/32
+*/
+const UWord32 exp2_tab_long[32] =
+{
+ 0x40000000,0x4166C34C,0x42D561B4,0x444C0740,
+ 0x45CAE0F2,0x47521CC6,0x48E1E9BA,0x4A7A77D4,
+ 0x4C1BF829,0x4DC69CDD,0x4F7A9930,0x51382182,
+ 0x52FF6B55,0x54D0AD5A,0x56AC1F75,0x5891FAC1,
+ 0x5A82799A,0x5C7DD7A4,0x5E8451D0,0x60962665,
+ 0x62B39509,0x64DCDEC3,0x6712460B,0x69540EC9,
+ 0x6BA27E65,0x6DFDDBCC,0x70666F76,0x72DC8374,
+ 0x75606374,0x77F25CCE,0x7A92BE8B,0x7D41D96E
+};
+
+/**
+ \brief Lookup-Table for binary power algorithm
+
+ This table is used for lookup 2^x with
+ x in range [0...1/32[ in steps of 1/1024
+*/
+const UWord32 exp2w_tab_long[32] =
+{
+ 0x40000000,0x400B1818,0x4016321B,0x40214E0C,
+ 0x402C6BE9,0x40378BB4,0x4042AD6D,0x404DD113,
+ 0x4058F6A8,0x40641E2B,0x406F479E,0x407A7300,
+ 0x4085A051,0x4090CF92,0x409C00C4,0x40A733E6,
+ 0x40B268FA,0x40BD9FFF,0x40C8D8F5,0x40D413DD,
+ 0x40DF50B8,0x40EA8F86,0x40F5D046,0x410112FA,
+ 0x410C57A2,0x41179E3D,0x4122E6CD,0x412E3152,
+ 0x41397DCC,0x4144CC3B,0x41501CA0,0x415B6EFB
+};
+
+/**
+ \brief Lookup-Table for binary power algorithm
+
+ This table is used for lookup 2^x with
+ x in range [0...1/1024[ in steps of 1/32768
+*/
+const UWord32 exp2x_tab_long[32] =
+{
+ 0x40000000,0x400058B9,0x4000B173,0x40010A2D,
+ 0x400162E8,0x4001BBA3,0x4002145F,0x40026D1B,
+ 0x4002C5D8,0x40031E95,0x40037752,0x4003D011,
+ 0x400428CF,0x4004818E,0x4004DA4E,0x4005330E,
+ 0x40058BCE,0x4005E48F,0x40063D51,0x40069613,
+ 0x4006EED5,0x40074798,0x4007A05B,0x4007F91F,
+ 0x400851E4,0x4008AAA8,0x4009036E,0x40095C33,
+ 0x4009B4FA,0x400A0DC0,0x400A6688,0x400ABF4F
+};
+
+/* square root tables */
+const Word32 SqrtTable[32] = /* Q31 */
+{
+ 0x5A82D429, 0x5BEA10FE, 0x5D4BE6E5, 0x5EA89270, 0x60004BE2, 0x615347A1, 0x62A1B68C, 0x63EBC651,
+ 0x6531A1B5, 0x667370D4, 0x67B1595F, 0x68EB7EC8, 0x6A220277, 0x6B5503F0, 0x6C84A0F9, 0x6DB0F5BD,
+ 0x6EDA1CE9, 0x70002FC7, 0x7123465A, 0x72437773, 0x7360D8C5, 0x747B7EFA, 0x75937DC4, 0x76A8E7EB,
+ 0x77BBCF60, 0x78CC4545, 0x79DA5A00, 0x7AE61D3E, 0x7BEF9E07, 0x7CF6EAC2, 0x7DFC113F, 0x7EFF1EC0
+};
+
+const Word16 SqrtDiffTable[32] = /* Q21 */
+{
+ 0x59CF, 0x5875, 0x572B, 0x55EE, 0x54BF, 0x539C, 0x5284, 0x5177,
+ 0x5074, 0x4F7A, 0x4E89, 0x4DA1, 0x4CC0, 0x4BE7, 0x4B15, 0x4A4A,
+ 0x4985, 0x48C6, 0x480C, 0x4758, 0x46AA, 0x4600, 0x455B, 0x44BA,
+ 0x441D, 0x4385, 0x42F1, 0x4260, 0x41D3, 0x414A, 0x40C3, 0x4040
+};
+
+
+const Word32 ISqrtTable[32] = /* Q31 */
+{
+ 0x7FFE7F85, 0x7E0A4E25, 0x7C2C56C7, 0x7A63002C, 0x78ACD922, 0x7708939D, 0x75750088, 0x73F10C2D,
+ 0x727BBB1A, 0x71142774, 0x6FB97EA5, 0x6E6AFF54, 0x6D27F79D, 0x6BEFC388, 0x6AC1CBA4, 0x699D83DA,
+ 0x68826A53, 0x6770068E, 0x6665E882, 0x6563A7DF, 0x6468E364, 0x63754043, 0x62886999, 0x61A20FEE,
+ 0x60C1E8C8, 0x5FE7AE45, 0x5F131EBE, 0x5E43FC76, 0x5D7A0D4F, 0x5CB51A81, 0x5BF4F061, 0x5B395E26
+};
+
+const Word16 ISqrtDiffTable[32] = /* Q21 */
+{
+ 0x7D0C, 0x777E, 0x7256, 0x6D8A, 0x6911, 0x64E5, 0x60FD, 0x5D54,
+ 0x59E5, 0x56AA, 0x53A0, 0x50C2, 0x4E0D, 0x4B7E, 0x4912, 0x46C6,
+ 0x4499, 0x4288, 0x4090, 0x3EB1, 0x3CE9, 0x3B36, 0x3996, 0x380A,
+ 0x368F, 0x3524, 0x33C9, 0x327C, 0x313D, 0x300B, 0x2EE5, 0x2DCA
+};
+
+/* 1/x tables */
+const Word32 InvTable[32] = /* Q31 */
+{
+ 0x7FFBFE40, 0x7C1B608E, 0x78752176, 0x750440BA, 0x71C44C49, 0x6EB14D0A, 0x6BC7B6B4, 0x69045A19,
+ 0x6664598A, 0x63E51EE2, 0x61845308, 0x5F3FD698, 0x5D15BB8E, 0x5B043FD0, 0x5909C861, 0x5724DD3C,
+ 0x555425B2, 0x53966532, 0x51EA787F, 0x504F5331, 0x4EC3FD84, 0x4D479267, 0x4BD93DBE, 0x4A783ADC,
+ 0x4923D31D, 0x47DB5CAE, 0x469E3974, 0x456BD608, 0x4443A8D9, 0x43253159, 0x420FF746, 0x41038A01
+};
+
+/* inverse integer (1/i) */
+const Word16 InvIntTable[65] =
+{
+ 0x7FFF,
+ 0x7FFF, 0x4000, 0x2AAB, 0x2000, 0x199A, 0x1555, 0x1249, 0x1000,
+ 0x0E39, 0x0CCD, 0x0BA3, 0x0AAB, 0x09D9, 0x0925, 0x0889, 0x0800,
+ 0x0788, 0x071C, 0x06BD, 0x0666, 0x0618, 0x05D1, 0x0591, 0x0555,
+ 0x051F, 0x04EC, 0x04BE, 0x0492, 0x046A, 0x0444, 0x0421, 0x0400,
+ 0x03E1, 0x03C4, 0x03A8, 0x038E, 0x0376, 0x035E, 0x0348, 0x0333,
+ 0x031F, 0x030C, 0x02FA, 0x02E9, 0x02D8, 0x02C8, 0x02B9, 0x02AB,
+ 0x029D, 0x028F, 0x0283, 0x0276, 0x026A, 0x025F, 0x0254, 0x0249,
+ 0x023F, 0x0235, 0x022B, 0x0222, 0x0219, 0x0211, 0x0208, 0x0200
+};
+
+const Word16 InvDiffTable[32] = /* Q20 */
+{
+ 0x7C14, 0x74C8, 0x6E1C, 0x67FF, 0x6260, 0x5D33, 0x586C, 0x5400,
+ 0x4FE7, 0x4C19, 0x4890, 0x4543, 0x422F, 0x3F4F, 0x3C9D, 0x3A17,
+ 0x37B8, 0x357E, 0x3365, 0x316B, 0x2F8D, 0x2DCB, 0x2C20, 0x2A8D,
+ 0x290F, 0x27A4, 0x264C, 0x2506, 0x23CF, 0x22A7, 0x218E, 0x2081
+};
+
+const Word32 BASOP_util_normReciprocal[CHEAP_NORM_SIZE] =
+{
+ 0l/*0.0 Q31*/, 2147483647l/*1.0000000000 Q31*/, 1073741824l/*0.5000000000 Q31*/, 715827883l/*0.3333333333 Q31*/, 536870912l/*0.2500000000 Q31*/, 429496730l/*0.2000000000 Q31*/,
+ 357913941l/*0.1666666667 Q31*/, 306783378l/*0.1428571429 Q31*/, 268435456l/*0.1250000000 Q31*/, 238609294l/*0.1111111111 Q31*/, 214748365l/*0.1000000000 Q31*/, 195225786l/*0.0909090909 Q31*/,
+ 178956971l/*0.0833333333 Q31*/, 165191050l/*0.0769230769 Q31*/, 153391689l/*0.0714285714 Q31*/, 143165577l/*0.0666666667 Q31*/, 134217728l/*0.0625000000 Q31*/, 126322568l/*0.0588235294 Q31*/,
+ 119304647l/*0.0555555556 Q31*/, 113025455l/*0.0526315789 Q31*/, 107374182l/*0.0500000000 Q31*/, 102261126l/*0.0476190476 Q31*/, 97612893l/*0.0454545455 Q31*/, 93368854l/*0.0434782609 Q31*/,
+ 89478485l/*0.0416666667 Q31*/, 85899346l/*0.0400000000 Q31*/, 82595525l/*0.0384615385 Q31*/, 79536431l/*0.0370370370 Q31*/, 76695845l/*0.0357142857 Q31*/, 74051160l/*0.0344827586 Q31*/,
+ 71582788l/*0.0333333333 Q31*/, 69273666l/*0.0322580645 Q31*/, 67108864l/*0.0312500000 Q31*/, 65075262l/*0.0303030303 Q31*/, 63161284l/*0.0294117647 Q31*/, 61356676l/*0.0285714286 Q31*/,
+ 59652324l/*0.0277777778 Q31*/, 58040099l/*0.0270270270 Q31*/, 56512728l/*0.0263157895 Q31*/, 55063683l/*0.0256410256 Q31*/, 53687091l/*0.0250000000 Q31*/, 52377650l/*0.0243902439 Q31*/,
+ 51130563l/*0.0238095238 Q31*/, 49941480l/*0.0232558140 Q31*/, 48806446l/*0.0227272727 Q31*/, 47721859l/*0.0222222222 Q31*/, 46684427l/*0.0217391304 Q31*/, 45691141l/*0.0212765957 Q31*/,
+ 44739243l/*0.0208333333 Q31*/, 43826197l/*0.0204081633 Q31*/, 42949673l/*0.0200000000 Q31*/, 42107522l/*0.0196078431 Q31*/, 41297762l/*0.0192307692 Q31*/, 40518559l/*0.0188679245 Q31*/,
+ 39768216l/*0.0185185185 Q31*/, 39045157l/*0.0181818182 Q31*/, 38347922l/*0.0178571429 Q31*/, 37675152l/*0.0175438596 Q31*/, 37025580l/*0.0172413793 Q31*/, 36398028l/*0.0169491525 Q31*/,
+ 35791394l/*0.0166666667 Q31*/, 35204650l/*0.0163934426 Q31*/, 34636833l/*0.0161290323 Q31*/, 34087042l/*0.0158730159 Q31*/, 33554432l/*0.0156250000 Q31*/, 33038210l/*0.0153846154 Q31*/,
+ 32537631l/*0.0151515152 Q31*/, 32051995l/*0.0149253731 Q31*/, 31580642l/*0.0147058824 Q31*/, 31122951l/*0.0144927536 Q31*/, 30678338l/*0.0142857143 Q31*/, 30246248l/*0.0140845070 Q31*/,
+ 29826162l/*0.0138888889 Q31*/, 29417584l/*0.0136986301 Q31*/, 29020049l/*0.0135135135 Q31*/, 28633115l/*0.0133333333 Q31*/, 28256364l/*0.0131578947 Q31*/, 27889398l/*0.0129870130 Q31*/,
+ 27531842l/*0.0128205128 Q31*/, 27183337l/*0.0126582278 Q31*/, 26843546l/*0.0125000000 Q31*/, 26512144l/*0.0123456790 Q31*/, 26188825l/*0.0121951220 Q31*/, 25873297l/*0.0120481928 Q31*/,
+ 25565282l/*0.0119047619 Q31*/, 25264514l/*0.0117647059 Q31*/, 24970740l/*0.0116279070 Q31*/, 24683720l/*0.0114942529 Q31*/, 24403223l/*0.0113636364 Q31*/, 24129030l/*0.0112359551 Q31*/,
+ 23860929l/*0.0111111111 Q31*/, 23598721l/*0.0109890110 Q31*/, 23342214l/*0.0108695652 Q31*/, 23091222l/*0.0107526882 Q31*/, 22845571l/*0.0106382979 Q31*/, 22605091l/*0.0105263158 Q31*/,
+ 22369621l/*0.0104166667 Q31*/, 22139007l/*0.0103092784 Q31*/, 21913098l/*0.0102040816 Q31*/, 21691754l/*0.0101010101 Q31*/, 21474836l/*0.0100000000 Q31*/, 21262214l/*0.0099009901 Q31*/,
+ 21053761l/*0.0098039216 Q31*/, 20849356l/*0.0097087379 Q31*/, 20648881l/*0.0096153846 Q31*/, 20452225l/*0.0095238095 Q31*/, 20259280l/*0.0094339623 Q31*/, 20069941l/*0.0093457944 Q31*/,
+ 19884108l/*0.0092592593 Q31*/, 19701685l/*0.0091743119 Q31*/, 19522579l/*0.0090909091 Q31*/, 19346700l/*0.0090090090 Q31*/, 19173961l/*0.0089285714 Q31*/, 19004280l/*0.0088495575 Q31*/,
+ 18837576l/*0.0087719298 Q31*/, 18673771l/*0.0086956522 Q31*/, 18512790l/*0.0086206897 Q31*/, 18354561l/*0.0085470085 Q31*/, 18199014l/*0.0084745763 Q31*/, 18046081l/*0.0084033613 Q31*/,
+ 17895697l/*0.0083333333 Q31*/, 17747799l/*0.0082644628 Q31*/, 17602325l/*0.0081967213 Q31*/, 17459217l/*0.0081300813 Q31*/, 17318416l/*0.0080645161 Q31*/, 17179869l/*0.0080000000 Q31*/,
+ 17043521l/*0.0079365079 Q31*/, 16909320l/*0.0078740157 Q31*/, 16777216l/*0.0078125000 Q31*/, 16647160l/*0.0077519380 Q31*/, 16519105l/*0.0076923077 Q31*/, 16393005l/*0.0076335878 Q31*/,
+ 16268816l/*0.0075757576 Q31*/, 16146494l/*0.0075187970 Q31*/, 16025997l/*0.0074626866 Q31*/, 15907286l/*0.0074074074 Q31*/, 15790321l/*0.0073529412 Q31*/, 15675063l/*0.0072992701 Q31*/,
+ 15561476l/*0.0072463768 Q31*/, 15449523l/*0.0071942446 Q31*/, 15339169l/*0.0071428571 Q31*/, 15230381l/*0.0070921986 Q31*/, 15123124l/*0.0070422535 Q31*/, 15017368l/*0.0069930070 Q31*/,
+ 14913081l/*0.0069444444 Q31*/, 14810232l/*0.0068965517 Q31*/, 14708792l/*0.0068493151 Q31*/, 14608732l/*0.0068027211 Q31*/, 14510025l/*0.0067567568 Q31*/, 14412642l/*0.0067114094 Q31*/,
+ 14316558l/*0.0066666667 Q31*/, 14221746l/*0.0066225166 Q31*/, 14128182l/*0.0065789474 Q31*/, 14035841l/*0.0065359477 Q31*/, 13944699l/*0.0064935065 Q31*/, 13854733l/*0.0064516129 Q31*/,
+ 13765921l/*0.0064102564 Q31*/, 13678240l/*0.0063694268 Q31*/, 13591669l/*0.0063291139 Q31*/, 13506187l/*0.0062893082 Q31*/, 13421773l/*0.0062500000 Q31*/
+};
+
+const Word16 f_atan_expand_range[MAXSFTAB-(MINSFTAB-1)] =
+{
+ /*****************************************************************************
+ *
+ * Table holds fixp_atan() output values which are outside of input range
+ * of fixp_atan() to improve SNR of fixp_atan2().
+ *
+ * This Table might also be used in fixp_atan() [todo] so there a wider input
+ * range can be covered, too.
+ *
+ * Matlab (generate table):
+ * for scl = 7:25 % MINSFTAB .. MAXSFTAB
+ * at=atan(0.5 *(2^scl)); % 0.5 because get in 'middle' area of current scale level 'scl'
+ * at/2 % div at by ATO_SCALE
+ * end
+ *
+ * Table divided by 2=ATO_SCALE <-- SF=ATO_SF
+ *****************************************************************************/
+ 25480/*7.775862990872099e-001 Q15*/, 25608/*7.814919928673978e-001 Q15*/, 25672/*7.834450483314648e-001 Q15*/,
+ 25704/*7.844216021392089e-001 Q15*/, 25720/*7.849098823026687e-001 Q15*/, 25728/*7.851540227918509e-001 Q15*/,
+ 25732/*7.852760930873737e-001 Q15*/, 25734/*7.853371282415015e-001 Q15*/, 25735/*7.853676458193612e-001 Q15*/,
+ 25735/*7.853829046083906e-001 Q15*/, 25736/*7.853905340029177e-001 Q15*/, 25736/*7.853943487001828e-001 Q15*/,
+ 25736/*7.853962560488155e-001 Q15*/, 25736/*7.853972097231319e-001 Q15*/, 25736/*7.853976865602901e-001 Q15*/,
+ 25736/*7.853979249788692e-001 Q15*/, 25736/*7.853980441881587e-001 Q15*/, 25736/*7.853981037928035e-001 Q15*/,
+ 25736/*7.853981335951259e-001 Q15*/
+ /* pi/4 = 0.785398163397448 = pi/2/ATO_SCALE */
+};
+
+
+/*
+ Sine tables
+ */
+#define STC(x) WORD322WORD16(x)
+
+/* #define STCP(a,b) (((Word32)STC(b)<<16) | STC(a)) */
+#define STCP(a,b) { { STC(a), STC(b) } }
+
+const PWord16 SineTable512[] =
+{
+ STCP(0x7fffffff, 0x00000000), STCP(0x7fffd886, 0x006487e3), STCP(0x7fff6216, 0x00c90f88), STCP(0x7ffe9cb2, 0x012d96b1),
+ STCP(0x7ffd885a, 0x01921d20), STCP(0x7ffc250f, 0x01f6a297), STCP(0x7ffa72d1, 0x025b26d7), STCP(0x7ff871a2, 0x02bfa9a4),
+ STCP(0x7ff62182, 0x03242abf), STCP(0x7ff38274, 0x0388a9ea), STCP(0x7ff09478, 0x03ed26e6), STCP(0x7fed5791, 0x0451a177),
+ STCP(0x7fe9cbc0, 0x04b6195d), STCP(0x7fe5f108, 0x051a8e5c), STCP(0x7fe1c76b, 0x057f0035), STCP(0x7fdd4eec, 0x05e36ea9),
+ STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd37153, 0x06ac406f), STCP(0x7fce0c3e, 0x0710a345), STCP(0x7fc85854, 0x077501be),
+ STCP(0x7fc25596, 0x07d95b9e), STCP(0x7fbc040a, 0x083db0a7), STCP(0x7fb563b3, 0x08a2009a), STCP(0x7fae7495, 0x09064b3a),
+ STCP(0x7fa736b4, 0x096a9049), STCP(0x7f9faa15, 0x09cecf89), STCP(0x7f97cebd, 0x0a3308bd), STCP(0x7f8fa4b0, 0x0a973ba5),
+ STCP(0x7f872bf3, 0x0afb6805), STCP(0x7f7e648c, 0x0b5f8d9f), STCP(0x7f754e80, 0x0bc3ac35), STCP(0x7f6be9d4, 0x0c27c389),
+ STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f5834b7, 0x0cefdb76), STCP(0x7f4de451, 0x0d53db92), STCP(0x7f434563, 0x0db7d376),
+ STCP(0x7f3857f6, 0x0e1bc2e4), STCP(0x7f2d1c0e, 0x0e7fa99e), STCP(0x7f2191b4, 0x0ee38766), STCP(0x7f15b8ee, 0x0f475bff),
+ STCP(0x7f0991c4, 0x0fab272b), STCP(0x7efd1c3c, 0x100ee8ad), STCP(0x7ef05860, 0x1072a048), STCP(0x7ee34636, 0x10d64dbd),
+ STCP(0x7ed5e5c6, 0x1139f0cf), STCP(0x7ec8371a, 0x119d8941), STCP(0x7eba3a39, 0x120116d5), STCP(0x7eabef2c, 0x1264994e),
+ STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e8e6eb2, 0x132b7bf9), STCP(0x7e7f3957, 0x138edbb1), STCP(0x7e6fb5f4, 0x13f22f58),
+ STCP(0x7e5fe493, 0x145576b1), STCP(0x7e4fc53e, 0x14b8b17f), STCP(0x7e3f57ff, 0x151bdf86), STCP(0x7e2e9cdf, 0x157f0086),
+ STCP(0x7e1d93ea, 0x15e21445), STCP(0x7e0c3d29, 0x16451a83), STCP(0x7dfa98a8, 0x16a81305), STCP(0x7de8a670, 0x170afd8d),
+ STCP(0x7dd6668f, 0x176dd9de), STCP(0x7dc3d90d, 0x17d0a7bc), STCP(0x7db0fdf8, 0x183366e9), STCP(0x7d9dd55a, 0x18961728),
+ STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d769bb5, 0x195b49ea), STCP(0x7d628ac6, 0x19bdcbf3), STCP(0x7d4e2c7f, 0x1a203e1b),
+ STCP(0x7d3980ec, 0x1a82a026), STCP(0x7d24881b, 0x1ae4f1d6), STCP(0x7d0f4218, 0x1b4732ef), STCP(0x7cf9aef0, 0x1ba96335),
+ STCP(0x7ce3ceb2, 0x1c0b826a), STCP(0x7ccda169, 0x1c6d9053), STCP(0x7cb72724, 0x1ccf8cb3), STCP(0x7ca05ff1, 0x1d31774d),
+ STCP(0x7c894bde, 0x1d934fe5), STCP(0x7c71eaf9, 0x1df5163f), STCP(0x7c5a3d50, 0x1e56ca1e), STCP(0x7c4242f2, 0x1eb86b46),
+ STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c116853, 0x1f7b7481), STCP(0x7bf88830, 0x1fdcdc1b), STCP(0x7bdf5b94, 0x203e300d),
+ STCP(0x7bc5e290, 0x209f701c), STCP(0x7bac1d31, 0x21009c0c), STCP(0x7b920b89, 0x2161b3a0), STCP(0x7b77ada8, 0x21c2b69c),
+ STCP(0x7b5d039e, 0x2223a4c5), STCP(0x7b420d7a, 0x22847de0), STCP(0x7b26cb4f, 0x22e541af), STCP(0x7b0b3d2c, 0x2345eff8),
+ STCP(0x7aef6323, 0x23a6887f), STCP(0x7ad33d45, 0x24070b08), STCP(0x7ab6cba4, 0x24677758), STCP(0x7a9a0e50, 0x24c7cd33),
+ STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a5fb0d8, 0x2588349d), STCP(0x7a4210d8, 0x25e845b6), STCP(0x7a24256f, 0x26483f6c),
+ STCP(0x7a05eead, 0x26a82186), STCP(0x79e76ca7, 0x2707ebc7), STCP(0x79c89f6e, 0x27679df4), STCP(0x79a98715, 0x27c737d3),
+ STCP(0x798a23b1, 0x2826b928), STCP(0x796a7554, 0x288621b9), STCP(0x794a7c12, 0x28e5714b), STCP(0x792a37fe, 0x2944a7a2),
+ STCP(0x7909a92d, 0x29a3c485), STCP(0x78e8cfb2, 0x2a02c7b8), STCP(0x78c7aba2, 0x2a61b101), STCP(0x78a63d11, 0x2ac08026),
+ STCP(0x78848414, 0x2b1f34eb), STCP(0x786280bf, 0x2b7dcf17), STCP(0x78403329, 0x2bdc4e6f), STCP(0x781d9b65, 0x2c3ab2b9),
+ STCP(0x77fab989, 0x2c98fbba), STCP(0x77d78daa, 0x2cf72939), STCP(0x77b417df, 0x2d553afc), STCP(0x7790583e, 0x2db330c7),
+ STCP(0x776c4edb, 0x2e110a62), STCP(0x7747fbce, 0x2e6ec792), STCP(0x77235f2d, 0x2ecc681e), STCP(0x76fe790e, 0x2f29ebcc),
+ STCP(0x76d94989, 0x2f875262), STCP(0x76b3d0b4, 0x2fe49ba7), STCP(0x768e0ea6, 0x3041c761), STCP(0x76680376, 0x309ed556),
+ STCP(0x7641af3d, 0x30fbc54d), STCP(0x761b1211, 0x3158970e), STCP(0x75f42c0b, 0x31b54a5e), STCP(0x75ccfd42, 0x3211df04),
+ STCP(0x75a585cf, 0x326e54c7), STCP(0x757dc5ca, 0x32caab6f), STCP(0x7555bd4c, 0x3326e2c3), STCP(0x752d6c6c, 0x3382fa88),
+ STCP(0x7504d345, 0x33def287), STCP(0x74dbf1ef, 0x343aca87), STCP(0x74b2c884, 0x34968250), STCP(0x7489571c, 0x34f219a8),
+ STCP(0x745f9dd1, 0x354d9057), STCP(0x74359cbd, 0x35a8e625), STCP(0x740b53fb, 0x36041ad9), STCP(0x73e0c3a3, 0x365f2e3b),
+ STCP(0x73b5ebd1, 0x36ba2014), STCP(0x738acc9e, 0x3714f02a), STCP(0x735f6626, 0x376f9e46), STCP(0x7333b883, 0x37ca2a30),
+ STCP(0x7307c3d0, 0x382493b0), STCP(0x72db8828, 0x387eda8e), STCP(0x72af05a7, 0x38d8fe93), STCP(0x72823c67, 0x3932ff87),
+ STCP(0x72552c85, 0x398cdd32), STCP(0x7227d61c, 0x39e6975e), STCP(0x71fa3949, 0x3a402dd2), STCP(0x71cc5626, 0x3a99a057),
+ STCP(0x719e2cd2, 0x3af2eeb7), STCP(0x716fbd68, 0x3b4c18ba), STCP(0x71410805, 0x3ba51e29), STCP(0x71120cc5, 0x3bfdfecd),
+ STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70b34525, 0x3caf50da), STCP(0x708378ff, 0x3d07c1d6), STCP(0x70536771, 0x3d600d2c),
+ STCP(0x7023109a, 0x3db832a6), STCP(0x6ff27497, 0x3e10320d), STCP(0x6fc19385, 0x3e680b2c), STCP(0x6f906d84, 0x3ebfbdcd),
+ STCP(0x6f5f02b2, 0x3f1749b8), STCP(0x6f2d532c, 0x3f6eaeb8), STCP(0x6efb5f12, 0x3fc5ec98), STCP(0x6ec92683, 0x401d0321),
+ STCP(0x6e96a99d, 0x4073f21d), STCP(0x6e63e87f, 0x40cab958), STCP(0x6e30e34a, 0x4121589b), STCP(0x6dfd9a1c, 0x4177cfb1),
+ STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d963c54, 0x42244481), STCP(0x6d6227fa, 0x427a41d0), STCP(0x6d2dd027, 0x42d0161e),
+ STCP(0x6cf934fc, 0x4325c135), STCP(0x6cc45698, 0x437b42e1), STCP(0x6c8f351c, 0x43d09aed), STCP(0x6c59d0a9, 0x4425c923),
+ STCP(0x6c242960, 0x447acd50), STCP(0x6bee3f62, 0x44cfa740), STCP(0x6bb812d1, 0x452456bd), STCP(0x6b81a3cd, 0x4578db93),
+ STCP(0x6b4af279, 0x45cd358f), STCP(0x6b13fef5, 0x4621647d), STCP(0x6adcc964, 0x46756828), STCP(0x6aa551e9, 0x46c9405c),
+ STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a359db9, 0x47706d93), STCP(0x69fd614a, 0x47c3c22f), STCP(0x69c4e37a, 0x4816ea86),
+ STCP(0x698c246c, 0x4869e665), STCP(0x69532442, 0x48bcb599), STCP(0x6919e320, 0x490f57ee), STCP(0x68e06129, 0x4961cd33),
+ STCP(0x68a69e81, 0x49b41533), STCP(0x686c9b4b, 0x4a062fbd), STCP(0x683257ab, 0x4a581c9e), STCP(0x67f7d3c5, 0x4aa9dba2),
+ STCP(0x67bd0fbd, 0x4afb6c98), STCP(0x67820bb7, 0x4b4ccf4d), STCP(0x6746c7d8, 0x4b9e0390), STCP(0x670b4444, 0x4bef092d),
+ STCP(0x66cf8120, 0x4c3fdff4), STCP(0x66937e91, 0x4c9087b1), STCP(0x66573cbb, 0x4ce10034), STCP(0x661abbc5, 0x4d31494b),
+ STCP(0x65ddfbd3, 0x4d8162c4), STCP(0x65a0fd0b, 0x4dd14c6e), STCP(0x6563bf92, 0x4e210617), STCP(0x6526438f, 0x4e708f8f),
+ STCP(0x64e88926, 0x4ebfe8a5), STCP(0x64aa907f, 0x4f0f1126), STCP(0x646c59bf, 0x4f5e08e3), STCP(0x642de50d, 0x4faccfab),
+ STCP(0x63ef3290, 0x4ffb654d), STCP(0x63b0426d, 0x5049c999), STCP(0x637114cc, 0x5097fc5e), STCP(0x6331a9d4, 0x50e5fd6d),
+ STCP(0x62f201ac, 0x5133cc94), STCP(0x62b21c7b, 0x518169a5), STCP(0x6271fa69, 0x51ced46e), STCP(0x62319b9d, 0x521c0cc2),
+ STCP(0x61f1003f, 0x5269126e), STCP(0x61b02876, 0x52b5e546), STCP(0x616f146c, 0x53028518), STCP(0x612dc447, 0x534ef1b5),
+ STCP(0x60ec3830, 0x539b2af0), STCP(0x60aa7050, 0x53e73097), STCP(0x60686ccf, 0x5433027d), STCP(0x60262dd6, 0x547ea073),
+ STCP(0x5fe3b38d, 0x54ca0a4b), STCP(0x5fa0fe1f, 0x55153fd4), STCP(0x5f5e0db3, 0x556040e2), STCP(0x5f1ae274, 0x55ab0d46),
+ STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e93dc1f, 0x56400758), STCP(0x5e50015d, 0x568a34a9), STCP(0x5e0bec6e, 0x56d42c99),
+ STCP(0x5dc79d7c, 0x571deefa), STCP(0x5d8314b1, 0x57677b9d), STCP(0x5d3e5237, 0x57b0d256), STCP(0x5cf95638, 0x57f9f2f8),
+ STCP(0x5cb420e0, 0x5842dd54), STCP(0x5c6eb258, 0x588b9140), STCP(0x5c290acc, 0x58d40e8c), STCP(0x5be32a67, 0x591c550e),
+ STCP(0x5b9d1154, 0x59646498), STCP(0x5b56bfbd, 0x59ac3cfd), STCP(0x5b1035cf, 0x59f3de12), STCP(0x5ac973b5, 0x5a3b47ab),
+ STCP(0x5a82799a, 0x5a82799a),
+};
+
+const PWord16 SineTable320[] =
+{
+ STCP(0x7fffffff, 0x00000000), STCP(0x7fff9aef, 0x00a0d951),
+ STCP(0x7ffe6bbf, 0x0141b1a5), STCP(0x7ffc726f, 0x01e287fc),
+ STCP(0x7ff9af04, 0x02835b5a), STCP(0x7ff62182, 0x03242abf),
+ STCP(0x7ff1c9ef, 0x03c4f52f), STCP(0x7feca851, 0x0465b9aa),
+ STCP(0x7fe6bcb0, 0x05067734), STCP(0x7fe00716, 0x05a72ccf),
+ STCP(0x7fd8878e, 0x0647d97c), STCP(0x7fd03e23, 0x06e87c3f),
+ STCP(0x7fc72ae2, 0x07891418), STCP(0x7fbd4dda, 0x0829a00c),
+ STCP(0x7fb2a71b, 0x08ca1f1b), STCP(0x7fa736b4, 0x096a9049),
+ STCP(0x7f9afcb9, 0x0a0af299), STCP(0x7f8df93c, 0x0aab450d),
+ STCP(0x7f802c52, 0x0b4b86a8), STCP(0x7f719611, 0x0bebb66c),
+ STCP(0x7f62368f, 0x0c8bd35e), STCP(0x7f520de6, 0x0d2bdc80),
+ STCP(0x7f411c2f, 0x0dcbd0d5), STCP(0x7f2f6183, 0x0e6baf61),
+ STCP(0x7f1cde01, 0x0f0b7727), STCP(0x7f0991c4, 0x0fab272b),
+ STCP(0x7ef57cea, 0x104abe71), STCP(0x7ee09f95, 0x10ea3bfd),
+ STCP(0x7ecaf9e5, 0x11899ed3), STCP(0x7eb48bfb, 0x1228e5f8),
+ STCP(0x7e9d55fc, 0x12c8106f), STCP(0x7e85580c, 0x13671d3d),
+ STCP(0x7e6c9251, 0x14060b68), STCP(0x7e5304f2, 0x14a4d9f4),
+ STCP(0x7e38b017, 0x154387e6), STCP(0x7e1d93ea, 0x15e21445),
+ STCP(0x7e01b096, 0x16807e15), STCP(0x7de50646, 0x171ec45c),
+ STCP(0x7dc79529, 0x17bce621), STCP(0x7da95d6c, 0x185ae269),
+ STCP(0x7d8a5f40, 0x18f8b83c), STCP(0x7d6a9ad5, 0x199666a0),
+ STCP(0x7d4a105d, 0x1a33ec9c), STCP(0x7d28c00c, 0x1ad14938),
+ STCP(0x7d06aa16, 0x1b6e7b7a), STCP(0x7ce3ceb2, 0x1c0b826a),
+ STCP(0x7cc02e15, 0x1ca85d12), STCP(0x7c9bc87a, 0x1d450a78),
+ STCP(0x7c769e18, 0x1de189a6), STCP(0x7c50af2b, 0x1e7dd9a4),
+ STCP(0x7c29fbee, 0x1f19f97b), STCP(0x7c02849f, 0x1fb5e836),
+ STCP(0x7bda497d, 0x2051a4dd), STCP(0x7bb14ac5, 0x20ed2e7b),
+ STCP(0x7b8788ba, 0x2188841a), STCP(0x7b5d039e, 0x2223a4c5),
+ STCP(0x7b31bbb2, 0x22be8f87), STCP(0x7b05b13d, 0x2359436c),
+ STCP(0x7ad8e482, 0x23f3bf7e), STCP(0x7aab55ca, 0x248e02cb),
+ STCP(0x7a7d055b, 0x25280c5e), STCP(0x7a4df380, 0x25c1db44),
+ STCP(0x7a1e2082, 0x265b6e8a), STCP(0x79ed8cad, 0x26f4c53e),
+ STCP(0x79bc384d, 0x278dde6e), STCP(0x798a23b1, 0x2826b928),
+ STCP(0x79574f28, 0x28bf547b), STCP(0x7923bb01, 0x2957af74),
+ STCP(0x78ef678f, 0x29efc925), STCP(0x78ba5524, 0x2a87a09d),
+ STCP(0x78848414, 0x2b1f34eb), STCP(0x784df4b3, 0x2bb68522),
+ STCP(0x7816a759, 0x2c4d9050), STCP(0x77de9c5b, 0x2ce45589),
+ STCP(0x77a5d413, 0x2d7ad3de), STCP(0x776c4edb, 0x2e110a62),
+ STCP(0x77320d0d, 0x2ea6f827), STCP(0x76f70f05, 0x2f3c9c40),
+ STCP(0x76bb5521, 0x2fd1f5c1), STCP(0x767edfbe, 0x306703bf),
+ STCP(0x7641af3d, 0x30fbc54d), STCP(0x7603c3fd, 0x31903982),
+ STCP(0x75c51e61, 0x32245f72), STCP(0x7585becb, 0x32b83634),
+ STCP(0x7545a5a0, 0x334bbcde), STCP(0x7504d345, 0x33def287),
+ STCP(0x74c34820, 0x3471d647), STCP(0x74810499, 0x35046736),
+ STCP(0x743e0918, 0x3596a46c), STCP(0x73fa5607, 0x36288d03),
+ STCP(0x73b5ebd1, 0x36ba2014), STCP(0x7370cae2, 0x374b5cb9),
+ STCP(0x732af3a7, 0x37dc420c), STCP(0x72e4668f, 0x386ccf2a),
+ STCP(0x729d2409, 0x38fd032d), STCP(0x72552c85, 0x398cdd32),
+ STCP(0x720c8075, 0x3a1c5c57), STCP(0x71c3204c, 0x3aab7fb7),
+ STCP(0x71790c7e, 0x3b3a4672), STCP(0x712e457f, 0x3bc8afa5),
+ STCP(0x70e2cbc6, 0x3c56ba70), STCP(0x70969fca, 0x3ce465f3),
+ STCP(0x7049c203, 0x3d71b14d), STCP(0x6ffc32eb, 0x3dfe9ba1),
+ STCP(0x6fadf2fc, 0x3e8b240e), STCP(0x6f5f02b2, 0x3f1749b8),
+ STCP(0x6f0f6289, 0x3fa30bc1), STCP(0x6ebf12ff, 0x402e694c),
+ STCP(0x6e6e1492, 0x40b9617d), STCP(0x6e1c67c4, 0x4143f379),
+ STCP(0x6dca0d14, 0x41ce1e65), STCP(0x6d770506, 0x4257e166),
+ STCP(0x6d23501b, 0x42e13ba4), STCP(0x6cceeed8, 0x436a2c45),
+ STCP(0x6c79e1c2, 0x43f2b271), STCP(0x6c242960, 0x447acd50),
+ STCP(0x6bcdc639, 0x45027c0c), STCP(0x6b76b8d6, 0x4589bdcf),
+ STCP(0x6b1f01c0, 0x461091c2), STCP(0x6ac6a180, 0x4696f710),
+ STCP(0x6a6d98a4, 0x471cece7), STCP(0x6a13e7b8, 0x47a27271),
+ STCP(0x69b98f48, 0x482786dc), STCP(0x695e8fe5, 0x48ac2957),
+ STCP(0x6902ea1d, 0x4930590f), STCP(0x68a69e81, 0x49b41533),
+ STCP(0x6849ada3, 0x4a375cf5), STCP(0x67ec1817, 0x4aba2f84),
+ STCP(0x678dde6e, 0x4b3c8c12), STCP(0x672f013f, 0x4bbe71d1),
+ STCP(0x66cf8120, 0x4c3fdff4), STCP(0x666f5ea6, 0x4cc0d5ae),
+ STCP(0x660e9a6a, 0x4d415234), STCP(0x65ad3505, 0x4dc154bb),
+ STCP(0x654b2f10, 0x4e40dc79), STCP(0x64e88926, 0x4ebfe8a5),
+ STCP(0x648543e4, 0x4f3e7875), STCP(0x64215fe5, 0x4fbc8b22),
+ STCP(0x63bcddc7, 0x503a1fe5), STCP(0x6357be2a, 0x50b735f8),
+ STCP(0x62f201ac, 0x5133cc94), STCP(0x628ba8ef, 0x51afe2f6),
+ STCP(0x6224b495, 0x522b7859), STCP(0x61bd253f, 0x52a68bfb),
+ STCP(0x6154fb91, 0x53211d18), STCP(0x60ec3830, 0x539b2af0),
+ STCP(0x6082dbc1, 0x5414b4c1), STCP(0x6018e6eb, 0x548db9cb),
+ STCP(0x5fae5a55, 0x55063951), STCP(0x5f4336a7, 0x557e3292),
+ STCP(0x5ed77c8a, 0x55f5a4d2), STCP(0x5e6b2ca8, 0x566c8f55),
+ STCP(0x5dfe47ad, 0x56e2f15d), STCP(0x5d90ce45, 0x5758ca31),
+ STCP(0x5d22c11c, 0x57ce1917), STCP(0x5cb420e0, 0x5842dd54),
+ STCP(0x5c44ee40, 0x58b71632), STCP(0x5bd529eb, 0x592ac2f7),
+ STCP(0x5b64d492, 0x599de2ee), STCP(0x5af3eee6, 0x5a107561),
+ STCP(0x5a82799a, 0x5a82799a)
+};
+
+/*
+ Sine windows
+ */
+#define WTC(x) WORD322WORD16(x)
+
+#define WTCP(a,b) { { WTC(a), WTC(b) } }
+
+const PWord16 SineWindow10[5] =
+{
+ WTCP(0x7f9afcb9, 0x0a0af299), WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7641af3d, 0x30fbc54d), WTCP(0x6d23501b, 0x42e13ba4),
+ WTCP(0x6154fb91, 0x53211d18),
+};
+
+const PWord16 SineWindow16[8] =
+{
+ WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x78848414, 0x2b1f34eb),
+ WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x5ed77c8a, 0x55f5a4d2),
+};
+
+const PWord16 SineWindow20[10] =
+{
+ WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7b31bbb2, 0x22be8f87),
+ WTCP(0x7816a759, 0x2c4d9050), WTCP(0x743e0918, 0x3596a46c), WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6a6d98a4, 0x471cece7),
+ WTCP(0x648543e4, 0x4f3e7875), WTCP(0x5dfe47ad, 0x56e2f15d),
+};
+
+const PWord16 SineWindow30[15] =
+{
+ WTCP(0x7ff4c56f, 0x0359c428), WTCP(0x7f9afcb9, 0x0a0af299), WTCP(0x7ee7aa4c, 0x10b5150f), WTCP(0x7ddb4bfc, 0x17537e63),
+ WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7aba9ae6, 0x245a9d65), WTCP(0x78a879f4, 0x2aba2ee4), WTCP(0x7641af3d, 0x30fbc54d),
+ WTCP(0x7387ea23, 0x371afcd5), WTCP(0x707d1443, 0x3d1389cb), WTCP(0x6d23501b, 0x42e13ba4), WTCP(0x697cf78a, 0x487fffe4),
+ WTCP(0x658c9a2d, 0x4debe4fe), WTCP(0x6154fb91, 0x53211d18), WTCP(0x5cd91140, 0x581c00b3),
+};
+
+const PWord16 SineWindow32[16] =
+{
+ WTCP(0x7ff62182, 0x03242abf), WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7e1d93ea, 0x15e21445),
+ WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x798a23b1, 0x2826b928), WTCP(0x776c4edb, 0x2e110a62),
+ WTCP(0x7504d345, 0x33def287), WTCP(0x72552c85, 0x398cdd32), WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6c242960, 0x447acd50),
+ WTCP(0x68a69e81, 0x49b41533), WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x60ec3830, 0x539b2af0), WTCP(0x5cb420e0, 0x5842dd54)
+};
+
+const PWord16 SineWindow40[20] =
+{
+ WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7ecaf9e5, 0x11899ed3),
+ WTCP(0x7e01b096, 0x16807e15), WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7a7d055b, 0x25280c5e),
+ WTCP(0x78ef678f, 0x29efc925), WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x732af3a7, 0x37dc420c),
+ WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6902ea1d, 0x4930590f),
+ WTCP(0x660e9a6a, 0x4d415234), WTCP(0x62f201ac, 0x5133cc94), WTCP(0x5fae5a55, 0x55063951), WTCP(0x5c44ee40, 0x58b71632),
+};
+
+const PWord16 SineWindow48[24] =
+{
+ WTCP(0x7ffb9d15, 0x02182427), WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7f92661d, 0x0a75d60e), WTCP(0x7f294bfd, 0x0ea0f48c),
+ WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7deeaa7a, 0x16ea0646), WTCP(0x7d1d7958, 0x1b05b40f), WTCP(0x7c29fbee, 0x1f19f97b),
+ WTCP(0x7b1474fd, 0x2325b847), WTCP(0x79dd3098, 0x2727d486), WTCP(0x78848414, 0x2b1f34eb), WTCP(0x770acdec, 0x2f0ac320),
+ WTCP(0x757075ac, 0x32e96c09), WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x71dba9ab, 0x3a7bd382), WTCP(0x6fe2313c, 0x3e2d7eb1),
+ WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6b93d02e, 0x455cb40c), WTCP(0x694015c3, 0x48d84609), WTCP(0x66cf8120, 0x4c3fdff4),
+ WTCP(0x6442bd7e, 0x4f9292dc), WTCP(0x619a7dce, 0x52cf758f), WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5bfa7b82, 0x590443a7)
+};
+
+const PWord16 SineWindow60[60] =
+{
+ WTCP(0x7ffd3154, 0x01aceb7c), WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7fb9d759, 0x085f2137), WTCP(0x7f76892f, 0x0bb65336),
+ WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7eace58a, 0x125df75b), WTCP(0x7e26b371, 0x15ad3e9a), WTCP(0x7d8a5f40, 0x18f8b83c),
+ WTCP(0x7cd80464, 0x1c3fd045), WTCP(0x7c0fc22a, 0x1f81f37c), WTCP(0x7b31bbb2, 0x22be8f87), WTCP(0x7a3e17f2, 0x25f51307),
+ WTCP(0x793501a9, 0x2924edac), WTCP(0x7816a759, 0x2c4d9050), WTCP(0x76e33b3f, 0x2f6e6d16), WTCP(0x759af34c, 0x3286f779),
+ WTCP(0x743e0918, 0x3596a46c), WTCP(0x72ccb9db, 0x389cea72), WTCP(0x71474660, 0x3b9941b1), WTCP(0x6fadf2fc, 0x3e8b240e),
+ WTCP(0x6e010780, 0x41720d46), WTCP(0x6c40cf2c, 0x444d7aff), WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x6887b5e2, 0x49dfe4c2),
+ WTCP(0x668f7c25, 0x4c95e688), WTCP(0x648543e4, 0x4f3e7875), WTCP(0x626968be, 0x51d92321), WTCP(0x603c496c, 0x54657194),
+ WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5bafc837, 0x595132a2),
+};
+
+const PWord16 SineWindow64[32] =
+{
+ WTCP(0x7ffd885a, 0x01921d20), WTCP(0x7fe9cbc0, 0x04b6195d), WTCP(0x7fc25596, 0x07d95b9e), WTCP(0x7f872bf3, 0x0afb6805),
+ WTCP(0x7f3857f6, 0x0e1bc2e4), WTCP(0x7ed5e5c6, 0x1139f0cf), WTCP(0x7e5fe493, 0x145576b1), WTCP(0x7dd6668f, 0x176dd9de),
+ WTCP(0x7d3980ec, 0x1a82a026), WTCP(0x7c894bde, 0x1d934fe5), WTCP(0x7bc5e290, 0x209f701c), WTCP(0x7aef6323, 0x23a6887f),
+ WTCP(0x7a05eead, 0x26a82186), WTCP(0x7909a92d, 0x29a3c485), WTCP(0x77fab989, 0x2c98fbba), WTCP(0x76d94989, 0x2f875262),
+ WTCP(0x75a585cf, 0x326e54c7), WTCP(0x745f9dd1, 0x354d9057), WTCP(0x7307c3d0, 0x382493b0), WTCP(0x719e2cd2, 0x3af2eeb7),
+ WTCP(0x7023109a, 0x3db832a6), WTCP(0x6e96a99d, 0x4073f21d), WTCP(0x6cf934fc, 0x4325c135), WTCP(0x6b4af279, 0x45cd358f),
+ WTCP(0x698c246c, 0x4869e665), WTCP(0x67bd0fbd, 0x4afb6c98), WTCP(0x65ddfbd3, 0x4d8162c4), WTCP(0x63ef3290, 0x4ffb654d),
+ WTCP(0x61f1003f, 0x5269126e), WTCP(0x5fe3b38d, 0x54ca0a4b), WTCP(0x5dc79d7c, 0x571deefa), WTCP(0x5b9d1154, 0x59646498),
+};
+
+const PWord16 SineWindow80[40] =
+{
+ WTCP(0x7ffe6bbf, 0x0141b1a5), WTCP(0x7ff1c9ef, 0x03c4f52f), WTCP(0x7fd8878e, 0x0647d97c), WTCP(0x7fb2a71b, 0x08ca1f1b),
+ WTCP(0x7f802c52, 0x0b4b86a8), WTCP(0x7f411c2f, 0x0dcbd0d5), WTCP(0x7ef57cea, 0x104abe71), WTCP(0x7e9d55fc, 0x12c8106f),
+ WTCP(0x7e38b017, 0x154387e6), WTCP(0x7dc79529, 0x17bce621), WTCP(0x7d4a105d, 0x1a33ec9c), WTCP(0x7cc02e15, 0x1ca85d12),
+ WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7b8788ba, 0x2188841a), WTCP(0x7ad8e482, 0x23f3bf7e), WTCP(0x7a1e2082, 0x265b6e8a),
+ WTCP(0x79574f28, 0x28bf547b), WTCP(0x78848414, 0x2b1f34eb), WTCP(0x77a5d413, 0x2d7ad3de), WTCP(0x76bb5521, 0x2fd1f5c1),
+ WTCP(0x75c51e61, 0x32245f72), WTCP(0x74c34820, 0x3471d647), WTCP(0x73b5ebd1, 0x36ba2014), WTCP(0x729d2409, 0x38fd032d),
+ WTCP(0x71790c7e, 0x3b3a4672), WTCP(0x7049c203, 0x3d71b14d), WTCP(0x6f0f6289, 0x3fa30bc1), WTCP(0x6dca0d14, 0x41ce1e65),
+ WTCP(0x6c79e1c2, 0x43f2b271), WTCP(0x6b1f01c0, 0x461091c2), WTCP(0x69b98f48, 0x482786dc), WTCP(0x6849ada3, 0x4a375cf5),
+ WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x654b2f10, 0x4e40dc79), WTCP(0x63bcddc7, 0x503a1fe5), WTCP(0x6224b495, 0x522b7859),
+ WTCP(0x6082dbc1, 0x5414b4c1), WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5d22c11c, 0x57ce1917), WTCP(0x5b64d492, 0x599de2ee),
+};
+
+const PWord16 SineWindow70[35] =
+{
+ WTCP(0x7ffdeffe, 0x016fa5fd), WTCP(0x7fed7058, 0x044ec292), WTCP(0x7fcc732b, 0x072d5101), WTCP(0x7f9afcb9, 0x0a0af299),
+ WTCP(0x7f591361, 0x0ce748ca), WTCP(0x7f06bfa3, 0x0fc1f52d), WTCP(0x7ea40c1b, 0x129a9991), WTCP(0x7e310583, 0x1570d80b),
+ WTCP(0x7dadbaaf, 0x184452fd), WTCP(0x7d1a3c8a, 0x1b14ad24), WTCP(0x7c769e18, 0x1de189a6), WTCP(0x7bc2f470, 0x20aa8c19),
+ WTCP(0x7aff56bc, 0x236f5896), WTCP(0x7a2bde32, 0x262f93be), WTCP(0x7948a614, 0x28eae2cb), WTCP(0x7855cbae, 0x2ba0eb97),
+ WTCP(0x77536e4c, 0x2e5154ac), WTCP(0x7641af3d, 0x30fbc54d), WTCP(0x7520b1ca, 0x339fe582), WTCP(0x73f09b33, 0x363d5e23),
+ WTCP(0x72b192ac, 0x38d3d8e3), WTCP(0x7163c154, 0x3b63005e), WTCP(0x70075233, 0x3dea8020), WTCP(0x6e9c7233, 0x406a04b2),
+ WTCP(0x6d23501b, 0x42e13ba4), WTCP(0x6b9c1c87, 0x454fd398), WTCP(0x6a0709e6, 0x47b57c4e), WTCP(0x68644c6e, 0x4a11e6aa),
+ WTCP(0x66b41a1a, 0x4c64c4c4), WTCP(0x64f6aa9f, 0x4eadc9ee), WTCP(0x632c3769, 0x50ecaabd), WTCP(0x6154fb91, 0x53211d18),
+ WTCP(0x5f7133d4, 0x554ad83c), WTCP(0x5d811e90, 0x576994c8), WTCP(0x5b84fbb6, 0x597d0cc7)
+};
+
+const PWord16 SineWindow96[48] =
+{
+ WTCP(0x7ffee744, 0x010c1460), WTCP(0x7ff62182, 0x03242abf), WTCP(0x7fe49698, 0x053c0a01), WTCP(0x7fca47b9, 0x07538d6b),
+ WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f7b65ef, 0x0b80edf1), WTCP(0x7f46d86c, 0x0d9681c2), WTCP(0x7f0991c4, 0x0fab272b),
+ WTCP(0x7ec3962a, 0x11beb9aa), WTCP(0x7e74ea6a, 0x13d114d0), WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7dbd98a4, 0x17f193c5),
+ WTCP(0x7d54ff2e, 0x19ff6f2a), WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7c6a0ef2, 0x1e15a99a), WTCP(0x7be7c847, 0x201dc0ef),
+ WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7ac9ca7a, 0x2427319d), WTCP(0x7a2e26f2, 0x26284422), WTCP(0x798a23b1, 0x2826b928),
+ WTCP(0x78ddcbf5, 0x2a226db5), WTCP(0x78292b8d, 0x2c1b3efb), WTCP(0x776c4edb, 0x2e110a62), WTCP(0x76a742d1, 0x3003ad85),
+ WTCP(0x75da14ef, 0x31f30638), WTCP(0x7504d345, 0x33def287), WTCP(0x74278c72, 0x35c750bc), WTCP(0x73424fa0, 0x37abff5d),
+ WTCP(0x72552c85, 0x398cdd32), WTCP(0x71603361, 0x3b69c947), WTCP(0x706374ff, 0x3d42a2ec), WTCP(0x6f5f02b2, 0x3f1749b8),
+ WTCP(0x6e52ee52, 0x40e79d8c), WTCP(0x6d3f4a40, 0x42b37e96), WTCP(0x6c242960, 0x447acd50), WTCP(0x6b019f1a, 0x463d6a87),
+ WTCP(0x69d7bf57, 0x47fb3757), WTCP(0x68a69e81, 0x49b41533), WTCP(0x676e5183, 0x4b67e5e4), WTCP(0x662eedc3, 0x4d168b8b),
+ WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x639b3a0b, 0x5063e008), WTCP(0x62471749, 0x520254ef), WTCP(0x60ec3830, 0x539b2af0),
+ WTCP(0x5f8ab487, 0x552e4605), WTCP(0x5e22a487, 0x56bb8a90), WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5b3f42ae, 0x59c42381)
+};
+
+const PWord16 SineWindow112[56] =
+{
+ WTCP(0x7fff31bf, 0x00e5c87e), WTCP(0x7ff8bfc7, 0x02b14de9), WTCP(0x7febdc2a, 0x047cb09e), WTCP(0x7fd8878e, 0x0647d97c),
+ WTCP(0x7fbec2ec, 0x0812b164), WTCP(0x7f9e8f91, 0x09dd213a), WTCP(0x7f77ef1c, 0x0ba711ea), WTCP(0x7f4ae37e, 0x0d706c64),
+ WTCP(0x7f176efc, 0x0f3919a0), WTCP(0x7edd942d, 0x110102a0), WTCP(0x7e9d55fc, 0x12c8106f), WTCP(0x7e56b7a4, 0x148e2c22),
+ WTCP(0x7e09bcb4, 0x16533edc), WTCP(0x7db6690c, 0x181731cd), WTCP(0x7d5cc0df, 0x19d9ee32), WTCP(0x7cfcc8af, 0x1b9b5d5a),
+ WTCP(0x7c968552, 0x1d5b68a2), WTCP(0x7c29fbee, 0x1f19f97b), WTCP(0x7bb731fb, 0x20d6f969), WTCP(0x7b3e2d40, 0x22925203),
+ WTCP(0x7abef3d5, 0x244becf6), WTCP(0x7a398c22, 0x2603b406), WTCP(0x79adfcdf, 0x27b9910e), WTCP(0x791c4d13, 0x296d6e00),
+ WTCP(0x78848414, 0x2b1f34eb), WTCP(0x77e6a986, 0x2ccecff7), WTCP(0x7742c55c, 0x2e7c2969), WTCP(0x7698dfd8, 0x30272ba0),
+ WTCP(0x75e90186, 0x31cfc11e), WTCP(0x75333343, 0x3375d481), WTCP(0x74777e35, 0x35195088), WTCP(0x73b5ebd1, 0x36ba2014),
+ WTCP(0x72ee85d5, 0x38582e27), WTCP(0x7221564d, 0x39f365e9), WTCP(0x714e678c, 0x3b8bb2a3), WTCP(0x7075c433, 0x3d20ffc8),
+ WTCP(0x6f977729, 0x3eb338ef), WTCP(0x6eb38ba1, 0x404249d5), WTCP(0x6dca0d14, 0x41ce1e65), WTCP(0x6cdb0745, 0x4356a2ad),
+ WTCP(0x6be6863c, 0x44dbc2ec), WTCP(0x6aec9649, 0x465d6b89), WTCP(0x69ed4403, 0x47db8918), WTCP(0x68e89c43, 0x4956085b),
+ WTCP(0x67deac2c, 0x4accd644), WTCP(0x66cf8120, 0x4c3fdff4), WTCP(0x65bb28c7, 0x4daf12ba), WTCP(0x64a1b10b, 0x4f1a5c1a),
+ WTCP(0x6383281a, 0x5081a9c9), WTCP(0x625f9c5f, 0x51e4e9ae), WTCP(0x61371c8b, 0x534409e8), WTCP(0x6009b78a, 0x549ef8c6),
+ WTCP(0x5ed77c8a, 0x55f5a4d2), WTCP(0x5da07af6, 0x5747fcca), WTCP(0x5c64c278, 0x5895efa4), WTCP(0x5b2462f5, 0x59df6c8f)
+};
+
+const PWord16 SineWindow120[60] =
+{
+ WTCP(0x7fff4c54, 0x00d676eb), WTCP(0x7ff9af04, 0x02835b5a), WTCP(0x7fee74a2, 0x0430238f), WTCP(0x7fdd9dad, 0x05dcbcbe),
+ WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7fab1d3d, 0x093516d4), WTCP(0x7f8975f9, 0x0ae0b22c), WTCP(0x7f62368f, 0x0c8bd35e),
+ WTCP(0x7f3560b9, 0x0e3667ad), WTCP(0x7f02f66f, 0x0fe05c64), WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7e8d6d91, 0x13321c53),
+ WTCP(0x7e4a5426, 0x14d9c245), WTCP(0x7e01b096, 0x16807e15), WTCP(0x7db3860f, 0x18263d36), WTCP(0x7d5fd801, 0x19caed29),
+ WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7ca80038, 0x1d10d5c2), WTCP(0x7c43de8e, 0x1eb1e9a7), WTCP(0x7bda497d, 0x2051a4dd),
+ WTCP(0x7b6b45a5, 0x21eff528), WTCP(0x7af6d7e6, 0x238cc85d), WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x79fdd35c, 0x26c1af22),
+ WTCP(0x7979477d, 0x28599eb0), WTCP(0x78ef678f, 0x29efc925), WTCP(0x7860399e, 0x2b841caf), WTCP(0x77cbc3f2, 0x2d168792),
+ WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x76931bae, 0x30355cdd), WTCP(0x75eef6ce, 0x31c1a43b), WTCP(0x7545a5a0, 0x334bbcde),
+ WTCP(0x74972f92, 0x34d3957e), WTCP(0x73e39c49, 0x36591cea), WTCP(0x732af3a7, 0x37dc420c), WTCP(0x726d3dc6, 0x395cf3e9),
+ WTCP(0x71aa82f7, 0x3adb21a1), WTCP(0x70e2cbc6, 0x3c56ba70), WTCP(0x701620f5, 0x3dcfadb0), WTCP(0x6f448b7e, 0x3f45ead8),
+ WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6d92c59b, 0x422a0154), WTCP(0x6cb2a837, 0x4397ba32), WTCP(0x6bcdc639, 0x45027c0c),
+ WTCP(0x6ae429ae, 0x466a36f9), WTCP(0x69f5dcd3, 0x47cedb31), WTCP(0x6902ea1d, 0x4930590f), WTCP(0x680b5c33, 0x4a8ea111),
+ WTCP(0x670f3df3, 0x4be9a3db), WTCP(0x660e9a6a, 0x4d415234), WTCP(0x65097cdb, 0x4e959d08), WTCP(0x63fff0ba, 0x4fe6756a),
+ WTCP(0x62f201ac, 0x5133cc94), WTCP(0x61dfbb8a, 0x527d93e6), WTCP(0x60c92a5a, 0x53c3bcea), WTCP(0x5fae5a55, 0x55063951),
+ WTCP(0x5e8f57e2, 0x5644faf4), WTCP(0x5d6c2f99, 0x577ff3da), WTCP(0x5c44ee40, 0x58b71632), WTCP(0x5b19a0c8, 0x59ea5454),
+};
+
+const PWord16 SineWindow128[64] =
+{
+ WTCP(0x7fff6216, 0x00c90f88), WTCP(0x7ffa72d1, 0x025b26d7), WTCP(0x7ff09478, 0x03ed26e6), WTCP(0x7fe1c76b, 0x057f0035),
+ WTCP(0x7fce0c3e, 0x0710a345), WTCP(0x7fb563b3, 0x08a2009a), WTCP(0x7f97cebd, 0x0a3308bd), WTCP(0x7f754e80, 0x0bc3ac35),
+ WTCP(0x7f4de451, 0x0d53db92), WTCP(0x7f2191b4, 0x0ee38766), WTCP(0x7ef05860, 0x1072a048), WTCP(0x7eba3a39, 0x120116d5),
+ WTCP(0x7e7f3957, 0x138edbb1), WTCP(0x7e3f57ff, 0x151bdf86), WTCP(0x7dfa98a8, 0x16a81305), WTCP(0x7db0fdf8, 0x183366e9),
+ WTCP(0x7d628ac6, 0x19bdcbf3), WTCP(0x7d0f4218, 0x1b4732ef), WTCP(0x7cb72724, 0x1ccf8cb3), WTCP(0x7c5a3d50, 0x1e56ca1e),
+ WTCP(0x7bf88830, 0x1fdcdc1b), WTCP(0x7b920b89, 0x2161b3a0), WTCP(0x7b26cb4f, 0x22e541af), WTCP(0x7ab6cba4, 0x24677758),
+ WTCP(0x7a4210d8, 0x25e845b6), WTCP(0x79c89f6e, 0x27679df4), WTCP(0x794a7c12, 0x28e5714b), WTCP(0x78c7aba2, 0x2a61b101),
+ WTCP(0x78403329, 0x2bdc4e6f), WTCP(0x77b417df, 0x2d553afc), WTCP(0x77235f2d, 0x2ecc681e), WTCP(0x768e0ea6, 0x3041c761),
+ WTCP(0x75f42c0b, 0x31b54a5e), WTCP(0x7555bd4c, 0x3326e2c3), WTCP(0x74b2c884, 0x34968250), WTCP(0x740b53fb, 0x36041ad9),
+ WTCP(0x735f6626, 0x376f9e46), WTCP(0x72af05a7, 0x38d8fe93), WTCP(0x71fa3949, 0x3a402dd2), WTCP(0x71410805, 0x3ba51e29),
+ WTCP(0x708378ff, 0x3d07c1d6), WTCP(0x6fc19385, 0x3e680b2c), WTCP(0x6efb5f12, 0x3fc5ec98), WTCP(0x6e30e34a, 0x4121589b),
+ WTCP(0x6d6227fa, 0x427a41d0), WTCP(0x6c8f351c, 0x43d09aed), WTCP(0x6bb812d1, 0x452456bd), WTCP(0x6adcc964, 0x46756828),
+ WTCP(0x69fd614a, 0x47c3c22f), WTCP(0x6919e320, 0x490f57ee), WTCP(0x683257ab, 0x4a581c9e), WTCP(0x6746c7d8, 0x4b9e0390),
+ WTCP(0x66573cbb, 0x4ce10034), WTCP(0x6563bf92, 0x4e210617), WTCP(0x646c59bf, 0x4f5e08e3), WTCP(0x637114cc, 0x5097fc5e),
+ WTCP(0x6271fa69, 0x51ced46e), WTCP(0x616f146c, 0x53028518), WTCP(0x60686ccf, 0x5433027d), WTCP(0x5f5e0db3, 0x556040e2),
+ WTCP(0x5e50015d, 0x568a34a9), WTCP(0x5d3e5237, 0x57b0d256), WTCP(0x5c290acc, 0x58d40e8c), WTCP(0x5b1035cf, 0x59f3de12),
+};
+
+const PWord16 SineWindow140[70] =
+{
+ WTCP(0x7fff7bff, 0x00b7d3bc), WTCP(0x7ffb5c00, 0x02277547), WTCP(0x7ff31c25, 0x0397050d), WTCP(0x7fe6bcb0, 0x05067734),
+ WTCP(0x7fd63e09, 0x0675bfe7), WTCP(0x7fc1a0b6, 0x07e4d34d), WTCP(0x7fa8e564, 0x0953a594), WTCP(0x7f8c0cdc, 0x0ac22ae8),
+ WTCP(0x7f6b180f, 0x0c30577a), WTCP(0x7f46080a, 0x0d9e1f7d), WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7eef9b46, 0x107852b2),
+ WTCP(0x7ebe414f, 0x11e4a65c), WTCP(0x7e88d1b4, 0x13506668), WTCP(0x7e4f4e2c, 0x14bb871b), WTCP(0x7e11b894, 0x1625fcc3),
+ WTCP(0x7dd012e6, 0x178fbbb1), WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7d409fe1, 0x1a60e6c3), WTCP(0x7cf2d72b, 0x1bc83baa),
+ WTCP(0x7ca1079d, 0x1d2eab5d), WTCP(0x7c4b33dc, 0x1e942a4d), WTCP(0x7bf15eac, 0x1ff8acf7), WTCP(0x7b938af1, 0x215c27dc),
+ WTCP(0x7b31bbb2, 0x22be8f87), WTCP(0x7acbf416, 0x241fd88e), WTCP(0x7a623764, 0x257ff78e), WTCP(0x79f48904, 0x26dee12c),
+ WTCP(0x7982ec80, 0x283c8a1b), WTCP(0x790d6581, 0x2998e716), WTCP(0x7893f7d1, 0x2af3ece2), WTCP(0x7816a759, 0x2c4d9050),
+ WTCP(0x77957822, 0x2da5c63e), WTCP(0x77106e58, 0x2efc8393), WTCP(0x76878e43, 0x3051bd43), WTCP(0x75fadc4d, 0x31a56850),
+ WTCP(0x756a5cff, 0x32f779c7), WTCP(0x74d61500, 0x3447e6c3), WTCP(0x743e0918, 0x3596a46c), WTCP(0x73a23e2d, 0x36e3a7fa),
+ WTCP(0x7302b945, 0x382ee6b0), WTCP(0x725f7f84, 0x397855e1), WTCP(0x71b8962b, 0x3abfeaf1), WTCP(0x710e029e, 0x3c059b4f),
+ WTCP(0x705fca59, 0x3d495c7e), WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6ef88241, 0x3fcae7a1), WTCP(0x6e3f7e01, 0x41089ce8),
+ WTCP(0x6d82ec32, 0x424439a6), WTCP(0x6cc2d2e9, 0x437db3b0), WTCP(0x6bff3855, 0x44b500eb), WTCP(0x6b3822c6, 0x45ea1750),
+ WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x699fa078, 0x484d77ce), WTCP(0x68ce40e4, 0x497bae33), WTCP(0x67f980a8, 0x4aa7865b),
+ WTCP(0x6721669f, 0x4bd0f69b), WTCP(0x6645f9c0, 0x4cf7f55d), WTCP(0x6567411d, 0x4e1c791f), WTCP(0x648543e4, 0x4f3e7875),
+ WTCP(0x63a0095c, 0x505dea05), WTCP(0x62b798ea, 0x517ac48c), WTCP(0x61cbfa0b, 0x5294fedd), WTCP(0x60dd3457, 0x53ac8fde),
+ WTCP(0x5feb4f7f, 0x54c16e8e), WTCP(0x5ef6534f, 0x55d391ff), WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5d033497, 0x57ef83e9),
+ WTCP(0x5c052224, 0x58f940fa), WTCP(0x5b041885, 0x5a002001)
+};
+
+const PWord16 SineWindow160[80] =
+{
+ WTCP(0x7fff9aef, 0x00a0d951), WTCP(0x7ffc726f, 0x01e287fc), WTCP(0x7ff62182, 0x03242abf), WTCP(0x7feca851, 0x0465b9aa),
+ WTCP(0x7fe00716, 0x05a72ccf), WTCP(0x7fd03e23, 0x06e87c3f), WTCP(0x7fbd4dda, 0x0829a00c), WTCP(0x7fa736b4, 0x096a9049),
+ WTCP(0x7f8df93c, 0x0aab450d), WTCP(0x7f719611, 0x0bebb66c), WTCP(0x7f520de6, 0x0d2bdc80), WTCP(0x7f2f6183, 0x0e6baf61),
+ WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7ee09f95, 0x10ea3bfd), WTCP(0x7eb48bfb, 0x1228e5f8), WTCP(0x7e85580c, 0x13671d3d),
+ WTCP(0x7e5304f2, 0x14a4d9f4), WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7de50646, 0x171ec45c), WTCP(0x7da95d6c, 0x185ae269),
+ WTCP(0x7d6a9ad5, 0x199666a0), WTCP(0x7d28c00c, 0x1ad14938), WTCP(0x7ce3ceb2, 0x1c0b826a), WTCP(0x7c9bc87a, 0x1d450a78),
+ WTCP(0x7c50af2b, 0x1e7dd9a4), WTCP(0x7c02849f, 0x1fb5e836), WTCP(0x7bb14ac5, 0x20ed2e7b), WTCP(0x7b5d039e, 0x2223a4c5),
+ WTCP(0x7b05b13d, 0x2359436c), WTCP(0x7aab55ca, 0x248e02cb), WTCP(0x7a4df380, 0x25c1db44), WTCP(0x79ed8cad, 0x26f4c53e),
+ WTCP(0x798a23b1, 0x2826b928), WTCP(0x7923bb01, 0x2957af74), WTCP(0x78ba5524, 0x2a87a09d), WTCP(0x784df4b3, 0x2bb68522),
+ WTCP(0x77de9c5b, 0x2ce45589), WTCP(0x776c4edb, 0x2e110a62), WTCP(0x76f70f05, 0x2f3c9c40), WTCP(0x767edfbe, 0x306703bf),
+ WTCP(0x7603c3fd, 0x31903982), WTCP(0x7585becb, 0x32b83634), WTCP(0x7504d345, 0x33def287), WTCP(0x74810499, 0x35046736),
+ WTCP(0x73fa5607, 0x36288d03), WTCP(0x7370cae2, 0x374b5cb9), WTCP(0x72e4668f, 0x386ccf2a), WTCP(0x72552c85, 0x398cdd32),
+ WTCP(0x71c3204c, 0x3aab7fb7), WTCP(0x712e457f, 0x3bc8afa5), WTCP(0x70969fca, 0x3ce465f3), WTCP(0x6ffc32eb, 0x3dfe9ba1),
+ WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6ebf12ff, 0x402e694c), WTCP(0x6e1c67c4, 0x4143f379), WTCP(0x6d770506, 0x4257e166),
+ WTCP(0x6cceeed8, 0x436a2c45), WTCP(0x6c242960, 0x447acd50), WTCP(0x6b76b8d6, 0x4589bdcf), WTCP(0x6ac6a180, 0x4696f710),
+ WTCP(0x6a13e7b8, 0x47a27271), WTCP(0x695e8fe5, 0x48ac2957), WTCP(0x68a69e81, 0x49b41533), WTCP(0x67ec1817, 0x4aba2f84),
+ WTCP(0x672f013f, 0x4bbe71d1), WTCP(0x666f5ea6, 0x4cc0d5ae), WTCP(0x65ad3505, 0x4dc154bb), WTCP(0x64e88926, 0x4ebfe8a5),
+ WTCP(0x64215fe5, 0x4fbc8b22), WTCP(0x6357be2a, 0x50b735f8), WTCP(0x628ba8ef, 0x51afe2f6), WTCP(0x61bd253f, 0x52a68bfb),
+ WTCP(0x60ec3830, 0x539b2af0), WTCP(0x6018e6eb, 0x548db9cb), WTCP(0x5f4336a7, 0x557e3292), WTCP(0x5e6b2ca8, 0x566c8f55),
+ WTCP(0x5d90ce45, 0x5758ca31), WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5bd529eb, 0x592ac2f7), WTCP(0x5af3eee6, 0x5a107561),
+};
+
+const PWord16 SineWindow180[90] =
+{
+ WTCP(0x7fffb026, 0x008efa17), WTCP(0x7ffd3154, 0x01aceb7c), WTCP(0x7ff833bd, 0x02cad485), WTCP(0x7ff0b77a, 0x03e8af9e),
+ WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7fda4391, 0x062425b6), WTCP(0x7fcb4c5b, 0x0741b592), WTCP(0x7fb9d759, 0x085f2137),
+ WTCP(0x7fa5e4e1, 0x097c6313), WTCP(0x7f8f7559, 0x0a997598), WTCP(0x7f76892f, 0x0bb65336), WTCP(0x7f5b20df, 0x0cd2f660),
+ WTCP(0x7f3d3cf4, 0x0def598a), WTCP(0x7f1cde01, 0x0f0b7727), WTCP(0x7efa04a8, 0x102749af), WTCP(0x7ed4b198, 0x1142cb98),
+ WTCP(0x7eace58a, 0x125df75b), WTCP(0x7e82a146, 0x1378c774), WTCP(0x7e55e59e, 0x1493365f), WTCP(0x7e26b371, 0x15ad3e9a),
+ WTCP(0x7df50bab, 0x16c6daa6), WTCP(0x7dc0ef44, 0x17e00505), WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7d515caf, 0x1a10eed3),
+ WTCP(0x7d15e8ad, 0x1b28a351), WTCP(0x7cd80464, 0x1c3fd045), WTCP(0x7c97b109, 0x1d56703c), WTCP(0x7c54efdc, 0x1e6c7dc7),
+ WTCP(0x7c0fc22a, 0x1f81f37c), WTCP(0x7bc8294d, 0x2096cbf1), WTCP(0x7b7e26aa, 0x21ab01c0), WTCP(0x7b31bbb2, 0x22be8f87),
+ WTCP(0x7ae2e9e4, 0x23d16fe8), WTCP(0x7a91b2c7, 0x24e39d85), WTCP(0x7a3e17f2, 0x25f51307), WTCP(0x79e81b06, 0x2705cb19),
+ WTCP(0x798fbdb0, 0x2815c06a), WTCP(0x793501a9, 0x2924edac), WTCP(0x78d7e8b6, 0x2a334d96), WTCP(0x787874a7, 0x2b40dae2),
+ WTCP(0x7816a759, 0x2c4d9050), WTCP(0x77b282b3, 0x2d5968a3), WTCP(0x774c08ab, 0x2e645ea1), WTCP(0x76e33b3f, 0x2f6e6d16),
+ WTCP(0x76781c7a, 0x30778ed2), WTCP(0x760aae73, 0x317fbeab), WTCP(0x759af34c, 0x3286f779), WTCP(0x7528ed32, 0x338d341b),
+ WTCP(0x74b49e5f, 0x34926f74), WTCP(0x743e0918, 0x3596a46c), WTCP(0x73c52fab, 0x3699cdf2), WTCP(0x734a1475, 0x379be6f6),
+ WTCP(0x72ccb9db, 0x389cea72), WTCP(0x724d224f, 0x399cd362), WTCP(0x71cb504e, 0x3a9b9cca), WTCP(0x71474660, 0x3b9941b1),
+ WTCP(0x70c10718, 0x3c95bd26), WTCP(0x70389514, 0x3d910a3c), WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6f212385, 0x3f8405bc),
+ WTCP(0x6e92296e, 0x407baa6a), WTCP(0x6e010780, 0x41720d46), WTCP(0x6d6dc08f, 0x42672981), WTCP(0x6cd8577a, 0x435afa54),
+ WTCP(0x6c40cf2c, 0x444d7aff), WTCP(0x6ba72a98, 0x453ea6c7), WTCP(0x6b0b6cbd, 0x462e78f9), WTCP(0x6a6d98a4, 0x471cece7),
+ WTCP(0x69cdb162, 0x4809fdeb), WTCP(0x692bba14, 0x48f5a767), WTCP(0x6887b5e2, 0x49dfe4c2), WTCP(0x67e1a7ff, 0x4ac8b16b),
+ WTCP(0x673993a9, 0x4bb008d9), WTCP(0x668f7c25, 0x4c95e688), WTCP(0x65e364c4, 0x4d7a45fe), WTCP(0x653550e2, 0x4e5d22c6),
+ WTCP(0x648543e4, 0x4f3e7875), WTCP(0x63d34137, 0x501e42a5), WTCP(0x631f4c54, 0x50fc7cfb), WTCP(0x626968be, 0x51d92321),
+ WTCP(0x61b19a00, 0x52b430c9), WTCP(0x60f7e3b0, 0x538da1ae), WTCP(0x603c496c, 0x54657194), WTCP(0x5f7ecedd, 0x553b9c45),
+ WTCP(0x5ebf77b5, 0x56101d94), WTCP(0x5dfe47ad, 0x56e2f15d), WTCP(0x5d3b428c, 0x57b41384), WTCP(0x5c766c1c, 0x58837ff4),
+ WTCP(0x5bafc837, 0x595132a2), WTCP(0x5ae75ab9, 0x5a1d278d),
+};
+
+
+const PWord16 SineWindow224[112] =
+{
+ WTCP(0x7fffcc70, 0x0072e46e), WTCP(0x7ffe2fee, 0x0158abd6), WTCP(0x7ffaf6f1, 0x023e6ee8), WTCP(0x7ff62182, 0x03242abf),
+ WTCP(0x7fefafb1, 0x0409dc76), WTCP(0x7fe7a192, 0x04ef8129), WTCP(0x7fddf741, 0x05d515f5), WTCP(0x7fd2b0da, 0x06ba97f4),
+ WTCP(0x7fc5ce84, 0x07a00445), WTCP(0x7fb75068, 0x08855802), WTCP(0x7fa736b4, 0x096a9049), WTCP(0x7f95819c, 0x0a4faa38),
+ WTCP(0x7f82315a, 0x0b34a2ec), WTCP(0x7f6d462b, 0x0c197784), WTCP(0x7f56c053, 0x0cfe251d), WTCP(0x7f3ea01a, 0x0de2a8d7),
+ WTCP(0x7f24e5cf, 0x0ec6ffd1), WTCP(0x7f0991c4, 0x0fab272b), WTCP(0x7eeca451, 0x108f1c07), WTCP(0x7ece1dd3, 0x1172db86),
+ WTCP(0x7eadfeae, 0x125662c9), WTCP(0x7e8c4748, 0x1339aef3), WTCP(0x7e68f80e, 0x141cbd28), WTCP(0x7e441171, 0x14ff8a8c),
+ WTCP(0x7e1d93ea, 0x15e21445), WTCP(0x7df57ff3, 0x16c45777), WTCP(0x7dcbd60e, 0x17a6514a), WTCP(0x7da096c2, 0x1887fee6),
+ WTCP(0x7d73c299, 0x19695d74), WTCP(0x7d455a24, 0x1a4a6a1c), WTCP(0x7d155df9, 0x1b2b220b), WTCP(0x7ce3ceb2, 0x1c0b826a),
+ WTCP(0x7cb0acef, 0x1ceb8869), WTCP(0x7c7bf954, 0x1dcb3134), WTCP(0x7c45b48d, 0x1eaa79fa), WTCP(0x7c0ddf47, 0x1f895fed),
+ WTCP(0x7bd47a36, 0x2067e03e), WTCP(0x7b998614, 0x2145f81f), WTCP(0x7b5d039e, 0x2223a4c5), WTCP(0x7b1ef397, 0x2300e366),
+ WTCP(0x7adf56c8, 0x23ddb139), WTCP(0x7a9e2dfd, 0x24ba0b76), WTCP(0x7a5b7a09, 0x2595ef56), WTCP(0x7a173bc2, 0x26715a16),
+ WTCP(0x79d17405, 0x274c48f2), WTCP(0x798a23b1, 0x2826b928), WTCP(0x79414bae, 0x2900a7f9), WTCP(0x78f6ece5, 0x29da12a7),
+ WTCP(0x78ab0847, 0x2ab2f674), WTCP(0x785d9ec8, 0x2b8b50a5), WTCP(0x780eb161, 0x2c631e82), WTCP(0x77be4111, 0x2d3a5d53),
+ WTCP(0x776c4edb, 0x2e110a62), WTCP(0x7718dbc8, 0x2ee722fb), WTCP(0x76c3e8e3, 0x2fbca46d), WTCP(0x766d773f, 0x30918c08),
+ WTCP(0x761587f3, 0x3165d71c), WTCP(0x75bc1c1a, 0x323982ff), WTCP(0x756134d4, 0x330c8d05), WTCP(0x7504d345, 0x33def287),
+ WTCP(0x74a6f899, 0x34b0b0df), WTCP(0x7447a5fc, 0x3581c569), WTCP(0x73e6dca3, 0x36522d83), WTCP(0x73849dc5, 0x3721e68d),
+ WTCP(0x7320ea9f, 0x37f0edea), WTCP(0x72bbc472, 0x38bf40ff), WTCP(0x72552c85, 0x398cdd32), WTCP(0x71ed2421, 0x3a59bfee),
+ WTCP(0x7183ac96, 0x3b25e69e), WTCP(0x7118c739, 0x3bf14eaf), WTCP(0x70ac7560, 0x3cbbf594), WTCP(0x703eb86a, 0x3d85d8bd),
+ WTCP(0x6fcf91b9, 0x3e4ef5a1), WTCP(0x6f5f02b2, 0x3f1749b8), WTCP(0x6eed0cc0, 0x3fded27c), WTCP(0x6e79b152, 0x40a58d69),
+ WTCP(0x6e04f1dd, 0x416b7801), WTCP(0x6d8ecfd8, 0x42308fc4), WTCP(0x6d174cc0, 0x42f4d237), WTCP(0x6c9e6a16, 0x43b83ce3),
+ WTCP(0x6c242960, 0x447acd50), WTCP(0x6ba88c28, 0x453c810d), WTCP(0x6b2b93fd, 0x45fd55a9), WTCP(0x6aad4270, 0x46bd48b7),
+ WTCP(0x6a2d9919, 0x477c57cb), WTCP(0x69ac9994, 0x483a807f), WTCP(0x692a4580, 0x48f7c06d), WTCP(0x68a69e81, 0x49b41533),
+ WTCP(0x6821a640, 0x4a6f7c74), WTCP(0x679b5e68, 0x4b29f3d1), WTCP(0x6713c8ac, 0x4be378f4), WTCP(0x668ae6bf, 0x4c9c0985),
+ WTCP(0x6600ba5b, 0x4d53a332), WTCP(0x6575453d, 0x4e0a43ab), WTCP(0x64e88926, 0x4ebfe8a5), WTCP(0x645a87dd, 0x4f748fd4),
+ WTCP(0x63cb432a, 0x502836f4), WTCP(0x633abcdc, 0x50dadbc1), WTCP(0x62a8f6c4, 0x518c7bfb), WTCP(0x6215f2b9, 0x523d1567),
+ WTCP(0x6181b292, 0x52eca5ca), WTCP(0x60ec3830, 0x539b2af0), WTCP(0x60558573, 0x5448a2a5), WTCP(0x5fbd9c41, 0x54f50abb),
+ WTCP(0x5f247e83, 0x55a06106), WTCP(0x5e8a2e27, 0x564aa35d), WTCP(0x5deead1f, 0x56f3cf9d), WTCP(0x5d51fd5e, 0x579be3a4),
+ WTCP(0x5cb420e0, 0x5842dd54), WTCP(0x5c15199f, 0x58e8ba94), WTCP(0x5b74e99d, 0x598d794c), WTCP(0x5ad392de, 0x5a31176a)
+};
+
+
+const PWord16 SineWindow256[128] =
+{
+ WTCP(0x7fffd886, 0x006487e3), WTCP(0x7ffe9cb2, 0x012d96b1), WTCP(0x7ffc250f, 0x01f6a297), WTCP(0x7ff871a2, 0x02bfa9a4),
+ WTCP(0x7ff38274, 0x0388a9ea), WTCP(0x7fed5791, 0x0451a177), WTCP(0x7fe5f108, 0x051a8e5c), WTCP(0x7fdd4eec, 0x05e36ea9),
+ WTCP(0x7fd37153, 0x06ac406f), WTCP(0x7fc85854, 0x077501be), WTCP(0x7fbc040a, 0x083db0a7), WTCP(0x7fae7495, 0x09064b3a),
+ WTCP(0x7f9faa15, 0x09cecf89), WTCP(0x7f8fa4b0, 0x0a973ba5), WTCP(0x7f7e648c, 0x0b5f8d9f), WTCP(0x7f6be9d4, 0x0c27c389),
+ WTCP(0x7f5834b7, 0x0cefdb76), WTCP(0x7f434563, 0x0db7d376), WTCP(0x7f2d1c0e, 0x0e7fa99e), WTCP(0x7f15b8ee, 0x0f475bff),
+ WTCP(0x7efd1c3c, 0x100ee8ad), WTCP(0x7ee34636, 0x10d64dbd), WTCP(0x7ec8371a, 0x119d8941), WTCP(0x7eabef2c, 0x1264994e),
+ WTCP(0x7e8e6eb2, 0x132b7bf9), WTCP(0x7e6fb5f4, 0x13f22f58), WTCP(0x7e4fc53e, 0x14b8b17f), WTCP(0x7e2e9cdf, 0x157f0086),
+ WTCP(0x7e0c3d29, 0x16451a83), WTCP(0x7de8a670, 0x170afd8d), WTCP(0x7dc3d90d, 0x17d0a7bc), WTCP(0x7d9dd55a, 0x18961728),
+ WTCP(0x7d769bb5, 0x195b49ea), WTCP(0x7d4e2c7f, 0x1a203e1b), WTCP(0x7d24881b, 0x1ae4f1d6), WTCP(0x7cf9aef0, 0x1ba96335),
+ WTCP(0x7ccda169, 0x1c6d9053), WTCP(0x7ca05ff1, 0x1d31774d), WTCP(0x7c71eaf9, 0x1df5163f), WTCP(0x7c4242f2, 0x1eb86b46),
+ WTCP(0x7c116853, 0x1f7b7481), WTCP(0x7bdf5b94, 0x203e300d), WTCP(0x7bac1d31, 0x21009c0c), WTCP(0x7b77ada8, 0x21c2b69c),
+ WTCP(0x7b420d7a, 0x22847de0), WTCP(0x7b0b3d2c, 0x2345eff8), WTCP(0x7ad33d45, 0x24070b08), WTCP(0x7a9a0e50, 0x24c7cd33),
+ WTCP(0x7a5fb0d8, 0x2588349d), WTCP(0x7a24256f, 0x26483f6c), WTCP(0x79e76ca7, 0x2707ebc7), WTCP(0x79a98715, 0x27c737d3),
+ WTCP(0x796a7554, 0x288621b9), WTCP(0x792a37fe, 0x2944a7a2), WTCP(0x78e8cfb2, 0x2a02c7b8), WTCP(0x78a63d11, 0x2ac08026),
+ WTCP(0x786280bf, 0x2b7dcf17), WTCP(0x781d9b65, 0x2c3ab2b9), WTCP(0x77d78daa, 0x2cf72939), WTCP(0x7790583e, 0x2db330c7),
+ WTCP(0x7747fbce, 0x2e6ec792), WTCP(0x76fe790e, 0x2f29ebcc), WTCP(0x76b3d0b4, 0x2fe49ba7), WTCP(0x76680376, 0x309ed556),
+ WTCP(0x761b1211, 0x3158970e), WTCP(0x75ccfd42, 0x3211df04), WTCP(0x757dc5ca, 0x32caab6f), WTCP(0x752d6c6c, 0x3382fa88),
+ WTCP(0x74dbf1ef, 0x343aca87), WTCP(0x7489571c, 0x34f219a8), WTCP(0x74359cbd, 0x35a8e625), WTCP(0x73e0c3a3, 0x365f2e3b),
+ WTCP(0x738acc9e, 0x3714f02a), WTCP(0x7333b883, 0x37ca2a30), WTCP(0x72db8828, 0x387eda8e), WTCP(0x72823c67, 0x3932ff87),
+ WTCP(0x7227d61c, 0x39e6975e), WTCP(0x71cc5626, 0x3a99a057), WTCP(0x716fbd68, 0x3b4c18ba), WTCP(0x71120cc5, 0x3bfdfecd),
+ WTCP(0x70b34525, 0x3caf50da), WTCP(0x70536771, 0x3d600d2c), WTCP(0x6ff27497, 0x3e10320d), WTCP(0x6f906d84, 0x3ebfbdcd),
+ WTCP(0x6f2d532c, 0x3f6eaeb8), WTCP(0x6ec92683, 0x401d0321), WTCP(0x6e63e87f, 0x40cab958), WTCP(0x6dfd9a1c, 0x4177cfb1),
+ WTCP(0x6d963c54, 0x42244481), WTCP(0x6d2dd027, 0x42d0161e), WTCP(0x6cc45698, 0x437b42e1), WTCP(0x6c59d0a9, 0x4425c923),
+ WTCP(0x6bee3f62, 0x44cfa740), WTCP(0x6b81a3cd, 0x4578db93), WTCP(0x6b13fef5, 0x4621647d), WTCP(0x6aa551e9, 0x46c9405c),
+ WTCP(0x6a359db9, 0x47706d93), WTCP(0x69c4e37a, 0x4816ea86), WTCP(0x69532442, 0x48bcb599), WTCP(0x68e06129, 0x4961cd33),
+ WTCP(0x686c9b4b, 0x4a062fbd), WTCP(0x67f7d3c5, 0x4aa9dba2), WTCP(0x67820bb7, 0x4b4ccf4d), WTCP(0x670b4444, 0x4bef092d),
+ WTCP(0x66937e91, 0x4c9087b1), WTCP(0x661abbc5, 0x4d31494b), WTCP(0x65a0fd0b, 0x4dd14c6e), WTCP(0x6526438f, 0x4e708f8f),
+ WTCP(0x64aa907f, 0x4f0f1126), WTCP(0x642de50d, 0x4faccfab), WTCP(0x63b0426d, 0x5049c999), WTCP(0x6331a9d4, 0x50e5fd6d),
+ WTCP(0x62b21c7b, 0x518169a5), WTCP(0x62319b9d, 0x521c0cc2), WTCP(0x61b02876, 0x52b5e546), WTCP(0x612dc447, 0x534ef1b5),
+ WTCP(0x60aa7050, 0x53e73097), WTCP(0x60262dd6, 0x547ea073), WTCP(0x5fa0fe1f, 0x55153fd4), WTCP(0x5f1ae274, 0x55ab0d46),
+ WTCP(0x5e93dc1f, 0x56400758), WTCP(0x5e0bec6e, 0x56d42c99), WTCP(0x5d8314b1, 0x57677b9d), WTCP(0x5cf95638, 0x57f9f2f8),
+ WTCP(0x5c6eb258, 0x588b9140), WTCP(0x5be32a67, 0x591c550e), WTCP(0x5b56bfbd, 0x59ac3cfd), WTCP(0x5ac973b5, 0x5a3b47ab),
+};
+
+const PWord16 SineWindow280[140] =
+{
+ WTCP(0x7fffdf00, 0x005be9f6), WTCP(0x7ffed6ff, 0x0113bd23), WTCP(0x7ffcc6ff, 0x01cb8e18), WTCP(0x7ff9af04, 0x02835b5a),
+ WTCP(0x7ff58f15, 0x033b236c), WTCP(0x7ff0673a, 0x03f2e4d4), WTCP(0x7fea377e, 0x04aa9e17), WTCP(0x7fe2ffee, 0x05624dba),
+ WTCP(0x7fdac098, 0x0619f243), WTCP(0x7fd1798e, 0x06d18a36), WTCP(0x7fc72ae2, 0x07891418), WTCP(0x7fbbd4aa, 0x08408e70),
+ WTCP(0x7faf76fe, 0x08f7f7c3), WTCP(0x7fa211f6, 0x09af4e96), WTCP(0x7f93a5af, 0x0a66916f), WTCP(0x7f843246, 0x0b1dbed5),
+ WTCP(0x7f73b7da, 0x0bd4d54d), WTCP(0x7f62368f, 0x0c8bd35e), WTCP(0x7f4fae88, 0x0d42b78f), WTCP(0x7f3c1fec, 0x0df98066),
+ WTCP(0x7f278ae1, 0x0eb02c6a), WTCP(0x7f11ef95, 0x0f66ba22), WTCP(0x7efb4e31, 0x101d2817), WTCP(0x7ee3a6e7, 0x10d374cf),
+ WTCP(0x7ecaf9e5, 0x11899ed3), WTCP(0x7eb1475f, 0x123fa4ab), WTCP(0x7e968f8b, 0x12f584e0), WTCP(0x7e7ad29e, 0x13ab3dfa),
+ WTCP(0x7e5e10d3, 0x1460ce82), WTCP(0x7e404a65, 0x15163503), WTCP(0x7e217f90, 0x15cb7006), WTCP(0x7e01b096, 0x16807e15),
+ WTCP(0x7de0ddb6, 0x17355dba), WTCP(0x7dbf0736, 0x17ea0d81), WTCP(0x7d9c2d5a, 0x189e8bf6), WTCP(0x7d78506a, 0x1952d7a3),
+ WTCP(0x7d5370b2, 0x1a06ef15), WTCP(0x7d2d8e7b, 0x1abad0d8), WTCP(0x7d06aa16, 0x1b6e7b7a), WTCP(0x7cdec3d2, 0x1c21ed87),
+ WTCP(0x7cb5dc00, 0x1cd5258f), WTCP(0x7c8bf2f7, 0x1d88221e), WTCP(0x7c61090b, 0x1e3ae1c5), WTCP(0x7c351e96, 0x1eed6311),
+ WTCP(0x7c0833f3, 0x1f9fa494), WTCP(0x7bda497d, 0x2051a4dd), WTCP(0x7bab5f93, 0x2103627d), WTCP(0x7b7b7697, 0x21b4dc06),
+ WTCP(0x7b4a8eeb, 0x2266100a), WTCP(0x7b18a8f4, 0x2316fd1b), WTCP(0x7ae5c518, 0x23c7a1cc), WTCP(0x7ab1e3c2, 0x2477fcb1),
+ WTCP(0x7a7d055b, 0x25280c5e), WTCP(0x7a472a51, 0x25d7cf68), WTCP(0x7a105313, 0x26874464), WTCP(0x79d88013, 0x273669e9),
+ WTCP(0x799fb1c2, 0x27e53e8e), WTCP(0x7965e897, 0x2893c0e9), WTCP(0x792b2508, 0x2941ef93), WTCP(0x78ef678f, 0x29efc925),
+ WTCP(0x78b2b0a7, 0x2a9d4c38), WTCP(0x787500ce, 0x2b4a7766), WTCP(0x78365881, 0x2bf7494a), WTCP(0x77f6b844, 0x2ca3c07f),
+ WTCP(0x77b62098, 0x2d4fdba2), WTCP(0x77749203, 0x2dfb9950), WTCP(0x77320d0d, 0x2ea6f827), WTCP(0x76ee923e, 0x2f51f6c4),
+ WTCP(0x76aa2222, 0x2ffc93c9), WTCP(0x7664bd46, 0x30a6cdd3), WTCP(0x761e6439, 0x3150a385), WTCP(0x75d7178c, 0x31fa1381),
+ WTCP(0x758ed7d2, 0x32a31c68), WTCP(0x7545a5a0, 0x334bbcde), WTCP(0x74fb818e, 0x33f3f387), WTCP(0x74b06c33, 0x349bbf09),
+ WTCP(0x7464662c, 0x35431e09), WTCP(0x74177014, 0x35ea0f2e), WTCP(0x73c98a8a, 0x36909120), WTCP(0x737ab630, 0x3736a287),
+ WTCP(0x732af3a7, 0x37dc420c), WTCP(0x72da4395, 0x38816e5b), WTCP(0x7288a69f, 0x3926261e), WTCP(0x72361d6e, 0x39ca6802),
+ WTCP(0x71e2a8ad, 0x3a6e32b4), WTCP(0x718e4907, 0x3b1184e2), WTCP(0x7138ff2a, 0x3bb45d3b), WTCP(0x70e2cbc6, 0x3c56ba70),
+ WTCP(0x708baf8d, 0x3cf89b31), WTCP(0x7033ab34, 0x3d99fe31), WTCP(0x6fdabf6e, 0x3e3ae223), WTCP(0x6f80ecf4, 0x3edb45ba),
+ WTCP(0x6f26347f, 0x3f7b27ac), WTCP(0x6eca96ca, 0x401a86b0), WTCP(0x6e6e1492, 0x40b9617d), WTCP(0x6e10ae96, 0x4157b6ca),
+ WTCP(0x6db26597, 0x41f58552), WTCP(0x6d533a56, 0x4292cbcf), WTCP(0x6cf32d99, 0x432f88fc), WTCP(0x6c924024, 0x43cbbb97),
+ WTCP(0x6c3072c1, 0x4467625d), WTCP(0x6bcdc639, 0x45027c0c), WTCP(0x6b6a3b58, 0x459d0766), WTCP(0x6b05d2ea, 0x4637032c),
+ WTCP(0x6aa08dbf, 0x46d06e1f), WTCP(0x6a3a6ca8, 0x47694703), WTCP(0x69d37078, 0x48018c9e), WTCP(0x696b9a02, 0x48993db5),
+ WTCP(0x6902ea1d, 0x4930590f), WTCP(0x689961a1, 0x49c6dd74), WTCP(0x682f0167, 0x4a5cc9af), WTCP(0x67c3ca4c, 0x4af21c89),
+ WTCP(0x6757bd2b, 0x4b86d4cf), WTCP(0x66eadae5, 0x4c1af14f), WTCP(0x667d2459, 0x4cae70d6), WTCP(0x660e9a6a, 0x4d415234),
+ WTCP(0x659f3dfc, 0x4dd3943b), WTCP(0x652f0ff4, 0x4e6535bd), WTCP(0x64be113a, 0x4ef6358d), WTCP(0x644c42b8, 0x4f869280),
+ WTCP(0x63d9a556, 0x50164b6d), WTCP(0x63663a03, 0x50a55f2c), WTCP(0x62f201ac, 0x5133cc94), WTCP(0x627cfd41, 0x51c19281),
+ WTCP(0x62072db3, 0x524eafce), WTCP(0x619093f5, 0x52db2357), WTCP(0x611930fc, 0x5366ebfc), WTCP(0x60a105be, 0x53f2089b),
+ WTCP(0x60281333, 0x547c7817), WTCP(0x5fae5a55, 0x55063951), WTCP(0x5f33dc1d, 0x558f4b2d), WTCP(0x5eb8998a, 0x5617ac90),
+ WTCP(0x5e3c9399, 0x569f5c62), WTCP(0x5dbfcb4a, 0x5726598b), WTCP(0x5d42419f, 0x57aca2f3), WTCP(0x5cc3f79a, 0x58323787),
+ WTCP(0x5c44ee40, 0x58b71632), WTCP(0x5bc52696, 0x593b3de2), WTCP(0x5b44a1a5, 0x59bead87), WTCP(0x5ac36076, 0x5a416413)
+};
+
+const PWord16 SineWindow320[160] =
+{
+ WTCP(0x7fffe6bc, 0x00506cb9), WTCP(0x7fff1c9b, 0x00f145ab), WTCP(0x7ffd885a, 0x01921d20), WTCP(0x7ffb29fd, 0x0232f21a),
+ WTCP(0x7ff80186, 0x02d3c39b), WTCP(0x7ff40efa, 0x037490a5), WTCP(0x7fef5260, 0x0415583b), WTCP(0x7fe9cbc0, 0x04b6195d),
+ WTCP(0x7fe37b22, 0x0556d30f), WTCP(0x7fdc608f, 0x05f78453), WTCP(0x7fd47c14, 0x06982c2b), WTCP(0x7fcbcdbc, 0x0738c998),
+ WTCP(0x7fc25596, 0x07d95b9e), WTCP(0x7fb813b0, 0x0879e140), WTCP(0x7fad081b, 0x091a597e), WTCP(0x7fa132e8, 0x09bac35d),
+ WTCP(0x7f949429, 0x0a5b1dde), WTCP(0x7f872bf3, 0x0afb6805), WTCP(0x7f78fa5b, 0x0b9ba0d5), WTCP(0x7f69ff76, 0x0c3bc74f),
+ WTCP(0x7f5a3b5e, 0x0cdbda79), WTCP(0x7f49ae2a, 0x0d7bd954), WTCP(0x7f3857f6, 0x0e1bc2e4), WTCP(0x7f2638db, 0x0ebb962c),
+ WTCP(0x7f1350f8, 0x0f5b5231), WTCP(0x7effa069, 0x0ffaf5f6), WTCP(0x7eeb274d, 0x109a807e), WTCP(0x7ed5e5c6, 0x1139f0cf),
+ WTCP(0x7ebfdbf5, 0x11d945eb), WTCP(0x7ea909fc, 0x12787ed8), WTCP(0x7e917000, 0x13179a9b), WTCP(0x7e790e25, 0x13b69836),
+ WTCP(0x7e5fe493, 0x145576b1), WTCP(0x7e45f371, 0x14f43510), WTCP(0x7e2b3ae8, 0x1592d257), WTCP(0x7e0fbb22, 0x16314d8e),
+ WTCP(0x7df3744b, 0x16cfa5b9), WTCP(0x7dd6668f, 0x176dd9de), WTCP(0x7db8921c, 0x180be904), WTCP(0x7d99f721, 0x18a9d231),
+ WTCP(0x7d7a95cf, 0x1947946c), WTCP(0x7d5a6e57, 0x19e52ebb), WTCP(0x7d3980ec, 0x1a82a026), WTCP(0x7d17cdc2, 0x1b1fe7b3),
+ WTCP(0x7cf5550e, 0x1bbd046c), WTCP(0x7cd21707, 0x1c59f557), WTCP(0x7cae13e4, 0x1cf6b97c), WTCP(0x7c894bde, 0x1d934fe5),
+ WTCP(0x7c63bf2f, 0x1e2fb79a), WTCP(0x7c3d6e13, 0x1ecbefa4), WTCP(0x7c1658c5, 0x1f67f70b), WTCP(0x7bee7f85, 0x2003ccdb),
+ WTCP(0x7bc5e290, 0x209f701c), WTCP(0x7b9c8226, 0x213adfda), WTCP(0x7b725e8a, 0x21d61b1e), WTCP(0x7b4777fe, 0x227120f3),
+ WTCP(0x7b1bcec4, 0x230bf065), WTCP(0x7aef6323, 0x23a6887f), WTCP(0x7ac23561, 0x2440e84d), WTCP(0x7a9445c5, 0x24db0edb),
+ WTCP(0x7a659496, 0x2574fb36), WTCP(0x7a362220, 0x260eac6a), WTCP(0x7a05eead, 0x26a82186), WTCP(0x79d4fa89, 0x27415996),
+ WTCP(0x79a34602, 0x27da53a9), WTCP(0x7970d165, 0x28730ecd), WTCP(0x793d9d03, 0x290b8a12), WTCP(0x7909a92d, 0x29a3c485),
+ WTCP(0x78d4f634, 0x2a3bbd37), WTCP(0x789f846b, 0x2ad37338), WTCP(0x78695428, 0x2b6ae598), WTCP(0x783265c0, 0x2c021369),
+ WTCP(0x77fab989, 0x2c98fbba), WTCP(0x77c24fdb, 0x2d2f9d9f), WTCP(0x77892910, 0x2dc5f829), WTCP(0x774f4581, 0x2e5c0a6b),
+ WTCP(0x7714a58b, 0x2ef1d377), WTCP(0x76d94989, 0x2f875262), WTCP(0x769d31d9, 0x301c863f), WTCP(0x76605edb, 0x30b16e23),
+ WTCP(0x7622d0ef, 0x31460922), WTCP(0x75e48874, 0x31da5651), WTCP(0x75a585cf, 0x326e54c7), WTCP(0x7565c962, 0x3302039b),
+ WTCP(0x75255392, 0x339561e1), WTCP(0x74e424c5, 0x34286eb3), WTCP(0x74a23d62, 0x34bb2927), WTCP(0x745f9dd1, 0x354d9057),
+ WTCP(0x741c467b, 0x35dfa35a), WTCP(0x73d837ca, 0x3671614b), WTCP(0x7393722a, 0x3702c942), WTCP(0x734df607, 0x3793da5b),
+ WTCP(0x7307c3d0, 0x382493b0), WTCP(0x72c0dbf3, 0x38b4f45d), WTCP(0x72793edf, 0x3944fb7e), WTCP(0x7230ed07, 0x39d4a82f),
+ WTCP(0x71e7e6dc, 0x3a63f98d), WTCP(0x719e2cd2, 0x3af2eeb7), WTCP(0x7153bf5d, 0x3b8186ca), WTCP(0x71089ef2, 0x3c0fc0e6),
+ WTCP(0x70bccc09, 0x3c9d9c28), WTCP(0x70704718, 0x3d2b17b3), WTCP(0x7023109a, 0x3db832a6), WTCP(0x6fd52907, 0x3e44ec22),
+ WTCP(0x6f8690db, 0x3ed14349), WTCP(0x6f374891, 0x3f5d373e), WTCP(0x6ee750a8, 0x3fe8c724), WTCP(0x6e96a99d, 0x4073f21d),
+ WTCP(0x6e4553ef, 0x40feb74f), WTCP(0x6df35020, 0x418915de), WTCP(0x6da09eb1, 0x42130cf0), WTCP(0x6d4d4023, 0x429c9bab),
+ WTCP(0x6cf934fc, 0x4325c135), WTCP(0x6ca47dbf, 0x43ae7cb7), WTCP(0x6c4f1af2, 0x4436cd58), WTCP(0x6bf90d1d, 0x44beb240),
+ WTCP(0x6ba254c7, 0x45462a9a), WTCP(0x6b4af279, 0x45cd358f), WTCP(0x6af2e6bc, 0x4653d24b), WTCP(0x6a9a321d, 0x46d9fff8),
+ WTCP(0x6a40d527, 0x475fbdc3), WTCP(0x69e6d067, 0x47e50ad8), WTCP(0x698c246c, 0x4869e665), WTCP(0x6930d1c4, 0x48ee4f98),
+ WTCP(0x68d4d900, 0x497245a1), WTCP(0x68783ab1, 0x49f5c7ae), WTCP(0x681af76a, 0x4a78d4f0), WTCP(0x67bd0fbd, 0x4afb6c98),
+ WTCP(0x675e843e, 0x4b7d8dd8), WTCP(0x66ff5584, 0x4bff37e2), WTCP(0x669f8425, 0x4c8069ea), WTCP(0x663f10b7, 0x4d012324),
+ WTCP(0x65ddfbd3, 0x4d8162c4), WTCP(0x657c4613, 0x4e012800), WTCP(0x6519f010, 0x4e80720e), WTCP(0x64b6fa66, 0x4eff4025),
+ WTCP(0x645365b2, 0x4f7d917c), WTCP(0x63ef3290, 0x4ffb654d), WTCP(0x638a619e, 0x5078bad1), WTCP(0x6324f37d, 0x50f59141),
+ WTCP(0x62bee8cc, 0x5171e7d9), WTCP(0x6258422c, 0x51edbdd4), WTCP(0x61f1003f, 0x5269126e), WTCP(0x618923a9, 0x52e3e4e6),
+ WTCP(0x6120ad0d, 0x535e3479), WTCP(0x60b79d10, 0x53d80065), WTCP(0x604df459, 0x545147eb), WTCP(0x5fe3b38d, 0x54ca0a4b),
+ WTCP(0x5f78db56, 0x554246c6), WTCP(0x5f0d6c5b, 0x55b9fc9e), WTCP(0x5ea16747, 0x56312b17), WTCP(0x5e34ccc3, 0x56a7d174),
+ WTCP(0x5dc79d7c, 0x571deefa), WTCP(0x5d59da1e, 0x579382ee), WTCP(0x5ceb8355, 0x58088c96), WTCP(0x5c7c99d1, 0x587d0b3b),
+ WTCP(0x5c0d1e41, 0x58f0fe23), WTCP(0x5b9d1154, 0x59646498), WTCP(0x5b2c73bb, 0x59d73de3), WTCP(0x5abb4629, 0x5a498950),
+};
+
+
+const PWord16 SineWindow420[210] =
+{
+ WTCP(0x7ffff155, 0x003d46a7), WTCP(0x7fff7bff, 0x00b7d3bc), WTCP(0x7ffe9154, 0x01326029), WTCP(0x7ffd3154, 0x01aceb7c),
+ WTCP(0x7ffb5c00, 0x02277547), WTCP(0x7ff9115b, 0x02a1fd18), WTCP(0x7ff65166, 0x031c8280), WTCP(0x7ff31c25, 0x0397050d),
+ WTCP(0x7fef7199, 0x0411844f), WTCP(0x7feb51c6, 0x048bffd7), WTCP(0x7fe6bcb0, 0x05067734), WTCP(0x7fe1b25b, 0x0580e9f6),
+ WTCP(0x7fdc32cc, 0x05fb57ac), WTCP(0x7fd63e09, 0x0675bfe7), WTCP(0x7fcfd415, 0x06f02235), WTCP(0x7fc8f4f7, 0x076a7e27),
+ WTCP(0x7fc1a0b6, 0x07e4d34d), WTCP(0x7fb9d759, 0x085f2137), WTCP(0x7fb198e5, 0x08d96773), WTCP(0x7fa8e564, 0x0953a594),
+ WTCP(0x7f9fbcdc, 0x09cddb27), WTCP(0x7f961f57, 0x0a4807be), WTCP(0x7f8c0cdc, 0x0ac22ae8), WTCP(0x7f818577, 0x0b3c4435),
+ WTCP(0x7f76892f, 0x0bb65336), WTCP(0x7f6b180f, 0x0c30577a), WTCP(0x7f5f3221, 0x0caa5092), WTCP(0x7f52d771, 0x0d243e0d),
+ WTCP(0x7f46080a, 0x0d9e1f7d), WTCP(0x7f38c3f7, 0x0e17f471), WTCP(0x7f2b0b45, 0x0e91bc79), WTCP(0x7f1cde01, 0x0f0b7727),
+ WTCP(0x7f0e3c36, 0x0f85240a), WTCP(0x7eff25f3, 0x0ffec2b3), WTCP(0x7eef9b46, 0x107852b2), WTCP(0x7edf9c3c, 0x10f1d398),
+ WTCP(0x7ecf28e5, 0x116b44f6), WTCP(0x7ebe414f, 0x11e4a65c), WTCP(0x7eace58a, 0x125df75b), WTCP(0x7e9b15a6, 0x12d73784),
+ WTCP(0x7e88d1b4, 0x13506668), WTCP(0x7e7619c3, 0x13c98397), WTCP(0x7e62ede5, 0x14428ea2), WTCP(0x7e4f4e2c, 0x14bb871b),
+ WTCP(0x7e3b3aaa, 0x15346c93), WTCP(0x7e26b371, 0x15ad3e9a), WTCP(0x7e11b894, 0x1625fcc3), WTCP(0x7dfc4a26, 0x169ea69e),
+ WTCP(0x7de6683a, 0x17173bbd), WTCP(0x7dd012e6, 0x178fbbb1), WTCP(0x7db94a3c, 0x1808260c), WTCP(0x7da20e53, 0x18807a5f),
+ WTCP(0x7d8a5f40, 0x18f8b83c), WTCP(0x7d723d18, 0x1970df36), WTCP(0x7d59a7f1, 0x19e8eedd), WTCP(0x7d409fe1, 0x1a60e6c3),
+ WTCP(0x7d272501, 0x1ad8c67c), WTCP(0x7d0d3767, 0x1b508d98), WTCP(0x7cf2d72b, 0x1bc83baa), WTCP(0x7cd80464, 0x1c3fd045),
+ WTCP(0x7cbcbf2d, 0x1cb74afa), WTCP(0x7ca1079d, 0x1d2eab5d), WTCP(0x7c84ddcf, 0x1da5f0ff), WTCP(0x7c6841db, 0x1e1d1b73),
+ WTCP(0x7c4b33dc, 0x1e942a4d), WTCP(0x7c2db3ee, 0x1f0b1d1f), WTCP(0x7c0fc22a, 0x1f81f37c), WTCP(0x7bf15eac, 0x1ff8acf7),
+ WTCP(0x7bd28991, 0x206f4923), WTCP(0x7bb342f3, 0x20e5c793), WTCP(0x7b938af1, 0x215c27dc), WTCP(0x7b7361a7, 0x21d2698f),
+ WTCP(0x7b52c733, 0x22488c42), WTCP(0x7b31bbb2, 0x22be8f87), WTCP(0x7b103f43, 0x233472f3), WTCP(0x7aee5205, 0x23aa361a),
+ WTCP(0x7acbf416, 0x241fd88e), WTCP(0x7aa92596, 0x249559e6), WTCP(0x7a85e6a5, 0x250ab9b4), WTCP(0x7a623764, 0x257ff78e),
+ WTCP(0x7a3e17f2, 0x25f51307), WTCP(0x7a198872, 0x266a0bb5), WTCP(0x79f48904, 0x26dee12c), WTCP(0x79cf19cb, 0x27539302),
+ WTCP(0x79a93ae9, 0x27c820ca), WTCP(0x7982ec80, 0x283c8a1b), WTCP(0x795c2eb5, 0x28b0ce8a), WTCP(0x793501a9, 0x2924edac),
+ WTCP(0x790d6581, 0x2998e716), WTCP(0x78e55a62, 0x2a0cba5e), WTCP(0x78bce070, 0x2a80671b), WTCP(0x7893f7d1, 0x2af3ece2),
+ WTCP(0x786aa0a9, 0x2b674b49), WTCP(0x7840db1f, 0x2bda81e6), WTCP(0x7816a759, 0x2c4d9050), WTCP(0x77ec057d, 0x2cc0761e),
+ WTCP(0x77c0f5b3, 0x2d3332e5), WTCP(0x77957822, 0x2da5c63e), WTCP(0x77698cf3, 0x2e182fbe), WTCP(0x773d344d, 0x2e8a6efd),
+ WTCP(0x77106e58, 0x2efc8393), WTCP(0x76e33b3f, 0x2f6e6d16), WTCP(0x76b59b2a, 0x2fe02b1e), WTCP(0x76878e43, 0x3051bd43),
+ WTCP(0x765914b5, 0x30c3231d), WTCP(0x762a2eaa, 0x31345c44), WTCP(0x75fadc4d, 0x31a56850), WTCP(0x75cb1dca, 0x321646d9),
+ WTCP(0x759af34c, 0x3286f779), WTCP(0x756a5cff, 0x32f779c7), WTCP(0x75395b10, 0x3367cd5d), WTCP(0x7507edac, 0x33d7f1d3),
+ WTCP(0x74d61500, 0x3447e6c3), WTCP(0x74a3d13a, 0x34b7abc6), WTCP(0x74712288, 0x35274076), WTCP(0x743e0918, 0x3596a46c),
+ WTCP(0x740a8519, 0x3605d743), WTCP(0x73d696bb, 0x3674d894), WTCP(0x73a23e2d, 0x36e3a7fa), WTCP(0x736d7b9f, 0x3752450f),
+ WTCP(0x73384f41, 0x37c0af6d), WTCP(0x7302b945, 0x382ee6b0), WTCP(0x72ccb9db, 0x389cea72), WTCP(0x72965134, 0x390aba4f),
+ WTCP(0x725f7f84, 0x397855e1), WTCP(0x722844fb, 0x39e5bcc5), WTCP(0x71f0a1cc, 0x3a52ee96), WTCP(0x71b8962b, 0x3abfeaf1),
+ WTCP(0x7180224b, 0x3b2cb170), WTCP(0x71474660, 0x3b9941b1), WTCP(0x710e029e, 0x3c059b4f), WTCP(0x70d45738, 0x3c71bde8),
+ WTCP(0x709a4465, 0x3cdda919), WTCP(0x705fca59, 0x3d495c7e), WTCP(0x7024e94b, 0x3db4d7b5), WTCP(0x6fe9a16f, 0x3e201a5b),
+ WTCP(0x6fadf2fc, 0x3e8b240e), WTCP(0x6f71de2a, 0x3ef5f46c), WTCP(0x6f35632e, 0x3f608b13), WTCP(0x6ef88241, 0x3fcae7a1),
+ WTCP(0x6ebb3b9a, 0x403509b4), WTCP(0x6e7d8f72, 0x409ef0ed), WTCP(0x6e3f7e01, 0x41089ce8), WTCP(0x6e010780, 0x41720d46),
+ WTCP(0x6dc22c28, 0x41db41a5), WTCP(0x6d82ec32, 0x424439a6), WTCP(0x6d4347da, 0x42acf4e8), WTCP(0x6d033f58, 0x4315730c),
+ WTCP(0x6cc2d2e9, 0x437db3b0), WTCP(0x6c8202c6, 0x43e5b676), WTCP(0x6c40cf2c, 0x444d7aff), WTCP(0x6bff3855, 0x44b500eb),
+ WTCP(0x6bbd3e7f, 0x451c47dc), WTCP(0x6b7ae1e6, 0x45834f72), WTCP(0x6b3822c6, 0x45ea1750), WTCP(0x6af5015c, 0x46509f16),
+ WTCP(0x6ab17de7, 0x46b6e668), WTCP(0x6a6d98a4, 0x471cece7), WTCP(0x6a2951d2, 0x4782b236), WTCP(0x69e4a9ae, 0x47e835f7),
+ WTCP(0x699fa078, 0x484d77ce), WTCP(0x695a366f, 0x48b2775d), WTCP(0x69146bd3, 0x49173448), WTCP(0x68ce40e4, 0x497bae33),
+ WTCP(0x6887b5e2, 0x49dfe4c2), WTCP(0x6840cb0e, 0x4a43d799), WTCP(0x67f980a8, 0x4aa7865b), WTCP(0x67b1d6f3, 0x4b0af0ae),
+ WTCP(0x6769ce2f, 0x4b6e1637), WTCP(0x6721669f, 0x4bd0f69b), WTCP(0x66d8a085, 0x4c33917f), WTCP(0x668f7c25, 0x4c95e688),
+ WTCP(0x6645f9c0, 0x4cf7f55d), WTCP(0x65fc199a, 0x4d59bda3), WTCP(0x65b1dbf8, 0x4dbb3f02), WTCP(0x6567411d, 0x4e1c791f),
+ WTCP(0x651c494d, 0x4e7d6ba2), WTCP(0x64d0f4ce, 0x4ede1631), WTCP(0x648543e4, 0x4f3e7875), WTCP(0x643936d4, 0x4f9e9214),
+ WTCP(0x63eccde5, 0x4ffe62b6), WTCP(0x63a0095c, 0x505dea05), WTCP(0x6352e980, 0x50bd27a7), WTCP(0x63056e98, 0x511c1b47),
+ WTCP(0x62b798ea, 0x517ac48c), WTCP(0x626968be, 0x51d92321), WTCP(0x621ade5c, 0x523736ae), WTCP(0x61cbfa0b, 0x5294fedd),
+ WTCP(0x617cbc14, 0x52f27b58), WTCP(0x612d24c0, 0x534fabcb), WTCP(0x60dd3457, 0x53ac8fde), WTCP(0x608ceb22, 0x5409273e),
+ WTCP(0x603c496c, 0x54657194), WTCP(0x5feb4f7f, 0x54c16e8e), WTCP(0x5f99fda4, 0x551d1dd5), WTCP(0x5f485426, 0x55787f17),
+ WTCP(0x5ef6534f, 0x55d391ff), WTCP(0x5ea3fb6c, 0x562e563a), WTCP(0x5e514cc8, 0x5688cb75), WTCP(0x5dfe47ad, 0x56e2f15d),
+ WTCP(0x5daaec6a, 0x573cc79f), WTCP(0x5d573b49, 0x57964de9), WTCP(0x5d033497, 0x57ef83e9), WTCP(0x5caed8a2, 0x5848694d),
+ WTCP(0x5c5a27b8, 0x58a0fdc3), WTCP(0x5c052224, 0x58f940fa), WTCP(0x5bafc837, 0x595132a2), WTCP(0x5b5a1a3d, 0x59a8d26a),
+ WTCP(0x5b041885, 0x5a002001), WTCP(0x5aadc35e, 0x5a571b18)
+};
+
+
+
+
+/**
+ * \brief Helper table containing the length, rasterand shape mapping to individual window slope tables.
+ * [0: sine ][0: radix2 raster ][ceil(log2(length)) length 4 .. 1024 ]
+ * [1: 640 raster
+ */
+const PWord16 *const windowSlopes[1][2][8] =
+{
+ { /* Sine */
+ { /* Radix 2 */
+ NULL,
+ NULL,
+ SineWindow16,
+ SineWindow32,
+ SineWindow64,
+ SineWindow128,
+ SineWindow256,
+ NULL
+ },
+ { /* 640 raster */
+ NULL, /* 2.5 */
+ NULL, /* 5 */
+ SineWindow10,
+ SineWindow20,
+ SineWindow40,
+ SineWindow80,
+ SineWindow160,
+ SineWindow320
+ },
+ }
+};
+
+#define DCTIV_SINETABLE SineTable512
+#define DCTIV_SINETABLE_SIZE_LD 9
+
+#define DCTIV_SINETABLE320 SineTable320
+#define DCTIV_SINETABLE320_SIZE_LD 8
+
+void BASOP_getTables(const PWord16 **ptwiddle, const PWord16 **sin_twiddle, Word16 *psin_step, Word16 length)
+{
+ const PWord16 *twiddle;
+ const PWord16 *sine;
+ Word16 ld2_length, sin_step;
+
+ /* Get ld2 of length - 2 + 1
+ -2: because first table entry is window of size 4
+ +1: because we already include +1 because of ceil(log2(length)) */
+ ld2_length = sub(16 -1 -1, norm_s(length));
+
+ /* Extract sort of "eigenvalue" (the 5 left most bits) of length. */
+ SWITCH ( (unsigned short)lshl(length, sub(15, ld2_length) ) )
+ {
+ case 0xa000: /* 640 */
+ move16();
+ move16();
+ sine = DCTIV_SINETABLE320;
+ sin_step = shl(1, sub(DCTIV_SINETABLE320_SIZE_LD+1, ld2_length));
+ twiddle = windowSlopes[0][1][sub(ld2_length,1)];
+ BREAK;
+
+ case 0x8000: /* radix 2 */
+ move16();
+ move16();
+ sine = DCTIV_SINETABLE;
+ sin_step = shl(1, sub(DCTIV_SINETABLE_SIZE_LD+1, ld2_length));
+ twiddle = windowSlopes[0][0][sub(ld2_length,2)];
+ BREAK;
+
+ default: /* not instrumented, probably obsolete */
+ sine = NULL;
+ sin_step = 0;
+ twiddle = NULL;
+ BREAK;
+ }
+
+ if (ptwiddle != NULL)
+ {
+ assert(twiddle != NULL || length == 0);
+ move16();
+ *ptwiddle = twiddle;
+ }
+
+ if (sin_twiddle != NULL)
+ {
+ move16();
+ *sin_twiddle = sine;
+ }
+ if ( psin_step != NULL )
+ {
+ assert(sin_step > 0 || length == 0);
+ move16();
+ *psin_step = sin_step;
+ }
+}
+
+const PWord16* getSineWindowTable(Word16 length)
+{
+ const PWord16 *p = NULL;
+
+ switch (length)
+ {
+ case 10:
+ p = SineWindow10;
+ BREAK;
+ case 16:
+ p = SineWindow16;
+ BREAK;
+ case 20:
+ p = SineWindow20;
+ BREAK;
+ case 30:
+ p = SineWindow30;
+ BREAK;
+ case 32:
+ p = SineWindow32;
+ BREAK;
+ case 40:
+ p = SineWindow40;
+ BREAK;
+ case 48:
+ p = SineWindow48;
+ BREAK;
+ case 60:
+ p = SineWindow60;
+ BREAK;
+ case 70:
+ p = SineWindow70;
+ BREAK;
+ case 96:
+ p = SineWindow96;
+ BREAK;
+ case 112:
+ p = SineWindow112;
+ BREAK;
+ case 120:
+ p = SineWindow120;
+ BREAK;
+ case 140:
+ p = SineWindow140;
+ BREAK;
+ case 180:
+ p = SineWindow180;
+ BREAK;
+ case 224:
+ p = SineWindow224;
+ BREAK;
+ case 280:
+ p = SineWindow280;
+ BREAK;
+ case 420:
+ p = SineWindow420;
+ BREAK;
+ }
+
+ assert(p != NULL);
+
+ return p;
+}
+
diff --git a/lib_com/rom_basop_util.h b/lib_com/rom_basop_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..5f235897c7a0d40bf3547f46ef0cdca0a140b0e8
--- /dev/null
+++ b/lib_com/rom_basop_util.h
@@ -0,0 +1,81 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#ifndef __BASOP_UTIL_ROM_H__
+#define __BASOP_UTIL_ROM_H__
+
+#include "typedef.h"
+#include "basop_util.h"
+
+#define LD_INT_TAB_LEN 120
+#define INV_TABLE_SIZE 256
+#define SQRT_TABLE_SIZE 256
+
+#ifndef CHEAP_NORM_SIZE
+#define CHEAP_NORM_SIZE 161
+#endif
+
+#define MINSFTAB 7
+#define MAXSFTAB 25
+
+/**
+ * \brief Lookup-Table for binary logarithm
+ */
+extern const Word16 ldCoeff[7];
+
+/**
+ \brief Lookup-Table for binary power algorithm
+*/
+extern const UWord32 exp2_tab_long[32];
+
+/**
+ \brief Lookup-Table for binary power algorithm
+*/
+extern const UWord32 exp2w_tab_long[32];
+
+/**
+ \brief Lookup-Table for binary power algorithm
+*/
+extern const UWord32 exp2x_tab_long[32];
+
+/**
+ \brief Lookup-Table for integer binary logarithm
+*/
+extern const Word32 ldIntCoeff[LD_INT_TAB_LEN];
+
+/**
+ * \brief Lookup-Table for 1/x
+*/
+extern const Word16 invTable[INV_TABLE_SIZE+1];
+
+/**
+ * \brief 1/x, x=[0,1,2,3...] table
+ */
+extern const Word16 InvIntTable[65];
+
+/**
+ * \brief Lookup-Table for Squareroot
+*/
+extern const Word16 sqrtTable[SQRT_TABLE_SIZE+1];
+extern const Word16 invSqrtTable[SQRT_TABLE_SIZE+1];
+
+extern const Word32 BASOP_util_normReciprocal[CHEAP_NORM_SIZE];
+extern const Word16 f_atan_expand_range[MAXSFTAB-(MINSFTAB-1)];
+
+/**
+ * \ brief Sine table
+ */
+extern const PWord16 SineTable512[257];
+extern const PWord16 SineTable480[241];
+extern const PWord16 SineTable400[201];
+extern const PWord16 SineTable384[193];
+extern const PWord16 SineTable320[161];
+
+/**
+ * \ brief Lookup for sine tables and windows.
+ */
+void BASOP_getTables(const PWord16 **ptwiddle, const PWord16 **sin_twiddle, Word16 *sin_step, Word16 length);
+const PWord16* getSineWindowTable(Word16 length);
+
+#endif
diff --git a/lib_com/rom_com_fx.c b/lib_com/rom_com_fx.c
new file mode 100644
index 0000000000000000000000000000000000000000..dba0f3a0d6494f64e2956fe831e7be04925c561b
--- /dev/null
+++ b/lib_com/rom_com_fx.c
@@ -0,0 +1,21195 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#include "options.h" /* Compilation switches */
+#include "prot_fx.h"
+#include "rom_com_fx.h" /* Static table prototypes */
+#include "cnst_fx.h" /* Decoder static structure */
+#include "stl.h"
+
+#include "basop_util.h"
+
+
+
+
+/*----------------------------------------------------------------------------------*
+ * Table of bitrates
+ *----------------------------------------------------------------------------------*/
+
+const Word32 brate_tbl[SIZE_BRATE_TBL] =
+{
+ ACELP_7k20, ACELP_8k00, ACELP_9k60, ACELP_13k20, ACELP_16k40, ACELP_24k40,
+ ACELP_32k, ACELP_48k, ACELP_64k, HQ_96k, HQ_128k
+};
+
+/*----------------------------------------------------------------------------------*
+ * Conversion of ACELP signalling parameters (ACELP internal Fs, coder type, bandwidth, sharpening flag) to index
+ * (to be consulted with the decision matrix)
+ *
+ * - in order to retrieve the index, each section in this table starts with a bitrate
+ * - the second value in each section corresponds to the number of bits
+ * - the other values represent indices created by combining different parameters into a single value through the macro SIG2IND()
+ *----------------------------------------------------------------------------------*/
+
+/* Combine coder_type, bandwidth, formant sharpening flag, and channel-aware flag into one indice */
+#define SIG2IND(ctype, bw, sf, ca_rf) ( ctype | (bw << 3) | (sf << 6) | (ca_rf << 7) )
+
+const Word32 acelp_sig_tbl[MAX_ACELP_SIG] =
+{
+ /* GENERIC UNVOICED VOICED TRANSITION AUDIO INACTIVE */
+ ACELP_7k20, 4,
+ SIG2IND(GENERIC, NB, 1, 0), SIG2IND(UNVOICED, NB, 0, 0), SIG2IND(VOICED, NB, 1, 0), SIG2IND(TRANSITION, NB, 1, 0), SIG2IND(AUDIO, NB, 0, 0), SIG2IND(INACTIVE, NB, 0, 0),
+ SIG2IND(GENERIC, WB, 1, 0), SIG2IND(UNVOICED, WB, 0, 0), SIG2IND(VOICED, WB, 1, 0), SIG2IND(TRANSITION, WB, 1, 0), SIG2IND(AUDIO, WB, 0, 0), SIG2IND(INACTIVE, WB, 0, 0),
+ SIG2IND(GENERIC, NB, 0, 0),
+ SIG2IND(GENERIC, WB, 0, 0),
+ SIG2IND(LR_MDCT, NB, 0, 0),
+
+ ACELP_8k00, 4,
+ SIG2IND(GENERIC, NB, 1, 0), SIG2IND(UNVOICED, NB, 0, 0), SIG2IND(VOICED, NB, 1, 0), SIG2IND(TRANSITION, NB, 1, 0), SIG2IND(AUDIO, NB, 0, 0), SIG2IND(INACTIVE, NB, 0, 0),
+ SIG2IND(GENERIC, WB, 1, 0), SIG2IND(UNVOICED, WB, 0, 0), SIG2IND(VOICED, WB, 1, 0), SIG2IND(TRANSITION, WB, 1, 0), SIG2IND(AUDIO, WB, 0, 0), SIG2IND(INACTIVE, WB, 0, 0),
+ SIG2IND(GENERIC, NB, 0, 0),
+ SIG2IND(GENERIC, WB, 0, 0),
+ SIG2IND(LR_MDCT, NB, 0, 0),
+
+ ACELP_13k20, 5,
+ SIG2IND(GENERIC, NB, 1, 0), SIG2IND(VOICED, NB, 1, 0), SIG2IND(TRANSITION, NB, 0, 0), SIG2IND(AUDIO, NB, 0, 0), SIG2IND(INACTIVE, NB, 0, 0),
+ SIG2IND(GENERIC, WB, 1, 0), SIG2IND(VOICED, WB, 1, 0), SIG2IND(TRANSITION, WB, 0, 0), SIG2IND(AUDIO, WB, 0, 0), SIG2IND(INACTIVE, WB, 0, 0),
+ SIG2IND(GENERIC, SWB, 1, 0), SIG2IND(VOICED, SWB, 1, 0), SIG2IND(TRANSITION, SWB, 0, 0), SIG2IND(AUDIO, SWB, 0, 0), SIG2IND(INACTIVE, SWB, 0, 0),
+ SIG2IND(GENERIC, NB, 0, 0), SIG2IND(VOICED, NB, 0, 0),
+ SIG2IND(GENERIC, WB, 0, 0), SIG2IND(VOICED, WB, 0, 0),
+ SIG2IND(GENERIC, SWB, 0, 0), SIG2IND(VOICED, SWB, 0, 0),
+ SIG2IND(GENERIC, WB, 1, 1), SIG2IND(UNVOICED, WB, 0, 1), SIG2IND(VOICED, WB, 1, 1), SIG2IND(INACTIVE, WB, 0, 1),
+ SIG2IND(GENERIC, SWB, 1, 1), SIG2IND(UNVOICED, SWB, 0, 1), SIG2IND(VOICED, SWB, 1, 1), SIG2IND(INACTIVE, SWB, 0, 1),
+ SIG2IND(LR_MDCT, NB, 0, 0),
+ SIG2IND(LR_MDCT, WB, 0, 0),
+ SIG2IND(LR_MDCT, SWB, 0, 0),
+
+ ACELP_32k, 4,
+ SIG2IND(GENERIC, WB, 1, 0), SIG2IND(TRANSITION, WB, 1, 0), SIG2IND(INACTIVE, WB, 0, 0),
+ SIG2IND(GENERIC, SWB, 1, 0), SIG2IND(TRANSITION, SWB, 1, 0), SIG2IND(INACTIVE, SWB, 0, 0),
+ SIG2IND(GENERIC, FB, 1, 0), SIG2IND(TRANSITION, FB, 1, 0), SIG2IND(INACTIVE, FB, 0, 0),
+ SIG2IND(GENERIC, WB, 0, 0), SIG2IND(TRANSITION, WB, 0, 0),
+ SIG2IND(GENERIC, SWB, 0, 0), SIG2IND(TRANSITION, SWB, 0, 0),
+ SIG2IND(GENERIC, FB, 0, 0), SIG2IND(TRANSITION, FB, 0, 0),
+
+ ACELP_64k, 4,
+ SIG2IND(GENERIC, WB, 0, 0), SIG2IND(TRANSITION, WB, 0, 0), SIG2IND(INACTIVE, WB, 0, 0),
+ SIG2IND(GENERIC, SWB, 1, 0), SIG2IND(TRANSITION, SWB, 1, 0), SIG2IND(INACTIVE, SWB, 0, 0),
+ SIG2IND(GENERIC, FB, 1, 0), SIG2IND(TRANSITION, FB, 1, 0), SIG2IND(INACTIVE, FB, 0, 0),
+ SIG2IND(GENERIC, SWB, 0, 0), SIG2IND(TRANSITION, SWB, 0, 0),
+ SIG2IND(GENERIC, FB, 0, 0), SIG2IND(TRANSITION, FB, 0, 0),
+};
+
+/*----------------------------------------------------------------------------------*
+ * ACELP bit allocation tables
+ *----------------------------------------------------------------------------------*/
+
+/* bit allocation table for end-frame LSF quantizer */
+const Word16 LSF_bits_tbl[] =
+{
+ /* IC UC VC GC TC AC */
+ 22, 37, 31, 29, 31, 22, /* ACELP_7k20 */
+ 22, 40, 36, 33, 34, 22, /* ACELP_8k00 */
+ 31, 0, 37, 37, 40, 31, /* ACELP_11k60 */
+ 31, 0, 39, 39, 41, 31, /* ACELP_12k15 */
+ 31, 0, 38, 38, 40, 31, /* ACELP_12k85 */
+ 31, 0, 38, 38, 40, 31, /* ACELP_13k20 */
+ 31, 0, 37, 42, 42, 31, /* ACELP_14k80 */
+ 31, 0, 43, 40, 40, 31, /* ACELP_16k40 */
+ 31, 0, 42, 40, 40, 0, /* ACELP_22k60 */
+ 31, 0, 46, 41, 41, 31, /* ACELP_24k40 */
+ 41, 0, 0, 41, 41, 0, /* ACELP_29k00 */
+ 41, 0, 0, 41, 41, 0, /* ACELP_29k20 */
+ 41, 0, 0, 41, 41, 0, /* ACELP_30k20 */
+ 41, 0, 0, 41, 41, 0, /* ACELP_30k40 */
+ 41, 0, 0, 41, 41, 0, /* ACELP_32k */
+ 41, 0, 0, 41, 41, 0, /* ACELP_48k */
+ 41, 0, 0, 41, 41, 0, /* ACELP_64k */
+};
+
+/* bit allocation table for mid-frame LSF quantizer */
+const Word16 mid_LSF_bits_tbl[] =
+{
+ /* IC UC VC GC TC AC */
+ 2, 5, 4, 5, 5, 2, /* ACELP_7k20 */
+ 2, 5, 4, 5, 5, 2, /* ACELP_8k00 */
+ 2, 0, 4, 5, 5, 2, /* ACELP_11k60 */
+ 2, 0, 5, 5, 5, 2, /* ACELP_12k15 */
+ 2, 0, 5, 5, 5, 2, /* ACELP_12k85 */
+ 2, 0, 5, 5, 5, 2, /* ACELP_13k20 */
+ 4, 0, 5, 5, 5, 4, /* ACELP_14k80 */
+ 4, 0, 5, 5, 5, 4, /* ACELP_16k40 */
+ 5, 0, 5, 5, 5, 5, /* ACELP_22k60 */
+ 5, 0, 5, 5, 5, 5, /* ACELP_24k40 */
+ 5, 0, 0, 5, 5, 5, /* ACELP_29k00 */
+ 5, 0, 0, 5, 5, 5, /* ACELP_29k20 */
+ 5, 0, 0, 5, 5, 5, /* ACELP_30k20 */
+ 5, 0, 0, 5, 5, 5, /* ACELP_30k40 */
+ 5, 0, 0, 5, 5, 5, /* ACELP_32k */
+ 5, 0, 0, 5, 5, 5, /* ACELP_48k */
+ 5, 0, 0, 5, 5, 5, /* ACELP_64k */
+};
+
+
+/* bit allocation table for scaled innovation energy prediction */
+const Word16 Es_pred_bits_tbl[] =
+{
+ /* UC VC GC TC */
+ 0, 0, 0, 4, /* ACELP_7k20 */
+ 0, 0, 0, 4, /* ACELP_8k00 */
+ 0, 5, 4, 4, /* ACELP_11k60 */
+ 0, 5, 5, 5, /* ACELP_12k15 */
+ 0, 5, 4, 5, /* ACELP_12k85 */
+ 0, 5, 4, 4, /* ACELP_13k20 */
+ 0, 5, 5, 5, /* ACELP_14k80 */
+ 0, 5, 5, 5, /* ACELP_16k40 */
+ 0, 5, 5, 5, /* ACELP_22k60 */
+ 0, 5, 5, 5, /* ACELP_24k40 */
+ 0, 0, 5, 5, /* ACELP_29k00 */
+ 0, 0, 5, 5, /* ACELP_29k20 */
+ 0, 0, 5, 5, /* ACELP_30k20 */
+ 0, 0, 5, 5, /* ACELP_30k40 */
+ 0, 0, 5, 5, /* ACELP_32k */
+ 0, 0, 5, 5, /* ACELP_48k */
+ 0, 0, 5, 5, /* ACELP_64k */
+};
+
+/* bit allocation table for gain quantizer (ACELP@12.8kHz) */
+/* the 4 values allocated correspond to 4 subframes */
+const Word16 gain_bits_tbl[] =
+{
+ /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */
+ 7,7,7,7, 7,6,6,6, 6,6,6,6, 5,5,5,5, 5,5,6,5, 5,3,6,6, 5,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,10, /* ACELP_7k20 */
+ 7,7,7,7, 8,7,6,6, 8,7,6,6, 5,5,5,5, 5,6,5,5, 5,3,6,6, 5,3,3,6, 3,5,5,5, 3,3,6,6, 3,3,3,14, /* ACELP_8k00 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,13, /* ACELP_11k60 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,14, /* ACELP_12k15 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,5, 3,3,3,14, /* ACELP_12k85 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,15, /* ACELP_13k20 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,15, /* ACELP_14k80 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,15, /* ACELP_16k40 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,14, /* ACELP_22k60 */
+ 0,0,0,0, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,6,6,6, 6,3,6,6, 6,3,3,6, 3,6,6,6, 3,3,6,6, 3,3,3,15, /* ACELP_24k40 */
+};
+
+/* bit allocation table for gain gain quantizer (ACELP@16kHz) */
+/* the 5 values allocated correspond to 5 subframes */
+const Word16 gain_bits_16kHz_tbl[] =
+{
+ /* IC GC TC0 TC64 TC128 TC192 TC256 */
+ 0,0,0,0,0, 6,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0, 0, /* ACELP_8k00 */
+ 0,0,0,0,0, 6,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0, 0, /* ACELP_14k80 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,15, /* ACELP_22k60 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,16, /* ACELP_24k40 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,14, /* ACELP_29k00 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,14, /* ACELP_29k20 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,14, /* ACELP_30k20 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,14, /* ACELP_30k40 */
+ 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 3,6,6,6,6, 3,3,6,6,6, 3,3,3,6,6, 3,3,3,3,14, /* ACELP_32k */
+ 12,12,12,12,12, 12,12,12,12,12, 12,12,12,12,12, 6,12,12,12,12, 6,6,12,12,12, 6,6,6,12,12, 6,6,6,6,12, /* ACELP_48k */
+ 12,12,12,12,12, 12,12,12,12,12, 12,12,12,12,12, 6,12,12,12,12, 6,6,12,12,12, 6,6,6,12,12, 6,6,6,6,12 /* ACELP_64k */
+};
+
+/* bit allocation table for adaptive codebook (pitch) (ACELP@12.8kHz) */
+/* the 4 values correspond to 4 subframes */
+const Word16 ACB_bits_tbl[] =
+{
+ /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */
+ 0,0,0,0, 9,5,5,5, 8,5, 8,5, 6,5,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,8, /* ACELP_7k20 */
+ 0,0,0,0, 10,5,5,5, 9,5, 8,5, 6,5,6,6, 0,7,6,6, 0,0,7,5, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_8k00 */
+ 0,0,0,0, 10,5,5,5, 10,6, 9,6, 6,5,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_11k60 */
+ 0,0,0,0, 10,5,5,5, 10,6, 9,6, 6,6,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_12k15 */
+ 0,0,0,0, 10,5,5,5, 10,6, 9,6, 6,5,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_12k85 */
+ 0,0,0,0, 10,5,5,5, 10,6, 9,6, 6,5,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_13k20 */
+ 0,0,0,0, 10,5,5,5, 10,6,10,6, 6,6,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_14k80 */
+ 0,0,0,0, 10,5,5,5, 10,6,10,6, 6,6,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_16k40 */
+ 0,0,0,0, 10,5,5,5, 10,6,10,6, 6,6,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_22k60 */
+ 0,0,0,0, 10,5,5,5, 10,6,10,6, 6,6,6,6, 0,7,6,6, 0,0,7,6, 0,0,0,7, 0,0,9,6, 0,0,5,9, 0,0,0,9, /* ACELP_24k40 */
+};
+
+/* bit allocation table for adaptive codebook (pitch) (ACELP@16kHz) */
+/* the 5 values correspond to 5 subframes */
+const Word16 ACB_bits_16kHz_tbl[] =
+{
+ /* IC GC TC0 TC64 TC128 TC192 TC256 */
+ 0,0, 0,0,0, 9,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0,0, 0,0, 0,0,0,0, 0, /* ACELP_8k00 */
+ 0,0, 0,0,0, 10,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0, 0,0,0, 0,0,0, 0,0, 0,0,0,0, 0, /* ACELP_14k80 */
+ 10,6,10,6,6, 10,6,10,6,6, 5,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_22k60 */
+ 10,6,10,6,6, 10,6,10,6,6, 5,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_24k40 */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_29k00 */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_29k20 */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_30k20 */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_30k40 */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_32k */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10, /* ACELP_48k */
+ 10,6,10,6,6, 10,6,10,6,6, 6,8,10,6,6, 0,6,10,6,6, 0,0,10,6,6, 0,0,0,10,6, 0,0,0,0,10 /* ACELP_64k */
+};
+
+/* bit allocation table for algebraic (fixed) codebook (innovation) (ACELP@12.8kHz) */
+/* the 4 values correspond to 4 subframes */
+const Word16 FCB_bits_tbl[] =
+{
+ /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */
+ 13,13,13,13, 12,12,12,20, 12,12,12,20, 12, 7,12,12, 12,12, 7,12, 12,12,12,12, 12,12,20,12, 12,12,12,12, 12,12,12,12, 12,12,12,20, /* ACELP_7k20 */
+ 13,13,13,13, 12,20,12,20, 12,20,12,20, 20,12,12,12, 20,12,12,12, 20,12,20,12, 20,12,20,20, 20,12,12,20, 20,12,20,12, 12,20,12,20, /* ACELP_8k00 */
+ 0, 0, 0, 0, 28,36,28,36, 28,28,28,36, 28,28,28,28, 28,28,28,28, 28,28,36,28, 28,36,28,36, 28,36,28,28, 28,28,28,36, 28,36,28,36, /* ACELP_11k60 */
+ 0, 0, 0, 0, 28,36,36,36, 28,36,28,36, 36,28,28,28, 36,28,28,28, 36,28,36,28, 36,36,28,43, 28,36,28,36, 28,36,28,36, 28,36,36,36, /* ACELP_12k15 */
+ 0, 0, 0, 0, 36,36,36,43, 36,36,36,36, 36,36,28,36, 36,28,36,36, 36,36,36,36, 36,36,43,43, 36,36,36,36, 36,36,36,43, 36,36,36,43, /* ACELP_12k85 */
+ 0, 0, 0, 0, 36,43,36,43, 36,36,36,43, 36,36,36,36, 36,36,36,36, 36,36,43,36, 36,43,43,43, 36,43,36,36, 43,36,43,36, 36,43,36,43, /* ACELP_13k20 */
+ 0, 0, 0, 0, 43,50,43,50, 43,43,43,43, 43,43,43,43, 43,43,43,43, 43,43,50,43, 43,50,50,50, 43,43,43,50, 50,43,50,43, 43,50,43,50, /* ACELP_14k80 */
+ 0, 0, 0, 0, 50,56,50,56, 50,50,50,56, 56,50,50,50, 56,50,50,50, 56,50,56,56, 56,56,56,56, 50,56,50,56, 50,56,56,56, 50,56,56,56, /* ACELP_16k40 */
+ 0, 0, 0, 0, 83,83,83,87, 78,83,83,83, 83,78,83,83, 83,78,83,87, 83,87,83,87, 83,87,87,92, 87,83,87,83, 87,83,87,87, 83,87,87,87, /* ACELP_22k60 */
+ 0, 0, 0, 0, 92,92,92,92, 87,92,92,92, 92,87,92,92, 92,87,92,92, 92,92,92,92, 92,92,92,92, 92,92,92,92, 92,92,92,92, 92,92,92,92, /* ACELP_24k40 */
+};
+
+/* bit allocation table for algebraic (fixed) codebook (innovation) (ACELP@16kHz) */
+/* the 5 values correspond to 5 subframes */
+const Word16 FCB_bits_16kHz_tbl[] =
+{
+ /* IC GC TC0 TC64 TC128 TC192 TC256 */
+ 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_8k00 */
+ 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_14k80 */
+ 0, 0, 0, 0, 0, 62,56,56,56,62, 62,56,56,56,56, 56,56,56,56,73, 62,56,62,62,62, 56,62,62,62,73, 62,62,62,62,68, /* ACELP_22k60 */
+ 0, 0, 0, 0, 0, 68,68,68,73,73, 68,68,68,68,73, 68,73,68,73,73, 73,73,73,73,73, 73,78,73,73,78, 73,78,73,73,78, /* ACELP_24k40 */
+ 12,12,12,12,12, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, /* ACELP_29k00 */
+ 12,12,12,12,12, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, 36,28,28,36,36, /* ACELP_29k20 */
+ 12,12,12,12,12, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, /* ACELP_30k20 */
+ 12,12,12,12,12, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, /* ACELP_30k40 */
+ 12,12,12,12,12, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, /* ACELP_32k */
+ 12,12,12,12,12, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, /* ACELP_48k */
+ 12,12,12,12,12, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36, 36,36,36,36,36 /* ACELP_64k */
+};
+
+/* bit allocation table for AVQ bits in active segments (ACELP@16kHz) */
+const Word16 AVQ_bits_16kHz_tbl[] =
+{
+ /* IC GC TC0 TC64 TC128 TC192 TC256 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_8k00 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_14k80 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_22k60 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ACELP_24k40 */
+ 78, 78, 78, 78, 78, 48, 48, 48, 48, 49, 48, 49, 49, 48, 49, 50, 50, 51, 52, 52, 50, 54, 53, 54, 54, 55, 55, 55, 55, 54, 52, 56, 56, 56, 56, /* ACELP_29k00 */
+ 79, 79, 79, 79, 78, 49, 49, 49, 49, 49, 50, 49, 49, 50, 49, 52, 52, 51, 52, 52, 54, 54, 53, 54, 54, 56, 55, 55, 56, 56, 56, 56, 56, 56, 56, /* ACELP_29k20 */
+ 78, 78, 78, 78, 78, 50, 50, 50, 50, 49, 51, 50, 50, 50, 50, 53, 53, 53, 52, 52, 55, 55, 55, 54, 54, 57, 57, 56, 56, 56, 57, 57, 57, 57, 56, /* ACELP_30k20 */
+ 79, 79, 79, 79, 78, 51, 51, 51, 50, 50, 51, 51, 51, 51, 51, 54, 54, 53, 53, 53, 56, 56, 56, 55, 54, 58, 57, 57, 57, 57, 58, 58, 58, 57, 57, /* ACELP_30k40 */
+ 86, 85, 85, 85, 85, 57, 57, 57, 57, 57, 58, 58, 57, 57, 57, 60, 60, 60, 60, 59, 62, 62, 62, 62, 61, 64, 64, 64, 63, 63, 64, 64, 64, 64, 64, /* ACELP_32k */
+ 143,142,142,142,142, 116,115,115,115,115, 116,116,115,115,115, 119,119,118,118,118, 121,121,121,121,121, 124,124,123,123,123, 126,126,126,126,126, /* ACELP_48k */
+ 207,206,206,206,206, 180,179,179,179,179, 180,180,179,179,179, 183,183,182,182,182, 185,185,185,185,185, 188,188,187,187,187, 190,190,190,190,190 /* ACELP_64k */
+};
+
+/* bit allocation table for reserved bits (ACELP@12.8kHz) */
+const Word16 reserved_bits_tbl[] =
+{
+ /* UC VC GC TC0_0 TC0_64 TC0_128 TC0_192 TC64 TC128 TC192 */
+ 1, 0, 0, 0, 0, 2, 4, 0, 3, 0, /* ACELP_7k20 */
+ 14, 0, 0, 0, 0, 0, 1, 0, 0, 0, /* ACELP_8k00 */
+ 0, 0, 0, 0, 1, 3, 6, 2, 6, 0, /* ACELP_11k60 */
+ 0, 0, 0, 0, 2, 4, 0, 3, 7, 0, /* ACELP_12k15 */
+ 0, 0, 0, 0, 1, 3, 0, 2, 0, 0, /* ACELP_12k85 */
+ 0, 0, 0, 0, 1, 4, 1, 3, 0, 0, /* ACELP_13k20 */
+ 0, 0, 0, 0, 2, 5, 2, 4, 1, 1, /* ACELP_14k80 */
+ 0, 0, 0, 0, 2, 0, 5, 5, 3, 3, /* ACELP_16k40 */
+ 0, 0, 2, 2, 0, 1, 3, 0, 0, 1, /* ACELP_22k60 */
+ 0, 0, 1, 1, 3, 8, 19, 7, 11, 11, /* ACELP_24k40 */
+};
+
+
+
+/*----------------------------------------------------------------------------------*
+ * Power of 2 table (2^x)
+ *----------------------------------------------------------------------------------*/
+
+const Word32 pow2[] =
+{
+ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
+};
+const Word16 crit_bins_corr_fx[CRIT_NOIS_BAND] =
+{
+ /*.9f, .9f, .85f, .8f, .775f, .75f, .725f , .7f , .675f, .65f, .625f , .60f, .6f, .6f, .6f, .6f, .6f, .6f, .6f, .6f, .6f, .6f, .6f*/
+ 29491, 29491, 27853, 26214, 25395, 24576, 23577 , 22938, 22118, 21299, 20480,
+ 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661, 19661
+};
+const Word16 crit_bins[CRIT_NOIS_BAND] =
+{
+ 4, 4, 4, 4, 4, 5, 6, 6, 6, 8, 8, 10, 11, 13, 15, 18, 22, 16, 16, 20, 20, 20, 16
+};
+const Word16 mfreq_bindiv_loc[] = { 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32 };
+const Word16 mfreq_bindiv_LD[] = {10, 10, 10, 10, 11, 12, 14, 15, 16, 19, 21, 24, 28, 32, 38, 45, 55, 70, 90, 110};
+const Word16 mfreq_loc_LD[] = { 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480,
+ 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, (6400-BIN_16kdct)
+ };
+
+/* bit allocation table for gain quantizer (ACELP@12.8kHz) */
+/* the 4 values allocated correspond to 4 subframes */
+
+/*----------------------------------------------------*
+ * Table for FFT
+ -----------------------------------------------------*/
+
+const Word16 Odx_fft32_5[32] = { 0,27,22,17,12,7,2,29,24,19,14,9,4,31,26,21,16,11,6,1,28,23,18,13,8,3,30,25,20,15,10,5 };
+
+const Word16 Idx_dortft160[160] =
+{
+ 0,65,130,35,100,5,70,135,40,105,10,75,140,45,110,15,80,145,
+ 50,115,20,85,150,55,120,25,90,155,60,125,30,95,96,1,66,131,
+ 36,101,6,71,136,41,106,11,76,141,46,111,16,81,146,51,116,21,
+ 86,151,56,121,26,91,156,61,126,31,32,97,2,67,132,37,102,7,
+ 72,137,42,107,12,77,142,47,112,17,82,147,52,117,22,87,152,57,
+ 122,27,92,157,62,127,128,33,98,3,68,133,38,103,8,73,138,43,
+ 108,13,78,143,48,113,18,83,148,53,118,23,88,153,58,123,28,93,
+ 158,63,64,129,34,99,4,69,134,39,104,9,74,139,44,109,14,79,
+ 144,49,114,19,84,149,54,119,24,89,154,59,124,29,94,159
+};
+
+const Word16 nextstate[STATES][2] = {{0, 1}, {2, 3}, {4, 5}, {6, 7}, {0, 1}, {2, 3}, {4, 5}, {6, 7}};/*current state points to next two states */
+
+const Word16 fine_gain_bits[8] = {0, 0, 0, 1, 2, 2, 4, 5};
+
+
+const Word16 resize_huffsizn[32] =
+{
+ 0, 0, 0, 0, 0, 11, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2,
+ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0, 0
+};
+
+const Word16 huffsizn[32] =
+{
+ 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 4, 4, 3, 3,
+ 3, 3, 4, 4, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7
+};
+
+const Word16 huffnorm_tran[32] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,122, 10, 6, 1,
+ 0, 3, 2, 26, 58, 186, 442, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+const Word16 huffsizn_tran[32] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 5, 3, 2, 2,
+ 2, 4, 6, 8, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+const Word16 pgain_huffsizn[32] =
+{
+ 10, 11, 10, 10, 9, 8, 6, 5, 5, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 5, 5, 6, 7, 7, 8, 10, 10, 12, 12
+};
+
+const Word16 dicnlg2[40] =
+{
+ 34, 33, 32, 31, 30, 29, 28, 27, 26, 25,
+ 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
+ 14, 13, 12, 11, 10, 9, 8, 7, 6, 5,
+ 4, 3, 2, 1, 0, -1, -2, -3, -4, -5
+};
+
+/*** Table for quantization of MLT coefficients ***/
+const Word16 norm_order_48[NB_SFM] =
+{
+ 0, 1, 8, 9, 16, 20, 24, 28, 32, 36, 40, 41, 37, 33, 29, 25, 21, 17, 11, 10, 3, 2,
+ 4, 5, 12, 13, 18, 22, 26, 30, 34, 38, 42, 43, 39, 35, 31, 27, 23, 19, 15, 14, 7, 6
+};
+const Word16 norm_order_32[SFM_N_SWB] =
+{
+ 0, 1, 8, 9, 16, 20, 24, 28, 32, 36, 37, 33, 29, 25, 21, 17, 11, 10, 3, 2,
+ 4, 5, 12, 13, 18, 22, 26, 30, 34, 38, 35, 31, 27, 23, 19, 15, 14, 7, 6
+};
+const Word16 norm_order_16[SFM_N_WB] =
+{
+ 0, 1, 8, 9, 16, 20, 24, 21, 17, 11, 10, 3, 2,
+ 4, 5, 12, 13, 18, 22, 25, 23, 19, 15, 14, 7, 6
+};
+
+const Word16 intl_bw_16[N_INTL_GRP_16] = {16, 16};
+const Word16 intl_bw_32[N_INTL_GRP_32] = {16, 24};
+const Word16 intl_bw_48[N_INTL_GRP_48] = {16, 24, 32};
+const Word16 intl_cnt_16[N_INTL_GRP_16] = {4, 1};
+const Word16 intl_cnt_32[N_INTL_GRP_32] = {4, 4};
+const Word16 intl_cnt_48[N_INTL_GRP_48] = {4, 3, 2};
+
+const Word16 band_start_HQ[44] =
+{
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88,
+ 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240,
+ 256, 280, 304, 328, 352, 376, 400, 424, 448, 472, 496, 520,
+ 544, 576, 608, 640, 672, 704, 736, 768
+};
+
+const Word16 band_end_HQ[44] =
+{
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96,
+ 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256,
+ 280, 304, 328, 352, 376, 400, 424, 448, 472, 496, 520, 544,
+ 576, 608, 640, 672, 704, 736, 768, 800
+};
+
+const Word16 band_len_HQ[44] =
+{
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 32, 32, 32, 32, 32, 32, 32, 32
+};
+
+const Word16 band_start_wb[26] =
+{
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88,
+ 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240,
+ 256, 288
+};
+
+const Word16 band_end_wb[26] =
+{
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96,
+ 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, 240, 256,
+ 288, 320
+};
+
+const Word16 band_len_wb[26] =
+{
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16,
+ 32, 32
+};
+
+const Word16 band_len_harm[SFM_N_HARM_FB] =
+{
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 16, 16, 16, 16, 16, 16, 32, 32, 32, 48, 48, 48, 48, 64, 64, 64, 96
+};
+
+const Word16 band_start_harm[SFM_N_HARM_FB] =
+{
+ 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
+ 128, 144, 160, 176, 192, 208, 224, 256, 288, 320, 368, 416, 464, 512, 576, 640, 704
+};
+
+const Word16 band_end_harm[SFM_N_HARM_FB] =
+{
+ 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128,
+ 144, 160, 176, 192, 208, 224, 256, 288, 320, 368, 416, 464, 512, 576, 640, 704, 800
+};
+
+const Word16 min_lat_bits_SN_fx[] = {-1, -1, 17, 12, 17, 17, -1, -1, 17, 12, 17, 17, -1, -1, 22, -1, 32, 26
+ };
+
+const Word16 min_lat_bits_pred_fx[] = {17, 18, 9, 15, -1, 21, 17, 14, 9, 15, -1, 21, 17, -1, -1, 26, -1, 26, 16};
+
+const Word16 offset_in_lvq_mode_SN_fx[][21] =
+{
+ {0}, /* I NB */
+ {0,1,1,1,1,1,2,3,3,3,3,4,4,4,5}, /* UV NB*/
+ {0,1,1,1,1,2,3,4,5,5,6,6,7,7,7,7,7,8,8,8,9}, /* V NB */
+ {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G NB */
+ {0,1,1,1,1,2,3,4,5,5,5,6,6,6,7,8}, /* T NB */
+ {0,0,0,0,1,2,2,2,2,3,4,5}, /* A NB */
+ {0}, /* I WB */
+ {0,1,1,1,2,3,3,3,3,3,3,4,4,4,5}, /* UV WB*/
+ {0,1,1,1,2,3,3,3,4,5,6,7,8,9,9,10,11,12,12,12,13}, /* V WB */
+ {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB */
+ {0,1,1,1,2,3,3,4,5,5,5,6,6,7,8,9,10}, /* T WB */
+ {0,0,0,0,1,2,2,2,3,4,4,4,4,4,4,4,4,4,4,5}, /* A WB */
+ {0},
+ {0},
+ {0,0,0,0,0,0,1,2,3,3,4,5,6,6,6,7}, /* V 16k */
+ {0}, /* G 16k */
+ {0,1}, /* T 16k */
+ {0}, /*{0,0,0,0,0,0,0,0,0,0,1} */ /* A 16k */
+};
+const Word16 offset_in_lvq_mode_pred_fx[][32] =
+{
+ {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I NB */
+ {0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV NB */
+ {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,3,4,4,5,6,7,8,9,10,10,11,12,13,13,13,14}, /* V NB */
+ {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G NB */
+ {0}, /* T NB */
+ {0,0,0,0,1,2,2,2,2,3,4,5}, /* A NB */
+ {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I WB */
+ {0,1,1,1,2,3,4,4,4,4,4,5,5,5,6}, /* UV WB */
+ {0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,3,4,4,5,6,7,8,9,10,10,11,12,13,13,13,14}, /* V WB */
+ {0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB */
+ {0}, /* T WB */
+ {0,0,0,0,1,2,2,2,3,4,4,4,4,4,4,4,4,4,4,5}, /* A WB */
+ {0,0,0,0,1,2,2,2,3,4,5,5,5,5,5,5,5,5,5,6}, /* I 16k */
+ {0}, /* UV 16k */
+ {0,0,0,0,0,0,1,2,3,3,4,5,6,6,6,7}, /* V 16k */
+ {0,0,0,0,0,0,1,2,3,4,5,6}, /* G 16k */
+ {0}, /* T 16k */
+ {0,0,0,0,0,0,1,2,3,4,5,6}, /* A 16k */
+ {0,0,0,0,0,1,1,1,2,3,4,5,6,6,7,8,9,10,11,12,13,14}, /* G WB MA*/
+};
+
+
+const Word16 offset_lvq_modes_SN_fx[] = {-1,-1,26,51,77,96,-1,-1,12,36,66,90,-1,-1,105,-1,88,102,
+ 112
+ }; /* CNG */
+
+const Word16 offset_lvq_modes_pred_fx[] = {74, 95, 15, 45, -1, 66, 81, 102, 0, 30, -1, 60, 88, -1, 109, 117, -1, 139, 124};
+
+const Word16 sfm_width[20] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8};
+const Word16 a_table_fx[20] = {8, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 7, 11};
+
+
+const Word16 inner_frame_tbl[4] = {L_FRAME8k, L_FRAME16k, L_FRAME32k, L_FRAME48k}; /* corresponds to NB, WB, SWB, FB */
+
+
+
+/*------------------------------------------------------------------------------*
+ * SWB BWE tables
+ *------------------------------------------------------------------------------*/
+
+const Word16 fb_bwe_subband[DIM_FB+1] = {640, 680, 720, 800};
+const Word16 fb_bwe_sm_subband[DIM_FB] = {656, 696, 760};
+
+/*------------------------------------------------------------------------------*
+ * SWB TBE tables
+ *------------------------------------------------------------------------------*/
+
+const Word16 lsf_q_num_bits[NUM_Q_LSF] = { 4, 4, 3, 3, 3 };
+
+const Word16 skip_bands_SWB_TBE[NUM_SHB_SUBFR+1] = {0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320}; /* bands for SWB TBE quantisation */
+const Word16 skip_bands_WB_TBE[NUM_SHB_SUBFR/2+1] = {0, 10, 20, 30, 40, 50, 60, 70, 80}; /* bands for WB TBE quantisation */
+
+const Word16 swb_lsp_prev_interp_init[10] = {32767, 31164, 26510, 19261, 10126, 0, -10126, -19261, -26510, -31164};
+/* st->swb_lsp_prev_interp[i] = (float)cos( (float)i * PI / (float)10.0f )*/
+
+const Word16 allpass_poles_3_ov_2[9] = /* Q15 */
+{
+ 2368,
+ 20545,
+ 30606,
+ 25520,
+ 7188,
+ 31808,
+ 28575,
+ 14384,
+ 32472
+};
+const Word16 decimate_3_ov_2_lowpass_num[3] = /* Q15 */
+{
+ 6399,
+ 12797,
+ 6399
+};
+const Word16 decimate_3_ov_2_lowpass_den[3] = /* Q15 */
+{
+ 32767,
+ 0,
+ 5624
+};
+
+const Word16 interpol_frac_shb[NB_SUBFR*2] =
+{
+ 22938, 9830, 13107, 19660, 3277, 29490, 0, 32767 /* Q15*/
+ /*0.7f, 0.3f, 0.4f, 0.6f, 0.1f, 0.9f, 0.0f, 1.0f */
+};
+
+/*----------------------------------------------------------------------------------*
+* ACELP/HQ core switching
+*----------------------------------------------------------------------------------*/
+/* bandwidths */
+const Word16 Nb[ NB_SFM] =
+{
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16,
+ 16, 16, 16, 16, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 32, 32, 32, 32, 32, 32, 32, 32
+};
+
+/* log2(Nb) to calculate minimum bits for one pulse in PVQ */
+const Word16 LNb[ NB_SFM] =
+{
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
+ 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5
+};
+
+
+const Word16 sin_switch_8[15] = {3212, 6393, 9512, 12540, 15447, 18205, 20788, 23170,
+ 25330, 27246, 28899, 30274, 31357, 32138, 32610
+ };
+
+const Word16 sin_switch_16[30] = {1660, 3315, 4962, 6596, 8213, 9810, 11380, 12922,
+ 14431, 15902, 17333, 18719, 20057, 21344, 22576, 23750,
+ 24863, 25912, 26895, 27808, 28651, 29419, 30112, 30728,
+ 31265, 31722, 32097, 32390, 32600, 32726
+ };
+
+
+const Word16 sin_switch_32[60] = {844, 1687, 2529, 3369, 4207, 5043, 5875, 6703,
+ 7526, 8345, 9158, 9965, 10766, 11559, 12345, 13122,
+ 13891, 14650, 15400, 16140, 16869, 17586, 18293, 18986,
+ 19668, 20336, 20991, 21632, 22258, 22870, 23467, 24048,
+ 24613, 25162, 25694, 26209, 26707, 27187, 27649, 28092,
+ 28518, 28924, 29311, 29678, 30026, 30354, 30662, 30949,
+ 31216, 31462, 31688, 31892, 32075, 32237, 32378, 32497,
+ 32594, 32670, 32725, 32757
+ };
+
+
+const Word16 sin_switch_48[90] = {566, 1131, 1696, 2261, 2825, 3388, 3950, 4511,
+ 5070, 5628, 6185, 6739, 7292, 7842, 8390, 8935,
+ 9478, 10018, 10555, 11089, 11620, 12147, 12670, 13190,
+ 13706, 14218, 14725, 15228, 15727, 16220, 16709, 17194,
+ 17672, 18146, 18614, 19077, 19534, 19985, 20431, 20870,
+ 21303, 21729, 22149, 22563, 22970, 23370, 23763, 24148,
+ 24527, 24899, 25263, 25619, 25968, 26309, 26642, 26968,
+ 27285, 27594, 27895, 28188, 28472, 28747, 29015, 29273,
+ 29523, 29764, 29996, 30219, 30433, 30639, 30835, 31021,
+ 31199, 31367, 31526, 31676, 31816, 31946, 32068, 32179,
+ 32281, 32373, 32456, 32529, 32592, 32646, 32690, 32724,
+ 32748, 32763
+ };
+
+
+const Word16 one_on_win_48k_fx[210] =
+{
+ 16399, 16412, 16425, 16439, 16452, 16465, 16479, 16492,
+ 16506, 16519, 16533, 16547, 16561, 16575, 16589, 16603,
+ 16618, 16632, 16647, 16662, 16677, 16692, 16707, 16722,
+ 16738, 16754, 16770, 16786, 16802, 16818, 16835, 16851,
+ 16868, 16885, 16902, 16919, 16937, 16955, 16972, 16990,
+ 17008, 17027, 17045, 17064, 17083, 17102, 17121, 17140,
+ 17160, 17180, 17200, 17220, 17240, 17261, 17281, 17302,
+ 17323, 17345, 17366, 17388, 17410, 17432, 17454, 17477,
+ 17499, 17522, 17545, 17569, 17592, 17616, 17640, 17664,
+ 17689, 17713, 17738, 17763, 17789, 17814, 17840, 17866,
+ 17892, 17918, 17945, 17972, 17999, 18027, 18054, 18082,
+ 18110, 18139, 18167, 18196, 18225, 18255, 18284, 18314,
+ 18345, 18375, 18406, 18437, 18468, 18499, 18531, 18563,
+ 18596, 18628, 18661, 18695, 18728, 18762, 18796, 18830,
+ 18865, 18900, 18935, 18971, 19007, 19043, 19080, 19117,
+ 19154, 19191, 19229, 19267, 19306, 19345, 19384, 19423,
+ 19463, 19504, 19544, 19585, 19626, 19668, 19710, 19752,
+ 19795, 19838, 19882, 19926, 19970, 20015, 20060, 20105,
+ 20151, 20198, 20244, 20291, 20339, 20387, 20435, 20484,
+ 20533, 20583, 20633, 20684, 20735, 20787, 20839, 20891,
+ 20944, 20997, 21051, 21106, 21161, 21216, 21272, 21328,
+ 21385, 21443, 21501, 21559, 21618, 21678, 21738, 21799,
+ 21860, 21922, 21984, 22048, 22111, 22175, 22240, 22306,
+ 22372, 22439, 22506, 22574, 22643, 22712, 22782, 22853,
+ 22924, 22996, 23069, 23142, 23216, 23291, 23367, 23443,
+ 23521, 23599, 23677, 23757, 23837, 23918, 24000, 24083,
+ 24167, 24251
+};
+
+const Word16 one_on_win_8k_16k_48k_fx[70] =
+{
+ 16432, 16472, 16512, 16554, 16596, 16639, 16684, 16730,
+ 16778, 16826, 16876, 16928, 16981, 17036, 17092, 17150,
+ 17210, 17271, 17334, 17399, 17465, 17534, 17604, 17676,
+ 17751, 17827, 17905, 17986, 18068, 18153, 18240, 18329,
+ 18421, 18515, 18612, 18711, 18813, 18918, 19025, 19135,
+ 19248, 19364, 19483, 19606, 19731, 19860, 19992, 20128,
+ 20268, 20411, 20558, 20709, 20865, 21024, 21188, 21357,
+ 21530, 21708, 21891, 22079, 22273, 22472, 22677, 22888,
+ 23105, 23329, 23560, 23797, 24041, 24251
+};
+
+
+
+/* short filters for BWE of ACELP->HQ switching frame in Q15 */
+const Word16 hp12800_16000_fx[21] =
+{
+ -0, 70, -207, 380, -405, 0, 1041, -2668, 4505,
+ -5968, 6526, -5968, 4505, -2668, 1041, 0, -405, 380,
+ -207, 70, -0
+};
+
+const Word16 hp12800_32000_fx[41] =
+{
+ -0, 45, 35, -47, -104, 0, 191, 156,
+ -203, -422, -0, 675, 523, -656, -1341, 0,
+ 2264, 1943, -2999, -9872, 19678, -9872, -2999, 1943,
+ 2264, 0, -1341, -656, 523, 675, -0, -422,
+ -203, 156, 191, 0, -104, -47, 35, 45, -0
+};
+
+const Word16 hp12800_48000_fx[61] =
+{
+ -0, 22, 33, 23, -10, -51, -69, -37, 45, 127,
+ 140, 40, -136, -271, -238, 0, 326, 507, 349, -143,
+ -696, -894, -450, 535, 1509, 1696, 521, -1998, -5136, -7735,
+ 24039, -7735, -5136, -1998, 521, 1696, 1509, 535, -450, -894,
+ -696, -143, 349, 507, 326, 0, -238, -271, -136, 40,
+ 140, 127, 45, -37, -69, -51, -10, 23, 33, 22, -0,
+};
+
+
+const Word16 hp16000_32000_fx[33] =
+{
+ -0, 62, -0, -127, -0, 270, -0, -523, -0, 940,
+ -0, -1662, -0, 3212, -0, -10353, 16407, -10353, -0, 3212,
+ -0, -1662, -0, 940, -0, -523, -0, 270, -0, -127,
+ -0, 62, -0
+};
+
+const Word16 hp16000_48000_fx[49] =
+{
+ -0, 33, 39, -0, -64, -83, -0, 138, 175, 0,
+ -272, -334, -0, 493, 596, 0, -870, -1059, -0, 1636,
+ 2120, 0, -4448, -9003, 21858, -9003, -4448, 0, 2120, 1636,
+ -0, -1059, -870, 0, 596, 493, -0, -334, -272, 0,
+ 175, 138, -0, -83, -64, -0, 39, 33, -0
+};
+
+
+
+const Word16 inner_frame_tbl_fx[4] = {L_FRAME8k, L_FRAME16k, L_FRAME32k, L_FRAME48k}; /* corresponds to NB, WB, SWB, FB */
+
+
+const Word16 cu15_fx[28][3] = /*Q13*/
+{
+ /* xx/3, xx*xx/3, xx*xx*xx/3 xx v */
+ /* 0:*/ { 182, 12, 1 }, /* 1/15 */
+ /* 1:*/ { 364, 49, 6 }, /* 2/15 */
+ /* 2:*/ { 546, 109, 22 }, /* 3/15 */
+ /* 3:*/ { 728, 194, 52 }, /* 4/15 */
+ /* 4:*/ { 910, 303, 101 }, /* 5/15 */
+ /* 5:*/ { 1092, 437, 175 }, /* 6/15 */
+ /* 6:*/ { 1274, 595, 278 }, /* 7/15 */
+ /* 7:*/ { 1456, 777, 414 }, /* 8/15 */
+ /* 8:*/ { 1638, 983, 590 }, /* 9/15 */
+ /* 9:*/ { 1820, 1214, 809 }, /* 10/15 */
+ /*10:*/ { 2002, 1468, 1077 }, /* 11/15 */
+ /*11:*/ { 2185, 1748, 1398 }, /* 12/15 */
+ /*12:*/ { 2367, 2051, 1778 }, /* 13/15 */
+ /*13:*/ { 2549, 2379, 2220 }, /* 14/15 */
+ /*14:*/ { 2913, 3107, 3314 }, /* 16/15 */
+ /*15:*/ { 3095, 3507, 3975 }, /* 17/15 */
+ /*16:*/ { 3277, 3932, 4719 }, /* 18/15 */
+ /*17:*/ { 3459, 4381, 5550 }, /* 19/15 */
+ /*18:*/ { 3641, 4855, 6473 }, /* 20/15 */
+ /*19:*/ { 3823, 5352, 7493 }, /* 21/15 */
+ /*20:*/ { 4005, 5874, 8615 }, /* 22/15 */
+ /*21:*/ { 4187, 6420, 9844 }, /* 23/15 */
+ /*22:*/ { 4369, 6991, 11185 }, /* 24/15 */
+ /*23:*/ { 4551, 7585, 12642 }, /* 25/15 */
+ /*24:*/ { 4733, 8204, 14221 }, /* 26/15 */
+ /*25:*/ { 4915, 8847, 15925 }, /* 27/15 */
+ /*26:*/ { 5097, 9515, 17761 }, /* 28/15 */
+ /*27:*/ { 5279, 10207, 19733 }, /* 29/15 */
+};
+
+const Word16 cu4_fx[6][3] = /*Q13*/
+{
+ /* xx/3, xx*xx/3, xx*xx*xx/3 xx v */
+ /* 0:*/ { 683, 171, 43 }, /* 1/4 */
+ /* 1:*/ { 1365, 683, 341 }, /* 2/4 */
+ /* 2:*/ { 2048, 1536, 1152 }, /* 3/4 */
+ /* 3:*/ { 3413, 4267, 5333 }, /* 5/4 */
+ /* 4:*/ { 4096, 6144, 9216 }, /* 6/4 */
+ /* 5:*/ { 4779, 8363, 14635 }, /* 7/4 */
+};
+
+const Word16 ct2_fx[7][14] =
+{
+ /* accepted configurations */
+ /*input 12.8, output : fout/fin Q13*/
+ /*8*/ {30, 22, 30, 16, 25, 30, 19, 30, 30, 0, 8, 4, 15, 5120},
+ /*16*/ {25, 22, 19, 16, 16, 0, 0, 0, 12, 1, 4, 4, 15, 10240},
+ /*32*/ {19, 16, 19, 16, 16, 0, 0, 0, 6, 2, 2, 4, 15, 20480},
+ /*48*/ {17, 14, 15, 16, 16, 0, 0, 0, 4, 3, 4, 4, 15, 30720},
+
+ /*input 16, output :*/
+ /*12*/ { 9, 3, 4, 5, 9, 0, 0, 0, 5, 0, 5, 5, 4, 6554},
+ /*32*/ { 4, 4, 4, 4, 4, 0, 0, 0, 2, 1, 1, 4, 4, 16384},
+ /*48*/ {18, 18, 18, 18, 18, 0, 0, 0, 5, 2, 1, 4, 15, 24576},
+};
+
+
+/* stable ISF vector */
+const Word16 stable_ISF_fx[M] =
+{ 1023, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 13311, 14335, 15361, 3978};
+/*------------------------------------------------------------------------------*
+ * SWB CNG table
+ *------------------------------------------------------------------------------*/
+const Word16 lsp_shb_prev_tbl_fx[LPC_SHB_ORDER]=
+{
+ /*Q15 */
+ 0,
+ 1638,
+ 3277,
+ 4915,
+ 6554,
+ 8192,
+ 9830,
+ 11469,
+ 13107,
+ 14746
+};
+const Word16 ENR_ATT_fx[5] = /*Q8*/
+{
+ 459, 357, 281, 255, 255
+};
+
+const Word16 sin_table256_fx[] =
+{
+ 101, 302, 503, 704, 905, 1106, 1307, 1507, 1708,
+ 1909, 2110, 2310, 2511, 2711, 2912, 3112, 3312, 3512,
+ 3712, 3911, 4111, 4310, 4510, 4709, 4907, 5106, 5305,
+ 5503, 5701, 5899, 6097, 6294, 6491, 6688, 6885, 7081,
+ 7278, 7473, 7669, 7864, 8059, 8254, 8449, 8643, 8836,
+ 9030, 9223, 9416, 9608, 9800, 9992, 10183, 10374, 10565,
+ 10755, 10945, 11134, 11323, 11511, 11699, 11887, 12074, 12261,
+ 12447, 12633, 12818, 13003, 13187, 13371, 13554, 13737, 13919,
+ 14101, 14282, 14463, 14643, 14823, 15002, 15180, 15358, 15535,
+ 15712, 15888, 16064, 16239, 16413, 16587, 16760, 16932, 17104,
+ 17275, 17446, 17616, 17785, 17953, 18121, 18288, 18455, 18621,
+ 18786, 18950, 19114, 19277, 19439, 19601, 19761, 19921, 20081,
+ 20239, 20397, 20554, 20710, 20865, 21020, 21174, 21327, 21479,
+ 21631, 21781, 21931, 22080, 22228, 22375, 22522, 22668, 22812,
+ 22956, 23099, 23241, 23383, 23523, 23663, 23801, 23939, 24076,
+ 24212, 24347, 24481, 24614, 24746, 24878, 25008, 25138, 25266,
+ 25394, 25520, 25646, 25771, 25894, 26017, 26139, 26259, 26379,
+ 26498, 26616, 26733, 26848, 26963, 27077, 27190, 27301, 27412,
+ 27522, 27630, 27738, 27844, 27950, 28054, 28158, 28260, 28361,
+ 28461, 28560, 28658, 28755, 28851, 28946, 29040, 29132, 29224,
+ 29314, 29404, 29492, 29579, 29665, 29750, 29833, 29916, 29997,
+ 30078, 30157, 30235, 30312, 30388, 30462, 30536, 30608, 30680,
+ 30750, 30819, 30886, 30953, 31018, 31082, 31146, 31207, 31268,
+ 31328, 31386, 31443, 31499, 31554, 31608, 31660, 31711, 31761,
+ 31810, 31858, 31904, 31950, 31994, 32037, 32078, 32119, 32158,
+ 32196, 32233, 32268, 32303, 32336, 32368, 32398, 32428, 32456,
+ 32483, 32509, 32534, 32557, 32579, 32600, 32620, 32638, 32656,
+ 32672, 32686, 32700, 32712, 32723, 32733, 32742, 32749, 32756,
+ 32760, 32764, 32767, 32767
+};
+/*----------------------------------------------------------------------------------*
+ * 2nd order high-pass filter with cut-off frequency at 400 Hz.
+ * Designed with Chebyshev of 2nd type
+ * Optimized for fixed-point to get the following frequency response:
+ *
+ * frequency: 0Hz 100Hz 200Hz 300Hz 400Hz 630Hz 1.5kHz 3kHz
+ * dB loss: -infdB -30dB -20dB -10dB -3dB +6dB +1dB 0dB
+ *
+ * Algorithm:
+ *
+ * y[i] = b[0]*x[i] + b[1]*x[i-1] + b[2]*x[i-2]
+ * + a[1]*y[i-1] + a[2]*y[i-2];
+ *
+ * short b[3] = {3660, -7320, 3660}; in Q12
+ * short a[3] = {4096, 7320, -3540}; in Q12
+ *----------------------------------------------------------------------------------*/
+const Word16 b_hp400_fx[3] = { 3660, -7320, 3660}; /* Q12 (/4) */
+const Word16 a_hp400_fx[3] = {16384, 29280, -14160}; /* Q12 (x4) */
+/*----------------------------------------------------------------------------------*
+ * 15th-order band-pass 6kHz to 7kHz FIR filter.
+ *
+ * frequency: 4kHz 5kHz 5.5kHz 6kHz 6.5kHz 7kHz 7.5kHz 8kHz
+ * dB loss: -60dB -45dB -13dB -3dB 0dB -3dB -13dB -45dB
+ *
+ * gain = 4.0
+ *----------------------------------------------------------------------------------*/
+const Word16 fir_6k_7k_fx[31] =
+{
+ -32, 47, 32, -27, -369,
+ 1122, -1421, 0, 3798, -8880,
+ 12349, -10984, 3548, 7766, -18001,
+ 22118, -18001, 7766, 3548, -10984,
+ 12349, -8880, 3798, 0, -1421,
+ 1122, -369, -27, 32, 47,
+ -32
+};
+
+
+const Word16 no_lead_fx[][MAX_NO_SCALES*2] =
+{
+ { 1, 0, 0, 1, 0, 0, }, /* 14 */
+ { 2, 0, 0, 1, 0, 0, }, /* 15 */
+ { 4, 2, 0, 1, 0, 0, }, /* 18 */
+ { 4, 2, 0, 2, 0, 0, }, /* 19 */
+ { 7, 5, 2, 5, 4, 2, }, /* 25 */
+ { 8, 8, 3, 8, 6, 2, }, /* 28 */ /* mode UV WB*/
+ { 4, 2, 0, 1, 0, 0, }, /* 18 */
+ { 4, 0, 0, 2, 1, 0, }, /* 19 */
+ { 9, 8, 8, 2, 2, 1, }, /* 24 */
+ { 8, 5, 2, 5, 2, 1, }, /* 25 */
+ { 18, 16, 8, 5, 5, 1, }, /* 29 */
+ { 24, 21, 10, 8, 8, 2, }, /* 32 */ /* mode UV NB*/
+
+ { 2, 0, 0, 2, 0, 0, }, /* 17 */
+ { 4, 2, 0, 1, 0, 0, }, /* 18 */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 */
+ { 5, 2, 1, 4, 1, 0, }, /* 22 */
+ { 8, 5, 2, 5, 2, 0, }, /* 25 */
+ { 8, 7, 4, 5, 3, 2, },
+ { 8, 8, 4, 6, 5, 2, },
+ { 13, 8, 5, 6, 5, 2, },
+ { 13, 8, 5, 8, 6, 2, },
+ { 13, 8, 5, 11, 8, 2, }, /* 30 */
+ { 24, 21, 8, 9, 8, 2, }, /* 32 */
+ { 23, 18, 8, 13, 11, 3, },
+ { 23, 21, 8, 17, 13, 4, }, /* 34 */
+ { 31, 31, 17, 26, 25, 9, }, /* 37 */ /* mode V WB*/
+ { 2, 0, 0, 2, 2, 0, }, /* 17 */
+ { 4, 2, 0, 1, 0, 0, }, /* 18 */
+ { 7, 5, 2, 2, 2, 0, }, /* 22 */
+ { 8, 7, 2, 2, 2, 0, }, /* 23 */
+ { 11, 8, 2, 2, 2, 0, }, /* 24 */
+ { 13, 13, 9, 2, 2, 0, }, /* 25 */
+ { 13, 11, 7, 5, 2, 0, }, /* 27 */
+ { 18, 14, 9, 5, 5, 2, }, /* 29 */
+ { 31, 31, 14, 11, 11, 5, }, /* 34 */
+ { 31, 31, 27, 24, 21, 14, }, /* 37 */ /* mode V NB */
+ { 5, 4, 0, 0, 0, 0, }, /* 12 (11.883) */
+ { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */
+ { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */
+ { 5, 4, 0, 2, 0, 0, }, /* 20 (19.796) */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */
+ { 5, 5, 2, 4, 2, 0, }, /* 23 (22.959) */
+ { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */
+ { 8, 8, 7, 5, 2, 0, }, /* 26 (25.904) */
+ { 13, 9, 8, 5, 2, 0, }, /* 27 (26.829) */
+ { 13, 11, 8, 5, 5, 1, }, /* 28 (27.989) */
+ { 13, 9, 8, 8, 5, 2, }, /* 29 (28.984) */
+ { 22, 16, 10, 6, 5, 2, }, /* 30 (29.980) */
+ { 21, 14, 10, 8, 7, 2, }, /* 31 (30.966) */
+ { 24, 21, 10, 8, 8, 2, }, /* 32 (31.995) */ /* G WB*/
+
+ { 5, 4, 1, 0, 0, 0, }, /* 12 (11.925) */
+ { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */
+ { 5, 4, 1, 1, 0, 0, }, /* 19 (18.745) */
+ { 5, 4, 1, 2, 0, 0, }, /* 20 (19.838) */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */
+ { 9, 8, 5, 2, 1, 0, }, /* 23 (22.815) */
+ { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */
+ { 13, 8, 7, 4, 2, 0, }, /* 26 (25.993) */
+ { 13, 9, 8, 5, 2, 2, }, /* 27 (26.954) */
+ { 18, 13, 8, 5, 2, 2, }, /* 28 (27.992) */
+ { 21, 13, 11, 5, 3, 2, }, /* 29 (28.996) */
+ { 22, 21, 13, 5, 5, 2, }, /* 30 (29.988) */
+ { 23, 21, 17, 7, 5, 2, }, /* 31 (30.962) */
+ { 27, 23, 21, 8, 5, 2, }, /* 32 (31.987) */ /* G NB*/
+ { 2, 0, 0, 2, 0, 0, }, /* 17 */
+ { 4, 2, 0, 1, 0, 0, }, /* 18 */
+ { 4, 1, 0, 4, 0, 0, }, /* 21 */
+ { 5, 2, 0, 4, 1, 0, }, /* 22 */
+ { 8, 5, 2, 4, 0, 0, }, /* 24 */
+ { 8, 5, 2, 5, 2, 0, }, /* 25 */
+ { 14, 10, 5, 5, 5, 1, }, /* 28 */
+ { 14, 10, 5, 8, 8, 4, }, /* 30 */
+ { 13, 10, 5, 13, 8, 8, },
+ { 23, 21, 8, 8, 8, 4, },
+ { 23, 18, 5, 13, 8, 8, }, /* 33 */
+ /* mode T WB */
+ { 2, 0, 0, 2, 2, 0, }, /* 17 */
+ { 4, 2, 0, 1, 0, 0, }, /* 18 */
+ { 7, 5, 2, 2, 2, 0, }, /* 22 */
+ { 8, 7, 4, 2, 2, 0, }, /* 23 */
+ { 11, 8, 5, 2, 2, 0, }, /* 24 */
+ { 18, 8, 5, 2, 2, 0, }, /* 25 */
+ { 16, 8, 5, 5, 5, 2, }, /* 28 */
+ { 28, 23, 8, 5, 5, 5, }, /* 31 */
+ { 31, 31, 8, 5, 5, 7, }, /* 32 */ /* mode T NB */
+
+ { 18, 18, 11, 9, 6, 5, }, /* 31 */
+ { 24, 23, 13, 9, 6, 5, }, /* 32 */ /* mode G 16k */
+
+ { 24, 23, 13, 9, 6, 5, }, /* 32 (31.998) */
+ { 36, 31, 18, 9, 6, 5, }, /* 33 (32.983) */ /* T 16k */
+
+ { 2, 0, 0, 2, 2, 0, }, /* 17 */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 */
+ { 7, 5, 2, 2, 2, 0, }, /* 22 */
+ { 9, 8, 3, 4, 2, 0, }, /* 25 */
+ { 11, 9, 8, 4, 2, 0, }, /* 26 */
+ { 48, 48, 34, 13, 11, 9 }, /* 36 */ /* mode AUDIO_WB 36 + 4 + 1 */
+
+ { 22, 10, 3, 0, 0, 0 }, /* 17 */
+ { 6, 6, 2, 2, 0, 0 }, /* 21 */
+ { 6, 6, 2, 2, 2, 0 }, /* 22 */
+ { 23, 10, 3, 2, 2, 0 }, /* 26 */
+ { 32, 16, 3, 2, 2, 0 }, /* 27 */ /* AUDIO_NB */
+ { 39, 30, 12, 2, 2, 0 }, /* 28 */ /* AUDIO_NB */
+ { 11, 9, 8, 4, 2, 0, }, /* 26 */
+ { 48, 48, 48, 13, 9, 8 }, /* 36 */ /* mode AUDIO_WB 16k 15-36 + 4 + 1*/
+ { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */
+ { 13, 13, 5, 5, 5, 0, }, /* 28 (27.994) */
+ { 18, 17, 5, 5, 5, 1, }, /* 29 (28.996) */
+ { 17, 13, 5, 8, 6, 2, }, /* 30 (29.991) */
+ { 23, 21, 8, 9, 8, 3, }, /* 32 (31.992) */
+ { 31, 29, 16, 8, 8, 3, }, /* 33 (32.993) */
+ { 31, 25, 16, 12, 8, 8, }, /* 34 (33.968) */
+ { 46, 48, 18, 18, 18, 12, }, /* 37 (36.995) */ /* VOICED 16k */
+ { 14, 12, 9, 2, 2, 0, }, /* 25 (24.980) */
+ { 15, 13, 3, 2, 2, 0, }, /* 25 (24.974) */
+ { 17, 3, 0, 2, 2, 1, }, /* 25 (24.852) */
+ { 13, 10, 3, 2, 2, 2, }, /* 25 (24.994) */
+ { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */
+ { 7, 3, 0, 5, 3, 1, }, /* 25 (24.671) */
+ { 4, 3, 2, 6, 6, 5, }, /* 25 (24.936) */
+ { 4, 2, 0, 9, 9, 3, }, /* 25 (24.955) */
+ { 4, 2, 0, 9, 8, 2, }, /* 25 (24.853) */
+ { 4, 2, 0, 9, 7, 6, }, /* 25 (24.881) */
+ { 6, 3, 0, 6, 3, 2, }, /* 25 (24.939) */
+ { 3, 2, 0, 9, 8, 5, }, /* 25 (24.996) */
+ { 2, 2, 0, 15, 3, 3, }, /* 25 (24.310) */
+ { 4, 2, 0, 9, 9, 3, }, /* 25 (24.955) */
+ { 4, 4, 2, 7, 6, 3, }, /* 25 (24.984) */
+ { 3, 2, 0, 9, 7, 6, }, /* 25 (24.866) */
+
+};
+
+const Word16 no_lead_p_fx[][MAX_NO_SCALES*2] =
+{
+
+ { 2, 1, 0, 0, 0, 0, }, /* 9 (8.464) */
+ { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */
+ { 5, 5, 2, 4, 2, 0, }, /* 23 (22.959) */
+ { 8, 5, 2, 4, 0, 0, }, /* 24 (23.949) */
+ { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */
+ { 13, 11, 5, 5, 2, 0, }, /* 27 (26.902) */
+ { 11, 10, 5, 6, 5, 2, }, /* 28 (27.996) */
+ { 14, 13, 5, 7, 5, 2, }, /* 29 (28.937) */
+ { 16, 13, 5, 8, 7, 2, }, /* 30 (29.954) */
+ { 21, 21, 5, 8, 5, 2, }, /* 31 (30.978) */
+ { 24, 21, 5, 8, 8, 4, }, /* 32 (31.978) */
+ { 32, 23, 5, 13, 11, 5, }, /* 34 (33.975) */
+ { 36, 31, 8, 16, 13, 5, }, /* 35 (34.975) */
+ { 45, 35, 16, 18, 13, 5, }, /* 36 (35.889) */
+ { 45, 35, 16, 38, 31, 8, }, /* 39 (38.488) */ /* V WB*/ /* 14 */
+
+ { 2, 0, 0, 0, 0, 0, }, /* 8 (7.913) */
+ { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */
+ { 8, 7, 2, 2, 2, 0, }, /* 23 (22.773) */
+ { 13, 11, 5, 2, 1, 0, }, /* 24 (23.999) */
+ { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */
+ { 13, 11, 5, 5, 2, 1, }, /* 27 (26.962) */
+ { 13, 11, 5, 5, 5, 2, }, /* 28 (27.835) */
+ { 14, 13, 5, 7, 5, 2, }, /* 29 (28.937) */
+ { 23, 21, 5, 5, 5, 2, }, /* 30 (29.969) */
+ { 23, 18, 5, 8, 5, 2, }, /* 31 (30.952) */
+ { 24, 21, 5, 8, 8, 4, }, /* 32 (31.978) */
+ { 43, 41, 13, 9, 8, 5, }, /* 34 (33.992) */
+ { 43, 36, 13, 13, 10, 5, }, /* 35 (35.000) */
+ { 43, 40, 13, 17, 13, 9, }, /* 36 (35.980) */
+ { 43, 42, 13, 31, 30, 18, }, /* 39 (38.512) */ /* V NB*/ /* 29 */
+
+ { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */
+ { 5, 4, 1, 1, 0, 0, }, /* 19 (18.745) */
+ { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */
+ { 10, 9, 5, 2, 0, 0, }, /* 23 (22.791) */
+ { 14, 13, 8, 2, 0, 0, }, /* 24 (23.999) */
+ { 14, 13, 8, 2, 2, 0, }, /* 25 (24.996) */
+ { 18, 17, 13, 2, 2, 0, }, /* 26 (25.934) */
+ { 14, 13, 8, 5, 4, 0, }, /* 28 (27.969) */
+ { 18, 17, 13, 5, 4, 2, }, /* 29 (28.996) */
+ { 22, 21, 13, 5, 5, 2, }, /* 30 (29.988) */
+ { 31, 23, 21, 5, 5, 2, }, /* 31 (30.931) */
+ { 27, 23, 21, 8, 5, 2, }, /* 32 (31.987) */
+ { 31, 23, 21, 9, 8, 5, }, /* 33 (32.982) */
+ { 32, 31, 24, 11, 8, 5, }, /* 34 (33.967) */
+ { 32, 32, 28, 13, 11, 8, }, /* 35 (34.994) */ /* G WB*/ /* 44 */
+
+ { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */
+ { 5, 4, 2, 1, 0, 0, }, /* 19 (18.792) */
+ { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */
+ { 8, 7, 2, 2, 2, 0, }, /* 23 (22.773) */
+ { 13, 11, 2, 2, 1, 0, }, /* 24 (23.932) */
+ { 16, 13, 2, 2, 2, 0, }, /* 25 (24.955) */
+ { 21, 17, 2, 2, 2, 0, }, /* 26 (25.991) */
+ { 13, 12, 2, 5, 5, 2, }, /* 28 (27.979) */
+ { 18, 16, 2, 5, 5, 2, }, /* 29 (28.878) */
+ { 23, 21, 2, 5, 5, 2, }, /* 30 (29.954) */
+ { 32, 28, 2, 5, 5, 2, }, /* 31 (30.893) */
+ { 38, 31, 2, 7, 5, 2, }, /* 32 (31.963) */
+ { 33, 31, 2, 8, 8, 4, }, /* 33 (32.997) */
+ { 42, 31, 2, 9, 9, 8, }, /* 34 (33.986) */
+ { 42, 31, 2, 13, 11, 9, }, /* 35 (34.952) */ /* G NB*/ /* 59 */
+
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */
+ { 13, 8, 5, 4, 2, 0, }, /* 26 */
+ { 13, 8, 5, 8, 6, 2, }, /* 29 */
+ { 13, 8, 5, 9, 8, 5, }, /* 30 */
+ { 48, 48, 48, 36, 36, 28 }, /* 40 */ /* mode 7 AUDIO_WB */ /* 65*/
+
+ { 7, 5, 2, 2, 0, 0 }, /* 21 */
+ { 13, 13, 9, 2, 2, 0 }, /* 25 */
+ { 18, 18, 9, 2, 2, 0 }, /* 26 */
+ { 24, 23, 10, 5, 4, 2 }, /* 30 */
+ { 31, 31, 12, 5, 5, 2 }, /* 31 */ /*AUDIO_NB */ /* 70 */
+ { 43, 34, 12, 5, 5, 4 }, /* 32 */ /*AUDIO_NB */ /* 71 */
+ { 13, 8, 5, 9, 8, 5, }, /* 30 */
+ { 48, 48, 45, 45, 31, 25 }, /* 40 */ /* mode AUDIO_WB 16k */ /* 73*/
+
+ { 2, 0, 0, 2, 2, 0, }, /* 17 (16.823) */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 7, 5, 2, 2, 2, 0, }, /* 22 (21.907) */
+ { 13, 11, 10, 2, 2, 0, }, /* 25 (24.863) */
+ { 18, 18, 10, 2, 2, 0, }, /* 26 (25.921) */
+ { 13, 9, 9, 5, 2, 0, }, /* 27 (26.837) */
+ { 40, 28, 25, 18, 17, 2, }, /* 36 (35.998) */ /* INACTIVE NB*/ /* 80*/
+
+ { 18, 17, 11, 0, 0, 0, }, /* 17 (16.932) */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */
+ { 13, 13, 9, 2, 2, 0, }, /* 25 (24.845) */
+ { 18, 18, 12, 2, 2, 0, }, /* 26 (25.999) */
+ { 23, 23, 16, 2, 2, 0, }, /* 27 (26.981) */
+ { 36, 32, 24, 17, 13, 13, }, /* 36 (35.929) */ /* INACTIVE WB */ /* 87 */
+
+ { 2, 2, 0, 2, 0, 0, }, /* 17 (16.823) */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 8, 5, 2, 2, 1, 0, }, /* 22 (21.985) */
+ { 13, 13, 9, 2, 2, 0, }, /* 25 (24.845) */
+ { 18, 17, 13, 2, 2, 0, }, /* 26 (25.934) */
+ { 23, 22, 17, 2, 2, 0, }, /* 27 (26.914) */
+ { 34, 32, 24, 16, 16, 13, }, /* 36 (35.915) */ /* INACTIVE WB 16k*/ /* 94 */
+
+ { 4, 2, 0, 1, 0, 0, }, /* 18 (17.479) */
+ { 5, 4, 0, 1, 0, 0, }, /* 19 (18.703) */
+ { 8, 7, 2, 2, 0, 0, }, /* 22 (21.776) */
+ { 10, 9, 5, 2, 0, 0, }, /* 23 (22.791) */
+ { 15, 13, 5, 2, 0, 0, }, /* 24 (23.999) */
+ { 18, 16, 8, 5, 5, 1, }, /* 29 (28.966) */
+ { 42, 32, 31, 5, 5, 2, }, /* 32 (31.990) */ /* UNVOICED NB*/ /* 100 */
+
+ { 1, 0, 0, 1, 0, 0, }, /* 14 (13.640) */
+ { 2, 0, 0, 1, 0, 0, }, /* 15 (14.733) */
+ { 4, 2, 0, 1, 0, 0, }, /* 18 (17.479) */
+ { 4, 2, 0, 2, 0, 0, }, /* 19 (18.572) */
+ { 5, 4, 0, 2, 0, 0, }, /* 20 (19.796) */
+ { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */
+ { 11, 10, 5, 6, 5, 2, }, /* 28 (27.996) */ /* UNVOICED WB */ /* 106 */
+ { 9, 3, 0, 4, 0, 0, }, /* 24 (23.818) */
+ { 18, 13, 10, 8, 3, 0, }, /* 30 (29.992) */
+ { 24, 18, 10, 9, 3, 0, }, /* 31 (30.998) */
+ { 32, 25, 10, 9, 3, 0, }, /* 32 (31.987) */
+ { 42, 31, 10, 12, 3, 2, }, /* 34 (33.994) */
+ { 44, 32, 27, 15, 3, 2, }, /* 35 (35.000) */
+ { 44, 32, 25, 19, 3, 2, }, /* 36 (35.994) */
+ { 48, 39, 32, 35, 15, 3, }, /* 39 (38.301) */ /* VOICED 16k */
+ { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ /* 107 */
+ { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */
+ { 32, 31, 18, 9, 7, 5, }, /* 33 (32.990) */
+ { 31, 31, 18, 11, 9, 8, }, /* 34 (33.974) */
+ { 32, 32, 20, 13, 12, 8, }, /* 35 (34.989) */
+ { 32, 32, 23, 18, 17, 8, }, /* 36 (35.988) */
+ { 32, 32, 23, 23, 22, 10, }, /* 37 (36.989) */ /* GENERIC 16k*/ /* 113 */
+
+ { 2, 0, 0, 2, 0, 0, }, /* 16 (15.826) */ /* 114 */
+ { 7, 5, 2, 2, 0, 0, }, /* 21 (20.910) */
+ { 14, 13, 8, 2, 0, 0, }, /* 24 (23.999) */
+ { 8, 8, 5, 4, 2, 0, }, /* 25 (24.992) */
+ { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */
+ { 16, 13, 8, 4, 2, 0, }, /* 27 (26.883) */
+ { 13, 13, 8, 5, 4, 2, }, /* 28 (27.901) */
+ { 23, 18, 13, 5, 5, 2, }, /* 30 (29.916) */
+ { 23, 23, 13, 7, 5, 2, }, /* 31 (30.993) */
+ { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */
+ { 32, 31, 24, 8, 7, 2, }, /* 33 (32.958) */
+ { 42, 32, 31, 9, 9, 4, }, /* 34 (33.987) */
+ { 40, 32, 29, 12, 9, 9, }, /* 35 (34.994) */
+ { 40, 32, 31, 17, 11, 11, }, /* 36 (35.968) */
+ { 41, 32, 31, 20, 18, 13, }, /* 37 (36.971) */ /* GENERIC 12.8k MA*/ /* 128 */
+
+ { 11, 10, 5, 4, 2, 0, }, /* 26 (25.917) */ /* 129 */
+ { 23, 23, 17, 8, 7, 2, }, /* 32 (31.980) */
+ { 31, 31, 18, 9, 8, 2, }, /* 33 (32.995) */
+ { 48, 32, 24, 9, 8, 3, }, /* 34 (33.993) */
+ { 48, 32, 28, 11, 10, 3, }, /* 35 (34.992) */
+ { 48, 37, 32, 16, 12, 4, }, /* 36 (35.997) */
+ { 48, 37, 32, 18, 17, 12, }, /* 37 (36.961) */ /* AUDIO 16k */
+};
+
+const Word16 pl_HQ_fx[] = /* Q1 vectors in first layers */
+{
+ 2, 2, 0, 0, 0, 0, 0, 0, /* 112, 4, 28 */
+ 1, 1, 1, 1, 1, 1, 1, 1, /* 128, 128, 1 */
+ 2, 2, 2, 2, 0, 0, 0, 0, /* 1120, 16, 70 */
+ 4, 0, 0, 0, 0, 0, 0, 0, /* 16 , 2, 8 */
+ 3, 1, 1, 1, 1, 1, 1, 1, /* 5 */ /* 1024,128, 8 */
+ 2, 2, 2, 2, 2, 2, 0, 0, /* 1792, 64, 28 */
+ 4, 2, 2, 0, 0, 0, 0, 0, /* 1344, 8, 168 */
+ 3, 3, 1, 1, 1, 1, 1, 1, /* 3584, 128, 28*/
+ 2, 2, 2, 2, 2, 2, 2, 2, /*256, 256, 1*/
+ 4, 2, 2, 2, 2, 0, 0, 0, /* 10 */ /* 8960, 32, 280 */
+ 4, 4, 0, 0, 0, 0, 0, 0, /* 112, 4, 28 */
+ 3, 3, 3, 1, 1, 1, 1, 1, /* 7168, 128, 56 */
+ 5, 1, 1, 1, 1, 1, 1, 1, /* 1024, 128, 8*/
+ 4, 2, 2, 2, 2, 2, 2, 0, /* 7168, 128, 56*/
+ 4, 4, 2, 2, 0, 0, 0, 0, /* 15 */ /* 6720, 16, 420 */
+ 6, 2, 0, 0, 0, 0, 0, 0, /* 224, 4, 56 */
+ 3, 3, 3, 3, 1, 1, 1, 1, /* 8960, 128, 70 */
+ 5, 3, 1, 1, 1, 1, 1, 1, /* 7168, 128, 56*/
+ 4, 4, 2, 2, 2, 2, 0, 0, /* 26880, 64, 420 */
+ 4, 4, 4, 0, 0, 0, 0, 0, /*20 */ /* 448, 8, 56 */
+ 6, 2, 2, 2, 0, 0, 0, 0, /* 4480, 16, 280 */
+ 3, 3, 3, 3, 3, 1, 1, 1, /* 7168, 128, 56 */
+ 5, 3, 3, 1, 1, 1, 1, 1, /* 21504, 128, 168 */
+ 4, 4, 2, 2, 2, 2, 2, 2, /* 7168, 256, 28 */
+ 4, 4, 4, 2, 2, 0, 0, 0, /* 25 */ /* 17920, 32, 560 */
+ 6, 2, 2, 2, 2, 2, 0, 0, /* 10752, 64, 168 */
+ 6, 4, 2, 0, 0, 0, 0, 0, /* 2688, 8, 336 */
+ 3, 3, 3, 3, 3, 3, 1, 1, /* 3584, 128, 28 */
+ 5, 3, 3, 3, 1, 1, 1, 1, /* 35840,128,280*/
+ 5, 5, 1, 1, 1, 1, 1, 1, /*30 */ /* 3584, 128, 28*/
+ 7, 1, 1, 1, 1, 1, 1, 1, /* 1024,128, 8 */
+ 4, 4, 4, 2, 2, 2, 2, 0,
+ 4, 4, 4, 4, 0, 0, 0, 0,
+ 6, 2, 2, 2, 2, 2, 2, 2,
+ 6, 4, 2, 2, 2, 0, 0, 0,
+ 8, 0, 0, 0, 0, 0, 0, 0,
+ 3, 3, 3, 3, 3, 3, 3, 1,
+ 5, 3, 3, 3, 3, 1, 1, 1,
+ 5, 5, 3, 1, 1, 1, 1, 1,
+ 7, 3, 1, 1, 1, 1, 1, 1,
+ 4, 4, 4, 4, 2, 2, 0, 0,
+ 6, 4, 2, 2, 2, 2, 2, 0,
+ 6, 4, 4, 2, 0, 0, 0, 0,
+ 6, 6, 0, 0, 0, 0, 0, 0,
+ 8, 2, 2, 0, 0, 0, 0, 0,
+ 3, 3, 3, 3, 3, 3, 3, 3,
+ 5, 3, 3, 3, 3, 3, 1, 1,
+ 5, 5, 3, 3, 1, 1, 1, 1,
+ 7, 3, 3, 1, 1, 1, 1, 1
+};
+
+const Word32 table_no_cv_fx[] = { 0, 112, 240, 1360, 1376, 2400, 4192, 5536, 9120, 9376, 18336, 18448, 25616, 26640, 33808, 40528, 40752,
+ 49712, 56880, 83760, 84208, 88688, 95856, 117360, 124528, 142448, 153200, 155888, 159472, 195312, 198896, 199920,
+ 235760, 236880, 238928, 274768, 274784, 275808, 311648, 333152, 340320, 367200, 410208, 423648,423760, 425104, 425232, 446736, 500496, 522000
+ ,0
+ };
+
+
+
+/* Innovative codebook config */
+const PulseConfig PulseConfTable[ACELP_FIXED_CDK_NB] =
+{
+ /* Design rules:
+ * ---> "fixed" + "tried-pair-pos"*2 = pulses & 0xfe
+ * ---> tracks with pulses % 3 == 0, have always TRACKPOS_FIXED_FIRST */
+ /* bits,iter,alp,pulses,fixed,tried-pair-pos,codetrack*/
+ { 7, 4, 16384/*2.0f Q13*/, 1, 0, {8}, TRACKPOS_FREE_ONE }, /* 7 bits, 1 pulses, 4 tracks, 1000 free track */
+ { 10, 4, 16384/*2.0f Q13*/, 2, 0, {8}, TRACKPOS_FIXED_EVEN }, /* 10 bits, 2 pulses, 4 tracks 1010 (used only even tracks designed for NB) */
+ { 12, 4, 16384/*2.0f Q13*/, 2, 0, {8}, TRACKPOS_FIXED_TWO }, /* 12 bits, 2 pulses, 2 tracks 11 used all tracks ala AMR-WB 6.6 */
+ { 15, 4, 16384/*2.0f Q13*/, 3, 0, {8}, TRACKPOS_FIXED_FIRST }, /* 15 bits, 3 pulses, 4 tracks 1110 fixed track to first ? */
+ { 17, 6, 16384/*2.0f Q13*/, 3, 0, {8}, TRACKPOS_FREE_THREE }, /* 17 bits, 3 pulses, 4 tracks (used all tracks) - 1110, 1101, 1011, 0111 */
+ { 20, 4, 16384/*2.0f Q13*/, 4, 0, {4, 8}, TRACKPOS_FIXED_FIRST }, /* 20 bits, 4 pulses, 4 tracks 1111 */
+ { 24, 4, 16384/*2.0f Q13*/, 5, 0, {4, 8}, TRACKPOS_FIXED_FIRST }, /* 24 bits, 5 pulses, 4 tracks 2111 fixed track to first */
+ { 26, 4, 16384/*2.0f Q13*/, 5, 0, {4, 8}, TRACKPOS_FREE_ONE }, /* 26 bits, 5 pulses, 4 tracks 2111 one free track ? */
+ { 28, 4, 12288/*1.5f Q13*/, 6, 0, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 28 bits, 6 pulses, 4 tracks 2211 */
+ { 30, 4, 12288/*1.5f Q13*/, 6, 0, {4, 8, 8}, TRACKPOS_FIXED_TWO }, /* 30 bits, 6 pulses, 4 tracks 2211 free consecutive track positions ? */
+ { 32, 4, 12288/*1.5f Q13*/, 7, 0, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 32 bits, 6 pulses, 4 tracks 2221 fixed ?*/
+ { 34, 4, 12288/*1.5f Q13*/, 7, 0, {4, 8, 8}, TRACKPOS_FREE_THREE }, /* 34 bits, 6 pulses, 4 tracks 2221 free track positions ? */
+ { 36, 4, 8192/*1.0f Q13*/, 8, 2, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 36 bits, 8 pulses, 4 tracks 2222 */
+ { 40, 4, 8192/*1.0f Q13*/, 9, 2, {4, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 40 bits, 9 pulses, 4 tracks 3222 fixed ?*/
+ { 43, 4, 8192/*1.0f Q13*/, 10, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 44 bits, 10 pulses, 4 tracks 3322 */
+ { 46, 4, 8192/*1.0f Q13*/, 10, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_TWO }, /* 46 bits, 10 pulses, 4 tracks 3322 free consecutive tracks ? */
+ { 47, 4, 8192/*1.0f Q13*/, 11, 2, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 47 bits, 10 pulses, 4 tracks 3332 fixed ? */
+ { 49, 4, 8192/*1.0f Q13*/, 11, 2, {4, 6, 8, 8}, TRACKPOS_FREE_THREE }, /* 49 bits, 10 pulses, 4 tracks 3332 free three track positions ? */
+ { 50, 4, 8192/*1.0f Q13*/, 12, 4, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 50 bits, 12 pulses, 4 tracks 3333 */
+ { 53, 4, 8192/*1.0f Q13*/, 13, 4, {4, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 53 bits, 13 pulses, 4 tracks 4333 fixed ? */
+ { 55, 4, 8192/*1.0f Q13*/, 13, 4, {4, 6, 8, 8}, TRACKPOS_FREE_ONE }, /* 55 bits, 13 pulses, 4 tracks 4333 free one ? */
+ { 56, 4, 8192/*1.0f Q13*/, 14, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 56 bits, 14 pulses, 4 tracks 4433 fixed ?!?! */
+ { 58, 4, 8192/*1.0f Q13*/, 14, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_TWO }, /* 58 bits, 14 pulses, 4 tracks 4433 free consecutive ? */
+ { 59, 4, 8192/*1.0f Q13*/, 15, 4, {4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 59 bits, 15 pulses, 4 tracks 4443 fixed ? */
+ { 61, 4, 8192/*1.0f Q13*/, 15, 4, {4, 6, 6, 8, 8}, TRACKPOS_FREE_THREE }, /* 61 bits, 15 pulses, 4 tracks 4443 free ? */
+ { 62, 3, 6554/*0.8f Q13*/, 16, 4, {4, 4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 62 bits, 16 pulses, 4 tracks 4444 */
+ { 65, 3, 6554/*0.8f Q13*/, 17, 4, {4, 4, 6, 6, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 65 bits, 17 pulses, 4 tracks 5444 fixed ?*/
+ { 68, 3, 6144/*0.75f Q13*/, 18, 4, {2, 3, 4, 5, 6, 7, 8}, TRACKPOS_FIXED_FIRST }, /* 68 bits, 18 pulses, 4 tracks 5544 */
+ { 70, 3, 6144/*0.75f Q13*/, 19, 4, {2, 3, 4, 5, 6, 7, 8}, TRACKPOS_FIXED_FIRST }, /* 70 bits, 19 pulses, 4 tracks 5554 fixed ? */
+ { 73, 3, 6144/*0.75f Q13*/, 20, 4, {2, 3, 4, 5, 6, 7, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 73 bits, 20 pulses, 4 tracks 5555 fixed ? */
+ { 75, 3, 6144/*0.75f Q13*/, 21, 4, {2, 3, 4, 5, 6, 7, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 75 bits, 21 pulses, 4 tracks 6555 fixed ? */
+ { 78, 3, 6144/*0.75f Q13*/, 22, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 78 bits, 22 pulses, 4 tracks 6655 fixed ? */
+ { 80, 3, 6144/*0.75f Q13*/, 23, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8}, TRACKPOS_FIXED_FIRST }, /* 80 bits, 23 pulses, 4 tracks 6665 fixed ? */
+ { 83, 2, 2458/*0.30f Q13*/, 24, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 83 bits, 24 pulses, 4 tracks 6666 */
+ { 85, 2, 2458/*0.30f Q13*/, 25, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 85 bits, 25 pulses, 4 tracks 7666 */
+ { 87, 2, 2048/*0.25f Q13*/, 26, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 87 bits, 26 pulses, 4 tracks 7766 */
+ { 89, 2, 2048/*0.25f Q13*/, 27, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 89 bits, 27 pulses, 4 tracks 7776 */
+ { 92, 2, 2048/*0.25f Q13*/, 28, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 92 bits, 28 pulses, 4 tracks 7777 */
+ { 94, 2, 2048/*0.25f Q13*/, 29, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 94 bits, 29 pulses, 4 tracks 8777 */
+ { 96, 1, 1638/*0.20f Q13*/, 30, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 96 bits, 30 pulses, 4 tracks 8877 */
+ { 98, 1, 1638/*0.20f Q13*/, 31, 4, {2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8}, TRACKPOS_FIXED_FIRST}, /* 98 bits, 31 pulses, 4 tracks 8887 */
+};
+
+/*----------------------------------------------------------------------------------*
+ * LSF quantization for CNG
+ *----------------------------------------------------------------------------------*/
+const Word16 cng_sort_fx[] = {/*5f */1,1,0,1,0,0, /* 4f */0,1,0,1,0,0,1,1,1,1};
+
+const Word16 perm_MSLVQ_fx[][4] =
+{
+ /* 5f*/
+ {6,11,7,15},
+ {6,15,-1,0},
+ {5,8,7,15},
+ {7,10,-1,0},
+ {-1,0,0,0},
+ {-1,0,0,0},
+ /* 4f */
+ {-1,0,0,0},
+ {0,9,7,10},
+ {-1,0,0,0},
+ {7,15,-1,0},
+ {-1,0,0,0},
+ {-1,0,0,0},
+ {6,10,7,11},
+ {6,11,7,12},
+ {6,11,7,12},
+ {6,11,7,12}
+};
+/*----------------------------------------------------------------------------------*
+ * table of cos(x) in Q15 used in FFT for spectral analysis
+ *----------------------------------------------------------------------------------*/
+const Word16 cos_table_129[129] =
+{
+ 32767,
+ 32758, 32729, 32679, 32610, 32522, 32413, 32286, 32138,
+ 31972, 31786, 31581, 31357, 31114, 30853, 30572, 30274,
+ 29957, 29622, 29269, 28899, 28511, 28106, 27684, 27246,
+ 26791, 26320, 25833, 25330, 24812, 24279, 23732, 23170,
+ 22595, 22006, 21403, 20788, 20160, 19520, 18868, 18205,
+ 17531, 16846, 16151, 15447, 14733, 14010, 13279, 12540,
+ 11793, 11039, 10279, 9512, 8740, 7962, 7180, 6393,
+ 5602, 4808, 4011, 3212, 2411, 1608, 804, 0,
+ -804, -1608, -2411, -3212, -4011, -4808, -5602, -6393,
+ -7180, -7962, -8740, -9512, -10279, -11039, -11793, -12540,
+ -13279, -14010, -14733, -15447, -16151, -16846, -17531, -18205,
+ -18868, -19520, -20160, -20788, -21403, -22006, -22595, -23170,
+ -23732, -24279, -24812, -25330, -25833, -26320, -26791, -27246,
+ -27684, -28106, -28511, -28899, -29269, -29622, -29957, -30274,
+ -30572, -30853, -31114, -31357, -31581, -31786, -31972, -32138,
+ -32286, -32413, -32522, -32610, -32679, -32729, -32758, -32768
+};
+
+/*----------------------------------------------------------------------------------*
+ * slope in Q11 used to compute y = acos(x)
+ ----------------------------------------------------------------------------------*/
+const Word16 acos_slope[128] =
+{
+ -26214, -9039, -5243, -3799, -2979, -2405, -2064, -1771,
+ -1579, -1409, -1279, -1170, -1079, -1004, -933, -880,
+ -827, -783, -743, -708, -676, -647, -621, -599,
+ -576, -557, -538, -521, -506, -492, -479, -466,
+ -456, -445, -435, -426, -417, -410, -402, -395,
+ -389, -383, -377, -372, -367, -363, -359, -355,
+ -351, -348, -345, -342, -340, -337, -335, -333,
+ -331, -330, -329, -328, -327, -326, -326, -326,
+ -326, -326, -326, -327, -328, -329, -330, -331,
+ -333, -335, -337, -340, -342, -345, -348, -351,
+ -355, -359, -363, -367, -372, -377, -383, -389,
+ -395, -402, -410, -417, -426, -435, -445, -456,
+ -466, -479, -492, -506, -521, -538, -557, -576,
+ -599, -621, -647, -676, -708, -743, -783, -827,
+ -880, -933, -1004, -1079, -1170, -1279, -1409, -1579,
+ -1771, -2064, -2405, -2979, -3799, -5243, -9039,-26214
+};
+
+/*----------------------------------------------------------------------------------*
+ * Quantization table for scaled innovation energy prediciton in Q8
+ *----------------------------------------------------------------------------------*/
+const Word16 Es_pred_qua_5b_fx[32] =
+{
+ -2048,
+ -525,
+ 642,
+ 1688,
+ 2547,
+ 3326,
+ 4026,
+ 4647,
+ 5211,
+ 5740,
+ 6221,
+ 6661,
+ 7067,
+ 7447,
+ 7815,
+ 8170,
+ 8518,
+ 8865,
+ 9204,
+ 9551,
+ 9912,
+ 10284,
+ 10669,
+ 11077,
+ 11509,
+ 11976,
+ 12486,
+ 13049,
+ 13695,
+ 14434,
+ 15354,
+ 16640,
+};
+
+
+const Word16 Es_pred_qua_4b_fx[16] =
+{
+ -2048,
+ -36,
+ 1828,
+ 3284,
+ 4584,
+ 5742,
+ 6821,
+ 7834,
+ /*8779, */
+ 8778,
+ 9701,
+ 10610,
+ 11524,
+ 12487,
+ 13560,
+ 14862,
+ 16640
+};
+
+
+const Word16 Es_pred_qua_3b_fx[8] =
+{
+ 1521/* 5.9422f Q8*/,
+ 3909/*15.2711f Q8*/,
+ 5987/*23.3857f Q8*/,
+ 7816/*30.5310f Q8*/,
+ 9477/*37.0190f Q8*/,
+ 11124/*43.4539f Q8*/,
+ 12863/*50.2442f Q8*/,
+ 15031/*58.7164f Q8*/
+};
+const Word16 Es_pred_qua_4b_no_ltp_fx[16] =
+{
+ -1280/*-5.f Q8*/,
+ 0/* 0.f Q8*/,
+ 1280/* 5.f Q8*/,
+ 2560/*10.f Q8*/,
+ 3840/*15.f Q8*/,
+ 5120/*20.f Q8*/,
+ 6400/*25.f Q8*/,
+ 7680/*30.f Q8*/,
+ 8960/*35.f Q8*/,
+ 10240/*40.f Q8*/,
+ 11520/*45.f Q8*/,
+ 12800/*50.f Q8*/,
+ 14080/*55.f Q8*/,
+ 15360/*60.f Q8*/,
+ 16640/*65.f Q8*/,
+ 17920/*70.f Q8*/
+};
+/*----------------------------------------------------------------------------------*
+ * Transition coding - gain quantization table
+ *----------------------------------------------------------------------------------*/
+const Word16 tbl_gain_code_tc_fx[N_GAIN_CODE_TC] = /*q13 */
+{
+ 2966,
+ 5930,
+ 7924,
+ 9712,
+ 11566,
+ 13754,
+ 16993,
+ 27280
+};
+/*----------------------------------------------------------------------------------*
+ * MA predicition coefficients for gain quantizer
+ *----------------------------------------------------------------------------------*/
+
+const Word16 pred_gain_fx[GAIN_PRED_ORDER] = {8192, 6554, 4915, 3277};
+
+const Word16 t_qua_gain6b_fx[64*2] =
+{
+ 1566, 1332,
+ 1577, 3557,
+ 3071, 6490,
+ 4193, 10163,
+ 4496, 2534,
+ 5019, 4488,
+ 5586, 15614,
+ 5725, 1422,
+ 6453, 580,
+ 6724, 6831,
+ 7657, 3527,
+ 8072, 2099,
+ 8232, 5319,
+ 8827, 8775,
+ 9740, 2868,
+ 9856, 1465,
+ 10087, 12488,
+ 10241, 4453,
+ 10859, 6618,
+ 11321, 3587,
+ 11417, 1800,
+ 11643, 2428,
+ 11718, 988,
+ 12312, 5093,
+ 12523, 8413,
+ 12574, 26214,
+ 12601, 3396,
+ 13172, 1623,
+ 13285, 2423,
+ 13418, 6087,
+ 13459, 12810,
+ 13656, 3607,
+ 14111, 4521,
+ 14144, 1229,
+ 14425, 1871,
+ 14431, 7234,
+ 14445, 2834,
+ 14628, 10036,
+ 14860, 17496,
+ 15161, 3629,
+ 15209, 5819,
+ 15299, 2256,
+ 15518, 4722,
+ 15663, 1060,
+ 15759, 7972,
+ 15939, 11964,
+ 16020, 2996,
+ 16086, 1707,
+ 16521, 4254,
+ 16576, 6224,
+ 16894, 2380,
+ 16906, 681,
+ 17213, 8406,
+ 17610, 3418,
+ 17895, 5269,
+ 18168, 11748,
+ 18230, 1575,
+ 18607, 32767,
+ 18728, 21684,
+ 19137, 2543,
+ 19422, 6577,
+ 19446, 4097,
+ 19450, 9056,
+ 20371, 14885
+};
+
+const Word16 t_qua_gain7b_fx[128*2] =
+{
+ 204, 441,
+ 464, 1977,
+ 869, 1077,
+ 1072, 3062,
+ 1281, 4759,
+ 1647, 1539,
+ 1845, 7020,
+ 1853, 634,
+ 1995, 2336,
+ 2351, 15400,
+ 2661, 1165,
+ 2702, 3900,
+ 2710, 10133,
+ 3195, 1752,
+ 3498, 2624,
+ 3663, 849,
+ 3984, 5697,
+ 4214, 3399,
+ 4415, 1304,
+ 4695, 2056,
+ 5376, 4558,
+ 5386, 676,
+ 5518, 23554,
+ 5567, 7794,
+ 5644, 3061,
+ 5672, 1513,
+ 5957, 2338,
+ 6533, 1060,
+ 6804, 5998,
+ 6820, 1767,
+ 6937, 3837,
+ 7277, 414,
+ 7305, 2665,
+ 7466, 11304,
+ 7942, 794,
+ 8007, 1982,
+ 8007, 1366,
+ 8326, 3105,
+ 8336, 4810,
+ 8708, 7954,
+ 8989, 2279,
+ 9031, 1055,
+ 9247, 3568,
+ 9283, 1631,
+ 9654, 6311,
+ 9811, 2605,
+ 10120, 683,
+ 10143, 4179,
+ 10245, 1946,
+ 10335, 1218,
+ 10468, 9960,
+ 10651, 3000,
+ 10951, 1530,
+ 10969, 5290,
+ 11203, 2305,
+ 11325, 3562,
+ 11771, 6754,
+ 11839, 1849,
+ 11941, 4495,
+ 11954, 1298,
+ 11975, 15223,
+ 11977, 883,
+ 11986, 2842,
+ 12438, 2141,
+ 12593, 3665,
+ 12636, 8367,
+ 12658, 1594,
+ 12886, 2628,
+ 12984, 4942,
+ 13146, 1115,
+ 13224, 524,
+ 13341, 3163,
+ 13399, 1923,
+ 13549, 5961,
+ 13606, 1401,
+ 13655, 2399,
+ 13782, 3909,
+ 13868, 10923,
+ 14226, 1723,
+ 14232, 2939,
+ 14278, 7528,
+ 14439, 4598,
+ 14451, 984,
+ 14458, 2265,
+ 14792, 1403,
+ 14818, 3445,
+ 14899, 5709,
+ 15017, 15362,
+ 15048, 1946,
+ 15069, 2655,
+ 15405, 9591,
+ 15405, 4079,
+ 15570, 7183,
+ 15687, 2286,
+ 15691, 1624,
+ 15699, 3068,
+ 15772, 5149,
+ 15868, 1205,
+ 15970, 696,
+ 16249, 3584,
+ 16338, 1917,
+ 16424, 2560,
+ 16483, 4438,
+ 16529, 6410,
+ 16620, 11966,
+ 16839, 8780,
+ 17030, 3050,
+ 17033, 18325,
+ 17092, 1568,
+ 17123, 5197,
+ 17351, 2113,
+ 17374, 980,
+ 17566, 26214,
+ 17609, 3912,
+ 17639, 32767,
+ 18151, 7871,
+ 18197, 2516,
+ 18202, 5649,
+ 18679, 3283,
+ 18930, 1370,
+ 19271, 13757,
+ 19317, 4120,
+ 19460, 1973,
+ 19654, 10018,
+ 19764, 6792,
+ 19912, 5135,
+ 20040, 2841,
+ 21234, 19833
+};
+/*----------------------------------------------------------------------------------*
+ * Tables for mode TC
+ * (tbl_gain_code_tc[i]+(tbl_gain_code_tc[i+1]-tbl_gain_code_tc[i])/2)
+ *----------------------------------------------------------------------------------*/
+const Word16 tbl_gain_code_tc_quant_mean[N_GAIN_CODE_TC-1] =
+{
+ 4448, 6927, 8818, 10639,
+ 12660, 15374, 22136
+}; /* Q13 */
+
+const Word16 gain_qua_mless_7b_fx[128*2] =
+{
+ 419, 28,
+ 1499, 607,
+ 1586, 322,
+ 1632, 144,
+ 1686, 229,
+ 1745, 495,
+ 2182, 409,
+ 2515, 716,
+ 2772, 824,
+ 3069, 1069,
+ 3211, 936,
+ 3218, 89,
+ 3477, 1244,
+ 3755, 272,
+ 3865, 549,
+ 3881, 348,
+ 4171, 181,
+ 4414, 627,
+ 4419, 472,
+ 4909, 1429,
+ 5238, 404,
+ 5241, 1651,
+ 5721, 85,
+ 5833, 250,
+ 5846, 693,
+ 5897, 325,
+ 6036, 544,
+ 6088, 779,
+ 6459, 1889,
+ 6650, 157,
+ 6678, 462,
+ 6798, 879,
+ 6922, 993,
+ 6929, 1130,
+ 7352, 620,
+ 7461, 386,
+ 7864, 232,
+ 7999, 314,
+ 8136, 536,
+ 8398, 712,
+ 8680, 459,
+ 8797, 1276,
+ 9046, 806,
+ 9198, 86,
+ 9434, 398,
+ 9730, 587,
+ 9735, 267,
+ 9742, 175,
+ 9917, 917,
+ 10042, 509,
+ 10053, 655,
+ 10132, 1030,
+ 10238, 339,
+ 10694, 1560,
+ 10817, 447,
+ 10964, 723,
+ 11405, 1149,
+ 11526, 549,
+ 11582, 386,
+ 11602, 791,
+ 11618, 286,
+ 11883, 862,
+ 11954, 607,
+ 12057, 214,
+ 12104, 496,
+ 12170, 1397,
+ 12437, 668,
+ 12616, 335,
+ 12668, 952,
+ 12684, 435,
+ 12983, 112,
+ 13235, 742,
+ 13399, 549,
+ 13525, 380,
+ 13527, 270,
+ 13625, 1044,
+ 13733, 482,
+ 13820, 617,
+ 14036, 817,
+ 14041, 1257,
+ 14295, 425,
+ 14346, 684,
+ 14367, 319,
+ 14416, 199,
+ 14644, 898,
+ 14944, 518,
+ 15090, 364,
+ 15154, 578,
+ 15309, 462,
+ 15360, 1933,
+ 15362, 756,
+ 15381, 262,
+ 15566, 1127,
+ 15699, 639,
+ 15804, 410,
+ 16081, 316,
+ 16161, 993,
+ 16359, 701,
+ 16451, 828,
+ 16500, 543,
+ 16540, 491,
+ 16617, 1729,
+ 16630, 196,
+ 16749, 369,
+ 16959, 1530,
+ 17028, 442,
+ 17139, 603,
+ 17369, 898,
+ 17393, 268,
+ 17972, 763,
+ 17985, 1361,
+ 18016, 333,
+ 18032, 667,
+ 18234, 406,
+ 18270, 105,
+ 18299, 554,
+ 18342, 488,
+ 18747, 1207,
+ 19027, 1073,
+ 19530, 216,
+ 19566, 963,
+ 19751, 835,
+ 19794, 615,
+ 19810, 298,
+ 19988, 710,
+ 19990, 449,
+ 20005, 374,
+ 20149, 531,
+};
+const Word16 gain_qua_mless_6b_fx[64*2] =
+{
+ 1676, 71,
+ 2128, 198,
+ 2318, 491,
+ 2348, 339,
+ 2798, 625,
+ 2893, 785,
+ 3911, 1099,
+ 4779, 244,
+ 4781, 427,
+ 5115, 935,
+ 5294, 1509,
+ 5767, 114,
+ 6018, 543,
+ 6152, 335,
+ 6205, 675,
+ 6234, 1822,
+ 6740, 1251,
+ 7034, 802,
+ 7782, 434,
+ 8005, 230,
+ 9232, 622,
+ 9337, 336,
+ 9388, 520,
+ 9770, 1038,
+ 9865, 734,
+ 10224, 879,
+ 10617, 118,
+ 10776, 426,
+ 11518, 249,
+ 11708, 1399,
+ 12044, 587,
+ 12270, 501,
+ 12277, 348,
+ 12498, 684,
+ 13020, 786,
+ 13097, 1196,
+ 13530, 422,
+ 13818, 917,
+ 14123, 290,
+ 14500, 1039,
+ 14538, 636,
+ 14636, 556,
+ 14667, 484,
+ 14931, 362,
+ 15055, 210,
+ 15653, 1594,
+ 15830, 1874,
+ 15868, 717,
+ 15897, 828,
+ 16153, 434,
+ 16540, 294,
+ 16874, 608,
+ 16936, 513,
+ 17182, 373,
+ 17644, 1337,
+ 17696, 126,
+ 18342, 1122,
+ 18461, 944,
+ 18991, 242,
+ 19114, 795,
+ 19187, 674,
+ 19256, 449,
+ 19485, 557,
+ 19515, 344,
+};
+
+const Word16 gain_qua_mless_5b_fx[32*2] =
+{
+ 2695, 109,
+ 3444, 271,
+ 3529, 433,
+ 4284, 801,
+ 4365, 607,
+ 4935, 1089,
+ 6896, 1407,
+ 7722, 324,
+ 7913, 146,
+ 8090, 468,
+ 9049, 913,
+ 9499, 600,
+ 9894, 741,
+ 9942, 1840,
+ 11906, 382,
+ 12008, 1103,
+ 12349, 243,
+ 12429, 501,
+ 13687, 630,
+ 13974, 896,
+ 14510, 748,
+ 15160, 322,
+ 15424, 428,
+ 15679, 541,
+ 15832, 1574,
+ 15999, 1281,
+ 17223, 211,
+ 17719, 1029,
+ 18185, 649,
+ 18432, 818,
+ 18638, 353,
+ 18889, 493,
+};
+
+const Word16 gp_gamma_1sfr_8b_fx[2*256] = /*Q14/Q9 */
+{
+ 305, 152,
+ 333, 37,
+ 352, 556,
+ 573, 82,
+ 652, 12,
+ 694, 207,
+ 808, 389,
+ 915, 776,
+ 986, 1089,
+ 987, 1583,
+ 1055, 60,
+ 1202, 2779,
+ 1205, 20,
+ 1346, 127,
+ 1432, 332,
+ 1689, 6554,
+ 1715, 261,
+ 1820, 49,
+ 2041, 698,
+ 2179, 4032,
+ 2199, 100,
+ 2272, 1303,
+ 2317, 461,
+ 2340, 175,
+ 2562, 26,
+ 2574, 14814,
+ 2657, 2101,
+ 2732, 66,
+ 2818, 9,
+ 2836, 296,
+ 2929, 938,
+ 3479, 130,
+ 3510, 220,
+ 3651, 3154,
+ 3667, 717,
+ 3720, 384,
+ 3783, 530,
+ 3811, 10744,
+ 3883, 5385,
+ 3941, 1609,
+ 3964, 46,
+ 4120, 80,
+ 4402, 15,
+ 4440, 1181,
+ 4485, 173,
+ 4740, 311,
+ 4848, 31,
+ 5125, 7642,
+ 5147, 110,
+ 5167, 908,
+ 5237, 252,
+ 5323, 623,
+ 5376, 2514,
+ 5590, 7,
+ 5595, 4475,
+ 5634, 64,
+ 5654, 461,
+ 5822, 22,
+ 5893, 140,
+ 5905, 1810,
+ 6177, 367,
+ 6268, 201,
+ 6352, 1092,
+ 6567, 752,
+ 6626, 50,
+ 6734, 95,
+ 6758, 295,
+ 6882, 3085,
+ 6962, 1363,
+ 7274, 540,
+ 7413, 166,
+ 7635, 2120,
+ 7642, 38,
+ 7671, 393,
+ 7730, 227,
+ 7860, 75,
+ 7980, 115,
+ 8011, 955,
+ 8092, 3687,
+ 8120, 17,
+ 8146, 5902,
+ 8453, 672,
+ 8524, 1602,
+ 8583, 58,
+ 8679, 275,
+ 8873, 332,
+ 8920, 454,
+ 8969, 9712,
+ 9129, 2566,
+ 9159, 196,
+ 9193, 1127,
+ 9219, 142,
+ 9300, 9,
+ 9302, 828,
+ 9409, 91,
+ 9736, 26,
+ 9872, 574,
+ 10066, 246,
+ 10131, 1352,
+ 10154, 1971,
+ 10196, 399,
+ 10238, 15785,
+ 10255, 4254,
+ 10401, 67,
+ 10439, 43,
+ 10511, 116,
+ 10531, 7399,
+ 10706, 998,
+ 10798, 722,
+ 10845, 171,
+ 10848, 304,
+ 10876, 2981,
+ 11069, 28204,
+ 11139, 507,
+ 11280, 12,
+ 11427, 388,
+ 11459, 214,
+ 11647, 1174,
+ 11710, 5061,
+ 11742, 1614,
+ 11793, 806,
+ 11816, 82,
+ 11890, 132,
+ 11996, 2301,
+ 12000, 603,
+ 12060, 55,
+ 12232, 256,
+ 12299, 33,
+ 12438, 338,
+ 12452, 458,
+ 12627, 3563,
+ 12646, 9489,
+ 12665, 934,
+ 12801, 1329,
+ 12802, 190,
+ 12877, 683,
+ 12941, 103,
+ 13038, 1890,
+ 13209, 6209,
+ 13222, 12674,
+ 13318, 21,
+ 13374, 283,
+ 13385, 149,
+ 13391, 383,
+ 13453, 545,
+ 13564, 1064,
+ 13596, 2561,
+ 13771, 810,
+ 13834, 1481,
+ 13874, 69,
+ 14027, 226,
+ 14093, 4429,
+ 14147, 7,
+ 14171, 609,
+ 14185, 47,
+ 14223, 3051,
+ 14273, 434,
+ 14321, 314,
+ 14415, 120,
+ 14443, 1252,
+ 14500, 173,
+ 14557, 933,
+ 14616, 1696,
+ 14639, 8229,
+ 14724, 89,
+ 14837, 703,
+ 14902, 2072,
+ 14917, 366,
+ 15000, 487,
+ 15009, 30,
+ 15095, 256,
+ 15138, 1119,
+ 15228, 3580,
+ 15371, 1386,
+ 15387, 5525,
+ 15398, 17932,
+ 15462, 149,
+ 15471, 791,
+ 15551, 569,
+ 15554, 2467,
+ 15559, 201,
+ 15616, 14,
+ 15664, 319,
+ 15798, 401,
+ 15811, 974,
+ 15874, 41,
+ 15929, 1649,
+ 15945, 79,
+ 16046, 111,
+ 16225, 647,
+ 16230, 1240,
+ 16297, 4110,
+ 16328, 10499,
+ 16331, 278,
+ 16355, 3003,
+ 16383, 455,
+ 16404, 169,
+ 16435, 2172,
+ 16438, 850,
+ 16745, 7090,
+ 16776, 354,
+ 16801, 1063,
+ 16803, 62,
+ 16812, 223,
+ 16927, 530,
+ 16951, 721,
+ 17039, 1447,
+ 17208, 1837,
+ 17233, 135,
+ 17371, 4642,
+ 17570, 406,
+ 17608, 267,
+ 17696, 906,
+ 17702, 2529,
+ 17705, 23239,
+ 17709, 1209,
+ 17745, 592,
+ 17800, 92,
+ 17858, 35,
+ 17860, 3360,
+ 17866, 9,
+ 17978, 184,
+ 18035, 321,
+ 18255, 754,
+ 18274, 480,
+ 18320, 18,
+ 18406, 55,
+ 18582, 13017,
+ 18677, 1516,
+ 18726, 1998,
+ 18904, 25,
+ 18914, 6103,
+ 19020, 8567,
+ 19022, 1116,
+ 19025, 349,
+ 19147, 239,
+ 19224, 604,
+ 19251, 160,
+ 19270, 4870,
+ 19358, 3789,
+ 19394, 126,
+ 19394, 103,
+ 19433, 72,
+ 19444, 46,
+ 19448, 2842,
+ 19489, 430,
+ 19575, 815,
+ 19628, 1306,
+ 19631, 972,
+ 19637, 202,
+ 19642, 289,
+ 19660, 527,
+ 19717, 1697,
+ 19731, 2263,
+ 19754, 676,
+ 19854, 382,
+};
+
+const Word16 gp_gamma_1sfr_7b_fx[2*128] = /*Q14/Q9 */
+{
+ 350, 85,
+ 428, 24,
+ 438, 681,
+ 642, 195,
+ 1071, 2012,
+ 1080, 402,
+ 1148, 1236,
+ 1159, 62,
+ 1424, 12,
+ 1662, 134,
+ 1985, 299,
+ 2100, 34,
+ 2163, 3168,
+ 2219, 538,
+ 2393, 6580,
+ 2499, 967,
+ 2882, 221,
+ 2974, 12743,
+ 3251, 98,
+ 3294, 51,
+ 3586, 1560,
+ 3711, 411,
+ 3721, 700,
+ 3862, 21,
+ 3947, 169,
+ 4001, 2249,
+ 4198, 4632,
+ 4372, 8,
+ 4993, 70,
+ 5022, 265,
+ 5568, 1194,
+ 5664, 495,
+ 5698, 115,
+ 5885, 854,
+ 6115, 2990,
+ 6266, 153,
+ 6376, 39,
+ 6432, 16,
+ 6601, 345,
+ 7108, 1957,
+ 7231, 660,
+ 7491, 202,
+ 7687, 93,
+ 8054, 3882,
+ 8108, 9624,
+ 8186, 1424,
+ 8243, 59,
+ 8354, 935,
+ 8358, 6401,
+ 8383, 439,
+ 8794, 285,
+ 8940, 124,
+ 9643, 25,
+ 9643, 581,
+ 9670, 2709,
+ 10065, 160,
+ 10218, 9,
+ 10240, 1728,
+ 10249, 80,
+ 10418, 1113,
+ 10497, 373,
+ 10650, 236,
+ 11095, 44,
+ 11095, 756,
+ 11284, 4978,
+ 11290, 16722,
+ 11815, 2299,
+ 11882, 482,
+ 12059, 114,
+ 12332, 8550,
+ 12363, 1394,
+ 12392, 186,
+ 12517, 336,
+ 12549, 3413,
+ 12694, 953,
+ 13096, 614,
+ 13185, 71,
+ 13247, 262,
+ 13479, 1914,
+ 13791, 14,
+ 13805, 30,
+ 14064, 138,
+ 14182, 420,
+ 14212, 1175,
+ 14477, 765,
+ 14605, 2745,
+ 14612, 6324,
+ 14730, 4199,
+ 14833, 301,
+ 14842, 203,
+ 14910, 12790,
+ 15171, 100,
+ 15191, 1625,
+ 15289, 532,
+ 15405, 52,
+ 15550, 985,
+ 16096, 357,
+ 16175, 2113,
+ 16284, 232,
+ 16333, 669,
+ 16363, 22999,
+ 16396, 156,
+ 16443, 1270,
+ 16455, 3482,
+ 16543, 8,
+ 16650, 5425,
+ 16878, 452,
+ 16989, 84,
+ 17024, 9676,
+ 17194, 876,
+ 17730, 20,
+ 17780, 1442,
+ 17864, 38,
+ 17874, 254,
+ 17929, 526,
+ 18011, 2403,
+ 18751, 7153,
+ 18786, 117,
+ 18820, 4420,
+ 19002, 63,
+ 19099, 401,
+ 19111, 183,
+ 19197, 776,
+ 19202, 2953,
+ 19236, 1052,
+ 19255, 301,
+ 19354, 1760,
+ 19432, 593,
+};
+
+const Word16 gp_gamma_1sfr_6b_fx[2*64] = /*Q14/Q9 */
+{
+ 436, 182,
+ 473, 63,
+ 962, 16,
+ 992, 647,
+ 1258, 1582,
+ 1447, 351,
+ 1711, 125,
+ 1809, 46,
+ 2569, 4173,
+ 2607, 957,
+ 2826, 251,
+ 2904, 12481,
+ 3248, 26,
+ 3594, 2254,
+ 3664, 78,
+ 3715, 483,
+ 4232, 8,
+ 4681, 188,
+ 5066, 6623,
+ 5232, 1273,
+ 6232, 695,
+ 6234, 49,
+ 6238, 113,
+ 6312, 318,
+ 7012, 17,
+ 7327, 3183,
+ 8008, 1739,
+ 8692, 446,
+ 8769, 163,
+ 8923, 1019,
+ 9094, 81,
+ 10358, 286,
+ 10491, 28,
+ 10612, 9788,
+ 10715, 760,
+ 11045, 4822,
+ 11319, 2403,
+ 11684, 56,
+ 12314, 108,
+ 12460, 556,
+ 12580, 9,
+ 12716, 213,
+ 12821, 1336,
+ 14202, 374,
+ 14325, 16971,
+ 14612, 838,
+ 14625, 3285,
+ 14668, 6231,
+ 14919, 39,
+ 15131, 137,
+ 15476, 1847,
+ 16056, 255,
+ 16277, 494,
+ 16290, 66,
+ 16582, 1048,
+ 16859, 17,
+ 17220, 8723,
+ 17443, 4295,
+ 18069, 2499,
+ 18212, 176,
+ 18499, 91,
+ 18517, 1445,
+ 18522, 332,
+ 18596, 663,
+};
+
+const Word16 gp_gamma_2sfr_7b_fx[2*128] = /*Q14/Q9 */
+{
+ 99, 1224,
+ 156, 243,
+ 168, 579,
+ 290, 355,
+ 437, 441,
+ 475, 187,
+ 734, 738,
+ 930, 93,
+ 1133, 153,
+ 1136, 298,
+ 1490, 508,
+ 1946, 401,
+ 1978, 16790,
+ 2098, 224,
+ 2117, 962,
+ 2407, 119,
+ 2686, 339,
+ 2929, 555,
+ 3404, 271,
+ 3465, 171,
+ 3469, 422,
+ 3714, 663,
+ 4436, 494,
+ 4494, 332,
+ 4571, 220,
+ 4583, 2182,
+ 4997, 848,
+ 5346, 380,
+ 5419, 108,
+ 5570, 579,
+ 5758, 266,
+ 5875, 442,
+ 5927, 170,
+ 6204, 3338,
+ 6394, 6435,
+ 6515, 328,
+ 6638, 730,
+ 6687, 1472,
+ 7045, 1056,
+ 7101, 498,
+ 7123, 210,
+ 7163, 9668,
+ 7345, 386,
+ 7598, 280,
+ 7853, 627,
+ 8462, 442,
+ 8648, 331,
+ 8822, 236,
+ 8887, 551,
+ 8953, 906,
+ 9317, 136,
+ 9587, 386,
+ 9651, 691,
+ 9796, 286,
+ 9852, 489,
+ 10005, 1215,
+ 10041, 192,
+ 10623, 576,
+ 10758, 329,
+ 10840, 425,
+ 10944, 792,
+ 11038, 257,
+ 11190, 1870,
+ 11541, 501,
+ 11729, 642,
+ 11873, 367,
+ 12064, 163,
+ 12332, 216,
+ 12339, 1100,
+ 12339, 295,
+ 12478, 444,
+ 12561, 568,
+ 12665, 845,
+ 13257, 396,
+ 13317, 677,
+ 13411, 511,
+ 13709, 324,
+ 13710, 1547,
+ 13711, 246,
+ 14054, 991,
+ 14112, 447,
+ 14246, 580,
+ 14355, 748,
+ 14394, 175,
+ 14453, 99,
+ 14604, 363,
+ 14887, 491,
+ 15074, 282,
+ 15110, 637,
+ 15242, 1292,
+ 15351, 413,
+ 15430, 843,
+ 15700, 541,
+ 15776, 204,
+ 15964, 335,
+ 15992, 688,
+ 16077, 453,
+ 16315, 4617,
+ 16406, 1032,
+ 16549, 595,
+ 16666, 384,
+ 16850, 776,
+ 16851, 482,
+ 16916, 253,
+ 17234, 309,
+ 17307, 2128,
+ 17469, 546,
+ 17666, 643,
+ 17699, 421,
+ 17852, 882,
+ 17870, 146,
+ 18146, 1244,
+ 18457, 489,
+ 18478, 346,
+ 18588, 723,
+ 18826, 208,
+ 19011, 1731,
+ 19042, 586,
+ 19286, 281,
+ 19428, 944,
+ 19446, 382,
+ 19555, 444,
+ 19689, 792,
+ 19755, 1111,
+ 19762, 527,
+ 19769, 1405,
+ 19774, 657,
+ 19780, 2675,
+};
+
+const Word16 gp_gamma_2sfr_6b_fx[2*64] = /*Q14/Q9 */
+{
+ 185, 306,
+ 435, 519,
+ 458, 145,
+ 1000, 211,
+ 1217, 394,
+ 1241, 751,
+ 1788, 93,
+ 2026, 1234,
+ 2162, 265,
+ 2397, 158,
+ 2617, 472,
+ 3324, 340,
+ 3391, 623,
+ 3835, 207,
+ 4503, 17210,
+ 4628, 407,
+ 4939, 897,
+ 5102, 275,
+ 5300, 120,
+ 5560, 511,
+ 6309, 1909,
+ 6571, 335,
+ 6770, 205,
+ 6990, 642,
+ 7085, 5087,
+ 7500, 428,
+ 8357, 827,
+ 8452, 261,
+ 9079, 537,
+ 9289, 354,
+ 9854, 1176,
+ 9864, 165,
+ 10436, 8580,
+ 10549, 437,
+ 10615, 677,
+ 11010, 282,
+ 11940, 530,
+ 12183, 367,
+ 12475, 920,
+ 12865, 225,
+ 13359, 618,
+ 13431, 441,
+ 13521, 1623,
+ 14177, 341,
+ 14299, 130,
+ 14452, 775,
+ 14799, 508,
+ 15250, 276,
+ 15715, 1130,
+ 15757, 660,
+ 15879, 422,
+ 16355, 3256,
+ 16439, 187,
+ 16751, 562,
+ 16906, 331,
+ 17178, 827,
+ 17889, 471,
+ 18219, 2175,
+ 18786, 248,
+ 18985, 1354,
+ 19067, 703,
+ 19220, 384,
+ 19349, 954,
+ 19422, 553,
+};
+const Word16 gp_gamma_3sfr_6b_fx[2*64] = /*Q14/Q9 */
+{
+ 195, 150,
+ 817, 288,
+ 1152, 616,
+ 1366, 188,
+ 1377, 410,
+ 1526, 902,
+ 1570, 98,
+ 2258, 238,
+ 2489, 518,
+ 2935, 338,
+ 3142, 161,
+ 3456, 1705,
+ 3990, 432,
+ 4159, 709,
+ 4187, 270,
+ 4374, 1236,
+ 5283, 526,
+ 5431, 131,
+ 5507, 356,
+ 5762, 211,
+ 6792, 620,
+ 6842, 446,
+ 6969, 304,
+ 7671, 807,
+ 8362, 245,
+ 8448, 530,
+ 8610, 380,
+ 9314, 1088,
+ 9828, 170,
+ 9921, 7010,
+ 10026, 459,
+ 10193, 312,
+ 10261, 658,
+ 11554, 394,
+ 11739, 882,
+ 11791, 542,
+ 11985, 4329,
+ 11996, 246,
+ 12762, 13441,
+ 12844, 1512,
+ 13131, 465,
+ 13135, 339,
+ 13215, 740,
+ 14138, 608,
+ 14524, 417,
+ 14780, 1030,
+ 14823, 283,
+ 15016, 171,
+ 15264, 527,
+ 15823, 2706,
+ 15943, 699,
+ 15959, 360,
+ 16350, 473,
+ 17211, 573,
+ 17366, 901,
+ 17517, 238,
+ 17799, 414,
+ 18069, 1415,
+ 18630, 1920,
+ 18887, 634,
+ 19018, 318,
+ 19304, 495,
+ 19400, 1114,
+ 19413, 767,
+};
+
+
+const Word16 gp_gamma_4sfr_6b_fx[2*64] = /*Q14/Q9 */
+{
+ 153, 141,
+ 282, 501,
+ 399, 239,
+ 783, 369,
+ 1110, 744,
+ 1430, 183,
+ 1440, 1748,
+ 1524, 1091,
+ 1602, 296,
+ 1828, 99,
+ 2000, 439,
+ 2678, 228,
+ 2815, 600,
+ 3084, 347,
+ 3861, 477,
+ 4154, 163,
+ 4214, 285,
+ 4428, 733,
+ 4976, 384,
+ 5482, 566,
+ 5552, 234,
+ 6158, 929,
+ 6536, 470,
+ 6560, 326,
+ 7288, 173,
+ 7429, 663,
+ 7447, 10616,
+ 7871, 407,
+ 8457, 266,
+ 8559, 550,
+ 8679, 1421,
+ 9457, 356,
+ 9533, 785,
+ 9854, 471,
+ 10584, 5781,
+ 10792, 3815,
+ 10813, 206,
+ 10829, 302,
+ 10986, 606,
+ 11380, 433,
+ 11468, 1073,
+ 12485, 356,
+ 12726, 520,
+ 12783, 721,
+ 13554, 259,
+ 13763, 139,
+ 13884, 430,
+ 14060, 2592,
+ 14266, 599,
+ 14332, 925,
+ 14997, 337,
+ 15355, 485,
+ 15526, 712,
+ 16440, 587,
+ 16504, 395,
+ 16626, 204,
+ 17228, 1287,
+ 17563, 805,
+ 17629, 517,
+ 18159, 1814,
+ 18320, 303,
+ 19228, 437,
+ 19263, 636,
+ 19417, 989,
+};
+
+const Word16 b_1sfr_fx[2] = /*Q12 */
+{
+ 9697, -920
+};
+const Word16 b_2sfr_fx[4] = /*Q12 */
+{
+ -1, 70, 3763, 542
+};
+const Word16 b_3sfr_fx[6] =
+{
+ -478, 110, 553, 3264, 92, 730
+};
+const Word16 b_4sfr_fx[8] =
+{
+ -381, 65, -271, 836, 3246, 34, 143, 650
+};
+/*-------------------------------------------------------------------*
+ * 1/4 resolution interpolation filter (-3 dB at 0.913*fs/2)
+ * Used in lib_com_fx\PRED_LT4_FX.C
+ * Q14
+ *-------------------------------------------------------------------*/
+const Word16 inter4_2_fx[] =
+{
+ 0, 1, 2, 1,
+ -2, -7, -10, -7,
+ 4, 19, 28, 22,
+ -2, -33, -55, -49,
+ -10, 47, 91, 92,
+ 38, -52, -133, -153,
+ -88, 43, 175, 231,
+ 165, -9, -209, -325,
+ -275, -60, 226, 431,
+ 424, 175, -213, -544,
+ -619, -355, 153, 656,
+ 871, 626, -16, -762,
+ -1207, -1044, -249, 853,
+ 1699, 1749, 780, -923,
+ -2598, -3267, -2147, 968,
+ 5531, 10359, 14031, 15401,
+ 14031, 10359, 5531, 968,
+ -2147, -3267, -2598, -923,
+ 780, 1749, 1699, 853,
+ -249, -1044, -1207, -762,
+ -16, 626, 871, 656,
+ 153, -355, -619, -544,
+ -213, 175, 424, 431,
+ 226, -60, -275, -325,
+ -209, -9, 165, 231,
+ 175, 43, -88, -153,
+ -133, -52, 38, 92,
+ 91, 47, -10, -49,
+ -55, -33, -2, 22,
+ 28, 19, 4, -7,
+ -10, -7, -2, 1,
+ 2, 1, 0, 0
+};
+
+const Word16 pwf_fx[17]=
+{
+ 22938, 16056, 11239, 7868, 5507, 3855, 2699, 1889,
+ 1322, 926, 648, 454, 317, 222, 156, 109,
+ 76
+};
+
+const Word16 Gamma_29491_Tbl[] =
+{
+ 29491, 26542, 23888, 21499, 19349, 17414, 15672, 14105,
+ 12694, 11425, 10282, 9254, 8329, 7496, 6746, 6071
+};
+
+
+/* Used in 'lsp2lsf_fx.c' */
+const Word8 Ind_Guess[256]=
+{
+ 126, 122, 120, 119, 117, 116, 115, 114,
+ 113, 112, 111, 110, 110, 109, 108, 108,
+ 107, 106, 106, 105, 104, 104, 103, 103,
+ 102, 102, 101, 101, 100, 100, 99, 99,
+ 98, 98, 97, 97, 96, 96, 95, 95,
+ 94, 94, 94, 93, 93, 92, 92, 91,
+ 91, 91, 90, 90, 89, 89, 89, 88,
+ 88, 87, 87, 87, 86, 86, 86, 85,
+ 85, 84, 84, 84, 83, 83, 83, 82,
+ 82, 82, 81, 81, 81, 80, 80, 80,
+ 79, 79, 78, 78, 78, 77, 77, 77,
+ 76, 76, 76, 75, 75, 75, 74, 74,
+ 74, 73, 73, 73, 72, 72, 72, 72,
+ 71, 71, 71, 70, 70, 70, 69, 69,
+ 69, 68, 68, 68, 67, 67, 67, 66,
+ 66, 66, 65, 65, 65, 64, 64, 64,
+ 64, 63, 63, 63, 62, 62, 62, 61,
+ 61, 61, 60, 60, 60, 59, 59, 59,
+ 58, 58, 58, 57, 57, 57, 56, 56,
+ 56, 55, 55, 55, 55, 54, 54, 54,
+ 53, 53, 53, 52, 52, 52, 51, 51,
+ 51, 50, 50, 50, 49, 49, 49, 48,
+ 48, 47, 47, 47, 46, 46, 46, 45,
+ 45, 45, 44, 44, 44, 43, 43, 43,
+ 42, 42, 41, 41, 41, 40, 40, 40,
+ 39, 39, 38, 38, 38, 37, 37, 36,
+ 36, 36, 35, 35, 34, 34, 33, 33,
+ 33, 32, 32, 31, 31, 30, 30, 29,
+ 29, 28, 28, 27, 27, 26, 26, 25,
+ 25, 24, 24, 23, 23, 22, 21, 21,
+ 20, 19, 19, 18, 17, 17, 16, 15,
+ 14, 13, 12, 11, 10, 8, 7, 5
+};
+/* Version 101 points */
+
+
+const Word16 tbl_mid_voi_wb_1b_fx[] = /* Q13*/
+{
+ 4551, 4599, 4754, 5035, 4982, 5228, 5318, 5603, 5699, 5652, 5642, 5766, 5825, 5874, 5819, 6056,
+ 3816, 3355, 2321, 2712, 2900, 2715, 2790, 2508, 2506, 2610, 2617, 2419, 2538, 2622, 3004, 2725,
+};
+const Word16 tbl_mid_voi_wb_4b_fx[] =
+{
+ 4337, 4235, 3526, 4083, 3514, 5457, 3168, 2509, 4418, 5021, 1313, 2952, 5347, 3893, 8325, 11758,
+ 4180, 4037, 3965, 3481, 4028, 3284, 2644, 4585, 4749, 3076, 3211, 1101, 4175, 7440, 5745, -4105,
+ 4239, 3957, 4450, 4974, 5400, 5734, 6246, 6586, 7774, 2699, 2783, 3474, 1345, -316, 5069, 4904,
+ 3964, 3810, 2673, 3031, 2249, 3168, 3155, 4204, 7316, 7176, 8680, 7147, 4918, 4136, 3142, 3011,
+ 4071, 3853, 3898, 3973, 3464, 2878, 5783, 5341, 1725, 801, 1194, 4239, 6866, 4950, 794, 6270,
+ 3933, 3750, 4931, 3667, 3585, 2550, 4308, 5757, 4503, 7081, 4893, 1076, 109, 1650, 1887, 8861,
+ 4803, 4827, 4969, 5511, 5768, 4327, 5277, 4934, 6909, 7672, 5355, 3940, 9990, 9622, 7457, 4202,
+ 4515, 4259, 2444, 4847, 3728, 4599, 4975, 6144, 4087, 4367, 7025, 5028, 2405, 7014, 13366, 6264,
+ 4746, 4556, 5408, 5866, 4733, 4088, 3965, 3329, 4669, 3105, 5918, 7824, 6026, 9177, 1856, 13229,
+ 4130, 4214, 2516, 3542, 4847, 3751, 3704, 2380, 4190, 4787, 4651, 4981, 5702, -27, -2961, 129,
+ 4461, 4724, 5233, 4680, 6010, 7222, 6351, 3069, 605, 5934, 5627, 3836, 3490, 6060, 3556, 2585,
+ 4628, 4723, 5465, 4180, 4460, 6173, 5915, 7260, 4703, 4114, 3938, 9585, 8085, 3781, 7520, 625,
+ 5002, 5621, 6352, 6914, 7170, 7719, 7585, 8408, 8360, 7883, 7370, 7222, 6616, 6002, 5565, 9394,
+ 4059, 4121, 4178, 4417, 3437, 1460, 1031, 111, 585, 1708, 4219, 5419, 2585, 3195, 6149, 3221,
+ 3394, 2776, 1970, 2707, 2983, 3931, 3247, 1729, 449, -109, -46, -469, 397, 1980, 2305, 1573,
+ 3259, 1870, 242, 392, 748, 615, 1185, 1285, 2259, 2687, 2212, 1762, 2174, 1887, 1847, 2073,
+};
+const Word16 tbl_mid_voi_wb_5b_fx[] =
+{
+ 4182, 3820, 4103, 5620, 4100, 4478, 3949, 5053, 2918, 3083, 4229, 3732, 1823, 6350, 17230, 4601,
+ 4361, 4077, 2236, 4128, 3216, 4673, 6022, 6522, 5746, 4282, 3121, 4448, 6457, 12573, 4401, 7796,
+ 4228, 4086, 4375, 4320, 4474, 4735, 4427, 5616, 5975, 138, 5887, 3722, 2304, -3430, 4995, 6246,
+ 4320, 4344, 4008, 4327, 3323, 6835, 3627, 3330, 3123, 3971, 2382, 1801, 6422, 3162, 9038, 14129,
+ 4193, 4202, 4413, 2703, 4175, 4330, 2615, 7600, 1717, 3506, 5671, 7170, 3545, 2350, -2738, 7287,
+ 4170, 3912, 4323, 3821, 4450, 6765, 7496, 8107, 7447, 5525, 3088, 1963, 2014, 3330, 976, 1002,
+ 4583, 4419, 3584, 4125, 4783, 5133, 3188, 5000, 4812, 4639, 10038, 7018, 5114, 5567, 3292, -6364,
+ 3926, 4092, 2710, 2721, 1799, 3509, 4542, 3351, 4583, 5877, 6539, 5135, 981, 4029, 7221, 592,
+ 4624, 4567, 4468, 4630, 5710, 5222, 5883, 2562, 8453, 2825, 109, 6491, 1210, 2921, 7292, 7118,
+ 4245, 4160, 5119, 4356, 5544, 3034, 1507, 4179, 5971, 1949, 3388, 613, 4995, 9019, 6755, -628,
+ 4905, 4962, 4529, 7025, 4905, 4470, 5063, 3440, 6348, 6102, 4319, 4395, 7515, 6549, -3697, 6513,
+ 4683, 4592, 5303, 4593, 4171, 5264, 6116, 7434, 4105, 5454, 2544, 8493, 6491, 894, 8983, -2406,
+ 3632, 3435, 3988, 4195, 3684, 2173, 6735, 4552, -339, 763, 308, 3463, 6123, 2895, 2831, 5715,
+ 4316, 4111, 2236, 2682, 1058, 544, 2541, 1677, 3549, 2767, 3376, 5901, 6689, 5811, 6617, 3311,
+ 4487, 4285, 4992, 3656, 5970, 4547, 3975, 5998, 4985, 6614, 4807, 1971, 14937, 4388, 6153, 3352,
+ 4601, 4710, 4957, 4454, 4873, 7207, 5881, 3461, 2282, 1829, 5617, 9926, 10043, 7722, 3232, 4629,
+ 3965, 3837, 2088, 4265, 5042, 3478, 4453, 2804, 4162, 4858, 4315, 4343, 5193, -1823, -5028, -1137,
+ 3439, 2837, 2549, 4062, 2857, 2657, 2662, 5088, 10548, 8913, 6631, 6395, 5568, 3210, 2431, 3400,
+ 4073, 3839, 5806, 5296, 3766, 2342, 2585, 891, 3144, 2988, 6807, 4626, 3700, 5854, 1543, 16158,
+ 4189, 4045, 4293, 4527, 4008, 1413, 4871, 6081, 3297, 6546, 5006, -365, -2369, 1375, 5522, 8787,
+ 4778, 4782, 4941, 4538, 4497, 3129, 4934, 4371, 7175, 6923, 8620, 10236, 8664, 10088, 10923, 7314,
+ 4945, 5016, 6439, 6353, 6624, 6463, 6938, 7547, 7004, 7283, 7655, 7149, 7650, 2747, 3416, 14892,
+ 4776, 5431, 5515, 6194, 5700, 5485, 2795, 5476, 4024, 8891, 2930, 7916, 3428, 8070, 5920, 13440,
+ 4718, 4986, 4800, 5286, 6567, 6554, 6601, 1235, -1216, 6556, 6098, 3962, 4361, 5536, 5517, 3935,
+ 4741, 4679, 5593, 4891, 3849, 5675, 6487, 6239, 7062, 12044, 10918, 2438, 3977, 7296, 8445, 6625,
+ 4859, 5781, 6592, 7399, 8027, 8858, 8139, 8951, 8760, 5506, 6294, 6540, 6516, 7527, 7688, 4084,
+ 4077, 3771, 3650, 3381, 3367, 4048, 3899, 4382, 3017, -2156, -1464, -2207, 828, 4838, 2071, 2363,
+ 3796, 3437, 3558, 3842, 2170, 4311, 2602, 696, 1939, 2576, 1239, 328, -129, -647, 1702, 2893,
+ 4015, 3506, 367, 1350, 3328, 3700, 3827, 2439, 1434, 3887, 2279, 1593, 3673, 5508, 3905, -2973,
+ 4088, 3990, 3732, 3256, 4718, 1375, 152, -99, -254, 1140, 3578, 3316, 2195, 2408, 5027, 999,
+ 3749, 3175, 1475, 686, 2006, 1959, 1558, 3059, 5374, 5014, 2439, 2396, 2467, 2218, 1031, 7866,
+ 2037, 701, 124, 278, 328, 253, 660, 528, 826, 473, 801, 800, 1053, 1330, 804, 967,
+};
+
+const Word16 tbl_mid_unv_wb_4b_fx[] =
+{
+ 5190, 3143, 50, 2521, 5180, 6320, 3890, 3365, 3582, 3517, 3406, 3049, 2864, 1621, 1932, -950,
+ 6813, 6650, 2135, 972, 452, 1453, 3221, 1697, 3165, 4443, 5924, 6297, 3907, 2862, 3586, 4625,
+ 3204, 2673, 6499, 4319, 1054, 559, 4404, 5815, 5072, 6625, 4493, 2479, 1773, 1606, 2099, 8330,
+ 1924, 2666, 4171, 5517, 5898, 7238, 7318, 7696, 7250, 6269, 6164, 6038, 5249, 4284, 4147, 2828,
+ 2834, 788, 77, 2016, 1824, 3224, 3441, 4472, 6286, 6717, 6783, 6743, 6715, 7051, 6562, 2531,
+ 6386, 5634, 5761, 5184, 3523, 4284, 1867, 1045, 579, 1176, 1743, 2599, 5276, 5564, 5368, 7914,
+ 1795, 1380, 5184, 9326, 8023, 3138, 1258, 1729, 3328, 3934, 5169, 5645, 5271, 5894, 5591, 5145,
+ 5734, 5844, 8799, 8753, 5628, 5710, 5255, 4872, 5349, 3431, 3006, 2486, 1418, 974, 1115, 2035,
+ 4194, 8421, 1812, 6078, 3003, 3455, 6719, 7501, 2120, 1892, 2658, 2317, 2296, 5735, 6553, 4485,
+ 8072, 11456, 6455, 5069, 4918, 4936, 4819, 4932, 6029, 6246, 6289, 6704, 6749, 5337, 4526, 3974,
+ 3709, 5584, 4884, -1502, 4864, 2333, 606, 5976, 6438, 2413, 1937, 3663, 5593, 6989, 6450, 3555,
+ 3843, -6887, 3697, 3880, 4448, 4264, 5961, 4198, 3583, 3942, 3606, 3768, 4457, 4374, 4096, 4524,
+ 2551, 6781, 7017, 2902, 9227, 8728, 7130, 1873, 2308, 4393, 3981, 3976, 4002, 4080, 4820, 5611,
+ 220, -174, -43, -542, 449, 1470, 1759, 1893, 1294, 995, 723, 723, 769, 994, 1369, 4413,
+ 1651, 2259, 3079, 2913, 1176, -491, -1262, -827, -217, 908, 1126, 1751, 1901, 1765, 2656, 247,
+ 5380, 7307, 7727, 8135, 8270, 8471, 8792, 8573, 8335, 8420, 8057, 7562, 7119, 7458, 6806, 7385,
+};
+const Word16 tbl_mid_unv_wb_5b_fx[] =
+{
+ 6237, 6323, 1151, 763, 4218, 6546, 8437, 8701, 7456, 6604, 4631, 2901, 3050, 1793, 1955, 2260,
+ 5542, 4318, 5343, 5521, 5999, 5477, 5265, 5234, 4616, 3329, 3444, 1816, -442, 45, -2, 8922,
+ 6370, 8208, 6583, 5630, 5401, 5458, 5188, 5595, 6637, 6891, 6962, 6967, 7014, 6330, 5445, 3101,
+ 2750, 2858, 5206, 4594, 3310, 3494, 2463, 3410, 3405, 6151, 7682, 8593, 4440, 3715, 2946, -4371,
+ 1157, 661, 3743, 6418, 7515, 8319, 7485, 7298, 7928, 7515, 6812, 5671, 5095, 5122, 4997, 3940,
+ 5133, 3446, 2693, 1620, 1860, 2663, 4603, 6289, 7451, 7255, 7511, 7486, 8869, 8704, 8431, 6632,
+ 2497, 6706, 7036, 3437, 10854, 8893, 6033, 3021, 2936, 4766, 4145, 4097, 5177, 4883, 5920, 7612,
+ -152, -54, 3955, 1170, 5562, 4695, 1370, 8293, 3106, 1942, 5508, 4878, 3495, 1094, 1079, 5401,
+ 482, 373, 220, -355, -236, -328, -426, -147, 244, 563, 567, 915, 1012, 676, 804, 2721,
+ 437, 816, 3208, 3395, 2501, 3795, 4380, 2553, 399, 31, -519, -475, -162, 1755, 2852, 1040,
+ 2067, 2125, 1247, 2393, 2872, 2218, 3502, 3977, 4712, 4275, 2600, 2380, 2314, 2893, 3555, 13929,
+ 3967, -635, -1752, 2490, 303, 969, 1045, 2839, 5670, 4651, 5202, 5248, 4182, 4381, 5492, 53,
+ 3041, 2494, 9264, 4970, 360, -3795, 6296, 6475, 4482, 6667, 5265, 2908, 2381, 2889, 3718, 5160,
+ 3364, 4119, 5929, 3164, -745, 9368, 1652, -719, 6323, 5113, 1919, 1260, 2630, 3585, 2224, 3178,
+ 1643, 837, 8074, 8337, 4237, 2332, 2190, -1176, 1968, 1238, 2354, 4756, 5269, 5759, 4962, 5411,
+ 7590, 6471, 2635, 1869, 1209, 1505, 2118, 892, 1652, 3717, 5010, 3969, 2265, 2428, 3278, 5027,
+ 7289, 8658, 11183, 8913, 6084, 6673, 5961, 4041, 3839, 2643, 2094, 3215, 2956, 2895, 3327, 5063,
+ 5814, -4982, 1120, 2112, 4384, 5288, 6052, 4305, 4724, 5062, 3380, 4200, 5838, 7181, 6383, 4771,
+ 3891, 7361, 4160, 1422, 4971, 939, 281, 3585, 4817, 1176, -306, 260, 3815, 8273, 7095, 1529,
+ 8179, 19416, 3518, 3547, 4619, 4231, 3359, 3606, 5131, 4469, 5204, 5115, 4941, 4772, 4175, 5160,
+ 4539, 5393, 2706, 5371, 1468, 8488, 10356, 2778, 1426, 371, 8093, 7808, 5208, 5996, 6081, 5057,
+ 3266, 3481, -4953, -5638, 4022, 5502, 3586, 3117, 2737, 3826, 3658, 3933, 3602, 4920, 4959, 3483,
+ 3846, 9592, 3360, 6480, 1215, 3170, 5218, 8641, 664, 2695, 3353, 1479, 1687, 6049, 7074, 4696,
+ 2231, 4497, 6761, 6799, 5941, 5445, 8083, 7944, 5879, 3744, 2518, 6482, 6581, 6096, 6379, -133,
+ 3360, 6078, 1064, 13807, 8185, 3605, 4327, 3777, 6211, 4977, 5015, 4871, 5825, 2506, 2130, 4946,
+ 5412, 4507, 952, 4098, 5027, 3949, 3501, 1778, 1955, 2126, 1626, 3669, 4446, -1101, 736, -2708,
+ 4824, 7481, 8884, -2619, -2754, 281, 4158, 3251, 4602, 2946, 3915, 6169, 6075, 3495, 3266, 4375,
+ 6135, 2668, 6784, 10326, 6892, 5479, 1511, 3070, 6410, 9193, 6954, 1084, 2873, 7030, 8139, 5670,
+ 7255, 5764, 5122, 5787, 3129, 5475, -2720, 3770, -827, 872, 1591, 4645, 7218, 5513, 5778, 6323,
+ 1185, -13100, 5560, 5867, 4153, 2591, 4923, 3450, 2062, 4251, 4289, 3397, 3835, 2082, 2343, 3172,
+ 4460, 4411, 3940, 4420, 9410, -2789, -2525, -2877, -1868, 2850, 4490, 4093, 3162, 3889, 3800, 3492,
+ 6408, 8292, 8434, 8544, 8707, 9146, 9377, 9301, 9063, 8945, 8346, 8173, 7175, 7254, 6120, 7420,
+};
+const Word16 tbl_mid_gen_wb_2b_fx[] =
+{
+ 3814, 5145, 5856, 5290, 5277, 4880, 4877, 4273, 3868, 3776, 3392, 3163, 3120, 3019, 3395, 5814,
+ 1482, 861, 1968, 3198, 3105, 3737, 3749, 4525, 4982, 4828, 5023, 5335, 5327, 5296, 5092, 3444,
+ 3955, 3851, 1520, 1666, 1554, 1385, 1537, 1276, 1443, 1526, 1597, 1636, 1867, 2041, 2483, 2059,
+ 7038, 8112, 7324, 6969, 6877, 7028, 6987, 7098, 7003, 6955, 6927, 6808, 6685, 6459, 5871, 6047,
+};
+
+
+const Word16 tbl_mid_gen_wb_5b_fx[] =
+{
+ 6510, 8058, 7103, 6095, 6483, 5866, 6026, 6443, 6882, 6907, 7015, 6581, 5649, 4044, 2816, 2519,
+ 3778, 2123, 3580, 4221, 2598, 4631, 2844, 4905, 5446, 4529, 5186, 6228, 6210, 5693, 6213, -4670,
+ 9050, 9934, 8441, 7921, 7546, 7840, 7977, 8335, 8679, 8706, 8703, 8607, 8560, 8375, 7759, 6405,
+ 4243, 5775, 2939, 5887, 4078, 3117, 5267, 5680, 4589, 2401, 731, 1011, 1657, 4733, 7051, 3992,
+ 2508, 3156, 3347, 1605, 4450, 4633, 3476, 6019, 4083, 3824, 5133, 6020, 3253, 1368, 1736, 13507,
+ 5934, 6372, 4494, 2957, 4424, 6667, 8167, 8413, 7957, 7139, 5518, 3059, 2829, 2821, 2773, 3274,
+ 4984, 5566, 5831, 4556, 5732, 6738, 6689, 4683, 2265, 4214, 7242, 9989, 9776, 9068, 4748, 2292,
+ 2601, 4933, 2764, 4923, 3763, 3678, 5596, 2079, 6108, 6824, 5507, 5612, 6793, 5553, 1140, 9993,
+ 7084, 6685, 5313, 5196, 3111, 5337, 3535, 2476, 2477, 1737, 2090, 4033, 5680, 6548, 7310, 11811,
+ 8140, 8602, 7166, 6738, 6018, 5299, 5686, 4722, 4108, 4456, 3713, 3131, 2658, 2336, 2250, 8051,
+ 727, 1865, 6073, 3932, 2258, 2413, 4823, 5733, 5101, 6126, 4690, 1130, 1172, 1479, 3956, 7204,
+ 6042, 1024, 5371, 5997, 4964, 5575, 5078, 5843, 6909, 8465, 8601, 6137, 5699, 8049, 9922, 8318,
+ 2728, 1625, 4750, 5004, 5799, 4938, 6353, 3274, 1781, 3095, 1479, 3136, 5470, 1391, -626, 2422,
+ 4407, 3228, 1266, 1488, 1222, 963, 1148, 1182, 1330, 1770, 860, 381, 813, 1268, 2352, 3956,
+ 1683, -120, 83, 1239, 946, 1609, 1982, 3215, 3950, 4200, 4497, 4898, 4551, 3595, 2345, 2444,
+ 1055, 3207, 7460, 6808, 7103, 6980, 7902, 8196, 6821, 6190, 6405, 7414, 7967, 7506, 6921, 9871,
+ 3164, 7995, 8446, 8770, 8443, 8302, 7372, 7049, 6090, 5698, 5090, 4792, 4996, 4874, 4285, 6685,
+ 3681, 319, 536, 3174, 4495, 5486, 5807, 5751, 5461, 4423, 3556, 3449, 5148, 7560, 6277, 3783,
+ 1987, 4209, 6954, 5880, 7459, 7762, 4326, 4958, 5154, 2150, 2988, 2469, 1175, 1099, 3999, 3950,
+ 1306, 2303, 7748, 8238, 6116, 2824, 1772, 1130, 2538, 3345, 5317, 4773, 3668, 5458, 5519, 5594,
+ 4140, 4329, 3339, 3001, 2669, -79, -582, -1729, -680, 1294, 2752, 3700, 3627, 4428, 4950, 2744,
+ 5309, 3611, 993, 3526, 2043, 3938, 2069, 1434, 4173, 2609, 2704, 3690, 3686, 1894, 1401, -1682,
+ 6091, 4810, 970, 1063, 1707, 3056, 4597, 6742, 7397, 6913, 7359, 7884, 7571, 6830, 6039, 3823,
+ 6599, 6006, 1248, 4330, 6935, 3784, 3535, 3902, 3221, 5384, 5691, 5997, 5975, 6731, 9125, 5385,
+ 204, 242, 2009, 3375, 3412, 3407, 2691, 2547, 598, -150, 67, 250, 618, 1185, 1987, 1157,
+ 4986, 7977, 6971, 1528, 86, 281, 1497, 3002, 4193, 4430, 4721, 5317, 6001, 6181, 6962, 5480,
+ 6914, 7963, 5254, 3050, 5365, 3224, 3781, 3044, 2571, 3155, 2243, 1612, 2157, 2526, 2784, -1629,
+ 7350, 6702, 2435, 1937, 2549, 1978, 2819, 2817, 2059, 2493, 3408, 2344, 1239, 1177, 914, 3763,
+ 4362, 3105, -1457, -1760, 314, 1452, 2603, 1642, 1670, 1652, 2258, 2492, 3844, 4399, 5213, 660,
+ 350, 357, 109, 83, -555, -886, -714, -587, -120, 25, 189, 531, 591, 146, 156, 1435,
+ 498, 211, 3062, 6766, 7150, 8142, 7531, 7527, 7855, 6898, 6613, 6480, 5290, 4310, 5341, 4129,
+ 2753, 6959, 7088, 4622, 2646, 2395, 1756, 325, 488, 259, -125, -577, -553, 615, 557, 4617,
+};
+
+const Word16 CBsizes_fx[] =
+{
+ 1,2,4,8,16,32,64
+};
+
+/*----------------------------------------------------------------------------------*
+ * LSF quantization - LSF mode/codebook selection tables
+ *----------------------------------------------------------------------------------*/
+const Word16 CB_lsf_fx[] =
+{
+ -1, /* Mode 0 : INACTIVE NB, Safety net */
+ -1, /* Mode 1 : UNVOICED NB, Safety net */
+ 0, /* Mode 2 : VOICED NB, Safety net */
+ 2, /* Mode 3 : GENERIC NB, Safety net */
+ 2, /* Mode 4 : TRANSITION NB, Safety net */
+ 4, /* Mode 5 : AUDIO NB, Safety net */
+ -1, /* Mode 6 : INACTIVE WB, Safety net */
+ -1, /* Mode 7 : UNVOICED WB, Safety net */
+ 5, /* Mode 8 : VOICED WB, Safety net */
+ 7, /* Mode 9 : GENERIC WB, Safety net */
+ 7, /* Mode 10 : TRANSITION WB, Safety net */
+ 9, /* Mode 11 : AUDIO WB, Safety net */
+ -1, /* Mode 12 : INACTIVE WB16k, Safety net */
+ -1, /* Mode 13 : UNVOICED WB16k, Safety net */
+ -1, /* Mode 14 : VOICED WB16k, Safety net */
+ -1, /* Mode 15 : GENERIC WB 16k, Safety net */
+ 10, /* Mode 16 : TRANSITION WB16k, Safety net */
+ -1, /* Mode 17 : AUDIO WB16k, Safety net */
+ 13 /* Mode 18 : CNG, Safety net */
+};
+
+const Word16 CB_p_lsf_fx[] =
+{
+ 0, /* Mode 0 : INACTIVE NB, Predictive */
+ 1, /* Mode 1 : UNVOICED NB, Predictive */
+ 4, /* Mode 2 : VOICED NB, Predictive */
+ 4, /* Mode 3 : GENERIC NB, Predictive */
+ -1, /* Mode 4 : TRANSITION NB, Predictive */
+ -1, /* Mode 5 : AUDIO NB, Predictive */
+ 0, /* Mode 6 : INACTIVE WB, Predictive */
+ 1, /* Mode 7 : UNVOICED WB, Predictive */
+ 6, /* Mode 8 : VOICED WB, Predictive */
+ 6, /* Mode 9 : GENERIC WB, Predictive */
+ -1, /* Mode 10 : TRANSITION WB, Predictive */
+ -1, /* Mode 11 : AUDIO WB, Predictive */
+ 0, /* Mode 12 : INACTIVE WB16k, Predictive */
+ -1, /* Mode 13 : UNVOICED WB16k, Predictive */
+ -1, /* Mode 14 : VOICED WB16k, Predictive */
+ 8, /* Mode 15 : GENERIC WB16k, Predictive */
+ -1, /* Mode 16 : TRANSITION WB16k, Predictive */
+ 10, /* Mode 17 : AUDIO WB16k, Predictive */
+ 9, /* Mode 18 : GENERIC WB, MA Predictive */
+};
+const Word16 CBbits_fx[] =
+{
+ -1, /* Mode 0 : INACTIVE NB, Safety net */
+ -1, /* Mode 1 : UNVOICED NB, Safety net */
+ 4, /* Mode 2 : VOICED NB, Safety net */
+ 5, /* Mode 3 : GENERIC NB, Safety net */
+ 5, /* Mode 4 : TRANSITION NB, Safety net */
+ 4, /* Mode 5 : AUDIO NB, Safety net */
+ -1, /* Mode 6 : INACTIVE WB, Safety net */
+ -1, /* Mode 7 : UNVOICED WB, Safety net */
+ 4, /* Mode 8 : VOICED WB, Safety net */
+ 5, /* Mode 9 : GENERIC WB, Safety net */
+ 5, /* Mode 10 : TRANSITION WB, Safety net */
+ 4, /* Mode 11 : AUDIO WB, Safety net */
+ -1, /* Mode 12 : INACTIVE WB16k, Safety net */
+ -1, /* Mode 13 : UNVOICED WB16k, Safety net */
+ 4, /* Mode 14 : VOICED WB16k, Safety net */
+ -1, /* Mode 15 : GENERIC WB16k, Safety net */
+ 4, /* Mode 16 : TRANSITION WB16k, Safety net */
+ -1, /* Mode 17 : AUDIO WB16k, Safety net */
+ 4, /* Mode 18: CNG, Safety net */
+};
+
+
+const Word16 CBbits_p_fx[] =
+{
+ 5, /* Mode 0 : INACTIVE NB, Predictive */
+ 4, /* Mode 1 : UNVOICED NB, Predictive */
+ 3, /* Mode 2 : VOICED NB, Predictive */
+ 3, /* Mode 3 : GENERIC NB, Predictive */
+ -1, /* Mode 4 : TRANSITION NB, Predictive */
+ 0, /* Mode 5 : AUDIO NB, Predictive */
+ 5, /* Mode 6 : INACTIVE WB, Predictive */
+ 4, /* Mode 7 : UNVOICED WB, Predictive */
+ 3, /* Mode 8 : VOICED WB, Predictive */
+ 3, /* Mode 9 : GENERIC WB, Predictive */
+ -1, /* Mode 10 : TRANSITION WB, Predictive */
+ 0, /* Mode 11 : AUDIO WB, Predictive */
+ 5, /* Mode 12 : INACTIVE WB16k, Predictive */
+ -1, /* Mode 13 : UNVOICED WB16k, Predictive */
+ 3, /* Mode 14 : VOICED WB16k, Predictive */
+ 5, /* Mode 15 : GENERIC WB16k, Predictive */
+ -1, /* Mode 16 : TRANSITION WB16k, Predictive */
+ 5, /* Mode 17 : AUDIO WB16k, Predictive */
+ 5, /* Mode 9 : GENERIC WB, Predictive */
+};
+
+
+
+const Word16 BitsVQ_fx[]=
+{
+ -1, /* Mode 0 : INACTIVE NB, Safety net */
+ -1, /* Mode 1 : UNVOICED NB, Safety net */
+ 8, /* Mode 2 : VOICED NB, Safety net */
+ 9, /* Mode 3 : GENERIC NB, Safety net */
+ 9, /* Mode 4 : TRANSITION NB, Safety net */
+ 4, /* Mode 5 : AUDIO NB, Safety net */
+ -1, /* Mode 6 : INACTIVE WB, Safety net */
+ -1, /* Mode 7 : UNVOICED WB, Safety net */
+ 8, /* Mode 8 : VOICED WB, Safety net */
+ 9, /* Mode 9 : GENERIC WB, Safety net */
+ 9, /* Mode 10 : TRANSITION WB, Safety net */
+ 4, /* Mode 11 : AUDIO WB, Safety net */
+ -1, /* Mode 12 : INACTIVE WB16k, Safety net */
+ -1, /* Mode 13 : UNVOICED WB16k, Safety net */
+ 8, /* Mode 14 : VOICED WB16k, Safety net */
+ -1, /* Mode 15 : GENERIC WB16k, Safety net */
+ 8, /* Mode 16 : TRANSITION WB16k, Safety net */
+ -1, /* Mode 17 : AUDIO WB16k, Safety net */
+ 4, /* Mode 18: CNG, Safety net */
+};
+
+
+const Word16 BitsVQ_p_fx[]=
+{
+ 5, /* Mode 0 : INACTIVE NB, Predictive */
+ 8, /* Mode 1 : UNVOICED NB, Predictive */
+ 6, /* Mode 2 : VOICED NB, Predictive */
+ 6, /* Mode 3 : GENERIC NB, Predictive */
+ -1, /* Mode 4 : TRANSITION NB, Predictive */
+ 0, /* Mode 5 : AUDIO NB, Predictive */
+ 5, /* Mode 6 : INACTIVE WB, Predictive */
+ 12, /* Mode 7 : UNVOICED WB, Predictive */
+ 6, /* Mode 8 : VOICED WB, Predictive */
+ 6, /* Mode 9 : GENERIC WB, Predictive */
+ -1, /* Mode 10 : TRANSITION WB, Predictive */
+ 0, /* Mode 11 : AUDIO WB, Predictive */
+ 5, /* Mode 12 : INACTIVE WB16k, Predictive */
+ -1, /* Mode 13 : UNVOICED WB16k, Predictive */
+ 6, /* Mode 14 : VOICED WB16k, Predictive */
+ 5, /* Mode 15 : GENERIC WB16k, Predictive */
+ -1, /* Mode 16 : TRANSITION WB16k, Predictive */
+ 5, /* Mode 17 : AUDIO WB16k, Predictive */
+ 5, /* Mode 18 : GENERIC WB, MA Predictive */
+};
+
+
+const Word16 predmode_tab[][6] =
+{
+ {1,1,2,2,0,2},
+ {1,1,2,2,0,2},
+ {1,-1,2,1,0,1},
+ {1,1,2,1,0,2} /* should check how is the cb for audio mode at 13.2*/
+};
+
+/* Stable ISP vector in Q15 */
+const Word16 stable_ISP_fx[16] = { 32139, 30274, 27247, 23170, 18206, 12540, 6393, 0, -6390, -12537, -18203, -23170, -27243, -30271, -32139, 1475 };
+/* Stable LSP vector in Q15 */
+/* This LSP corresponds to GEWB_Ave_fx */
+const Word16 stable_LSP_fx[16] = {32437, 31676, 29486, 25681, 21564, 16413, 10838, 5385, -735, -6405, -11986, -17040, -22052, -26346, -29678, -31784};
+/* Length 16 vector in Scale = 2.56f */
+const Word16 SVWB2_Ave_fx[16] = {998, 1488, 2682, 3823, 5084, 6305, 7485, 8686, 9861, 11004, 12339, 13664, 15088, 16330, 17663, 18754 };
+/* An 16-by-1 matrix */
+const Word16 IANB_Ave_fx[16] =
+{
+ 726, 1433, 2493, 3408, 4340, 5215, 6103, 6947, 7772, 8536, 9252, 10012, 10909, 12427, 13997, 15193
+};
+/* An 16-by-1 matrix */
+const Word16 IAWB_Ave_fx[16] =
+{
+ 577, 1350, 2526, 3535, 4539, 5504, 6497, 7460, 8445, 9396, 10371, 11319, 12307, 13268, 14249, 15207
+};
+/* An 16-by-1 matrix */
+const Word16 IAWB2_Ave_fx[16] =
+{
+ 731, 1777, 3194, 4386, 5629, 6806, 8012, 9164, 10329, 11469, 12731, 14037, 15326, 16538, 17801, 18927
+};
+/* Length 16 vector in Scale = 2.56f */
+const Word16 UVNB_Ave_fx[16] = {1018, 1764, 2856, 3751, 4611, 5410, 6233, 6961, 7685, 8304, 8859, 9325, 9977, 11741, 13699, 15074 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 UVWB_Ave_fx[16] = {898, 1900, 3172, 4190, 5181, 6161, 7134, 8066, 8995, 9888, 10784, 11636, 12527, 13396, 14301, 15183 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 SVNB_Ave_fx[16] = {890, 1268, 1930, 2902, 3938, 4823, 5832, 6644, 7487, 8202, 8906, 9545, 10788, 12565, 13959, 15183 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 SVWB_Ave_fx[16] = {832, 1248, 1949, 3083, 4131, 5117, 6179, 7067, 8008, 8922, 9875, 10741, 11785, 12860, 13968, 15048 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 GEWB_Ave_fx[16] = {742, 1350, 2354, 3495, 4446, 5456, 6434, 7331, 8309, 9218, 10145, 11044, 12042, 13063, 14101, 15103 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 GEWB2_Ave_fx[16] = {909, 1783, 3227, 4443, 5685, 6851, 7996, 9116, 10213, 11263, 12465, 13754, 15090, 16293, 17621, 18695 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 GENB_Ave_fx[16] = {836, 1344, 2257, 3263, 4173, 5031, 5950, 6707, 7514, 8234, 8881, 9439, 10393, 12226, 13855, 15135 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 TRNB_Ave_fx[16] = {919, 1335, 2106, 3142, 4092, 4938, 5905, 6670, 7490, 8199, 8868, 9444, 10544, 12383, 13900, 15156 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 TRWB_Ave_fx[16] = {834, 1326, 2151, 3341, 4305, 5299, 6318, 7198, 8167, 9071, 10001, 10867, 11871, 12912, 13986, 15046 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 TRWB2_Ave_fx[16] = {945, 1546, 2866, 4150, 5342, 6568, 7660, 8809, 9894, 10934, 12170, 13577, 14981, 16280, 17614, 18778 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 AUNB_Ave_fx[16] = {887, 1443, 2356, 3194, 4105, 4949, 5841, 6635, 7437, 8181, 8867, 9478, 10385, 12182, 13858, 15131 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 AUWB_Ave_fx[16] = {810, 1468, 2476, 3417, 4396, 5342, 6311, 7215, 8171, 9078, 10030, 10969, 12014, 13075, 14146, 15133 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 AUWB2_Ave_fx[16] = {933, 1745, 3040, 4157, 5379, 6490, 7646, 8725, 9852, 10930, 12214, 13647, 15062, 16297, 17636, 18768 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 means_wb_cleanspeech_lsf16k0[16] = {727, 1426, 2582, 3554, 4548, 5481, 6397, 7293, 8170, 9010, 9972, 11003, 12072, 13034, 14097, 14956 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 means_swb_cleanspeech_lsf25k6[16] = {786, 1840, 2892, 3833, 4778, 5658, 6641, 7662, 8692, 9630, 10603, 11534, 12489, 13387, 14349, 15217 };
+/* Length 16 vector in Scale = 2.56f */
+const Word16 means_swb_cleanspeech_lsf32k0[16] = {757, 1855, 2862, 3798, 4705, 5661, 6742, 7692, 8658, 9577, 10513, 11401, 12358, 13269, 14275, 15149 };
+
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor0_fx[16] = {27361, 27361, 27361, 27197, 27197, 27197, 26378, 26460, 26214, 25985, 26460, 26460, 25985, 25723, 25723, 24740 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor1_fx[16] = {27034, 27034, 27034, 26640, 26313, 26640, 26640, 26132, 26214, 26214, 26460, 26870, 26870, 26706, 27034, 26640 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor2_fx[16] = {24248, 23593, 24510, 24248, 24510, 24019, 24019, 23757, 23757, 24019, 24248, 24248, 23593, 23101, 23593, 23101 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor3_fx[16] = {24248, 24248, 24740, 24248, 24510, 23757, 23429, 23101, 22610, 23101, 23593, 24740, 25002, 24740, 25002, 24838 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor4_fx[16] = {19005, 18350, 19268, 19005, 19268, 18776, 18776, 18514, 18514, 18776, 19005, 19005, 18350, 17859, 17695, 17203 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor5_fx[16] = {23839, 23593, 23593, 23839, 23839, 23593, 23593, 23593, 23839, 24084, 24347, 24576, 24576, 23364, 23364, 23364 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor6_fx[16] = {24084, 23839, 24084, 23593, 23593, 22938, 22381, 21791, 21135, 21955, 22381, 24347, 24576, 23593, 24576, 24347 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor7_fx[16] = {24347, 24084, 24347, 24347, 24347, 24084, 24347, 24576, 24576, 24740, 25068, 24347, 24084, 23839, 23364, 24740 };
+/* Length 16 vector in Q = 15 */
+const Word16 Predictor8_fx[16] = {24740, 24740, 24740, 24576, 24576, 24576, 24084, 23839, 23593, 23364, 23839, 23839, 23364, 23101, 23101, 22118 };
+
+const Word16 *const ModeMeans_fx[] = {IANB_Ave_fx, UVNB_Ave_fx, SVNB_Ave_fx, GENB_Ave_fx, TRNB_Ave_fx, AUNB_Ave_fx, IAWB_Ave_fx, UVWB_Ave_fx,
+ SVWB_Ave_fx, GEWB_Ave_fx, TRWB_Ave_fx, AUWB_Ave_fx, IAWB2_Ave_fx, NULL, SVWB2_Ave_fx, GEWB2_Ave_fx, TRWB2_Ave_fx, AUWB2_Ave_fx
+ };
+const Word16 * const Predictors_fx[] = {Predictor6_fx, NULL, Predictor1_fx, Predictor3_fx, NULL, Predictor6_fx,Predictor5_fx, NULL, Predictor0_fx,
+ Predictor2_fx, NULL, Predictor5_fx, Predictor7_fx, NULL, Predictor8_fx, Predictor4_fx, NULL, Predictor7_fx
+ };
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 UVD_MA1_fx[256] =
+{
+ -301, -503, -426, -187, -131, -64, -45, -20, 11, 56, 63, 90, 110, 175, 97, 33,
+ 161, 353, 474, 502, 709, 782, 794, 765, 632, 532, 406, 285, 230, 145, 97, 52,
+ -37, -5, 205, 323, 412, 349, 221, 91, -6, -59, -86, -112, -32, 209, 73, 23,
+ -273, -615, -820, -794, -834, -838, -822, -819, -751, -701, -641, -562, -391, -271, -184, -63,
+ 262, 168, 104, -9, -78, -163, -141, -199, -191, -249, -245, -317, -168, 535, 109, 33,
+ -410, -675, -681, -611, -500, -396, -273, -183, -47, 60, 194, 357, 1044, 1080, 335, 140,
+ 154, 185, 256, 238, 203, 238, 280, 260, 300, 267, 258, 196, 121, -618, -263, -60,
+ 345, 705, 859, 786, 743, 584, 425, 267, 168, 105, 74, 28, 119, 267, 105, 39,
+ -39, -166, -230, -196, -255, -276, -318, -349, -387, -438, -539, -613, -752, -956, -1353, -1628,
+ 498, 479, 414, 231, 98, 5, -18, -41, -60, -78, -91, -96, -81, 72, 30, -8,
+ 41, 120, 65, 141, 117, 186, 249, 299, 418, 520, 566, 618, 692, 579, 321, 166,
+ -236, -278, -69, 13, 113, 362, 445, 539, 503, 387, 269, 172, 120, -21, 1, 4,
+ -103, -46, -137, -132, -108, -97, -67, -37, -8, 41, 82, 107, 43, -605, -189, -56,
+ -220, -315, -482, -516, -489, -445, -415, -362, -304, -205, -136, -68, -7, 131, 70, 25,
+ -10, -121, -210, -237, -224, -302, -246, -310, -271, -343, -285, -364, 28, 703, 135, 54,
+ 118, 50, -67, -166, -349, -416, -442, -446, -439, -420, -382, -319, -245, -209, -140, -82
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 UVD_MA2_fx[256] =
+{
+ -75, -64, -150, -231, -272, -278, -248, -194, -156, -107, -74, -43, -92, -21, 9, 5,
+ 393, 275, -12, -156, -208, -215, -162, -132, -115, -109, -94, -85, -104, -10, 5, -1,
+ -297, -389, -99, -78, -66, -19, -12, 8, 0, -3, -15, -22, -113, -82, -16, 2,
+ 59, -11, 5, -33, -11, -61, -70, -139, -143, -239, -207, -223, 711, 701, 143, 68,
+ -195, 406, 222, 49, -6, -23, -6, 9, 0, 13, 26, 49, -44, -129, -18, -7,
+ 23, -30, -141, 79, -18, -76, -55, -14, 44, 98, 88, 86, -96, -351, -112, -39,
+ 380, 329, 235, 173, 141, 72, 25, -4, -6, -19, -21, -33, -55, -23, 3, -1,
+ -81, -210, -284, 158, 396, 290, 163, 59, -25, -22, -10, -6, -46, -32, 9, 5,
+ 9, 34, -15, 5, 23, -48, -127, -243, -347, -421, -455, -475, -495, -449, -294, -163,
+ -13, -171, -416, -414, -245, -25, 69, 102, 104, 84, 50, 33, -38, -4, 0, 5,
+ 50, 118, 68, 37, 147, 319, 371, 355, 291, 204, 130, 81, 21, 46, 36, 22,
+ -95, -108, 311, 214, -28, -153, -226, -192, -129, -69, -42, -11, -48, -17, 13, 2,
+ -185, -223, -104, 26, 53, 89, 132, 181, 258, 346, 397, 445, 392, 241, 125, 58,
+ 83, 33, -9, -81, 40, 99, 56, 8, -51, -85, -106, -124, -196, 5, 5, 0,
+ 143, 148, 19, -121, -247, -211, -67, 83, 198, 268, 290, 300, 240, 164, 86, 37,
+ -198, -136, 370, 372, 300, 240, 156, 113, 79, 60, 44, 29, -35, -38, 6, 7
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 UVWB_MA3_fx[256] =
+{
+ -26, 23, 7, -6, -1, 3, 40, 35, -43, -24, 56, 157, 265, 423, 382, 260,
+ 61, -300, -130, -101, -8, 106, 108, 114, 88, 43, -2, -33, -56, 67, 29, 13,
+ -31, 47, 45, -121, 46, 22, 111, 233, -256, -252, -123, -71, -31, 54, 56, 33,
+ 20, -154, 67, 198, -232, -167, -86, -12, 79, 116, 88, 78, 44, 75, 27, -7,
+ -14, 153, -166, 21, 107, 64, 233, -223, -147, -27, -1, 43, 61, 70, 50, 18,
+ 3, -115, -8, 143, 192, 193, -124, -195, -198, -162, -75, 14, 45, 83, 79, 49,
+ 12, -57, 25, -29, -11, 12, -7, -13, -12, 31, 74, 99, -10, -421, -209, -111,
+ -25, 115, 119, -19, -117, -164, -203, -237, -206, -169, -110, -41, -11, 15, 1, -7,
+ -13, 170, -143, -128, -224, -94, 1, 96, 144, 102, 29, 2, -37, 46, 7, -12,
+ -11, 10, -34, 38, 24, 86, 149, 211, 240, 279, 247, 218, 154, 161, 74, 15,
+ -24, 64, 110, 125, -24, 123, 161, 166, 177, 18, -112, -116, -141, -117, -113, -91,
+ -4, -20, -17, -11, -27, 13, -15, -40, -58, -157, -252, -283, -288, -186, -162, -112,
+ -20, 2, 32, 44, -31, -49, 8, 13, 55, -59, -162, -212, -61, 384, 115, 36,
+ -4, 42, -75, 92, 268, -203, -125, 10, 52, 121, 72, -43, -109, -47, -66, -76,
+ -39, 76, 268, -254, -28, 87, 2, 91, 85, 68, 89, 96, 42, 90, 39, 4,
+ 2, 2, -56, 7, 67, -31, -219, -192, -24, 146, 249, 269, 209, 199, 106, 31
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 SVNB_SN1_fx[256] =
+{
+ 135, 109, 135, -153, -549, 214, 416, 195, 291, 247, 100, -127, -579, -160, -66, -32,
+ -107, -150, -274, -149, 642, 594, 338, 183, 81, -31, -14, -150, -387, -40, -44, -18,
+ 73, 42, 171, 339, 213, 42, -137, -277, -379, -441, -440, -478, 270, 126, -4, 6,
+ -307, -479, -636, -596, -100, 83, 167, 200, 260, 376, 523, 1051, 1142, 490, 249, 108,
+ -148, -215, -324, -570, -917, -685, -208, 127, 285, 353, 441, 940, 1100, 458, 229, 100,
+ 427, 432, 548, 426, 133, 13, -9, -141, -108, -144, -195, -419, -733, -144, -109, -45,
+ -115, -220, -194, 661, 896, 688, 489, 351, 211, 258, 147, 30, -746, -784, -156, -95,
+ 16, -48, -88, -430, -798, 36, 204, 68, 174, 162, 20, 61, 627, 266, 102, 48,
+ -252, -370, -630, -614, 680, 1024, 869, 598, 419, 259, 193, 27, 90, 156, 53, 27,
+ -48, 33, 26, -227, -556, -766, -391, 231, 413, 282, 226, 89, 194, 187, 44, 30,
+ -204, -291, -345, -131, 125, 72, 16, -29, -106, -49, -27, 183, 714, 277, 114, 49,
+ -11, 205, 285, 69, -58, -207, -301, -160, -30, -2, 12, -99, -580, -178, -80, -41,
+ 120, 189, 281, 427, 234, 138, 124, 126, 50, 205, 121, 76, -797, -1204, -235, -133,
+ 63, -18, 146, 666, 480, 236, 134, -39, -97, -130, -175, -378, -746, -159, -106, -46,
+ 386, 399, 415, 157, -175, -282, -315, -318, -222, -225, -267, -342, 317, 152, 15, 14,
+ 39, 56, 71, -95, -387, -509, -595, -466, -395, -186, -24, 421, 814, 292, 127, 52
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 SVNB_SN2_fx[256] =
+{
+ -16, 111, 111, -89, -115, -404, -514, 162, 277, 41, -94, -89, 15, 31, 2, 2,
+ -82, -99, -25, -287, -464, 204, 18, -123, -38, 56, 109, 198, 160, 96, 41, 19,
+ -95, -62, -242, -415, 318, 118, -121, 44, 74, 40, 85, 114, 52, 36, 21, 8,
+ 29, 40, 43, 23, -202, -149, 288, 149, -20, -109, -186, -275, -127, 18, -25, -6,
+ 20, 36, -97, -228, 565, 508, 134, 42, -70, -237, -258, -259, -123, -9, -29, -10,
+ -72, -169, 492, 463, 193, 204, -13, -75, -82, -125, -181, -230, -181, -10, -40, -12,
+ -108, -221, -229, 648, 575, 288, 146, 1, -14, -4, -51, -120, -81, -14, -17, -5,
+ -199, -264, -309, 209, 8, -128, 24, -47, 87, 257, 240, 185, 93, 70, 34, 16,
+ 25, 82, -60, -155, -407, -615, 29, 100, -113, 32, 207, 258, 203, 111, 49, 21,
+ 37, 127, 95, 4, 112, -45, -217, -158, -277, -407, -304, -152, 72, 52, -6, 0,
+ -30, -81, -116, -416, -219, 677, 538, 328, 213, 60, -60, -109, -78, 0, -5, 0,
+ 9, -15, 26, 75, -175, -336, -673, -586, 238, 310, 198, 189, 212, 126, 48, 24,
+ -18, -4, -80, 102, 130, -116, -268, -471, -567, -104, 205, 221, 143, 81, 29, 12,
+ 4, 39, 65, 115, 88, 189, 136, 124, 49, 106, 37, 89, -375, -626, -114, -73,
+ 540, 525, 472, 221, 118, -31, 15, 7, -71, -139, -108, -93, -13, -4, -13, -8,
+ -44, -44, -143, -272, -525, -365, 479, 502, 312, 225, 161, 72, 28, 42, 26, 12
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 SVWB_SN1_fx[256] =
+{
+ -71, -61, -170, -563, -962, -845, 186, 421, 282, 344, 260, 155, 186, 52, -18, -11,
+ -107, -139, -289, -270, 788, 615, 249, 174, -1, -24, 159, 106, -46, -183, -187, -107,
+ -144, -221, -215, 359, 192, -34, -186, -326, -256, -124, -49, 84, 214, 237, 186, 91,
+ 218, 332, 335, 41, -191, -394, -614, -543, -415, -379, -285, -153, -86, -101, -69, -13,
+ 587, 616, 732, 419, 270, 252, 102, 40, 53, -35, -57, -34, 19, -14, -15, -120,
+ -76, -222, -127, 1216, 1188, 815, 532, 320, 311, 228, 34, -59, -96, -86, -44, -38,
+ -176, -282, -507, -455, 1122, 1359, 965, 742, 610, 448, 474, 412, 185, 127, 127, -24,
+ -156, -225, 16, 458, 423, 438, 393, 400, 525, 658, 682, 681, 612, 438, 267, 68,
+ 89, 120, 172, 355, 195, -8, -22, -67, -110, -40, -93, -163, -382, -685, -926, -468,
+ -227, -362, -452, -577, -213, -22, 56, 82, 132, 216, 348, 420, 358, 299, 257, 143,
+ 38, -77, 117, 856, 486, 282, 16, -154, -130, -315, -618, -783, -892, -545, -88, 59,
+ 218, 324, 232, -162, -583, -552, 126, 62, -40, -27, -227, -348, -334, -324, -238, -65,
+ 82, 16, -20, -539, -787, 604, 340, 259, 260, -53, -251, -211, -12, 127, 171, 99,
+ -24, 168, 202, -142, -223, -448, -282, 122, 148, 155, 363, 380, 347, 263, 124, -68,
+ 165, 150, 226, 95, -172, -257, -413, -510, -533, -734, -1014, -1206, -834, -162, 6, 97,
+ -78, -72, -81, -322, -605, -731, -740, -564, -356, -219, -151, 11, 200, 237, 212, 170
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 SVWB_SN2_fx[256] =
+{
+ -126, -152, -342, -423, 311, 95, 3, 29, -93, 4, 227, 193, 142, 120, 93, 62,
+ 190, 258, 382, 310, 166, -11, -77, -67, -217, -327, -330, -378, -461, -309, -142, -47,
+ -16, -58, -77, -339, -534, 469, 399, 237, 290, 135, 34, 86, -14, -77, -30, 10,
+ 13, -4, 644, 572, 412, 438, 272, 286, 234, 177, 118, 147, 131, 138, 127, 38,
+ -73, -88, -112, 42, 36, 141, 424, 386, 504, 576, 523, 483, 431, 328, 233, 59,
+ -120, -169, -270, -445, -593, -268, -133, -138, -11, 56, 133, 210, 166, 116, 122, 137,
+ 282, 370, 255, 76, -89, -191, 139, 80, 12, 176, 185, 145, 244, 253, 173, -18,
+ 13, 14, -43, 73, -59, -270, -448, -622, -59, 374, 353, 293, 189, -54, -199, -122,
+ -75, -106, -281, -312, 585, 405, 185, 62, -176, -319, -330, -400, -418, -162, -4, 78,
+ -31, -11, -79, -83, -88, -274, -343, -431, -623, -518, -148, -11, -17, -21, 21, 90,
+ -101, -173, -240, 444, 303, 121, 104, -37, 185, 134, -45, -136, -164, 4, 153, 114,
+ -8, 40, 107, -76, -254, -551, -673, 288, 318, 25, 14, -62, -97, -2, 13, -20,
+ 87, 127, 80, 216, 336, 147, 188, 165, -10, 125, 193, 87, -126, -396, -736, -669,
+ 2, 4, 96, 185, 6, 62, -37, -136, -177, -250, -227, 201, 744, 651, 351, 74,
+ -16, -39, -82, -177, -380, -183, -24, -109, -194, -407, -641, -615, -157, 146, 191, 167,
+ -21, -12, -39, -63, -159, -128, 20, 6, 16, 39, -60, -243, -594, -733, -364, 46
+};
+
+/* An 16-by-32 matrix in Scale = 2.56f */
+const Word16 GEWB_MA1_fx[512] =
+{
+ 269, 268, 416, 287, 157, 7, -132, -276, -482, -701, -1025, -1350, -1642, -982, -321, -49,
+ 237, 949, 1374, 1228, 1337, 1219, 1123, 1016, 852, 752, 664, 559, 448, 306, 194, 83,
+ -6, -176, -373, -111, -221, -387, -483, -639, -753, -786, -774, -655, -328, -114, -25, 27,
+ 135, 164, -4, -181, -364, -528, -464, -424, -393, -314, -242, -185, -104, -61, -32, -37,
+ 15, -218, -322, 668, 597, 343, 196, -5, -46, -159, -359, -524, -629, -548, -308, -95,
+ 242, 463, 767, 661, 558, 403, 268, 191, 71, -4, -51, -103, -141, -176, -161, -142,
+ -179, -147, 715, 865, 970, 932, 822, 763, 602, 514, 436, 370, 285, 189, 106, 36,
+ -49, -227, -589, -933, -1172, -700, -248, -175, -132, -132, -125, -103, -47, -49, -12, 60,
+ -7, -227, -404, 272, 83, -50, -165, -319, -343, -501, -731, -939, -1013, -607, -202, -2,
+ -76, -271, -661, -582, 296, 86, -60, -166, -335, -314, -213, -285, -324, -280, -164, -39,
+ -264, -452, -111, 171, 229, 357, 355, 461, 509, 517, 489, 441, 347, 246, 158, 75,
+ 67, -49, -340, -546, -758, -919, -876, -727, -658, -567, -492, -400, -234, -140, -63, 36,
+ -142, 94, 514, 400, 406, 389, 379, 413, 391, 377, 354, 314, 245, 156, 94, 34,
+ 97, -47, -316, -620, -874, -179, -206, -290, -304, -514, -690, -723, -503, -252, -73, 39,
+ 485, 674, 532, 195, 38, -60, 17, 52, 63, 74, 85, 62, 35, -10, -22, -51,
+ -105, -23, 287, 394, 469, 609, 706, 860, 933, 933, 874, 789, 638, 465, 297, 148,
+ -223, -499, -837, -813, -391, -231, -178, -182, -81, 2, 84, 113, 131, 142, 127, 107,
+ -64, 269, 879, 849, 1013, 1157, 1250, 1337, 1263, 1176, 1048, 900, 703, 502, 318, 165,
+ 61, 1, -198, -209, -345, -417, -280, -280, -307, -272, -341, -418, -604, -738, -887, -394,
+ 45, 77, 124, 152, 99, 43, 20, -4, -91, -85, -192, -280, -544, -754, -1176, -1296,
+ 173, 69, -49, -226, -344, -479, -489, -618, -727, -909, -1122, -1446, -1292, -492, -205, 10,
+ -80, -80, 338, 285, 123, 48, -76, -80, -105, -118, -108, -80, -58, -28, -9, -8,
+ 74, -79, -292, -618, -756, 345, 216, 180, 143, -73, -186, -223, -200, -143, -52, -21,
+ -253, -519, -578, -188, -96, -35, -7, 27, 133, 218, 258, 258, 231, 180, 120, 70,
+ 273, 740, 950, 736, 701, 635, 611, 602, 566, 533, 494, 447, 350, 230, 131, 42,
+ -100, -345, -702, -352, 709, 682, 485, 324, 161, 112, 148, 25, -88, -106, -86, -101,
+ 307, 265, 253, 65, -63, -75, -169, -282, -390, -501, -550, -532, -406, -296, -186, -132,
+ -26, 70, 50, -84, -89, 28, 106, 199, 305, 391, 450, 469, 419, 301, 191, 80,
+ 22, 39, -154, -426, -597, -497, -159, -69, 41, 95, 114, 114, 99, 33, -7, -40,
+ -162, -356, -511, -461, -475, -513, -477, -485, -395, -249, -136, -71, -4, 33, 54, 64,
+ -82, -295, -562, 241, 65, -163, -227, -384, -237, -229, -266, -223, -94, 10, 41, 31,
+ -104, -323, -302, 733, 646, 418, 271, 149, 155, 154, 119, 99, 89, 63, 13, -16
+};
+/* An 16-by-32 matrix in Scale = 2.56f */
+const Word16 GETRNB_SN1_fx[512] =
+{
+ -119, -271, -427, 447, 321, 58, 37, -105, -65, 99, 106, 21, -277, 53, 9, -6,
+ -93, -241, -433, -826, -1028, 17, 180, 138, 320, 234, 152, 235, 973, 594, 199, 96,
+ -300, -474, -553, -497, -374, -231, -224, -170, -145, 51, 154, 714, 1338, 690, 271, 118,
+ -115, -228, -248, 9, -27, -196, -240, -269, -293, -310, -276, -254, 769, 481, 117, 59,
+ 172, 58, 469, 585, 512, 336, 145, -52, -167, -344, -379, -487, 285, 377, 27, 27,
+ 81, 34, 574, 859, 818, 702, 521, 344, 177, 23, -116, -274, -611, -78, -61, -35,
+ 76, 19, -104, -388, -687, 54, 279, 144, 237, 223, 110, 9, -335, 4, 3, -10,
+ 115, 380, 486, 446, 389, 316, 239, 249, 197, 207, 162, 141, -435, -1516, -409, -136,
+ -146, -348, -425, 645, 998, 790, 609, 468, 282, 287, 153, 87, -461, -592, -88, -64,
+ -249, -471, -835, -642, 589, 960, 887, 637, 442, 286, 242, 132, 142, 299, 99, 44,
+ 128, 37, -120, -314, -571, -730, -868, -558, -259, -109, 8, 413, 1145, 593, 210, 92,
+ 151, 331, 267, 130, -24, -89, -133, -43, -75, 57, 19, 94, -469, -796, -124, -90,
+ -339, -468, -292, -34, 76, 179, 231, 269, 259, 281, 275, 204, -93, 157, 53, 16,
+ 33, 176, 25, -201, -311, -497, -509, -242, -47, 6, 86, 48, -165, 176, 24, 8,
+ 27, 223, 461, 500, 479, 475, 489, 560, 635, 741, 924, 1347, 1546, 806, 277, 54,
+ 510, 464, 402, 114, -80, -285, -290, -321, -283, -368, -325, -424, 388, 402, 52, 38,
+ 521, 614, 732, 549, 428, 278, 180, 81, 14, -110, -204, -355, -649, -32, -56, -36,
+ 72, 26, 262, 263, 159, 113, 60, -10, -73, -121, -201, -329, -768, -61, -60, -39,
+ 85, 57, 116, -40, -78, -159, -154, -247, -220, -366, -331, -532, -35, 344, 0, 25,
+ 527, 919, 1339, 1225, 1190, 1023, 774, 577, 393, 160, -4, -184, -281, 29, -21, -12,
+ -230, -283, -338, -379, -313, -293, -163, -122, 15, 97, 243, 168, 361, 449, 102, 61,
+ 378, 369, 369, 136, 42, -72, -73, -154, -155, -260, -270, -444, -562, 173, -36, -9,
+ 168, 108, -36, -347, -559, -436, -254, -263, -236, -227, -247, -238, 796, 488, 123, 62,
+ -151, -118, 163, 452, 430, 484, 456, 418, 377, 363, 256, 183, -403, -1429, -382, -126,
+ -204, -366, -652, -512, 428, 353, 182, 88, -10, -94, -54, -11, 801, 527, 151, 76,
+ 60, 79, -169, -465, -789, -844, -55, 181, 209, 172, 210, 107, 260, 399, 91, 52,
+ -69, -205, -377, -164, 647, 584, 302, 151, 32, -135, -136, -223, -269, 170, 4, 5,
+ 38, 418, 885, 979, 990, 1027, 870, 804, 669, 537, 360, 241, -336, -1281, -338, -111,
+ -420, -700, -912, -622, -337, -51, 67, 173, 326, 554, 766, 1395, 1656, 894, 390, 178,
+ -141, -252, -507, -822, -1084, -845, -280, 20, 149, 242, 393, 951, 1428, 740, 303, 135,
+ -120, -37, 31, 105, 72, 99, 53, 117, 59, 171, 120, 177, -414, -993, -160, -98,
+ -382, -612, -631, -167, 4, 104, 130, 141, 242, 325, 348, 430, 1048, 651, 222, 109
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 GETRNB_SN2_fx[256] =
+{
+ -27, 71, 45, -4, 28, 69, 25, 94, 45, 90, 45, 87, -177, -567, -116, -59,
+ -208, -147, 531, 399, 199, 113, -21, -28, -34, -38, -48, -46, -47, 18, -1, -1,
+ 69, -20, -115, -355, -380, 388, 379, 193, 134, 37, -42, -60, -35, 29, 6, 5,
+ 107, 89, -98, -189, 379, 289, 68, 22, -71, -179, -187, -192, -137, 4, -17, -7,
+ -44, -81, -371, -448, 226, 75, -52, 43, 40, 36, 79, 120, 130, 76, 36, 15,
+ 131, 115, 192, 177, 25, -7, -23, -95, -132, -184, -206, -245, -200, -12, -29, -11,
+ 45, -25, -249, 50, -189, -358, 253, 145, -39, 27, 34, -20, -52, 13, 1, 2,
+ -254, -155, 23, -89, -30, 23, -23, -21, -45, -86, -92, -109, -48, 52, 3, 3,
+ -248, -233, 139, 213, 232, 361, 349, 401, 373, 301, 230, 207, 204, 101, 32, 14,
+ 491, 546, 409, 147, 34, -18, 52, 59, 48, 27, 14, 7, -1, -37, -16, -9,
+ 36, 41, 0, -21, -29, -64, -207, -346, -516, -355, -64, 73, 156, 94, 30, 11,
+ -28, -173, -278, 506, 427, 164, 111, 21, -33, -61, -78, -90, -32, 39, 4, 4,
+ -44, -60, -215, -373, -485, -270, 12, 151, 271, 265, 215, 178, 153, 71, 32, 17,
+ 110, 155, -29, -259, -218, -183, -175, -132, -85, -98, -87, -93, -77, 0, -9, -4,
+ -116, -14, 235, 1, -238, -398, -419, -55, 109, 77, 62, 74, 73, 47, 16, 8,
+ -20, -108, -219, 246, 20, -184, -328, -449, -67, 142, 125, 110, 91, 74, 28, 13
+};
+/* An 16-by-32 matrix in Scale = 2.56f */
+const Word16 GETRWB_SN1_fx[512] =
+{
+ -232, -191, 282, 248, 344, 390, 428, 490, 538, 592, 620, 607, 533, 372, 261, 136,
+ -59, -227, -418, -288, -247, -448, -501, -644, -760, -922, -1112, -1204, -523, -130, 12, 131,
+ 139, 838, 1402, 1327, 1465, 1391, 1371, 1342, 1220, 1147, 1041, 910, 733, 518, 335, 181,
+ 211, 148, -94, -275, -484, -586, -541, -634, -583, -511, -424, -322, -285, -299, -194, -87,
+ 410, 362, 337, 73, -36, -113, -180, -274, -373, -493, -501, -473, -393, -361, -271, -251,
+ -85, -366, -819, -532, 753, 688, 414, 203, 24, -43, 129, 60, -100, -123, -97, -114,
+ 4, 37, 484, 514, 340, 225, 89, 59, 40, 3, -5, -1, -11, -49, -43, -48,
+ -223, -471, -661, -567, -496, -519, -464, -542, -484, -343, -276, -185, -43, 17, 84, 133,
+ -106, -312, -668, -741, 385, 329, 121, -157, -423, -710, -957, -1280, -1143, -330, -20, 131,
+ 250, 157, 71, -310, -552, -740, -745, -778, -827, -1064, -1336, -1629, -788, -195, -44, 131,
+ 140, 633, 970, 864, 867, 761, 683, 648, 572, 544, 516, 469, 383, 238, 143, 55,
+ 116, 143, 229, 134, -25, -120, -232, -333, -535, -642, -985, -1259, -1873, -1727, -330, -10,
+ -64, -82, -62, -232, -308, -346, -296, -272, -153, -26, 108, 205, 232, 158, 129, 53,
+ 82, -92, -309, -791, -1128, -259, -243, -405, -367, -637, -903, -1084, -675, -199, 17, 146,
+ -247, -569, -886, -758, -334, -206, -158, -150, -64, 57, 190, 252, 261, 210, 163, 129,
+ -23, -319, -458, 791, 718, 400, 233, -81, -174, -400, -758, -1048, -1338, -1038, -288, -6,
+ 50, 462, 303, -47, -122, -134, 15, 137, 179, 222, 266, 249, 219, 123, 80, 30,
+ -116, -332, -650, -1104, -1367, -691, -376, -295, -178, -199, -170, -24, 125, 95, 125, 168,
+ -66, -314, -526, 325, 156, -56, -114, -287, -126, -185, -292, -298, -189, -81, 1, 23,
+ 147, -30, -291, -771, -939, 262, 182, 126, 127, -100, -163, -134, -91, -95, -52, -19,
+ -225, -496, -449, -61, 46, 135, 182, 247, 324, 404, 457, 464, 420, 305, 209, 106,
+ 418, 312, 415, 74, -156, -345, -400, -634, -769, -1057, -1362, -1841, -1848, -471, -147, 87,
+ 38, 19, -232, -552, -698, -941, -483, 119, 54, -34, 70, -68, -144, -192, -253, -236,
+ 80, -30, -214, -157, -292, -312, -283, -347, -384, -372, -487, -503, -746, -950, -1372, -644,
+ 44, 55, 124, 181, 125, 109, 61, 29, -73, -54, -206, -278, -638, -929, -1563, -1742,
+ 802, 823, 726, 353, 272, 122, 117, 94, 80, 40, 68, 47, 42, -19, -26, -69,
+ 50, -97, -306, -666, -918, -1109, -1124, -776, -710, -728, -675, -486, -150, -3, 93, 160,
+ 81, -144, -131, 319, 227, -96, -236, -517, -711, -949, -1231, -1644, -1625, -444, -117, 86,
+ -230, -237, 586, 799, 931, 1023, 1077, 1179, 1133, 1101, 1027, 909, 731, 515, 330, 171,
+ 448, 632, 1047, 782, 631, 390, 155, -82, -342, -685, -1103, -1520, -1779, -931, -214, 34,
+ -77, -352, -353, 787, 938, 677, 513, 352, 284, 278, 247, 181, 141, 73, 8, -39,
+ 54, 42, -67, -298, -465, -593, -533, -547, -626, -741, -977, -1317, -1665, -613, -119, 80
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 GETRWB_SN2_fx[256] =
+{
+ -202, -246, -356, -356, -232, -164, -79, 4, 78, 130, 152, 165, 170, 141, 90, 70,
+ 38, 78, -72, -185, -446, -552, 269, 295, 104, 77, -54, -184, -168, -72, -32, -2,
+ 69, 93, 39, 116, 100, 46, 50, -1, -2, 62, 8, -105, -404, -656, -494, -224,
+ -285, -305, 263, 97, 29, 33, -24, 54, 35, 25, -4, -6, -30, 13, 20, 21,
+ -28, -70, -160, 34, 5, -145, -264, -425, -539, -329, -19, 228, 411, 280, 141, 51,
+ 244, 245, 19, -319, -461, -184, -10, 47, 220, 293, 309, 330, 281, 140, 71, 12,
+ -128, -251, -374, 424, 279, 68, 35, -68, 13, 45, -6, -41, -73, -17, 8, 27,
+ -55, -7, 438, 500, 493, 442, 286, 211, 68, -39, -117, -167, -180, -131, -75, -63,
+ 30, 31, 69, 114, -172, -407, -596, -391, 102, 169, 158, 131, 46, 4, -6, -3,
+ 69, 76, 33, 238, 164, 119, 160, 165, 273, 342, 383, 419, 456, 378, 262, 96,
+ -55, 43, -59, -273, -200, -286, -287, -221, -247, -245, -194, -160, -129, -36, -31, 3,
+ -35, -46, -272, -357, 484, 246, -11, 21, -123, -197, -102, -94, -96, -22, 6, 6,
+ -117, -188, -252, -227, 0, 460, 506, 526, 501, 389, 250, 131, -28, -32, 24, 17,
+ 399, 511, 390, 146, 80, -84, -81, -57, -123, -138, -95, -82, -51, -33, -14, -45,
+ -9, 12, 300, 304, 182, 27, -197, -258, -344, -393, -384, -318, -140, -5, -6, 6,
+ 64, 25, -7, -256, -306, 381, 243, 96, -17, -190, -285, -246, -65, 48, 37, 29
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 TRWB2_SN1_fx[256] =
+{
+ -74, -384, -764, -964, -1122, -912, -819, -740, -728, -572, -379, -317, -250, -51, -67, 85,
+ -311, -618, -439, -108, 156, 257, 404, 543, 643, 729, 732, 572, 446, 329, 236, 164,
+ 523, 1549, 1557, 1476, 1374, 1192, 1068, 923, 901, 788, 717, 401, 262, 6, -100, -368,
+ -13, -80, -189, -386, -486, -357, -216, -63, 65, 189, 248, 194, 218, 219, 205, 169,
+ -104, -519, -772, 492, 224, 18, -203, -244, -126, -220, -362, -417, -271, -71, -34, -50,
+ -202, 124, 811, 975, 1326, 1468, 1613, 1527, 1474, 1366, 1220, 906, 700, 509, 351, 207,
+ -57, -196, -238, -281, -267, -239, -190, -137, -27, 4, 77, -178, -256, -553, -669, -1105,
+ -183, -211, 804, 789, 685, 529, 479, 403, 371, 313, 279, 49, -19, -156, -179, -335,
+ 758, 848, 608, 313, 271, 176, 177, 73, 106, 61, 59, -159, -203, -287, -268, -343,
+ 199, 70, 95, -29, -245, -411, -745, -1009, -1473, -1921, -2633, -1648, -537, -284, -87, 207,
+ 82, -217, -460, -646, -718, -821, -983, -1282, -1580, -2108, -1863, -609, -407, -122, -50, 243,
+ -132, 364, 364, 340, 489, 496, 596, 606, 704, 756, 777, 616, 521, 409, 305, 211,
+ 123, -189, -91, -306, -319, -407, -600, -679, -911, -855, -566, -249, -65, -1, -65, -25,
+ 79, -58, -103, -150, -268, -265, -426, -479, -614, -671, -1005, -1378, -2027, -1547, -568, -52,
+ -275, -669, -1070, -1097, -688, -433, -340, -148, -27, 194, 309, 277, 229, 188, 82, 127,
+ 397, 1343, 1482, 1729, 1978, 2012, 1969, 1852, 1729, 1574, 1407, 1087, 848, 636, 431, 278
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 TRWB2_SN2_fx[256] =
+{
+ 50, -66, -486, -850, 504, 345, 261, 10, -207, -218, -174, -18, 72, 69, 3, 24,
+ -171, -439, -632, 390, 143, -89, -292, -314, -227, -157, 33, 181, 185, 204, 128, 167,
+ 458, 459, 78, -250, -365, -381, -353, -382, -327, -284, -191, -18, 3, 37, 29, 95,
+ -169, -227, -423, -448, -485, -426, -364, -284, -238, -184, -228, -190, -145, 17, 65, 145,
+ -4, -120, -170, -333, -677, -782, -719, -391, -112, 232, 464, 392, 275, 215, 121, 139,
+ -94, -130, 453, 295, -45, -286, -444, -473, -519, -428, -268, -40, -12, 46, 39, 118,
+ -189, -245, 805, 815, 518, 293, 162, 110, -67, -158, -223, -120, -36, 15, 26, 60,
+ 23, 130, 107, 0, -31, -66, 33, 22, 101, -10, -32, -232, -281, -590, -672, -1089,
+ 51, 106, 157, 132, 40, 11, -73, -66, -165, -294, -561, -770, -742, -489, -202, 4,
+ 25, 230, 286, 179, 75, 18, 15, 24, 109, 187, 310, 334, 328, 291, 237, 212,
+ -238, -492, -550, 563, 764, 610, 542, 427, 373, 261, 166, 171, 122, 34, -21, -92,
+ -359, -462, -10, 22, -42, -2, 78, 167, 154, 155, 74, 73, 66, 94, 89, 126,
+ -5, -110, -374, -546, -386, -136, 95, 305, 437, 570, 615, 558, 463, 335, 209, 151,
+ 23, 376, 292, 235, 485, 519, 657, 549, 478, 338, 186, 7, -28, -155, -95, -188,
+ 166, 139, -277, -716, -822, 234, 319, 326, 234, 36, -155, -317, -247, -80, 49, 117,
+ 431, 853, 745, 512, 325, 139, 83, -31, -25, -47, -17, -12, -24, -43, -5, 13
+};
+/* An 16-by-32 matrix in Scale = 2.56f */
+const Word16 GEWB2_MA1_fx[512] =
+{
+ 659, 1694, 1634, 1513, 1305, 1098, 933, 805, 733, 624, 525, 339, 239, 50, -35, -215,
+ 6, 65, 125, 55, -85, -126, -272, -316, -507, -586, -1010, -1278, -1941, -1910, -426, 78,
+ 281, 315, 236, -4, -102, -171, -232, -335, -362, -425, -488, -603, -669, -736, -648, -593,
+ 29, -251, -582, -871, -969, -897, -991, -1077, -1275, -1480, -998, -393, -247, -9, 28, 271,
+ -60, -361, 401, 552, 236, 35, -196, -215, -496, -683, -911, -820, -576, -299, -240, -141,
+ 416, 574, 662, 350, 133, -160, -431, -781, -1200, -1652, -2035, -1092, -449, -192, -11, 263,
+ -206, -609, -931, 28, -229, -358, -543, -462, -377, -360, -336, -251, -105, 35, 26, 80,
+ 369, 1256, 1380, 1571, 1726, 1727, 1644, 1521, 1350, 1156, 984, 748, 580, 395, 254, 108,
+ -147, -479, -330, -73, -272, -441, -685, -837, -1139, -1458, -1370, -414, -208, -12, 14, 213,
+ -50, 100, -82, -253, -7, 119, 294, 392, 494, 578, 589, 523, 462, 383, 300, 249,
+ -94, -362, -575, -770, -987, -999, -922, -697, -582, -305, -135, -31, -8, 23, -33, 62,
+ 29, -64, -4, -123, -344, -414, -679, -767, -1152, -1401, -2105, -1905, -582, -300, -64, 223,
+ 428, 990, 1019, 809, 681, 470, 366, 179, 126, -26, -141, -363, -423, -536, -437, -545,
+ -133, -357, 364, 241, -39, -227, -334, -305, -426, -292, -102, 87, 159, 182, 160, 190,
+ 560, 764, 531, 156, 22, -18, 23, -20, 19, 0, 13, -61, -35, -44, -12, -48,
+ 33, -235, -634, -1093, 136, -31, -68, -285, -529, -535, -462, -249, -95, -53, -116, -61,
+ -188, -628, -894, 702, 700, 373, 196, 51, 95, -56, -191, -181, -173, -132, -116, -218,
+ 37, -188, -661, -1087, -1322, -258, -186, -181, -238, -372, -418, -508, -433, -197, -73, 28,
+ -231, -222, 911, 875, 669, 440, 363, 301, 257, 192, 147, 68, 77, 43, 57, 17,
+ -4, -187, -356, -410, -569, -499, -584, -568, -660, -703, -965, -1201, -1540, -708, -252, 87,
+ 220, 64, -67, -357, -572, -744, -913, -1176, -1439, -1894, -2152, -762, -419, -146, -10, 281,
+ -253, -627, -1075, -1206, -721, -398, -337, -188, -118, 50, 125, 198, 200, 190, 96, 164,
+ -348, -741, -854, -357, -163, -103, -26, 143, 231, 318, 335, 325, 274, 233, 167, 190,
+ -143, -256, -191, -280, -250, -191, -82, 37, 126, 102, 67, -130, -202, -430, -495, -810,
+ 232, 107, -22, -341, -497, -523, -607, -646, -746, -690, -478, -295, -160, -77, -53, -7,
+ -33, -98, -258, -501, -589, -438, -316, -168, -58, 82, 175, 219, 249, 259, 237, 226,
+ -393, -665, -19, 185, 249, 266, 378, 468, 499, 508, 464, 388, 310, 238, 186, 145,
+ -240, -99, 408, 480, 693, 761, 946, 943, 951, 893, 782, 613, 482, 351, 260, 163,
+ -23, 523, 885, 903, 1172, 1287, 1482, 1491, 1476, 1402, 1240, 1005, 787, 604, 433, 292,
+ 262, 988, 904, 732, 734, 665, 715, 656, 673, 615, 541, 372, 284, 139, 68, -84,
+ -119, 446, 1118, 1215, 1372, 1280, 1208, 989, 881, 675, 557, 319, 227, 23, -39, -256,
+ -102, 178, 379, 252, 365, 319, 455, 377, 413, 278, 225, -36, -67, -351, -375, -772
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 AUNB_SN1_fx[256] =
+{
+ -180, -79, -51, 39, 66, 99, 48, 108, 56, 127, 34, 46, -470, -845, -141, -90,
+ -212, 82, 284, 422, 416, 416, 313, 289, 233, 210, 108, 55, -439, -1323, -336, -123,
+ -9, 405, 532, 659, 710, 798, 844, 971, 1072, 1181, 1464, 1913, 2028, 1232, 549, 265,
+ 75, 49, 330, 493, 448, 329, 204, 67, -18, -134, -235, -400, -605, -30, -67, -36,
+ -9, -7, -95, -222, -322, -421, -321, -233, -110, -86, 67, -19, 3, 345, 41, 30,
+ 153, 34, -172, -386, -500, -548, -503, -420, -317, -207, -114, 183, 1096, 661, 198, 94,
+ 616, 501, 471, 220, 157, 55, 4, -161, -178, -314, -267, -389, 216, 429, 46, 38,
+ -559, -854, -789, -369, -153, 64, 146, 296, 388, 520, 574, 958, 1481, 898, 340, 164,
+ 131, 137, 116, 57, 64, -21, -38, -112, -123, -199, -214, -379, -641, 83, -53, -21,
+ -101, -324, -648, -801, -835, -737, -501, -296, -86, 144, 400, 1025, 1501, 861, 322, 151,
+ -231, -397, -512, -506, -308, -200, -127, -91, -18, 17, 94, 114, 798, 625, 161, 88,
+ -518, -617, -201, 103, 258, 279, 273, 267, 281, 251, 214, 114, 58, 270, 70, 31,
+ 17, -86, -78, -82, -22, -73, -171, -299, -334, -431, -422, -526, 517, 511, 71, 53,
+ 276, 182, -40, -336, -461, -93, 342, 267, 166, 18, -43, -196, -146, 236, 18, 14,
+ 227, 338, 224, 188, 107, 80, 57, 92, 34, 80, -5, -4, -515, -927, -174, -100,
+ 731, 744, 797, 675, 590, 438, 328, 215, 144, 24, -96, -239, -486, -175, -65, -41
+};
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 AUWB_SN1_fx[256] =
+{
+ 328, 137, 358, 330, 184, 145, -60, -294, -555, -784, -945, -872, -601, -337, -155, -33,
+ 32, -212, -488, -651, -752, -877, -892, -886, -853, -795, -705, -549, -330, -224, -127, -9,
+ 372, 327, 197, 33, 13, -55, -87, -124, -125, -148, -144, -168, -175, -184, -127, -125,
+ 752, 727, 623, 519, 449, 350, 309, 289, 272, 252, 185, 124, 118, 35, 22, -20,
+ 14, 144, 296, 432, 416, 325, 177, 166, 151, 123, 109, 104, 47, -22, -45, -49,
+ 310, 112, -141, -529, -654, -53, 162, -33, -297, -551, -772, -817, -540, -287, -95, -7,
+ -158, 241, 443, 543, 559, 579, 566, 606, 610, 622, 602, 578, 485, 331, 197, 104,
+ -471, -530, 37, 272, 397, 442, 466, 523, 561, 592, 608, 576, 485, 348, 222, 133,
+ 162, 0, -87, -85, -151, -331, -410, -603, -767, -1030, -1348, -1812, -1735, -678, -284, -6,
+ -156, 36, 15, 26, 41, 118, 201, 265, 339, 382, 420, 435, 377, 264, 159, 84,
+ -69, -274, -411, -158, 60, -56, -190, -305, -371, -389, -411, -407, -338, -276, -173, -99,
+ 0, -26, -196, -379, -369, -327, -193, -148, -77, -10, 63, 98, 98, 49, 40, -5,
+ -149, -432, -729, -923, -927, -766, -568, -455, -333, -219, -122, -29, 11, 9, 20, 54,
+ 177, 64, -60, -232, -411, -552, -557, -550, -509, -464, -380, -331, -297, -288, -215, -170,
+ -16, 439, 971, 1104, 1209, 1323, 1339, 1374, 1317, 1223, 1107, 983, 781, 535, 315, 151,
+ -432, -727, -686, -340, -156, -40, 18, 102, 169, 257, 306, 335, 296, 213, 137, 97
+};
+
+/* An 16-by-16 matrix in Scale = 2.56f */
+const Word16 AUWB2_SN1_fx[256] =
+{
+ -107, -446, -835, -1041, -1152, -1161, -1146, -969, -828, -533, -251, -242, -139, 172, 95, 466,
+ 1052, 1008, 1052, 875, 864, 748, 783, 690, 754, 715, 688, 342, 195, -32, -251, -509,
+ -311, -170, 366, 632, 748, 863, 983, 1042, 1118, 1188, 1133, 895, 728, 621, 460, 418,
+ 608, 525, 322, 30, -237, -483, -862, -1178, -1651, -2184, -2770, -1349, -430, -28, 128, 562,
+ 296, 171, -192, -429, -488, -470, -492, -473, -448, -352, -242, -309, -337, -210, -265, -182,
+ 831, 703, 456, 217, 165, 65, 17, -53, -67, -78, -38, -222, -340, -329, -349, -391,
+ 162, -13, -158, -335, -526, -705, -986, -1245, -1640, -2149, -2754, -1344, -372, -12, 134, 564,
+ -79, -389, -569, -699, -811, -940, -1058, -1299, -1534, -2077, -1953, -507, -216, 143, 191, 607,
+ -106, -116, -210, -225, -323, -330, -494, -491, -700, -757, -1057, -1424, -2222, -1509, -259, 348,
+ -366, -748, -1177, -1216, -1017, -698, -444, -154, 10, 285, 361, 284, 255, 359, 187, 365,
+ 77, 447, 418, 475, 453, 459, 475, 515, 562, 648, 658, 452, 367, 334, 244, 204,
+ 10, 197, 170, 166, 144, 60, 52, -2, -20, -40, 18, -238, -279, -434, -451, -807,
+ -460, -713, -547, -153, 64, 243, 386, 492, 620, 752, 759, 536, 445, 324, 151, -32,
+ -246, -396, -413, -371, -354, -317, -307, -228, -195, -101, -36, -174, -197, -162, -261, -349,
+ -329, -240, 326, 462, 428, 344, 405, 374, 439, 434, 467, 127, 85, -154, -248, -683,
+ -12, 15, -222, -227, -31, 124, 200, 294, 357, 541, 607, 459, 376, 352, 282, 283
+};
+
+/* An 16-by-16 matrix */
+const short CNG_SN1_fx[256] =
+{
+ 600, 1640, 3039, 4257, 5512, 6740, 7989, 9169, 10393, 11612, 12880, 14100, 15378, 16554, 17816, 18918,
+ 1188, 2487, 3746, 4903, 6103, 7261, 8437, 9587, 10776, 11954, 13172, 14355, 15564, 16712, 17913, 19012,
+ 346, 799, 2259, 3555, 4876, 6175, 7516, 8803, 10073, 11323, 12631, 13938, 15282, 16553, 17817, 19039,
+ 439, 1616, 3446, 4743, 6073, 7288, 8553, 9726, 10947, 12106, 13312, 14474, 15650, 16773, 17894, 18977,
+ 921, 1800, 2976, 4007, 5105, 6137, 7178, 8150, 9057, 9914, 11009, 12545, 13671, 15502, 17428, 18927,
+ 896, 1899, 3035, 4128, 5301, 6429, 7604, 8719, 9886, 11059, 12417, 13621, 14962, 16135, 17475, 18460,
+ 722, 1507, 2537, 3437, 4328, 5190, 6018, 6841, 7587, 8343, 8925, 9511, 9919, 11075, 13613, 15021,
+ 315, 612, 1671, 2910, 3990, 5083, 6120, 7170, 8188, 9173, 10148, 11186, 12250, 13262, 14290, 15284,
+ 885, 1928, 3010, 3973, 4952, 5900, 6848, 7769, 8701, 9609, 10581, 11540, 12508, 13450, 14412, 15349,
+ 338, 1020, 2657, 3736, 4839, 5791, 6806, 7760, 8738, 9659, 10627, 11567, 12534, 13468, 14416, 15334,
+ 1126, 1964, 2999, 3855, 4764, 5608, 6482, 7286, 8109, 8827, 9570, 10649, 11999, 13125, 14223, 15252,
+ 385, 815, 2000, 2939, 3906, 4879, 5793, 6734, 7661, 8526, 9309, 10146, 11597, 12955, 14106, 15241,
+ 633, 1445, 2400, 3293, 4235, 5171, 6143, 7084, 8057, 8980, 9924, 10924, 11987, 12998, 14016, 15058,
+ 584, 1248, 2250, 3131, 4050, 4920, 5811, 6652, 7471, 8244, 8913, 9480, 10188, 12225, 13871, 15123,
+ 1157, 1820, 2745, 3505, 4354, 5097, 5932, 6648, 7408, 8034, 8635, 9083, 9977, 12228, 13819, 15108,
+ 572, 1401, 2514, 3501, 4503, 5465, 6469, 7435, 8416, 9328, 10306, 11309, 12328, 13303, 14306, 15261,
+};
+/* An 16-by-32 matrix */
+const Word16 IAA_MA1_fx[512] =
+{
+ -175, -490, -520, -631, -645, -614, -610, -548, -503, -432, -353, -301, -238, -141, -67, 26,
+ 301, 407, 227, 96, -12, -18, -13, 2, 39, 107, 124, 92, 83, 100, 62, 72,
+ -280, -737, -569, -164, -9, 100, 141, 211, 252, 281, 274, 217, 206, 219, 117, 106,
+ -266, -753, -841, -587, -487, -345, -263, -167, -114, -30, 8, 32, 34, 61, 55, 104,
+ -91, -137, -293, -349, -352, -326, -268, -247, -178, -129, -56, -96, -11, 219, 49, 56,
+ -18, 1, -33, -14, -19, -5, -22, -14, -43, -37, -104, -143, -375, -770, -190, -100,
+ 72, -22, -121, -220, -320, -378, -500, -587, -729, -795, -1056, -1305, -1691, -1090, -452, -60,
+ 19, -279, -453, -580, -588, -739, -858, -1044, -1281, -1614, -921, -376, -273, -84, -2, 187,
+ 853, 759, 591, 376, 260, 122, 39, -71, -133, -184, -209, -297, -299, -171, -124, -83,
+ 266, 34, -182, -367, -516, -686, -881, -1121, -1414, -1834, -2110, -997, -519, -274, -109, 137,
+ -2, -8, 42, 91, 172, 211, 298, 336, 433, 409, 546, 1043, 1499, 1038, 410, 189,
+ 86, 254, 259, 254, 246, 219, 184, 122, 79, 11, -55, -170, -363, -934, -371, -188,
+ 168, 167, -122, -244, -325, -340, -359, -343, -331, -291, -278, -270, -272, -162, -101, -46,
+ -244, -459, -367, -340, -295, -220, -173, -107, -22, 53, 103, 293, 1084, 807, 260, 117,
+ -319, -650, -685, -427, -290, -105, 25, 161, 303, 418, 587, 1074, 1563, 1085, 400, 170,
+ 146, 257, 282, 295, 303, 294, 297, 262, 237, 193, 92, 341, 1220, 884, 315, 144,
+ -291, -558, 147, 201, 282, 280, 310, 302, 313, 306, 292, 239, 198, 188, 106, 94,
+ -11, -8, -156, -204, -231, -250, -265, -289, -269, -316, -322, -450, -488, -676, -778, -973,
+ -117, -27, 4, 96, 174, 229, 271, 310, 344, 362, 344, 273, 209, 180, 109, 106,
+ -260, -290, 151, 269, 406, 442, 551, 590, 679, 681, 900, 1293, 1631, 1132, 477, 221,
+ -37, 374, 394, 414, 419, 395, 345, 313, 282, 255, 211, 126, 84, 51, -10, -53,
+ 404, 327, 174, 28, -124, -290, -490, -695, -1011, -1111, -529, -288, -183, -69, -7, 142,
+ 563, 752, 585, 555, 512, 478, 424, 396, 376, 343, 300, 194, 193, 162, 78, 46,
+ -59, -131, -35, 49, 54, -12, -92, -185, -243, -289, -288, -344, -326, 0, -38, 6,
+ 496, 582, 564, 514, 521, 490, 486, 436, 432, 320, 456, 1060, 1523, 1058, 419, 194,
+ 174, 77, 18, -89, -112, -196, -165, -247, -222, -326, -332, -494, 499, 617, 121, 60,
+ 315, 299, 229, 137, 78, -3, -40, -138, -198, -307, -375, -502, -515, -25, -88, -49,
+ -232, -29, 353, 399, 485, 487, 523, 526, 556, 559, 520, 415, 328, 283, 187, 166,
+ 182, 385, 403, 453, 515, 572, 635, 691, 787, 852, 1154, 1483, 1779, 1231, 524, 246,
+ -273, -492, -185, -97, -52, -51, -17, -27, 13, 20, 45, -20, 52, 244, 58, 56,
+ 20, -3, -241, -267, -194, -86, 4, 75, 140, 191, 200, 154, 137, 146, 85, 77,
+ 92, 628, 611, 708, 706, 716, 672, 694, 655, 619, 550, 432, 354, 284, 204, 172
+};
+/* An 16-by-8 matrix in Scale = 2.56f */
+const Word16 GESVNB_AR1_fx[128] =
+{
+ -25, -64, -140, -118, 270, 240, 127, 70, 20, -40, -56, -111, -82, 64, 2, 5,
+ 81, 104, 71, 70, 0, -49, -54, -73, -59, -92, -102, -201, -404, -52, -40, -15,
+ -112, -217, -251, -202, -34, 57, 58, 62, 79, 127, 177, 306, 524, 315, 112, 53,
+ 17, -6, 34, 66, 14, -26, -174, -196, -142, -131, -102, -97, 180, 154, 29, 17,
+ 5, -27, -107, -197, -343, -333, -182, -143, -91, -17, 43, 120, 383, 267, 83, 40,
+ -1, -15, -35, -56, -169, -145, 86, 101, 77, 48, 29, 78, -9, 68, 15, 9,
+ 3, 9, 320, 450, 385, 348, 215, 155, 105, 45, -13, -75, -272, -129, -52, -23,
+ 4, 49, 54, 90, 92, 101, 59, 69, 20, 70, 23, 43, -280, -624, -114, -55
+};
+/* An 16-by-8 matrix in Scale = 2.56f */
+const Word16 GESVNB_AR2_fx[128] =
+{
+ -22, -35, -31, -166, -164, 217, 212, 155, 166, 123, 67, 33, -21, -41, -3, -1,
+ -14, -20, -16, -70, -77, -53, 23, -7, -98, -123, -99, -49, 357, 114, 36, 19,
+ -57, -119, -303, -215, -33, -103, -97, -117, -105, -102, -67, -134, -176, 113, 16, 8,
+ -12, 14, 30, -37, -112, -226, -206, -25, 125, 134, 99, 83, 55, -4, 9, 4,
+ -19, 23, 171, 57, 13, -15, -26, -42, -65, -69, -77, -169, -351, -105, -49, -21,
+ -14, -10, 8, 35, 161, 104, -74, -102, -135, -47, 45, 264, 52, -69, -1, -5,
+ 213, 284, 230, 121, 50, 12, 43, 48, 27, -7, -24, -39, 75, 1, -9, -3,
+ -75, -137, -89, 275, 164, 65, 125, 91, 86, 91, 56, 10, 9, -10, 0, 0
+};
+/* An 16-by-8 matrix in Scale = 2.56f */
+const Word16 GESVWB_AR1_fx[128] =
+{
+ -3, -16, -31, 2, -81, -123, -226, -260, -196, -122, -20, 78, 178, 145, 84, 46,
+ 55, 42, 15, 32, -48, -81, -109, -137, -187, -264, -330, -387, -363, -176, -38, 37,
+ -32, -70, -144, -269, -337, -183, 59, 58, 44, 49, 42, 51, 72, 50, 26, 38,
+ -18, -58, -79, 125, 352, 291, 180, 118, 72, 25, -23, -82, -185, -167, -33, 6,
+ -10, 135, 544, 517, 517, 561, 515, 528, 500, 472, 413, 383, 318, 219, 118, 57,
+ -54, -280, -614, -548, -521, -522, -448, -479, -457, -438, -377, -355, -318, -271, -222, -89,
+ -62, -96, -86, -10, 104, 155, 120, 112, 190, 264, 291, 272, 232, 166, 95, 27,
+ 33, 61, 155, 121, 9, -28, 6, 103, 64, 17, 4, -2, -31, -88, -209, -206
+};
+/* An 16-by-8 matrix in Scale = 2.56f */
+const Word16 GESVWB_AR2_fx[128] =
+{
+ -147, -326, -421, -91, -22, -25, -14, -21, 32, 76, 104, 102, 65, 47, 50, 41,
+ -39, -16, 61, -13, -38, -56, 47, 153, 195, 213, 212, 220, 245, 245, 209, 86,
+ -34, -73, 82, 387, 199, 71, 56, -18, -33, -56, -88, -79, -5, 59, 55, 29,
+ -7, -21, -21, -158, -123, 304, 226, 168, 124, 8, -75, -91, -54, -5, 37, 30,
+ -26, -22, -67, -225, 107, 38, -82, -113, -213, -205, -62, 28, 89, 95, 52, 17,
+ 227, 404, 325, 134, 45, -16, 3, -15, -55, -65, -55, -54, -18, -8, 1, -14,
+ 19, 30, 12, 28, 48, 13, 2, -47, -38, 41, 29, -8, -154, -315, -411, -242,
+ 8, 24, 29, -61, -215, -329, -237, -106, -12, -12, -64, -118, -167, -119, 8, 52
+};
+
+/* An 16-by-32 matrix in Scale = 2.56f */
+const Word16 AUWB2_MA1_fx[512] =
+{
+ 391, 298, 179, -37, -225, -387, -627, -864, -1216, -1644, -2108, -804, -277, -5, 121, 468,
+ 351, 213, 141, -75, -130, -164, -332, -410, -524, -573, -575, -474, -331, -103, -22, 201,
+ 81, 874, 1137, 1223, 1242, 1262, 1238, 1185, 1141, 1085, 993, 733, 570, 424, 256, 145,
+ -6, -25, -105, -147, -327, -342, -587, -620, -954, -1143, -1878, -2059, -356, -100, 134, 477,
+ -197, -505, -826, -1043, -863, -485, -296, -103, -6, 178, 269, 245, 231, 320, 243, 413,
+ -518, -605, 282, 430, 532, 596, 676, 748, 808, 861, 834, 681, 534, 498, 293, 337,
+ -244, -563, -720, -599, -500, -494, -627, -739, -1028, -1219, -297, 9, 71, 272, 285, 563,
+ -448, -854, -916, -518, -287, -52, 56, 245, 347, 524, 557, 497, 416, 452, 321, 437,
+ 150, 113, 28, -26, 1, -80, -177, -226, -193, -156, -62, -227, -240, -383, -535, -809,
+ -240, -246, -174, -66, 80, 149, 244, 284, 413, 434, 473, 158, 56, -167, -326, -723,
+ 131, -11, 141, 32, 24, -122, -397, -610, -888, -812, 30, 232, 306, 371, 341, 446,
+ -158, -545, -529, 151, 142, -101, -426, -716, -1031, -1479, -1550, -352, -132, 145, 187, 517,
+ 148, -104, -445, -841, -31, 183, -86, -316, -615, -660, -231, 84, 192, 275, 201, 311,
+ -183, -220, -243, -182, -237, -176, -266, -233, -336, -339, -650, -1019, -1652, -846, -52, 387,
+ -104, -117, -254, -332, -191, 1, 64, 182, 317, 495, 626, 574, 519, 508, 456, 505,
+ -151, -237, 492, 479, 273, 139, 36, -60, -119, 74, 174, 188, 298, 366, 347, 478,
+ 158, 23, -210, -450, -673, -637, -423, -331, -133, 14, 128, 69, 62, 143, 171, 313,
+ 501, 394, 37, -57, 67, 70, 46, 35, 92, 120, 337, 258, 276, 283, 368, 500,
+ 42, -157, -398, -600, -742, -780, -781, -980, -1166, -1629, -968, -149, -99, 188, 209, 529,
+ -240, 190, 465, 543, 575, 565, 605, 596, 653, 599, 583, 279, 203, -51, -186, -589,
+ 316, 371, 417, 372, 293, 189, 230, 154, 184, 91, 94, -175, -198, -358, -454, -736,
+ 72, -159, -362, -499, -633, -690, -794, -739, -662, -456, -360, -338, -251, -6, 50, 346,
+ -202, -332, -428, -462, -508, -440, -552, -647, -885, -1217, -1733, -619, -162, 95, 202, 510,
+ -91, -391, -709, -884, -1012, -1001, -936, -714, -509, -198, 42, 99, 119, 261, 238, 496,
+ -370, 92, 476, 604, 681, 762, 826, 893, 934, 1001, 954, 783, 629, 590, 412, 467,
+ -193, -22, -28, 46, 214, 387, 502, 643, 728, 864, 859, 723, 581, 569, 435, 483,
+ 223, 291, 633, 508, 350, 141, -156, -476, -930, -1417, -1809, -764, -206, 77, 191, 515,
+ -475, -791, -417, 75, 201, 343, 408, 549, 612, 707, 686, 572, 463, 457, 321, 373,
+ 842, 716, 669, 593, 419, 423, 373, 321, 273, 280, 354, 217, 193, 232, 175, 294,
+ 116, -60, -144, -299, -421, -551, -732, -952, -1203, -1662, -1996, -537, -240, 55, 138, 486,
+ -323, -665, -686, -214, -201, -260, -373, -329, -333, -165, 66, 96, 175, 310, 291, 486,
+ -19, 43, 35, 40, 42, 55, 63, 101, 133, 194, 222, 152, 117, 145, 133, 213
+};
+
+
+const Word16 *const Quantizers_fx[] = {SVNB_SN1_fx, SVNB_SN2_fx, GETRNB_SN1_fx, GETRNB_SN2_fx, AUNB_SN1_fx,SVWB_SN1_fx, SVWB_SN2_fx, GETRWB_SN1_fx,
+ GETRWB_SN2_fx, AUWB_SN1_fx,/* U13, */
+ TRWB2_SN1_fx, TRWB2_SN2_fx, AUWB2_SN1_fx, CNG_SN1_fx
+ };
+const Word16 *const Quantizers_p_fx[] = {IAA_MA1_fx, UVD_MA1_fx, UVD_MA2_fx, UVWB_MA3_fx, GESVNB_AR1_fx, GESVNB_AR2_fx, GESVWB_AR1_fx, GESVWB_AR2_fx,
+ GEWB2_MA1_fx,GEWB_MA1_fx, AUWB2_MA1_fx
+ };
+
+/* Q1 */
+const Word16 sigma_MSLVQ_fx[][16] =
+{
+ {3},
+ {3},
+ {107, 113, 160, 185, 202, 211, 219, 222, 222, 217, 218, 270, 327, 176, 66, 43},
+ {125, 130, 182, 185, 191, 199, 204, 207, 205, 191, 179, 227, 305, 261, 95, 64},
+ {123, 123, 176, 197, 207, 218, 228, 235, 232, 218, 209, 272, 342, 216, 89, 68},
+ {219, 212, 255, 271, 273, 274, 260, 255, 250, 248, 249, 302, 328, 394, 85, 37},
+ {3},
+ {3},
+ {113, 134, 220, 253, 260, 275, 274, 287, 304, 323, 321, 325, 349, 350, 376, 332},
+ {158, 179, 242, 248, 246, 259, 257, 267, 278, 274, 276, 289, 309, 309, 312, 306},
+ {146, 146, 222, 256, 261, 278, 290, 302, 318, 313, 323, 352, 394, 407, 415, 399},
+ {217, 227, 287, 303, 316, 310, 296, 304, 303, 305, 317, 327, 355, 321, 305, 279},
+ {3},
+ {3},
+ {193, 216, 283, 320, 343, 359, 375, 408, 413, 445, 479, 489, 502, 466, 456, 479},
+ {230, 238, 312, 330, 334, 329, 339, 357, 353, 358, 391, 403, 441, 459, 379, 497},
+ {231, 277, 304, 322, 347, 353, 366, 372, 373, 397, 438, 451, 424, 413, 381, 447},
+ {264, 287, 364, 386, 384, 373, 382, 373, 393, 403, 448, 438, 403, 430, 401, 586},
+ {224, 298, 262, 264, 258, 244, 260, 283, 313, 295, 275, 279, 260, 286, 286, 399},
+ {411, 314, 301, 332, 335, 343, 356, 409, 430, 413, 363, 364, 338, 332, 315, 412},
+ {136, 269, 343, 367, 405, 430, 411, 421, 444, 466, 435, 423, 328, 247, 235, 240},
+ {178, 433, 305, 268, 258, 252, 253, 246, 250, 250, 245, 256, 242, 273, 300, 371},
+ {349, 334, 335, 341, 336, 331, 343, 425, 505, 722, 783, 655,1006, 862, 346, 248},
+ {315, 306, 323, 306, 300, 278, 276, 287, 380, 394, 327, 333, 339, 382, 370, 626},
+ {236, 250, 241, 231, 241, 245, 238, 221, 215, 190, 181, 178, 183, 428, 184, 55},
+ {113, 189, 360, 312, 332, 326, 296, 268, 272, 282, 320, 275, 219, 203, 179, 143},
+ {273, 255, 245, 237, 242, 236, 214, 217, 223, 260, 233, 193, 187, 183, 174, 163},
+ {111, 321, 275, 219, 213, 207, 202, 205, 205, 225, 239, 208, 192, 187, 168, 152},
+ {383, 326, 300, 287, 290, 292, 276, 251, 258, 291, 430, 521, 397, 305, 274, 269},
+ {152, 221, 271, 291, 344, 310, 308, 257, 252, 256, 339, 491, 499, 199, 179, 107},
+ {226, 237, 236, 239, 250, 238, 228, 223, 227, 241, 311, 312, 299, 313, 421, 360},
+ {221, 238, 214, 220, 246, 244, 232, 221, 210, 208, 200, 229, 368, 431, 106, 71},
+ {249, 259, 267, 283, 278, 275, 251, 237, 203, 209, 198, 279, 543, 509, 122, 90},
+ {192, 249, 256, 235, 231, 230, 213, 215, 210, 247, 284, 237, 214, 210, 199, 181},
+};
+
+/* An 16-by-19 matrix in Scale = 2.56f */
+const Word16 sigma_p_fx[][16] =
+{
+ {152, 164, 179, 170, 172, 176, 171, 169, 169, 174, 175, 216, 247, 304, 113, 110},
+ {131, 171, 178, 176, 174, 178, 178, 178, 135, 166, 167, 176, 183, 197, 199, 206},
+ {84, 89, 120, 142, 154, 175, 184, 186, 189, 181, 178, 198, 245, 190, 54, 28},
+ {138, 157, 200, 194, 189, 208, 207, 206, 214, 197, 186, 222, 311, 302, 103, 43},
+ {3},
+ {146, 165, 183, 194, 197, 202, 191, 190, 187, 186, 171, 189, 281, 311, 61, 34},
+ {142, 168, 184, 183, 187, 190, 187, 188, 189, 193, 200, 212, 231, 245, 169, 177},
+ {174, 164, 168, 197, 300, 372, 199, 59, 208, 208, 209, 218, 231, 246, 237, 232},
+ {91, 101, 147, 165, 174, 195, 207, 210, 218, 230, 230, 244, 268, 272, 269, 250},
+ {157, 192, 226, 210, 211, 228, 228, 241, 245, 246, 248, 263, 274, 275, 270, 251},
+ {3},
+ {131, 160, 183, 193, 202, 205, 203, 212, 212, 213, 217, 220, 229, 214, 203, 200},
+ {187, 221, 231, 229, 237, 232, 232, 236, 249, 259, 286, 284, 250, 238, 238, 296},
+ {3},
+ {140, 173, 241, 320, 314, 315, 304, 295, 329, 359, 369, 357, 388, 354, 359, 396},
+ {248, 300, 339, 344, 360, 350, 363, 361, 368, 391, 431, 433, 406, 400, 377, 467},
+ {3},
+ {141, 180, 213, 223, 232, 234, 242, 240, 250, 253, 268, 255, 245, 235, 227, 200},
+ {178, 205, 259, 258, 273, 285, 275, 289, 299, 300, 310, 320, 335, 329, 316, 269},
+};
+
+/* An 16-by-33 matrix in Scale = 32768.00f */
+const Word16 inv_sigma_MSLVQ_fx[][16] =
+{
+ {32767},
+ {32767},
+ {783, 746, 523, 453, 416, 397, 384, 378, 378, 386, 384, 310, 256, 477, 1273, 1935},
+ {670, 647, 461, 452, 440, 421, 412, 405, 410, 440, 468, 369, 275, 321, 883, 1305},
+ {679, 682, 477, 426, 405, 385, 368, 357, 362, 385, 401, 308, 245, 388, 942, 1231},
+ {383, 395, 329, 309, 307, 307, 322, 329, 335, 338, 337, 278, 256, 213, 989, 2243},
+ {32767},
+ {32767},
+ {740, 628, 382, 332, 322, 305, 306, 292, 276, 259, 261, 258, 240, 240, 223, 253},
+ {530, 469, 346, 338, 341, 323, 326, 314, 302, 306, 304, 290, 271, 272, 269, 274},
+ {576, 576, 378, 327, 322, 302, 289, 278, 264, 268, 259, 238, 213, 206, 202, 210},
+ {386, 370, 292, 277, 266, 271, 284, 276, 276, 275, 264, 257, 236, 262, 275, 300},
+ {32767},
+ {32767},
+ {435, 389, 296, 262, 244, 233, 223, 205, 203, 188, 175, 172, 167, 180, 184, 175},
+ {365, 352, 268, 254, 251, 255, 247, 235, 237, 234, 214, 208, 190, 183, 221, 169},
+ {363, 302, 276, 261, 241, 237, 229, 226, 225, 211, 191, 186, 198, 203, 220, 188},
+ {318, 292, 230, 218, 218, 225, 219, 225, 213, 208, 187, 192, 208, 195, 209, 143},
+ {374, 281, 320, 318, 325, 344, 322, 296, 268, 284, 305, 301, 322, 294, 293, 210},
+ {204, 267, 279, 253, 250, 245, 235, 205, 195, 203, 231, 231, 248, 252, 266, 204},
+ {616, 312, 245, 229, 207, 195, 204, 199, 189, 180, 193, 198, 256, 340, 356, 349},
+ {471, 194, 275, 313, 325, 333, 332, 342, 335, 336, 342, 328, 347, 307, 280, 226},
+ {241, 251, 250, 246, 250, 254, 245, 197, 166, 116, 107, 128, 83, 97, 242, 339},
+ {266, 274, 259, 274, 279, 302, 304, 292, 221, 213, 257, 252, 247, 219, 227, 134},
+ {355, 336, 348, 363, 348, 342, 353, 379, 391, 442, 462, 472, 458, 196, 456,1518},
+ {744, 443, 233, 269, 253, 257, 283, 313, 308, 298, 262, 305, 383, 413, 469, 585},
+ {308, 330, 343, 353, 347, 356, 392, 387, 376, 322, 359, 435, 448, 458, 482, 514},
+ {756, 261, 305, 384, 394, 406, 415, 409, 409, 372, 352, 403, 438, 448, 498, 552},
+ {219, 257, 280, 293, 289, 288, 304, 335, 325, 289, 195, 161, 211, 275, 306, 312},
+ {550, 380, 309, 288, 244, 271, 272, 326, 332, 328, 248, 171, 168, 421, 468, 781},
+ {371, 355, 356, 350, 336, 353, 368, 376, 369, 348, 269, 269, 281, 268, 199, 233},
+ {380, 353, 392, 381, 342, 344, 362, 379, 399, 403, 420, 367, 228, 195, 789,1184},
+ {337, 324, 314, 297, 301, 305, 335, 354, 414, 401, 425, 301, 154, 165, 690, 927},
+ {438, 337, 327, 357, 363, 365, 394, 390, 400, 340, 295, 354, 392, 399, 421, 462},
+};
+
+/* An 16-by-19 matrix in Scale = 32768.00f */
+const Word16 inv_sigma_p_fx[][16] =
+{
+ {552, 513, 469, 494, 486, 478, 492, 496, 496, 482, 480, 388, 339, 276, 743, 760},
+ {640, 492, 472, 478, 482, 471, 470, 471, 623, 504, 501, 477, 459, 425, 421, 408},
+ {1001, 939, 696, 589, 545, 480, 456, 451, 444, 462, 472, 424, 342, 441, 1567, 3002},
+ {609, 534, 419, 432, 444, 403, 406, 407, 391, 425, 452, 378, 269, 278, 818, 1939},
+ {32767},
+ {574, 507, 459, 432, 425, 415, 440, 442, 449, 450, 490, 443, 299, 270, 1377, 2451},
+ {591, 499, 456, 457, 449, 441, 448, 446, 443, 436, 420, 397, 364, 342, 496, 475},
+ {482, 512, 498, 426, 280, 225, 422, 1411, 404, 404, 402, 385, 364, 342, 355, 361},
+ {917, 831, 572, 507, 482, 430, 406, 399, 385, 365, 364, 344, 313, 309, 311, 335},
+ {533, 436, 371, 399, 398, 368, 367, 348, 343, 342, 338, 319, 306, 305, 311, 334},
+ {32767},
+ {641, 523, 458, 434, 415, 410, 412, 395, 397, 394, 386, 381, 366, 392, 413, 419},
+ {449, 380, 364, 366, 354, 362, 362, 356, 337, 323, 293, 296, 336, 352, 353, 283},
+ {32767},
+ {601, 485, 348, 262, 267, 266, 276, 285, 255, 233, 227, 235, 216, 237, 233, 212},
+ {338, 279, 247, 244, 233, 239, 231, 232, 228, 215, 194, 194, 207, 210, 222, 180},
+ {32767},
+ {594, 466, 394, 376, 362, 358, 346, 350, 336, 332, 313, 329, 343, 358, 370, 419},
+ {471, 409, 323, 325, 308, 295, 305, 290, 281, 280, 271, 262, 251, 255, 266, 312},
+};
+
+const Word16 CNG_details_codebook_fx[64][NUM_ENV_CNG]= /* Q6 */
+{
+ {443,547,613,547,510,471,540,479,586,535,565,611,532,500,462,551,498,463,446,484},
+ {600,499,472,537,633,654,641,646,674,677,687,693,693,690,688,700,693,696,640,571},
+ {529,537,501,582,537,474,505,491,521,545,561,591,566,609,570,608,636,655,649,524},
+ {648,690,689,684,693,599,668,714,663,675,524,519,726,658,673,696,654,715,708,668},
+ {623,630,660,656,686,688,637,666,630,555,470,468,464,445,502,583,615,545,605,592},
+ {659,668,669,625,662,700,700,693,702,702,688,677,654,584,525,492,446,477,634,615},
+ {634,648,656,552,520,557,662,659,572,617,691,683,684,666,673,695,682,698,680,623},
+ {756,743,734,709,730,757,746,722,484,552,779,688,686,610,616,749,758,694,745,729},
+ {549,568,556,625,683,619,609,667,663,684,709,649,691,668,594,511,525,617,542,684},
+ {550,467,533,760,739,692,773,756,743,770,765,791,779,784,775,792,759,577,642,553},
+ {658,674,656,651,670,582,593,520,467,470,522,589,600,596,587,631,652,679,645,669},
+ {788,765,787,797,785,799,787,786,780,692,641,550,501,513,726,747,670,687,734,773},
+ {641,654,668,673,665,682,689,684,697,665,664,593,544,494,458,537,622,650,635,635},
+ {706,753,762,716,748,762,788,792,785,788,799,777,782,766,760,710,704,503,519,735},
+ {748,775,784,635,717,504,539,640,764,778,681,721,791,786,787,780,780,770,774,781},
+ {752,516,624,780,713,753,569,548,770,784,749,740,690,755,776,748,744,730,767,698},
+ {453,471,516,517,561,653,659,616,629,608,682,698,679,681,645,587,594,522,499,469},
+ {617,534,506,615,782,792,754,771,740,787,791,776,782,787,793,788,775,778,651,736},
+ {661,593,490,495,491,495,554,656,658,611,628,660,680,677,698,678,673,699,687,679},
+ {798,793,786,795,799,772,771,696,624,557,507,545,724,757,747,770,780,785,793,784},
+ {703,695,703,714,697,701,697,631,598,498,475,451,503,611,648,664,664,683,679,688},
+ {744,672,659,762,785,745,757,761,761,767,722,757,761,737,699,471,582,770,724,756},
+ {775,746,535,680,541,513,697,723,743,744,769,741,741,738,769,772,779,743,714,724},
+ {767,771,697,756,766,752,710,477,602,783,746,766,692,708,783,782,761,778,787,785},
+ {483,588,700,665,665,640,650,717,699,707,692,698,700,692,668,650,609,610,540,484},
+ {507,618,788,766,754,692,709,785,788,770,793,785,799,784,767,776,789,759,761,495},
+ {709,712,706,678,661,604,503,480,653,664,664,639,621,675,695,689,704,681,711,709},
+ {788,740,770,768,771,776,732,749,739,764,714,492,544,783,714,708,717,559,739,768},
+ {758,771,789,779,777,799,791,785,779,779,752,675,718,510,501,600,727,750,752,758},
+ {759,765,676,658,774,767,737,749,769,784,778,738,755,769,788,756,473,530,777,725},
+ {669,665,721,653,499,774,780,781,767,561,690,747,722,779,757,727,764,745,770,736},
+ {731,768,745,775,783,782,715,741,786,673,766,777,764,730,773,769,774,781,778,764},
+ {557,505,545,604,660,672,604,596,580,612,587,556,546,597,530,494,437,480,546,555},
+ {560,588,510,495,606,720,718,742,756,755,767,774,776,778,772,772,776,776,754,592},
+ {680,644,620,612,516,477,471,499,502,598,664,588,656,682,689,671,668,672,682,692},
+ {757,778,781,799,775,750,799,758,789,774,489,579,799,739,774,723,686,788,787,778},
+ {705,685,654,680,672,680,657,579,574,619,639,518,482,545,665,587,540,599,606,651},
+ {729,767,767,773,783,778,793,773,784,779,757,768,686,654,679,564,483,549,490,522},
+ {725,693,715,588,522,629,721,647,697,684,614,725,708,674,715,729,717,725,689,738},
+ {797,783,795,797,782,757,636,624,508,517,703,750,746,757,772,771,774,790,779,799},
+ {556,591,652,692,728,712,698,688,704,718,728,717,713,693,716,558,490,540,620,678},
+ {532,617,777,775,763,789,768,785,778,791,792,792,793,777,781,724,551,665,540,509},
+ {710,697,706,717,673,679,620,581,546,474,562,684,680,675,660,656,702,680,701,708},
+ {771,793,788,787,794,791,792,783,791,792,733,770,532,525,692,761,777,753,734,728},
+ {724,695,678,652,695,735,697,712,714,721,696,710,569,581,570,522,642,704,748,726},
+ {796,754,785,782,732,814,803,794,799,790,810,806,794,797,756,745,749,506,741,779},
+ {793,767,785,780,724,648,488,747,784,771,793,740,759,805,794,796,795,795,801,806},
+ {787,508,640,775,722,792,774,705,781,801,774,800,786,806,808,783,795,797,784,782},
+ {654,649,601,597,594,667,646,662,615,623,651,671,669,674,682,653,624,484,473,665},
+ {790,765,479,527,746,728,770,753,721,774,794,802,789,782,803,795,764,804,779,776},
+ {738,699,642,509,515,501,466,614,702,612,683,720,687,717,704,739,714,733,721,718},
+ {778,795,791,786,758,783,783,743,744,527,554,789,762,767,722,722,777,788,776,782},
+ {694,696,700,696,709,710,696,689,674,662,581,538,496,637,644,681,679,671,689,704},
+ {776,788,742,796,779,756,788,789,782,798,795,804,771,753,571,611,504,545,593,779},
+ {799,717,747,682,487,573,766,774,775,762,711,802,799,796,790,787,802,789,773,786},
+ {795,797,790,804,788,791,774,706,532,770,786,743,789,708,755,785,804,803,807,770},
+ {568,722,738,680,713,703,693,749,703,705,740,720,712,631,621,727,730,722,574,612},
+ {626,762,734,770,759,750,792,775,790,792,788,786,791,767,782,778,794,745,504,544},
+ {774,784,779,753,654,560,530,532,555,699,742,695,716,767,770,772,778,780,779,782},
+ {781,781,790,783,792,798,787,792,765,740,701,537,564,773,767,756,786,797,789,801},
+ {738,717,799,794,772,784,774,790,788,748,789,769,768,763,504,587,783,751,784,732},
+ {776,789,763,772,800,786,802,787,805,799,776,773,792,761,750,702,532,745,807,735},
+ {765,778,764,484,607,791,757,760,700,687,789,777,779,783,768,791,778,757,784,770},
+ {800,825,775,782,821,679,805,824,752,824,796,785,829,817,824,803,814,807,762,779}
+};
+
+const Word16 interpol_frac_mid_fx[NB_SUBFR*3] = { 16384, 16384, 0,
+ 0, 32767, 0,
+ 0, 16384, 16384,
+ 0, 0, 32767
+ };
+
+const Word16 interpol_frac_mid_16k_fx[NB_SUBFR16k*3] = { 18022, 14746, 0,
+ 4915, 27853, 0,
+ 0, 24576, 8192,
+ 0, 11469, 21299,
+ 0, 0, 32767
+ };
+
+
+const Word16 pi0_fx[] = {28,1,70,8,8,28,168,28,1,280,28,56,8,56,420,56, 70, 56,420, 56, 280, 56, 168, 28, 560, 168,336,28,280,28,8
+ ,280,70, 8, 1120, 8, 8, 280, 168, 56, 420, 336, 840, 28, 168, 1, 168, 420, 168
+ };
+
+const Word16 pl_par_fx[] = /* 1 if even number of signs */
+{
+ 0, 1, 0, 0, -1, 0, 0, 1, 0, 0,
+ 0, -1, 1, 0, 0, 0, 1, -1, 0, 0,
+ 0, -1, 1, 0, 0, 0, 0, 1, -1, 1, -1, 0,
+ 0, 0, 0, 0, -1, 1, -1, 1, 0, 0, 0, 0, 0, 1, -1, 1, -1
+};
+const Word16 no_vals_fx[NO_LEADERS]= {2,1,2,2,2,2,3,2,1,3,2,2,2,3,3,3,2,3,3,2,3,2,3,2,3,3,4,2,3,2,2,3,2,2,4,2,2,3,3,3,3,4,4,2,3,1,3,3,3};
+
+const Word16 no_vals_ind_fx[NO_LEADERS][MAX_NO_VALS]=
+{
+ {2,6,0,0},
+ {8,0,0,0},
+ {4,4,0,0},
+ {1,7,0,0},
+ {1,7,0,0},
+ {6,2,0,0},
+ {1,2,5,0},
+ {2,6,0,0},
+ {8,0,0,0},
+ {1,4,3,0},
+ {2,6,0,0},
+ {3,5,0,0},
+ {1,7,0,0},
+ {1,6,1,0},
+ {2,2,4,0},
+ {1,1,6,0},
+ {4,4,0,0},
+ {1,1,6,0},
+ {2,4,2,0},
+ {3,5,0,0},
+ {1,3,4,0},
+ {5,3,0,0},
+ {1,2,5,0},
+ {2,6,0,0},
+ {3,2,3,0},
+ {1,5,2,0},
+ {1,1,1,5},
+ {6,2,0,0},
+ {1,3,4,0},
+ {2,6,0,0},
+ {1,7,0,0},
+ {3,4,1,0},
+ {4,4,0,0},
+ {1,7,0,0},
+ {1,1,3,3},
+ {1,7,0,0},
+ {7,1,0,0},
+ {1,4,3,0},
+ {2,1,5,0},
+ {1,1,6,0},
+ {4,2,2,0},
+ {1,1,5,1},
+ {1,2,1,4},
+ {2,6,0,0},
+ {1,2,5,0},
+ {8,0,0,0},
+ {1,5,2,0},
+ {2,2,4,0},
+ {1,2,5,0}
+};
+
+const Word16 C_VQ_fx[LATTICE_DIM+1][LATTICE_DIM+1]=
+{
+ {1,0,0,0,0,0,0,0,0},
+ {1,1,0,0,0,0,0,0,0},
+ {1,2,1,0,0,0,0,0,0},
+ {1,3,3,1,0,0,0,0,0},
+ {1,4,6,4,1,0,0,0,0},
+ {1,5,10,10,5,1,0,0,0},
+ {1,6,15,20,15,6,1,0,0},
+ {1,7,21,35,35,21,7,1,0},
+ {1,8,28,56,70,56,28,8,1}
+};
+
+const Word16 vals_fx[NO_LEADERS][MAX_NO_VALS]= /*Q1 */
+{
+ {2, 0, 0, 0},
+ {1, 0, 0, 0},
+ {2, 0, 0, 0},
+ {4, 0, 0, 0},
+ {3, 1, 0, 0},
+ {2, 0, 0, 0},
+ {4, 2, 0, 0},
+ {3, 1, 0, 0},
+ {2, 0, 0, 0},
+ {4, 2, 0, 0},
+ {4, 0, 0, 0},
+ {3, 1, 0, 0},
+ {5, 1, 0, 0},
+ {4, 2, 0, 0},
+ {4, 2, 0, 0},
+ {6, 2, 0, 0},
+ {3, 1, 0, 0},
+ {5, 3, 1, 0},
+ {4, 2, 0, 0},
+ {4, 0, 0, 0},
+ {6, 2, 0, 0},
+ {3, 1, 0, 0},
+ {5, 3, 1, 0},
+ {4, 2, 0, 0},
+ {4, 2, 0, 0},
+ {6, 2, 0, 0},
+ {6, 4, 2, 0},
+ {3, 1, 0, 0},
+ {5, 3, 1, 0},
+ {5, 1, 0, 0},
+ {7, 1, 0, 0},
+ {4, 2, 0, 0},
+ {4, 0, 0, 0},
+ {6, 2, 0, 0},
+ {6, 4, 2, 0},
+ {8, 0, 0, 0},
+ {3, 1, 0, 0},
+ {5, 3, 1, 0},
+ {5, 3, 1, 0},
+ {7, 3, 1, 0},
+ {4, 2, 0, 0},
+ {6, 4, 2, 0},
+ {6, 4, 2, 0},
+ {6, 0, 0, 0},
+ {8, 2, 0, 0},
+ {3, 0, 0, 0},
+ {5, 3, 1, 0},
+ {5, 3, 1, 0},
+ {7, 3, 1, 0},
+};
+
+/* An 6-by-128 matrix in Scale = 2048.00f */
+const Word16 scales_fx[][6] =
+{
+ {3129, 0, 0, 3138, 0, 0, }, /* 14 */
+ {3287, 0, 0, 3138, 0, 0, }, /* 15 */
+ {2611, 5034, 0, 3138, 0, 0, },
+ {2611, 5034, 0, 3340, 0, 0, },
+ {2165, 3674, 5931, 2363, 3809, 6281, },
+ {1898, 2986, 4745, 2116, 3668, 7045, }, /* 28 */ /* mode 0 UV WB*/
+ {2630, 5480, 0, 2972, 0, 0, },
+ {2802, 0, 0, 2869, 5073, 0, },
+ {1763, 2546, 3723, 2515, 4559, 21109, },
+ {2195, 3961, 7440, 2501, 6017, 21961, },
+ {1841, 2902, 1386, 2116, 3762, 22309, },
+ {1700, 2710, 1288, 1866, 3246, 20660, }, /* 32 */ /* mode 1 UV NB*/
+
+
+ {3222, 0, 0, 3391, 0, 0, },
+ {2537, 4923, 0, 3187, 0, 0, },
+ {2161, 3482, 9091, 3391, 0, 0, },
+ {2560, 4923, 8462, 2775, 4835, 0, },
+ {2163, 3656, 9263, 2699, 5296, 0, },
+ {2040, 3082, 6871, 2427, 3637, 5587, },
+ {1903, 2841, 6875, 2212, 3484, 5908, },
+ {1888, 3058, 6900, 2212, 3484, 5908, },
+ {1888, 3058, 6900, 2183, 3469, 6420, },
+ {1888, 3058, 6900, 1970, 3174, 8081, },
+ {1528, 2269, 5876, 1964, 3033, 8002, },
+ {1577, 2445, 5782, 1858, 2871, 4334, },
+
+ {1532, 2259, 5870, 2421, 1661, 6824, }, /* 34 */
+
+ {1386, 1972, 4356, 1487, 2216, 4514, }, /* 37 */ /* mode 2 V WB*/
+ {3357, 0, 0, 2494, 4426, 0, },
+ {2634, 5009, 0, 2888, 0, 0, },
+ {2224, 3539, 7696, 2494, 4426, 0, },
+ {2120, 3226, 9861, 2494, 4426, 0, },
+ {1974, 3140, 10121, 2494, 4426, 0, },
+ {1722, 2454, 4059, 2494, 4426, 0, },
+ {1839, 2658, 4473, 2490, 5456, 0, },
+ {1722, 2533, 4581, 2038, 3394, 5808, },
+
+ {1427, 2009, 4184, 1915, 3082, 1350, },
+ {1370, 1862, 2720, 2017, 1339, 3914, }, /* 37 */ /* mode 3 V NB */
+
+ {2482, 3885, 0, 0, 0, 0, },
+ {3346, 0, 0, 3418, 0, 0, },
+ {2638, 4962, 0, 3418, 0, 0, },
+ {2482, 3885, 0, 3418, 0, 0, },
+ {2218, 3617, 6502, 3418, 0, 0, },
+ {2124, 3295, 8659, 3418, 0, 0, },
+ {2243, 3398, 5562, 2693, 5132, 0, },
+ {1927, 2839, 4549, 2693, 5132, 0, },
+ {1860, 2675, 3893, 2703, 5372, 0, },
+ {2202, 3619, 1618, 2703, 5372, 0, },
+ {2093, 3135, 1554, 2273, 3594, 5313, },
+ {2202, 3619, 1618, 2238, 3895, 6173, },
+ {1829, 3015, 1382, 2259, 3625, 5820, },
+ {1864, 3170, 1403, 2114, 3381, 5147, },
+ {1692, 2572, 1294, 2009, 3158, 4540, }, /* 32 (31.995) */ /* G WB*/
+ {2425, 3707, 5655, 0, 0, 0, },
+ {3299, 0, 0, 3314, 0, 0, },
+ {2425, 3707, 5655, 3174, 0, 0, },
+ {2425, 3707, 5655, 3314, 0, 0, },
+ {2177, 3557, 6113, 3314, 0, 0, },
+ {2208, 3738, 6476, 3009, 4606, 0, },
+ {2816, 1874, 4264, 3009, 4606, 0, },
+ {1966, 2914, 1434, 2683, 4366, 0, },
+ {2302, 1626, 3895, 2628, 4714, 0, },
+ {2206, 3537, 1571, 2560, 3996, 6105, },
+ {1911, 3013, 1403, 2560, 3996, 6105, },
+ {1898, 3277, 1380, 2363, 3637, 5845, },
+ {2144, 1479, 3656, 2163, 3363, 5532, },
+ {1989, 1409, 3090, 2136, 3543, 6003, },
+ {1882, 1356, 2800, 2165, 3703, 6285, }, /* 32 (31.987) */ /* G NB*/
+ {3312, 0, 0, 3394, 0, 0, },
+ {2611, 4706, 0, 3201, 0, 0, },
+ {2679, 4821, 0, 2841, 0, 0, },
+ {2644, 4952, 0, 2775, 5003, 0, },
+ {2210, 3623, 6169, 2841, 0, 0, },
+ {2210, 3623, 6169, 2714, 5233, 0, },
+ {1837, 2744, 5333, 2191, 3459, 5175, },
+ {1837, 2744, 5333, 1923, 2978, 4266, },
+ {1853, 2718, 5323, 2271, 1591, 3492, },
+ {1561, 2255, 4831, 1923, 2978, 4266, },
+ {1626, 2511, 6513, 2271, 1591, 3492, }, /* 33 */
+ /* mode 6 T WB */
+ {3336, 0, 0, 2439, 4528, 0, },
+ {2615, 5237, 0, 2800, 0, 0, },
+ {2216, 3607, 8047, 2439, 4528, 0, },
+ {2085, 3144, 5751, 2439, 4528, 0, },
+ {1933, 3025, 5659, 2439, 4528, 0, },
+ {1864, 3572, 6793, 2439, 4528, 0, },
+ {1884, 3375, 6283, 1985, 3447, 8096, },
+ {1513, 2275, 5517, 1800, 2890, 4721, },
+ {1452, 2114, 5564, 1659, 2550, 3736, }, /* 32 */ /* mode 7 T NB */
+
+ {1552, 2286, 4022, 2497, 4139, 1634,},
+ {1432, 2118, 4051, 2497, 4139, 1634, }, /* 32 */ /* mode 8 G 16k */
+
+ {1487, 2150, 3779, 2775, 1761, 4516, },
+ {1386, 2042, 3418, 2775, 1761, 4516, }, /* 33 (32.983) */ /* T 16k */
+
+ {3371, 0, 0, 2568, 5036, 0, },
+ {2198, 3815, 6617, 3437, 0, 0, },
+ {2198, 3815, 6617, 2568, 5036, 0, },
+ {1948, 3056, 5112, 2570, 6085, 0, },
+ {2351, 3770, 1665, 2570, 6085, 0, }, /* 26 */
+ {1233, 1780, 2904, 2589, 1565, 4542, }, /* 36 */ /* mode 10 AUDIO_WB 36 + 4 + 1 */
+
+ {1747, 3623, 9062, 0, 0, 0, },
+ {2071, 3406, 9017, 3232, 0, 0, },
+ {2071, 3406, 9017, 2462, 4964, 0, },
+ {1804, 3314, 8471, 2462, 4964, 0, },
+ {1735, 3668, 9146, 2462, 4964, 0, }, /* 27 */ /* AUDIO_NB */
+ {1372, 2277, 4893, 2462, 4964, 0, }, /* 28 */ /* AUDIO_NB */
+ {2316, 3717, 1630, 2591, 5722, 0, },
+ {1167, 1647, 2451, 2380, 3992, 1491, }, /* 36 */ /* mode 12 AUDIO_WB 16k 15-36 + 4 + 1*/
+ {2140, 3248, 7688, 3418, 0, 0, },
+ {1802, 2621, 5784, 2251, 3553, 0, },
+ {1702, 2488, 5994, 2230, 3498, 5077, },
+ {1782, 2718, 5951, 2183, 3521, 5480, },
+
+ {1581, 2298, 4815, 2961, 1933, 4243, },
+
+ {1436, 2001, 3559, 1939, 2976, 4264, },
+
+ {1473, 2091, 3484, 2292, 1626, 3473, },
+
+ {1311, 1810, 3547, 1546, 2232, 3170, }, /* 37 (36.995) */ /* VOICED 16k */
+ {2494, 1630, 4676, 2642, 6810, 0, },
+ {3256, 1710, 9085, 2247, 6287, 0, },
+
+ {2036, 5360, 0, 2234, 4573, 7080, },
+ {1817, 3222, 7256, 2228, 3742, 6281, },
+ {1714, 2535, 3897, 2658, 5728, 0, },
+ {2331, 5788, 0, 2265, 5726, 8993, },
+ {1927, 3955, 9161, 1395, 2593, 4768, },
+ {2769, 8872, 0, 1679, 3164, 8550, },
+ {2750, 7387, 0, 1759, 2976, 5304, },
+ {2474, 5612, 0, 1554, 2540, 4469, },
+ {2300, 5603, 0, 1790, 3068, 5296, },
+ {1882, 5061, 0, 1260, 2195, 4293, },
+ {3170, 9232, 0, 1690, 4461, 8817, },
+ {2492, 5935, 0, 1509, 2492, 3953, },
+
+ {1999, 4485, 11706, 3084, 1315, 8624, },
+ {2267, 5315, 0, 2666, 1237, 1802}, /* CNG */
+
+};/* An 6-by-146 matrix in Scale = 2048.00f */
+const Word16 scales_p_fx[][6] =
+{
+ {2998, 4862, 0, 0, 0, 0, },
+ {2591, 5251, 0, 3355, 0, 0, },
+ {2177, 3488, 5745, 2650, 4819, 0, },
+ {2177, 3926, 6273, 2796, 0, 0, },
+ {1872, 2892, 4553, 2650, 4819, 0, },
+ {1806, 2869, 4919, 2689, 4999, 0, },
+ {2777, 1776, 4868, 2191, 3453, 5214, },
+ {1733, 2761, 5214, 2204, 3568, 5444, },
+ {1731, 2824, 5255, 2087, 3230, 5003, },
+ {1548, 2435, 5732, 2220, 3695, 5648, },
+ {1546, 2494, 5777, 1933, 2935, 4041, },
+ {1483, 2529, 6025, 2570, 1737, 4096, },
+ {1407, 2279, 4788, 1747, 2720, 3981, },
+ {1327, 2107, 3760, 1749, 2777, 4016, },
+ {1327, 2107, 3760, 1407, 2167, 3891, }, /* 39 (38.488) */ /* V WB*/ /* 14 */
+ {3303, 0, 0, 0, 0, 0, },
+ {2595, 5069, 0, 3316, 0, 0, },
+ {2077, 3338, 5046, 2632, 4405, 0, },
+ {1829, 2847, 4739, 3000, 4708, 0, },
+ {1905, 2869, 4403, 2621, 4616, 0, },
+ {1829, 2847, 4739, 2613, 4518, 6111, },
+ {1829, 2847, 4739, 2122, 3371, 5061, },
+ {1755, 2738, 5046, 2136, 3543, 5376, },
+ {1567, 2497, 3181, 2122, 3371, 5061, },
+ {1616, 2720, 3383, 2154, 3654, 5542, },
+ {1565, 2507, 3185, 1884, 2955, 4168, },
+ {1358, 2173, 2535, 2824, 1839, 3996, },
+ {1378, 2261, 2675, 2578, 1696, 4002, },
+ {1364, 2193, 2558, 1645, 2542, 3541, },
+ {1348, 2128, 2486, 1946, 1333, 2927, }, /* 39 (38.512) */ /* V NB*/ /* 29 */
+ {3277, 0, 0, 3181, 0, 0, },
+ {2322, 4067, 6748, 3181, 0, 0, },
+ {2021, 3662, 5446, 3373, 0, 0, },
+ {1841, 3281, 5282, 3373, 0, 0, },
+ {1632, 2650, 4383, 3373, 0, 0, },
+ {1632, 2650, 4383, 2734, 4557, 0, },
+ {1518, 2357, 3719, 2734, 4557, 0, },
+ {1632, 2650, 4383, 2429, 3957, 0, },
+ {1518, 2357, 3719, 2384, 3734, 5671, },
+ {1450, 2306, 4000, 2204, 3543, 5687, },
+ {1352, 2148, 3217, 2204, 3543, 5687, },
+ {1356, 2101, 3183, 2200, 3918, 6189, },
+ {1352, 2148, 3217, 2947, 1896, 4364, },
+ {1290, 1978, 3117, 2687, 1804, 4520, },
+ {1264, 1886, 2963, 2114, 3172, 1548, }, /* 35 (34.994) */ /* G WB*/ /* 44 */
+ {3267, 0, 0, 3076, 0, 0, },
+ {2300, 3985, 7643, 3076, 0, 0, },
+ {2116, 4250, 8886, 2906, 5009, 0, },
+ {2017, 3672, 12216, 2623, 4760, 0, },
+ {1804, 3289, 14326, 2906, 5009, 0, },
+ {1729, 3240, 14377, 2623, 4760, 0, },
+ {1616, 3113, 14752, 2623, 4760, 0, },
+ {1780, 3168, 14326, 2109, 3592, 6353, },
+ {1673, 3056, 14582, 2109, 3592, 6353, },
+ {1546, 2830, 14608, 2109, 3592, 6353, },
+ {1446, 2693, 14797, 2109, 3592, 6353, },
+ {1411, 2654, 14930, 2081, 3840, 6633, },
+ {1430, 2611, 14764, 1872, 3170, 4983, },
+ {1391, 2693, 14930, 2517, 3779, 1665, },
+ {1391, 2693, 14930, 2433, 1581, 4004, }, /* 35 (34.952) */ /* G NB*/ /* 59 */
+
+ {2070, 3639, 5652, 3305, 0,0,},
+ {1747, 2830, 4231, 2550, 5487, 0,},
+ {2472, 1593, 4522, 2550, 5487, 0,},
+ {2472, 1593, 4522, 2075, 3752, 6253},
+ {2472, 1593, 4522, 2908, 1786, 4772,},
+ {1075, 1577, 2198, 1669, 2533, 1161}, /* 40 (39.990) */ /* AUDIO_WB */ /* 65 */
+
+ {2191, 3668, 7993, 3275, 0, 0, },
+ {1679, 2492, 4278, 2570, 4690, 0, },
+ {1597, 2394, 5110, 2570, 4690, 0, },
+ {2202, 1481, 4835, 2273, 4016, 7150, },
+
+ {1415, 2107, 4786, 2118, 3668, 8200, }, /* 31 */ /*AUDIO_NB */ /* 70 */
+ {1374, 2204, 5337, 1956, 3168, 5149, }, /* 32 */ /*AUDIO_NB */ /* 71 */
+ {2425, 4336, 1589,3420, 2165, 1380, },
+ {1067, 1530, 2116, 1630, 2730, 1110,}, /* 40 */ /* mode AUDIO_WB 16k */ /* 73*/
+
+ {3439, 0, 0, 2626, 5061, 0, },
+ {2228, 3787, 6543, 3455, 0, 0, },
+ {2228, 3787, 6543, 2626, 5061, 0, },
+ {2306, 3459, 1618, 2626, 5061, 0, },
+ {1905, 2830, 1397, 2626, 5061, 0, },
+ {2284, 1626, 3793, 2623, 6212, 0, },
+ {1720, 2818, 1276, 1638, 2900, 8724, }, /* 36 (35.998) */ /* INACTIVE NB */
+ {1640, 2351, 3690, 0, 0, 0, },
+ {2230, 3711, 6496, 3434, 0, 0, },
+ {2230, 3899, 6597, 3115, 5396, 0, },
+ {1731, 2482, 3961, 2689, 4954, 0, },
+ {1595, 2243, 3482, 2689, 4954, 0, },
+ {1481, 2079, 3408, 2689, 4954, 0, },
+ {1829, 1335, 2945, 2204, 1475, 3674, }, /* 36 (35.929) */ /* INACTIVE WB*/
+ {2783, 4723, 0, 3418, 0, 0, },
+ {2206, 3946, 7262, 3418, 0, 0, },
+ {2206, 4162, 7328, 2927, 5552, 0, },
+ {1706, 2566, 4311, 2628, 5235, 0, },
+ {1589, 2359, 3805, 2628, 5235, 0, },
+ {1473, 2183, 3547, 2628, 5235, 0, },
+ {1927, 1333, 3205, 1479, 2437, 3973, }, /* 36 (35.915) */ /* INACTIVE 16k*/
+
+ {2646, 5077, 0, 3156, 0, 0, },
+ {2462, 3897, 0, 3156, 0, 0, },
+ {2105, 3361, 5028, 3375, 0, 0, },
+ {2554, 1798, 4770, 3375, 0, 0, },
+ {1767, 2781, 5165, 3375, 0, 0, },
+ {1673, 2503, 4116, 2200, 3656, 5597, },
+ {1669, 1253, 2623, 2161, 3531, 6046, }, /* 32 (31.990) */ /* UNVOICED NB*/
+
+ {3164, 0, 0, 3170, 0, 0, },
+ {3359, 0, 0, 3170, 0, 0, },
+ {2636, 5630, 0, 3170, 0, 0, },
+ {2636, 5630, 0, 3387, 0, 0, },
+ {2437, 4149, 0, 3387, 0, 0, },
+ {1907, 2986, 5018, 2650, 5616, 0, },
+ {1796, 2859, 5605, 2214, 3719, 6881, }, /* 28 (27.996) */ /* UNVOICED WB */
+ {2316, 3351, 0, 2808, 0, 0, },
+ {1913, 2615, 1491, 2370, 3475, 0, },
+ {1706, 2380, 1348, 2357, 3455, 0, },
+ {1538, 2114, 1225, 2357, 3455, 0, },
+ {1452, 2058, 1167, 2171, 3629, 5569, },
+ {1528, 2050, 1231, 2056, 3693, 5923, },
+ {1522, 2048, 1227, 1917, 3811, 5886, },
+ {1587, 1257, 2124, 1630, 2671, 3901, }, /* 39 (38.301) */ /* VOICED 16k */
+ {1831, 2742, 5220, 2679, 5327, 0, },
+ {1475, 2073, 3273, 3097, 1896, 4377, },
+ {1395, 1993, 3377, 2828, 1794, 4360, },
+ {1401, 1974, 3359, 2392, 3637, 1612, },
+ {1368, 1915, 3176, 2081, 3109, 1458, },
+ {1350, 1866, 2918, 2738, 1821, 1315, },
+ {1350, 1866, 2918, 1718, 2636, 1243, }, /* 37 (36.989) */ /* GENERIC 16k*/
+ {3344, 0, 0, 3455, 0, 0, },
+ {2204, 3666, 6025, 3455, 0, 0, },
+ {1708, 2517, 3871, 3455, 0, 0, },
+ {1921, 2875, 4409, 2675, 5386, 0, },
+ {2744, 1815, 4751, 2675, 5386, 0, },
+ {1706, 2560, 3908, 2675, 5386, 0, },
+ {1706, 2484, 3836, 2304, 3766, 5773, },
+ {1567, 2380, 3461, 2097, 3559, 5812, },
+ {1485, 2150, 3668, 3031, 1888, 6357, },
+ {1458, 2073, 3172, 3060, 1849, 6889, },
+ {1350, 1898, 2779, 3060, 1849, 6889, },
+ {1683, 1257, 2638, 1864, 3090, 4618, },
+ {1722, 1278, 2617, 2378, 1561, 3703, },
+ {1716, 1274, 2593, 2212, 1456, 3502, },
+ {1704, 1268, 2611, 1921, 2929, 1319, }, /* 37 (36.971) */ /* GENERIC 12.8k MA*/
+ {1810, 2763, 5263, 2691, 5343, 0, },
+ {1456, 2085, 3308, 3035, 1886, 7027, },
+
+ {1391, 1995, 3398, 1942, 3172, 7062, },
+
+ {1702, 1266, 3033, 1911, 3101, 4731, },
+ {1671, 1249, 2871, 2920, 1796, 4639, },
+ {1612, 2574, 1221, 1759, 2963, 4979, },
+ {1612, 2574, 1221, 2265, 1505, 3398}, /* 37 (36.993) */ /* AUDIO 16k */
+
+};
+
+
+
+/*-----------------------------------------------------------------*
+ * BC-TCVQ frame-end quantization tables (BC-TCVQ is used in Voiced mode for 16kHz isf)
+ *-----------------------------------------------------------------*/
+const Word16 NTRANS[4][NUM_STATE] = {{0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14}, /* indices of previous state of first branche */
+ {1,3,5,7,9,11,13,15,1,3,5,7,9,11,13,15}, /* indices of previous state of second branches */
+ {4,2,1,3,0,2,1,3,2,0,3,1,7,0,3,1}, /* indices of previous subset of first branch */
+ {2,0,3,6,2,0,3,1,0,2,1,3,0,2,1,5} /* indices of previous subset of second branch */
+};
+
+const Word16 NTRANS2[4][NUM_STATE] = {{0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7},
+ {8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15},
+ {4,2,2,0,1,3,3,6,0,2,2,0,1,3,3,1},
+ {2,0,0,2,3,1,1,3,7,0,0,2,3,1,1,5}
+};
+
+/* BC-TCQ Bit Allocations */
+const Word16 BC_TCVQ_BIT_ALLOC_40B[M/2+4] = {1, 4, 5,5,4,4, 2,2,2,2, 5,4 }; /*1+39bit*/
+
+const Word16 FixBranch_tbl[4][4][N_STAGE_VQ - 4] =
+{
+ {{0, 0, 0, 0}, {1, 0, 0, 0}, {0, 1, 0, 0}, {1, 1, 0, 0}}, /* incase of initial state 0 */
+ {{0, 0, 1, 0}, {1, 0, 1, 0}, {0, 1, 1, 0}, {1, 1, 1, 0}}, /* incase of initial state 4 */
+ {{0, 0, 0, 1}, {1, 0, 0, 1}, {0, 1, 0, 1}, {1, 1, 0, 1}}, /* incase of initial state 8 */
+ {{0, 0, 1, 1}, {1, 0, 1, 1}, {0, 1, 1, 1}, {1, 1, 1, 1}} /* incase of initial state 12 */
+};
+
+const Word16 AR_IntraCoeff_fx[N_STAGE_VQ-1][2][2] = /* Q15 */
+{
+ {{-9584, 22162}, {-13849, 7127}},
+ {{ 1604, 16400}, { 2861, 9414}},
+ {{ 6537, 16475}, { 3498, 13792}},
+ {{ 7879, 14434}, { 7021, 12992}},
+ {{ 6329, 16215}, { 5200, 10052}},
+ {{ 3062, 12146}, { 2147, 4857}},
+ {{ 1226, 11040}, { -794, 6137}}
+};
+const Word16 SN_IntraCoeff_fx[N_STAGE_VQ-1][2][2] = /* Q15 */
+{
+ {{-14822, 26501}, {-17180, 10012}},
+ {{ 317, 19858}, { -432, 13799}},
+ {{ 4747, 22069}, { 2653, 19016}},
+ {{ 6823, 20747}, { 7077, 19154}},
+ {{ 1665, 25161}, { 2519, 13654}},
+ {{ 166, 18043}, { -221, 9732}},
+ {{ -781, 20026}, { -5332, 18882}}
+};
+const Word16 scale_ARSN_fx[M] = /* Q14 */
+{
+ 29994, 30153, 29506, 28534, 28246, 28618, 26388, 27029,
+ 25726, 25474, 25797, 26540, 25613, 24968, 25880, 25584
+};
+const Word16 scale_inv_ARSN_fx[M] = /* Q15 */
+{
+ 17898, 17806, 18196, 18815, 19005, 18760, 20342, 19864,
+ 20870, 21076, 20811, 20228, 20962, 21502, 20745, 20985
+};
+const Word16 AR_TCVQ_CB_SUB1_fx[2][128][2] = /* x2.65 */
+{
+ {
+ {-435 , -434}, {-233 , 124}, {-381 , 44}, {-274 , -88}, {-332 , -224}, {-563 , -600}, {-332 , 134}, { 53 , -739},
+ {-567 , 0}, { 149 , 316}, {-191 , 541}, {-123 , 317}, {-493 , -634}, {-528 , 268}, {-321 , -386}, {-432 , -220},
+ {-244 , -230}, { -33 , 454}, {-188 , -642}, {-131 , -215}, {-676 , 263}, {-472 , -403}, {-312 , -159}, {-340 , 297},
+ {-121 , -217}, { -6 , 241}, {-203 , -211}, {-126 , -15}, {-734 , -374}, {-458 , -6}, {-297 , -27}, {-307 , -553},
+ {-177 , 3}, {-175 , -273}, { 63 , 363}, { 133 , 527}, {-133 , -185}, {-449 , -1206}, {-287 , -281}, {-131 , 869},
+ {-100 , -105}, { -75 , -179}, {-141 , 131}, { -32 , 108}, { -81 , 161}, {-446 , -230}, {-283 , -884}, {-128 , -165},
+ {-153 , -451}, {-177 , -114}, {-113 , -127}, {-223 , -355}, {-246 , -447}, {-396 , -705}, {-280 , 329}, { -37 , -64},
+ {-118 , 208}, { -82 , 64}, {-339 , -367}, { -58 , -132}, {-458 , 644}, {-381 , -543}, {-272 , 557}, { 62 , 75},
+ {-307 , -829}, { 310 , 445}, { 73 , -26}, { 95 , 219}, { 223 , 611}, { 279 , 195}, { 430 , 575}, { 424 , 221},
+ { -25 , 2}, { 323 , 236}, {-100 , -310}, { 11 , -35}, { 83 , -3}, { 281 , 738}, { 495 , 393}, { 89 , 1284},
+ { 32 , 136}, { 29 , 34}, { 491 , 575}, { 105 , -188}, { 15 , -440}, { 285 , 10}, { 516 , -105}, { 313 , 704},
+ { -6 , -274}, { -62 , -64}, { -12 , -127}, { 170 , 2387}, { 162 , 196}, { 336 , 413}, { 543 , 210}, { 231 , -70},
+ { -2 , 691}, { 98 , 134}, { 25 , 141}, { 261 , 305}, { 312 , -322}, { 336 , 228}, { 561 , 781}, { 766 , 514},
+ { -14 , -117}, { 166 , 905}, { -50 , 1}, { 471 , 369}, { 345 , 247}, { 347 , -383}, { 561 , 1128}, { 513 , 1030},
+ { 100 , -15}, { 185 , 70}, { 167 , 131}, { 122 , 36}, { 561 , 743}, { 401 , 111}, { 595 , -579}, { 674 , 215},
+ { 191 , 189}, { 38 , -78}, { 428 , 0}, { 261 , 136}, { -29 , -99}, { 405 , 308}, { 614 , 574}, {1682 , 1704}
+ },
+ {
+ {-942 , -168}, {-262 , -361}, { -53 , -171}, {-245 , 472}, {-2145 , -2315}, {-1307 , 1261}, {-870 , -1940}, { -652 , -564},
+ {-500 , 447}, {-578 , -198}, {-554 , 111}, { -98 , -84}, {-1315 , 0}, {-1229 , -1618}, {-868 , 230}, { -385 , 1061},
+ {-768 , -998}, {-202 , -60}, {-283 , -197}, {-142 , -325}, { -558 , 755}, {-1217 , 456}, {-803 , 766}, { -982 , 743},
+ {-415 , -357}, { -28 , 1054}, { 114 , -246}, { 81 , 732}, { -804 , -506}, {-1126 , -112}, {-797 , -132}, { -289 , -204},
+ {-347 , -29}, { -37 , -259}, {-142 , -438}, {-249 , 87}, { -874 , 341}, {-1074 , -2635}, {-668 , -1552}, {-1140 , -764},
+ {-245 , -513}, { -48 , 526}, { 14 , 395}, {-452 , -646}, { -441 , -969}, { -953 , -1284}, {-645 , -387}, { -736 , 111},
+ {-163 , 305}, {-349 , 224}, {-225 , 736}, { 94 , -85}, { -302 , -549}, { -937 , -892}, {-605 , -1089}, { -64 , -101},
+ {-161 , -211}, {-392 , -1299}, {-148 , 125}, { 14 , 131}, { -432 , -127}, { -920 , -510}, {-598 , -730}, { 85 , 154},
+ { 25 , -155}, { -57 , 238}, { 471 , 276}, { 421 , 680}, { -173 , 316}, { 597 , 1805}, { 906 , -673}, { 538 , 450},
+ {-267 , -805}, { 2 , -19}, { 222 , 219}, { 185 , 352}, { -33 , -178}, { 606 , 118}, { 959 , -70}, { 350 , -91},
+ { -87 , 42}, { 727 , 905}, { 54 , 33}, { 316 , 44}, { 251 , 15}, { 610 , -122}, { 990 , 1436}, { 82 , 1480},
+ { 181 , 535}, { 177 , 130}, { 700 , 565}, { 626 , 331}, { 279 , 551}, { 680 , 707}, {1012 , 727}, { 1057 , 766},
+ { -13 , -396}, { 364 , 412}, { 442 , -181}, { 202 , -386}, { 565 , 1397}, { 740 , 2621}, {1080 , 361}, { 1118 , 191},
+ { 81 , 266}, { 217 , -130}, { 349 , 1009}, { 678 , -476}, { 1361 , 878}, { 795 , 472}, {1267 , 1034}, { 1040 , 1255},
+ { 351 , 201}, { -69 , -633}, { -36 , -1046}, { 808 , 30}, { 1300 , -198}, { 803 , 1026}, {1390 , -326}, { 2291 , 2479},
+ { 166 , 13}, { 521 , 84}, { 255 , -717}, { 987 , 448}, { 777 , 220}, { 811 , 208}, {1395 , 2021}, { 1499 , 417}
+ }
+};
+const Word16 AR_TCVQ_CB_SUB2_fx[2][64][2] =
+{
+ {
+ {-357 , -53}, {-525 , 167}, {-232 , 255}, {-132 , -359}, {-940 , -221}, { -260 , -1296}, {-1197 , -455}, { -833 , 49},
+ {-132 , -1}, {-401 , -280}, {-212 , -217}, {-194 , 92}, {-580 , -710}, { -862 , -750}, { -669 , 430}, { -521 , 719},
+ {-620 , -454}, {-239 , 509}, { -15 , -575}, { 389 , 704}, {-890 , 518}, {-1154 , 84}, { -632 , -1023}, { -620 , -1263},
+ {-268 , -470}, {-326 , -738}, { 44 , 635}, { 73 , 362}, {-226 , -22}, { -625 , -106}, { -720 , -114}, {-1114 , -1070},
+ { 19 , -250}, { 83 , 99}, { 35 , -16}, { 263 , -316}, { 472 , 1096}, { -52 , -328}, { -249 , 971}, { 1387 , 876},
+ { 10 , 203}, { 869 , 649}, { 225 , 170}, { 301 , 83}, {1256 , 482}, { 391 , -777}, { 1064 , -320}, { 52 , 1207},
+ { 309 , 375}, { 469 , 226}, { 619 , 400}, { 60 , -93}, { 335 , 244}, { 316 , -65}, { -45 , -987}, { 648 , -294},
+ { 218 , -66}, {-108 , -133}, { 500 , -19}, { 824 , 163}, { 483 , -443}, { 1297 , 240}, { 1000 , 1205}, { 623 , 1347}
+ },
+ {
+ {-424 , -965}, { -46 , -194}, { 20 , 298}, {-333 , -278}, {-797 , -522}, {-868 , -60}, { -20 , -140}, {-1085 , -904},
+ {-615 , -243}, {-367 , 22}, {-261 , -519}, {-111 , -27}, {-745 , 142}, {-484 , -1519}, { -329 , 13}, {-1077 , 92},
+ {-529 , 218}, {-519 , -597}, {-276 , -72}, { -87 , -398}, { -51 , -1257}, {-291 , 409}, { -883 , 611}, { 176 , -401},
+ {-134 , -245}, { 37 , 506}, { 23 , -10}, {-225 , 293}, {-913 , -1324}, {-174 , -290}, {-1086 , -386}, { -139 , -78},
+ {-123 , 125}, { -26 , -738}, { 113 , -344}, { 175 , 182}, { 754 , -446}, {1207 , 529}, { 932 , 990}, { 136 , 122},
+ { 267 , 327}, { 382 , -182}, { 718 , 471}, { 738 , 108}, { 158 , 130}, { 437 , 401}, { 358 , -667}, { 1380 , 836},
+ { 184 , -17}, { 435 , 231}, { 403 , 63}, { 151 , -125}, {-109 , -237}, { 692 , -241}, { 1247 , 193}, { 885 , 324},
+ {-283 , 661}, { 44 , 105}, { 156 , 911}, { 387 , 588}, { 690 , 1459}, { 664 , 1057}, { -38 , 1455}, { 645 , 909}
+ }
+};
+const Word16 AR_TCVQ_CB_SUB3_fx[4][32][2] =
+{
+ {
+ {-487 , 9}, {-456 , -400}, { 96 , 451}, {-239 , 422}, {-685 , -1309}, { 68 , -709}, {-302 , -1185}, { 481 , -287},
+ {-287 , -697}, {-194 , 73}, {-159 , -132}, {-161 , -312}, {-809 , 417}, {-860 , -926}, { -26 , -71}, {-1052 , -432},
+ { 53 , 134}, { 106 , -140}, { 336 , -18}, { 404 , 735}, {-109 , -516}, { 719 , -65}, { -34 , 1336}, { -171 , 905},
+ { 52 , -347}, { 359 , 266}, { 715 , 351}, { 100 , 133}, { 87 , 130}, { 975 , 999}, {1257 , 547}, { 738 , 1372}
+ },
+ {
+ {-340 , -464}, {-216 , -779}, { 104 , -403}, { -92 , -221}, {-760 , -602}, {-914 , -811}, {-661 , -895}, {-1292 , -290},
+ {-317 , 131}, {-575 , -154}, {-228 , -129}, {-257 , 487}, {-286 , -1354}, { -93 , -259}, {-798 , 179}, { -815 , -1368},
+ { 215 , 570}, { -2 , 73}, { 545 , 167}, { 250 , 188}, { 76 , 48}, {-943 , 587}, { 379 , 1232}, { 1070 , 112},
+ { 117 , -27}, { 389 , -142}, { 18 , 214}, { 735 , 581}, {1098 , 1244}, { 451 , 408}, {1482 , 650}, { -174 , 1160}
+ },
+ {
+ {-256 , -485}, { -67 , 571}, { -5 , 161}, {-171 , 153}, {-1188 , -440}, {-1081 , 110}, {-641 , -921}, {-232 , -96},
+ {-511 , 146}, {-288 , -93}, { 484 , 665}, {-610 , -366}, { -357 , -899}, { -861 , -1088}, { -78 , -105}, {-265 , -845},
+ { 15 , 18}, { 79 , -383}, {-205 , -258}, { 306 , 264}, { 28 , 69}, { 34 , 65}, {1170 , 669}, { 133 , 74},
+ { 521 , 183}, { 132 , 84}, { 362 , -90}, { 57 , -181}, { 894 , 456}, { 1147 , 742}, { 212 , 274}, { 891 , 262}
+ },
+ {
+ { 94 , 464}, { 8 , 138}, {-365 , -640}, {-399 , 172}, {-249 , -109}, { -94 , -316}, {-163 , -250}, {-598 , -704},
+ {-185 , 36}, {-470 , -199}, { 65 , 241}, {-104 , -362}, {-220 , -801}, {-866 , -66}, {-931 , -400}, {-172 , -132},
+ {-148 , -494}, { 465 , 251}, {-179 , -72}, { 439 , 287}, { 824 , 559}, { 33 , 134}, { 59 , 134}, { 88 , 146},
+ { 186 , 43}, { 69 , -261}, { 267 , -96}, { 40 , 79}, { 84 , 130}, { 678 , 378}, { 811 , 448}, { 920 , 541}
+ }
+};
+const Word16 SN_TCVQ_CB_SUB1_fx[2][128][2] =
+{
+ {
+ {-639 , 105}, {-488 , -449}, {-530 , -811}, {-419 , -634}, {-781 , -1061}, {-585 , 386}, {-501 , -737}, {-489 , -728},
+ {-702 , -685}, {-510 , -762}, {-390 , -287}, {-379 , -379}, {-573 , -848}, {-583 , -778}, {-500 , -810}, {-671 , -420},
+ {-516 , 802}, {-265 , -492}, {-523 , -568}, {-195 , 2882}, {-600 , -172}, {-568 , -869}, {-497 , 663}, {-643 , -929},
+ {-346 , -378}, {-253 , -313}, {-418 , 595}, {-240 , -465}, {-424 , -546}, {-556 , -305}, {-497 , 2453}, {-451 , -235},
+ {-452 , -670}, {-368 , -624}, {-379 , -662}, {-305 , -85}, {-549 , 399}, {-546 , -644}, {-484 , -426}, {-387 , -546},
+ {-325 , -550}, {-229 , 118}, { -83 , 1004}, {-120 , 465}, {-289 , -222}, {-516 , 155}, {-480 , 1494}, {-415 , 138},
+ {-419 , -100}, {-347 , 1091}, {-434 , 76}, {-138 , -291}, {-434 , -719}, {-514 , 945}, {-473 , -26}, {-144 , -320},
+ {-376 , 1505}, {-329 , 374}, {-316 , -504}, { -58 , -6}, {-270 , -466}, {-507 , -540}, {-466 , -181}, {-256 , -518},
+ {-196 , 726}, { -88 , -356}, {-186 , -394}, { 31 , -201}, { -77 , -319}, { 408 , 136}, { 630 , 680}, { 875 , 1365},
+ {-200 , -190}, { 166 , 1289}, { 600 , 1085}, { 276 , 464}, { 567 , 1575}, { 425 , 278}, { 666 , 377}, {1209 , 2344},
+ {-182 , -409}, { -95 , -141}, { 65 , 507}, { 127 , 212}, { 340 , 235}, { 481 , 408}, { 721 , 1203}, {1112 , 756},
+ { 162 , 362}, { 138 , 753}, {-169 , -128}, { 187 , -32}, { 68 , -93}, { 528 , 2866}, { 786 , 789}, {1247 , 1468},
+ {-476 , 2428}, { 20 , 133}, { 2 , -236}, { 426 , 799}, { 393 , 590}, { 532 , 1562}, { 807 , 534}, {1410 , 1051},
+ { -14 , -263}, { 83 , -158}, { 158 , -38}, { 616 , 550}, { 845 , 543}, { 536 , 238}, { 912 , 1521}, {1635 , 1344},
+ { 115 , -55}, { 263 , 87}, {-126 , 234}, { 376 , 191}, { 459 , 2644}, { 542 , 927}, { 941 , 948}, {1896 , 1528},
+ { -19 , 1853}, { 455 , 366}, { 545 , 283}, { 831 , 835}, {1217 , 846}, { 560 , 542}, {1013 , 650}, {1905 , 2343}
+ },
+ {
+ {-528 , -246}, {-631 , 56}, {-717 , -277}, { -40 , 1327}, {-1011 , -688}, {-827 , -341}, {-656 , -1599}, { -992 , -1559},
+ {-450 , 933}, {-540 , 2109}, {-598 , -1267}, {-387 , -512}, {-1100 , -1979}, {-812 , -617}, {-649 , -147}, { -874 , 586},
+ {-720 , - 601}, {-281 , -279}, {-578 , 635}, { 169 , 80}, {-1020 , -134}, {-794 , 259}, {-638 , 821}, { -907 , 42},
+ {-709 , -1525}, {-482 , 1340}, {-232 , -979}, { 104 , 2314}, { -918 , -1179}, {-790 , 1284}, {-609 , 2259}, { -854 , -978},
+ {-624 , 326}, {-194 , 1705}, { -88 , 1060}, { 383 , 1190}, { -415 , 15}, {-789 , -1145}, {-604 , 407}, { -869 , 1136},
+ {-503 , -1047}, {-545 , -794}, {-128 , 471}, { 84 , 638}, { -591 , -1509}, {-699 , 1746}, {-600 , -369}, { -784 , 1642},
+ {-221 , -668}, {-223 , 261}, { -82 , -446}, {-378 , -1215}, { -741 , 969}, {-689 , -863}, {-569 , -595}, {-1012 , -403},
+ {-331 , 518}, {-175 , 787}, {-220 , -3}, { -46 , -841}, { -960 , 297}, {-666 , 68}, {-565 , -1364}, { -265 , -21},
+ { 649 , 767}, { 255 , 360}, { 338 , -342}, {1664 , 1627}, { 205 , -226}, { 967 , 31}, {1217 , 928}, { 1697 , 1233},
+ { 322 , 1445}, { 320 , 1790}, { 413 , 212}, { 994 , 209}, { 766 , 264}, { 974 , 883}, {1228 , 241}, { 1679 , 801},
+ { 75 , 312}, { 754 , 1425}, { 348 , 621}, { 644 , 474}, { 1008 , 763}, {1036 , 2024}, {1354 , 530}, { 1611 , 2129},
+ { 162 , 931}, { 883 , 822}, { 990 , 488}, { 615 , -203}, { 1929 , 1234}, {1059 , 1375}, {1382 , 1426}, { 2048 , 1599},
+ { 602 , 162}, { 380 , 820}, { 709 , 1064}, {1168 , 1374}, { 549 , 583}, {1062 , 470}, {1415 , 1092}, { 2095 , 2234},
+ { 187 , -630}, { 118 , -493}, { 714 , 1787}, {1298 , 673}, { 957 , 1258}, {1082 , 1124}, {1460 , 786}, { 2124 , 1205},
+ { 34 , -189}, { 54 , -35}, { 798 , 0}, { 747 , 2378}, { 1420 , 1152}, {1118 , 1673}, {1492 , 2287}, { 2416 , 1618},
+ {1159 , 1795}, { 389 , -126}, {1194 , 1003}, {1578 , 1002}, { 1294 , 366}, {1148 , 694}, {1513 , 1791}, { 2746 , 2096}
+ }
+};
+const Word16 SN_TCVQ_CB_SUB2_fx[2][64][2] =
+{
+ {
+ {-709 , -609}, {-615 , -1025}, {-430 , -321}, { -44 , 1032}, {-1050 , -32}, {-1028 , -1856}, {-970 , -109}, { -572 , -1426},
+ {-568 , 154}, {-142 , -189}, { -80 , 533}, { -38 , -632}, { -391 , 1275}, { -986 , -732}, {-479 , -510}, { -966 , 96},
+ {-847 , -1387}, {-895 , 607}, {-368 , -930}, {-386 , 352}, { -290 , 10}, { -833 , 94}, {-528 , 1718}, { -210 , 115},
+ {-529 , 857}, {-727 , -230}, {-128 , 31}, { 133 , 76}, { -275 , -777}, { -615 , -1367}, {-339 , -13}, {-1035 , 1231},
+ { 448 , 851}, { 599 , 106}, {1103 , 1112}, { 635 , 1249}, { 761 , 774}, { 531 , -71}, { 722 , 473}, { 767 , 413},
+ { 258 , 276}, { 346 , -380}, { 487 , 504}, {1114 , 122}, { 882 , 1553}, { 1983 , 1239}, {2126 , 1217}, { 1742 , 1262},
+ { 135 , -252}, { 216 , 545}, { 500 , -125}, {1379 , 1910}, { 304 , 76}, { 1509 , 609}, {1543 , 1385}, { 542 , 1831},
+ {-240 , -467}, { 771 , 652}, { 913 , 280}, {1307 , 716}, { 1834 , 1029}, { 1049 , 491}, {1624 , 733}, { 2495 , 1944}
+ },
+ {
+ {-729 , -852}, {-590 , 306}, {-398 , 295}, { -31 , 13}, {-659 , -75}, {-604 , -1229}, {-519 , -675}, {-823 , 47},
+ {-755 , -207}, {-818 , -424}, {-705 , -1285}, {-258 , -828}, {-807 , -707}, {-182 , -712}, {-928 , 3}, {-455 , -1149},
+ {-844 , 422}, {-596 , -1008}, {-504 , -470}, {-459 , 737}, {-338 , -728}, {-836 , 1028}, {-613 , 1242}, {-609 , 1292},
+ {-285 , 36}, {-280 , -424}, { 100 , 126}, {-459 , -135}, {-159 , -151}, {-287 , 190}, { 56 , -262}, {-264 , -317},
+ { -8 , 603}, { 63 , 301}, { 537 , -155}, { 289 , 569}, { 193 , -412}, { 864 , 79}, { 686 , 399}, { 842 , 1657},
+ { 115 , -211}, { 608 , 340}, { 12 , -650}, { 711 , 1103}, { 101 , 510}, { 358 , -416}, {1266 , 453}, { 532 , 612},
+ {-256 , -680}, { 41 , 1163}, { 597 , 793}, { 484 , -61}, { 476 , 256}, {1729 , 1246}, {1209 , 1483}, {1472 , 1113},
+ { 389 , 330}, { 176 , -388}, {1025 , 317}, {1049 , 732}, {1480 , 1108}, {1285 , 616}, {1730 , 999}, {2001 , 1669}
+ }
+};
+const Word16 SN_TCVQ_CB_SUB3_fx[4][32][2] =
+{
+ {
+ {-377 , -872}, {-407 , 801}, {-611 , -449}, {-397 , -87}, {-476 , -1063}, {-797 , -249}, {-263 , -662}, {-473 , 1508},
+ {-716 , 310}, {-616 , -982}, {-742 , -1326}, { 197 , 327}, {-894 , -1556}, {-871 , -1259}, {-708 , -1380}, {-789 , -848},
+ { 64 , -313}, { -59 , -547}, { -2 , 67}, { 363 , -167}, { 633 , 1840}, { 232 , -357}, {1243 , 1492}, {1640 , 973},
+ { 203 , 518}, { 511 , 946}, { 612 , 241}, {1085 , 724}, { 811 , 326}, { 863 , 241}, { 556 , 534}, {1956 , 2087}
+ },
+ {
+ {-948 , 28}, {-827 , -1180}, {-348 , -331}, { -36 , 216}, {-1453 , -1162}, {-682 , -639}, {-747 , -1517}, {-704 , 1228},
+ {-535 , -988}, {-550 , -109}, {-478 , 580}, {-310 , -699}, {-1308 , -225}, {-775 , -1581}, {-831 , -613}, {-120 , -222},
+ { 32 , 200}, { 120 , -221}, { 470 , 466}, { 808 , 313}, { 950 , 711}, { 430 , -576}, {1984 , 1405}, {1645 , 887},
+ { 131 , 1148}, { 286 , 508}, { 342 , -236}, {1003 , 1202}, { 317 , -726}, {1493 , 732}, {1336 , 694}, {2382 , 1772}
+ },
+ {
+ {-874 , -374}, {-237 , 26}, { 15 , 870}, {-710 , 433}, { 40 , -769}, {-1059 , -1350}, { 65 , 208}, {-1012 , -1369},
+ { -79 , -459}, {-671 , -942}, { -12 , 56}, {-162 , -431}, {-820 , -1073}, { -886 , -136}, {-327 , -501}, { -55 , -14},
+ { 652 , 647}, { 365 , 411}, { 614 , 252}, { 154 , 215}, { 12 , 62}, { 226 , 177}, {1689 , 1213}, { 751 , 179},
+ { 31 , 182}, { 281 , -291}, {-354 , -642}, { 939 , 924}, { 619 , 90}, { 1675 , 1130}, { 827 , 272}, { 1550 , 1446}
+ },
+ {
+ {-366 , -916}, {-346 , -234}, {-518 , -140}, { 26 , 305}, {-254 , -92}, {-634 , -976}, {-493 , -1076}, {-334 , -913},
+ {-566 , 68}, { 102 , 216}, {-296 , -927}, {-501 , -1030}, {-437 , -1006}, {-146 , -145}, {-211 , -202}, { 62 , 359},
+ { 163 , -122}, { 759 , 553}, { 82 , 207}, {-177 , -243}, { 163 , 343}, {1152 , 929}, { 197 , 248}, { 43 , -147},
+ { 169 , 371}, {-468 , -1043}, { 686 , 418}, { 563, 245}, {1052 , 843}, { 259 , 341}, {1063 , 637}, { 865 , 654}
+ }
+};
+const Word16 AR_SVQ_CB1_fx[32][8] = /* x2.56 */
+{
+ { -1, 4, 16, 4, 45, -110, 10, 167, },
+ { -3, 2, 8, -12, -7, 23, 279, -46, },
+ { 0, 2, 1, 8, -73, -40, 71, -97, },
+ { 0, 2, 42, 74, -39, 72, 27, 8, },
+ { 0, 1, 9, -6, 40, -65, -55, -128, },
+ { 0, 0, 8, -10, -43, 105, -5, -126, },
+ { 0, 0, 12, -3, -98, -18, -88, -73, },
+ { 0, 1, -6, -12, -49, -179, -30, -15, },
+ { -1, 0, 24, 78, 25, -69, -26, -14, },
+ { 0, 1, -1, -29, 23, -65, -126, 34, },
+ { 2, -4, -23, -7, -13, -2, -22, -4, },
+ { -1, 1, -2, 44, -54, -58, 107, 60, },
+ { 0, 1, -3, -15, -54, 97, -100, 41, },
+ { 0, -2, -81, 93, -13, 18, -31, -75, },
+ { -1, 2, 0, -5, 166, -64, -48, 8, },
+ { -2, 0, -27, -108, 36, 3, 12, -80, },
+ { 0, 0, 0, 4, 82, -1, 79, 54, },
+ { 1, -4, 5, -9, -38, 289, 16, 16, },
+ { -1, 2, 6, -68, 61, 67, -31, 100, },
+ { 3, -6, 2, -2, -1, -6, -217, 273, },
+ { 0, 1, -43, -62, -7, -60, 28, 78, },
+ { -1, 2, 10, 0, 76, 84, -55, -45, },
+ { -1, -2, 4, 5, -32, 75, 70, 176, },
+ { 2, -1, 0, 6, 27, 29, -220, -97, },
+ { -1, 1, 90, -56, -10, -16, 29, 8, },
+ { -1, 3, -10, 0, 2, -24, 49, -336, },
+ { -1, 1, -8, -9, 55, -134, 105, -44, },
+ { 0, 1, -16, 69, 51, 40, -51, 98, },
+ { 0, 2, -12, -32, -140, 49, 50, 26, },
+ { 0, 3, 8, 29, 77, 24, 76, -103, },
+ { -1, 2, -24, -18, 7, 100, 94, 5, },
+ { 0, -1, 10, 26, -87, -34, -56, 103, }
+};
+const Word16 AR_SVQ_CB2_fx[16][8] = /* x2.56 */
+{
+ { -37, -59, 208, -88, 54, 58, -16, -24, },
+ { 0, -98, 9, -65, -182, -21, 19, 9, },
+ { -1, 110, -8, 59, 201, 9, -38, -22, },
+ { -1, 40, -22, -183, 46, -162, -38, -6, },
+ { 12, 2, -193, 64, -43, -48, 11, 9, },
+ { -83, 175, -8, -55, -65, 66, 26, 6, },
+ { 29, 3, 2, -10, -100, 293, 75, -12, },
+ { 7, -54, -76, -91, 63, 119, -84, -84, },
+ { 3, 7, 6, 6, -30, 15, -176, 168, },
+ { -10, 45, 26, 57, -92, -68, -117, -134, },
+ { 0, -37, -34, -69, 106, 54, 121, 131, },
+ { -25, -64, 7, 205, 1, 93, 27, 6, },
+ { 64, 28, 51, 8, -7, 18, 27, 0, },
+ { -20, 44, 57, 78, -55, -170, 88, 93, },
+ { 12, -125, 12, 56, 100, -160, -87, -3, },
+ { -7, -18, -7, -6, 36, -54, 175, -176, }
+};
+
+const Word16 interpol_frac_mid_relaxprev_12k8_fx[NB_SUBFR*3] = { 0, 22938, 9830,
+ 0, 0, 32767,
+ 0, 0, 32767,
+ 0, 0, 32767
+ };
+
+const Word16 interpol_frac_mid_FEC_fx[NB_SUBFR*3] = { 8192, 18022, 6554,
+ 0, 22938, 9830,
+ 0, 14746, 18022,
+ 0, 0, 32767
+ };
+
+const Word16 interpol_frac_mid_relaxprev_pred_12k8_fx[NB_SUBFR*3] = { 4915, 22938, 4915,
+ 1638, 21299, 9830,
+ 0, 16384, 16384,
+ 0, 0, 32767
+ };
+
+const Word16 interpol_frac_mid_relaxprev_16k_fx[NB_SUBFR16k*3] = { 0, 22938, 9830,
+ 0, 0, 32767,
+ 0, 0, 32767,
+ 0, 0, 32767,
+ 0, 0, 32767
+ };
+
+const Word16 interpol_frac_mid_16k_FEC_fx[NB_SUBFR16k*3] = { 13107, 13107, 6554,
+ 0, 26214, 6554,
+ 0, 21299, 11469,
+ 0, 4915, 27853,
+ 0, 0, 32767
+ };
+
+const Word16 interpol_frac_mid_relaxprev_pred_16k_fx[NB_SUBFR16k*3] = { 4915, 22938, 4915,
+ 1638, 21299, 9830,
+ 0, 16384, 16384,
+ 0, 4915, 27853,
+ 0, 0, 32767
+ };
+
+const Word16 filter_LP15_180H_fx[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/15, hann( N )' */
+{
+ 16384, 16263, 15904, 15317, 14516, 13524,
+ 12366, 11073, 9678, 8216, 6723, 5236,
+ 3790, 2416, 1144, 0, -997, -1831,
+ -2492, -2976, -3285, -3425, -3408, -3248,
+ -2966, -2583, -2123, -1610, -1070, -526,
+ 0, 487, 919, 1281, 1564, 1761,
+ 1869, 1891, 1830, 1695, 1496, 1244,
+ 954, 641, 318, 0, -300, -569,
+ -799, -982, -1113, -1188, -1209, -1176,
+ -1094, -969, -809, -623, -420, -209,
+ 0, 198, 377, 531, 653, 741,
+ 793, 807, 786, 732, 649, 543,
+ 418, 282, 140, 0, -133, -253,
+ -356, -438, -497, -531, -540, -526,
+ -489, -433, -362, -278, -187, -93,
+ 0, 88, 167, 234, 288, 325,
+ 347, 352, 342, 317, 280, 233,
+ 179, 120, 59, 0, -56, -105,
+ -147, -180, -203, -215, -217, -210,
+ -194, -170, -141, -107, -72, -35,
+ 0, 33, 61, 85, 103, 116,
+ 122, 122, 117, 107, 93, 76,
+ 58, 38, 19, 0, -17, -31,
+ -43, -51, -57, -59, -58, -55,
+ -49, -42, -34, -25, -16, -8,
+ 0, 7, 12, 16, 19, 20,
+ 21, 20, 18, 16, 13, 10,
+ 7, 4, 2, 0, -1, -2,
+ -3, -3, -3, -3, -2, -2,
+ -1, -1, 0, 0, 0, 0,
+ 0
+};
+
+const Word16 filter_LP15_180H_13b_fx[6*31] = /*Q13 Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )'*/
+{
+ 8192, 8132, 7952, 7658, 7258, 6762,
+ 6183, 5536, 4839, 4108, 3362, 2618,
+ 1895, 1208, 572, 0, -498, -915,
+ -1246, -1488, -1643, -1713, -1704, -1624,
+ -1483, -1291, -1061, -805, -535, -263,
+ 0, 244, 459, 640, 782, 880,
+ 935, 945, 915, 848, 748, 622,
+ 477, 320, 159, 0, -150, -285,
+ -400, -491, -556, -594, -604, -588,
+ -547, -485, -405, -312, -210, -104,
+ 0, 99, 189, 265, 327, 371,
+ 396, 404, 393, 366, 325, 271,
+ 209, 141, 70, 0, -66, -127,
+ -178, -219, -248, -266, -270, -263,
+ -245, -217, -181, -139, -94, -46,
+ 0, 44, 83, 117, 144, 163,
+ 173, 176, 171, 158, 140, 116,
+ 89, 60, 30, 0, -28, -53,
+ -74, -90, -101, -108, -109, -105,
+ -97, -85, -70, -54, -36, -18,
+ 0, 16, 31, 43, 52, 58,
+ 61, 61, 58, 53, 47, 38,
+ 29, 19, 9, 0, -8, -16,
+ -21, -26, -28, -29, -29, -27,
+ -25, -21, -17, -13, -8, -4,
+ 0, 3, 6, 8, 10, 10,
+ 10, 10, 9, 8, 6, 5,
+ 3, 2, 1, 0, -1, -1,
+ -1, -2, -2, -1, -1, -1,
+ -1, 0, 0, 0, 0, 0,
+ 0
+};
+const Word16 filter_LP12_180H_fx[] = /* Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )' */
+{
+ 16384, 16196, 15641, 14741, 13533, 12067,
+ 10402, 8604, 6742, 4887, 3105, 1459,
+ 0, -1230, -2202, -2900, -3322, -3478,
+ -3392, -3095, -2628, -2037, -1371, -676,
+ 0, 618, 1143, 1550, 1822, 1954,
+ 1946, 1811, 1565, 1233, 842, 421,
+ 0, -394, -736, -1008, -1196, -1294,
+ -1299, -1217, -1059, -839, -576, -290,
+ 0, 274, 514, 707, 842, 913,
+ 920, 865, 755, 600, 413, 208,
+ 0, -197, -371, -511, -609, -662,
+ -667, -627, -548, -436, -300, -151,
+ 0, 143, 270, 371, 443, 481,
+ 485, 456, 398, 316, 217, 109,
+ 0, -104, -195, -268, -319, -346,
+ -348, -326, -284, -225, -155, -78,
+ 0, 73, 137, 189, 224, 242,
+ 243, 227, 198, 156, 107, 54,
+ 0, -50, -94, -128, -151, -163,
+ -163, -152, -131, -103, -70, -35,
+ 0, 32, 60, 82, 96, 103,
+ 102, 95, 81, 64, 43, 21,
+ 0, -19, -36, -48, -56, -59,
+ -58, -53, -45, -35, -23, -11,
+ 0, 10, 18, 24, 28, 29,
+ 28, 25, 21, 16, 10, 5,
+ 0, -4, -7, -9, -10, -10,
+ -9, -8, -6, -5, -3, -1,
+ 0, 1, 1, 2, 2, 1,
+ 1, 1, 0, 0, 0, 0,
+ 0
+};
+const Word16 filter_LP12_180H_13b_fx[] = /*Q13 Sincfilt.m: N=180*2+1, Fmin=0, Fmax=1/12, hann( N )*/
+{
+ 8192, 8098, 7820, 7370, 6766, 6033,
+ 5201, 4302, 3371, 2443, 1553, 729,
+ 0, -615, -1101, -1450, -1661, -1739,
+ -1696, -1547, -1314, -1019, -685, -338,
+ 0, 309, 571, 775, 911, 977,
+ 973, 905, 783, 616, 421, 210,
+ 0, -197, -368, -504, -598, -647,
+ -649, -608, -529, -420, -288, -145,
+ 0, 137, 257, 353, 421, 457,
+ 460, 432, 377, 300, 206, 104,
+ 0, -99, -185, -255, -305, -331,
+ -333, -314, -274, -218, -150, -76,
+ 0, 72, 135, 186, 221, 240,
+ 242, 228, 199, 158, 109, 55,
+ 0, -52, -97, -134, -159, -173,
+ -174, -163, -142, -113, -77, -39,
+ 0, 37, 69, 94, 112, 121,
+ 121, 114, 99, 78, 53, 27,
+ 0, -25, -47, -64, -76, -81,
+ -81, -76, -66, -52, -35, -18,
+ 0, 16, 30, 41, 48, 52,
+ 51, 47, 41, 32, 21, 11,
+ 0, -10, -18, -24, -28, -30,
+ -29, -27, -23, -17, -12, -6,
+ 0, 5, 9, 12, 14, 14,
+ 14, 13, 10, 8, 5, 2,
+ 0, -2, -4, -5, -5, -5,
+ -5, -4, -3, -2, -1, -1,
+ 0, 0, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0,
+ 0
+};
+
+const Word16 filter_LP24_90H_fx[] =
+{
+
+ 10240, 10208, 10111, 9951, 9731,
+ 9452, 9119, 8734, 8304, 7834,
+ 7328, 6794, 6237, 5664, 5081,
+ 4495, 3913, 3339, 2780, 2241,
+ 1727, 1242, 791, 376, 0,
+ -335, -629, -880, -1089, -1256,
+ -1383, -1471, -1523, -1540, -1527,
+ -1487, -1422, -1337, -1235, -1119,
+ -994, -862, -727, -592, -460,
+ -333, -212, -101, 0, 90,
+ 167, 232, 285, 325, 354,
+ 371, 378, 376, 366, 349,
+ 326, 299, 269, 236, 203,
+ 171, 139, 109, 81, 56,
+ 34, 15, 0, -12, -21,
+ -27, -30, -31, -31, -29,
+ -26, -22, -18, -14, -10,
+ -7, -4, -2, -1, 0,
+ 0, 0, 0, 0, 0,
+ 0,
+ 0
+
+};
+
+const Word16 filter_LP24_90H_13b_fx[] =
+{
+
+ 5120, 5104, 5056, 4976, 4865,
+ 4726, 4559, 4367, 4152, 3917,
+ 3664, 3397, 3119, 2832, 2541,
+ 2248, 1956, 1669, 1390, 1120,
+ 863, 621, 396, 188, 0,
+ -168, -315, -440, -545, -628,
+ -691, -735, -761, -770, -764,
+ -743, -711, -668, -617, -560,
+ -497, -431, -364, -296, -230,
+ -166, -106, -51, 0, 45,
+ 84, 116, 143, 163, 177,
+ 186, 189, 188, 183, 174,
+ 163, 149, 134, 118, 102,
+ 85, 69, 54, 40, 28,
+ 17, 8, 0, -6, -10,
+ -13, -15, -16, -15, -14,
+ -13, -11, -9, -7, -5,
+ -3, -2, -1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0,
+ 0
+};
+
+const Word16 filter_LP3_90H_fx[] = /* Sincfilt.m: N=90*2+1, Fmin=0, Fmax=1/3, hann( N )' */
+{
+ 16384, 13545, 6766, 0, -3371, -2689,
+ 0, 1907, 1661, 0, -1314, -1187,
+ 0, 990, 911, 0, -783, -729,
+ 0, 638, 598, 0, -529, -499,
+ 0, 445, 421, 0, -377, -357,
+ 0, 321, 305, 0, -274, -260,
+ 0, 234, 221, 0, -199, -188,
+ 0, 169, 159, 0, -142, -134,
+ 0, 119, 112, 0, -99, -93,
+ 0, 81, 76, 0, -66, -61,
+ 0, 52, 48, 0, -41, -37,
+ 0, 31, 28, 0, -23, -20,
+ 0, 16, 14, 0, -10, -9,
+ 0, 6, 5, 0, -3, -2,
+ 0, 1, 1, 0, 0, 0,
+ 0
+};
+
+const Word16 filter_LP15_360H_13b_fx[] = /* Sincfilt.m: N=360*2+1, Fmin=0, Fmax=1/15, hann( N )' */
+{
+
+ 8192, 8132, 7954, 7662, 7265, 6772, 6196, 5552,
+ 4857, 4127, 3381, 2636, 1911, 1220, 579, 0,
+ -506, -931, -1269, -1519, -1681, -1757, -1752, -1674,
+ -1533, -1339, -1104, -840, -560, -276, 0, 258,
+ 488, 682, 836, 946, 1008, 1024, 996, 927,
+ 821, 687, 529, 357, 178, 0, -170, -325,
+ -458, -567, -646, -694, -710, -696, -652, -581,
+ -489, -379, -257, -129, 0, 124, 238, 338,
+ 420, 481, 518, 533, 523, 492, 440, 372,
+ 289, 197, 99, 0, -96, -184, -262, -326,
+ -374, -405, -417, -410, -386, -346, -293, -228,
+ -156, -78, 0, 76, 147, 209, 260, 299,
+ 324, 334, 329, 310, 279, 236, 184, 125,
+ 63, 0, -62, -119, -169, -211, -243, -263,
+ -271, -268, -252, -227, -192, -150, -102, -52,
+ 0, 50, 97, 138, 173, 198, 215, 222,
+ 219, 207, 186, 157, 123, 84, 42, 0,
+ -41, -80, -113, -142, -163, -176, -182, -180,
+ -170, -152, -129, -101, -69, -35, 0, 34,
+ 65, 93, 116, 133, 144, 149, 147, 139,
+ 125, 106, 82, 56, 28, 0, -28, -53,
+ -76, -95, -109, -118, -121, -120, -113, -101,
+ -86, -67, -46, -23, 0, 22, 43, 61,
+ 77, 88, 95, 98, 97, 91, 82, 69,
+ 54, 37, 19, 0, -18, -35, -49, -61,
+ -70, -76, -78, -77, -73, -65, -55, -43,
+ -29, -15, 0, 14, 27, 39, 48, 55,
+ 60, 62, 61, 57, 51, 43, 33, 23,
+ 11, 0, -11, -21, -30, -37, -43, -46,
+ -48, -47, -44, -39, -33, -26, -17, -9,
+ 0, 8, 16, 23, 28, 32, 35, 36,
+ 35, 33, 29, 25, 19, 13, 6, 0,
+ -6, -12, -17, -21, -24, -25, -26, -25,
+ -24, -21, -18, -14, -9, -5, 0, 4,
+ 8, 12, 14, 16, 18, 18, 17, 16,
+ 14, 12, 9, 6, 3, 0, -3, -6,
+ -8, -10, -11, -11, -12, -11, -10, -9,
+ -8, -6, -4, -2, 0, 2, 3, 5,
+ 6, 6, 7, 7, 7, 6, 5, 4,
+ 3, 2, 1, 0, -1, -2, -3, -3,
+ -3, -3, -3, -3, -3, -3, -2, -2,
+ -1, 0, 0, 0, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0
+
+};
+
+const Resampling_cfg_fx resampling_cfg_tbl_fx[] =
+{
+ /* fin fout up.fac. den.fac. len.out filter coefs. filter mem./2 flags */
+ {8000, 12800, 8, 5, 256, filter5_39s320_120_fx, 15, RS_INV_FAC },
+ {12800, 8000, 5, 8, 160, filter5_39s320_120_fx, L_FILT_UP8k, RS_INV_FAC },
+ {16000, 8000, 6, 12, 160, filter_LP12_180H_fx, 180/6, 0 },
+
+ {12800, 16000, 15, 12, 320, filter_LP15_180H_fx, L_FILT_UP16k, 0 },
+ {12800, 32000, 15, 6, 640, filter_LP15_180H_fx, L_FILT_UP32k, 0 },
+ {12800, 48000, 15, 4, 960, filter_LP15_180H_fx, L_FILT_UP48k , 0 },
+
+ {16000, 12800, 12, 15, 256, filter_LP15_180H_fx, L_FILT16k, 0 },
+ {16000, 32000, 12, 6, 640, filter_LP12_180H_fx, L_FILT16k, 0 },
+ {16000, 48000, 12, 4, 960, filter_LP12_180H_fx, L_FILT16k, 0 },
+
+ {32000, 12800, 6, 15, 256, filter_LP15_180H_13b_fx, L_FILT32k, 0 },
+ {32000, 16000, 6, 12, 320, filter_LP12_180H_13b_fx, L_FILT32k, 0 },
+ {32000, 25600, 12, 15, 512, filter_LP15_360H_13b_fx, L_FILT32k, 0 },
+ {32000, 48000, 3, 2, 960, filter_LP3_90H_fx, L_FILT32k, 0 },
+
+ {48000, 12800, 4, 15, 256, filter_LP15_180H_13b_fx, L_FILT48k, 0 },
+ {48000, 16000, 4, 12, 320, filter_LP12_180H_13b_fx, L_FILT48k, 0 },
+ {48000, 25600, 8, 15, 512, filter_LP15_360H_13b_fx, L_FILT48k, 0 },
+ {48000, 32000, 2, 3, 640, filter_LP3_90H_fx, L_FILT48k, 0 },
+
+ /* configs with NB 4kHz low-pass */
+ {16000, 12800, 12, 15, 256, filter_LP24_90H_fx, L_FILT16k, 0 },
+ {32000, 12800, 6, 15, 256, filter_LP24_90H_13b_fx, L_FILT32k, 0 },
+ {48000, 12800, 4, 15, 256, filter_LP24_90H_13b_fx, L_FILT48k, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, 0 } /* trailing entry (just to calculate the length of this table) */
+};
+/*-------------------------------------------------------------------*
+ * 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2)
+ * for fractional pitch search
+ * Used in lib_enc\pit_enc.c Q14
+ *-------------------------------------------------------------------*/
+const Word16 inter4_1_fx[32] =
+{
+ -12, -26, 32, 206,
+ 420, 455, 73, -766,
+ -1732, -2142,-1242, 1376,
+ 5429, 9910,13418,14746,
+ 13418, 9910, 5429, 1376,
+ -1242, -2142,-1732, -766,
+ 73, 455, 420, 206,
+ 32, -26, -12, 0
+};
+const Word16 CNG_burst_att_fx[6][8] =
+{
+ {30076, 27793, 25832, 24129, 22637, 21319, 20146, 19095},
+ {29714, 27181, 25046, 23222, 21646, 20270, 20205, 20205},
+ {29415, 26685, 24418, 22506, 22410, 22410, 22410, 22410},
+ {29310, 26512, 24201, 23198, 23198, 23198, 23198, 23198},
+ {29310, 26512, 24201, 23198, 23198, 23198, 23198, 23198},
+ {29789, 27307, 25206, 23406, 21845, 20480, 19661, 19661}
+};
+/* 2.0 - 6.4 kHz phase dispersion */
+const Word16 Low_H_phasedisp[L_SUBFR]=
+{
+ 16389, 16381, 16386, 16382, 16382, 16383, 16381, 16384, 16385, 10265,
+ 10154, 9894, 14052, 16343, -531, 13216, 16373, 15510, 9407, 15949,
+ 4726, 14593, 10404, 9796, -16336, -1815,-10623, 12647, 14556,-12683,
+ 11389, 8176, 16382,-14197, 11781, 10379, 7516, 10424,-12472, 16285,
+ -1200,-13137, 12659, -7446, 15684, -3763,-13418, -5280, 521, -9685,
+ -16375, -1219, 8436,-13059, -12861,-12775, 0, 3, 0, -2,
+ -1, -1, -1, 2
+};
+
+/* 3.2 - 6.4 kHz phase dispersion */
+const Word16 Mid_H_phasedisp[L_SUBFR]=
+{
+ 16382, 16382, 16384, 16385, 16386, 16388, 16387, 16383, 16387, 16383,
+ 16386, 16386, 16386, 16384, 16382, 16388, 14847, 9629, 13249, 14487,
+ 10995, 643, 13818, 13779, 6468, 8665, 11634, 9781,-14636, -982,
+ 11746, -722, 16386,-16365, -11422, 16354, 7363, 13148,-11538,-13903,
+ -15051, -8862, 8812,-16371, -12146, 7661, -9637,-13253, -6922, 4,
+ -4, -1, -5, 1, 7, 6, -7, -1, 4, -4,
+ 0, -1, -3, 3
+};
+/* phase table needed in FFT */
+const Word16 phs_tbl_dec[64*2] =
+{
+ /* part of table that is not scaled by 2 */
+ 16384, 0, 16305, -1606, 16069, -3196, 15678, -4756, 15136, -6270,
+ 14449, -7723, 13622, -9102, 12665, -10394, 11585, -11585, 10394, -12665,
+ 9102, -13622, 7723, -14449, 6270, -15136, 4756, -15678, 3196, -16069,
+ 1606, -16305, 0, -16384, -1606, -16305, -3196, -16069, -4756, -15678,
+ -6270, -15136, -7723, -14449, -9102, -13622, -10394, -12665, -11585, -11585,
+ -12665, -10394, -13622, -9102, -14449, -7723, -15136, -6270, -15678, -4756,
+ -16069, -3196, -16305, -1606,
+ /* part of table that is scaled by 2 (this save one operation in FFT inner loops) */
+ 32767, 0, 32610, -3212, 32138, -6392, 31356, -9512, 30272, -12540,
+ 28898, -15446, 27244, -18204, 25330, -20788, 23170, -23170, 20788, -25330,
+ 18204, -27244, 15446, -28898, 12540, -30272, 9512, -31356, 6392, -32138,
+ 3212, -32610, 0, -32768, -3212, -32610, -6392, -32138, -9512, -31356,
+ -12540, -30272, -15446, -28898, -18204, -27244, -20788, -25330, -23170, -23170,
+ -25330, -20788, -27244, -18204, -28898, -15446, -30272, -12540, -31356, -9512,
+ -32138, -6392, -32610, -3212
+};
+
+const Word16 FFT_W64[(64*2)*2] =
+{
+ 16384, 0, 16364, -804, 16305, -1606, 16207, -2404,
+ 16069, -3196, 15893, -3981, 15679, -4756, 15426, -5520,
+ 15137, -6270, 14811, -7005, 14449, -7723, 14053, -8423,
+ 13623, -9102, 13160, -9760, 12665, -10394, 12140, -11003,
+ 11585, -11585, 11003, -12140, 10394, -12665, 9760, -13160,
+ 9102, -13623, 8423, -14053, 7723, -14449, 7005, -14811,
+ 6270, -15137, 5520, -15426, 4756, -15679, 3981, -15893,
+ 3196, -16069, 2404, -16207, 1606, -16305, 804, -16364,
+ 0, -16384, -804, -16364, -1606, -16305, -2404, -16207,
+ -3196, -16069, -3981, -15893, -4756, -15679, -5520, -15426,
+ -6270, -15137, -7005, -14811, -7723, -14449, -8423, -14053,
+ -9102, -13623, -9760, -13160, -10394, -12665, -11003, -12140,
+ -11585, -11585, -12140, -11003, -12665, -10394, -13160, -9760,
+ -13623, -9102, -14053, -8423, -14449, -7723, -14811, -7005,
+ -15137, -6270, -15426, -5520, -15679, -4756, -15893, -3981,
+ -16069, -3196, -16207, -2404, -16305, -1606, -16364, -804,
+ /* The following is a duplication of the above but scaled up by a factor of 2.
+ * This save one operation in inverse FFT inner loops */
+ 32767, 0, 32729, -1608, 32610, -3212, 32413, -4808,
+ 32138, -6393, 31786, -7962, 31357, -9512, 30853, -11039,
+ 30274, -12540, 29622, -14010, 28899, -15447, 28106, -16846,
+ 27246, -18205, 26320, -19520, 25330, -20788, 24279, -22006,
+ 23170, -23170, 22006, -24279, 20788, -25330, 19520, -26320,
+ 18205, -27246, 16846, -28106, 15447, -28899, 14010, -29622,
+ 12540, -30274, 11039, -30853, 9512, -31357, 7962, -31786,
+ 6393, -32138, 4808, -32413, 3212, -32610, 1608, -32729,
+ 0, -32768, -1608, -32729, -3212, -32610, -4808, -32413,
+ -6393, -32138, -7962, -31786, -9512, -31357, -11039, -30853,
+ -12540, -30274, -14010, -29622, -15447, -28899, -16846, -28106,
+ -18205, -27246, -19520, -26320, -20788, -25330, -22006, -24279,
+ -23170, -23170, -24279, -22006, -25330, -20788, -26320, -19520,
+ -27246, -18205, -28106, -16846, -28899, -15447, -29622, -14010,
+ -30274, -12540, -30853, -11039, -31357, -9512, -31786, -7962,
+ -32138, -6393, -32413, -4808, -32610, -3212, -32729, -1608
+};
+
+const Word16 FFT_W128[] =
+{
+ /* part of table that is not scaled by 2 */
+ 16384, 0, 16379, -402, 16364, -804, 16339, -1205,
+ 16305, -1606, 16260, -2006, 16206, -2404, 16142, -2801,
+ 16069, -3196, 15985, -3590, 15893, -3981, 15790, -4370,
+ 15678, -4756, 15557, -5139, 15426, -5519, 15286, -5896,
+ 15136, -6270, 14978, -6639, 14811, -7005, 14634, -7366,
+ 14449, -7723, 14255, -8075, 14053, -8423, 13842, -8765,
+ 13622, -9102, 13395, -9434, 13159, -9760, 12916, -10080,
+ 12665, -10394, 12406, -10701, 12139, -11002, 11866, -11297,
+ 11585, -11585, 11297, -11866, 11002, -12139, 10701, -12406,
+ 10394, -12665, 10080, -12916, 9760, -13159, 9434, -13395,
+ 9102, -13622, 8765, -13842, 8423, -14053, 8075, -14255,
+ 7723, -14449, 7366, -14634, 7005, -14811, 6639, -14978,
+ 6270, -15136, 5896, -15286, 5519, -15426, 5139, -15557,
+ 4756, -15678, 4370, -15790, 3981, -15893, 3590, -15985,
+ 3196, -16069, 2801, -16142, 2404, -16206, 2006, -16260,
+ 1606, -16305, 1205, -16339, 804, -16364, 402, -16379,
+ 0, -16384, -402, -16379, -804, -16364, -1205, -16339,
+ -1606, -16305, -2006, -16260, -2404, -16206, -2801, -16142,
+ -3196, -16069, -3590, -15985, -3981, -15893, -4370, -15790,
+ -4756, -15678, -5139, -15557, -5519, -15426, -5896, -15286,
+ -6270, -15136, -6639, -14978, -7005, -14811, -7366, -14634,
+ -7723, -14449, -8075, -14255, -8423, -14053, -8765, -13842,
+ -9102, -13622, -9434, -13395, -9760, -13159, -10080, -12916,
+ -10394, -12665, -10701, -12406, -11002, -12139, -11297, -11866,
+ -11585, -11585, -11866, -11297, -12139, -11002, -12406, -10701,
+ -12665, -10394, -12916, -10080, -13159, -9760, -13395, -9434,
+ -13622, -9102, -13842, -8765, -14053, -8423, -14255, -8075,
+ -14449, -7723, -14634, -7366, -14811, -7005, -14978, -6639,
+ -15136, -6270, -15286, -5896, -15426, -5519, -15557, -5139,
+ -15678, -4756, -15790, -4370, -15893, -3981, -15985, -3590,
+ -16069, -3196, -16142, -2801, -16206, -2404, -16260, -2006,
+ -16305, -1606, -16339, -1205, -16364, -804, -16379, -402,
+ /* part of table that is scaled by 2 (this save one operation in FFT inner loops) */
+ 32767, 0, 32758, -804, 32728, -1608, 32678, -2410,
+ 32610, -3212, 32520, -4012, 32412, -4808, 32284, -5602,
+ 32138, -6392, 31970, -7180, 31786, -7962, 31580, -8740,
+ 31356, -9512, 31114, -10278, 30852, -11038, 30572, -11792,
+ 30272, -12540, 29956, -13278, 29622, -14010, 29268, -14732,
+ 28898, -15446, 28510, -16150, 28106, -16846, 27684, -17530,
+ 27244, -18204, 26790, -18868, 26318, -19520, 25832, -20160,
+ 25330, -20788, 24812, -21402, 24278, -22004, 23732, -22594,
+ 23170, -23170, 22594, -23732, 22004, -24278, 21402, -24812,
+ 20788, -25330, 20160, -25832, 19520, -26318, 18868, -26790,
+ 18204, -27244, 17530, -27684, 16846, -28106, 16150, -28510,
+ 15446, -28898, 14732, -29268, 14010, -29622, 13278, -29956,
+ 12540, -30272, 11792, -30572, 11038, -30852, 10278, -31114,
+ 9512, -31356, 8740, -31580, 7962, -31786, 7180, -31970,
+ 6392, -32138, 5602, -32284, 4808, -32412, 4012, -32520,
+ 3212, -32610, 2410, -32678, 1608, -32728, 804, -32758,
+ 0, -32768, -804, -32758, -1608, -32728, -2410, -32678,
+ -3212, -32610, -4012, -32520, -4808, -32412, -5602, -32284,
+ -6392, -32138, -7180, -31970, -7962, -31786, -8740, -31580,
+ -9512, -31356, -10278, -31114, -11038, -30852, -11792, -30572,
+ -12540, -30272, -13278, -29956, -14010, -29622, -14732, -29268,
+ -15446, -28898, -16150, -28510, -16846, -28106, -17530, -27684,
+ -18204, -27244, -18868, -26790, -19520, -26318, -20160, -25832,
+ -20788, -25330, -21402, -24812, -22004, -24278, -22594, -23732,
+ -23170, -23170, -23732, -22594, -24278, -22004, -24812, -21402,
+ -25330, -20788, -25832, -20160, -26318, -19520, -26790, -18868,
+ -27244, -18204, -27684, -17530, -28106, -16846, -28510, -16150,
+ -28898, -15446, -29268, -14732, -29622, -14010, -29956, -13278,
+ -30272, -12540, -30572, -11792, -30852, -11038, -31114, -10278,
+ -31356, -9512, -31580, -8740, -31786, -7962, -31970, -7180,
+ -32138, -6392, -32284, -5602, -32412, -4808, -32520, -4012,
+ -32610, -3212, -32678, -2410, -32728, -1608, -32758, -804
+};
+
+const Word16 FFT_W256[(256*2)*2] =
+{
+ /* Each adjacent pair represents the real and imaginary part of a complex number: */
+ /* W = exp{-j*(PI*n/256)} = cos(PI*n/256)*16384 -j*sin(PI*n/256)*16384 for n=0, 1, ..., 255. */
+ 16384, 0, 16383, -201, 16379, -402, 16373, -603,
+ 16364, -804, 16353, -1005, 16340, -1205, 16324, -1406,
+ 16305, -1606, 16284, -1806, 16261, -2006, 16235, -2205,
+ 16207, -2404, 16176, -2603, 16143, -2801, 16107, -2999,
+ 16069, -3196, 16029, -3393, 15986, -3590, 15941, -3786,
+ 15893, -3981, 15843, -4176, 15791, -4370, 15736, -4563,
+ 15679, -4756, 15619, -4948, 15557, -5139, 15493, -5330,
+ 15426, -5520, 15357, -5708, 15286, -5897, 15213, -6084,
+ 15137, -6270, 15059, -6455, 14978, -6639, 14896, -6823,
+ 14811, -7005, 14724, -7186, 14635, -7366, 14543, -7545,
+ 14449, -7723, 14354, -7900, 14256, -8076, 14155, -8250,
+ 14053, -8423, 13949, -8595, 13842, -8765, 13733, -8935,
+ 13623, -9102, 13510, -9269, 13395, -9434, 13279, -9598,
+ 13160, -9760, 13039, -9921, 12916, -10080, 12792, -10238,
+ 12665, -10394, 12537, -10549, 12406, -10702, 12274, -10853,
+ 12140, -11003, 12004, -11151, 11866, -11297, 11727, -11442,
+ 11585, -11585, 11442, -11727, 11297, -11866, 11151, -12004,
+ 11003, -12140, 10853, -12274, 10702, -12406, 10549, -12537,
+ 10394, -12665, 10238, -12792, 10080, -12916, 9921, -13039,
+ 9760, -13160, 9598, -13279, 9434, -13395, 9269, -13510,
+ 9102, -13623, 8935, -13733, 8765, -13842, 8595, -13949,
+ 8423, -14053, 8250, -14155, 8076, -14256, 7900, -14354,
+ 7723, -14449, 7545, -14543, 7366, -14635, 7186, -14724,
+ 7005, -14811, 6823, -14896, 6639, -14978, 6455, -15059,
+ 6270, -15137, 6084, -15213, 5897, -15286, 5708, -15357,
+ 5520, -15426, 5330, -15493, 5139, -15557, 4948, -15619,
+ 4756, -15679, 4563, -15736, 4370, -15791, 4176, -15843,
+ 3981, -15893, 3786, -15941, 3590, -15986, 3393, -16029,
+ 3196, -16069, 2999, -16107, 2801, -16143, 2603, -16176,
+ 2404, -16207, 2205, -16235, 2006, -16261, 1806, -16284,
+ 1606, -16305, 1406, -16324, 1205, -16340, 1005, -16353,
+ 804, -16364, 603, -16373, 402, -16379, 201, -16383,
+ 0, -16384, -201, -16383, -402, -16379, -603, -16373,
+ -804, -16364, -1005, -16353, -1205, -16340, -1406, -16324,
+ -1606, -16305, -1806, -16284, -2006, -16261, -2205, -16235,
+ -2404, -16207, -2603, -16176, -2801, -16143, -2999, -16107,
+ -3196, -16069, -3393, -16029, -3590, -15986, -3786, -15941,
+ -3981, -15893, -4176, -15843, -4370, -15791, -4563, -15736,
+ -4756, -15679, -4948, -15619, -5139, -15557, -5330, -15493,
+ -5520, -15426, -5708, -15357, -5897, -15286, -6084, -15213,
+ -6270, -15137, -6455, -15059, -6639, -14978, -6823, -14896,
+ -7005, -14811, -7186, -14724, -7366, -14635, -7545, -14543,
+ -7723, -14449, -7900, -14354, -8076, -14256, -8250, -14155,
+ -8423, -14053, -8595, -13949, -8765, -13842, -8935, -13733,
+ -9102, -13623, -9269, -13510, -9434, -13395, -9598, -13279,
+ -9760, -13160, -9921, -13039, -10080, -12916, -10238, -12792,
+ -10394, -12665, -10549, -12537, -10702, -12406, -10853, -12274,
+ -11003, -12140, -11151, -12004, -11297, -11866, -11442, -11727,
+ -11585, -11585, -11727, -11442, -11866, -11297, -12004, -11151,
+ -12140, -11003, -12274, -10853, -12406, -10702, -12537, -10549,
+ -12665, -10394, -12792, -10238, -12916, -10080, -13039, -9921,
+ -13160, -9760, -13279, -9598, -13395, -9434, -13510, -9269,
+ -13623, -9102, -13733, -8935, -13842, -8765, -13949, -8595,
+ -14053, -8423, -14155, -8250, -14256, -8076, -14354, -7900,
+ -14449, -7723, -14543, -7545, -14635, -7366, -14724, -7186,
+ -14811, -7005, -14896, -6823, -14978, -6639, -15059, -6455,
+ -15137, -6270, -15213, -6084, -15286, -5897, -15357, -5708,
+ -15426, -5520, -15493, -5330, -15557, -5139, -15619, -4948,
+ -15679, -4756, -15736, -4563, -15791, -4370, -15843, -4176,
+ -15893, -3981, -15941, -3786, -15986, -3590, -16029, -3393,
+ -16069, -3196, -16107, -2999, -16143, -2801, -16176, -2603,
+ -16207, -2404, -16235, -2205, -16261, -2006, -16284, -1806,
+ -16305, -1606, -16324, -1406, -16340, -1205, -16353, -1005,
+ -16364, -804, -16373, -603, -16379, -402, -16383, -201,
+
+ /* The following is a duplication of the above but scaled up by a factor of 2.
+ * This save one operation in inverse FFT inner loops */
+ 32767, 0, 32766, -402, 32758, -804, 32746, -1206,
+ 32729, -1608, 32706, -2009, 32679, -2411, 32647, -2811,
+ 32610, -3212, 32568, -3612, 32522, -4011, 32470, -4410,
+ 32413, -4808, 32352, -5205, 32286, -5602, 32214, -5998,
+ 32138, -6393, 32058, -6787, 31972, -7180, 31881, -7571,
+ 31786, -7962, 31686, -8351, 31581, -8740, 31471, -9127,
+ 31357, -9512, 31238, -9896, 31114, -10279, 30986, -10660,
+ 30853, -11039, 30715, -11417, 30572, -11793, 30425, -12167,
+ 30274, -12540, 30118, -12910, 29957, -13279, 29792, -13646,
+ 29622, -14010, 29448, -14373, 29269, -14733, 29086, -15091,
+ 28899, -15447, 28707, -15800, 28511, -16151, 28311, -16500,
+ 28106, -16846, 27897, -17190, 27684, -17531, 27467, -17869,
+ 27246, -18205, 27020, -18538, 26791, -18868, 26557, -19195,
+ 26320, -19520, 26078, -19841, 25833, -20160, 25583, -20475,
+ 25330, -20788, 25073, -21097, 24812, -21403, 24548, -21706,
+ 24279, -22006, 24008, -22302, 23732, -22595, 23453, -22884,
+ 23170, -23170, 22884, -23453, 22595, -23732, 22302, -24008,
+ 22006, -24279, 21706, -24548, 21403, -24812, 21097, -25073,
+ 20788, -25330, 20475, -25583, 20160, -25833, 19841, -26078,
+ 19520, -26320, 19195, -26557, 18868, -26791, 18538, -27020,
+ 18205, -27246, 17869, -27467, 17531, -27684, 17190, -27897,
+ 16846, -28106, 16500, -28311, 16151, -28511, 15800, -28707,
+ 15447, -28899, 15091, -29086, 14733, -29269, 14373, -29448,
+ 14010, -29622, 13646, -29792, 13279, -29957, 12910, -30118,
+ 12540, -30274, 12167, -30425, 11793, -30572, 11417, -30715,
+ 11039, -30853, 10660, -30986, 10279, -31114, 9896, -31238,
+ 9512, -31357, 9127, -31471, 8740, -31581, 8351, -31686,
+ 7962, -31786, 7571, -31881, 7180, -31972, 6787, -32058,
+ 6393, -32138, 5998, -32214, 5602, -32286, 5205, -32352,
+ 4808, -32413, 4410, -32470, 4011, -32522, 3612, -32568,
+ 3212, -32610, 2811, -32647, 2411, -32679, 2009, -32706,
+ 1608, -32729, 1206, -32746, 804, -32758, 402, -32766,
+ 0, -32768, -402, -32766, -804, -32758, -1206, -32746,
+ -1608, -32729, -2009, -32706, -2411, -32679, -2811, -32647,
+ -3212, -32610, -3612, -32568, -4011, -32522, -4410, -32470,
+ -4808, -32413, -5205, -32352, -5602, -32286, -5998, -32214,
+ -6393, -32138, -6787, -32058, -7180, -31972, -7571, -31881,
+ -7962, -31786, -8351, -31686, -8740, -31581, -9127, -31471,
+ -9512, -31357, -9896, -31238, -10279, -31114, -10660, -30986,
+ -11039, -30853, -11417, -30715, -11793, -30572, -12167, -30425,
+ -12540, -30274, -12910, -30118, -13279, -29957, -13646, -29792,
+ -14010, -29622, -14373, -29448, -14733, -29269, -15091, -29086,
+ -15447, -28899, -15800, -28707, -16151, -28511, -16500, -28311,
+ -16846, -28106, -17190, -27897, -17531, -27684, -17869, -27467,
+ -18205, -27246, -18538, -27020, -18868, -26791, -19195, -26557,
+ -19520, -26320, -19841, -26078, -20160, -25833, -20475, -25583,
+ -20788, -25330, -21097, -25073, -21403, -24812, -21706, -24548,
+ -22006, -24279, -22302, -24008, -22595, -23732, -22884, -23453,
+ -23170, -23170, -23453, -22884, -23732, -22595, -24008, -22302,
+ -24279, -22006, -24548, -21706, -24812, -21403, -25073, -21097,
+ -25330, -20788, -25583, -20475, -25833, -20160, -26078, -19841,
+ -26320, -19520, -26557, -19195, -26791, -18868, -27020, -18538,
+ -27246, -18205, -27467, -17869, -27684, -17531, -27897, -17190,
+ -28106, -16846, -28311, -16500, -28511, -16151, -28707, -15800,
+ -28899, -15447, -29086, -15091, -29269, -14733, -29448, -14373,
+ -29622, -14010, -29792, -13646, -29957, -13279, -30118, -12910,
+ -30274, -12540, -30425, -12167, -30572, -11793, -30715, -11417,
+ -30853, -11039, -30986, -10660, -31114, -10279, -31238, -9896,
+ -31357, -9512, -31471, -9127, -31581, -8740, -31686, -8351,
+ -31786, -7962, -31881, -7571, -31972, -7180, -32058, -6787,
+ -32138, -6393, -32214, -5998, -32286, -5602, -32352, -5205,
+ -32413, -4808, -32470, -4410, -32522, -4011, -32568, -3612,
+ -32610, -3212, -32647, -2811, -32679, -2411, -32706, -2009,
+ -32729, -1608, -32746, -1206, -32758, -804, -32766, -402
+};
+
+const Word16 FFT_W512[(512*2)*2] =
+{
+ 16384, 0, 16384, -101, 16383, -201, 16381, -302,
+ 16379, -402, 16376, -503, 16373, -603, 16369, -704,
+ 16364, -804, 16359, -904, 16353, -1005, 16347, -1105,
+ 16340, -1205, 16332, -1306, 16324, -1406, 16315, -1506,
+ 16305, -1606, 16295, -1706, 16284, -1806, 16273, -1906,
+ 16261, -2006, 16248, -2105, 16235, -2205, 16221, -2305,
+ 16207, -2404, 16192, -2503, 16176, -2603, 16160, -2702,
+ 16143, -2801, 16125, -2900, 16107, -2999, 16088, -3098,
+ 16069, -3196, 16049, -3295, 16029, -3393, 16008, -3492,
+ 15986, -3590, 15964, -3688, 15941, -3786, 15917, -3883,
+ 15893, -3981, 15868, -4078, 15843, -4176, 15817, -4273,
+ 15791, -4370, 15763, -4467, 15736, -4563, 15707, -4660,
+ 15679, -4756, 15649, -4852, 15619, -4948, 15588, -5044,
+ 15557, -5139, 15525, -5235, 15493, -5330, 15460, -5425,
+ 15426, -5520, 15392, -5614, 15357, -5708, 15322, -5803,
+ 15286, -5897, 15250, -5990, 15213, -6084, 15175, -6177,
+ 15137, -6270, 15098, -6363, 15059, -6455, 15019, -6547,
+ 14978, -6639, 14937, -6731, 14896, -6823, 14854, -6914,
+ 14811, -7005, 14768, -7096, 14724, -7186, 14680, -7276,
+ 14635, -7366, 14589, -7456, 14543, -7545, 14497, -7635,
+ 14449, -7723, 14402, -7812, 14354, -7900, 14305, -7988,
+ 14256, -8076, 14206, -8163, 14155, -8250, 14104, -8337,
+ 14053, -8423, 14001, -8509, 13949, -8595, 13896, -8680,
+ 13842, -8765, 13788, -8850, 13733, -8935, 13678, -9019,
+ 13623, -9102, 13567, -9186, 13510, -9269, 13453, -9352,
+ 13395, -9434, 13337, -9516, 13279, -9598, 13219, -9679,
+ 13160, -9760, 13100, -9841, 13039, -9921, 12978, -10001,
+ 12916, -10080, 12854, -10159, 12792, -10238, 12729, -10316,
+ 12665, -10394, 12601, -10471, 12537, -10549, 12472, -10625,
+ 12406, -10702, 12340, -10778, 12274, -10853, 12207, -10928,
+ 12140, -11003, 12072, -11077, 12004, -11151, 11935, -11224,
+ 11866, -11297, 11797, -11370, 11727, -11442, 11656, -11514,
+ 11585, -11585, 11514, -11656, 11442, -11727, 11370, -11797,
+ 11297, -11866, 11224, -11935, 11151, -12004, 11077, -12072,
+ 11003, -12140, 10928, -12207, 10853, -12274, 10778, -12340,
+ 10702, -12406, 10625, -12472, 10549, -12537, 10471, -12601,
+ 10394, -12665, 10316, -12729, 10238, -12792, 10159, -12854,
+ 10080, -12916, 10001, -12978, 9921, -13039, 9841, -13100,
+ 9760, -13160, 9679, -13219, 9598, -13279, 9516, -13337,
+ 9434, -13395, 9352, -13453, 9269, -13510, 9186, -13567,
+ 9102, -13623, 9019, -13678, 8935, -13733, 8850, -13788,
+ 8765, -13842, 8680, -13896, 8595, -13949, 8509, -14001,
+ 8423, -14053, 8337, -14104, 8250, -14155, 8163, -14206,
+ 8076, -14256, 7988, -14305, 7900, -14354, 7812, -14402,
+ 7723, -14449, 7635, -14497, 7545, -14543, 7456, -14589,
+ 7366, -14635, 7276, -14680, 7186, -14724, 7096, -14768,
+ 7005, -14811, 6914, -14854, 6823, -14896, 6731, -14937,
+ 6639, -14978, 6547, -15019, 6455, -15059, 6363, -15098,
+ 6270, -15137, 6177, -15175, 6084, -15213, 5990, -15250,
+ 5897, -15286, 5803, -15322, 5708, -15357, 5614, -15392,
+ 5520, -15426, 5425, -15460, 5330, -15493, 5235, -15525,
+ 5139, -15557, 5044, -15588, 4948, -15619, 4852, -15649,
+ 4756, -15679, 4660, -15707, 4563, -15736, 4467, -15763,
+ 4370, -15791, 4273, -15817, 4176, -15843, 4078, -15868,
+ 3981, -15893, 3883, -15917, 3786, -15941, 3688, -15964,
+ 3590, -15986, 3492, -16008, 3393, -16029, 3295, -16049,
+ 3196, -16069, 3098, -16088, 2999, -16107, 2900, -16125,
+ 2801, -16143, 2702, -16160, 2603, -16176, 2503, -16192,
+ 2404, -16207, 2305, -16221, 2205, -16235, 2105, -16248,
+ 2006, -16261, 1906, -16273, 1806, -16284, 1706, -16295,
+ 1606, -16305, 1506, -16315, 1406, -16324, 1306, -16332,
+ 1205, -16340, 1105, -16347, 1005, -16353, 904, -16359,
+ 804, -16364, 703, -16369, 603, -16373, 503, -16376,
+ 402, -16379, 302, -16381, 201, -16383, 101, -16384,
+ 0, -16384, -101, -16384, -201, -16383, -302, -16381,
+ -402, -16379, -503, -16376, -603, -16373, -704, -16369,
+ -804, -16364, -904, -16359, -1005, -16353, -1105, -16347,
+ -1205, -16340, -1306, -16332, -1406, -16324, -1506, -16315,
+ -1606, -16305, -1706, -16295, -1806, -16284, -1906, -16273,
+ -2006, -16261, -2105, -16248, -2205, -16235, -2305, -16221,
+ -2404, -16207, -2503, -16192, -2603, -16176, -2702, -16160,
+ -2801, -16143, -2900, -16125, -2999, -16107, -3098, -16088,
+ -3196, -16069, -3295, -16049, -3393, -16029, -3492, -16008,
+ -3590, -15986, -3688, -15964, -3786, -15941, -3883, -15917,
+ -3981, -15893, -4078, -15868, -4176, -15843, -4273, -15817,
+ -4370, -15791, -4467, -15763, -4563, -15736, -4660, -15707,
+ -4756, -15679, -4852, -15649, -4948, -15619, -5044, -15588,
+ -5139, -15557, -5235, -15525, -5330, -15493, -5425, -15460,
+ -5520, -15426, -5614, -15392, -5708, -15357, -5803, -15322,
+ -5897, -15286, -5990, -15250, -6084, -15213, -6177, -15175,
+ -6270, -15137, -6363, -15098, -6455, -15059, -6547, -15019,
+ -6639, -14978, -6731, -14937, -6823, -14896, -6914, -14854,
+ -7005, -14811, -7096, -14768, -7186, -14724, -7276, -14680,
+ -7366, -14635, -7456, -14589, -7545, -14543, -7635, -14497,
+ -7723, -14449, -7812, -14402, -7900, -14354, -7988, -14305,
+ -8076, -14256, -8163, -14206, -8250, -14155, -8337, -14104,
+ -8423, -14053, -8509, -14001, -8595, -13949, -8680, -13896,
+ -8765, -13842, -8850, -13788, -8935, -13733, -9019, -13678,
+ -9102, -13623, -9186, -13567, -9269, -13510, -9352, -13453,
+ -9434, -13395, -9516, -13337, -9598, -13279, -9679, -13219,
+ -9760, -13160, -9841, -13100, -9921, -13039, -10001, -12978,
+ -10080, -12916, -10159, -12854, -10238, -12792, -10316, -12729,
+ -10394, -12665, -10471, -12601, -10549, -12537, -10625, -12472,
+ -10702, -12406, -10778, -12340, -10853, -12274, -10928, -12207,
+ -11003, -12140, -11077, -12072, -11151, -12004, -11224, -11935,
+ -11297, -11866, -11370, -11797, -11442, -11727, -11514, -11656,
+ -11585, -11585, -11656, -11514, -11727, -11442, -11797, -11370,
+ -11866, -11297, -11935, -11224, -12004, -11151, -12072, -11077,
+ -12140, -11003, -12207, -10928, -12274, -10853, -12340, -10778,
+ -12406, -10702, -12472, -10625, -12537, -10549, -12601, -10471,
+ -12665, -10394, -12729, -10316, -12792, -10238, -12854, -10159,
+ -12916, -10080, -12978, -10001, -13039, -9921, -13100, -9840,
+ -13160, -9760, -13219, -9679, -13279, -9598, -13337, -9516,
+ -13395, -9434, -13453, -9352, -13510, -9269, -13567, -9186,
+ -13623, -9102, -13678, -9019, -13733, -8935, -13788, -8850,
+ -13842, -8765, -13896, -8680, -13949, -8595, -14001, -8509,
+ -14053, -8423, -14104, -8337, -14155, -8250, -14206, -8163,
+ -14256, -8076, -14305, -7988, -14354, -7900, -14402, -7812,
+ -14449, -7723, -14497, -7635, -14543, -7545, -14589, -7456,
+ -14635, -7366, -14680, -7276, -14724, -7186, -14768, -7096,
+ -14811, -7005, -14854, -6914, -14896, -6823, -14937, -6731,
+ -14978, -6639, -15019, -6547, -15059, -6455, -15098, -6363,
+ -15137, -6270, -15175, -6177, -15213, -6084, -15250, -5990,
+ -15286, -5897, -15322, -5803, -15357, -5708, -15392, -5614,
+ -15426, -5520, -15460, -5425, -15493, -5330, -15525, -5235,
+ -15557, -5139, -15588, -5044, -15619, -4948, -15649, -4852,
+ -15679, -4756, -15707, -4660, -15736, -4563, -15763, -4467,
+ -15791, -4370, -15817, -4273, -15843, -4176, -15868, -4078,
+ -15893, -3981, -15917, -3883, -15941, -3786, -15964, -3688,
+ -15986, -3590, -16008, -3492, -16029, -3393, -16049, -3295,
+ -16069, -3196, -16088, -3098, -16107, -2999, -16125, -2900,
+ -16143, -2801, -16160, -2702, -16176, -2603, -16192, -2503,
+ -16207, -2404, -16221, -2305, -16235, -2205, -16248, -2105,
+ -16261, -2006, -16273, -1906, -16284, -1806, -16295, -1706,
+ -16305, -1606, -16315, -1506, -16324, -1406, -16332, -1306,
+ -16340, -1205, -16347, -1105, -16353, -1005, -16359, -904,
+ -16364, -804, -16369, -703, -16373, -603, -16376, -503,
+ -16379, -402, -16381, -302, -16383, -201, -16384, -101,
+ /* The following is a duplication of the above but scaled up by a factor of 2.
+ * This save one operation in inverse FFT inner loops */
+ 32767, 0, 32767, -201, 32766, -402, 32762, -603,
+ 32758, -804, 32753, -1005, 32746, -1206, 32738, -1407,
+ 32729, -1608, 32718, -1809, 32706, -2009, 32693, -2210,
+ 32679, -2411, 32664, -2611, 32647, -2811, 32629, -3012,
+ 32610, -3212, 32590, -3412, 32568, -3612, 32546, -3812,
+ 32522, -4011, 32496, -4211, 32470, -4410, 32442, -4609,
+ 32413, -4808, 32383, -5007, 32352, -5205, 32319, -5404,
+ 32286, -5602, 32251, -5800, 32214, -5998, 32177, -6195,
+ 32138, -6393, 32099, -6590, 32058, -6787, 32015, -6983,
+ 31972, -7180, 31927, -7376, 31881, -7571, 31834, -7767,
+ 31786, -7962, 31737, -8157, 31686, -8351, 31634, -8546,
+ 31581, -8740, 31527, -8933, 31471, -9127, 31415, -9319,
+ 31357, -9512, 31298, -9704, 31238, -9896, 31177, -10088,
+ 31114, -10279, 31050, -10469, 30986, -10660, 30920, -10850,
+ 30853, -11039, 30784, -11228, 30715, -11417, 30644, -11605,
+ 30572, -11793, 30499, -11980, 30425, -12167, 30350, -12354,
+ 30274, -12540, 30196, -12725, 30118, -12910, 30038, -13095,
+ 29957, -13279, 29875, -13463, 29792, -13646, 29707, -13828,
+ 29622, -14010, 29535, -14192, 29448, -14373, 29359, -14553,
+ 29269, -14733, 29178, -14912, 29086, -15091, 28993, -15269,
+ 28899, -15447, 28803, -15624, 28707, -15800, 28610, -15976,
+ 28511, -16151, 28411, -16326, 28311, -16500, 28209, -16673,
+ 28106, -16846, 28002, -17018, 27897, -17190, 27791, -17361,
+ 27684, -17531, 27576, -17700, 27467, -17869, 27357, -18037,
+ 27246, -18205, 27133, -18372, 27020, -18538, 26906, -18703,
+ 26791, -18868, 26674, -19032, 26557, -19195, 26439, -19358,
+ 26320, -19520, 26199, -19681, 26078, -19841, 25956, -20001,
+ 25833, -20160, 25708, -20318, 25583, -20475, 25457, -20632,
+ 25330, -20788, 25202, -20943, 25073, -21097, 24943, -21251,
+ 24812, -21403, 24680, -21555, 24548, -21706, 24414, -21856,
+ 24279, -22006, 24144, -22154, 24008, -22302, 23870, -22449,
+ 23732, -22595, 23593, -22740, 23453, -22884, 23312, -23028,
+ 23170, -23170, 23028, -23312, 22884, -23453, 22740, -23593,
+ 22595, -23732, 22449, -23870, 22302, -24008, 22154, -24144,
+ 22006, -24279, 21856, -24414, 21706, -24548, 21555, -24680,
+ 21403, -24812, 21251, -24943, 21097, -25073, 20943, -25202,
+ 20788, -25330, 20632, -25457, 20475, -25583, 20318, -25708,
+ 20160, -25833, 20001, -25956, 19841, -26078, 19681, -26199,
+ 19520, -26320, 19358, -26439, 19195, -26557, 19032, -26674,
+ 18868, -26791, 18703, -26906, 18538, -27020, 18372, -27133,
+ 18205, -27246, 18037, -27357, 17869, -27467, 17700, -27576,
+ 17531, -27684, 17361, -27791, 17190, -27897, 17018, -28002,
+ 16846, -28106, 16673, -28209, 16500, -28311, 16326, -28411,
+ 16151, -28511, 15976, -28610, 15800, -28707, 15624, -28803,
+ 15447, -28899, 15269, -28993, 15091, -29086, 14912, -29178,
+ 14733, -29269, 14553, -29359, 14373, -29448, 14192, -29535,
+ 14010, -29622, 13828, -29707, 13646, -29792, 13463, -29875,
+ 13279, -29957, 13095, -30038, 12910, -30118, 12725, -30196,
+ 12540, -30274, 12354, -30350, 12167, -30425, 11980, -30499,
+ 11793, -30572, 11605, -30644, 11417, -30715, 11228, -30784,
+ 11039, -30853, 10850, -30920, 10660, -30986, 10469, -31050,
+ 10279, -31114, 10088, -31177, 9896, -31238, 9704, -31298,
+ 9512, -31357, 9319, -31415, 9127, -31471, 8933, -31527,
+ 8740, -31581, 8546, -31634, 8351, -31686, 8157, -31737,
+ 7962, -31786, 7767, -31834, 7571, -31881, 7376, -31927,
+ 7180, -31972, 6983, -32015, 6787, -32058, 6590, -32099,
+ 6393, -32138, 6195, -32177, 5998, -32214, 5800, -32251,
+ 5602, -32286, 5404, -32319, 5205, -32352, 5007, -32383,
+ 4808, -32413, 4609, -32442, 4410, -32470, 4211, -32496,
+ 4011, -32522, 3812, -32546, 3612, -32568, 3412, -32590,
+ 3212, -32610, 3012, -32629, 2811, -32647, 2611, -32664,
+ 2411, -32679, 2210, -32693, 2009, -32706, 1809, -32718,
+ 1608, -32729, 1407, -32738, 1206, -32746, 1005, -32753,
+ 804, -32758, 603, -32762, 402, -32766, 201, -32767,
+ 0, -32768, -201, -32767, -402, -32766, -603, -32762,
+ -804, -32758, -1005, -32753, -1206, -32746, -1407, -32738,
+ -1608, -32729, -1809, -32718, -2009, -32706, -2210, -32693,
+ -2411, -32679, -2611, -32664, -2811, -32647, -3012, -32629,
+ -3212, -32610, -3412, -32590, -3612, -32568, -3812, -32546,
+ -4011, -32522, -4211, -32496, -4410, -32470, -4609, -32442,
+ -4808, -32413, -5007, -32383, -5205, -32352, -5404, -32319,
+ -5602, -32286, -5800, -32251, -5998, -32214, -6195, -32177,
+ -6393, -32138, -6590, -32099, -6787, -32058, -6983, -32015,
+ -7180, -31972, -7376, -31927, -7571, -31881, -7767, -31834,
+ -7962, -31786, -8157, -31737, -8351, -31686, -8546, -31634,
+ -8740, -31581, -8933, -31527, -9127, -31471, -9319, -31415,
+ -9512, -31357, -9704, -31298, -9896, -31238, -10088, -31177,
+ -10279, -31114, -10469, -31050, -10660, -30986, -10850, -30920,
+ -11039, -30853, -11228, -30784, -11417, -30715, -11605, -30644,
+ -11793, -30572, -11980, -30499, -12167, -30425, -12354, -30350,
+ -12540, -30274, -12725, -30196, -12910, -30118, -13095, -30038,
+ -13279, -29957, -13463, -29875, -13646, -29792, -13828, -29707,
+ -14010, -29622, -14192, -29535, -14373, -29448, -14553, -29359,
+ -14733, -29269, -14912, -29178, -15091, -29086, -15269, -28993,
+ -15447, -28899, -15624, -28803, -15800, -28707, -15976, -28610,
+ -16151, -28511, -16326, -28411, -16500, -28311, -16673, -28209,
+ -16846, -28106, -17018, -28002, -17190, -27897, -17361, -27791,
+ -17531, -27684, -17700, -27576, -17869, -27467, -18037, -27357,
+ -18205, -27246, -18372, -27133, -18538, -27020, -18703, -26906,
+ -18868, -26791, -19032, -26674, -19195, -26557, -19358, -26439,
+ -19520, -26320, -19681, -26199, -19841, -26078, -20001, -25956,
+ -20160, -25833, -20318, -25708, -20475, -25583, -20632, -25457,
+ -20788, -25330, -20943, -25202, -21097, -25073, -21251, -24943,
+ -21403, -24812, -21555, -24680, -21706, -24548, -21856, -24414,
+ -22006, -24279, -22154, -24144, -22302, -24008, -22449, -23870,
+ -22595, -23732, -22740, -23593, -22884, -23453, -23028, -23312,
+ -23170, -23170, -23312, -23028, -23453, -22884, -23593, -22740,
+ -23732, -22595, -23870, -22449, -24008, -22302, -24144, -22154,
+ -24279, -22006, -24414, -21856, -24548, -21706, -24680, -21555,
+ -24812, -21403, -24943, -21251, -25073, -21097, -25202, -20943,
+ -25330, -20788, -25457, -20632, -25583, -20475, -25708, -20318,
+ -25833, -20160, -25956, -20001, -26078, -19841, -26199, -19681,
+ -26320, -19520, -26439, -19358, -26557, -19195, -26674, -19032,
+ -26791, -18868, -26906, -18703, -27020, -18538, -27133, -18372,
+ -27246, -18205, -27357, -18037, -27467, -17869, -27576, -17700,
+ -27684, -17531, -27791, -17361, -27897, -17190, -28002, -17018,
+ -28106, -16846, -28209, -16673, -28311, -16500, -28411, -16326,
+ -28511, -16151, -28610, -15976, -28707, -15800, -28803, -15624,
+ -28899, -15447, -28993, -15269, -29086, -15091, -29178, -14912,
+ -29269, -14733, -29359, -14553, -29448, -14373, -29535, -14192,
+ -29622, -14010, -29707, -13828, -29792, -13646, -29875, -13463,
+ -29957, -13279, -30038, -13095, -30118, -12910, -30196, -12725,
+ -30274, -12540, -30350, -12354, -30425, -12167, -30499, -11980,
+ -30572, -11793, -30644, -11605, -30715, -11417, -30784, -11228,
+ -30853, -11039, -30920, -10850, -30986, -10660, -31050, -10469,
+ -31114, -10279, -31177, -10088, -31238, -9896, -31298, -9704,
+ -31357, -9512, -31415, -9319, -31471, -9127, -31527, -8933,
+ -31581, -8740, -31634, -8546, -31686, -8351, -31737, -8157,
+ -31786, -7962, -31834, -7767, -31881, -7571, -31927, -7376,
+ -31972, -7180, -32015, -6983, -32058, -6787, -32099, -6590,
+ -32138, -6393, -32177, -6195, -32214, -5998, -32251, -5800,
+ -32286, -5602, -32319, -5404, -32352, -5205, -32383, -5007,
+ -32413, -4808, -32442, -4609, -32470, -4410, -32496, -4211,
+ -32522, -4011, -32546, -3812, -32568, -3612, -32590, -3412,
+ -32610, -3212, -32629, -3012, -32647, -2811, -32664, -2611,
+ -32679, -2411, -32693, -2210, -32706, -2009, -32718, -1809,
+ -32729, -1608, -32738, -1407, -32746, -1206, -32753, -1005,
+ -32758, -804, -32762, -603, -32766, -402, -32767, -201
+};
+
+const Word16 sincos_t_rad3_fx[T_SIN_PI_2+1] =
+{
+ 0, 134, 268, 402, 536, 670, 804, 938,
+ 1072, 1206, 1340, 1474, 1608, 1742, 1876, 2009,
+ 2143, 2277, 2411, 2544, 2678, 2811, 2945, 3078,
+ 3212, 3345, 3479, 3612, 3745, 3878, 4011, 4144,
+ 4277, 4410, 4543, 4675, 4808, 4941, 5073, 5205,
+ 5338, 5470, 5602, 5734, 5866, 5998, 6130, 6261,
+ 6393, 6524, 6655, 6787, 6918, 7049, 7180, 7310,
+ 7441, 7571, 7702, 7832, 7962, 8092, 8222, 8351,
+ 8481, 8610, 8740, 8869, 8998, 9127, 9255, 9384,
+ 9512, 9640, 9768, 9896, 10024, 10151, 10279, 10406,
+ 10533, 10660, 10786, 10913, 11039, 11165, 11291, 11417,
+ 11543, 11668, 11793, 11918, 12043, 12167, 12292, 12416,
+ 12540, 12664, 12787, 12910, 13033, 13156, 13279, 13401,
+ 13524, 13646, 13767, 13889, 14010, 14131, 14252, 14373,
+ 14493, 14613, 14733, 14852, 14972, 15091, 15210, 15328,
+ 15447, 15565, 15683, 15800, 15917, 16035, 16151, 16268,
+ 16384, 16500, 16616, 16731, 16846, 16961, 17075, 17190,
+ 17304, 17417, 17531, 17644, 17757, 17869, 17981, 18093,
+ 18205, 18316, 18427, 18538, 18648, 18758, 18868, 18978,
+ 19087, 19195, 19304, 19412, 19520, 19627, 19735, 19841,
+ 19948, 20054, 20160, 20265, 20371, 20475, 20580, 20684,
+ 20788, 20891, 20994, 21097, 21199, 21301, 21403, 21504,
+ 21605, 21706, 21806, 21906, 22006, 22105, 22204, 22302,
+ 22400, 22498, 22595, 22692, 22788, 22884, 22980, 23076,
+ 23170, 23265, 23359, 23453, 23546, 23640, 23732, 23824,
+ 23916, 24008, 24099, 24189, 24279, 24369, 24459, 24548,
+ 24636, 24724, 24812, 24900, 24986, 25073, 25159, 25245,
+ 25330, 25415, 25499, 25583, 25667, 25750, 25833, 25915,
+ 25997, 26078, 26159, 26239, 26320, 26399, 26478, 26557,
+ 26635, 26713, 26791, 26868, 26944, 27020, 27096, 27171,
+ 27246, 27320, 27394, 27467, 27540, 27612, 27684, 27756,
+ 27827, 27897, 27967, 28037, 28106, 28175, 28243, 28311,
+ 28378, 28445, 28511, 28577, 28642, 28707, 28771, 28835,
+ 28899, 28962, 29024, 29086, 29148, 29209, 29269, 29329,
+ 29389, 29448, 29506, 29564, 29622, 29679, 29736, 29792,
+ 29847, 29902, 29957, 30011, 30064, 30118, 30170, 30222,
+ 30274, 30325, 30375, 30425, 30475, 30524, 30572, 30620,
+ 30668, 30715, 30761, 30807, 30853, 30897, 30942, 30986,
+ 31029, 31072, 31114, 31156, 31197, 31238, 31278, 31318,
+ 31357, 31396, 31434, 31471, 31508, 31545, 31581, 31617,
+ 31651, 31686, 31720, 31753, 31786, 31818, 31850, 31881,
+ 31912, 31942, 31972, 32001, 32029, 32058, 32085, 32112,
+ 32138, 32164, 32190, 32214, 32239, 32262, 32286, 32308,
+ 32330, 32352, 32373, 32393, 32413, 32433, 32452, 32470,
+ 32488, 32505, 32522, 32538, 32553, 32568, 32583, 32597,
+ 32610, 32623, 32635, 32647, 32658, 32669, 32679, 32689,
+ 32698, 32706, 32714, 32722, 32729, 32735, 32741, 32746,
+ 32750, 32755, 32758, 32761, 32764, 32766, 32767, 32767,
+ 32767
+};
+
+/*----------------------------------------------------------------------------------*
+ * Sine & Cosine - table for the FFT and IFFT of 1024 points, value range [0 ... sin(-5pi/4)]
+ * dimension of the table = 641=4*256*(5/8)+1
+ *----------------------------------------------------------------------------------*/
+/* every 4th value is identical to sincos_t above, (but sincos_t is also used by swb_tbe_com) a separate table is used */
+const Word16 sincos_t_ext_fx[641] =
+{
+ 0, 201, 402, 603, 804, 1005, 1206, 1407,
+ 1608, 1809, 2009, 2210, 2411, 2611, 2811, 3012,
+ 3212, 3412, 3612, 3812, 4011, 4211, 4410, 4609,
+ 4808, 5007, 5205, 5404, 5602, 5800, 5998, 6195,
+ 6393, 6590, 6787, 6983, 7180, 7376, 7571, 7767,
+ 7962, 8157, 8351, 8546, 8740, 8933, 9127, 9319,
+ 9512, 9704, 9896, 10088, 10279, 10469, 10660, 10850,
+ 11039, 11228, 11417, 11605, 11793, 11980, 12167, 12354,
+ 12540, 12725, 12910, 13095, 13279, 13463, 13646, 13828,
+ 14010, 14192, 14373, 14553, 14733, 14912, 15091, 15269,
+ 15447, 15624, 15800, 15976, 16151, 16326, 16500, 16673,
+ 16846, 17018, 17190, 17361, 17531, 17700, 17869, 18037,
+ 18205, 18372, 18538, 18703, 18868, 19032, 19195, 19358,
+ 19520, 19681, 19841, 20001, 20160, 20318, 20475, 20632,
+ 20788, 20943, 21097, 21251, 21403, 21555, 21706, 21856,
+ 22006, 22154, 22302, 22449, 22595, 22740, 22884, 23028,
+ 23170, 23312, 23453, 23593, 23732, 23870, 24008, 24144,
+ 24279, 24414, 24548, 24680, 24812, 24943, 25073, 25202,
+ 25330, 25457, 25583, 25708, 25833, 25956, 26078, 26199,
+ 26320, 26439, 26557, 26674, 26791, 26906, 27020, 27133,
+ 27246, 27357, 27467, 27576, 27684, 27791, 27897, 28002,
+ 28106, 28209, 28311, 28411, 28511, 28610, 28707, 28803,
+ 28899, 28993, 29086, 29178, 29269, 29359, 29448, 29535,
+ 29622, 29707, 29792, 29875, 29957, 30038, 30118, 30196,
+ 30274, 30350, 30425, 30499, 30572, 30644, 30715, 30784,
+ 30853, 30920, 30986, 31050, 31114, 31177, 31238, 31298,
+ 31357, 31415, 31471, 31527, 31581, 31634, 31686, 31737,
+ 31786, 31834, 31881, 31927, 31972, 32015, 32058, 32099,
+ 32138, 32177, 32214, 32251, 32286, 32319, 32352, 32383,
+ 32413, 32442, 32470, 32496, 32522, 32546, 32568, 32590,
+ 32610, 32629, 32647, 32664, 32679, 32693, 32706, 32718,
+ 32729, 32738, 32746, 32753, 32758, 32762, 32766, 32767,
+ 32767, 32767, 32766, 32762, 32758, 32753, 32746, 32738,
+ 32729, 32718, 32706, 32693, 32679, 32664, 32647, 32629,
+ 32610, 32590, 32568, 32546, 32522, 32496, 32470, 32442,
+ 32413, 32383, 32352, 32319, 32286, 32251, 32214, 32177,
+ 32138, 32099, 32058, 32015, 31972, 31927, 31881, 31834,
+ 31786, 31737, 31686, 31634, 31581, 31527, 31471, 31415,
+ 31357, 31298, 31238, 31177, 31114, 31050, 30986, 30920,
+ 30853, 30784, 30715, 30644, 30572, 30499, 30425, 30350,
+ 30274, 30196, 30118, 30038, 29957, 29875, 29792, 29707,
+ 29622, 29535, 29448, 29359, 29269, 29178, 29086, 28993,
+ 28899, 28803, 28707, 28610, 28511, 28411, 28311, 28209,
+ 28106, 28002, 27897, 27791, 27684, 27576, 27467, 27357,
+ 27246, 27133, 27020, 26906, 26791, 26674, 26557, 26439,
+ 26320, 26199, 26078, 25956, 25833, 25708, 25583, 25457,
+ 25330, 25202, 25073, 24943, 24812, 24680, 24548, 24414,
+ 24279, 24144, 24008, 23870, 23732, 23593, 23453, 23312,
+ 23170, 23028, 22884, 22740, 22595, 22449, 22302, 22154,
+ 22006, 21856, 21706, 21555, 21403, 21251, 21097, 20943,
+ 20788, 20632, 20475, 20318, 20160, 20001, 19841, 19681,
+ 19520, 19358, 19195, 19032, 18868, 18703, 18538, 18372,
+ 18205, 18037, 17869, 17700, 17531, 17361, 17190, 17018,
+ 16846, 16673, 16500, 16326, 16151, 15976, 15800, 15624,
+ 15447, 15269, 15091, 14912, 14733, 14553, 14373, 14192,
+ 14010, 13828, 13646, 13463, 13279, 13095, 12910, 12725,
+ 12540, 12354, 12167, 11980, 11793, 11605, 11417, 11228,
+ 11039, 10850, 10660, 10469, 10279, 10088, 9896, 9704,
+ 9512, 9319, 9127, 8933, 8740, 8546, 8351, 8157,
+ 7962, 7767, 7571, 7376, 7180, 6983, 6787, 6590,
+ 6393, 6195, 5998, 5800, 5602, 5404, 5205, 5007,
+ 4808, 4609, 4410, 4211, 4011, 3812, 3612, 3412,
+ 3212, 3012, 2811, 2611, 2411, 2210, 2009, 1809,
+ 1608, 1407, 1206, 1005, 804, 603, 402, 201,
+ 0, -201, -402, -603, -804, -1005, -1206, -1407,
+ -1608, -1809, -2009, -2210, -2411, -2611, -2811, -3012,
+ -3212, -3412, -3612, -3812, -4011, -4211, -4410, -4609,
+ -4808, -5007, -5205, -5404, -5602, -5800, -5998, -6195,
+ -6393, -6590, -6787, -6983, -7180, -7376, -7571, -7767,
+ -7962, -8157, -8351, -8546, -8740, -8933, -9127, -9319,
+ -9512, -9704, -9896, -10088, -10279, -10469, -10660, -10850,
+ -11039, -11228, -11417, -11605, -11793, -11980, -12167, -12354,
+ -12540, -12725, -12910, -13095, -13279, -13463, -13646, -13828,
+ -14010, -14192, -14373, -14553, -14733, -14912, -15091, -15269,
+ -15447, -15624, -15800, -15976, -16151, -16326, -16500, -16673,
+ -16846, -17018, -17190, -17361, -17531, -17700, -17869, -18037,
+ -18205, -18372, -18538, -18703, -18868, -19032, -19195, -19358,
+ -19520, -19681, -19841, -20001, -20160, -20318, -20475, -20632,
+ -20788, -20943, -21097, -21251, -21403, -21555, -21706, -21856,
+ -22006, -22154, -22302, -22449, -22595, -22740, -22884, -23028,
+ -23028
+};
+
+
+
+
+const Word16 FFT_REORDER_1024[512] =
+{
+ 0, 512, 256, 768, 128, 640, 384, 896,
+ 64, 576, 320, 832, 192, 704, 448, 960,
+ 32, 544, 288, 800, 160, 672, 416, 928,
+ 96, 608, 352, 864, 224, 736, 480, 992,
+ 16, 528, 272, 784, 144, 656, 400, 912,
+ 80, 592, 336, 848, 208, 720, 464, 976,
+ 48, 560, 304, 816, 176, 688, 432, 944,
+ 112, 624, 368, 880, 240, 752, 496, 1008,
+ 8, 520, 264, 776, 136, 648, 392, 904,
+ 72, 584, 328, 840, 200, 712, 456, 968,
+ 40, 552, 296, 808, 168, 680, 424, 936,
+ 104, 616, 360, 872, 232, 744, 488, 1000,
+ 24, 536, 280, 792, 152, 664, 408, 920,
+ 88, 600, 344, 856, 216, 728, 472, 984,
+ 56, 568, 312, 824, 184, 696, 440, 952,
+ 120, 632, 376, 888, 248, 760, 504, 1016,
+ 4, 516, 260, 772, 132, 644, 388, 900,
+ 68, 580, 324, 836, 196, 708, 452, 964,
+ 36, 548, 292, 804, 164, 676, 420, 932,
+ 100, 612, 356, 868, 228, 740, 484, 996,
+ 20, 532, 276, 788, 148, 660, 404, 916,
+ 84, 596, 340, 852, 212, 724, 468, 980,
+ 52, 564, 308, 820, 180, 692, 436, 948,
+ 116, 628, 372, 884, 244, 756, 500, 1012,
+ 12, 524, 268, 780, 140, 652, 396, 908,
+ 76, 588, 332, 844, 204, 716, 460, 972,
+ 44, 556, 300, 812, 172, 684, 428, 940,
+ 108, 620, 364, 876, 236, 748, 492, 1004,
+ 28, 540, 284, 796, 156, 668, 412, 924,
+ 92, 604, 348, 860, 220, 732, 476, 988,
+ 60, 572, 316, 828, 188, 700, 444, 956,
+ 124, 636, 380, 892, 252, 764, 508, 1020,
+ 2, 514, 258, 770, 130, 642, 386, 898,
+ 66, 578, 322, 834, 194, 706, 450, 962,
+ 34, 546, 290, 802, 162, 674, 418, 930,
+ 98, 610, 354, 866, 226, 738, 482, 994,
+ 18, 530, 274, 786, 146, 658, 402, 914,
+ 82, 594, 338, 850, 210, 722, 466, 978,
+ 50, 562, 306, 818, 178, 690, 434, 946,
+ 114, 626, 370, 882, 242, 754, 498, 1010,
+ 10, 522, 266, 778, 138, 650, 394, 906,
+ 74, 586, 330, 842, 202, 714, 458, 970,
+ 42, 554, 298, 810, 170, 682, 426, 938,
+ 106, 618, 362, 874, 234, 746, 490, 1002,
+ 26, 538, 282, 794, 154, 666, 410, 922,
+ 90, 602, 346, 858, 218, 730, 474, 986,
+ 58, 570, 314, 826, 186, 698, 442, 954,
+ 122, 634, 378, 890, 250, 762, 506, 1018,
+ 6, 518, 262, 774, 134, 646, 390, 902,
+ 70, 582, 326, 838, 198, 710, 454, 966,
+ 38, 550, 294, 806, 166, 678, 422, 934,
+ 102, 614, 358, 870, 230, 742, 486, 998,
+ 22, 534, 278, 790, 150, 662, 406, 918,
+ 86, 598, 342, 854, 214, 726, 470, 982,
+ 54, 566, 310, 822, 182, 694, 438, 950,
+ 118, 630, 374, 886, 246, 758, 502, 1014,
+ 14, 526, 270, 782, 142, 654, 398, 910,
+ 78, 590, 334, 846, 206, 718, 462, 974,
+ 46, 558, 302, 814, 174, 686, 430, 942,
+ 110, 622, 366, 878, 238, 750, 494, 1006,
+ 30, 542, 286, 798, 158, 670, 414, 926,
+ 94, 606, 350, 862, 222, 734, 478, 990,
+ 62, 574, 318, 830, 190, 702, 446, 958,
+ 126, 638, 382, 894, 254, 766, 510, 1022
+};
+
+const Word16 Gamma_19661_Tbl_fx[] =
+{
+ 19661, 11797, 7078, 4247, 2548, 1529, 917, 550, 330, 198, 119, 71, 43, 26, 16, 10
+};/*Q15 */
+
+/*-----------------------------------------------------------------*
+ * Transition coding - gain quantization table for g_trans
+ *-----------------------------------------------------------------*/
+const Word16 tbl_gain_trans_tc_fx[N_GAIN_TC] =
+{
+ 4588, 11109, 19212, 29862,/*<- Q7
+Q4 ->*/ 5536, 8184, 13115, 24000
+};
+/*-----------------------------------------------------------------*
+ * Transition coding - table of prototype glottal impulses
+ *-----------------------------------------------------------------*/
+const Word16 Glottal_cdbk_fx[L_IMPULSE*NUM_IMPULSE] = /*Q13*/
+{
+ /* impulse 0 */
+ -715, -1690, -2903, -1742, -1295, -4266,
+ -4893, 1725, 8192, 5812, -628, -1956,
+ 581, 936, -81, 831, 1517,
+
+ /* impulse 1 */
+ -2168, -1356, -404, -2715, -4469, -2164,
+ -2180, -8058, -9140, 1163, 10343, 6677,
+ -1758, -2839, 377, 326, -490,
+
+ /* impulse 2 */
+ 360, 561, 4184, 2533, -3326, -2549,
+ 2059, -2112, -9542, -6134, 1307, 124,
+ -3421, -1465, 475, -886, -1262,
+
+ /* impulse 3 */
+ -1294, -715, -184, -1544, -1638, -219,
+ -3503, -9409, -7955, -1407, -285, -2494,
+ 305, 4658, 3289, 116, 1488,
+
+ /* impulse 4 */
+ 837, 2523, 2444, 2679, 5962, 6935,
+ -924, -9907, -7565, 643, 1350, -2577,
+ -2100, -277, -1546, -2279, -882,
+
+ /* impulse 5 */
+ -418, -886, -48, -494, -2368, -2060,
+ -1233, -5271,-10430, -6955, 3301, 7578,
+ 2599, -1665, -461, 735, -181,
+
+ /* impulse 6 */
+ -467, -1865, -1455, -127, -1881, -3776,
+ 822, 8335, 8192, 863, -2762, -375,
+ 757, -558, -285, 653, 150,
+
+ /* impulse 7 */
+ 1087, 471, -618, 706, 1546, -1605,
+ -3256, 2396, 8060, 5189, -99, -37,
+ 1105, -668, -1434, -59, -81
+};
+
+/*----------------------------------------------------------------------------------*
+ * Gaussian codebook
+ *----------------------------------------------------------------------------------*/
+/*table in Q12*/
+const Word16 gaus_dico_fx[190] =
+{
+ -399, -125, 523, -466, 305, -658, -809, 47,
+ -141, -171, -583, -259, 296, 1334, -285, -401,
+ -478, -418, 140, -540, 177, -1089, 130, -292,
+ 143, 492, -310, -862, -320, 388, 546, 84,
+ -1202, 107, 108, 340, 239, -130, 930, 342,
+ 153, -264, -763, -113, 387, -535, 83, -856,
+ -361, -421, 120, 396, -367, 640, 817, 222,
+ -1017, -82, -120, 890, 340, -384, 47, 339,
+ -505, -430, 161, 979, 890, -267, 104, 508,
+ -150, -194, 442, 193, 413, -24, 395, -43,
+ -217, 69, -398, 167, 116, -936, -95, 1466,
+ -435, 461, 862, -136, -94, 1311, -371, 68,
+ 134, -296, -156, -564, -48, -487, 647, 315,
+ 513, -101, -685, -318, -344, -644, -66, 851,
+ 414, -29, 509, 414, 502, 399, 557, 649,
+ -299, 750, 546, -756, -12, -365, 593, -707,
+ 394, -131, -375, -62, -914, -256, -424, 64,
+ 464, -1140, 280, 91, -83, -288, -550, 389,
+ 52, -1228, 6, -430, 74, 205, -478, -148,
+ -592, 282, -73, 1212, 42, 580, -334, 484,
+ -765, 443, 649, 271, -739, 375, 613, -460,
+ -208, 235, -120, -49, -311, 605, 875, 521,
+ 202, -506, -548, -1088, -43, -221, 673, -245,
+ -27, 469, 353, 53, 744, 275
+};
+
+const Word16 Idx_dortft320_16fx[320] =
+{
+ 0,65,130,195,260,5,70,135,200,265,10,75,140,205,270,15,80,145,210,275,20,85,150,215,280,25,90,155,220,285,30,95,
+ 160,225,290,35,100,165,230,295,40,105,170,235,300,45,110,175,240,305,50,115,180,245,310,55,120,185,250,315,60,125,
+ 190,255,256,1,66,131,196,261,6,71,136,201,266,11,76,141,206,271,16,81,146,211,276,21,86,151,216,281,26,91,156,221,
+ 286,31,96,161,226,291,36,101,166,231,296,41,106,171,236,301,46,111,176,241,306,51,116,181,246,311,56,121,186,251,
+ 316,61,126,191,192,257,2,67,132,197,262,7,72,137,202,267,12,77,142,207,272,17,82,147,212,277,22,87,152,217,282,27,
+ 92,157,222,287,32,97,162,227,292,37,102,167,232,297,42,107,172,237,302,47,112,177,242,307,52,117,182,247,312,57,122,
+ 187,252,317,62,127,128,193,258,3,68,133,198,263,8,73,138,203,268,13,78,143,208,273,18,83,148,213,278,23,88,153,218,
+ 283,28,93,158,223,288,33,98,163,228,293,38,103,168,233,298,43,108,173,238,303,48,113,178,243,308,53,118,183,248,313,
+ 58,123,188,253,318,63,64,129,194,259,4,69,134,199,264,9,74,139,204,269,14,79,144,209,274,19,84,149,214,279,24,89,154,
+ 219,284,29,94,159,224,289,34,99,164,229,294,39,104,169,234,299,44,109,174,239,304,49,114,179,244,309,54,119,184,249,
+ 314,59,124,189,254,319
+};
+const Word16 Ip_fft128_16fx[10] = {64, 1, 0, 128, 64, 192, 32, 160, 96, 224};
+const Word32 w_fft128_16fx[64] =
+{
+ 1073741824, 0, 759250112, 759250112, 992008064, 410903232, 410903232, 992008064,
+ 1053110144, 209476640, 596539008, 892783680, 892783680, 596539008, 209476640, 1053110144,
+ 1068571456, 105245104, 681174592, 830013632, 946955712, 506158400, 311690816, 1027506880,
+ 1027506880, 311690816, 506158400, 946955712, 830013632, 681174592, 105245104, 1068571456,
+ 1072448448, 52686008, 721080960, 795590208, 970651136, 459083776, 361732736, 1010975232,
+ 1041563136, 260897968, 552013632, 920979072, 862437504, 639627264, 157550640, 1062120192,
+ 1062120192, 157550640, 639627264, 862437504, 920979072, 552013632, 260897968, 1041563136,
+ 1010975232, 361732736, 459083776, 970651136, 795590208, 721080960, 52686008, 1072448448,
+};
+const Word16 Ip_fft32_16fx[6] = {16,1,0,32,16,48};
+const Word16 Ip_fft64_16fx[6] = {32,1,0,64,32,96};
+const Word16 Odx_fft64_16fx[64] =
+{
+ 0,59,54,49,44,39,34,29,24,19,14,9,4,63,58,53,48,43,38,33,28,23,18,13,8,3,62,57,52,47,42,37,
+ 32,27,22,17,12,7,2,61,56,51,46,41,36,31,26,21,16,11,6,1,60,55,50,45,40,35,30,25,20,15,10,5
+};
+const Word32 w_fft32_16fx[16] =
+{
+ 1073741824, 0, 759250113, 759250113, 992008059, 410903236, 410903236, 992008059,
+ 1053110143, 209476636, 596539003, 892783685, 892783685, 596539003, 209476636, 1053110143
+};
+const Word16 edct_table_320_16fx[320] =
+{
+ 7747, 7747, 7747, 7746, 7746, 7745, 7744, 7742,
+ 7741, 7739, 7737, 7735, 7733, 7730, 7728, 7725,
+ 7722, 7719, 7716, 7712, 7708, 7704, 7700, 7696,
+ 7692, 7687, 7682, 7677, 7672, 7666, 7661, 7655,
+ 7649, 7643, 7637, 7630, 7623, 7617, 7610, 7602,
+ 7595, 7587, 7580, 7572, 7563, 7555, 7547, 7538,
+ 7529, 7520, 7511, 7501, 7492, 7482, 7472, 7462,
+ 7451, 7441, 7430, 7419, 7408, 7397, 7386, 7374,
+ 7362, 7350, 7338, 7326, 7314, 7301, 7288, 7275,
+ 7262, 7249, 7235, 7221, 7208, 7194, 7179, 7165,
+ 7150, 7136, 7121, 7106, 7091, 7075, 7060, 7044,
+ 7028, 7012, 6995, 6979, 6962, 6946, 6929, 6912,
+ 6894, 6877, 6859, 6842, 6824, 6806, 6787, 6769,
+ 6750, 6732, 6713, 6694, 6674, 6655, 6635, 6616,
+ 6596, 6576, 6556, 6535, 6515, 6494, 6473, 6452,
+ 6431, 6410, 6388, 6367, 6345, 6323, 6301, 6279,
+ 6257, 6234, 6211, 6189, 6166, 6143, 6119, 6096,
+ 6072, 6049, 6025, 6001, 5977, 5953, 5928, 5904,
+ 5879, 5854, 5829, 5804, 5779, 5753, 5728, 5702,
+ 5676, 5650, 5624, 5598, 5572, 5545, 5518, 5492,
+ 5465, 5438, 5411, 5383, 5356, 5328, 5301, 5273,
+ 5245, 5217, 5189, 5160, 5132, 5104, 5075, 5046,
+ 5017, 4988, 4959, 4930, 4900, 4871, 4841, 4811,
+ 4781, 4751, 4721, 4691, 4661, 4630, 4600, 4569,
+ 4538, 4508, 4477, 4446, 4414, 4383, 4352, 4320,
+ 4288, 4257, 4225, 4193, 4161, 4129, 4097, 4064,
+ 4032, 3999, 3967, 3934, 3901, 3868, 3835, 3802,
+ 3769, 3736, 3702, 3669, 3635, 3602, 3568, 3534,
+ 3500, 3466, 3432, 3398, 3364, 3330, 3295, 3261,
+ 3226, 3192, 3157, 3122, 3087, 3052, 3017, 2982,
+ 2947, 2912, 2877, 2841, 2806, 2771, 2735, 2699,
+ 2664, 2628, 2592, 2556, 2520, 2484, 2448, 2412,
+ 2376, 2340, 2304, 2267, 2231, 2194, 2158, 2121,
+ 2085, 2048, 2011, 1975, 1938, 1901, 1864, 1827,
+ 1790, 1753, 1716, 1679, 1642, 1605, 1567, 1530,
+ 1493, 1455, 1418, 1381, 1343, 1306, 1268, 1231,
+ 1193, 1156, 1118, 1080, 1043, 1005, 967, 930,
+ 892, 854, 816, 778, 740, 703, 665, 627,
+ 589, 551, 513, 475, 437, 399, 361, 323,
+ 285, 247, 209, 171, 133, 95, 57, 19
+};
+const Word16 edct_table_128_16fx[128] = /*Q15 */
+{
+ 9742, 9740, 9737, 9733, 9727, 9720, 9711, 9701,
+ 9689, 9676, 9661, 9645, 9627, 9608, 9588, 9566,
+ 9543, 9518, 9492, 9464, 9435, 9405, 9373, 9339,
+ 9305, 9269, 9231, 9192, 9152, 9110, 9067, 9023,
+ 8977, 8930, 8882, 8832, 8781, 8728, 8675, 8619,
+ 8563, 8505, 8447, 8386, 8325, 8262, 8198, 8133,
+ 8067, 7999, 7930, 7860, 7789, 7717, 7643, 7568,
+ 7492, 7415, 7337, 7258, 7178, 7097, 7014, 6931,
+ 6846, 6761, 6674, 6586, 6498, 6408, 6318, 6226,
+ 6134, 6040, 5946, 5851, 5755, 5658, 5560, 5462,
+ 5362, 5262, 5161, 5059, 4957, 4854, 4750, 4645,
+ 4539, 4433, 4327, 4219, 4111, 4002, 3893, 3783,
+ 3673, 3562, 3450, 3338, 3226, 3113, 2999, 2885,
+ 2771, 2656, 2541, 2425, 2309, 2193, 2076, 1959,
+ 1842, 1724, 1607, 1489, 1370, 1252, 1133, 1014,
+ 895, 776, 657, 538, 418, 299, 179, 60
+};
+const Word16 edct_table_160_16fx[160] =
+{
+ 9213, 9212, 9211, 9208, 9204, 9200, 9195, 9188,
+ 9181, 9173, 9164, 9155, 9144, 9132, 9120, 9107,
+ 9093, 9078, 9062, 9045, 9027, 9009, 8989, 8969,
+ 8948, 8926, 8903, 8880, 8855, 8830, 8803, 8776,
+ 8748, 8719, 8690, 8659, 8628, 8596, 8563, 8529,
+ 8495, 8459, 8423, 8386, 8348, 8309, 8270, 8230,
+ 8188, 8147, 8104, 8061, 8016, 7971, 7926, 7879,
+ 7832, 7784, 7735, 7686, 7635, 7584, 7533, 7480,
+ 7427, 7373, 7319, 7263, 7207, 7151, 7093, 7035,
+ 6976, 6917, 6857, 6796, 6735, 6673, 6610, 6547,
+ 6483, 6418, 6353, 6287, 6221, 6154, 6086, 6018,
+ 5949, 5880, 5810, 5739, 5668, 5597, 5525, 5452,
+ 5379, 5305, 5231, 5156, 5081, 5005, 4929, 4852,
+ 4775, 4698, 4620, 4541, 4462, 4383, 4303, 4223,
+ 4142, 4061, 3980, 3898, 3816, 3734, 3651, 3568,
+ 3484, 3400, 3316, 3231, 3146, 3061, 2976, 2890,
+ 2804, 2718, 2631, 2544, 2457, 2370, 2282, 2195,
+ 2107, 2019, 1930, 1842, 1753, 1664, 1575, 1486,
+ 1397, 1307, 1218, 1128, 1038, 948, 858, 768,
+ 678, 588, 497, 407, 317, 226, 136, 45
+};
+
+const Word16 ip_edct2_64_fx[6] = {16, 64, 0, 32, 16, 48};
+
+const Word16 w_edct2_64_fx[80] = /*Q14 */
+{
+ 16384, 0, 11585, 11585, 15137, 6270, 6270, 15137,
+ 16069, 3196, 9102, 13623, 13623, 9102, 3196, 16069,
+ 11585, 8190, 8182, 8170, 8153, 8130, 8103, 8071,
+ 8035, 7993, 7946, 7895, 7839, 7779, 7713, 7643,
+ 7568, 7489, 7405, 7317, 7225, 7128, 7027, 6921,
+ 6811, 6698, 6580, 6458, 6333, 6203, 6070, 5933,
+ 5793, 5649, 5501, 5351, 5197, 5040, 4880, 4717,
+ 4551, 4383, 4212, 4038, 3862, 3683, 3503, 3320,
+ 3135, 2948, 2760, 2570, 2378, 2185, 1990, 1795,
+ 1598, 1401, 1202, 1003, 803, 603, 402, 201
+};
+/*------------------------------------------------------------------------------*
+ * FIX POINT EDCT tables
+ *------------------------------------------------------------------------------*/
+const Word16 edct_table_80_fx[80] = /*Q16 */
+{
+ 21911, 21903, 21886, 21860, 21827, 21784, 21734, 21675,
+ 21608, 21532, 21448, 21356, 21255, 21147, 21030, 20905,
+ 20772, 20631, 20482, 20325, 20161, 19988, 19808, 19621,
+ 19425, 19222, 19012, 18795, 18570, 18338, 18099, 17853,
+ 17600, 17340, 17074, 16801, 16522, 16236, 15944, 15646,
+ 15341, 15031, 14715, 14394, 14067, 13734, 13396, 13053,
+ 12705, 12352, 11994, 11632, 11265, 10894, 10519, 10139,
+ 9756, 9369, 8978, 8584, 8186, 7786, 7382, 6975,
+ 6566, 6155, 5741, 5324, 4906, 4486, 4064, 3640,
+ 3215, 2789, 2362, 1934, 1505, 1075, 645, 215
+};
+
+const Word16 edct_table_100_fx[] =
+{
+ 20723, 20718, 20708, 20692, 20672, 20646, 20616, 20580,
+ 20539, 20493, 20442, 20386, 20325, 20259, 20188, 20112,
+ 20031, 19946, 19855, 19759, 19658, 19553, 19443, 19328,
+ 19208, 19083, 18954, 18820, 18681, 18538, 18390, 18238,
+ 18081, 17920, 17754, 17584, 17410, 17231, 17048, 16861,
+ 16670, 16474, 16275, 16071, 15864, 15652, 15437, 15218,
+ 14995, 14768, 14538, 14304, 14067, 13826, 13582, 13335,
+ 13084, 12830, 12573, 12312, 12049, 11783, 11513, 11241,
+ 10966, 10689, 10409, 10126, 9841, 9553, 9263, 8971,
+ 8676, 8379, 8081, 7780, 7477, 7173, 6867, 6559,
+ 6249, 5938, 5625, 5311, 4996, 4679, 4362, 4043,
+ 3723, 3403, 3081, 2759, 2436, 2112, 1788, 1464,
+ 1139, 814, 488, 163
+};
+
+const Word16 edct_table_120_fx[120] = /*Q16 */
+{
+ 19800, 19797, 19790, 19780, 19766, 19749, 19729, 19705,
+ 19678, 19648, 19614, 19576, 19536, 19492, 19445, 19394,
+ 19340, 19283, 19223, 19159, 19092, 19021, 18948, 18871,
+ 18791, 18708, 18621, 18531, 18438, 18342, 18243, 18141,
+ 18035, 17927, 17815, 17701, 17583, 17462, 17339, 17212,
+ 17082, 16950, 16815, 16676, 16535, 16391, 16244, 16095,
+ 15942, 15787, 15629, 15469, 15306, 15140, 14972, 14801,
+ 14628, 14452, 14273, 14092, 13909, 13723, 13535, 13345,
+ 13152, 12958, 12761, 12561, 12360, 12156, 11951, 11743,
+ 11533, 11322, 11108, 10893, 10675, 10456, 10235, 10012,
+ 9788, 9562, 9334, 9104, 8874, 8641, 8407, 8172,
+ 7935, 7697, 7457, 7217, 6975, 6732, 6487, 6242,
+ 5995, 5748, 5499, 5250, 4999, 4748, 4496, 4243,
+ 3990, 3736, 3481, 3225, 2969, 2713, 2456, 2199,
+ 1941, 1683, 1424, 1166, 907, 648, 389, 130
+};
+
+const Word16 edct_table_320_fx[320] = /*Q16 */
+{
+ 15495, 15495, 15494, 15493, 15491, 15489, 15487, 15484,
+ 15481, 15478, 15474, 15470, 15466, 15461, 15456, 15450,
+ 15444, 15438, 15431, 15424, 15417, 15409, 15401, 15392,
+ 15383, 15374, 15364, 15354, 15344, 15333, 15322, 15310,
+ 15298, 15286, 15273, 15260, 15247, 15233, 15219, 15205,
+ 15190, 15175, 15159, 15143, 15127, 15110, 15093, 15076,
+ 15058, 15040, 15021, 15002, 14983, 14964, 14944, 14924,
+ 14903, 14882, 14860, 14839, 14817, 14794, 14771, 14748,
+ 14725, 14701, 14677, 14652, 14627, 14602, 14576, 14550,
+ 14524, 14497, 14470, 14443, 14415, 14387, 14359, 14330,
+ 14301, 14271, 14242, 14212, 14181, 14150, 14119, 14088,
+ 14056, 14024, 13991, 13958, 13925, 13891, 13858, 13823,
+ 13789, 13754, 13719, 13683, 13647, 13611, 13575, 13538,
+ 13501, 13463, 13425, 13387, 13349, 13310, 13271, 13231,
+ 13192, 13152, 13111, 13071, 13030, 12988, 12947, 12905,
+ 12862, 12820, 12777, 12734, 12690, 12647, 12602, 12558,
+ 12513, 12468, 12423, 12377, 12331, 12285, 12239, 12192,
+ 12145, 12098, 12050, 12002, 11954, 11905, 11856, 11807,
+ 11758, 11708, 11658, 11608, 11557, 11507, 11455, 11404,
+ 11352, 11301, 11248, 11196, 11143, 11090, 11037, 10983,
+ 10930, 10876, 10821, 10767, 10712, 10657, 10601, 10546,
+ 10490, 10434, 10378, 10321, 10264, 10207, 10150, 10092,
+ 10034, 9976, 9918, 9859, 9800, 9741, 9682, 9623,
+ 9563, 9503, 9443, 9382, 9322, 9261, 9200, 9138,
+ 9077, 9015, 8953, 8891, 8829, 8766, 8703, 8640,
+ 8577, 8513, 8450, 8386, 8322, 8258, 8193, 8129,
+ 8064, 7999, 7933, 7868, 7802, 7737, 7671, 7604,
+ 7538, 7471, 7405, 7338, 7271, 7203, 7136, 7068,
+ 7001, 6933, 6865, 6796, 6728, 6659, 6591, 6522,
+ 6453, 6383, 6314, 6244, 6175, 6105, 6035, 5965,
+ 5895, 5824, 5754, 5683, 5612, 5541, 5470, 5399,
+ 5327, 5256, 5184, 5113, 5041, 4969, 4897, 4824,
+ 4752, 4680, 4607, 4534, 4462, 4389, 4316, 4243,
+ 4169, 4096, 4023, 3949, 3876, 3802, 3728, 3654,
+ 3580, 3506, 3432, 3358, 3284, 3209, 3135, 3060,
+ 2986, 2911, 2836, 2761, 2687, 2612, 2537, 2462,
+ 2386, 2311, 2236, 2161, 2085, 2010, 1934, 1859,
+ 1783, 1708, 1632, 1557, 1481, 1405, 1329, 1254,
+ 1178, 1102, 1026, 950, 874, 798, 722, 646,
+ 570, 494, 418, 342, 266, 190, 114, 38
+};
+
+const Word16 edct_table_480_fx[480] = /*Q16 */
+{
+ 14001, 14001, 14001, 14000, 14000, 13999, 13998, 13997,
+ 13996, 13995, 13993, 13991, 13990, 13988, 13986, 13983,
+ 13981, 13978, 13976, 13973, 13970, 13967, 13963, 13960,
+ 13956, 13953, 13949, 13945, 13940, 13936, 13932, 13927,
+ 13922, 13917, 13912, 13907, 13902, 13896, 13890, 13885,
+ 13879, 13872, 13866, 13860, 13853, 13846, 13840, 13833,
+ 13825, 13818, 13811, 13803, 13795, 13787, 13779, 13771,
+ 13763, 13754, 13746, 13737, 13728, 13719, 13709, 13700,
+ 13691, 13681, 13671, 13661, 13651, 13641, 13630, 13620,
+ 13609, 13598, 13587, 13576, 13565, 13553, 13542, 13530,
+ 13518, 13506, 13494, 13482, 13469, 13457, 13444, 13431,
+ 13418, 13405, 13392, 13378, 13365, 13351, 13337, 13323,
+ 13309, 13295, 13280, 13266, 13251, 13236, 13221, 13206,
+ 13191, 13175, 13160, 13144, 13128, 13112, 13096, 13080,
+ 13063, 13047, 13030, 13013, 12996, 12979, 12962, 12944,
+ 12927, 12909, 12891, 12873, 12855, 12837, 12819, 12800,
+ 12782, 12763, 12744, 12725, 12706, 12686, 12667, 12647,
+ 12628, 12608, 12588, 12568, 12547, 12527, 12506, 12486,
+ 12465, 12444, 12423, 12402, 12380, 12359, 12337, 12316,
+ 12294, 12272, 12250, 12227, 12205, 12182, 12160, 12137,
+ 12114, 12091, 12068, 12045, 12021, 11998, 11974, 11950,
+ 11926, 11902, 11878, 11854, 11829, 11804, 11780, 11755,
+ 11730, 11705, 11680, 11654, 11629, 11603, 11578, 11552,
+ 11526, 11500, 11474, 11447, 11421, 11394, 11368, 11341,
+ 11314, 11287, 11260, 11232, 11205, 11177, 11150, 11122,
+ 11094, 11066, 11038, 11010, 10981, 10953, 10924, 10895,
+ 10867, 10838, 10809, 10779, 10750, 10721, 10691, 10662,
+ 10632, 10602, 10572, 10542, 10512, 10481, 10451, 10420,
+ 10390, 10359, 10328, 10297, 10266, 10235, 10203, 10172,
+ 10140, 10109, 10077, 10045, 10013, 9981, 9949, 9917,
+ 9884, 9852, 9819, 9786, 9754, 9721, 9688, 9654,
+ 9621, 9588, 9554, 9521, 9487, 9454, 9420, 9386,
+ 9352, 9318, 9283, 9249, 9214, 9180, 9145, 9111,
+ 9076, 9041, 9006, 8971, 8935, 8900, 8865, 8829,
+ 8794, 8758, 8722, 8686, 8650, 8614, 8578, 8542,
+ 8505, 8469, 8432, 8396, 8359, 8322, 8285, 8248,
+ 8211, 8174, 8137, 8099, 8062, 8025, 7987, 7949,
+ 7912, 7874, 7836, 7798, 7760, 7721, 7683, 7645,
+ 7606, 7568, 7529, 7491, 7452, 7413, 7374, 7335,
+ 7296, 7257, 7218, 7178, 7139, 7100, 7060, 7020,
+ 6981, 6941, 6901, 6861, 6821, 6781, 6741, 6701,
+ 6661, 6620, 6580, 6539, 6499, 6458, 6418, 6377,
+ 6336, 6295, 6254, 6213, 6172, 6131, 6090, 6048,
+ 6007, 5966, 5924, 5883, 5841, 5799, 5758, 5716,
+ 5674, 5632, 5590, 5548, 5506, 5464, 5422, 5379,
+ 5337, 5295, 5252, 5210, 5167, 5124, 5082, 5039,
+ 4996, 4953, 4911, 4868, 4825, 4782, 4738, 4695,
+ 4652, 4609, 4566, 4522, 4479, 4435, 4392, 4348,
+ 4305, 4261, 4218, 4174, 4130, 4086, 4042, 3999,
+ 3955, 3911, 3867, 3823, 3778, 3734, 3690, 3646,
+ 3602, 3557, 3513, 3469, 3424, 3380, 3335, 3291,
+ 3246, 3202, 3157, 3112, 3068, 3023, 2978, 2933,
+ 2889, 2844, 2799, 2754, 2709, 2664, 2619, 2574,
+ 2529, 2484, 2439, 2394, 2349, 2303, 2258, 2213,
+ 2168, 2122, 2077, 2032, 1986, 1941, 1896, 1850,
+ 1805, 1759, 1714, 1668, 1623, 1577, 1532, 1486,
+ 1441, 1395, 1350, 1304, 1258, 1213, 1167, 1121,
+ 1076, 1030, 984, 939, 893, 847, 801, 756,
+ 710, 664, 618, 573, 527, 481, 435, 389,
+ 344, 298, 252, 206, 160, 115, 69, 23
+};
+
+const Word16 edct_table_600_fx[] =
+{
+ 26483, 26483, 26483, 26482, 26481, 26481, 26479, 26478,
+ 26477, 26475, 26473, 26471, 26469, 26467, 26464, 26461,
+ 26459, 26455, 26452, 26449, 26445, 26441, 26437, 26433,
+ 26429, 26424, 26420, 26415, 26410, 26404, 26399, 26393,
+ 26387, 26381, 26375, 26369, 26362, 26356, 26349, 26342,
+ 26335, 26327, 26320, 26312, 26304, 26296, 26287, 26279,
+ 26270, 26261, 26252, 26243, 26234, 26224, 26214, 26204,
+ 26194, 26184, 26173, 26163, 26152, 26141, 26130, 26118,
+ 26107, 26095, 26083, 26071, 26059, 26046, 26033, 26021,
+ 26008, 25994, 25981, 25968, 25954, 25940, 25926, 25912,
+ 25897, 25883, 25868, 25853, 25838, 25823, 25807, 25791,
+ 25776, 25760, 25743, 25727, 25711, 25694, 25677, 25660,
+ 25643, 25625, 25608, 25590, 25572, 25554, 25535, 25517,
+ 25498, 25480, 25461, 25441, 25422, 25403, 25383, 25363,
+ 25343, 25323, 25302, 25282, 25261, 25240, 25219, 25198,
+ 25176, 25155, 25133, 25111, 25089, 25067, 25044, 25022,
+ 24999, 24976, 24953, 24929, 24906, 24882, 24858, 24834,
+ 24810, 24786, 24761, 24737, 24712, 24687, 24662, 24636,
+ 24611, 24585, 24559, 24533, 24507, 24481, 24454, 24427,
+ 24401, 24373, 24346, 24319, 24291, 24264, 24236, 24208,
+ 24180, 24151, 24123, 24094, 24065, 24036, 24007, 23978,
+ 23948, 23918, 23888, 23858, 23828, 23798, 23767, 23737,
+ 23706, 23675, 23644, 23612, 23581, 23549, 23518, 23486,
+ 23453, 23421, 23389, 23356, 23323, 23290, 23257, 23224,
+ 23191, 23157, 23123, 23090, 23056, 23021, 22987, 22953,
+ 22918, 22883, 22848, 22813, 22778, 22742, 22707, 22671,
+ 22635, 22599, 22563, 22526, 22490, 22453, 22416, 22379,
+ 22342, 22305, 22267, 22230, 22192, 22154, 22116, 22078,
+ 22039, 22001, 21962, 21923, 21884, 21845, 21806, 21766,
+ 21727, 21687, 21647, 21607, 21567, 21527, 21486, 21446,
+ 21405, 21364, 21323, 21282, 21241, 21199, 21157, 21116,
+ 21074, 21032, 20989, 20947, 20905, 20862, 20819, 20776,
+ 20733, 20690, 20647, 20603, 20560, 20516, 20472, 20428,
+ 20384, 20339, 20295, 20250, 20205, 20161, 20116, 20070,
+ 20025, 19980, 19934, 19888, 19842, 19796, 19750, 19704,
+ 19658, 19611, 19565, 19518, 19471, 19424, 19377, 19329,
+ 19282, 19234, 19186, 19139, 19091, 19042, 18994, 18946,
+ 18897, 18849, 18800, 18751, 18702, 18653, 18604, 18554,
+ 18505, 18455, 18405, 18355, 18305, 18255, 18205, 18154,
+ 18104, 18053, 18002, 17951, 17900, 17849, 17798, 17747,
+ 17695, 17643, 17592, 17540, 17488, 17436, 17383, 17331,
+ 17278, 17226, 17173, 17120, 17067, 17014, 16961, 16908,
+ 16854, 16801, 16747, 16693, 16640, 16586, 16531, 16477,
+ 16423, 16368, 16314, 16259, 16204, 16149, 16094, 16039,
+ 15984, 15929, 15873, 15818, 15762, 15706, 15650, 15595,
+ 15538, 15482, 15426, 15370, 15313, 15256, 15200, 15143,
+ 15086, 15029, 14972, 14914, 14857, 14800, 14742, 14684,
+ 14627, 14569, 14511, 14453, 14395, 14336, 14278, 14220,
+ 14161, 14103, 14044, 13985, 13926, 13867, 13808, 13749,
+ 13689, 13630, 13570, 13511, 13451, 13391, 13332, 13272,
+ 13212, 13151, 13091, 13031, 12971, 12910, 12849, 12789,
+ 12728, 12667, 12606, 12545, 12484, 12423, 12362, 12300,
+ 12239, 12177, 12116, 12054, 11992, 11930, 11868, 11806,
+ 11744, 11682, 11620, 11558, 11495, 11433, 11370, 11307,
+ 11245, 11182, 11119, 11056, 10993, 10930, 10867, 10803,
+ 10740, 10677, 10613, 10550, 10486, 10422, 10358, 10295,
+ 10231, 10167, 10103, 10039, 9974, 9910, 9846, 9781,
+ 9717, 9652, 9588, 9523, 9458, 9394, 9329, 9264,
+ 9199, 9134, 9069, 9003, 8938, 8873, 8808, 8742,
+ 8677, 8611, 8546, 8480, 8414, 8348, 8283, 8217,
+ 8151, 8085, 8019, 7953, 7886, 7820, 7754, 7688,
+ 7621, 7555, 7488, 7422, 7355, 7289, 7222, 7155,
+ 7088, 7022, 6955, 6888, 6821, 6754, 6687, 6620,
+ 6553, 6485, 6418, 6351, 6283, 6216, 6149, 6081,
+ 6014, 5946, 5879, 5811, 5743, 5676, 5608, 5540,
+ 5472, 5404, 5337, 5269, 5201, 5133, 5065, 4997,
+ 4928, 4860, 4792, 4724, 4656, 4587, 4519, 4451,
+ 4382, 4314, 4246, 4177, 4109, 4040, 3972, 3903,
+ 3834, 3766, 3697, 3629, 3560, 3491, 3422, 3354,
+ 3285, 3216, 3147, 3078, 3009, 2941, 2872, 2803,
+ 2734, 2665, 2596, 2527, 2458, 2389, 2320, 2251,
+ 2182, 2112, 2043, 1974, 1905, 1836, 1767, 1697,
+ 1628, 1559, 1490, 1421, 1351, 1282, 1213, 1144,
+ 1074, 1005, 936, 867, 797, 728, 659, 589,
+ 520, 451, 381, 312, 243, 173, 104, 35
+};
+
+const Word16 edct_table_128_fx[128] = /*Q16 */
+{
+ 19483, 19480, 19474, 19466, 19454, 19439, 19422, 19401,
+ 19378, 19351, 19322, 19290, 19255, 19217, 19176, 19132,
+ 19086, 19036, 18984, 18928, 18870, 18809, 18746, 18679,
+ 18610, 18537, 18462, 18385, 18304, 18221, 18135, 18046,
+ 17954, 17860, 17763, 17664, 17561, 17457, 17349, 17239,
+ 17126, 17011, 16893, 16773, 16650, 16524, 16396, 16266,
+ 16133, 15998, 15860, 15720, 15578, 15433, 15286, 15137,
+ 14985, 14831, 14675, 14516, 14356, 14193, 14028, 13861,
+ 13692, 13521, 13348, 13173, 12996, 12816, 12635, 12452,
+ 12268, 12081, 11892, 11702, 11510, 11316, 11121, 10924,
+ 10725, 10524, 10322, 10119, 9914, 9707, 9499, 9290,
+ 9079, 8867, 8653, 8438, 8222, 8005, 7786, 7566,
+ 7345, 7123, 6900, 6676, 6451, 6225, 5998, 5770,
+ 5541, 5312, 5081, 4850, 4618, 4385, 4152, 3918,
+ 3684, 3449, 3213, 2977, 2741, 2504, 2266, 2029,
+ 1791, 1552, 1314, 1075, 837, 598, 359, 120
+};
+
+const Word16 edct_table_160_fx[160] = /*Q16 */
+{
+ 18426, 18425, 18421, 18416, 18409, 18400, 18389, 18377,
+ 18362, 18346, 18329, 18309, 18288, 18265, 18240, 18214,
+ 18185, 18155, 18123, 18090, 18055, 18018, 17979, 17938,
+ 17896, 17852, 17806, 17759, 17710, 17659, 17607, 17552,
+ 17497, 17439, 17380, 17319, 17256, 17192, 17126, 17058,
+ 16989, 16918, 16846, 16772, 16696, 16619, 16540, 16459,
+ 16377, 16293, 16208, 16121, 16033, 15943, 15851, 15758,
+ 15664, 15568, 15470, 15371, 15271, 15169, 15065, 14960,
+ 14854, 14746, 14637, 14527, 14415, 14301, 14186, 14070,
+ 13953, 13834, 13714, 13592, 13469, 13345, 13220, 13093,
+ 12965, 12836, 12706, 12574, 12441, 12307, 12172, 12036,
+ 11898, 11759, 11620, 11479, 11337, 11193, 11049, 10904,
+ 10758, 10610, 10462, 10312, 10162, 10011, 9858, 9705,
+ 9551, 9395, 9239, 9082, 8925, 8766, 8606, 8446,
+ 8285, 8123, 7960, 7797, 7632, 7467, 7301, 7135,
+ 6968, 6800, 6632, 6463, 6293, 6122, 5952, 5780,
+ 5608, 5435, 5262, 5089, 4915, 4740, 4565, 4389,
+ 4214, 4037, 3861, 3684, 3506, 3328, 3150, 2972,
+ 2793, 2614, 2435, 2256, 2076, 1896, 1716, 1536,
+ 1356, 1175, 994, 814, 633, 452, 271, 90
+};
+
+const Word16 edct_table_40_fx[40] = /*Q16 */
+{
+ 26049, 26009, 25928, 25808, 25648, 25448, 25210, 24932,
+ 24616, 24262, 23870, 23442, 22977, 22477, 21943, 21375,
+ 20773, 20140, 19475, 18781, 18058, 17306, 16528, 15725,
+ 14897, 14047, 13174, 12282, 11370, 10441, 9496, 8536,
+ 7563, 6578, 5584, 4580, 3570, 2554, 1534, 512
+};
+
+const Word16 edct_table_20_fx[20] = /*Q16 */
+{
+ 30939, 30749, 30368, 29801, 29049, 28119, 27015, 25745,
+ 24316, 22737, 21018, 19169, 17202, 15129, 12963, 10717,
+ 8405, 6041, 3639, 1216
+};
+
+
+const Word16 edct_table_64_fx[] =
+{
+ 23167, 23153, 23125, 23083, 23027, 22958, 22874, 22777,
+ 22666, 22542, 22403, 22252, 22087, 21908, 21717, 21512,
+ 21295, 21064, 20821, 20565, 20297, 20017, 19725, 19420,
+ 19105, 18777, 18438, 18089, 17728, 17356, 16975, 16582,
+ 16180, 15769, 15347, 14917, 14477, 14029, 13572, 13107,
+ 12634, 12154, 11666, 11171, 10670, 10162, 9648, 9128,
+ 8603, 8072, 7537, 6997, 6453, 5905, 5353, 4798,
+ 4241, 3681, 3118, 2554, 1988, 1421, 853, 284
+};
+
+
+const Word16 edct_table_200_fx[] =
+{
+ 17427, 17426, 17423, 17420, 17416, 17411, 17404, 17397,
+ 17388, 17378, 17368, 17356, 17343, 17329, 17314, 17298,
+ 17281, 17262, 17243, 17223, 17201, 17179, 17155, 17131,
+ 17105, 17079, 17051, 17022, 16992, 16961, 16929, 16896,
+ 16862, 16827, 16791, 16754, 16716, 16676, 16636, 16595,
+ 16553, 16509, 16465, 16420, 16373, 16326, 16278, 16228,
+ 16178, 16126, 16074, 16021, 15966, 15911, 15855, 15797,
+ 15739, 15680, 15620, 15558, 15496, 15433, 15369, 15304,
+ 15238, 15171, 15103, 15035, 14965, 14894, 14823, 14751,
+ 14677, 14603, 14528, 14452, 14375, 14297, 14218, 14139,
+ 14058, 13977, 13895, 13812, 13728, 13643, 13558, 13471,
+ 13384, 13296, 13207, 13117, 13027, 12935, 12843, 12750,
+ 12657, 12562, 12467, 12371, 12274, 12177, 12078, 11979,
+ 11880, 11779, 11678, 11576, 11473, 11370, 11266, 11161,
+ 11055, 10949, 10843, 10735, 10627, 10518, 10409, 10299,
+ 10188, 10076, 9964, 9852, 9739, 9625, 9510, 9395,
+ 9280, 9164, 9047, 8930, 8812, 8694, 8575, 8455,
+ 8335, 8215, 8094, 7973, 7851, 7728, 7605, 7482,
+ 7358, 7234, 7109, 6984, 6858, 6732, 6606, 6479,
+ 6352, 6224, 6096, 5967, 5839, 5710, 5580, 5450,
+ 5320, 5190, 5059, 4928, 4796, 4664, 4532, 4400,
+ 4268, 4135, 4002, 3868, 3735, 3601, 3467, 3333,
+ 3198, 3064, 2929, 2794, 2659, 2523, 2388, 2252,
+ 2116, 1980, 1844, 1708, 1572, 1436, 1299, 1163,
+ 1026, 889, 753, 616, 479, 342, 205, 68
+};
+
+const Word16 edct_table_240_fx[] =
+{
+ 16650, 16650, 16648, 16646, 16643, 16640, 16635, 16630,
+ 16625, 16618, 16611, 16603, 16595, 16585, 16575, 16565,
+ 16553, 16541, 16528, 16515, 16501, 16486, 16470, 16454,
+ 16437, 16419, 16401, 16381, 16362, 16341, 16320, 16298,
+ 16275, 16252, 16228, 16203, 16178, 16151, 16125, 16097,
+ 16069, 16040, 16010, 15980, 15949, 15918, 15885, 15852,
+ 15819, 15784, 15749, 15713, 15677, 15640, 15602, 15564,
+ 15525, 15485, 15445, 15404, 15362, 15320, 15277, 15233,
+ 15189, 15144, 15098, 15052, 15005, 14957, 14909, 14860,
+ 14811, 14761, 14710, 14659, 14607, 14554, 14501, 14447,
+ 14392, 14337, 14282, 14225, 14168, 14111, 14053, 13994,
+ 13934, 13874, 13814, 13753, 13691, 13629, 13566, 13502,
+ 13438, 13374, 13309, 13243, 13176, 13109, 13042, 12974,
+ 12905, 12836, 12767, 12696, 12626, 12554, 12482, 12410,
+ 12337, 12264, 12190, 12115, 12040, 11965, 11889, 11812,
+ 11735, 11657, 11579, 11501, 11422, 11342, 11262, 11182,
+ 11101, 11019, 10937, 10855, 10772, 10689, 10605, 10521,
+ 10436, 10351, 10265, 10179, 10093, 10006, 9919, 9831,
+ 9743, 9654, 9565, 9476, 9386, 9296, 9205, 9114,
+ 9023, 8931, 8839, 8746, 8653, 8560, 8466, 8372,
+ 8278, 8183, 8088, 7993, 7897, 7801, 7704, 7608,
+ 7511, 7413, 7315, 7217, 7119, 7020, 6921, 6822,
+ 6723, 6623, 6523, 6422, 6321, 6221, 6119, 6018,
+ 5916, 5814, 5712, 5609, 5507, 5404, 5300, 5197,
+ 5093, 4990, 4885, 4781, 4677, 4572, 4467, 4362,
+ 4257, 4151, 4046, 3940, 3834, 3728, 3622, 3515,
+ 3408, 3302, 3195, 3088, 2981, 2873, 2766, 2658,
+ 2551, 2443, 2335, 2227, 2119, 2011, 1903, 1795,
+ 1686, 1578, 1469, 1361, 1252, 1143, 1035, 926,
+ 817, 708, 599, 490, 381, 272, 163, 54
+};
+
+const Word16 edct_table_256_fx[] =
+{
+ 16384, 16383, 16382, 16380, 16378, 16375, 16371, 16367,
+ 16362, 16356, 16350, 16343, 16336, 16328, 16319, 16310,
+ 16300, 16290, 16278, 16267, 16254, 16242, 16228, 16214,
+ 16199, 16184, 16168, 16151, 16134, 16116, 16098, 16079,
+ 16059, 16039, 16018, 15997, 15975, 15952, 15929, 15905,
+ 15881, 15856, 15830, 15804, 15777, 15750, 15722, 15693,
+ 15664, 15634, 15604, 15573, 15541, 15509, 15476, 15443,
+ 15409, 15375, 15340, 15304, 15268, 15231, 15194, 15156,
+ 15117, 15078, 15039, 14999, 14958, 14917, 14875, 14832,
+ 14789, 14746, 14702, 14657, 14612, 14566, 14520, 14473,
+ 14426, 14378, 14329, 14280, 14231, 14181, 14130, 14079,
+ 14027, 13975, 13922, 13869, 13815, 13761, 13706, 13651,
+ 13595, 13538, 13481, 13424, 13366, 13308, 13249, 13190,
+ 13130, 13069, 13008, 12947, 12885, 12823, 12760, 12697,
+ 12633, 12569, 12504, 12439, 12373, 12307, 12240, 12173,
+ 12106, 12038, 11969, 11901, 11831, 11762, 11691, 11621,
+ 11550, 11478, 11406, 11334, 11261, 11188, 11114, 11040,
+ 10965, 10891, 10815, 10740, 10663, 10587, 10510, 10433,
+ 10355, 10277, 10198, 10119, 10040, 9961, 9881, 9800,
+ 9719, 9638, 9557, 9475, 9393, 9310, 9227, 9144,
+ 9061, 8977, 8892, 8808, 8723, 8638, 8552, 8466,
+ 8380, 8293, 8206, 8119, 8032, 7944, 7856, 7768,
+ 7679, 7590, 7501, 7411, 7321, 7231, 7141, 7050,
+ 6960, 6868, 6777, 6685, 6593, 6501, 6409, 6316,
+ 6223, 6130, 6037, 5943, 5850, 5756, 5661, 5567,
+ 5472, 5377, 5282, 5187, 5092, 4996, 4900, 4804,
+ 4708, 4611, 4515, 4418, 4321, 4224, 4127, 4030,
+ 3932, 3835, 3737, 3639, 3541, 3442, 3344, 3246,
+ 3147, 3048, 2949, 2851, 2751, 2652, 2553, 2454,
+ 2354, 2255, 2155, 2055, 1956, 1856, 1756, 1656,
+ 1556, 1456, 1356, 1255, 1155, 1055, 954, 854,
+ 754, 653, 553, 452, 352, 251, 151, 50
+};
+
+const Word16 edct_table_400_fx[] =
+{
+ 29308, 29308, 29307, 29306, 29304, 29302, 29299, 29296,
+ 29292, 29288, 29284, 29279, 29273, 29267, 29261, 29254,
+ 29247, 29239, 29231, 29223, 29214, 29204, 29194, 29184,
+ 29173, 29162, 29150, 29138, 29125, 29112, 29099, 29085,
+ 29070, 29055, 29040, 29024, 29008, 28991, 28974, 28957,
+ 28939, 28920, 28901, 28882, 28862, 28842, 28821, 28800,
+ 28779, 28757, 28734, 28711, 28688, 28664, 28640, 28615,
+ 28590, 28565, 28539, 28512, 28485, 28458, 28430, 28402,
+ 28373, 28344, 28315, 28285, 28255, 28224, 28192, 28161,
+ 28129, 28096, 28063, 28030, 27996, 27962, 27927, 27892,
+ 27856, 27820, 27784, 27747, 27710, 27672, 27634, 27595,
+ 27556, 27517, 27477, 27437, 27396, 27355, 27313, 27272,
+ 27229, 27186, 27143, 27100, 27055, 27011, 26966, 26921,
+ 26875, 26829, 26782, 26736, 26688, 26640, 26592, 26544,
+ 26495, 26445, 26395, 26345, 26294, 26243, 26192, 26140,
+ 26088, 26035, 25982, 25929, 25875, 25821, 25766, 25711,
+ 25655, 25600, 25543, 25487, 25430, 25372, 25315, 25256,
+ 25198, 25139, 25079, 25020, 24960, 24899, 24838, 24777,
+ 24715, 24653, 24591, 24528, 24465, 24401, 24337, 24273,
+ 24208, 24143, 24078, 24012, 23946, 23879, 23812, 23745,
+ 23677, 23609, 23541, 23472, 23403, 23334, 23264, 23194,
+ 23123, 23052, 22981, 22909, 22837, 22765, 22692, 22619,
+ 22546, 22472, 22398, 22324, 22249, 22174, 22098, 22023,
+ 21947, 21870, 21793, 21716, 21639, 21561, 21483, 21404,
+ 21326, 21246, 21167, 21087, 21007, 20927, 20846, 20765,
+ 20684, 20602, 20520, 20437, 20355, 20272, 20189, 20105,
+ 20021, 19937, 19852, 19768, 19682, 19597, 19511, 19425,
+ 19339, 19252, 19165, 19078, 18991, 18903, 18815, 18726,
+ 18638, 18549, 18459, 18370, 18280, 18190, 18100, 18009,
+ 17918, 17827, 17735, 17643, 17551, 17459, 17366, 17274,
+ 17181, 17087, 16994, 16900, 16805, 16711, 16616, 16521,
+ 16426, 16331, 16235, 16139, 16043, 15946, 15850, 15753,
+ 15656, 15558, 15461, 15363, 15265, 15166, 15068, 14969,
+ 14870, 14770, 14671, 14571, 14471, 14371, 14271, 14170,
+ 14069, 13968, 13867, 13765, 13663, 13562, 13459, 13357,
+ 13254, 13152, 13049, 12946, 12842, 12739, 12635, 12531,
+ 12427, 12323, 12218, 12113, 12008, 11903, 11798, 11693,
+ 11587, 11481, 11375, 11269, 11163, 11056, 10950, 10843,
+ 10736, 10628, 10521, 10414, 10306, 10198, 10090, 9982,
+ 9874, 9765, 9657, 9548, 9439, 9330, 9221, 9112,
+ 9002, 8892, 8783, 8673, 8563, 8453, 8342, 8232,
+ 8122, 8011, 7900, 7789, 7678, 7567, 7456, 7344,
+ 7233, 7121, 7010, 6898, 6786, 6674, 6562, 6450,
+ 6337, 6225, 6112, 6000, 5887, 5774, 5661, 5548,
+ 5435, 5322, 5209, 5096, 4982, 4869, 4755, 4642,
+ 4528, 4414, 4300, 4187, 4073, 3959, 3845, 3730,
+ 3616, 3502, 3388, 3273, 3159, 3044, 2930, 2815,
+ 2701, 2586, 2472, 2357, 2242, 2127, 2013, 1898,
+ 1783, 1668, 1553, 1438, 1323, 1208, 1093, 978,
+ 863, 748, 633, 518, 403, 288, 173, 58
+};
+
+const Word16 Ip_fft16_fx[6] = {8,1,0,16,8,24};
+
+const Word16 Ip_fft8_fx[6] = {4,1,0,8,4,12};
+const Word16 w_fft8_fx[4] = {16384, 0, 11585, 11585}; /*Q14 */
+
+const Word16 Ip_fft32_fx[6] = {16,1,0,32,16,48};
+const Word16 Ip_fft64_fx[6] = {32,1,0,64,32,96};
+const Word16 Ip_fft4_fx[6] = {2,1,0,4,2,6};
+const Word16 w_fft4_fx[2] = {16384, 0}; /*Q14 */
+
+const Word16 Ip_fft128_fx[10] = {64,1,0,128,64,192,32,160,96,224};
+
+/* For the general fix point fft implementation */
+const Word16 sincos_t_fx[161] =
+{
+ /*Q15 */
+ 0,
+ 804, 1607, 2410, 3211, 4011,
+ 4808, 5602, 6392, 7179, 7961,
+ 8739, 9512, 10278, 11039, 11793,
+ 12539, 13278, 14010, 14732, 15446,
+ 16151, 16846, 17530, 18204, 18868,
+ 19519, 20159, 20787, 21403, 22005,
+ 22594, 23170, 23732, 24279, 24812,
+ 25330, 25832, 26319, 26790, 27245,
+ 27684, 28106, 28511, 28898, 29269,
+ 29621, 29956, 30273, 30572, 30852,
+ 31114, 31357, 31581, 31785, 31971,
+ 32138, 32285, 32413, 32521, 32610,
+ 32679, 32728, 32758, 32767, 32758,
+ 32728, 32679, 32610, 32521, 32413,
+ 32285, 32138, 31971, 31785, 31581,
+ 31357, 31114, 30852, 30572, 30273,
+ 29956, 29621, 29269, 28898, 28511,
+ 28106, 27684, 27245, 26790, 26319,
+ 25832, 25330, 24812, 24279, 23732,
+ 23170, 22594, 22005, 21403, 20787,
+ 20159, 19519, 18868, 18204, 17530,
+ 16846, 16151, 15446, 14732, 14010,
+ 13278, 12539, 11793, 11039, 10278,
+ 9512, 8739, 7961, 7179, 6392,
+ 5602, 4808, 4011, 3211, 2410,
+ 1607, 804, 0, -804, -1607,
+ -2410, -3211, -4011, -4808, -5602,
+ -6392, -7179, -7961, -8739, -9512,
+ -10278, -11039, -11793, -12539, -13278,
+ -14010, -14732, -15446, -16151, -16846,
+ -17530, -18204, -18868, -19519, -20159,
+ -20787, -21403, -22005, -22594, -23170,
+};
+
+/*------------------------------------------------------------------------------*
+ * GSC tables
+ *------------------------------------------------------------------------------*/
+
+const Word16 gsc_sfm_start[MBANDS_GN] = {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240};
+
+const Word16 gsc_sfm_end[MBANDS_GN] = {16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256};
+
+const Word16 gsc_sfm_size[MBANDS_GN] = {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16};
+
+
+/*GSC related */
+const Word16 GSC_freq_bits[] =
+{
+ 21, 66, -6, 25, 15, 11, 10, 5, 0, 0, 5, 4, 0, 0, 4, 0, 0, /* ACELP_7k20*/
+ 21, 74, -4, 26, 16, 12, 11, 9, 0, 0, 4, 4, 1, 1, 3, 0, 0, /* ACELP_8k00*/
+ 26, 96, -4, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_11k60*/
+ 26, 96, -4, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_12k15*/
+ 26, 96, -4, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_12k85*/
+ 31, 96, -4, 28, 18, 13, 12,10,10, 5, 4, 4, 1, 0, 1, 3, 4, /* ACELP_13k20*/
+};
+
+/***IN Q2 ****/
+const Word16 mfreq_loc_Q2fx[] = { 700, 1500, 3100, 4700, 6300, 7900, 9500, 11100, 12700, 14300, 15900, 17500, 19100, 20700, 22300, 25500, 28700, 31900 };
+const Word16 mfreq_loc_div_25[] = {7, 15, 31, 47, 63, 79, 95, 111, 127, 143, 159, 175, 191, 207, 223, 255, 287, 319};
+
+const Word16 mfreq_bindiv_loc_fx[] = {8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 32, 32, 32 };
+/*const Word16 mean_gp_fx[] = {4795}; */
+const Word16 mean_gp_fx[] = {9590}; /*Q14*/
+
+const Word16 dic_gp_fx[] = /*Q14*/
+{
+ -9580, -7692, -6385, -4474, -3254, -2038, -806, -82,
+ 1034, 2259, 3457, 4684, 5290, 6544, 8548, 10052,
+ -8964, -8338, -7021, -5754, -5118, -3850, -2654, -1429,
+ 408, 1660, 2852, 4071, 5915, 7170, 7825, 9249
+};
+
+const Word16 Gain_meanNB_fx[]=
+{
+ 9852,
+};/* Q12 */
+
+const Word16 Gain_mean_dicNB_fx[1*64] = /*Q12 */
+{
+ -1309, -931, -568, -396, -54, 807, 1174, 1533,
+ 1901, 2092, 2286, 2493, 2698, 3130, 2909, 286,
+ -748, 990, 631, -1119, -1697, -2114, -2788, -5399,
+ -9841, -1902, -3270, -7975, -7438, -6926, -7192, -2325,
+ -1504, -2549, -3022, -3532, -3818, -4136, -4751, -5071,
+ -5756, -6093, -8998, -6389, -8765, -9438, 3369, 3917,
+ 3619, 4684, -8264, 4255, -4433, -6662, -9230, -7678,
+ 5859, 118, 457, -227, 1717, 1353, -8499, -9649
+};
+
+const Word16 Mean_dic_NB_fx[1*10] = /*Q12 */
+{
+ -444, -100, -120, -37, 25,
+ 70, 148, 63, 170, 229
+};
+
+const Word16 Gain_dic1_NB_fx[3*64] = /*Q12 */
+{
+ -606, -92, 5,
+ -1965, 294, 666,
+ -440, 119, 661,
+ -106, 267, 108,
+ -1213, 345, -136,
+ -1251, 618, 566,
+ -1905, -750, 648,
+ -1043, -360, -498,
+ -18, -322, 96,
+ 334, 116, -247,
+ -1929, 660, 23,
+ -1845, 1178, 485,
+ -180, 836, 167,
+ -1892, -922, -321,
+ 416, -437, -344,
+ 595, -548, 158,
+ -265, -807, -338,
+ -1065, -1015, -20,
+ -626, 595, -333,
+ -569, 1090, 651,
+ 27, 587, -331,
+ -184, -85, -503,
+ -1902, -1807, 326,
+ -1861, -159, -989,
+ -666, 143, -1163,
+ -1718, 1031, -744,
+ 847, 301, -59,
+ 720, -1001, -216,
+ 1380, -866, -969,
+ 803, -4, -608,
+ 233, 408, -998,
+ 1459, 87, 263,
+ 345, -615, -1026,
+ 877, -148, -7,
+ 68, -1075, 270,
+ 802, 329, 475,
+ -1923, -126, -38,
+ 1275, -419, -349,
+ 401, 926, 575,
+ 846, -233, 547,
+ 693, -1880, 356,
+ -362, -1683, -219,
+ 231, -339, 598,
+ 1227, -616, 267,
+ 1116, 91, -1316,
+ -551, -650, 530,
+ 444, 32, 181,
+ -384, 1207, -775,
+ -993, 1163, 41,
+ 784, -1018, 538,
+ 635, 636, -424,
+ 1373, -1367, 149,
+ 1442, 401, -444,
+ 1094, 888, 123,
+ 874, 1113, -1082,
+ -646, -1112, -1103,
+ 539, -1632, -683,
+ 402, 571, 99,
+ -1778, -1809, -849,
+ -732, -1691, 700,
+ -678, 526, 274,
+ 320, 1227, -118,
+ -1222, -180, 454,
+ 173, 349, 530
+};
+
+const Word16 Gain_dic2_NB_fx[3*32] = /*Q12 */
+{
+ 28, 0, -66,
+ -557, 4, 206,
+ 281, -642, 36,
+ -417, 81, -494,
+ -380, 684, 450,
+ 521, -1544, 258,
+ -1119, 613, -1151,
+ 514, 24, 797,
+ 292, -84, -526,
+ 296, 418, -231,
+ -419, -68, 976,
+ 2, -308, 398,
+ -456, -1007, 263,
+ -1221, -371, 446,
+ -221, -390, -181,
+ -1210, 588, 751,
+ -1093, 528, -174,
+ 590, 372, -1271,
+ -79, -251, -1241,
+ -1016, -487, -512,
+ 542, 581, 338,
+ -265, 456, -105,
+ 490, -71, 89,
+ 42, 235, 379,
+ 31, 1194, -202,
+ 173, -839, 850,
+ -46, 500, -802,
+ 152, 933, 1073,
+ 980, 345, -263,
+ 807, -580, -521,
+ -23, -992, -585,
+ 876, -576, 411
+};
+
+const Word16 Gain_dic3_NB_fx[4*16] = /*Q12 */
+{
+ -16, 65, -227, 11,
+ -214, 553, 366, 185,
+ 137, -338, -300, -625,
+ -122, 82, 538, -797,
+ 160, 285, -1103, 35,
+ -594, 312, -379, -423,
+ 169, -642, -395, 363,
+ 351, -1166, 630, -261,
+ -1190, 217, 416, 187,
+ -577, 244, -636, 858,
+ 580, 482, -220, 635,
+ 475, -188, 372, 27,
+ -65, -369, 504, 910,
+ -423, -442, 124, -40,
+ 480, 575, -41, -651,
+ 682, 680, 910, 489
+};
+
+const Word16 Gain_dic2_NBHR_fx[3*64] = /*Q12 */
+{
+ 29, 0, -94,
+ -605, -202, -174,
+ 324, -380, -163,
+ -126, -301, -306,
+ -288, 124, 112,
+ -86, 524, -115,
+ 234, 18, -464,
+ -55, -281, 179,
+ 161, 446, 632,
+ 366, -82, 97,
+ 228, -1149, 270,
+ 293, 286, -143,
+ -123, -35, -896,
+ -540, -675, 175,
+ 331, -483, -687,
+ -779, 204, -668,
+ -492, 768, -510,
+ -1215, -620, -483,
+ 681, -76, -296,
+ -671, 396, -45,
+ -759, 298, 564,
+ -284, 589, 321,
+ -1366, -592, 496,
+ -448, -585, -712,
+ 12, -756, -90,
+ 513, 167, -927,
+ -1172, 1060, -1198,
+ -477, 748, 1006,
+ 42, 103, 1277,
+ -940, 1049, 138,
+ -924, -14, -1469,
+ 684, 679, -1580,
+ 417, -374, -1572,
+ 607, 270, 256,
+ 567, 778, 843,
+ 1414, -223, -542,
+ 97, 200, 251,
+ 222, 1074, -547,
+ -714, -285, 1046,
+ 386, -684, 984,
+ 338, 674, 116,
+ -274, 171, -368,
+ 581, -1871, 342,
+ 94, 442, -597,
+ -293, -1205, 851,
+ -127, 501, -1247,
+ 175, 1700, 1357,
+ -24, 1224, 285,
+ 707, -952, -293,
+ 668, 492, -407,
+ 1164, 751, 201,
+ 381, -595, 288,
+ -1570, 481, -531,
+ -597, -160, 326,
+ -578, -1311, -40,
+ -118, -523, 576,
+ -1513, 527, 757,
+ -184, 40, 609,
+ -1215, 98, 68,
+ -65, -1324, -836,
+ 821, -299, 204,
+ 796, 21, 840,
+ 310, -133, 542,
+ 1042, -974, 537
+};
+
+const Word16 Gain_dic3_NBHR_fx[4*128] = /*Q12 */
+{
+ 293, 7, -202, -95,
+ 535, 110, 542, -512,
+ -578, 65, -560, -345,
+ 206, 332, 10, -533,
+ -76, 356, -14, 83,
+ 149, -372, -195, -490,
+ -478, -241, -55, 113,
+ -293, -470, -606, 62,
+ 797, -1448, 625, -1128,
+ 173, 464, -1686, -49,
+ -392, -295, -159, -464,
+ -715, 420, -146, -984,
+ -36, 28, -484, 119,
+ 472, 272, -729, -116,
+ 68, -87, -628, -429,
+ 429, -918, -158, -191,
+ -545, 230, -435, 261,
+ -128, 15, -791, 612,
+ 268, -387, -1258, 102,
+ 378, 238, 301, 3,
+ -494, 149, 131, -124,
+ 634, -308, 99, 24,
+ 572, 711, 754, -1137,
+ -1109, 400, 1093, 369,
+ -831, -423, 1583, 1089,
+ -83, 156, -105, 1078,
+ -930, 476, 152, 380,
+ 776, 1162, 788, -43,
+ 279, 50, 408, 597,
+ 476, 483, 73, 749,
+ 903, 686, 80, -411,
+ 195, -768, 280, 344,
+ -263, -999, -46, -284,
+ -66, 263, 315, -1239,
+ 435, 578, -234, -1169,
+ 199, -1669, 188, 114,
+ -57, 419, -509, -633,
+ 98, -119, 129, -816,
+ -157, -365, -249, 537,
+ 67, -624, 121, 1153,
+ 1444, 142, -584, 38,
+ 1086, -84, 162, 994,
+ 392, -384, -124, 533,
+ 252, 183, -1161, -885,
+ -431, -829, 102, 432,
+ -708, 987, -1021, -644,
+ -64, 120, -1684, 985,
+ 210, -494, -906, 1302,
+ 50, -186, 177, 185,
+ -256, 872, -1004, 387,
+ 564, -80, -679, 515,
+ -763, -40, -1174, 228,
+ -1029, 199, -59, -297,
+ 30, -47, 198, -264,
+ -396, -1435, 913, -1018,
+ -141, 962, 36, 458,
+ 36, -388, 776, -1000,
+ -74, 489, 1137, 140,
+ -970, -766, 666, -117,
+ 90, 599, 1665, 1405,
+ -313, -685, -764, -615,
+ 563, -462, -627, -768,
+ 792, 560, -1445, 556,
+ -581, 721, -559, 1137,
+ -699, -273, 274, -846,
+ 940, -690, 747, -253,
+ -177, -541, 1355, -217,
+ -586, 427, 1196, -868,
+ 147, 532, -550, 405,
+ 258, 677, -245, -166,
+ 772, 1062, -331, 482,
+ 388, 1870, -576, 1585,
+ 462, 865, 454, 1212,
+ 570, 528, -681, 1229,
+ -386, 607, 599, 865,
+ -154, -20, -211, -231,
+ 96, 736, 408, -259,
+ 763, -1533, 1094, 249,
+ 705, -1132, 1757, -1082,
+ 310, -481, 329, -395,
+ 194, -781, 59, -954,
+ -933, -957, -25, 1866,
+ -852, -224, -482, 822,
+ -1438, 490, 221, 1281,
+ 392, 677, 539, 347,
+ 884, -614, 1844, 678,
+ -773, 484, -928, 2477,
+ -274, -461, 378, -263,
+ -283, -312, 583, 342,
+ 453, -1541, 378, 1266,
+ 778, 1095, 1290, 824,
+ -958, -443, -208, -71,
+ 985, -1001, -123, 473,
+ 56, -1003, -513, 474,
+ -259, 1435, 975, 315,
+ -59, -169, 724, 961,
+ -210, 1030, 341, -977,
+ 1054, 2917, -7, -877,
+ -852, -228, 330, 625,
+ 9, -524, -97, -14,
+ 16, -50, 476, 2406,
+ 264, -238, 768, 56,
+ 187, 108, -169, 446,
+ 673, 238, 992, 671,
+ -218, 285, 485, 181,
+ 669, -526, 639, 571,
+ 650, 20, -188, -516,
+ 1031, 165, 526, 136,
+ -333, 307, 102, -569,
+ -157, 309, -934, -121,
+ -336, 141, 39, 536,
+ 662, 364, -133, 222,
+ -1284, 637, -636, 77,
+ 1241, 846, 467, 638,
+ 842, 328, 1330, -320,
+ 152, -1009, 550, -215,
+ -772, 13, 594, -122,
+ 336, -410, -547, -2,
+ 869, -106, 321, -1180,
+ 516, 1247, -828, -577,
+ -670, 873, 367, -132,
+ -415, 630, -287, -164,
+ -105, 138, 657, -441,
+ -160, -1085, 940, 704,
+ -128, -68, -369, -1052,
+ -1434, 594, 546, -665,
+ -1849, 75, 175, 174,
+ -1283, 729, -1590, 1032
+};
+
+
+const Word16 mean_m_fx[1*1] = /*Q12 */
+{
+ 11762
+};
+const Word16 mean_gain_dic_fx[1*64]=
+{
+ -739, -519, -76, 147, 574, 779, 983, 1185,
+ 1384, 1580, 1784, 1989, 2204, 2643, 2864, 2422,
+ 362, -295, -1197, -1936, -2757, -11755, -8216, 3083,
+ 3311, -1434, -1682, -3341, -9284, -9057, -8616, -7783,
+ -7359, -6964, -6592, -6233, -5470, -5050, -4651, -3954,
+ -2470, -963, -2199, -3042, -3643, -4292, -5854, -10199,
+ 4103, 3548, 4390, 4717, 3817, -10525, -11521, -9570,
+ -9899, -9171, -10841, -11165, 5500, 5079, 6139, 6993
+}; /* Q12 */
+
+const Word16 YGain_mean_LR_fx[1*12]=
+{
+ -385, -178, -143, -116, -46, -12,
+ 64, 50, 118, 68, 133, 151
+};
+
+const Word16 YGain_dic1_LR_fx[3*32]= /*Q12 */
+{
+ -1909, 159, -90,
+ -155, 416, -15,
+ -99, -84, 396,
+ -1832, -848, -320,
+ -779, 1024, 45,
+ -1860, -1761, 273,
+ 81, -341, -309,
+ -819, -3, -315,
+ 483, 215, -194,
+ 242, 937, -76,
+ -1830, -1753, -1102,
+ -1589, 868, -657,
+ -911, 389, 421,
+ -1834, 915, 390,
+ -144, 564, -869,
+ 878, -1544, 301,
+ 446, 332, 376,
+ -540, -822, -1001,
+ 548, -192, 232,
+ 920, -589, -175,
+ 869, 717, -564,
+ 797, -103, -1047,
+ -335, -1732, -186,
+ -1840, -345, 566,
+ 1205, 109, 43,
+ 985, -456, 570,
+ 650, -1223, -874,
+ 928, 752, 390,
+ -124, 833, 575,
+ -1811, -249, -1142,
+ -711, -767, 185,
+ 344, -876, 267,
+};
+
+const Word16 YGain_dic2_LR_fx[4*32] = /*Q12 */
+{
+ -294, -73, -41, 11,
+ 276, 330, -1316, 173,
+ 26, -712, 86, 1,
+ -841, -539, 246, -479,
+ 43, -207, 709, 116,
+ 104, -197, 227, -548,
+ 261, -228, 165, 606,
+ 613, 403, -122, -420,
+ 14, 182, -544, -669,
+ -734, 392, -492, -131,
+ -1316, 274, 116, 331,
+ -1339, 535, -1261, 608,
+ -346, 277, -426, 729,
+ -1067, -836, -571, 388,
+ 643, 503, 484, 532,
+ -148, 447, 120, -392,
+ -600, 263, 519, -75,
+ 686, -346, 379, 23,
+ 130, 239, 376, -1366,
+ 68, 656, -361, 92,
+ 608, 286, -405, 487,
+ -1031, 507, 523, -971,
+ 51, -44, -521, 172,
+ -573, -500, 398, 632,
+ 240, 147, 104, 51,
+ -319, -680, -890, -398,
+ -195, 503, 306, 459,
+ 335, 368, 662, -389,
+ 378, -788, -537, 680,
+ 433, -1129, 472, -883,
+ 472, -312, -301, -207,
+ 378, -1346, 433, 408,
+};
+
+const Word16 YGain_dic3_LR_fx[5*32] = /*Q12 */
+{
+ -332, -191, -122, -455, -210,
+ 364, -48, -664, 408, 225,
+ -576, -342, 367, 52, 270,
+ -392, -157, -77, 625, -224,
+ -183, -652, -406, 99, 266,
+ 24, 65, 74, 525, 613,
+ -805, 306, -383, -21, 247,
+ 16, 133, -416, -4, -567,
+ 294, -750, 443, -367, 228,
+ 536, 816, 767, 562, 594,
+ -54, 200, -1108, -582, 227,
+ 123, -43, 414, -376, -649,
+ 592, -652, -674, -386, -356,
+ 100, -58, -45, -108, 103,
+ -727, -194, -1170, 931, 1096,
+ 512, 758, -440, -769, -1051,
+ 362, 787, -276, -139, 149,
+ -218, 387, 457, -414, 265,
+ -202, 663, -1104, 882, -338,
+ -57, 405, 269, 257, -221,
+ 335, 864, 1164, -611, -618,
+ 1275, 494, -1783, 119, 1222,
+ 752, 76, 270, 73, -57,
+ 376, -1255, 145, 724, 603,
+ -989, 618, 659, 675, 560,
+ 128, -147, -138, -368, 963,
+ 140, -170, 866, 538, 127,
+ 122, -616, 166, 236, -396,
+ 374, 279, 407, 650, -1269,
+ -861, 613, -755, -1334, -972,
+ -922, 314, 416, -114, -648,
+ 265, 85, 61, -1110, 45
+};
+
+const Word16 YG_mean16_fx[1*16] = /*Q12 */
+{
+ -396, -192, -168, -136, -60, -17, 45, 39,
+ 120, 81, 90, 67, 147, 34, 163, 184
+};
+
+const Word16 YG_dicMR_1_fx[4*64] = /*Q12 */
+{
+ -1879, 826, 539, -210,
+ -120, 267, -137, -142,
+ -798, -473, 434, 243,
+ 297, -896, 369, 307,
+ -1883, -1333, 416, 510,
+ -1955, -660, -471, 224,
+ -905, -804, -517, 433,
+ -961, 20, -258, -224,
+ 209, 977, -213, -17,
+ 536, -244, 159, 97,
+ -265, 775, 412, -327,
+ 337, -391, -237, -472,
+ -1962, -1836, -692, 471,
+ 625, 173, -463, -15,
+ -965, 263, 62, 600,
+ -782, 889, -433, 211,
+ -1791, 852, -453, -776,
+ -182, -177, -1078, 80,
+ -364, 350, 280, 293,
+ -902, 1119, 295, -1194,
+ 16, 440, -342, 459,
+ -1825, -1584, -1382, -798,
+ 723, 57, -1235, -661,
+ 888, -1638, 277, 234,
+ 340, 345, 141, -610,
+ 1280, -23, 17, 144,
+ -639, -852, -520, -553,
+ 1032, 843, 149, 435,
+ 581, 783, 519, -196,
+ 457, 945, 498, -1289,
+ -1897, -41, 425, 514,
+ 787, 161, 506, 385,
+ -559, 1079, 319, 515,
+ 500, 340, 60, 106,
+ 251, -997, -1163, -960,
+ 261, -1288, -631, 335,
+ 1241, -620, -387, -662,
+ 167, 194, 476, 67,
+ 830, -261, 430, -1201,
+ -479, -123, 71, -1162,
+ 225, -1482, 132, -802,
+ 680, 763, -1010, 429,
+ 200, -125, 261, 590,
+ 771, -740, -183, 229,
+ -1860, -348, 278, -549,
+ -1768, 967, 281, 594,
+ -1727, -1697, 87, -764,
+ 1169, 631, -114, -471,
+ -1636, -101, -1324, -91,
+ 821, -745, 458, -264,
+ 1014, -576, 390, 470,
+ 1041, -517, -1018, 367,
+ 826, 17, 426, -326,
+ -467, -1641, 201, 325,
+ -1906, 428, -338, 222,
+ -1021, 630, 419, -75,
+ -86, -379, -203, 234,
+ 659, 527, -491, -1507,
+ -564, -1745, -979, -173,
+ -1764, -433, -743, -1090,
+ 242, 709, 269, 497,
+ 716, 74, -208, 618,
+ -297, 645, -864, -805,
+ -46, -326, 412, -296
+};
+const Word16 YG_dicMR_2_fx[4*32] = /*Q12 */
+{
+ 93, 217, -122, 37,
+ -13, -83, 105, -491,
+ -398, -592, 399, -160,
+ 543, -81, -470, 408,
+ 394, -630, -94, -258,
+ -665, 133, -136, -125,
+ 397, -351, 630, -148,
+ -1166, 406, -865, 554,
+ -136, -302, -263, 81,
+ -674, -657, -571, -691,
+ -206, 381, -699, 122,
+ 272, -1506, 356, 15,
+ 451, -961, 638, -1133,
+ 316, -787, 165, 585,
+ 312, -144, 185, 274,
+ 39, -706, -997, 250,
+ -915, -871, -114, 458,
+ -834, 348, 364, -1188,
+ 450, 723, -256, 412,
+ 369, 468, -1371, 416,
+ 344, 164, 290, -1094,
+ 664, 122, 34, -218,
+ 555, 254, 559, 825,
+ 312, 492, 496, -27,
+ -399, 315, 690, -330,
+ -458, 710, 206, 415,
+ 290, 89, -662, -467,
+ -72, 593, -108, -460,
+ -217, 46, 319, 189,
+ -1366, 199, 365, 62,
+ -552, -166, 772, 861,
+ -159, 120, -215, 775
+};
+const Word16 YG_dicMR_3_fx[4*32] = /*Q12 */
+{
+ -103, -143, -85, -19,
+ -404, 182, -795, 84,
+ 398, -594, -55, -256,
+ 283, 128, -472, 279,
+ -246, -628, 281, 297,
+ -853, 468, 358, -915,
+ 272, 149, 209, -443,
+ -168, -504, 452, -525,
+ 624, -427, 779, 117,
+ 1079, 404, -98, 80,
+ 136, 165, 142, -1394,
+ 513, -566, -150, 822,
+ 124, 646, 199, 272,
+ -165, -702, -615, 165,
+ 333, 810, -457, 1038,
+ -360, 105, -110, 537,
+ -224, 125, 562, -26,
+ 699, -1105, 809, -1323,
+ -1229, 841, -767, 571,
+ -310, 437, -114, -230,
+ -1045, 630, 564, 322,
+ 282, 1170, -723, -306,
+ -328, -247, -251, -598,
+ 354, 332, -1593, 499,
+ 332, -23, 219, 304,
+ 325, -1511, 378, 299,
+ -94, -54, 679, 956,
+ 507, 830, 861, -739,
+ -895, -135, 16, -34,
+ 677, 650, 961, 714,
+ 816, -665, -1741, -671,
+ 274, 93, -617, -433
+};
+const Word16 YG_dicMR_4_fx[4*16] = /*Q12 */
+{
+ -163, -44, -108, 32,
+ 556, 153, 115, 120,
+ 617, 818, 802, 719,
+ -639, -665, 122, 664,
+ 353, -555, -352, -86,
+ -1162, 833, -1034, 326,
+ -511, -406, -478, -523,
+ 491, -1473, 404, -21,
+ 148, 288, -45, -544,
+ -61, 172, -791, -44,
+ 715, -449, 861, 504,
+ -108, 263, 610, 118,
+ 962, 826, -1013, -37,
+ -32, -495, 362, -214,
+ -37, 661, -75, 289,
+ -835, 243, 85, -105
+};
+
+
+/***********IN Q15*****************/
+const Word16 sm_table_fx[] =
+{
+ 32767, 32126, 31480, 30838, 30196, 29557, 28918, 28279, 27643, 27007,
+ 26375, 25746, 25120, 24494, 23875, 23255, 22643, 22033, 21427, 20824,
+ 20228, 19638, 19048, 18468, 17891, 17321, 16758, 16197, 15647, 15103,
+ 14562, 14031, 13507, 12989, 12481, 11980, 11488, 11000, 10525, 10056,
+ 9598, 9146, 8706, 8274, 7851, 7438, 7035, 6642, 6259, 5885,
+ 5521, 5171, 4830, 4499, 4178, 3870, 3572, 3287, 3011, 2746,
+ 2494, 2254, 2025, 1809, 1602, 1412, 1229, 1062, 904, 760,
+ 629, 511, 403, 308, 226, 157, 102, 56, 26, 7,
+};
+
+const Word32 GSC_freq_bits_fx[] =
+{
+ 5505024, 17563648, -1572864, 6553600, 3932160, 2883584, 2621440, 1310720, 0, 0, 1310720, 1048576, 0, 0, 1048576, 0, 0, /* ACELP_7k20*/
+ 5505024, 19660800, -1048576, 6815744, 4194304, 3145728, 2883584, 2359296, 0, 0, 1048576, 1048576, 262144, 262144, 786432, 0, 0, /* ACELP_8k00*/
+ 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_11k60*/
+ 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k15*/
+ 6815744, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_12k85*/
+ 8126464, 25165824, -1048576, 7340032, 4718592, 3407872, 3145728, 2621440, 2621440, 1310720, 1048576, 1048576, 262144, 0, 262144, 786432, 1048576, /* ACELP_13k20*/
+};
+
+const Word32 pow2_fx[] =
+{
+ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576
+};
+
+
+/*----------------------------------------------------------------------------------*
+ * means of ISFs for WB active speech
+ *----------------------------------------------------------------------------------*/
+const Word16 Mean_isf_wb[M] = /* G722.2 active speech ISF's means */
+{
+ 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
+ 8750, 9753,10705, 11728, 12833, 13971,15043, 4037
+};
+const Word16 interpol_isp_amr_wb_fx[] = {14746, 26214, 31457, 32767};
+const Word16 interpol_frac_16k_fx[NB_SUBFR16k] = { 6554, 13107, 19661, 26214, 32767 };
+const Word16 interpol_frac_fx[NB_SUBFR] = {8192, 16384, 24576,32767};
+
+
+/*----------------------------------------------------------------------------------*
+ * ISF quantization (AMR-WB IO mode)
+ *----------------------------------------------------------------------------------*/
+
+const Word16 mean_isf_amr_wb_fx[M] =
+{
+ 738, 1326, 2336, 3578, 4596, 5662, 6711, 7730,
+ 8750, 9753,10705, 11728, 12833, 13971,15043, 4037
+};
+const Word16 mean_isf_noise_amr_wb_fx[M]=
+{
+ 478, 1100, 2213, 3267, 4219, 5222, 6198, 7240,
+ 8229, 9153,10098, 11108, 12144, 13184,14165, 3803
+};
+
+/* ISF codebook - common 1st stage, 1st split (only in AMR-WB IO mode) */
+/*------------------------------------------------------*
+ * Indirection for 1st stage 1st split of 46 bit cb. :
+ The transmitted_index = indirect_dico1[found_index];
+ *------------------------------------------------------*/
+const Word16 Indirect_dico1[SIZE_BK1] =
+{
+ 2, 6, 18, 22, 34, 35, 38, 50,
+ 66, 67, 70, 82, 98, 99, 102, 130,
+ 131, 134, 146, 150, 162, 178, 194, 198,
+ 210, 226, 230, 242, 0, 1, 3, 4,
+ 5, 7, 8, 9, 10, 11, 12, 13,
+ 14, 15, 16, 17, 19, 20, 21, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 36, 37, 39, 40, 41, 42,
+ 43, 44, 45, 46, 47, 48, 49, 51,
+ 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 62, 63, 64, 65, 68, 69,
+ 71, 72, 73, 74, 75, 76, 77, 78,
+ 79, 80, 81, 83, 84, 85, 86, 87,
+ 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 100, 101, 103, 104, 105, 106,
+ 107, 108, 109, 110, 111, 112, 113, 114,
+ 115, 116, 117, 118, 119, 120, 121, 122,
+ 123, 124, 125, 126, 127, 128, 129, 132,
+ 133, 135, 136, 137, 138, 139, 140, 141,
+ 142, 143, 144, 145, 147, 148, 149, 151,
+ 152, 153, 154, 155, 156, 157, 158, 159,
+ 160, 161, 163, 164, 165, 166, 167, 168,
+ 169, 170, 171, 172, 173, 174, 175, 176,
+ 177, 179, 180, 181, 182, 183, 184, 185,
+ 186, 187, 188, 189, 190, 191, 192, 193,
+ 195, 196, 197, 199, 200, 201, 202, 203,
+ 204, 205, 206, 207, 208, 209, 211, 212,
+ 213, 214, 215, 216, 217, 218, 219, 220,
+ 221, 222, 223, 224, 225, 227, 228, 229,
+ 231, 232, 233, 234, 235, 236, 237, 238,
+ 239, 240, 241, 243, 244, 245, 246, 247,
+ 248, 249, 250, 251, 252, 253, 254, 255
+};
+
+const Word16 dico1_isf_fx[]=
+{
+ 740, 1263, 1292, 1006, 997, 1019, 1017, 976, 923,
+ 557, 946, 1049, 867, 846, 990, 1112, 1262, 1241,
+ 633, 898, 996, 756, 662, 683, 783, 909, 996,
+ 830, 736, 278, 820, 1254, 686, 712, 1039, 473,
+ 503, 885, 1508, 1307, 1282, 1172, 1119, 1209, 1061,
+ 416, 719, 989, 1227, 1001, 1052, 954, 741, 1044,
+ 585, 1132, 1233, 1091, 1247, 1433, 1512, 1448, 1314,
+ -31, 469, 803, 659, 619, 658, 843, 987, 1113,
+ 842, 1678, 1841, 1549, 1474, 1256, 1082, 905, 742,
+ 370, 1216, 1768, 1633, 1212, 636, 22, -330, 71,
+ 73, 738, 893, 968, 993, 1768, 2273, 1840, 1391,
+ 1513, 1714, 1238, 534, 276, 315, 461, 459, 508,
+ 421, 1293, 1640, 1623, 1742, 1617, 1499, 1284, 1006,
+ -95, 752, 1680, 1569, 1618, 1436, 1200, 980, 712,
+ -78, 831, 1194, 1110, 1378, 1481, 1492, 1365, 1217,
+ 670, 1208, 1168, 860, 742, 601, 528, 403, 309,
+ 397, 621, 966, 752, 579, 398, 400, 329, 252,
+ 510, 864, 1108, 807, 939, 902, 925, 717, 481,
+ 539, 835, 913, 719, 617, 544, 591, 565, 642,
+ 162, 889, 654, 108, -34, 244, 488, 561, 532,
+ -62, 1033, 1308, 1035, 1127, 1098, 1029, 961, 823,
+ -14, 945, 990, 801, 755, 815, 847, 913, 892,
+ 394, 1765, 1666, 1339, 1117, 806, 642, 479, 380,
+ 529, 1851, 2003, 1228, 622, -41, -416, 344, 819,
+ 635, 1058, 883, 492, 372, 312, 317, 274, 241,
+ 279, 966, 1642, 1478, 1463, 1123, 795, 525, 339,
+ 457, 955, 1177, 1214, 1427, 1457, 1345, 917, 539,
+ 148, 751, 1515, 1105, 867, 606, 474, 448, 399,
+ 579, 1081, 1035, 390, 3, -263, -198, -82, 38,
+ 18, -68, -12, 313, 761, 405, 249, 111, -76,
+ -91, 827, 948, 648, 613, 535, 522, 490, 421,
+ 41, -44, -281, -472, 652, 534, 193, 135, -90,
+ 41, -121, -356, -60, 663, 307, 61, -48, -344,
+ -118, -204, 328, 512, 870, 793, 610, 402, 186,
+ 156, 293, 74, -338, -475, -897, -594, -161, -497,
+ 226, 131, -138, 307, 169, -271, -164, -387, -624,
+ 62, -32, -61, -252, -541, -828, -1027, -523, -662,
+ 102, -61, 141, 112, -270, -251, -541, 25, -150,
+ 6, -132, -356, -686, -96, -322, -522, -31, -326,
+ -36, -209, -521, -229, 307, -132, -5, -99, -384,
+ 60, -51, -237, -668, -973, -407, -708, -75, -172,
+ 26, -138, -266, 111, -302, 43, -278, -356, -359,
+ 570, 822, 496, -154, -312, -92, 137, 279, 371,
+ -146, 368, 409, 68, 6, 77, 167, 202, 162,
+ -103, 294, 607, 415, 483, 462, 480, 431, 408,
+ -120, -338, -612, -524, 584, 331, 92, 433, 276,
+ -178, -293, -154, -41, 269, 100, -9, 213, 160,
+ -218, -304, 463, 454, 397, 273, 202, 286, 273,
+ -232, 7, 6, -388, -472, -427, -378, -167, -100,
+ -294, -183, 134, -47, 101, -88, -84, -117, -3,
+ 57, 17, -202, -634, -989, -1119, -533, 176, -36,
+ 120, -28, 23, 111, -319, 318, -22, -77, 266,
+ -271, -464, -434, -658, -640, -385, -385, -99, -69,
+ -198, -259, -266, -44, -39, -139, -137, 171, 66,
+ 9, -145, -377, -846, -1000, -111, -325, 342, 135,
+ -81, -286, -380, 192, -57, 307, 76, -24, -140,
+ 677, 702, 247, 56, 249, 141, -105, -236, -99,
+ 36, -39, -69, 348, 198, -93, 322, 91, -72,
+ -127, -376, -657, 139, 623, 223, 501, 306, 220,
+ -113, -384, -796, 504, 438, 85, 213, -83, -194,
+ -174, -422, 7, 1155, 1089, 1182, 1003, 945, 806,
+ 8, -126, -317, -103, -351, -695, -98, -268, -537,
+ 33, -103, -290, 167, -39, -407, 44, -208, -375,
+ 104, -23, -64, -291, -637, -851, -1084, -61, -112,
+ -75, -306, -434, 218, -148, -354, -680, -133, -216,
+ -121, -377, -718, -97, -130, -361, -156, -379, -599,
+ -56, -254, -586, 235, 157, -214, 11, -260, -149,
+ -124, -267, -397, -580, -593, -527, -805, -385, 346,
+ -193, -440, -708, -351, -141, -255, -499, -147, -185,
+ 448, 660, 494, 208, 509, 461, 338, 291, 149,
+ -223, 88, 335, 159, 212, 191, 286, 308, 205,
+ -171, -242, 514, 362, 295, 524, 552, 694, 585,
+ -64, -308, -448, -21, 284, 786, 446, 289, 92,
+ -218, -390, -7, 169, 206, 330, 352, 408, 358,
+ -36, 702, 959, 859, 861, 1115, 1269, 1357, 1305,
+ -133, -341, -65, 678, 417, 440, 486, 518, 780,
+ 33, -44, -191, -344, -461, -755, -201, 217, -31,
+ -353, -547, -44, 123, -61, -68, -79, 29, 60,
+ 73, -57, -406, -766, -1243, -1203, 240, 400, 165,
+ -73, -282, -601, -213, -171, -375, 332, 35, -103,
+ -29, -207, -553, -476, -638, -908, 172, -22, -135,
+ -192, -239, -164, -103, -111, -47, 153, 125, 110,
+ -1, -203, -570, -1030, -1424, -535, 155, 1, 147,
+ -333, -653, -865, -197, -158, -21, -44, 95, 108,
+ 389, 588, 490, 33, -237, -524, -628, -136, -260,
+ 40, -177, -462, 453, 862, 380, 131, -130, -405,
+ -76, -281, -741, -742, 898, 619, 277, 71, -222,
+ -32, -265, -556, -25, 994, 682, 305, 126, -165,
+ -69, -349, -585, 234, 1158, 903, 626, 510, 251,
+ -1, -99, -272, -210, -603, -351, -540, -811, -383,
+ -16, -230, -504, 410, 149, -205, -343, -651, -639,
+ 103, -9, -227, -205, -562, -781, -1079, -1208, -156,
+ 143, 63, -135, -67, -317, -602, -784, -1154, -640,
+ -144, -391, -674, -622, -200, -254, -660, -947, -395,
+ -40, -250, -625, 27, 543, 94, -131, -386, -673,
+ -123, -371, -757, -451, -564, -614, -415, -711, -35,
+ -116, -309, -593, -268, 239, -33, -338, -650, -135,
+ 94, 251, 554, 57, -312, -423, -154, -57, 235,
+ -268, -71, 381, 114, -44, -87, 125, 173, 133,
+ -131, -19, 1149, 670, 486, 356, 309, 369, 296,
+ -223, -501, -899, -722, -70, 6, 131, 310, 394,
+ -99, -303, -517, 249, 64, -53, 135, -11, 453,
+ -147, -399, -730, -401, 817, 738, 802, 749, 575,
+ -154, -435, -739, 800, 593, 366, 529, 318, 326,
+ -224, 45, -39, -387, -515, -518, -608, -384, -321,
+ -315, -377, 143, -101, -113, -377, -177, -144, -12,
+ 117, 40, -239, -651, -1051, -581, -737, -990, -328,
+ 26, -50, -157, -23, -453, -283, -531, -546, 192,
+ -252, -501, -743, -589, -627, -499, -328, -118, -72,
+ -324, -494, -244, -306, -144, -177, -262, -135, -78,
+ -36, -234, -519, -961, -1290, -314, -479, -371, -45,
+ -95, -292, -535, -8, -300, 112, -164, -277, 198,
+ -99, -128, 880, 836, 579, 351, 23, -95, -217,
+ -27, -258, 124, 1011, 597, 425, 144, 7, -73,
+ -69, -300, -683, -435, 1132, 899, 504, 332, 109,
+ -74, -323, -637, 563, 1074, 608, 371, 105, -49,
+ -259, -121, 1440, 1334, 1628, 1490, 1438, 1223, 933,
+ -82, -306, -613, -222, -378, -675, -545, -671, -845,
+ 53, -124, -347, 422, 52, -125, -270, -529, 9,
+ 79, -89, -320, -662, -999, -1199, -1243, -676, -297,
+ -68, -273, -611, 137, -146, -397, -627, -845, -220,
+ -112, -346, -797, -826, 234, -132, -188, -278, -522,
+ -159, -405, -734, -419, 293, 74, -167, -167, 184,
+ -153, -437, -833, -1080, -336, -472, -561, -340, -253,
+ -169, -423, -820, -904, -131, -19, -346, -604, 31,
+ 33, -31, 312, 62, -148, 49, -59, 564, 486,
+ -306, -333, 194, -44, 67, 72, 147, 205, 243,
+ -207, -49, 1360, 983, 969, 991, 1014, 1110, 973,
+ -211, -172, 883, 627, 711, 674, 705, 798, 746,
+ -88, -325, -763, -974, 687, 908, 514, 382, 172,
+ -292, -612, -805, 63, 131, 270, 259, 352, 348,
+ -235, -84, 955, 818, 1120, 1289, 1559, 1480, 1285,
+ -180, -461, -614, 657, 691, 745, 854, 783, 713,
+ -97, -309, -477, -614, -777, -734, -768, -526, -472,
+ -344, -476, -35, -169, 49, -77, -150, -240, -141,
+ -52, -268, -639, -919, -1278, -1113, -342, -333, -151,
+ -68, -242, -585, -73, -209, -478, -159, -429, 133,
+ -197, -499, -1005, -1268, -272, -224, -105, -67, 17,
+ -363, -618, -414, -116, -62, 20, 10, 116, 108,
+ -195, -475, -906, -1260, -891, -441, -277, -142, -28,
+ -226, -519, -950, -700, -275, -266, -116, -105, 82,
+ 404, 511, 520, 327, 17, -194, -333, -536, -586,
+ -114, -130, 276, 237, 204, 342, 135, -16, -111,
+ 191, 180, -137, -467, 272, 106, -95, 17, -192,
+ -80, -290, -626, 194, 598, 196, 21, -281, 77,
+ 137, 367, 534, 764, 670, 382, 296, 153, 84,
+ 303, 497, 144, -85, -125, -539, -482, -464, -764,
+ 233, 347, 68, -147, 169, -210, -242, -226, -482,
+ 307, 422, 154, -175, -386, -722, -724, -904, -1015,
+ 309, 308, 160, -60, -470, -420, -598, -791, -219,
+ 68, 121, -137, -560, -146, -446, -515, -494, -729,
+ 130, 53, -227, 46, 474, 32, -161, -192, -490,
+ 213, 164, -71, -465, -876, -161, -456, -587, -48,
+ 218, 117, 39, 177, -194, -88, -226, -418, 50,
+ 210, 547, 569, 279, 121, -44, -50, 10, -84,
+ 58, 140, 182, -5, 267, 117, 106, 211, 198,
+ 153, 559, 872, 460, 222, 108, 188, 180, 183,
+ 158, 119, 284, -153, -271, 229, 87, 110, -57,
+ -183, 82, 118, 21, 13, 40, 118, 191, 185,
+ 163, 56, 609, 341, 50, 329, 68, 266, 218,
+ 100, 206, 18, -304, -107, -436, -487, -65, -306,
+ -86, 154, 134, -30, -45, -73, -104, -80, -96,
+ 245, 330, 10, -440, -849, -1082, 79, 40, -265,
+ 196, 372, 272, -181, -493, -389, 275, 80, -59,
+ 2, -12, -246, -505, -100, -436, 21, -187, -431,
+ -221, -48, 36, -271, -186, -147, -109, 26, 71,
+ 213, 140, 72, -351, -620, -84, -363, 69, 46,
+ 91, 167, -3, -95, -99, -105, -48, 114, 147,
+ 259, 249, 172, 607, 406, 52, 59, -189, -320,
+ 115, -85, -54, 574, 128, 226, -59, -253, 130,
+ 39, 364, 757, 940, 728, 660, 659, 583, 770,
+ -115, -338, -760, -471, 394, 37, 441, 178, 6,
+ -57, -305, -525, 796, 453, 188, -4, -114, 248,
+ 71, 444, 797, 731, 1096, 1157, 1222, 1029, 811,
+ 135, 359, 551, 425, 749, 815, 874, 704, 502,
+ 132, 247, 0, -206, -449, -750, -258, -514, -633,
+ 248, 249, 91, 121, -195, -499, -90, -282, -435,
+ 78, 20, -277, -623, -983, -1224, -415, -458, -639,
+ 347, 509, 208, -179, -464, -728, -76, -237, -486,
+ -103, -343, -756, -713, -265, -609, -191, -398, -636,
+ -121, -383, -749, 567, 252, -36, -354, -417, -50,
+ 204, 100, -149, -650, -1081, -47, -7, -263, 111,
+ -46, -180, -267, -324, -562, -394, -692, 398, 292,
+ 482, 670, 683, 624, 442, 165, 116, 36, -149,
+ 108, 247, 291, 247, 355, 122, 109, 224, 296,
+ 292, 349, 725, 482, 388, 329, 429, 620, 667,
+ -34, 197, 213, -127, 84, 494, 620, 575, 375,
+ 126, 207, 172, 167, 362, 202, 296, 395, 455,
+ -6, 250, 539, 467, 636, 801, 1149, 1287, 1118,
+ 27, 240, 369, 280, 440, 411, 634, 892, 953,
+ 159, 170, -58, -395, -797, -690, 77, -211, -334,
+ -5, -28, -13, -74, -335, -603, 300, 88, -205,
+ 82, -33, -364, -698, -1203, -1153, 110, -146, -289,
+ 113, 1, -243, -588, -994, -496, 414, 160, 42,
+ -56, -247, -440, -693, -996, -479, 11, -178, -357,
+ -151, -353, -327, -211, -340, 141, 65, 425, 453,
+ 34, -169, -455, -932, -1215, 138, 499, 256, 324,
+ 68, 139, -15, -547, -478, 17, 306, 502, 481,
+ -32, -134, 445, 129, -143, -244, -503, -507, -599,
+ 61, -140, -345, 496, 458, -2, 20, -227, -514,
+ 215, 519, 920, 1053, 1090, 791, 528, 290, 155,
+ -54, -233, -647, -602, 639, 294, -2, -167, -442,
+ -78, -315, -791, -113, 820, 403, 158, -116, -356,
+ -105, -379, -236, 1224, 893, 749, 568, 356, 214,
+ -17, -199, -144, 50, -283, -247, -578, -846, -1087,
+ 69, -11, -381, -206, 209, -284, -387, -416, -716,
+ 39, -5, -145, -374, -682, -909, -1074, -1169, -1066,
+ 287, 226, 67, -221, -662, -171, -421, -642, -707,
+ -132, -348, -538, -448, -20, -4, -354, -748, -933,
+ 4, -75, -289, -598, 317, 52, -208, -297, -559,
+ -88, -264, -358, -589, -631, -248, -523, -822, -1071,
+ 70, -8, 54, -314, -515, 92, -146, -274, -493,
+ 199, 62, 391, 158, -141, 71, -219, -203, -207,
+ 152, 40, 329, 162, -29, 48, -149, 108, 127,
+ 267, 722, 1256, 882, 625, 248, 8, -81, -60,
+ -58, -138, -291, -600, -12, -2, -39, 147, 117,
+ -107, -345, -513, 459, 76, 92, -272, 388, 262,
+ 362, 516, 203, -409, -716, -831, -331, 185, 209,
+ -117, -391, -298, 671, 292, 538, 257, 166, -38,
+ -102, -319, -194, -283, -573, -262, -579, -219, -444,
+ -235, 78, 11, -168, -101, -229, -263, -321, -123,
+ 70, 50, -170, -599, -996, -588, -263, -516, -455,
+ 394, 363, 229, -136, -538, 21, -183, -348, -201,
+ -124, -368, -640, -879, -847, -209, -409, -494, -515,
+ -127, -341, -541, -425, -510, -10, -252, -473, -291,
+ 84, -69, -201, -676, -868, 103, -311, -132, -320,
+ 5, -173, -188, -297, -628, 197, -57, 7, -11,
+ 49, -160, 56, 558, 111, 33, -311, -440, -463,
+ -1, -246, -307, 862, 453, 139, -170, -355, -232,
+ -197, -38, 1702, 1331, 1252, 950, 692, 504, 426,
+ -108, -344, -861, -1172, 444, 354, 88, -46, -220,
+ -53, -321, -494, 1113, 744, 364, 198, -34, -75,
+ -69, 199, 897, 1140, 1343, 1183, 977, 742, 522,
+ 122, 44, -269, 27, -155, -562, -307, -590, -773,
+ 154, 42, -160, 252, -129, -305, -471, -733, -371,
+ 135, 185, -82, -416, -722, -913, -504, -743, -880,
+ 149, 214, -84, -329, -680, -835, -426, -661, -81,
+ -128, -380, -735, -998, -337, 17, -182, -467, -697,
+ -84, -290, -510, -592, 13, 440, 154, -38, -279,
+ 70, -61, -246, -727, -1047, -80, -381, -535, -704,
+ 178, -2, -146, -670, -938, 482, 138, 63, 65,
+ -11, 15, 772, 443, 142, -20, -209, -126, -161,
+ -32, -249, 95, 552, 124, 30, -343, 82, -86,
+ -163, -257, 899, 1097, 906, 751, 502, 390, 294,
+ -51, -258, -447, -806, -368, 763, 464, 364, 183,
+ -166, -374, -367, 87, 35, 399, 418, 856, 833,
+ -205, -310, 588, 778, 785, 1065, 1118, 1245, 1157,
+ -173, -312, 107, 345, 400, 790, 870, 1113, 1001,
+ -7, -120, -387, -410, -614, -943, -226, -384, -491,
+ -203, -288, -51, -331, -90, -178, -408, -573, -338,
+ 56, -29, -273, -627, -1041, -798, -247, -467, 148,
+ 66, -2, -205, -205, -575, -349, -57, -352, -58,
+ -45, -225, -471, -924, -497, 77, -32, 44, -135,
+ -277, -491, -497, -502, -424, -202, -137, 77, 96,
+ 26, -179, -469, -1008, -1260, 262, -35, -132, -259,
+ -66, -232, -447, -533, -789, -191, -100, -267, 364,
+ 111, 43, -287, -423, -608, -987, -922, -799, -827,
+ 77, 76, -101, -260, -549, -850, -88, -231, -329,
+ 75, 24, -66, -269, -427, -528, -773, 201, -5,
+ 67, 7, -61, -320, -487, 12, -200, -242, -94,
+ 27, -54, -149, -354, -661, -594, -450, -481, 560,
+ 31, -69, -246, -549, -1141, -178, -232, -275, -288,
+ 16, -84, -176, 7, -83, -210, -246, -424, -589,
+ 63, -60, -201, -90, -269, -400, -685, -1218, -258,
+ 169, 217, 142, -71, -243, -433, -504, -511, -537,
+ 6, -105, -234, -321, -188, -131, -307, -521, -1319,
+ -34, -151, -369, 11, 44, -95, -280, -500, 160,
+ 31, -37, -163, -334, 288, 89, -150, -86, -299,
+ -35, -161, -362, -74, -74, -263, 240, 9, -153,
+ -45, -208, -529, -896, 89, 24, -130, -313, -373,
+ 234, 276, 197, -10, -236, -162, -134, -85, -112,
+ 42, -73, 133, 392, 98, 72, -153, -162, -99,
+ -3, -145, -338, 408, 401, 133, -52, -296, -501,
+ 3, -109, -152, -85, -56, 42, -145, 703, 205,
+ -49, -149, -281, -134, -121, -41, -21, 16, 958,
+ 30, -107, -196, -463, -523, 490, 236, 70, -128,
+ -33, -161, -364, -148, 757, 516, 250, 43, -65,
+ -34, -193, -244, 750, 527, 349, 234, 172, 134,
+ -64, -223, -379, 55, 28, 248, 793, 442, 320,
+ 29, -85, -298, -622, -888, 127, 206, 387, 460,
+ -48, -170, -477, -876, 573, 635, 440, 375, 311,
+ 42, 3, -212, -441, -718, -821, 388, 373, 211,
+ -106, -155, 1092, 459, 570, 561, 506, 604, 514,
+ -144, -264, 0, 460, 619, 877, 916, 1273, 921
+};
+/* ISF codebook - common 1st stage, 2nd split (only in AMR-WB IO mode) */
+const Word16 dico2_isf_fx[] =
+{
+ 1357, 1313, 1136, 784, 438, 181, 145,
+ 636, 648, 667, 568, 442, 217, 362,
+ 427, 440, 674, 524, 332, 117, -417,
+ 121, 295, 468, 465, 230, 44, -221,
+ -147, -240, 149, 80, 390, 278, 106,
+ -418, -556, 552, 511, 235, 144, -95,
+ 43, 193, 274, 150, 67, 34, -273,
+ -43, -126, 171, 416, 282, 63, -354,
+ -372, -86, -344, -108, -94, -182, -89,
+ -600, -840, -200, 465, 258, -11, -253,
+ -48, 329, 97, -290, -543, -795, -354,
+ -570, -117, 187, 10, -133, -416, -76,
+ -618, -129, -247, -371, 45, -76, 277,
+ -1022, -1079, 126, 474, 254, 127, 52,
+ -281, 76, -167, -361, -283, -551, -283,
+ -119, -52, -1, 134, -32, -204, -415,
+ 1064, 827, 637, 684, 464, 209, 12,
+ 482, 416, 449, 371, 335, 294, 194,
+ 719, 576, 365, 135, 113, 91, -199,
+ 298, 176, 493, 366, 194, 163, 36,
+ -35, -236, -259, -36, -4, 99, 152,
+ -98, -306, -27, 228, 90, 111, -86,
+ 91, 13, -211, -258, -106, 86, -64,
+ 73, -35, -57, -31, 162, 35, -192,
+ -109, -335, -629, -66, -61, -128, 322,
+ -495, -669, -728, 193, 31, -220, 122,
+ 324, 95, -89, -91, -409, -710, -154,
+ 0, -234, 92, 33, -343, -609, -220,
+ -343, -408, -476, -655, -153, 82, 222,
+ -490, -745, -255, 49, -48, 135, -127,
+ 119, -67, -328, -390, -272, -545, -56,
+ -57, -130, -10, -7, -164, -47, -22,
+ 984, 1064, 961, 568, 210, -27, 16,
+ 811, 691, 754, 514, 224, -35, 166,
+ 662, 704, 618, 386, 57, -211, -257,
+ 510, 359, 418, 393, 91, -144, -18,
+ -193, -31, -27, 223, 89, -143, 24,
+ -112, -98, 471, 319, 185, 3, 175,
+ 252, 146, -47, 272, 48, -211, -234,
+ 146, 69, 203, 364, 68, -52, 51,
+ -259, -478, -697, -349, -758, -501, 63,
+ -501, -769, -289, 79, -311, -497, -106,
+ 251, 53, -235, -469, -895, -884, 145,
+ -416, -551, 140, -133, -523, -775, 44,
+ -326, -423, -713, -497, -86, -431, 99,
+ -757, -772, -160, -76, -46, -32, 379,
+ 85, -35, -200, -401, -663, -1040, -247,
+ -180, -330, -92, -376, 27, -183, -110,
+ 1279, 1086, 781, 502, 324, 164, 157,
+ 682, 466, 449, 277, 146, 28, 409,
+ 635, 472, 390, 107, -232, -538, -139,
+ 196, 396, 332, 213, 209, -29, -81,
+ 150, -95, -312, 76, -77, -320, -50,
+ 46, 9, 47, 175, 139, 30, 384,
+ 218, 206, -24, -250, -96, -276, -183,
+ 26, 119, 38, 14, -4, -133, -52,
+ -477, -614, -987, -715, -631, -813, 200,
+ -744, -1009, -1065, -745, -631, -171, 18,
+ -137, -251, -483, -613, -980, -1203, 12,
+ -605, -767, -562, -686, -1088, -515, 58,
+ -202, -428, -782, -1072, -96, -234, -179,
+ -480, -709, -1070, -897, -131, -92, 321,
+ -145, -193, -512, -729, -572, -765, -210,
+ -331, -585, -525, -631, -281, -208, -303,
+ 1165, 1104, 939, 828, 716, 426, 155,
+ 6, -109, 820, 778, 415, 113, -27,
+ 381, 339, 314, 265, 121, -9, -474,
+ -373, 47, 584, 442, 99, -231, -113,
+ -496, -38, -285, 262, 305, 170, 4,
+ -587, -556, 69, 66, 471, 354, 13,
+ -138, 70, -18, 106, 67, 167, -302,
+ -445, -141, 185, 191, 151, 83, -133,
+ -257, -521, -720, -198, 134, -46, -182,
+ -819, -1168, -777, 512, 359, 95, -113,
+ 137, -2, -74, -138, -401, -114, -371,
+ -242, -466, 204, 223, -31, -212, -192,
+ -532, -637, -466, -686, 256, 277, -139,
+ -1141, -1244, -381, -75, -54, 14, 88,
+ -311, 115, -143, -499, -343, 124, -416,
+ -616, -147, -135, 43, -4, 121, -369,
+ 835, 783, 641, 390, 355, 350, 64,
+ 72, 194, 443, 467, 436, 219, 372,
+ 464, 369, 192, 4, -156, -72, -226,
+ 57, 206, 303, 205, 188, 101, 265,
+ -40, -205, -488, -184, 276, 64, -26,
+ -217, -433, -297, 137, 328, 308, -289,
+ 378, 81, -308, -465, 57, -37, 227,
+ -100, 24, -36, -151, 199, 8, 143,
+ -426, -697, -1059, -133, 388, 161, 321,
+ -644, -1023, -1271, 39, 66, -123, 70,
+ 372, 177, -173, -556, -553, -304, -189,
+ -117, -369, -425, -122, -462, -152, -73,
+ -649, -850, -1189, -767, 497, 360, 222,
+ -798, -1139, -1455, -190, 430, 234, 179,
+ 42, -94, -405, -692, 38, -202, -246,
+ -169, -366, -290, -88, -64, 32, -292,
+ 1010, 923, 938, 710, 465, 230, 342,
+ 217, 300, 1054, 675, 68, -458, -179,
+ 78, 453, 316, 18, -237, -496, -243,
+ 167, 21, 424, 215, -91, -303, -170,
+ -290, -81, -70, -67, 40, 54, -59,
+ -353, -427, -90, 53, 94, 9, 54,
+ -28, 318, 283, 15, -240, -58, 79,
+ -75, -121, 229, 35, 58, 6, -133,
+ -351, -514, -744, -834, -705, -137, 164,
+ -1124, -1388, -1055, -230, -73, 40, 36,
+ -163, -233, -532, -785, -1170, -697, 96,
+ -788, -959, -246, -430, -624, -165, -8,
+ -856, -540, -630, -907, -337, -70, 76,
+ -937, -1042, -659, -733, -208, 199, -26,
+ -523, 78, -98, -501, -869, -890, -81,
+ -624, -703, -45, -348, -25, 87, -186,
+ 1005, 823, 546, 249, 90, -22, 207,
+ 298, 397, 381, 319, 200, 62, 303,
+ 473, 379, 133, -247, -632, -441, 75,
+ 284, 208, 391, 115, -25, 44, 95,
+ -72, 79, -95, -63, -129, -293, 203,
+ -164, -349, 115, 122, 69, -1, 378,
+ 348, 170, 99, 58, -179, -302, 188,
+ -190, -2, 150, 23, -51, -11, 216,
+ -615, -863, -1090, -1427, -802, -48, -6,
+ -961, -1276, -1548, -727, -58, 56, 223,
+ -124, -255, -561, -988, -1277, -148, -82,
+ -480, -660, -891, -1191, -1339, -325, 20,
+ -621, -917, -1296, -1350, 264, 289, 50,
+ -844, -1022, -1345, -1329, -293, 46, 278,
+ -260, -468, -829, -1176, -533, -560, -78,
+ -215, -484, -822, -1233, -791, 15, -138,
+ 1301, 1317, 1262, 1048, 716, 357, -64,
+ 578, 824, 925, 802, 630, 362, 102,
+ 470, 925, 767, 514, 327, 190, -112,
+ 225, 492, 495, 437, 598, 384, -45,
+ 43, 82, -42, 175, 519, 342, -64,
+ -304, -154, 159, 576, 403, 221, 327,
+ 214, 244, 122, -62, 312, 92, -160,
+ 218, 208, 310, 268, 306, 323, -199,
+ -285, -269, -79, -124, -143, -153, 236,
+ -205, -384, -426, 344, 59, -185, -184,
+ -272, 247, 126, -210, -518, -468, 78,
+ -99, -120, 502, 160, -280, -557, 304,
+ -423, -17, -283, -443, 215, 212, -140,
+ -564, -684, -228, 510, 361, 130, 323,
+ -428, 335, 98, -65, 36, -215, -246,
+ -362, 51, 364, -16, -234, 150, -165,
+ 914, 883, 751, 653, 676, 464, -153,
+ 631, 545, 535, 720, 596, 360, -81,
+ 783, 712, 512, 439, 341, 251, -391,
+ 497, 417, 249, 372, 295, 173, -193,
+ 128, -110, -385, 93, 39, 173, -231,
+ 216, -59, -253, 462, 389, 154, 69,
+ 455, 270, -4, -337, -49, 233, -322,
+ 307, 143, 53, 218, 128, 236, -156,
+ -37, -186, -240, -411, -110, 9, 399,
+ -140, -365, -628, 258, 380, 214, 277,
+ 131, 454, 177, -285, -520, 108, -214,
+ 77, -141, 201, -123, -490, -131, 60,
+ -14, -194, -521, -741, 273, 362, -33,
+ -362, -566, -287, -228, 161, 237, 317,
+ -269, 195, -75, -375, -204, 11, 77,
+ -128, -264, -156, -223, -475, 265, 27,
+ 1238, 1147, 916, 689, 432, 210, -280,
+ 800, 664, 879, 726, 411, 160, -164,
+ 454, 686, 536, 275, 147, 46, 111,
+ 303, 486, 512, 355, 241, 181, -69,
+ 79, 92, 29, 147, 233, 52, 17,
+ -171, 289, 131, 439, 271, 3, -10,
+ 413, 241, 144, 174, 155, -2, 14,
+ 58, 217, 247, 219, 149, 175, -18,
+ 228, -8, -240, -206, -513, -191, 202,
+ -96, -272, -454, 33, -300, -575, 46,
+ -10, -108, -246, -347, -770, -535, 9,
+ -326, -430, -61, -321, -704, -299, 201,
+ -1, -280, -603, -419, -185, 18, -36,
+ -516, -522, -379, -291, -181, -97, 27,
+ -159, -313, -525, -224, -510, -831, -197,
+ -292, -459, -59, -310, -562, -143, -351,
+ 1066, 912, 631, 389, 207, 86, -224,
+ 596, 512, 596, 505, 314, 122, -48,
+ 787, 861, 441, -93, -303, 33, -190,
+ 257, 469, 337, 51, 15, 298, -93,
+ 295, 73, -119, 25, 36, 23, 108,
+ -28, -3, -32, 114, 21, 185, 107,
+ 482, 305, 15, -279, -319, 52, 96,
+ 226, 46, 115, 72, -136, 133, -125,
+ 18, -207, -559, -590, -503, -482, 321,
+ -571, -789, -951, -172, -441, -538, 113,
+ 181, 14, -310, -641, -1001, -202, 159,
+ -136, -393, -433, -513, -911, -144, -22,
+ 72, -265, -706, -954, -159, 53, 332,
+ -338, -591, -852, -383, -395, 56, 44,
+ 43, -158, -464, -897, -631, -157, -294,
+ -161, -128, -328, -573, -483, -125, 11,
+ 1017, 906, 1051, 1005, 679, 341, -102,
+ 359, 334, 1567, 1314, 723, 105, 10,
+ -65, 726, 529, 301, 220, 43, -273,
+ -510, 436, 719, 566, 358, 179, 114,
+ -560, 298, 133, -120, 342, 225, 14,
+ -899, -101, 217, 617, 400, 146, -58,
+ -41, 352, 82, -196, 39, 121, -167,
+ -212, 59, 447, 284, 423, 250, -169,
+ -371, -484, -596, 30, -41, 249, 22,
+ -372, -650, -794, 477, 445, 216, -79,
+ -352, 275, 17, -443, -929, 92, 19,
+ -699, -696, 431, 264, -49, -310, 182,
+ -978, -217, -430, -400, 101, 261, 72,
+ -929, -889, -357, -13, 463, 378, 236,
+ -826, 56, 30, -299, -360, -128, -51,
+ -878, -299, -111, 75, 65, 36, 3,
+ 817, 368, -25, 354, 697, 591, -173,
+ 309, 212, 222, 751, 484, 140, -56,
+ 593, 379, 70, -8, 258, 180, 110,
+ 165, -46, 255, 297, 219, 273, 105,
+ 160, -70, -358, -181, 379, 330, 319,
+ -238, -369, -198, 740, 580, 319, -143,
+ 201, 109, -202, -456, 328, 276, -141,
+ 203, 170, 111, 42, 207, 360, 188,
+ -345, -399, -513, -233, 650, 422, 81,
+ -635, -961, -1220, 463, 539, 204, 209,
+ 202, -25, -194, -498, -787, 193, -143,
+ -449, -538, 195, -106, -331, 68, 62,
+ -228, -477, -840, -576, 317, 128, 283,
+ -671, -937, -807, -114, 391, 335, -62,
+ 246, 2, -314, -679, -303, 180, -88,
+ -107, -272, 90, -198, -28, 290, -112,
+ 885, 1149, 1021, 712, 496, 281, -83,
+ 269, 492, 787, 643, 347, 70, 124,
+ 336, 636, 499, 92, -229, -179, 191,
+ 26, 402, 564, 340, 149, -11, 135,
+ -440, 561, 470, 204, -72, -186, 140,
+ -720, 14, 355, 229, 68, -133, 465,
+ 110, 310, 103, 12, 106, 29, 158,
+ -178, 113, 161, 142, 121, 115, 27,
+ -651, -414, -645, -152, -164, -13, -429,
+ -639, -944, -681, -104, -81, 52, -189,
+ -663, -164, -316, -683, -954, -205, -83,
+ -609, -669, -172, -517, -694, 283, -80,
+ -646, -152, -383, -678, -246, -40, -143,
+ -747, -796, -745, -390, -98, 43, 275,
+ -599, -199, -398, -433, -436, -538, 31,
+ -1107, -568, -376, -265, -126, -21, 1,
+ 847, 573, 308, 392, 305, 101, 55,
+ 273, 293, 201, 267, 346, 201, 123,
+ 727, 480, 226, 2, -65, -138, 164,
+ 273, 208, 173, 292, 12, 253, 174,
+ 340, 207, 180, 88, 116, 46, 475,
+ -460, -166, -30, 13, 110, 173, 396,
+ 137, 88, 43, -137, -94, 34, 284,
+ 96, -14, 226, 40, 63, 70, 130,
+ -467, -735, -1012, -1174, -307, 305, -67,
+ -612, -920, -1146, -567, -8, 92, -25,
+ -182, -271, -492, -754, -857, 287, -75,
+ -494, -787, -689, -683, -709, 137, -326,
+ -288, -550, -903, -1105, 334, 321, -62,
+ -354, -653, -834, -445, 1, 377, -152,
+ -162, -306, -608, -937, -297, 247, -192,
+ -234, -477, -244, -488, -266, 342, -332
+};
+
+/* ISF codebook - 46b, 2nd stage, 1st split (only in AMR-WB IO mode) */
+const Word16 dico21_isf_46b_fx[] =
+{
+ 329, 409, 249,
+ -33, 505, 160,
+ -29, -14, 582,
+ -262, 127, 354,
+ 145, 237, 175,
+ -152, 245, 122,
+ 27, 42, 340,
+ -84, -93, 311,
+ 285, 222, -156,
+ 47, -43, -504,
+ 234, 121, 385,
+ 104, -317, 45,
+ 176, 195, 8,
+ 104, -59, -94,
+ 177, 53, 192,
+ -34, -127, 152,
+ 570, 277, -34,
+ -67, -329, -639,
+ -157, -272, 462,
+ -177, -462, 198,
+ 322, 179, 115,
+ -386, 171, 19,
+ 19, -12, 195,
+ -120, -252, 201,
+ 304, 36, -336,
+ -128, -221, -380,
+ 171, -185, 296,
+ -242, -312, 23,
+ 198, 39, 16,
+ -3, -177, -111,
+ 111, -93, 76,
+ -92, -223, 4,
+ 177, 406, -44,
+ -168, 380, -149,
+ -4, 273, 331,
+ -420, 513, 277,
+ 21, 247, 47,
+ -58, 131, -2,
+ -3, 134, 180,
+ -145, 40, 175,
+ 189, 74, -145,
+ -27, -45, -325,
+ 370, -114, -21,
+ -83, -415, -173,
+ 77, 95, -51,
+ -40, -30, -67,
+ 71, 88, 86,
+ -35, -98, 14,
+ 69, 197, -334,
+ -196, 79, -231,
+ -348, -137, 218,
+ -352, -89, -85,
+ 47, 201, -130,
+ -165, 37, -15,
+ -43, 3, 86,
+ -161, -108, 79,
+ 83, 21, -237,
+ -81, -149, -238,
+ 150, -186, -251,
+ -186, -249, -162,
+ -19, 66, -139,
+ -26, -50, -181,
+ 24, 11, 0,
+ -130, -105, -98
+};
+/* ISF codebook - 46b, 2nd stage, 2st split (only in AMR-WB IO mode) */
+const Word16 dico22_isf_46b_fx[]=
+{
+ -127, 310, 42,
+ -242, 197, 5,
+ -151, 84, -17,
+ -214, 127, -149,
+ -247, -131, 159,
+ -268, -267, -95,
+ -217, 1, -79,
+ -271, -80, -185,
+ -45, 436, 159,
+ 165, 199, 391,
+ -33, 81, 187,
+ -66, -42, 355,
+ -298, -57, 343,
+ -108, -537, 226,
+ -144, -23, 193,
+ 176, -402, 87,
+ 53, 296, 25,
+ -84, 253, -104,
+ -58, 105, -126,
+ -169, 174, -314,
+ -48, 44, -294,
+ -164, -417, -242,
+ -139, 3, -194,
+ -155, -207, -211,
+ 119, 322, 213,
+ 333, 50, 380,
+ 237, 247, -2,
+ 466, -16, 201,
+ 238, -255, -107,
+ 67, -440, -149,
+ 122, -88, -139,
+ 88, -247, -73,
+ -41, 231, 167,
+ -62, 155, 16,
+ -65, 16, 77,
+ -68, -2, -63,
+ -151, -300, 160,
+ -18, -333, 54,
+ -56, -94, 5,
+ 2, -190, 14,
+ 92, 148, 209,
+ 108, 9, 272,
+ 108, 35, 110,
+ 142, -85, 145,
+ 47, -157, 279,
+ 3, -320, 246,
+ 43, -72, 68,
+ 86, -217, 135,
+ 36, 140, 79,
+ 56, 175, -49,
+ 26, 45, 3,
+ 73, 55, -101,
+ 109, -183, -242,
+ -4, -283, -242,
+ 48, -68, -48,
+ -6, -153, -122,
+ 161, 196, 96,
+ 232, 80, 190,
+ 165, 97, 11,
+ 258, -31, 71,
+ 267, -77, -91,
+ 311, -209, 87,
+ 152, -14, -22,
+ 150, -149, 9,
+ -324, 557, 187,
+ -384, 307, 46,
+ -251, 27, 77,
+ -365, 77, -52,
+ -482, -84, 160,
+ -424, -515, -64,
+ -294, -120, -4,
+ -476, -116, -109,
+ -97, 318, 365,
+ 106, 627, 445,
+ -190, 120, 287,
+ -146, 65, 619,
+ -427, 242, 363,
+ -361, -371, 432,
+ -347, 102, 168,
+ -629, 195, -14,
+ -65, 476, -47,
+ -297, 320, -168,
+ -55, 356, -264,
+ -391, 82, -286,
+ -51, -31, -556,
+ -178, -399, -586,
+ -205, -49, -360,
+ -343, -238, -337,
+ 220, 457, 58,
+ 561, 467, 259,
+ 340, 270, -168,
+ 450, 77, -280,
+ 60, 167, -413,
+ 133, -252, -492,
+ 216, 157, -290,
+ 282, 0, -495,
+ -226, 293, 183,
+ -157, 135, 122,
+ -158, -59, 39,
+ -133, -118, -97,
+ -332, -309, 113,
+ -160, -425, -6,
+ -149, -211, 24,
+ -80, -277, -90,
+ -11, 125, 338,
+ 130, -71, 465,
+ 5, -45, 184,
+ 237, -95, 253,
+ -139, -197, 297,
+ -19, -300, 511,
+ -63, -152, 139,
+ 250, -289, 336,
+ 124, 339, -150,
+ 34, 176, -208,
+ 171, 166, -116,
+ 94, 38, -229,
+ 75, -65, -339,
+ -78, -205, -385,
+ 0, -30, -163,
+ -56, -110, -242,
+ 321, 244, 194,
+ 505, 238, -1,
+ 317, 116, 65,
+ 309, 88, -74,
+ 452, -51, -50,
+ 334, -217, -290,
+ 211, 41, -152,
+ 238, -55, -260
+};
+
+/* ISF codebook - 46b, 2nd stage, 3rd split (only in AMR-WB IO mode) */
+const Word16 dico23_isf_46b_fx[]=
+{
+ -10, 151, 359,
+ 136, 298, 223,
+ 255, -104, 290,
+ 423, 6, 183,
+ -270, -269, -98,
+ -52, -82, 13,
+ -82, -274, -97,
+ 90, -246, -72,
+ -299, -70, 421,
+ -88, 365, 430,
+ 187, -318, 381,
+ 380, 37, 488,
+ -373, -316, 79,
+ -308, -101, 5,
+ -135, -451, 8,
+ 72, -421, -154,
+ 180, 170, -121,
+ 62, 177, -40,
+ 326, 80, -105,
+ 248, 263, -5,
+ -168, -181, -221,
+ -2, -23, -158,
+ -14, -149, -121,
+ 119, -91, -147,
+ 119, 332, -153,
+ 49, 303, 34,
+ 442, -55, -69,
+ 217, 454, 58,
+ -359, -187, -375,
+ -42, 50, -274,
+ -8, -267, -249,
+ 85, -86, -346,
+ -77, -40, 345,
+ 89, 134, 219,
+ 156, -80, 160,
+ 108, 40, 116,
+ -158, -206, 29,
+ 5, -32, 175,
+ -65, -158, 146,
+ 55, -78, 73,
+ -114, -222, 353,
+ -47, 81, 211,
+ 49, -151, 268,
+ 105, 4, 302,
+ -263, -132, 183,
+ -151, -28, 201,
+ -177, -307, 166,
+ 101, -221, 130,
+ 74, 58, -98,
+ 32, 44, 13,
+ 194, 30, -142,
+ 170, 96, 8,
+ -136, -119, -91,
+ -65, 8, -55,
+ 3, -188, 12,
+ 45, -63, -49,
+ 149, -21, -19,
+ 24, 144, 95,
+ 254, -22, 60,
+ 161, 196, 96,
+ -158, -61, 48,
+ -70, 33, 82,
+ -23, -321, 58,
+ 155, -147, 5,
+ -364, 328, 77,
+ -21, 453, 173,
+ -108, 82, 630,
+ 367, 263, 208,
+ -300, -62, -176,
+ -205, 143, -158,
+ -169, -410, -264,
+ 257, -269, -100,
+ -636, 289, -2,
+ -292, 627, 173,
+ -382, -363, 387,
+ 248, 524, 447,
+ -521, -111, -107,
+ -395, 118, -274,
+ -343, -680, -125,
+ -172, -447, -663,
+ 75, 148, -367,
+ -79, 263, -94,
+ 249, 148, -286,
+ 380, 271, -162,
+ -142, -4, -186,
+ -57, 111, -125,
+ -35, -108, -254,
+ 100, 29, -242,
+ -80, 303, -264,
+ -78, 464, -57,
+ 248, -22, -494,
+ 661, 662, 44,
+ -193, -40, -330,
+ -178, 145, -337,
+ -90, -199, -400,
+ -40, -23, -498,
+ -192, 114, 315,
+ -41, 244, 190,
+ 88, -97, 485,
+ 241, 80, 212,
+ -246, 40, 87,
+ -156, 147, 134,
+ -2, -334, 239,
+ 308, -203, 110,
+ -459, 251, 422,
+ -218, 310, 228,
+ -86, -346, 654,
+ 184, 175, 425,
+ -481, -63, 169,
+ -349, 117, 188,
+ -125, -560, 310,
+ 158, -416, 94,
+ 46, 171, -192,
+ -63, 157, 14,
+ 256, -35, -271,
+ 322, 123, 53,
+ -214, 4, -76,
+ -156, 86, -18,
+ 128, -197, -232,
+ 265, -90, -98,
+ -308, 332, -145,
+ -131, 308, 58,
+ 509, 59, -339,
+ 562, 196, -14,
+ -378, 100, -47,
+ -234, 202, 1,
+ 104, -270, -493,
+ 319, -210, -325
+};
+/* ISF codebook - 46b, 2nd stage, 4th split (only in AMR-WB IO mode) */
+const Word16 dico24_isf_46b_fx[]=
+{
+ -79, -89, -4,
+ -171, 77, -211,
+ 160, -193, 98,
+ 120, -103, 323,
+ 32, -22, -129,
+ 72, 78, -268,
+ 182, -76, -66,
+ 309, 99, -145,
+ -229, -157, -84,
+ -383, 98, -71,
+ -90, -352, 12,
+ -284, -178, 178,
+ -65, -125, -166,
+ -87, -175, -351,
+ 42, -198, -48,
+ 154, -140, -243,
+ -77, 18, 108,
+ -39, 355, 91,
+ 87, 8, 155,
+ -4, 158, 239,
+ 128, 95, -54,
+ 7, 246, -124,
+ 258, 15, 89,
+ 206, 216, 98,
+ -201, 9, 18,
+ -312, 233, 204,
+ -39, -174, 155,
+ -144, -9, 284,
+ -57, 70, -69,
+ -157, 187, 18,
+ 54, -30, 23,
+ 24, 135, 55
+};
+
+/* ISF codebook - 46b, 2nd stage, 5th split (only in AMR-WB IO mode) */
+const Word16 dico25_isf_46b_fx[]=
+{
+ 169, 142, -119, 115,
+ 206, -20, 94, 226,
+ -106, 313, -21, 16,
+ -62, 161, 71, 255,
+ -89, 101, -185, 125,
+ 72, -30, -201, 344,
+ -258, 33, -8, 81,
+ -104, -154, 72, 296,
+ 144, -68, -268, -25,
+ 81, -78, -87, 106,
+ 22, 155, -186, -119,
+ -46, -28, 27, 91,
+ -114, -37, -175, -33,
+ -94, -222, -189, 122,
+ -132, -119, -191, -270,
+ -172, -173, 18, -43,
+ 279, 135, -42, -128,
+ 187, -86, 229, -138,
+ 159, 240, 140, 46,
+ 69, 25, 227, 77,
+ 21, 115, 13, 8,
+ 68, -248, 126, 81,
+ -150, 137, 207, -9,
+ -154, -133, 289, 67,
+ 143, -37, -86, -326,
+ 180, -32, 19, -23,
+ 26, 168, 116, -233,
+ -32, -26, 118, -78,
+ 3, -8, -45, -115,
+ 57, -215, -54, -83,
+ -209, 112, -22, -167,
+ -91, -151, 168, -262
+};
+
+/* ISF codebook - 36b, 2nd stage, 1st split (only in AMR-WB IO mode) */
+const Word16 dico21_isf_36b_fx[]=
+{
+ -52, -96, 212, 315, -73,
+ 82, -204, 363, 136, -197,
+ -126, -331, 183, 218, 143,
+ -49, -41, 557, 230, 72,
+ 2, -73, 163, 377, 221,
+ 133, 111, 278, 215, -110,
+ -102, -20, 284, 113, 273,
+ 84, 319, 290, 18, 85,
+ -25, -5, 125, 132, -204,
+ -38, -5, 286, -9, -356,
+ -140, -256, 92, 117, -189,
+ -144, 191, 313, 51, -98,
+ 167, -10, 44, 247, 36,
+ 381, 197, 238, 74, 6,
+ 38, -408, 29, -3, -85,
+ 92, 266, 157, -25, -200,
+ 161, -121, 70, 84, -140,
+ -16, -86, 112, -94, -189,
+ -269, -270, 351, 107, -24,
+ -68, -67, 492, -103, -155,
+ -53, -131, 62, 122, 10,
+ 135, 84, 283, -55, -120,
+ -12, -219, 331, -81, 167,
+ 220, -136, 147, -172, -42,
+ 140, -95, -109, -88, -194,
+ 0, -2, -4, -33, -381,
+ -66, -217, 152, -186, -402,
+ 244, 108, 156, -140, -395,
+ 113, -136, -196, 110, -24,
+ 214, 118, 11, -64, -131,
+ -110, -286, -6, -332, 16,
+ 94, 97, 79, -291, -205,
+ -5, -39, -20, 252, -96,
+ 76, 174, 101, 163, 61,
+ -69, -239, -55, 399, 6,
+ -115, 319, 164, 275, 196,
+ -15, 36, -47, 331, 121,
+ 226, 209, 271, 325, 184,
+ 13, -80, -218, 471, 353,
+ 288, 378, 16, -51, 251,
+ 174, 116, 52, 149, -279,
+ 235, 276, 39, 120, -48,
+ 0, -108, -108, 241, -339,
+ -93, 534, 45, 33, -87,
+ 194, 149, -71, 405, -44,
+ 409, 370, 81, -186, -154,
+ 25, -102, -448, 124, -173,
+ 22, 408, -110, -310, -214,
+ -26, 23, -83, 114, 14,
+ -110, 164, 52, 223, -82,
+ 37, -25, -263, 306, -15,
+ -466, 415, 292, 165, -18,
+ 29, -19, -171, 155, 182,
+ 179, 144, -27, 231, 258,
+ -103, -247, -396, 238, 113,
+ 375, -154, -109, -4, 156,
+ 98, 85, -292, -5, -124,
+ 116, 139, -116, -98, -294,
+ -14, -83, -278, -117, -378,
+ 106, 33, -106, -344, -484,
+ 119, 17, -412, 138, 166,
+ 384, 101, -204, 88, -156,
+ -121, -284, -300, -1, -166,
+ 280, 33, -152, -313, -81,
+ -37, 22, 229, 153, 37,
+ -60, -83, 236, -8, -41,
+ -169, -228, 126, -20, 363,
+ -235, 17, 364, -156, 156,
+ -25, -30, 72, 144, 156,
+ 153, -26, 256, 97, 144,
+ -21, -37, 48, -65, 250,
+ 63, 77, 273, -128, 124,
+ -129, -26, 40, 9, -115,
+ -6, 82, 38, -90, -182,
+ -336, -13, 28, 158, 91,
+ -30, 241, 137, -170, -17,
+ 146, 14, -11, 33, 61,
+ 192, 197, 54, -84, 85,
+ 23, -200, -78, -29, 140,
+ 122, 237, 106, -341, 136,
+ -57, -142, -85, -16, -74,
+ -59, -90, -8, -187, -20,
+ -211, -267, 216, -179, -110,
+ -50, -7, 220, -267, -70,
+ -57, -42, -17, -15, 71,
+ 32, 21, 63, -137, 33,
+ -137, -175, 104, -68, 97,
+ -67, -43, 133, -301, 221,
+ -116, -200, -81, -92, -272,
+ -64, -41, -54, -244, -220,
+ -287, -242, -50, -87, -89,
+ -245, 236, 102, -166, -295,
+ 66, 24, -162, -71, 95,
+ 66, 136, -90, -220, -36,
+ -98, -161, -222, -188, 29,
+ -18, 18, -19, -415, 9,
+ 49, 61, 100, 39, -56,
+ -111, 82, 135, -31, 52,
+ -90, -153, -93, 189, 182,
+ -214, 295, 119, -74, 284,
+ 2, 137, 37, 47, 182,
+ 92, 117, 184, -53, 373,
+ -21, -14, -35, 136, 391,
+ 146, 129, -164, -28, 333,
+ 92, 80, -84, 100, -134,
+ -8, 217, -32, 3, -47,
+ -151, 251, -215, 142, 92,
+ -224, 310, -172, -275, 98,
+ 159, 155, -177, 112, 53,
+ 205, 27, 8, -240, 192,
+ 169, 120, -319, -201, 106,
+ 11, 36, -86, -237, 455,
+ -109, -154, -163, 174, -55,
+ -38, 32, -101, -78, -59,
+ -205, -321, -97, 69, 79,
+ -310, 44, 18, -185, 34,
+ -115, -20, -148, -39, 203,
+ -29, 154, -30, -158, 166,
+ -45, -131, -317, -24, 363,
+ -165, -205, -112, -222, 265,
+ -32, -44, -150, 54, -193,
+ -6, -38, -255, -169, -115,
+ -266, 87, -189, -36, -169,
+ -60, -87, -266, -436, -170,
+ -68, -81, -278, 24, 38,
+ -23, -19, -155, -256, 141,
+ -61, -226, -565, -175, 71,
+ 9, -29, -237, -515, 263
+};
+
+/* ISF codebook - 36b, 2nd stage, 2nd split (only in AMR-WB IO mode) */
+const Word16 dico22_isf_36b_fx[]=
+{
+ -298, -6, 95, 31,
+ -213, -87, -122, 261,
+ 4, -49, 208, 14,
+ -129, -110, 30, 118,
+ -214, 258, 110, -235,
+ -41, -18, -126, 120,
+ 103, 65, 127, -37,
+ 126, -36, -24, 25,
+ -138, -67, -278, -186,
+ -164, -194, -201, 78,
+ -211, -87, -51, -221,
+ -174, -79, -94, -39,
+ 23, -6, -157, -240,
+ 22, -110, -153, -68,
+ 148, -5, -2, -149,
+ -1, -135, -39, -179,
+ 68, 360, -117, -15,
+ 137, 47, -278, 146,
+ 136, 260, 135, 65,
+ 61, 116, -45, 97,
+ 231, 379, 87, -120,
+ 338, 177, -272, 3,
+ 266, 156, 28, -69,
+ 260, 84, -85, 86,
+ -266, 154, -256, -182,
+ -17, -65, -304, -6,
+ -40, 175, -151, -180,
+ -27, 27, -87, -63,
+ 121, 114, -166, -469,
+ 159, -66, -323, -231,
+ 214, 152, -141, -212,
+ 137, 36, -184, -51,
+ -282, -237, 40, 10,
+ -48, -235, -37, 251,
+ -54, -323, 136, 29,
+ -88, -174, 213, 198,
+ -390, 99, -63, -375,
+ 107, -169, -164, 424,
+ 69, -111, 141, -167,
+ 74, -129, 65, 144,
+ -353, -207, -205, -109,
+ -160, -386, -355, 98,
+ -176, -493, -20, -143,
+ -252, -432, -2, 216,
+ -90, -174, -168, -411,
+ 13, -284, -229, -160,
+ -87, -279, 34, -251,
+ -75, -263, -58, -42,
+ 420, 53, -211, -358,
+ 384, -35, -374, 396,
+ 68, -228, 323, -2,
+ 167, -307, 192, 194,
+ 459, 329, -5, -332,
+ 375, 79, -7, 313,
+ 282, -124, 200, -92,
+ 271, -162, -70, 180,
+ -157, -298, -514, -309,
+ 58, -163, -546, 18,
+ 124, -364, 167, -238,
+ 83, -411, -117, 96,
+ 140, -112, -388, -624,
+ 259, -133, -317, 41,
+ 163, -130, -64, -334,
+ 226, -165, -124, -110,
+ -466, -61, 6, 229,
+ -153, 205, -145, 242,
+ -159, 48, 195, 148,
+ -58, 28, 31, 279,
+ -303, 185, 279, -4,
+ -61, 197, 59, 86,
+ -114, 123, 168, -52,
+ 35, 36, 100, 126,
+ -407, 102, -77, -40,
+ -338, -1, -342, 156,
+ -179, 105, -34, -97,
+ -185, 84, -35, 108,
+ -133, 107, -91, -357,
+ -180, 54, -229, 24,
+ -44, 47, 47, -182,
+ -66, 13, 45, 4,
+ -339, 251, 64, 226,
+ -42, 101, -350, 275,
+ -99, 398, 142, 121,
+ 111, 12, -102, 260,
+ 0, 505, 260, -94,
+ 161, 285, -96, 224,
+ -4, 206, 314, 33,
+ 167, 139, 88, 204,
+ -235, 316, -60, -25,
+ -8, -150, -312, 201,
+ -36, 292, 61, -104,
+ -40, 174, -162, 42,
+ -21, 402, -29, -351,
+ 21, 152, -360, -93,
+ 57, 191, 212, -196,
+ 76, 158, -21, -69,
+ -328, -185, 331, 119,
+ -53, 285, 56, 337,
+ -107, -24, 405, 29,
+ -18, 137, 272, 277,
+ -255, 22, 173, -191,
+ 295, 322, 325, 302,
+ 21, -27, 332, -178,
+ 119, 13, 271, 129,
+ -455, -180, 116, -191,
+ -227, 62, -148, 524,
+ -176, -287, 282, -157,
+ -243, 13, 199, 430,
+ -59, -49, 115, -365,
+ 72, -172, -137, 93,
+ -138, -126, 141, -84,
+ 5, -124, 38, -20,
+ -258, 311, 601, 213,
+ 94, 130, -61, 502,
+ -1, -157, 485, 313,
+ 146, -74, 158, 345,
+ 276, 135, 280, -57,
+ 490, 252, 99, 43,
+ 267, -74, 429, 105,
+ 278, -23, 119, 94,
+ -542, 488, 257, -115,
+ -84, -244, -438, 478,
+ -113, -545, 387, 101,
+ -95, -306, 111, 498,
+ 95, 166, 22, -301,
+ 420, -15, -58, -78,
+ 270, 29, 122, -282,
+ 160, -240, 50, -38
+};
+/* ISF codebook - 36b, 2nd stage, 3rd split (only in AMR-WB IO mode) */
+const Word16 dico23_isf_36b_fx[]=
+{
+ 81, -18, 68, -27, -122, -280, -4,
+ 45, -177, 209, -30, -136, -74, 131,
+ -44, 101, -75, -88, -48, -137, -54,
+ -245, -28, 63, -18, -112, -103, 58,
+ -79, -6, 220, -65, 114, -35, -50,
+ 109, -65, 143, -114, 129, 76, 125,
+ 166, 90, -61, -242, 186, -74, -43,
+ -46, -92, 49, -227, 24, -155, 39,
+ 67, 85, 99, -42, 53, -184, -281,
+ 142, -122, 0, 21, -142, -15, -17,
+ 223, 92, -21, -48, -82, -14, -167,
+ 51, -37, -243, -30, -90, 18, -56,
+ 54, 105, 74, 86, 69, 13, -101,
+ 196, 72, -89, 43, 65, 19, 39,
+ 121, 34, 131, -82, 25, 213, -156,
+ 101, -102, -136, -21, 57, 214, 22,
+ 36, -124, 205, 204, 58, -156, -83,
+ 83, -117, 137, 137, 85, 116, 44,
+ -92, -148, -68, 11, -102, -197, -220,
+ -76, -185, -58, 132, -26, -183, 85,
+ -7, -31, -2, 23, 205, -151, 10,
+ -27, -37, -5, -18, 292, 131, 1,
+ 117, -168, 9, -93, 80, -59, -125,
+ -182, -244, 98, -24, 135, -22, 94,
+ 221, 97, 106, 42, 43, -160, 83,
+ 25, -64, -21, 6, 14, -15, 154,
+ 126, 15, -140, 150, -10, -207, -114,
+ 79, -63, -211, -70, -28, -217, 165,
+ 46, 38, -22, 281, 132, -62, 109,
+ 112, 54, -112, -93, 208, 27, 296,
+ 115, 10, -147, 41, 216, 42, -276,
+ 50, -115, -254, 167, 117, -2, 61,
+ 17, 144, 34, -72, -186, -150, 272,
+ -29, -66, -89, -95, -149, 129, 251,
+ 122, 0, -50, -234, -91, 36, 26,
+ -105, -102, -88, -121, -236, -7, -11,
+ -204, 109, 5, -191, 105, -15, 163,
+ -80, 32, -24, -209, 41, 294, 70,
+ -106, -94, -204, -118, 120, -50, -37,
+ -82, -241, 46, -131, -29, 150, -55,
+ 33, 155, 120, -89, -8, 7, 62,
+ 213, 82, 61, 18, -161, 144, 152,
+ 30, 131, 65, -87, -255, -17, -107,
+ -8, 85, -64, 51, -162, 223, -53,
+ -134, 261, 69, -56, 218, 72, -111,
+ 2, 155, -113, -87, 49, 85, -28,
+ -163, 42, -1, -196, 7, 39, -245,
+ 14, -137, -79, 11, -160, 202, -293,
+ -94, 33, 208, 100, 56, -44, 326,
+ -78, -41, 232, 13, -142, 227, 80,
+ -16, -87, 201, 33, -133, 15, -183,
+ -58, -192, -47, 184, -128, 133, 99,
+ -205, 11, -155, 78, 52, 72, 141,
+ -246, 26, 99, 151, 59, 115, -64,
+ -79, -47, -16, -14, 6, 47, -43,
+ -72, -178, -27, 162, 112, 43, -174,
+ -175, 238, 186, 71, -54, -188, -76,
+ -225, 233, 39, -39, -158, 122, 44,
+ -26, 43, 84, 130, -93, -51, 22,
+ 3, 92, -150, 136, -182, -57, 97,
+ -131, 179, -78, 80, 91, -165, 90,
+ -2, 148, 15, 130, 65, 175, 117,
+ -138, 114, -137, 132, 3, -10, -186,
+ 140, -4, -37, 254, -62, 92, -109
+};
+
+/* ISF codebook for SID frames - 28b, 1st split */
+const Word16 dico1_ns_28b_fx[]=
+{
+ -269, -673,
+ -222, -537,
+ -233, -430,
+ -138, -451,
+ -212, -331,
+ -192, -241,
+ -87, -231,
+ -191, -128,
+ -70, -106,
+ -164, -6,
+ 74, -179,
+ 27, -33,
+ -102, 74,
+ -162, 115,
+ -94, 172,
+ -6, 130,
+ -143, 234,
+ 14, 218,
+ -65, 270,
+ 88, 182,
+ -124, 341,
+ -44, 381,
+ 38, 335,
+ 117, 274,
+ -112, 454,
+ 74, 431,
+ -5, 488,
+ 175, 384,
+ -83, 561,
+ 122, 529,
+ 21, 601,
+ 229, 481,
+ 231, 303,
+ 226, 608,
+ 300, 372,
+ 210, 187,
+ 306, 265,
+ 328, 473,
+ 382, 331,
+ 371, 132,
+ 139, 58,
+ 365, 21,
+ 250, -82,
+ 443, 218,
+ 483, 110,
+ 426, 415,
+ 579, 222,
+ 518, 333,
+ 573, 448,
+ 455, 529,
+ 685, 329,
+ 332, 580,
+ 595, 593,
+ 468, 645,
+ 762, 517,
+ 326, 709,
+ 485, 793,
+ 130, 684,
+ 671, 737,
+ 354, 876,
+ 88, 806,
+ -65, 706,
+ -35, 1016,
+ 266, 1123
+};
+/* ISF codebook for SID frames - 28b, 2nd spilt */
+const Word16 dico2_ns_28b_fx[]=
+{
+ -824, -884, -949,
+ -805, -456, -418,
+ -442, -438, -541,
+ -217, -578, -793,
+ -168, -444, -582,
+ -287, -492, -274,
+ -552, -297, -300,
+ -163, -333, -358,
+ -370, -232, -232,
+ -175, -358, -159,
+ -381, -21, -357,
+ -184, -159, -162,
+ -53, -191, -280,
+ 18, -267, -215,
+ -138, 61, -283,
+ 71, -95, -294,
+ 13, -156, -546,
+ 0, -83, -79,
+ 44, 97, -316,
+ 178, -52, -213,
+ 222, -261, -422,
+ 237, -118, -44,
+ 141, 145, -132,
+ 363, 81, -287,
+ 213, 65, 34,
+ -107, 94, -5,
+ 91, -29, 126,
+ -355, 51, -41,
+ -219, -76, 145,
+ -63, 100, 244,
+ -719, 44, 27,
+ -572, -124, 155,
+ -423, 133, 315,
+ -917, 71, 224,
+ -268, 318, 131,
+ -93, -190, 420,
+ -97, 122, 491,
+ -79, 317, 355,
+ 130, 100, 325,
+ 86, -293, 210,
+ 133, 258, 161,
+ 176, -73, 465,
+ 195, 300, 384,
+ 348, 22, 221,
+ 376, 183, 409,
+ 377, 286, 202,
+ 242, 213, 659,
+ 257, 565, 248,
+ 344, 408, -76,
+ 405, 440, 509,
+ 612, 385, 379,
+ 536, 607, 216,
+ -56, 582, 192,
+ 100, 517, 567,
+ -365, 448, 445,
+ 728, 347, 10,
+ 505, 357, 759,
+ 636, 582, 658,
+ 335, 517, 852,
+ 378, 809, 572,
+ -195, 878, 829,
+ 529, 707, 987,
+ 918, 726, 392,
+ 1250, 997, 1063
+};
+
+/* ISF codebook for SID frames - 28b, 3rd spilt */
+const Word16 dico3_ns_28b_fx[]=
+{
+ -805, -838, -774,
+ -522, -627, -828,
+ -477, -486, -603,
+ -295, -481, -634,
+ -366, -384, -393,
+ -186, -414, -396,
+ -237, -394, -106,
+ -252, -202, -275,
+ -61, -177, -442,
+ -84, -198, -199,
+ -179, -125, -31,
+ -72, -47, -163,
+ -298, -220, 215,
+ -64, -168, 251,
+ -133, 156, -59,
+ -30, -2, 127,
+ 54, 66, -61,
+ -233, 21, 251,
+ 209, -50, 32,
+ 33, 194, 136,
+ -117, -18, 475,
+ 202, 46, 309,
+ 256, 185, 53,
+ 35, 200, 390,
+ 200, 263, 242,
+ -216, 302, 294,
+ 128, 358, 0,
+ 19, 431, 287,
+ 224, 447, 280,
+ 367, 165, 213,
+ 397, 314, 319,
+ 383, 379, 75,
+ 277, 325, 462,
+ 394, 505, 334,
+ 251, 98, -213,
+ 450, 153, 448,
+ 565, 226, 76,
+ 470, 383, 502,
+ 635, 390, 278,
+ 237, 135, 620,
+ 342, 401, 649,
+ 331, 551, 518,
+ 130, 418, 592,
+ 531, 306, 737,
+ 729, 389, 580,
+ 497, 557, 699,
+ 296, 383, 874,
+ 283, 624, 759,
+ 126, 622, 476,
+ 559, 595, 472,
+ 382, 770, 616,
+ 719, 613, 745,
+ 540, 639, 928,
+ 517, 826, 801,
+ 684, 811, 604,
+ 752, 786, 857,
+ 933, 661, 350,
+ 694, 450, 1061,
+ 562, 911, 1051,
+ 824, 813, 1104,
+ 758, 1047, 882,
+ 1140, 917, 889,
+ 1039, 1246, 1426,
+ 1483, 1666, 1876
+};
+/* ISF codebook for SID frames - 28b, 4th spilt */
+const Word16 dico4_ns_28b_fx[]=
+{
+ -776, -854, -891, -920,
+ -552, -610, -663, -741,
+ -321, -370, -476, -565,
+ 274, -160, -456, 201,
+ 265, 67, -160, -306,
+ -8, -210, 79, 272,
+ 163, 236, 307, 308,
+ 578, 317, 64, 298,
+ -9, 197, 342, 620,
+ 343, 232, 314, 622,
+ 173, 149, 548, 527,
+ 356, 370, 481, 376,
+ 135, 444, 488, 556,
+ 391, 471, 487, 653,
+ 228, 424, 576, 835,
+ 422, 372, 722, 682,
+ 295, 673, 693, 635,
+ 539, 596, 590, 449,
+ 475, 618, 659, 818,
+ 735, 517, 491, 673,
+ 602, 346, 257, 877,
+ 625, 635, 849, 720,
+ 727, 818, 698, 595,
+ 653, 481, 690, 1139,
+ 814, 762, 704, 908,
+ 507, 747, 898, 936,
+ 848, 855, 924, 785,
+ 646, 1037, 882, 795,
+ 772, 845, 1024, 1151,
+ 1133, 983, 818, 921,
+ 940, 1068, 1252, 1302,
+ 1588, 1767, 1718, 1513
+};
+/* ISF codebook for SID frames - 28b, 5th spilt */
+const Word16 dico5_ns_28b_fx[]=
+{
+ -810, -879, -945, -254,
+ 248, 184, 671, 128,
+ 288, 703, 918, 99,
+ 658, 558, 662, 219,
+ 552, 585, 910, 208,
+ 559, 804, 759, 119,
+ 606, 774, 921, -139,
+ 782, 761, 748, 208,
+ 756, 708, 983, 56,
+ 544, 864, 1010, 152,
+ 737, 698, 987, 299,
+ 771, 924, 879, 103,
+ 536, 785, 961, 405,
+ 667, 916, 801, 328,
+ 738, 705, 773, 439,
+ 823, 871, 992, 355,
+ 640, 1004, 1052, 369,
+ 724, 822, 949, 597,
+ 415, 655, 729, 482,
+ 1009, 896, 793, 363,
+ 908, 803, 687, -25,
+ 1016, 838, 1011, 189,
+ 947, 1112, 942, 222,
+ 914, 1049, 981, 527,
+ 956, 987, 1011, -120,
+ 781, 1049, 1121, 92,
+ 1178, 1053, 884, 47,
+ 1123, 1059, 1182, 118,
+ 933, 972, 1277, 357,
+ 1109, 918, 1101, 503,
+ 1039, 1286, 1220, 317,
+ 1351, 1207, 1010, 326
+};
+
+/*----------------------------------------------------------------------------------*
+ * table of cos(x) in Q15 used in FFT for spectral analysis
+ *----------------------------------------------------------------------------------*/
+
+
+/*------------------------------------------------------------------------------*
+ * Critical bands in Q0
+ *------------------------------------------------------------------------------*/
+
+const Word16 wind_sss_fx[LEN_WIN_SSS] = /*window for subsampling*/
+{
+ 2621, 2627, 2645, 2675, 2717, 2771, 2836, 2914,
+ 3003, 3103, 3216, 3340, 3475, 3621, 3779, 3948,
+ 4127, 4318, 4519, 4730, 4952, 5184, 5426, 5677,
+ 5938, 6209, 6488, 6777, 7074, 7379, 7693, 8015,
+ 8344, 8681, 9025, 9375, 9733, 10097, 10466, 10842,
+ 11223, 11609, 12000, 12395, 12795, 13198, 13605, 14016,
+ 14429, 14845, 15263, 15683, 16105, 16527, 16951, 17376,
+ 17800, 18225, 18649, 19072, 19495, 19916, 20335, 20752,
+ 21166, 21578, 21987, 22392, 22794, 23191, 23585, 23973,
+ 24357, 24735, 25108, 25474, 25835, 26189, 26537, 26877,
+ 27210, 27536, 27853, 28163, 28464, 28757, 29041, 29316,
+ 29582, 29838, 30085, 30322, 30549, 30765, 30972, 31167,
+ 31352, 31526, 31690, 31842, 31983, 32112, 32230, 32337,
+ 32432, 32515, 32586, 32646, 32694, 32730, 32754, 32766,
+ 32767, 32096, 30111, 26894, 22575, 17333, 11380, 4962
+};
+/*----------------------------------------------------------------------------------*
+ * Low-pass FIR filter for low-frequency post-filtering @ 8kHz
+ * fir1(240,(3900/32000),hanning(241))*5
+ *----------------------------------------------------------------------------------*/
+
+const Word16 filter5_39s320_120_fx[121] = /* Q15 */
+{
+ 19968, 19480, 18061, 15834, 12993, 9779, 6458, 3290,
+ 506, -1713, -3253, -4075, -4212, -3762, -2873, -1720,
+ -488, 654, 1568, 2160, 2389, 2263, 1838, 1201,
+ 460, -275, -903, -1348, -1566, -1546, -1312, -914,
+ -422, 90, 547, 891, 1083, 1108, 975, 716,
+ 376, 9, -331, -599, -762, -805, -732, -562,
+ -325, -61, 192, 399, 533, 582, 546, 435,
+ 272, 83, -103, -259, -366, -413, -398, -328,
+ -218, -86, 46, 161, 243, 283, 280, 238,
+ 166, 77, -14, -94, -153, -185, -188, -163,
+ -119, -62, -3, 50, 90, 113, 117, 104,
+ 78, 44, 9, -23, -47, -62, -65, -58,
+ -45, -27, -8, 9, 21, 28, 30, 27,
+ 20, 13, 5, -2, -7, -9, -9, -8,
+ -6, -3, -1, 0, 1, 1, 1, 0,
+ 0
+
+};
+
+
+const Word16 Assym_window_W16fx[L_LP] = /*Q15*/
+{
+ 2621, 2624, 2630, 2640, 2655, 2674, 2698, 2725,
+ 2757, 2792, 2833, 2877, 2925, 2978, 3034, 3095,
+ 3160, 3229, 3302, 3379, 3460, 3545, 3634, 3727,
+ 3824, 3925, 4029, 4138, 4250, 4366, 4486, 4609,
+ 4737, 4867, 5002, 5140, 5281, 5426, 5575, 5727,
+ 5882, 6040, 6202, 6367, 6535, 6707, 6881, 7059,
+ 7239, 7422, 7609, 7798, 7990, 8184, 8382, 8581,
+ 8784, 8989, 9196, 9406, 9618, 9832, 10049, 10268,
+ 10489, 10711, 10936, 11163, 11391, 11622, 11854, 12087,
+ 12322, 12559, 12797, 13037, 13278, 13520, 13763, 14007,
+ 14253, 14499, 14746, 14994, 15243, 15493, 15743, 15994,
+ 16245, 16496, 16748, 17000, 17253, 17505, 17758, 18010,
+ 18263, 18515, 18767, 19019, 19270, 19521, 19772, 20022,
+ 20271, 20519, 20767, 21014, 21260, 21504, 21748, 21991,
+ 22232, 22473, 22711, 22949, 23185, 23419, 23652, 23883,
+ 24113, 24340, 24566, 24790, 25012, 25231, 25449, 25664,
+ 25878, 26089, 26297, 26503, 26707, 26908, 27107, 27303,
+ 27496, 27687, 27874, 28059, 28241, 28420, 28596, 28769,
+ 28939, 29105, 29269, 29429, 29586, 29739, 29889, 30036,
+ 30179, 30319, 30455, 30588, 30717, 30842, 30964, 31082,
+ 31196, 31306, 31413, 31516, 31615, 31709, 31800, 31888,
+ 31971, 32050, 32125, 32196, 32263, 32325, 32384, 32439,
+ 32489, 32535, 32577, 32615, 32649, 32679, 32704, 32725,
+ 32742, 32755, 32763, 32767, 32767, 32758, 32741, 32715,
+ 32681, 32638, 32587, 32527, 32458, 32381, 32296, 32203,
+ 32101, 31991, 31873, 31746, 31612, 31470, 31320, 31162,
+ 30996, 30823, 30642, 30454, 30259, 30056, 29847, 29630,
+ 29407, 29177, 28940, 28697, 28448, 28193, 27931, 27664,
+ 27391, 27113, 26829, 26540, 26246, 25947, 25643, 25335,
+ 25022, 24706, 24385, 24060, 23732, 23401, 23066, 22728,
+ 22387, 22043, 21697, 21349, 20999, 20646, 20292, 19937,
+ 19580, 19223, 18864, 18505, 18145, 17785, 17425, 17065,
+ 16705, 16346, 15988, 15631, 15275, 14920, 14567, 14215,
+ 13866, 13519, 13174, 12832, 12492, 12156, 11823, 11493,
+ 11166, 10844, 10525, 10210, 9900, 9594, 9292, 8996,
+ 8704, 8418, 8137, 7861, 7591, 7327, 7068, 6816,
+ 6570, 6330, 6097, 5870, 5650, 5437, 5231, 5032,
+ 4840, 4656, 4479, 4310, 4148, 3994, 3848, 3709,
+ 3579, 3457, 3343, 3237, 3139, 3050, 2969, 2896,
+ 2832, 2776, 2729, 2690, 2660, 2639, 2626, 2621
+};
+
+const Word16 assym_window_16k_fx[L_LP_16k] = /*Q15*/
+{
+ 2621, 2623, 2627, 2634, 2643, 2655, 2670, 2688,
+ 2708, 2731, 2757, 2785, 2816, 2849, 2886, 2925,
+ 2966, 3011, 3058, 3107, 3159, 3214, 3271, 3331,
+ 3394, 3459, 3527, 3597, 3670, 3745, 3823, 3903,
+ 3985, 4071, 4158, 4248, 4341, 4436, 4533, 4632,
+ 4734, 4839, 4945, 5054, 5165, 5279, 5394, 5512,
+ 5632, 5754, 5879, 6005, 6134, 6264, 6397, 6531,
+ 6668, 6807, 6947, 7090, 7234, 7381, 7529, 7679,
+ 7831, 7984, 8140, 8297, 8455, 8616, 8778, 8941,
+ 9107, 9273, 9442, 9611, 9782, 9955, 10129, 10304,
+ 10481, 10659, 10838, 11019, 11200, 11383, 11567, 11752,
+ 11938, 12125, 12313, 12502, 12693, 12883, 13075, 13268,
+ 13461, 13655, 13850, 14046, 14242, 14439, 14637, 14835,
+ 15033, 15232, 15432, 15631, 15832, 16032, 16233, 16434,
+ 16635, 16837, 17039, 17240, 17442, 17644, 17846, 18048,
+ 18250, 18452, 18653, 18855, 19056, 19257, 19458, 19658,
+ 19858, 20058, 20257, 20456, 20654, 20852, 21049, 21245,
+ 21441, 21637, 21831, 22025, 22218, 22410, 22602, 22792,
+ 22982, 23170, 23358, 23545, 23730, 23915, 24098, 24280,
+ 24461, 24641, 24820, 24997, 25173, 25348, 25521, 25693,
+ 25863, 26032, 26200, 26366, 26530, 26693, 26854, 27014,
+ 27171, 27328, 27482, 27635, 27786, 27935, 28082, 28227,
+ 28371, 28513, 28652, 28790, 28926, 29059, 29191, 29320,
+ 29448, 29573, 29697, 29818, 29937, 30053, 30168, 30280,
+ 30390, 30498, 30603, 30706, 30807, 30905, 31002, 31095,
+ 31186, 31275, 31362, 31446, 31527, 31606, 31683, 31757,
+ 31828, 31897, 31963, 32027, 32088, 32147, 32203, 32257,
+ 32307, 32356, 32401, 32444, 32484, 32522, 32557, 32589,
+ 32619, 32646, 32670, 32692, 32711, 32727, 32741, 32751,
+ 32760, 32765, 32767, 32767, 32762, 32751, 32734, 32712,
+ 32685, 32652, 32614, 32570, 32521, 32466, 32406, 32341,
+ 32270, 32194, 32112, 32026, 31934, 31837, 31735, 31627,
+ 31515, 31398, 31275, 31148, 31016, 30878, 30737, 30590,
+ 30438, 30282, 30122, 29957, 29787, 29613, 29434, 29252,
+ 29065, 28874, 28679, 28480, 28277, 28070, 27859, 27644,
+ 27426, 27205, 26980, 26751, 26520, 26285, 26047, 25805,
+ 25561, 25314, 25065, 24812, 24557, 24300, 24040, 23777,
+ 23513, 23246, 22978, 22707, 22435, 22161, 21885, 21608,
+ 21329, 21049, 20768, 20485, 20202, 19918, 19632, 19347,
+ 19060, 18773, 18486, 18198, 17911, 17623, 17335, 17047,
+ 16760, 16473, 16186, 15900, 15614, 15330, 15046, 14763,
+ 14481, 14200, 13921, 13643, 13367, 13092, 12818, 12547,
+ 12277, 12010, 11744, 11481, 11220, 10961, 10705, 10451,
+ 10200, 9951, 9706, 9463, 9223, 8987, 8754, 8523,
+ 8297, 8073, 7854, 7637, 7425, 7216, 7011, 6810,
+ 6613, 6420, 6231, 6046, 5865, 5689, 5517, 5350,
+ 5187, 5028, 4875, 4726, 4581, 4442, 4307, 4177,
+ 4052, 3932, 3818, 3708, 3603, 3503, 3409, 3320,
+ 3236, 3157, 3084, 3016, 2953, 2895, 2844, 2797,
+ 2756, 2720, 2690, 2665, 2646, 2632, 2624, 2621
+};
+/*------------------------------------------------------------------------------*
+ * lag window for windowing the autocorrelations in LP analysis
+ * Used in lib_enc\analy_lp_fx.c
+ *------------------------------------------------------------------------------*/
+const Word16 Hamcos_Window[L_LP_AMR_WB] =
+{
+ 2621, 2622, 2626, 2632, 2640, 2650, 2662, 2677,
+ 2694, 2714, 2735, 2759, 2785, 2814, 2844, 2877,
+ 2912, 2949, 2989, 3031, 3075, 3121, 3169, 3220,
+ 3273, 3328, 3385, 3444, 3506, 3569, 3635, 3703,
+ 3773, 3845, 3919, 3996, 4074, 4155, 4237, 4321,
+ 4408, 4496, 4587, 4680, 4774, 4870, 4969, 5069,
+ 5171, 5275, 5381, 5489, 5599, 5710, 5824, 5939,
+ 6056, 6174, 6295, 6417, 6541, 6666, 6793, 6922,
+ 7052, 7185, 7318, 7453, 7590, 7728, 7868, 8009,
+ 8152, 8296, 8442, 8589, 8737, 8887, 9038, 9191,
+ 9344, 9499, 9655, 9813, 9971, 10131, 10292, 10454,
+ 10617, 10781, 10946, 11113, 11280, 11448, 11617, 11787,
+ 11958, 12130, 12303, 12476, 12650, 12825, 13001, 13178,
+ 13355, 13533, 13711, 13890, 14070, 14250, 14431, 14612,
+ 14793, 14975, 15158, 15341, 15524, 15708, 15891, 16076,
+ 16260, 16445, 16629, 16814, 16999, 17185, 17370, 17555,
+ 17740, 17926, 18111, 18296, 18481, 18666, 18851, 19036,
+ 19221, 19405, 19589, 19773, 19956, 20139, 20322, 20504,
+ 20686, 20867, 21048, 21229, 21408, 21588, 21767, 21945,
+ 22122, 22299, 22475, 22651, 22825, 22999, 23172, 23344,
+ 23516, 23686, 23856, 24025, 24192, 24359, 24525, 24689,
+ 24853, 25016, 25177, 25337, 25496, 25654, 25811, 25967,
+ 26121, 26274, 26426, 26576, 26725, 26873, 27019, 27164,
+ 27308, 27450, 27590, 27729, 27867, 28003, 28137, 28270,
+ 28401, 28531, 28659, 28785, 28910, 29033, 29154, 29274,
+ 29391, 29507, 29622, 29734, 29845, 29953, 30060, 30165,
+ 30268, 30370, 30469, 30566, 30662, 30755, 30847, 30936,
+ 31024, 31109, 31193, 31274, 31354, 31431, 31506, 31579,
+ 31651, 31719, 31786, 31851, 31914, 31974, 32032, 32088,
+ 32142, 32194, 32243, 32291, 32336, 32379, 32419, 32458,
+ 32494, 32528, 32560, 32589, 32617, 32642, 32664, 32685,
+ 32703, 32719, 32733, 32744, 32753, 32760, 32764, 32767,
+ 32767, 32765, 32757, 32745, 32727, 32705, 32678, 32646,
+ 32609, 32567, 32520, 32468, 32411, 32349, 32283, 32211,
+ 32135, 32054, 31968, 31877, 31781, 31681, 31575, 31465,
+ 31351, 31231, 31107, 30978, 30844, 30706, 30563, 30415,
+ 30263, 30106, 29945, 29779, 29609, 29434, 29255, 29071,
+ 28883, 28691, 28494, 28293, 28087, 27878, 27664, 27446,
+ 27224, 26997, 26767, 26533, 26294, 26052, 25806, 25555,
+ 25301, 25043, 24782, 24516, 24247, 23974, 23698, 23418,
+ 23134, 22847, 22557, 22263, 21965, 21665, 21361, 21054,
+ 20743, 20430, 20113, 19794, 19471, 19146, 18817, 18486,
+ 18152, 17815, 17476, 17134, 16789, 16442, 16092, 15740,
+ 15385, 15028, 14669, 14308, 13944, 13579, 13211, 12841,
+ 12470, 12096, 11721, 11344, 10965, 10584, 10202, 9819,
+ 9433, 9047, 8659, 8270, 7879, 7488, 7095, 6701,
+ 6306, 5910, 5514, 5116, 4718, 4319, 3919, 3519,
+ 3118, 2716, 2315, 1913, 1510, 1108, 705, 302
+};
+/*----------------------------------------------------------------------------------*
+ * AMR-WB IO WB BWE - deemphasis, values in Q15:
+ *----------------------------------------------------------------------------------*/
+const Word16 deem_tab_fx[56] =
+{
+ 20668, 20625, 20583, 20541, 20501, 20462, 20423, 20385,
+ 20348, 20313, 20277, 20243, 20210, 20177, 20146, 20115,
+ 20085, 20055, 20027, 19999, 19972, 19946, 19921, 19896,
+ 19873, 19850, 19827, 19806, 19785, 19766, 19746, 19728,
+ 19710, 19693, 19677, 19662, 19647, 19633, 19620, 19607,
+ 19596, 19585, 19574, 19565, 19556, 19548, 19540, 19533,
+ 19527, 19522, 19518, 19514, 19510, 19508, 19506, 19505
+};
+
+
+/*----------------------------------------------------------------------------------*
+ * AMR-WB IO WB BWE - HP filter in frequency domain, values in Q15:
+ *----------------------------------------------------------------------------------*/
+const Word16 filt_hp_fx[56] =
+{
+ 53, 153, 274, 415, 578, 765, 978, 1217, 1483, 1778, 2102,
+ 2457, 2843, 3261, 3710, 4192, 4706, 5252, 5829, 6438, 7077,
+ 7746, 8443, 9168, 9918, 10693, 11489, 12306, 13141, 13992,
+ 14856, 15732, 16615, 17504, 18395, 19287, 20174, 21056, 21928,
+ 22787, 23631, 24456, 25260, 26039, 26791, 27512, 28201, 28853,
+ 29468, 30043, 30574, 31061, 31502, 31894, 32237, 32529
+};
+
+/*----------------------------------------------------------------------------------*
+ * AMR-WB IO WB BWE - gains for 23k85 mode, values in Q15:
+ *----------------------------------------------------------------------------------*/
+const Word16 HP_gain_fx[16] =
+{
+ 3624, 4673, 5597, 6479, 7425, 8378, 9324, 10264,
+ 11210, 12206, 13391, 14844, 16770, 19655, 24289, 32728
+};
+
+/*----------------------------------------------------------------------------------*
+ * AMR-WB IO WB BWE - band-pass 6-8kHz FIR filter, values in Q15:
+ *----------------------------------------------------------------------------------*/
+const Word16 fir_6k_8k_fx[31] =
+{
+ 44, -155, 323, -482, 563, -590, 726, -1180, 1986, -2818, 3028,
+ -1991, -423, 3583, -6281, 7342, -6281, 3583, -423, -1991, 3028,
+ -2818, 1986, -1180, 726, -590, 563, -482, 323, -155, 44
+};
+
+const Word16 exp_tab_q_fx[34] = /*Q14 */
+{
+ 16384, -16068, 15137, -13622,
+ 11585, -9101, 6270, -3195,
+ 0, 3196, -6269, 9102,
+ -11584, 13623, -15136, 16069,
+ -16383, 0, -3195, 6270,
+ -9101, 11585, -13622, 15137,
+ -16068, 16384, -16068, 15137,
+ -13622, 11585, -9101, 6270,
+ -3195, 0
+};
+
+const Word16 exp_tab_p_fx[34] = /*Q14 */
+{
+ 16384, -11584, 0, 11585,
+ -16383, 11585, 0, -11584,
+ 16384, -11584, 0, 11585,
+ -16383, 11585, 0, -11584,
+ 16384, 0, -11584, 16384,
+ -11584, 0, 11585, -16383,
+ 11585, 0, -11584, 16384,
+ -11584, 0, 11585, -16383,
+ 11585, 0
+};
+const Word16 swb_bwe_trans_subband_width_fx[SWB_FENV_TRANS] = {76, 76, 84, 84};
+const Word16 sqrt_swb_bwe_trans_subband_width_fx[SWB_FENV_TRANS] = {17854, 17854, 18770, 18770};/*Q11 */
+const Word16 sqrt_swb_bwe_subband_fx_L1[SWB_FENV] = {16384, 20066, 16384, 20066, 16384, 20066, 16384, 20066, 20066, 20066, 20066, 20066, 23170, 23170}; /*Q12 */
+const Word16 sqrt_swb_bwe_subband_fx_L2[SWB_FENV/2] = {25905, 25905, 25905, 25905, 28378, 28378, 32767}; /*Q12 */
+const Word16 smooth_factor_fx[SWB_FENV-1] = {1638, 1638, 1638, 1638, 1638, 1638, 1638, 1366, 1366, 1366, 1366, 1024, 1024};
+const Word16 swb_bwe_sm_subband_fx[SWB_FENV] = {248, 268, 288, 308, 328, 348, 368, 388, 412, 436, 460, 484, 512, 544};
+
+const Word16 swb_bwe_trans_subband_fx[SWB_FENV_TRANS+1] = {240, 316, 392, 476, 560};
+const Word16 swb_bwe_subband_fx[SWB_FENV+1] = {240, 256, 280, 296, 320, 336, 360, 376, 400, 424, 448, 472, 496, 528, 560};
+const Word16 F_2_5_fx[64] = /*Q10 */
+{
+ 1189, 675, -5106, -5293, 10476, -12, 10860, 10026,
+ -382, -616, 6426, 339, 9681, 9068, 3002, 2216,
+ 3208, 3042, 8255, -604, 16133, 5171, 17641, 18769,
+ -2529, -3248, -1447, -1991, 15511, 14855, 11631, 11996,
+ 9654, -124, 7267, -1617, 12799, 3237, 10598, 1555,
+ 5510, -1775, 1149, -2292, 12659, 12425, 4382, -1814,
+ 6305, 5629, 3404, -2632, 19555, 9582, 7835, 7619,
+ -517, -3795, 19031, 11574, 19156, 18748, 23563, 23465,
+};
+
+const Word16 swb_inv_bwe_subband_width_fx[SWB_FENV] = {2048,1365,2048,1365,2048,1365,2048,1365,1365,1365,1365,1365,1024,1024};
+
+const Word16 EnvCdbk11_fx [N_CB11 * DIM11] = /*Q8 */
+{
+ -2220, 29, 1168, 2124, 2180, 1208, 741,
+ 1521, -312, -843, -1523, -1970, -2205, -2541,
+ 746, 1835, 3461, 4398, 4292, 4184, 3462,
+ 1627, 2475, 2937, 2839, 2198, 1729, 1325,
+ -514, -731, -557, -200, 100, 475, 540,
+ 655, 956, 1272, 1083, 774, 687, 459,
+ 5987, 5460, 4689, 4192, 3845, 3615, 3393,
+ 3571, 4840, 5784, 6266, 5933, 5158, 4433,
+ 2959, 2087, 1180, 979, 1180, 1371, 1636,
+ 6029, 6157, 6431, 6762, 6998, 7153, 7050,
+ -822, 210, 450, 178, -639, -1346, -1577,
+ 4451, 4184, 4111, 4329, 4833, 5232, 5512,
+ 3420, 3994, 4321, 4205, 3684, 3154, 2651,
+ -3734, -2305, -1388, -324, 22, -847, -1141,
+ 850, 510, 896, 1780, 2130, 2688, 2826,
+ 3294, 2823, 2510, 2516, 3029, 3413, 3843,
+ -3563, -3409, -3199, -2917, -2584, -2282, -1981,
+ -2738, -3185, -3752, -4320, -4484, -4524, -4329,
+ -7534, -7481, -7283, -7175, -6757, -6281, -5865,
+ -4868, -4836, -4603, -4422, -4086, -3738, -3323,
+ -13896, -13775, -13484, -13339, -12926, -12399, -11970,
+ 8409, 8420, 8305, 8103, 7954, 7778, 7496,
+ 7180, 6845, 6369, 5971, 5557, 5309, 5027,
+ 4633, 4008, 3267, 2422, 2072, 1778, 1510,
+ 10128, 10432, 10540, 10473, 10176, 9837, 9586,
+ 2933, 2695, 2060, 1286, 424, -254, -825,
+ -10032, -9847, -9544, -9420, -9000, -8508, -8084,
+ 1830, 927, -158, -388, -360, -368, -287,
+ -21962, -21904, -21548, -21471, -21004, -20511, -20064,
+ -6090, -6142, -5937, -5852, -5493, -5104, -4671,
+ -1382, -1640, -2205, -2557, -2785, -3019, -2994,
+ -1300, -1567, -1744, -1642, -1409, -1080, -902,
+};
+
+const Word16 EnvCdbk1st_fx [N_CB1ST * DIM1ST] = /*Q8 */
+{
+ -1819, -1138, 751,
+ -494, 162, -826,
+ -3199, -123, 2479,
+ -2071, 238, -429,
+ -1819, 1780, 1233,
+ 284, 1187, -1123,
+ -1689, -722, -484,
+ -1256, 52, -1336,
+ -604, 3738, -1297,
+ 555, 412, 743,
+ -626, -1685, 1527,
+ 145, 1557, -224,
+ -638, 1370, 1589,
+ -1188, 37, -410,
+ -428, -3320, 1860,
+ 2597, -95, -2876,
+ -742, -583, -684,
+ 1607, -1671, -1874,
+ -1111, -936, -1374,
+ 275, -2314, 518,
+ 2682, 2368, -302,
+ 1809, -555, -579,
+ 3193, -1270, -1208,
+ 750, 84, 154,
+ -1160, 429, 1098,
+ 816, -613, -2897,
+ 2159, -1885, 1245,
+ -671, 426, 3177,
+ 867, -144, -639,
+ 843, -1888, 2271,
+ 1542, 259, -148,
+ -1680, 1027, 285,
+ 162, -763, 1666,
+ -1916, 1175, -1227,
+ -345, -907, -151,
+ 1979, 1062, 402,
+ -1231, 2437, 3130,
+ -2422, 361, 1040,
+ -4314, -4106, -4221,
+ 146, -1200, -1828,
+ 485, 889, -3847,
+ 384, -2461, -2845,
+ 1526, -600, 1599,
+ -838, -571, 1097,
+ 1776, -3393, 4058,
+ -3330, 2429, 1732,
+ 468, -2140, -934,
+ 833, 2292, -1129,
+ -20, -1029, 652,
+ -346, 168, 1834,
+ -1730, 838, 2234,
+ 1622, -1695, -194,
+ -3198, -773, 228,
+ 1070, 1741, 285,
+ 1655, -212, -1628,
+ 2178, 604, 1784,
+ 1801, -3224, -848,
+ -819, 348, 187,
+ 16, 300, 244,
+ 769, 201, 1554,
+ 719, -394, 780,
+ 311, 2853, 185,
+ 1163, 489, -1022,
+ -330, 459, 877,
+ 109, -541, -691,
+ -509, -267, 478,
+ -340, -417, -1403,
+ -860, -675, -2703,
+ 1025, 826, 250,
+ -1043, 1008, -434,
+ -1042, -631, 60,
+ -173, 332, -2084,
+ 984, 919, -2042,
+ -1257, -2287, 339,
+ 366, -1309, -158,
+ 1041, 1039, 1083,
+ 3566, 918, 227,
+ 62, -139, 936,
+ 2424, 730, -1022,
+ -745, 1954, 427,
+ -1091, -1358, -478,
+ -173, 2121, -2367,
+ -2175, 2535, -1946,
+ -880, -1964, -1549,
+ -249, -1203, -927,
+ -2377, -443, -1775,
+ -1439, -582, 2037,
+ -529, -3679, -550,
+ 608, -284, -1566,
+ 201, 63, -344,
+ 1376, 218, 816,
+ 2471, -348, 479,
+ -1388, 988, -2674,
+ 1429, -3538, 1125,
+ 864, -1351, 845,
+ 301, 977, 408,
+ -1122, 3364, 1107,
+ -213, 730, -329,
+ 839, -683, -92,
+ 631, 1172, 2364,
+ 598, 685, -329,
+ -780, -1317, 448,
+ -424, -153, -199,
+ 768, -331, 2825,
+ 882, -1047, -975,
+ -375, -1835, -299,
+ 2861, -3375, -3158,
+ 2099, 2168, -2630,
+ 1602, 1930, 1451,
+ 1294, 1265, -586,
+ -2500, -2570, -2667,
+ -806, -1529, 3272,
+ -522, 1072, 478,
+ 4035, -2491, 480,
+ -1908, 2414, -178,
+ -1563, -143, 438,
+ 205, 861, 1287,
+ -691, 963, -1374,
+ -2359, -2032, -886,
+ 162, -442, 160,
+ 194, 2494, 1960,
+ -2533, -2578, 1924,
+ 267, 1701, 937,
+ 2919, 2950, 2382,
+ -670, 2102, -859,
+ -3147, 1385, -215,
+ 1482, -595, 415,
+ 228, 290, -1060,
+};
+
+const Word16 EnvCdbk2nd_fx [N_CB2ND * DIM2ND] = /*Q8 */
+{
+ 1104, -1833, -1110, -954,
+ 757, 853, -176, 286,
+ -873, -587, -7, 1458,
+ -462, -553, -350, 104,
+ 1938, 1957, -1340, -703,
+ 1202, -779, 21, 1996,
+ -2851, -169, 1049, 940,
+ -1355, -726, -1788, 1076,
+ -767, -641, -646, -880,
+ 135, -832, -197, -889,
+ -826, 3, 279, -502,
+ -714, 544, -526, 375,
+ 291, -1076, -816, -3929,
+ -1175, -475, 2219, -642,
+ 197, -219, -1052, -1601,
+ 1175, -162, -695, -336,
+ 1124, 126, -2326, -1573,
+ 1164, -1323, -1958, 1074,
+ -2080, -2152, 113, 649,
+ -637, -860, 721, 267,
+ -609, 1658, -1006, -1352,
+ 1631, 2225, 2128, 1827,
+ -1112, -1351, 1856, 1656,
+ -2132, 1006, 770, -1294,
+ -472, 776, 1661, 2248,
+ -121, -574, -1481, -316,
+ 2565, -1081, 188, 293,
+ 398, 2598, 704, -1129,
+ 1023, 104, 550, 499,
+ -416, 127, 253, -1894,
+ 456, -2578, 190, 1018,
+ -1488, 286, -1202, -915,
+ -1164, 1874, 1651, 302,
+ -1312, -1547, -1625, -1516,
+ 170, -233, 817, 1209,
+ -1090, 341, 709, 725,
+ 854, 819, -278, -1083,
+ -15, 113, 286, 283,
+ 1166, -906, 1880, 301,
+ 342, -7, -587, 776,
+ -785, -1259, -1166, 3194,
+ -1630, -1071, 300, -1080,
+ -12, 190, -538, -493,
+ 351, 907, 1929, -1534,
+ 480, 36, 593, -526,
+ 813, 1216, 986, 89,
+ 98, 1010, -2272, 268,
+ 2766, -102, -1307, -873,
+ -1660, -467, -365, 47,
+ 1496, 1277, -228, -2791,
+ 1565, -669, 520, -1598,
+ -361, 1078, 457, -364,
+ 543, -950, 28, 248,
+ 1904, 815, -1034, 1125,
+ -13, -1951, 1085, -1005,
+ -2223, 1519, -624, 857,
+ 1121, 831, 872, 1295,
+ 193, 2284, -422, 609,
+ -156, 827, -733, 2065,
+ -3390, -3384, -3197, -3220,
+ 31, 896, 539, 978,
+ -21, 408, 1502, 405,
+ -583, -1662, -665, -164,
+ 2193, 976, 613, -436,
+};
+
+const Word16 EnvCdbk3rd_fx [N_CB3RD * DIM3RD] = /*Q8 */
+{
+ 1031, -2454, 748,
+ 2770, 2442, 1761,
+ -2348, 4079, -959,
+ 1874, -735, -2242,
+ -59, 35, 201,
+ -1518, 162, 1809,
+ -1977, -1063, -103,
+ 2485, 1212, -863,
+ 882, 192, 39,
+ 1356, 851, 979,
+ -1377, -2961, -1477,
+ 497, -808, 593,
+ -394, -748, -1564,
+ -950, -198, -436,
+ -503, -1420, -234,
+ 318, 985, -1905,
+ -118, 1783, 1563,
+ 220, 929, 400,
+ 857, 37, -995,
+ -807, 1943, -409,
+ -743, -524, 552,
+ 940, 1643, -299,
+ 805, -1421, -768,
+ -2330, 705, 156,
+ 61, 203, 1213,
+ -138, 517, -642,
+ 64, -501, -435,
+ 2194, -625, 157,
+ -1600, 341, -1611,
+ 1137, -351, 2353,
+ -811, -1715, 1522,
+ -870, 613, 446,
+};
+
+const Word16 EnvCdbk4th_fx [N_CB4TH * DIM4TH] = /*Q8 */
+{
+ 1024, -210, -207, 591,
+ -280, -2486, -951, 958,
+ 1539, 1136, 411, 1314,
+ 1761, -202, 1339, 203,
+ -2438, -2109, -2028, -2125,
+ 1849, -1408, -670, 144,
+ -469, 2674, -1589, -3604,
+ 1642, -702, 139, 2476,
+ -483, 372, -861, 540,
+ -119, 827, 863, 952,
+ 23, 99, -24, -303,
+ 488, -2233, -1432, -1399,
+ 54, -43, 96, -1527,
+ 1170, 133, -119, -717,
+ 258, -1215, -439, 160,
+ -1049, 793, 970, -770,
+ -1914, -1245, 1281, 422,
+ -1194, 1005, 176, -2368,
+ -1631, 1316, -1125, -361,
+ 1124, 1132, 61, -2186,
+ 790, -2055, 1174, 938,
+ 2974, 3874, 2315, 2040,
+ -300, 2484, 59, -860,
+ 543, 1307, -1868, -725,
+ 389, -115, -945, -146,
+ -1837, -578, -620, 975,
+ 389, 1779, 1732, 296,
+ 377, 897, 1555, 2269,
+ -854, 26, 590, 1413,
+ -780, -985, 1389, 2639,
+ 312, -277, -935, -3289,
+ 1740, 1852, 641, -519,
+ 738, 898, -466, 115,
+ 1187, -286, -1514, -1309,
+ 74, -801, -583, -987,
+ 510, -667, 430, -191,
+ 418, -303, 806, 1258,
+ -1083, -1065, 362, -2114,
+ -1075, 82, 260, 286,
+ -2579, 14, 75, -854,
+ -661, -634, 482, -581,
+ -338, -306, 3255, 388,
+ -230, -24, 1161, 205,
+ 256, 546, -141, 1379,
+ -63, -775, -484, 1478,
+ -517, -546, -451, 86,
+ 1473, -1201, 430, -1892,
+ 394, 831, 620, -664,
+ 334, 64, 1773, -1576,
+ -1783, 1270, 1020, 944,
+ 1023, 98, -1908, 1330,
+ -560, -1044, 380, 707,
+ -427, -708, -1815, -90,
+ -54, 2298, -537, 1151,
+ -499, 703, -1018, 3322,
+ 92, 717, -607, -1032,
+ -1313, -1393, -580, -485,
+ 34, -2192, 788, -860,
+ 2641, 628, -776, -259,
+ -702, -159, -1483, -1638,
+ -33, -63, 97, 553,
+ 692, 523, 548, 349,
+ -913, 54, -456, -702,
+ -341, 944, 157, 100,
+};
+
+const Word16 w_NOR_fx[SWB_FENV] = /*Q15 */
+{
+ 32767, 32056, 31374, 30720, 30093, 29491, 28913,
+ 28357, 27822, 27307, 26810, 26331, 25869, 25423,
+};
+
+const Word16 Mean_env_fx[SWB_FENV] = /*Q8 */
+{
+ 7327, 7414, 7181, 7160, 6889, 6866, 6746,
+ 6651, 6385, 6152, 5873, 5668, 5435, 5222,
+};
+
+const Word16 Env_TR_Cdbk1_fx [N_CB_TR1 * DIM_TR1] = /*Q8 */
+{
+ 229, -2347,
+ 8199, 7726,
+ -312, 1700,
+ 9881, 5949,
+ 8942, 8358,
+ 3865, 3287,
+ 2405, 796,
+ 3664, 1433,
+ 3059, 2215,
+ 618, 874,
+ -5479, -4636,
+ 2237, 2512,
+ 4265, 2428,
+ 6583, 2065,
+ 4548, 6579,
+ 11325, 7340,
+ 10578, 9264,
+ 8491, 6457,
+ -1380, -2484,
+ 3377, 5069,
+ 7393, 5120,
+ 4798, 4440,
+ 5506, 7614,
+ -3371, -3982,
+ 2806, 2959,
+ 2242, 3550,
+ 1334, 3065,
+ 2055, -1350,
+ 815, 5507,
+ 4940, 1457,
+ -1950, -1046,
+ 653, -1133,
+ 872, -3622,
+ -1756, 245,
+ 5792, 5542,
+ 4084, 7696,
+ 4569, 5204,
+ -810, -1555,
+ 10127, 10384,
+ 11341, 11713,
+ 6365, 4996,
+ 8641, 10527,
+ 5914, 3366,
+ 4522, 3266,
+ 5217, 2830,
+ 8107, 8980,
+ 3952, 5858,
+ 5848, 8990,
+ 6424, 5931,
+ 5185, 3823,
+ 6367, 6917,
+ 3548, 2683,
+ 1634, 2098,
+ 2729, -89,
+ 6964, 7664,
+ 3179, 3561,
+ 6388, 4193,
+ 4024, 4828,
+ -378, 434,
+ 9338, 9507,
+ 7593, 3483,
+ -6835, -6317,
+ 5207, 5029,
+ 11326, 10488,
+ 7411, 6086,
+ 10072, 8255,
+ -6099, -5652,
+ 7074, 8702,
+ -12228, -11384,
+ -11471, -10567,
+ -13025, -12253,
+ -12879, -11289,
+ -13952, -13062,
+ -16214, -15389,
+ -11659, -10789,
+ -12351, -11477,
+ -12789, -11947,
+ -15139, -14249,
+ -11326, -11219,
+ -11950, -11093,
+ -11800, -10928,
+ -23738, -22881,
+ 12795, 11890,
+ -3793, -2879,
+ -27373, -26492,
+ -11928, -11531,
+ -12110, -11258,
+ -20492, -19634,
+ -14371, -13608,
+ -12591, -11728,
+ -14055, -11739,
+ 9471, 7272,
+ -11184, -10335,
+ -13313, -11673,
+ -12209, -10610,
+ -13465, -12761,
+ 7690, 7115,
+ 2564, 4496,
+ 5587, 4551,
+ -813, -562,
+ -4483, -5521,
+ 1556, 98,
+ 2, 3468,
+ 1410, 1339,
+ 4049, 161,
+ -4538, -4026,
+ -9866, -9115,
+ -1616, -4727,
+ 2457, 1653,
+ 631, 2155,
+ -17982, -17082,
+ 2628, 6088,
+ -10791, -9933,
+ -12426, -11566,
+ 4322, 4000,
+ -1574, 2162,
+ -7968, -7599,
+ 1523, 4192,
+ 5621, 6537,
+ -2511, -1987,
+ 12471, 9218,
+ 8746, 4971,
+ 3642, 4148,
+ 5089, 5948,
+ 350, -92,
+ 7028, 6683,
+ -2430, -3216,
+ -3974, -886,
+};
+
+const Word16 Env_TR_Cdbk2_fx [N_CB_TR2 * DIM_TR2] = /*Q8 */
+{
+ 2639, 375,
+ -481, 1694,
+ -2400, -3306,
+ 86, -4018,
+ -1301, 47,
+ 734, 299,
+ 957, -1039,
+ 2204, 1486,
+ 361, -1136,
+ 2628, -838,
+ -2010, 1296,
+ 373, 127,
+ -573, 2604,
+ 689, -1554,
+ 1676, -371,
+ 1298, 279,
+ -901, 1086,
+ 1747, -2723,
+ 214, -657,
+ -731, -909,
+ 1545, -1658,
+ -369, -2208,
+ -1276, 1748,
+ 1141, -522,
+ 186, -1893,
+ -1260, -2016,
+ -478, -504,
+ 1287, 1882,
+ -97, -1400,
+ -1372, -1165,
+ 800, -152,
+ 413, -240,
+ -208, -858,
+ -90, -399,
+ 492, 2519,
+ 913, 1368,
+ -344, 282,
+ 305, 526,
+ -251, 860,
+ -1066, 567,
+ -2800, -687,
+ 1, 674,
+ 176, 878,
+ -716, -153,
+ 706, 831,
+ -1083, -424,
+ 419, 1192,
+ -132, 565,
+ 708, -2406,
+ 600, -661,
+ 1712, 2969,
+ -1974, 379,
+ -672, 208,
+ 26, 296,
+ -1821, -501,
+ -513, 635,
+ 266, 1737,
+ -221, 1232,
+ -3498, 1632,
+ -337, -66,
+ -552, -1427,
+ 1329, 850,
+ -718, -2948,
+ -3, 0,
+};
+
+const Word16 Mean_env_tr_fx[5]= {6971, 6095, 6111, 4995}; /*Q8 */
+
+
+const Word16 EnvCdbkFB_fx [N_CB_FB * DIM_FB] = /*Q7 */
+{
+ -2126, -1242, -945,
+ 1628, -686, -539,
+ 1230, 2245, 2532,
+ 2822, 3094, 2669,
+ -12376, -11507, -11342,
+ 2678, 3533, 3510,
+ 489, 903, 689,
+ 1930, 2929, 3025,
+ 3424, 4179, 4050,
+ -2500, -1707, -1415,
+ -3511, -2563, -2224,
+ -865, -987, -1212,
+ -424, 891, 1919,
+ 1976, 2520, 2277,
+ 673, 1667, 1945,
+ 5169, 6024, 5983,
+ -1367, -501, -236,
+ -254, 679, 989,
+ -18974, -18088, -17834,
+ -23007, -22053, -22109,
+ 2262, 2301, -625,
+ -124, 431, 372,
+ 1454, 1962, 1791,
+ 200, 1094, 1347,
+ -997, -110, 213,
+ -697, 267, 602,
+ -3066, -2172, -1876,
+ -4358, -3493, -3164,
+ -360, 59, -472,
+ -1813, -919, -601,
+ 4204, 4967, 4913,
+ 953, 1457, 1245
+};
+
+const Word16 Mean_env_fb_fx[DIM_FB] = {1760, 805, 473}; /*Q8 */
+
+
+/*-------------------------------------------------------------------*
+ * Pulse indexing tables for ACELP innovation coding
+ *-------------------------------------------------------------------*/
+
+const Word32 PI_select_table_fx[23][8] =
+{
+ {1, 0, 0, 0, 0, 0, 0, 0},
+ {1, 1, 0, 0, 0, 0, 0, 0},
+ {1, 2, 1, 0, 0, 0, 0, 0},
+ {1, 3, 3, 1, 0, 0, 0, 0},
+ {1, 4, 6, 4, 1, 0, 0, 0},
+ {1, 5, 10, 10, 5, 1, 0, 0},
+ {1, 6, 15, 20, 15, 6, 1, 0},
+ {1, 7, 21, 35, 35, 21, 7, 1},
+ {1, 8, 28, 56, 70, 56, 28, 8},
+ {1, 9, 36, 84, 126, 126, 84, 36},
+ {1, 10, 45, 120, 210, 252, 210, 120},
+ {1, 11, 55, 165, 330, 462, 462, 330},
+ {1, 12, 66, 220, 495, 792, 924, 792},
+ {1, 13, 78, 286, 715, 1287, 1716, 1716},
+ {1, 14, 91, 364, 1001, 2002, 3003, 3432},
+ {1, 15, 105, 455, 1365, 3003, 5005, 6435},
+ {1, 16, 120, 560, 1820, 4368, 8008, 11440},
+ {1, 17, 136, 680, 2380, 6188, 12376, 19448},
+ {1, 18, 153, 816, 3060, 8568, 18564, 31824},
+ {1, 19, 171, 969, 3876, 11628, 27132, 50388},
+ {1, 20, 190, 1140, 4845, 15504, 38760, 77520},
+ {1, 21, 210, 1330, 5985, 20349, 54264, 116280},
+ {1, 22, 231, 1540, 7315, 26334, 74613, 1705444}
+};
+
+const Word32 PI_offset_fx[8][8] =
+{
+ /* for 0p(0). */
+ {0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000},
+ /* for 1p(1). */
+ {0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000},
+ /* for 2p(2,1). */
+ {0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000,0x00000},
+ /* for 3p(3,2,1). */
+ {0x00000,0x00000,0x01180,0x01540,0x00000,0x00000,0x00000,0x00000},
+ /* for 4p(4,3,2,1). */
+ {0x00000,0x00000,0x071C0,0x0A640,0x0ABE0,0x00000,0x00000,0x00000},
+ /* for 5p(5,4,3,2,1). */
+ {0x00000,0x00000,0x22200,0x3E900,0x45200,0x45980,0x00000,0x00000},
+ /* for 6p(6,5,4,3,2,1). */
+ {0x00000,0x00000,0x07d200,0x127c00,0x16ed80,0x179c80,0x17a5e0,0x00000},
+ /* for 7p(7,6,5,4,3,2,1). */
+ {0x00000,0x00000,0x165800,0x454400,0x654200,0x6E2500,0x6F2B80,0x6F36C0}
+};
+
+const Word16 PI_factor_fx[7] = {0,0,120,560,1820,4368,8008};
+
+/*------------------------------------------------------------------------------*
+ * AVQ - RE8 tables
+ *------------------------------------------------------------------------------*/
+
+const Word16 select_table22_fx[5][9] =
+{
+ {1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {0, 1, 2, 3, 4, 5, 6, 7, 8},
+ {0, 0, 1, 3, 6, 10, 15, 21, 28},
+ {0, 0, 0, 1, 4, 10, 20, 35, 56},
+ {0, 0, 0, 0, 1, 5, 15, 35, 70}
+};
+
+/* value of leader element */
+const Word16 vals_a_fx[36][4] =
+{
+ {1}, {0,2}, {0,2}, {1,3}, {0,4}, {2,0}, {1,3}, {0,2,4},
+ {2}, {1,3}, {2,0,4}, {0,4}, {1,5}, {1,3}, {2,0,4}, {0,2,4},
+ {1,3,5}, {0,2,6}, {0,4}, {0,2,6}, {0,2,4,6}, {1,7}, {0,8}, {0,6},
+ {0,2,8}, {0,4,8}, {1,9}, {0,2,10}, {0,8}, {0,6,10}, {0,12}, {0,4,12},
+ {0,10}, {0,2,14}, {0,8,12}, {0,16}
+};
+
+/* code parameter for every leader */
+const Word16 vals_q_fx[36][4] =
+{
+ {7,1}, {2,2,2}, {4,2,4}, {7,2,1}, {1,2,1}, {6,2,2}, {7,2,2}, {3,3,3,1},
+ {8,1}, {7,2,3}, {5,3,4,1}, {2,2,2}, {7,2,1}, {7,2,4}, {7,3,2,1}, {4,3,4,2},
+ {7,3,2,1}, {2,3,2,1}, {3,2,3}, {4,3,4,1}, {3,4,3,2}, {7,2,1}, {1,2,1}, {2,2,2},
+ {3,3,3,1}, {2,3,2,1}, {7,2,1}, {2,3,2,1}, {2,2,2}, {2,3,2,1}, {1,2,1}, {2,3,2,1},
+ {2,2,2}, {2,3,2,1}, {2,3,2,1}, {1,2,1}
+};
+
+/* codebook start address for every leader */
+const UWord16 Is_fx[36] =
+{
+ 0, 128, 256, 1376, 240, 0, 1792, 2400, 5376, 5632, 12800, 3744,
+ 21760, 22784, 31744, 38912, 45632, 3856, 52800, 53248, 57728, 60416, 4080, 61440,
+ 61552, 62896, 63120, 64144, 64368, 64480, 64704, 64720, 64944, 65056, 65280, 65504
+};
+
+/* A3 - Number of the absolute leaders in codebook Q3 */
+const Word16 A3_fx[NB_LDQ3] =
+{
+ 0, 1, 4, 2, 3, 7, 11, 17, 22
+};
+
+/* A4 - Number of the absolute leaders in codebook Q4 */
+const Word16 A4_fx[NB_LDQ4] =
+{
+ 5, 6, 8, 9, 10, 12, 13, 14, 15,
+ 16, 18, 19, 20, 21, 23, 24, 25, 26,
+ 27, 28, 29, 30, 31, 32, 33, 34, 35
+};
+
+/* I3 - Cardinality offsets for absolute leaders in Q3 */
+const UWord16 I3_fx[NB_LDQ3] =
+{
+ 0, 128, 240, 256, 1376, 2400, 3744, 3856, 4080
+};
+
+/* I4 - Cardinality offset for absolute leaders in Q4 */
+const UWord16 I4_fx[NB_LDQ4] =
+{
+ 0, 1792, 5376, 5632, 12800, 21760, 22784, 31744, 38912,
+ 45632, 52800, 53248, 57728, 60416, 61440, 61552, 62896, 63120,
+ 64144, 64368, 64480, 64704, 64720, 64944, 65056, 65280, 65504
+};
+
+/* Da_pos - Position of the first absolute leader on a spherical shell (or sphere) */
+const Word16 Da_pos_fx[NB_SPHERE] =
+{
+ 0, 2, 5, 8, 13, 18, 20, 22, 23, 25, 26, 27, 27, 28, 28, 28,
+ 29, 30, 31, 31, 32, 32, 32, 32, 32, 34, 35, 35, 35, 35, 35, 35
+};
+
+/* Da_nb - Number of absolute leaders on a spherical shell */
+const Word16 Da_nb_fx[NB_SPHERE] =
+{
+ 2, 3, 3, 5, 5, 2, 2, 1, 2, 1, 1, 0, 1, 0, 0, 1,
+ 1, 1, 0, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1
+};
+
+/* Da_id - identification code of an absolute leader */
+const Word16 Da_id_fx[NB_LEADER] =
+{
+ 0x0001, 0x0004, 0x0008, 0x000B, 0x0020, 0x000C, 0x0015, 0x0024,
+ 0x0010, 0x001F, 0x0028, 0x0040, 0x004F, 0x0029, 0x002C, 0x0044,
+ 0x0059, 0x00A4, 0x0060, 0x00A8, 0x00C4, 0x012D, 0x0200, 0x0144,
+ 0x0204, 0x0220, 0x0335, 0x04E4, 0x0400, 0x0584, 0x0A20, 0x0A40,
+ 0x09C4, 0x12C4, 0x0C20, 0x2000
+};
+
+/* Da_nq - Codebook number for each absolute leader */
+const Word16 Da_nq_fx[NB_LEADER+2] =
+{
+ 2, 2, 3, 3, 2, 4, 4, 3, 4, 4, 4, 3, 4, 4, 4, 4,
+ 4, 3, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 0, 100
+};
+
+
+/*------------------------------------------------------------------------------*
+ * LP muisc post-filter
+ *------------------------------------------------------------------------------*/
+
+const Word16 post_dct_wind_fx[OFFSET2] = /*Q15 */
+{
+ 32767, 32766, 32759, 32748, 32733, 32713, 32689, 32660,
+ 32627, 32590, 32548, 32502, 32452, 32397, 32338, 32274,
+ 32207, 32135, 32059, 31979, 31894, 31805, 31712, 31615,
+ 31514, 31409, 31300, 31187, 31070, 30949, 30823, 30695,
+ 30562, 30425, 30285, 30141, 29993, 29841, 29686, 29527,
+ 29365, 29200, 29030, 28858, 28682, 28503, 28320, 28134,
+ 27945, 27753, 27558, 27360, 27159, 26955, 26749, 26539,
+ 26327, 26112, 25894, 25674, 25452, 25226, 24999, 24769,
+ 24537, 24303, 24067, 23828, 23588, 23345, 23101, 22855,
+ 22607, 22358, 22107, 21854, 21600, 21345, 21088, 20830,
+ 20570, 20310, 20049, 19786, 19523, 19258, 18993, 18728,
+ 18461, 18195, 17927, 17659, 17391, 17123, 16854, 16586,
+ 16317, 16048, 15779, 15511, 15243, 14975, 14707, 14440,
+ 14173, 13907, 13642, 13377, 13114, 12851, 12589, 12328,
+ 12068, 11809, 11552, 11296, 11041, 10787, 10536, 10285,
+ 10037, 9790, 9545, 9301, 9060, 8820, 8583, 8348,
+ 8115, 7884, 7655, 7429, 7205, 6983, 6765, 6548,
+ 6335, 6124, 5916, 5710, 5508, 5308, 5112, 4918,
+ 4728, 4540, 4356, 4175, 3998, 3824, 3653, 3485,
+ 3321, 3161, 3004, 2851, 2701, 2555, 2413, 2274,
+ 2139, 2009, 1882, 1758, 1639, 1524, 1413, 1306,
+ 1203, 1104, 1009, 918, 831, 749, 671, 597,
+ 527, 461, 400, 343, 291, 242, 199, 159,
+ 124, 93, 67, 45, 27, 14, 5, 1
+};
+
+const Word16 mfreq_loc_LD_fx[] = { 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480,
+ 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, (6400-BIN_16kdct_fx)
+ };
+
+const Word16 inv_mfreq_bindiv_LD_fx[] = {3277, 3277, 3277, 3277, 2979, 2731, 2341, 2185, 2048, 1725, 1560, 1365, 1170, 1024, 862, 728, 596, 468, 364, 298}; /*Q15 */
+
+const Word16 inv_mfreq_bindiv_LD_M1_fx[] = {3641, 3641, 3641, 3641, 3277, 2979, 2521, 2341, 2185, 1820, 1638, 1425, 1214, 1057, 886, 745, 607, 475, 368, 301}; /*Q15 */
+
+const Word16 sc_qnoise_fx[] = {3277, 3277, 3277, 3277, 3277, 3277, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2185, 2185, 2185, 2185, 2185};
+
+const Word16 MAX_SNR_SNR1_tab_FX[MBANDS_GN_LD] = { 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 16815, 17096, 17096, 17096, 17096};
+
+const Word16 INV_MAX_SNR_tab_FX[MBANDS_GN_LD] = { 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 862, 1425, 1425, 1425, 1425};
+
+/*const Word16 inv_mfreq_bindiv_LD1_fx[] = {13107, 13107, 13107, 13107, 11916, 10923, 9362, 8738, 8192, 6899, 6242, 5461, 4681, 4096, 3449, 2913, 2383, 1872, 1456, 1192}; //Q17 */
+
+/*------------------------------------------------------------------------------*
+ * Highrate SWB BWE tables
+ *------------------------------------------------------------------------------*/
+
+const Word16 overlap_coefs_48kHz_fx[NSV_OVERLAP*WIDTH_BAND] = /* in Q15 */
+{
+ 9830, 11141, 11796, 12780, 13763, 14418, 15073, 15565, 16056, 16712, 17695, 18678, 20316, 23593, 27197, 31130
+};
+
+const Word16 overlap_coefs_fx[NSV_OVERLAP*WIDTH_BAND] = /* in Q15 */
+{
+ 8847, 10027, 10617, 11502, 12386, 12976, 13566, 14008, 14451, 15041, 15925, 16810, 18285, 21234, 24478, 28017
+};
+
+const Word16 swb_hr_env_code1_fx[NUM_ENVLOPE_CODE_HR1*2] = /* in Q9 */
+{
+ 23, 21, 268, 240, 344, 310, 504, 438,
+ 629, 580, 856, 734, 1305, 1209, 1637, 1693,
+ 1321, 2671, 2154, 3709, 1801, 890, 2243, 1410,
+ 2436, 2404, 3496, 3127, 2279, 5187, 3715, 6394,
+ 3435, 1000, 3381, 1894, 5434, 1299, 4806, 2171,
+ 3645, 4240, 4640, 3628, 4567, 4999, 5785, 6023,
+ 6032, 3010, 7194, 4949, 5735, 4609, 7391, 6777,
+ 7341, 1999, 10276, 2220, 9270, 4210, 11444, 4917,
+ 3708, 8481, 6030, 9814, 5694, 7913, 7457, 8888,
+ 9124, 6090, 8943, 7832, 10925, 6889, 10519, 8768,
+ 4637, 11437, 5754, 14762, 6791, 12873, 8317, 14468,
+ 7818, 11028, 8696, 12646, 10031, 11617, 10315, 13255,
+ 9112, 9960, 10901, 10336, 12338, 9772, 12090, 11543,
+ 12125, 8360, 13766, 9934, 13317, 8004, 14817, 8315,
+ 12848, 6332, 14189, 6791, 14505, 5289, 15684, 6580,
+ 12940, 3143, 14948, 3698, 16472, 2570, 16373, 4851
+};
+
+const Word16 swb_hr_env_code2_fx[NUM_ENVLOPE_CODE_HR2*2] = /* in Q9 */
+{
+ 262, 242, 686, 568, 1303, 901, 1600, 1559,
+ 2505, 1905, 2053, 2944, 2617, 1108, 3414, 1993,
+ 4329, 1409, 5695, 1801, 3391, 3052, 4384, 2562,
+ 4567, 3985, 5509, 3051, 6374, 4280, 7003, 5750,
+ 7000, 2794, 8434, 2006, 10706, 3294, 13034, 4412,
+ 8402, 3878, 9510, 5269, 11309, 6406, 10839, 8811,
+ 2701, 4927, 4656, 5773, 6116, 7956, 8474, 7704,
+ 3255, 8984, 6818, 11144, 3915, 13367, 1255, 16350
+};
+
+const Word16 swb_hr_env_code3_fx[NUM_ENVLOPE_CODE_HR_TR*N_BANDS_TRANS_BWE_HR] = /* in Q9 */
+{
+ 409, 347, 898, 622, 1457, 1033, 2242, 1012,
+ 3039, 1508, 2017, 2161, 4137, 1348, 3881, 2553,
+ 2538, 5306, 3962, 4430, 4730, 3610, 5225, 2877,
+ 5450, 2240, 5970, 1779, 5553, 1364, 6003, 838
+};
+
+
+const Word16 Ip_fft256_fx[10] = {128, 1, 0, 256, 128, 384, 64, 320,192, 448};
+
+const Word16 Ip_fft512_fx[18] = {256, 1, 0, 512, 256, 768, 128, 640,384, 896, 64, 576, 320, 832, 192, 704,448, 960};
+const Word16 w_fft512_fx[256] =
+{
+ 16384, 0, 11585, 11585, 15137, 6270, 6270, 15137,
+ 16069, 3196, 9102, 13623, 13623, 9102, 3196, 16069,
+ 16305, 1606, 10394, 12665, 14449, 7723, 4756, 15679,
+ 15679, 4756, 7723, 14449, 12665, 10394, 1606, 16305,
+ 16364, 804, 11003, 12140, 14811, 7005, 5520, 15426,
+ 15893, 3981, 8423, 14053, 13160, 9760, 2404, 16207,
+ 16207, 2404, 9760, 13160, 14053, 8423, 3981, 15893,
+ 15426, 5520, 7005, 14811, 12140, 11003, 804, 16364,
+ 16379, 402, 11297, 11866, 14978, 6639, 5897, 15286,
+ 15986, 3590, 8765, 13842, 13395, 9434, 2801, 16143,
+ 16261, 2006, 10080, 12916, 14256, 8076, 4370, 15791,
+ 15557, 5139, 7366, 14635, 12406, 10702, 1205, 16340,
+ 16340, 1205, 10702, 12406, 14635, 7366, 5139, 15557,
+ 15791, 4370, 8076, 14256, 12916, 10080, 2006, 16261,
+ 16143, 2801, 9434, 13395, 13842, 8765, 3590, 15986,
+ 15286, 5897, 6639, 14978, 11866, 11297, 402, 16379,
+ 16383, 201, 11442, 11727, 15059, 6455, 6084, 15213,
+ 16029, 3393, 8935, 13733, 13510, 9269, 2999, 16107,
+ 16284, 1806, 10238, 12792, 14354, 7900, 4563, 15736,
+ 15619, 4948, 7545, 14543, 12537, 10549, 1406, 16324,
+ 16353, 1005, 10853, 12274, 14724, 7186, 5330, 15493,
+ 15843, 4176, 8250, 14155, 13039, 9921, 2205, 16235,
+ 16176, 2603, 9598, 13279, 13949, 8595, 3786, 15941,
+ 15357, 5708, 6823, 14896, 12004, 11151, 603, 16373,
+ 16373, 603, 11151, 12004, 14896, 6823, 5708, 15357,
+ 15941, 3786, 8595, 13949, 13279, 9598, 2603, 16176,
+ 16235, 2205, 9921, 13039, 14155, 8250, 4176, 15843,
+ 15493, 5330, 7186, 14724, 12274, 10853, 1005, 16353,
+ 16324, 1406, 10549, 12537, 14543, 7545, 4948, 15619,
+ 15736, 4563, 7900, 14354, 12792, 10238, 1806, 16284,
+ 16107, 2999, 9269, 13510, 13733, 8935, 3393, 16029,
+ 15213, 6084, 6455, 15059, 11727, 11442, 201, 16383
+};
+const Word16 sinq_16k[3*L_FRAME16k/20] =
+{
+ 536, 1608, 2678, 3745, 4808, 5866, 6918, 7962,
+ 8998, 10024, 11039, 12043, 13033, 14010, 14972, 15917,
+ 16846, 17757, 18648, 19520, 20371, 21199, 22006, 22788,
+ 23546, 24279, 24986, 25667, 26319, 26944, 27540, 28106,
+ 28642, 29147, 29622, 30064, 30475, 30852, 31197, 31508,
+ 31786, 32029, 32238, 32413, 32553, 32658, 32728, 32763
+};
+const Word16 sinq_32k[3*L_FRAME32k/20] =
+{
+ 268, 804, 1340, 1876, 2411, 2945, 3479, 4011, 4543, 5073, 5602, 6130,
+ 6655, 7180, 7702, 8222, 8740, 9255, 9768, 10279, 10786, 11291, 11793, 12292,
+ 12787, 13279, 13767, 14252, 14733, 15210, 15683, 16151, 16616, 17075, 17531, 17981,
+ 18427, 18868, 19304, 19734, 20160, 20580, 20994, 21403, 21806, 22203, 22595, 22980,
+ 23359, 23732, 24098, 24459, 24812, 25159, 25499, 25832, 26159, 26478, 26790, 27095,
+ 27393, 27684, 27967, 28243, 28511, 28771, 29024, 29269, 29506, 29735, 29956, 30170,
+ 30375, 30572, 30761, 30941, 31114, 31278, 31433, 31580, 31719, 31849, 31971, 32084,
+ 32189, 32285, 32372, 32451, 32521, 32582, 32634, 32678, 32713, 32740, 32757, 32766
+};
+
+const Word16 sinq_48k[3*L_FRAME48k/20] =
+{
+ 179, 536, 893, 1251, 1608, 1965, 2321, 2678, 3034, 3390, 3745, 4100,
+ 4454, 4808, 5161, 5514, 5866, 6217, 6568, 6918, 7267, 7615, 7962, 8308,
+ 8654, 8998, 9341, 9683, 10024, 10364, 10702, 11039, 11375, 11710, 12043, 12375,
+ 12705, 13033, 13361, 13686, 14010, 14332, 14653, 14972, 15289, 15604, 15918, 16229,
+ 16539, 16846, 17152, 17455, 17757, 18056, 18353, 18648, 18941, 19232, 19520, 19806,
+ 20090, 20371, 20650, 20926, 21200, 21471, 21740, 22006, 22269, 22530, 22789, 23044,
+ 23297, 23547, 23794, 24038, 24280, 24519, 24754, 24987, 25217, 25444, 25667, 25888,
+ 26106, 26320, 26531, 26740, 26945, 27147, 27345, 27541, 27733, 27921, 28107, 28289,
+ 28468, 28643, 28815, 28984, 29149, 29310, 29468, 29623, 29774, 29922, 30066, 30206,
+ 30343, 30476, 30606, 30732, 30854, 30973, 31087, 31199, 31306, 31410, 31510, 31606,
+ 31699, 31788, 31873, 31954, 32031, 32105, 32175, 32241, 32303, 32361, 32415, 32466,
+ 32513, 32556, 32595, 32630, 32661, 32688, 32712, 32731, 32747, 32759, 32766, 32767
+};
+const Word16 Asr_LP16_fx[21] =
+{
+ /*Q15 */
+ 0, 110, 0, -428, 0, 1153, 0, -2832,
+ 0, 10199, 16384, 10199, 0, -2832, 0, 1153,
+ 0, -428, 0, 110, 0
+};
+
+const Word16 Asr_LP32_fx[41] =
+{
+ /*Q15 */
+ 0, 24, 55, 58, 0, -113, -214, -198,
+ 0, 323, 576, 510, 0, -795, -1416, -1280,
+ 0, 2337, 5099, 7334, 8192, 7334, 5099, 2337,
+ 0, -1280, -1416, -795, 0, 510, 576, 323,
+ 0, -198, -214, -113, 0, 58, 55, 24,
+ 0
+};
+
+const Word16 Asr_LP48_fx[61] =
+{
+ /*Q17 */
+ 0, 38, 93, 146, 167, 123, 0, -192,
+ -408, -571, -592, -407, 0, 564, 1143, 1537,
+ 1546, 1035, 0, -1391, -2801, -3776, -3843, -2635,
+ 0, 3919, 8679, 13599, 17887, 20809, 21845, 20809,
+ 17887, 13599, 8679, 3919, 0, -2635, -3843, -3776,
+ -2801, -1391, 0, 1035, 1546, 1537, 1143, 564,
+ 0, -407, -592, -571, -408, -192, 0, 123,
+ 167, 146, 93, 38, 0
+};
+const Word16 short_window_48kHz_fx[L_FRAME48k/2/2] = /* second half is symetric and omitted */
+{
+ 107, 322, 536, 751, 965, 1179, 1394, 1608, 1822, 2036, 2250, 2464, 2678, 2892, 3105, 3319,
+ 3532, 3745, 3958, 4171, 4383, 4596, 4808, 5020, 5232, 5444, 5655, 5866, 6077, 6288, 6498, 6708,
+ 6918, 7127, 7336, 7545, 7754, 7962, 8170, 8377, 8585, 8791, 8998, 9204, 9409, 9615, 9819, 10024,
+ 10228, 10431, 10634, 10837, 11039, 11241, 11442, 11643, 11843, 12043, 12242, 12441, 12639, 12836, 13033, 13230,
+ 13426, 13621, 13816, 14010, 14204, 14397, 14589, 14781, 14972, 15162, 15352, 15541, 15730, 15917, 16105, 16291,
+ 16477, 16662, 16846, 17030, 17213, 17395, 17576, 17757, 17937, 18116, 18294, 18472, 18648, 18824, 18999, 19174,
+ 19347, 19520, 19692, 19863, 20033, 20202, 20371, 20538, 20705, 20871, 21035, 21199, 21363, 21525, 21686, 21846,
+ 22006, 22164, 22322, 22478, 22634, 22788, 22942, 23095, 23246, 23397, 23546, 23695, 23843, 23989, 24135, 24279,
+ 24423, 24565, 24707, 24847, 24986, 25125, 25262, 25398, 25533, 25667, 25800, 25931, 26062, 26191, 26320, 26447,
+ 26573, 26698, 26821, 26944, 27066, 27186, 27305, 27423, 27540, 27655, 27770, 27883, 27995, 28106, 28216, 28324,
+ 28431, 28537, 28642, 28746, 28848, 28949, 29049, 29148, 29245, 29341, 29436, 29530, 29622, 29713, 29803, 29891,
+ 29979, 30064, 30149, 30232, 30315, 30395, 30475, 30553, 30630, 30705, 30780, 30853, 30924, 30994, 31063, 31131,
+ 31197, 31262, 31326, 31388, 31449, 31508, 31567, 31624, 31679, 31733, 31786, 31837, 31887, 31936, 31984, 32029,
+ 32074, 32117, 32159, 32200, 32239, 32276, 32313, 32348, 32381, 32413, 32444, 32473, 32501, 32528, 32553, 32577,
+ 32600, 32621, 32640, 32658, 32675, 32691, 32705, 32717, 32729, 32738, 32747, 32754, 32759, 32764, 32766, 32767,
+};
+const Word16 short_window_32kHz_fx[L_FRAME32k/2/2] = /* second half is symetric and omitted */
+{
+ 161, 483, 804, 1126, 1447, 1768, 2090, 2411, 2731, 3052, 3372, 3692, 4011, 4330, 4649, 4967,
+ 5285, 5602, 5919, 6235, 6550, 6865, 7180, 7493, 7806, 8118, 8429, 8740, 9049, 9358, 9666, 9973,
+ 10279, 10584, 10888, 11191, 11492, 11793, 12093, 12391, 12688, 12984, 13279, 13572, 13865, 14155, 14445, 14733,
+ 15019, 15305, 15588, 15871, 16151, 16430, 16708, 16984, 17258, 17531, 17802, 18071, 18338, 18604, 18868, 19130,
+ 19390, 19649, 19905, 20160, 20413, 20663, 20912, 21159, 21403, 21646, 21886, 22125, 22361, 22595, 22827, 23056,
+ 23284, 23509, 23732, 23953, 24171, 24387, 24601, 24812, 25021, 25228, 25432, 25633, 25833, 26029, 26223, 26415,
+ 26604, 26791, 26975, 27156, 27335, 27511, 27684, 27855, 28023, 28188, 28351, 28511, 28668, 28823, 28974, 29123,
+ 29269, 29412, 29553, 29690, 29825, 29957, 30086, 30212, 30335, 30455, 30572, 30687, 30798, 30906, 31012, 31114,
+ 31214, 31310, 31403, 31494, 31581, 31665, 31747, 31825, 31900, 31972, 32041, 32107, 32169, 32229, 32286, 32339,
+ 32389, 32437, 32481, 32522, 32559, 32594, 32626, 32654, 32679, 32701, 32720, 32736, 32749, 32758, 32764, 32767,
+};
+
+const Word16 short_window_16kHz_fx[L_FRAME16k/2/2] = /* second half is symetric and omitted */
+{
+ 322, 965, 1608, 2250, 2892, 3532, 4171, 4808, 5444, 6077, 6708, 7336, 7962, 8585, 9204, 9819,
+ 10431, 11039, 11643, 12242, 12836, 13426, 14010, 14589, 15162, 15730, 16291, 16846, 17395, 17937, 18472, 18999,
+ 19520, 20033, 20538, 21035, 21525, 22006, 22478, 22942, 23397, 23843, 24279, 24707, 25125, 25533, 25931, 26320,
+ 26698, 27066, 27423, 27770, 28106, 28431, 28746, 29049, 29341, 29622, 29891, 30149, 30395, 30630, 30853, 31063,
+ 31262, 31449, 31624, 31786, 31936, 32074, 32200, 32313, 32413, 32501, 32577, 32640, 32691, 32729, 32754, 32766,
+};
+
+const Word16 short_window_8kHz_fx[L_FRAME8k/2/2] = /* second half is symetric and omitted */
+{
+ 643, 1929, 3212, 4490, 5760, 7022, 8274, 9512,
+ 10736, 11943, 13132, 14300, 15447, 16569, 17666, 18736,
+ 19777, 20788, 21766, 22711, 23621, 24494, 25330, 26127,
+ 26883, 27598, 28270, 28899, 29483, 30022, 30514, 30959,
+ 31357, 31706, 32007, 32258, 32459, 32610, 32711, 32762,
+};
+
+const Word16 Hilbert_coeffs_fx[4*NUM_HILBERTS][HILBERT_ORDER1+1] = /* Q14 */
+{
+ { 0, 14320, 0, -30699, 0, 16384}, /* num_Real[0] */
+ {11897, 0, -28240, 0, 16384, 0}, /* num_Imag[0] */
+ {16384, 0, -30699, 0, 14320, 0}, /* den_Real[0] */
+ {16384, 0, -28240, 0, 11897, 0}, /* den_Imag[0] */
+ {7671, 0, -23855, 0, 16384, 0}, /* num_Real[1] */
+ { 2505, 0, -18139, 0, 16384, 0}, /* num_Imag[1] */
+ {16384, 0, -23855, 0, 7671, 0}, /* den_Imag[1] */
+ {16384, 0, -18139, 0, 2505, 0}, /* den_Imag[1] */
+};
+
+
+const Word16 win_flatten_4k_fx[L_FRAME16k/8] = /*Q15 */
+{
+ 13, 114, 315, 615, 1013, 1505, 2089, 2761,
+ 3517, 4353, 5263, 6241, 7282, 8378, 9525, 10713,
+ 11937, 13188, 14458, 15741, 17027, 18310, 19580, 20831,
+ 22055, 23243, 24390, 25486, 26527, 27505, 28415, 29251,
+ 30007, 30679, 31263, 31755, 32153, 32453, 32654, 32755
+};
+
+const Word16 gaus_dico_swb_fx[256] =
+{
+ /*Q15 */
+ 709, 11759, -5333, -2701, 2397, -18, -4286, 2368,
+ -4576, -1584, -900, -940, 3676, 5441, -44, 2234,
+ -5698, 3082, -2671, 1666, -640, -3343, -1005, -1689,
+ 2048, 281, -3935, -3723, 5628, 385, -746, -3243,
+ -3332, -7228, -1748, -206, -5474, 2554, 2861, 3168,
+ 5039, 588, -508, -8167, 6549, -3433, 2187, -3666,
+ -5874, 2767, 8370, 1038, 6434, 6279, 625, 4030,
+ -1031, 1823, 9896, -1395, 2712, -1110, -742, 6142,
+ -4456, -10487, -144, -5104, 1968, -312, 6176, 2173,
+ 2334, -240, 2712, 7460, 2219, -3116, -56, 2770,
+ 5577, -1225, 770, 3557, 2246, 2322, 3077, 41,
+ 992, -4971, 441, -5039, 4913, 3811, 1142, -1283,
+ -6578, 4171, -1473, -3793, -5008, 1984, -1138, -1185,
+ 5646, 1014, -5118, 7141, 2656, -7241, -3538, 2337,
+ 7239, -504, -943, -10129, 702, -3811, -302, 2435,
+ 5090, 3744, 2335, -3904, -1401, -1662, -7256, 6484,
+ -6864, -5428, 1954, -7316, -1420, -1542, 5442, 311,
+ 3698, -1343, -2974, 8756, 324, -1903, 2580, 2635,
+ 4236, -1851, 3147, -772, -708, -3830, 2601, -1889,
+ -3444, -762, 3939, 3206, -7406, -837, -1167, -438,
+ 3707, -1015, -7472, 1849, 4277, 1459, -3047, -3760,
+ 740, -7134, -3753, -3092, 209, -12121, 1398, 2266,
+ 2505, -7974, -1121, -3481, -5644, 1329, 4532, 958,
+ 5311, -4258, -3195, -1769, -3055, 4399, -15, 10182,
+ 4503, 1912, -1574, 5054, -3163, 4881, -5364, 1925,
+ -1205, -6432, 2305, -8917, -1422, 514, -3001, 3928,
+ 2321, 360, -355, 1477, -3492, -4570, 1913, 2772,
+ -1380, -5161, 3812, 2614, 2204, -3135, 1244, -3066,
+ -4446, -6389, 4899, -5250, 1372, 1999, 1122, 5312,
+ 1310, -1189, -3310, 6403, 3818, 7734, 1620, -8533,
+ 706, 7498, -4472, 1272, -949, 3203, -4427, -2855,
+ 4419, 2283, 6410, 2584, -3397, -3382, -2976, -48,
+};
+
+
+const Word16 win_flatten_fx[L_FRAME16k/2] = /*Q15 */
+{
+ 3, 13, 28, 50, 78, 113, 154, 200, 254, 313,
+ 378, 450, 528, 611, 701, 797, 899, 1006, 1120, 1239,
+ 1365, 1496, 1632, 1775, 1923, 2076, 2235, 2400, 2569, 2745,
+ 2925, 3110, 3301, 3496, 3697, 3902, 4112, 4327, 4546, 4770,
+ 4999, 5232, 5469, 5710, 5955, 6205, 6458, 6715, 6976, 7240,
+ 7508, 7779, 8054, 8331, 8612, 8896, 9183, 9472, 9764, 10059,
+ 10356, 10655, 10956, 11260, 11566, 11873, 12182, 12493, 12805, 13119,
+ 13434, 13750, 14067, 14385, 14703, 15023, 15342, 15663, 15983, 16304,
+ 16625, 16945, 17265, 17586, 17905, 18224, 18542, 18860, 19176, 19492,
+ 19806, 20119, 20431, 20741, 21049, 21355, 21660, 21963, 22263, 22561,
+ 22857, 23150, 23441, 23729, 24014, 24297, 24576, 24852, 25125, 25395,
+ 25661, 25923, 26182, 26437, 26689, 26936, 27179, 27418, 27653, 27884,
+ 28110, 28332, 28549, 28761, 28969, 29172, 29370, 29563, 29751, 29934,
+ 30112, 30284, 30451, 30613, 30769, 30920, 31065, 31205, 31338, 31467,
+ 31589, 31705, 31816, 31921, 32020, 32113, 32199, 32280, 32355, 32423,
+ 32486, 32542, 32592, 32636, 32673, 32704, 32730, 32748, 32761, 32767
+};
+const Word16 AP1_STEEP_FX[ALLPASSSECTIONS_STEEP] = {1985, 14072, 26500}; /*Q15 Format */
+const Word16 AP2_STEEP_FX[ALLPASSSECTIONS_STEEP] = {7230, 20838, 30852}; /*Q15 Format */
+
+const Word16 cos_fb_exc_fx[32] = /* Q15 */
+{
+ /*Q35*/
+ 32767, 32138, 30274, 27246, 23170, 18205, 12540, 6393,
+ 0, -6393, -12540, -18205, -23170, -27246, -30274, -32138,
+ -32768, -32138, -30274, -27246, -23170, -18205, -12540, -6393,
+ 0, 6393, 12540, 18205, 23170, 27246, 30274, 32138,
+};
+
+
+const Word16 subwin_wb_fx[SHB_OVERLAP_LEN/2+1]=
+{0, 5126, 10126, 14876, 19261, 23170, 26510, 29197, 31164, 32365, 32767 };
+
+const Word16 window_wb_fx[L_SHB_LAHEAD/4]=/*sin, 1 */
+{ 7502, 18518, 27034, 31898, 32767}; /*Q15*/
+
+const Word16 window_shb_fx[L_SHB_LAHEAD]= /*sin, 1, sin */
+{
+ /*Q15(round) */
+ 1513, 4527, 7502, 10413, 13236, 15945, 18518, 20934, 23170, 25210,
+ 27034, 28627, 29976, 31069, 31898, 32454, 32733, 32767, 32767, 32767,
+};
+
+const Word16 window_shb_32k_fx[2*L_SHB_LAHEAD] =
+{
+ /*Q15(round) */
+ 1513, 3020, 4527, 6015, 7502, 8958, 10413, 11825, 13236, 14590,
+ 15945, 17232, 18518, 19726, 20934, 22052, 23170, 24190, 25210, 26122,
+ 27034, 27830, 28627, 29301, 29976, 30523, 31069, 31483, 31898, 32176,
+ 32454, 32593, 32733, 32751, 32767, 32767, 32767, 32767, 32767, 32767,
+};
+
+const Word16 subwin_shb_fx[SHB_OVERLAP_LEN+1]=
+{
+ /*Q15(round) */
+ 0, 202, 802, 1786, 3129,
+ 4799, 6754, 8946, 11321, 13821,
+ 16384,18947, 21447, 23822, 26014,
+ 27969, 29639, 30982, 31966, 32566,
+ 32767
+};
+
+/*----------------------------------------------------------------------------------*
+ * FEC for HQ core
+ *----------------------------------------------------------------------------------*/
+
+const short Num_bands_NB[MAX_SB_NB] = {8,8,2};
+
+
+const Word16 hvq_cb_search_overlap24k[17] =
+{
+ 0, 8, 17, 27,
+ 39, 53, 69, 89,
+ 113, 128, 128, 128,
+ 128, 128, 128, 128,
+ 128
+};
+
+const Word16 hvq_cb_search_overlap32k[21] =
+{
+ 0, 6, 13, 21,
+ 30, 40, 51, 64,
+ 78, 96, 116, 128,
+ 128, 128, 128, 128,
+ 128, 128, 128, 128,
+ 128
+};
+
+
+const Word16 hvq_pg_huff_offset[NUM_PG_HUFFLEN] = {0,2,3,8,9,11,13,15,19};
+const Word16 hvq_pg_huff_thres[NUM_PG_HUFFLEN] = {0,0x2,0x4,0x18,0x20,0x40,0x80,0x100,0x300};
+
+const Word16 hvq_pg_huff_tab[32] =
+{
+ 30, 31, 1, 0, 2, 3, 28, 29, 4, 5, 27, 25, 26, 6, 24, 7, 8, 22, 23, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21
+};
+
+const Word16 hvq_cp_huff_len[52] =
+{
+ 3, 4, 5, 6, 6, 6, 6, 6, 4, 4, 5, 5, 5, 5, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8,
+ 8, 8, 8, 8, 9, 10, 10, 11, 11, 11, 10, 10, 10, 10, 11, 12, 12, 13, 13, 12, 12, 11, 12
+};
+
+const Word16 hvq_cp_huff_val[52] =
+{
+ 7, 8, 6, 3, 4, 5, 6, 7, 9, 10, 7, 8, 9, 10, 11, 12, 13, 11, 12, 13, 14, 15, 8, 9, 10,
+ 11, 4, 5, 3, 4, 5, 6, 7, 5, 4, 5, 3, 4, 5, 6, 7, 8, 9, 6, 1, 2, 0, 1, 3, 4, 7, 5
+};
+
+const Word16 hvq_cp_layer1_map5[HVQ_CP_MAP_LEN] = { 16, 8, 4, 2, 1, 18, 17, 9 };
+
+const Word16 hvq_cp_huff_thres[HVQ_CP_HUFF_NUM_LEN] = { 0x0, 0x2, 0xC, 0x20, 0x50, 0x60, 0x100, 0x180, 0x600, 0x1000, 0x1C00 };
+const Word16 hvq_cp_huff_offset[HVQ_CP_HUFF_NUM_LEN] = { 0, 2, 7, 12, 18, 19, 24, 26, 35, 45, 51 };
+
+const Word16 hvq_cp_huff_tab[52] =
+{
+ 46, 47, 44, 45, 48, 49, 51, 36, 37, 38, 43, 50, 34, 35, 39, 40, 41, 42, 33, 28, 29, 30, 31, 32, 26, 27,
+ 3, 4, 5, 6, 7, 22, 23, 24, 25, 2, 10, 11, 12, 13, 17, 18, 19, 20, 21, 1, 8, 9, 14, 15, 16, 0
+};
+
+
+
+
+const Word16 * const lsf_q_cb_fx[NUM_Q_LSF] = { lsf_q_cb_4b_fx, lsf_q_cb_4b_fx, lsf_q_cb_3b_fx, lsf_q_cb_3b_fx, lsf_q_cb_3b_fx };
+const Word16 lsf_q_cb_size_fx[NUM_Q_LSF] = {16, 16, 8, 8, 8};
+const Word16 grid_smoothing_fx[5] = { 6554, 11469, 16384, 24576, 26214 };
+const Word16 mirror_point_q_cb_fx[MIRROR_POINT_Q_CB_SIZE] = { 471, 692, 896, 1216};
+
+const Word16 lbr_wb_bwe_lsfvq_cbook_2bit_fx[4*4] =
+{
+ /*Q15 */
+ 3876, 5920, 8951, 11884,
+ 6556, 7979, 10835, 13133,
+ 4401, 6781, 10676, 13493,
+ 8453, 9693, 12024, 13921,
+};
+
+const Word32 SHBCB_FrameGain16_fx[16]=
+{
+ /*Q18*/
+ 38968, 125277, 254474, 493383, 1043711, 2083177, 3792746, 6395076,
+ 10256080, 15738899, 23269902, 34118236, 48362464, 71128080, 107459896, 192888864
+};
+const Word16 full_band_bpf_1_fx[6][5] = /*in Q13*/
+{
+ { 789, 802, 248, 802, 789},
+ { 789, 1199, 838, 1199, 789},
+ { 789, 136, -1123, 136, 789},
+ { 8192, 19654, 24391, 17059, 6561},
+ { 8192, 15339, 20118, 13819, 6190},
+ { 8192, 21155, 26558, 17237, 5599}
+};
+
+/* 12th order elliptic Bandpass filter at 16.3 to 19.8 kHz sampled at 48 kHz b0,b1,b2,a0,a1,a2 */
+const Word16 full_band_bpf_2_fx[6][5] = /*in Q13*/
+{
+ { 492, 912, 974, 912, 492},
+ { 492, 1161, 1353, 1161, 492},
+ { 492, 259, -311, 259, 492},
+ { 8192, 22912, 30622, 21214, 7143},
+ { 8192, 20364, 27329, 18844, 6886},
+ { 8192, 23496, 31199, 20826, 6487}
+};
+
+/* 12th order elliptic Bandpass filter at 15.4 to 20.0 kHz sampled at 48 kHz b0,b1,b2,a0,a1,a2 */
+const Word16 full_band_bpf_3_fx[6][5] = /*in Q13*/
+{
+ {611, 888, 717, 888, 611},
+ {611, 1211, 1214, 1211, 611},
+ {611, 197, -671, 197, 611},
+ {8192, 21727, 28230, 19588, 6871},
+ {8192, 18438, 24377, 16796, 6567},
+ {8192, 22683, 29442, 19400, 6081}
+};
+
+const Word16 SHBCB_SubGain5bit_fx[128] =
+{
+ /*Q14 */
+ -2388, -7806, -6576, -6024,
+ -7066, -5430, -4998, -3495,
+ -16722, -15343, -960, -7940,
+ -26291, -5921, -4917, -4378,
+ -1526, -6621, -8475, -9624,
+ -8047, -4086, -8940, -3043,
+ -3630, -5129, -4964, -7381,
+ -270, -18662, -24233, -25418,
+ -9246, -7551, -5584, -2053,
+ -2091, -4622, -9199, -14628,
+ -4645, -2197, -10255, -9697,
+ -2438, -9386, -11737, -4570,
+ -14366, -11436, -8252, -819,
+ -16192, -16332, -17043, -225,
+ -5407, -8588, -7577, -2296,
+ -26309, -21930, -7522, -2514,
+ -3260, -4246, -7947, -6614,
+ -1820, -5520, -15272, -19764,
+ -3706, -3737, -5850, -10520,
+ -10081, -4050, -4065, -5001,
+ -3908, -9909, -2881, -9604,
+ -520, -11156, -12620, -12768,
+ -4539, -5149, -6208, -4462,
+ -4866, -7672, -4235, -4407,
+ -9163, -13411, -2975, -3915,
+ -12267, -7568, -3842, -2827,
+ -7181, -4914, -2608, -9392,
+ -6275, -2868, -5962, -6511,
+ -12962, -1034, -8517, -10992,
+ -8247, -7608, -2502, -5026,
+ -5812, -4998, -3860, -5778,
+ -16907, -5974, -4434, -3276,
+};
+
+
+/* 5-bit TD WB BWE temporal shaping codebook */
+
+const Word16 HBCB_SubGain5bit_fx[128] =
+{
+ -15224, -17789, -9897, -5048, -456, -1232, -2238, -2782,
+ -3391, -3864, -4026, -4045, -2017, -1311, -878, -1973,
+ -12837, -15376, -8273, -4141, -2791, -3037, -2403, -342,
+ -3388, -3646, -3471, -2829, -157, -2025, -2318, -2243,
+ -14652, -16433, -7699, -1188, -2567, -1755, -346, -1682,
+ -2068, -2321, -2344, -2348, -1759, -1038, -1865, -2041,
+ -11396, -13719, -7749, -2734, -809, -1935, -1886, -781,
+ -2136, -1940, -942, -1571, -1926, -2378, -2572, -2145,
+ -17531, -19267, -7721, -2672, -714, -675, -1516, -2071,
+ -1925, -2325, -2523, -2657, -1644, -1674, -2036, -2017,
+ -12781, -14601, -6714, -1380, -2093, -1704, -1124, -756,
+ -2776, -2687, -2066, -1202, -1102, -680, -1956, -2376,
+ -14436, -15846, -4918, -2071, -1613, -744, -1807, -1381,
+ -620, -1294, -2026, -2162, -794, -1755, -1167, -1762,
+ -11627, -13377, -5876, -1959, -1009, -1879, -1027, -1915,
+ -1734, -1265, -2001, -1018, -698, -1733, -2172, -1195,
+
+};
+
+const Word32 SHBCB_FrameGain64_fx[64]=
+{
+ /* Q18 */
+ 11553, 19429, 27466, 35948, 45184, 54817, 65050, 76114,
+ 88089, 100815, 114314, 128727, 144236, 160812, 178639, 197656,
+ 217917, 239688, 263098, 288617, 315962, 345380, 376751, 410569,
+ 446867, 485779, 527885, 574220, 624562, 679333, 738912, 803391,
+ 873329, 949299, 1032054, 1121728, 1219559, 1327347, 1446046, 1576547,
+ 1720983, 1881933, 2062979, 2266614, 2496129, 2759206, 3060575, 3409584,
+ 3818114, 4295643, 4868000, 5551295, 6368310, 7329048, 8475924, 9889403,
+ 11649918, 13794493, 16487623, 19979932, 24732260, 31339886, 41958624, 64261100,
+};
+
+const Word16 lsf_grid_fx[4][5] =
+{
+ { 5242, 10229, 15516, 21804, 27540, },
+ { 5117, 10059, 14949, 20478, 25493, },
+ { 4648, 8732, 13022, 18247, 24474, },
+ { 5052, 8925, 12903, 19427, 28382, }
+};
+
+const Word16 ola_win_shb_switch_fold_fx[L_SUBFR16k] =
+{
+ 322, 965, 1608, 2250, 2892, 3532, 4171, 4808,
+ 5444, 6077, 6708, 7336, 7962, 8585, 9204, 9819,
+ 10431, 11039, 11643, 12242, 12836, 13426, 14010, 14589,
+ 15162, 15730, 16291, 16846, 17395, 17937, 18472, 18999,
+ 19520, 20033, 20538, 21035, 21525, 22006, 22478, 22942,
+ 23397, 23843, 24279, 24707, 25125, 25533, 25931, 26320,
+ 26698, 27066, 27423, 27770, 28106, 28431, 28746, 29049,
+ 29341, 29622, 29891, 30149, 30395, 30630, 30853, 31063,
+ 31262, 31449, 31624, 31786, 31936, 32074, 32200, 32313,
+ 32413, 32501, 32577, 32640, 32691, 32729, 32754, 32766
+};
+const Word16 win_lpc_hb_wb_fx[(L_LOOK_12k8 + L_SUBFR + L_FRAME) * 5/32] =
+{
+ 17, 70, 157, 279, 435, 625, 849, 1106,
+ 1396, 1718, 2071, 2454, 2867, 3309, 3779, 4276,
+ 4799, 5346, 5917, 6510, 7125, 7759, 8411, 9081,
+ 9766, 10465, 11177, 11900, 12633, 13373, 14120, 14872,
+ 15627, 16384, 17141, 17896, 18648, 19395, 20135, 20868,
+ 21591, 22303, 23002, 23687, 24357, 25009, 25643, 26258,
+ 26851, 27422, 27969, 28492, 28989, 29459, 29901, 30314,
+ 30697, 31050, 31372, 31662, 31919, 32143, 32333, 32489,
+ 32611, 32698, 32751
+};
+
+const Word16 wac_h[LPC_SHB_ORDER] =
+{
+ 32763,
+ 32751,
+ 32731,
+ 32703,
+ 32667,
+ 32622,
+ 32570,
+ 32510,
+ 32442,
+ 32366
+};
+
+const Word16 wac_l[LPC_SHB_ORDER] =
+{
+ 31381,
+ 27317,
+ 20869,
+ 12529,
+ 2980,
+ 25869,
+ 16731,
+ 9600,
+ 5926,
+ 7354
+};
+
+const Word16 lpc_weights_fx[LPC_SHB_ORDER+1] =
+{
+ 32767, 31948, 31150, 30371, 29612,
+ 28871, 28149, 27446, 26760, 26091, 25438
+};
+
+
+
+const Word16 SHBCB_SubGain5bit_12_fx[128] =
+{
+ /*Q12 */
+ -597, -1952, -1644, -1506, -1767, -1357, -1249, -874,
+ -4181, -3836, -240, -1985, -6573, -1480, -1229, -1094,
+ -381, -1655, -2119, -2406, -2012, -1022, -2235, -761,
+ -908, -1282, -1241, -1845, -68, -4666, -6058, -6355,
+ -2311, -1888, -1396, -513, -523, -1155, -2300, -3657,
+ -1161, -549, -2564, -2424, -609, -2346, -2934, -1142,
+ -3591, -2859, -2063, -205, -4048, -4083, -4261, -56,
+ -1352, -2147, -1894, -574, -6577, -5483, -1881, -628,
+ -815, -1061, -1987, -1654, -455, -1380, -3818, -4941,
+ -926, -934, -1463, -2630, -2520, -1013, -1016, -1250,
+ -977, -2477, -720, -2401, -130, -2789, -3155, -3192,
+ -1135, -1287, -1552, -1115, -1217, -1918, -1059, -1102,
+ -2291, -3353, -744, -979, -3067, -1892, -961, -707,
+ -1795, -1229, -652, -2348, -1569, -717, -1490, -1628,
+ -3240, -258, -2129, -2748, -2062, -1902, -625, -1257,
+ -1453, -1250, -965, -1445, -4227, -1494, -1108, -819,
+
+
+};
+
+
+const Word16 lsf_q_cb_4b_fx[16] =
+{
+ 589, 773, 914, 1043,
+ 1173, 1302, 1430, 1558,
+ 1698, 1843, 1973, 2103,
+ 2258, 2470, 2787, 3282
+
+};
+
+const Word16 lsf_q_cb_3b_fx[8] =
+{
+ 679, 976, 1245, 1491,
+ 1739, 2011, 2365, 2953
+};
+
+const Word16 pwAlpha[10]= {0x6666, 0x51ec, 0x4189, 0x346e, 0x29f1,
+ 0x218e, 0x1ad8, 0x157a, 0x112e, 0x0dbe
+ };
+
+const Word16 wb_bwe_lsfvq_cbook_8bit_fx[256*6] =
+{
+ 2107, 3430, 5123, 6677, 9403, 13197,
+ 4031, 5069, 7343, 8910, 10647, 12245,
+ 2037, 3542, 6708, 8763, 10505, 12655,
+ 5732, 6373, 7912, 9546, 12584, 14230,
+ 2028, 3337, 5473, 7880, 10269, 12450,
+ 5809, 6497, 8317, 9624, 11497, 14007,
+ 2428, 3962, 5675, 7724, 11361, 13385,
+ 6348, 8307, 8898, 9948, 11058, 13350,
+ 3552, 4421, 5896, 7143, 9975, 13233,
+ 5719, 6344, 7482, 8403, 10765, 13455,
+ 3509, 4379, 5896, 7437, 11765, 14307,
+ 4521, 8122, 8791, 9856, 11232, 14020,
+ 2175, 3970, 7788, 9803, 11334, 12910,
+ 4511, 8156, 8886, 10450, 12686, 14959,
+ 4223, 5285, 7053, 8423, 11317, 14566,
+ 7159, 8379, 9040, 10122, 11799, 14270,
+ 1866, 3064, 4848, 7227, 11225, 13963,
+ 5915, 6631, 8740, 10002, 11385, 12726,
+ 3342, 4547, 6475, 9404, 11994, 13418,
+ 6156, 6880, 8932, 10353, 12380, 13746,
+ 2648, 4972, 7575, 9476, 12117, 13875,
+ 5822, 6526, 8747, 10941, 12671, 13971,
+ 4032, 5110, 7592, 9267, 11374, 14390,
+ 6864, 8384, 9086, 10649, 12944, 15026,
+ 3661, 4636, 6668, 8329, 10374, 12185,
+ 5802, 6444, 8344, 9811, 12234, 14843,
+ 3593, 4436, 6663, 8693, 11539, 14272,
+ 5110, 8270, 9006, 10703, 12269, 13901,
+ 1992, 3229, 5616, 9085, 11419, 13254,
+ 4319, 5859, 9602, 11396, 12836, 14199,
+ 3836, 4822, 8285, 10190, 11728, 13302,
+ 8016, 8698, 10179, 11434, 12944, 14783,
+ 1891, 3329, 6168, 8307, 10818, 14213,
+ 5803, 6442, 7973, 9131, 11090, 12657,
+ 2803, 5499, 8093, 9694, 11223, 12849,
+ 6222, 6981, 8615, 9848, 12016, 13380,
+ 2543, 4747, 7638, 9373, 11129, 13652,
+ 5912, 6615, 9006, 10553, 11959, 13312,
+ 3604, 4520, 7650, 9833, 12161, 14748,
+ 7970, 8729, 9780, 10789, 12483, 13985,
+ 3793, 4716, 7041, 8547, 10610, 13601,
+ 5640, 6235, 7313, 8370, 12057, 14300,
+ 3765, 4699, 6784, 9512, 12663, 14216,
+ 4634, 8363, 9195, 10385, 11477, 13310,
+ 2462, 4816, 8556, 10394, 11920, 13468,
+ 3698, 7974, 9207, 10962, 13507, 15208,
+ 3738, 4667, 7545, 10775, 13024, 14559,
+ 7267, 8610, 9509, 11264, 12821, 14495,
+ 2624, 4295, 6173, 8897, 12343, 14174,
+ 6324, 7135, 8742, 10013, 12598, 14108,
+ 4448, 5839, 8842, 10335, 11737, 13071,
+ 6147, 6988, 9510, 10893, 12240, 13535,
+ 3025, 5140, 7152, 9223, 11404, 13255,
+ 5985, 6782, 9611, 11341, 12723, 14007,
+ 4679, 5958, 8100, 9842, 11835, 13492,
+ 7740, 8565, 9432, 10478, 12611, 14609,
+ 3830, 4784, 7681, 9528, 11134, 12675,
+ 5742, 6527, 8359, 10728, 13195, 14626,
+ 4491, 5635, 7284, 8749, 11594, 13785,
+ 6772, 8490, 9253, 10943, 12476, 13973,
+ 2024, 3588, 7524, 10453, 12198, 13858,
+ 5783, 8882, 9978, 11763, 13237, 14829,
+ 3979, 5009, 8342, 10323, 12231, 14313,
+ 8148, 8903, 10193, 11350, 13246, 14490,
+ 2297, 3810, 5638, 7265, 9162, 11514,
+ 5809, 6518, 7832, 8766, 10327, 11957,
+ 2535, 4591, 7415, 9080, 10623, 12257,
+ 5948, 6598, 8515, 10082, 12721, 14188,
+ 2443, 4278, 6581, 8172, 9883, 11807,
+ 5913, 6535, 8878, 10296, 12141, 14245,
+ 2428, 3925, 6409, 9835, 11962, 13628,
+ 7430, 8531, 9302, 10259, 11444, 12933,
+ 3701, 4694, 6372, 7671, 9445, 11571,
+ 5822, 6470, 7807, 8885, 11506, 14529,
+ 3742, 4580, 6232, 7860, 11252, 13127,
+ 5710, 8330, 8943, 10243, 11696, 14511,
+ 2607, 4197, 6714, 10408, 12714, 14320,
+ 4116, 8438, 9717, 11018, 12156, 13663,
+ 4224, 5318, 7486, 10110, 12779, 14331,
+ 5565, 8413, 9115, 10930, 12588, 14759,
+ 1898, 3150, 5779, 9497, 12432, 14439,
+ 6274, 7186, 9258, 10404, 11733, 12952,
+ 3700, 4591, 7575, 9533, 11461, 13777,
+ 6234, 7104, 9032, 10986, 13088, 14417,
+ 2354, 4579, 7744, 9960, 12629, 14802,
+ 6050, 6729, 9345, 10745, 12436, 14253,
+ 4345, 5529, 8117, 9718, 12433, 14109,
+ 8009, 8701, 9863, 10954, 13046, 14474,
+ 4184, 5186, 6876, 8428, 11236, 12973,
+ 6113, 6842, 8386, 9659, 12892, 14707,
+ 3989, 4936, 7152, 8879, 11743, 13632,
+ 5169, 8411, 9209, 11361, 13452, 15076,
+ 2397, 4387, 7033, 9035, 11821, 13736,
+ 3607, 8128, 10170, 11565, 12819, 14147,
+ 4449, 5805, 8963, 10676, 12596, 14558,
+ 7911, 8741, 10040, 11622, 13579, 15092,
+ 2372, 4290, 6990, 8705, 10637, 13685,
+ 6137, 6917, 8382, 9380, 10859, 12348,
+ 3235, 5973, 8187, 10174, 12420, 14382,
+ 6077, 6764, 8551, 9803, 12150, 14079,
+ 2952, 5097, 6853, 8952, 12066, 14080,
+ 6606, 7683, 9508, 10695, 12182, 13601,
+ 3707, 4638, 7468, 10484, 12295, 13754,
+ 7960, 8715, 10051, 11348, 12757, 14072,
+ 4139, 5241, 7576, 9037, 10912, 13485,
+ 5838, 6444, 7768, 8965, 12867, 14998,
+ 4245, 5338, 7248, 9190, 12328, 14047,
+ 6159, 8874, 9899, 11134, 12150, 13512,
+ 2250, 4288, 8698, 10944, 12624, 14316,
+ 3146, 6848, 9904, 11775, 13534, 14953,
+ 4044, 5161, 8365, 10294, 12945, 14907,
+ 7398, 8724, 9813, 11821, 13246, 14552,
+ 2121, 3890, 6855, 9274, 12059, 14663,
+ 6329, 7182, 8789, 10081, 13001, 14917,
+ 4484, 5761, 8634, 10295, 12111, 14022,
+ 6326, 7208, 9672, 11078, 12830, 14529,
+ 3230, 5564, 7646, 9955, 12011, 13683,
+ 4683, 6896, 10002, 11805, 13329, 14747,
+ 4771, 6044, 8081, 10305, 12526, 14037,
+ 8231, 9203, 10351, 11427, 12926, 14635,
+ 4385, 5774, 7989, 9305, 10751, 12299,
+ 5810, 6658, 9062, 11629, 13359, 14655,
+ 4288, 5388, 7804, 9378, 11781, 13652,
+ 4398, 8560, 9646, 11161, 12701, 14872,
+ 1947, 3440, 7202, 10953, 13222, 14806,
+ 4686, 8972, 10615, 12054, 13260, 14615,
+ 3801, 4849, 8922, 11200, 12882, 14423,
+ 8061, 8813, 10453, 11912, 13335, 14710,
+ 2365, 3888, 5664, 7346, 10407, 14331,
+ 4563, 5839, 7472, 8684, 10572, 12800,
+ 2593, 4197, 6719, 9323, 11229, 12919,
+ 6081, 6774, 8132, 9244, 12202, 13918,
+ 2405, 3981, 6144, 8740, 11347, 13796,
+ 5793, 6444, 8286, 10049, 12152, 13520,
+ 2795, 4727, 6528, 8506, 11323, 13474,
+ 6181, 8598, 9346, 10614, 11725, 13545,
+ 4002, 5001, 6596, 7792, 9987, 13065,
+ 5748, 6365, 7759, 9028, 11818, 13487,
+ 3906, 4863, 6462, 7763, 10705, 14359,
+ 4315, 8428, 9322, 10582, 11942, 14500,
+ 2812, 4622, 7346, 10036, 11745, 13429,
+ 4221, 8338, 9277, 11280, 12869, 14317,
+ 4345, 5427, 7121, 8736, 12787, 14837,
+ 7678, 8614, 9456, 10461, 12024, 13852,
+ 2193, 3662, 5609, 7867, 12276, 14739,
+ 6083, 6864, 8879, 10080, 11623, 13720,
+ 4114, 5125, 7224, 9729, 11808, 13297,
+ 6383, 7232, 9252, 10720, 12622, 14030,
+ 2788, 5189, 8074, 9953, 11795, 14361,
+ 6079, 6987, 8662, 10589, 12444, 14390,
+ 4480, 5690, 7708, 9115, 11800, 14576,
+ 7848, 8763, 9802, 10924, 12515, 14832,
+ 3582, 4575, 6729, 9084, 11139, 12800,
+ 5885, 6534, 8853, 10432, 12664, 14960,
+ 3891, 4850, 7195, 8932, 12097, 14665,
+ 5797, 8545, 9385, 11556, 12997, 14392,
+ 1962, 3544, 7039, 9349, 11272, 13857,
+ 4106, 5493, 9652, 12038, 13603, 14932,
+ 4328, 5413, 7949, 10282, 12164, 13618,
+ 8135, 8918, 10057, 11085, 13190, 15015,
+ 2702, 4627, 6447, 8009, 10197, 13676,
+ 5998, 6656, 8315, 9496, 11597, 13122,
+ 3146, 6293, 8530, 10158, 11798, 13558,
+ 6374, 7289, 8698, 9776, 11885, 14236,
+ 3171, 5794, 7737, 9377, 11312, 13878,
+ 6279, 7150, 9192, 10414, 12052, 14174,
+ 4117, 5195, 7805, 9512, 12450, 14849,
+ 7963, 8955, 10071, 11129, 12324, 13605,
+ 4365, 5505, 7013, 8171, 10488, 13658,
+ 6124, 6894, 8286, 9349, 11859, 14737,
+ 3753, 4673, 6421, 8146, 12726, 14980,
+ 5457, 8706, 9598, 11035, 12294, 14268,
+ 2783, 4916, 7947, 10568, 12395, 14123,
+ 3909, 8145, 9524, 11951, 14052, 15282,
+ 3952, 5139, 8180, 11380, 13699, 15085,
+ 7200, 9031, 10025, 11484, 12924, 14848,
+ 2533, 4412, 6472, 8299, 11405, 14627,
+ 6563, 7530, 9064, 10267, 12560, 14422,
+ 4849, 6618, 8678, 10166, 11983, 13841,
+ 6393, 7569, 9960, 11300, 12644, 13906,
+ 3170, 5117, 7158, 9665, 11687, 14114,
+ 6122, 7071, 10013, 11733, 13170, 14466,
+ 4308, 5441, 7607, 9900, 11904, 14292,
+ 8129, 9024, 10087, 11081, 12670, 14356,
+ 4253, 5392, 8175, 9780, 11353, 12988,
+ 5453, 6638, 8596, 11453, 13885, 15263,
+ 4664, 5903, 7618, 9420, 12198, 13853,
+ 7149, 8859, 9746, 11029, 12219, 14188,
+ 2318, 4251, 7702, 9889, 11778, 14182,
+ 6679, 9280, 10573, 11950, 13100, 14491,
+ 4010, 5176, 8989, 10821, 12250, 13654,
+ 8076, 8886, 10411, 11722, 12992, 14267,
+ 2308, 4017, 6024, 7618, 9736, 13081,
+ 6001, 6751, 7987, 8966, 10964, 13589,
+ 2908, 5350, 7266, 8739, 10442, 12981,
+ 6143, 6839, 9027, 10366, 12881, 14416,
+ 2667, 4224, 6172, 8378, 10717, 12602,
+ 6275, 7120, 9249, 10613, 12580, 14823,
+ 2692, 4586, 6968, 9858, 12120, 14209,
+ 7771, 8769, 9743, 10745, 11943, 13225,
+ 4201, 5355, 7129, 8337, 9975, 11767,
+ 6216, 7100, 8444, 9442, 11298, 13690,
+ 4111, 5040, 6562, 8071, 12034, 13923,
+ 6657, 8599, 9337, 10665, 12040, 14704,
+ 3060, 5215, 7260, 10118, 12577, 14386,
+ 5103, 8913, 10157, 11519, 12669, 14220,
+ 4633, 5920, 7804, 9514, 12741, 14690,
+ 6720, 8585, 9448, 11556, 13510, 15095,
+ 2361, 3970, 6213, 9335, 13270, 15075,
+ 6506, 7440, 9041, 10179, 12024, 13587,
+ 4221, 5405, 8311, 9818, 11579, 14044,
+ 6216, 7224, 9515, 11389, 13545, 15068,
+ 2872, 5507, 8153, 10650, 13065, 14825,
+ 6002, 6676, 9393, 11023, 12965, 14755,
+ 4438, 5642, 8268, 10097, 12295, 14724,
+ 7797, 8622, 9642, 10932, 13287, 15118,
+ 4471, 5638, 7551, 9217, 11440, 12928,
+ 6051, 6890, 8906, 10655, 13437, 15116,
+ 3953, 4934, 7779, 9619, 12204, 14012,
+ 5439, 8649, 9791, 12232, 13899, 15193,
+ 2728, 4495, 6728, 9363, 11344, 14053,
+ 4069, 8460, 9835, 11742, 13366, 14825,
+ 4874, 6937, 9226, 10944, 12845, 14547,
+ 8195, 9093, 10392, 11594, 13355, 15010,
+ 2956, 5192, 7080, 8765, 11014, 14174,
+ 6384, 7287, 8812, 9816, 11336, 12808,
+ 2912, 6122, 9132, 10874, 12583, 14265,
+ 6148, 6925, 8821, 10030, 12212, 14758,
+ 2572, 4778, 7325, 9216, 11620, 14651,
+ 6654, 7718, 9546, 10806, 12633, 14354,
+ 4328, 5514, 8231, 10852, 12821, 14261,
+ 8051, 9205, 10385, 11490, 12674, 13988,
+ 4624, 6013, 7907, 9239, 11160, 13787,
+ 5786, 6531, 8210, 9968, 13410, 15249,
+ 3859, 4898, 7132, 9692, 13395, 15118,
+ 6712, 8944, 10028, 11521, 12690, 14118,
+ 2417, 4875, 9132, 11671, 13382, 14841,
+ 4113, 8355, 10734, 12517, 13905, 15115,
+ 4455, 5753, 7923, 10298, 13343, 15030,
+ 6998, 8878, 10113, 12233, 13768, 15107,
+ 2720, 4801, 6883, 9267, 12694, 14837,
+ 6507, 7496, 9312, 10696, 13185, 14850,
+ 4631, 6341, 9164, 10796, 12325, 13734,
+ 6602, 7817, 9932, 11349, 13132, 14672,
+ 3089, 5561, 7579, 9433, 12256, 14633,
+ 6246, 7715, 10371, 12065, 13563, 14878,
+ 4757, 6352, 8543, 10216, 12748, 14620,
+ 8183, 9366, 10628, 11857, 13185, 14599,
+ 4734, 6314, 8348, 9716, 11274, 12942,
+ 5824, 6871, 9829, 12268, 13874, 15138,
+ 4719, 6142, 8224, 9683, 11915, 14350,
+ 6288, 8774, 9655, 11204, 12696, 14867,
+ 2661, 4586, 7326, 10934, 13501, 15026,
+ 5932, 9323, 10877, 12454, 13715, 15004,
+ 4467, 6039, 8842, 11164, 13356, 14901,
+ 7880, 9158, 10593, 12209, 13609, 14989,
+};
+
+const Word16 swb_tbe_lsfvq_cbook_8b[256*LPC_SHB_ORDER] = /* Q15 */
+{
+ 1705, 3230, 4202, 5086, 6148, 7221, 8127, 10728, 13656, 15364,
+ 1668, 2958, 4063, 5644, 7356, 9440, 11046, 12261, 13228, 14503,
+ 1546, 2917, 4226, 5477, 6976, 8349, 9709, 11882, 13218, 14715,
+ 1158, 2729, 5177, 6967, 8297, 9611, 10655, 11668, 12757, 14415,
+ 1616, 3005, 4368, 5810, 7107, 8129, 9376, 10457, 12738, 14835,
+ 1232, 2451, 4145, 6446, 7741, 8993, 10377, 11898, 14213, 15314,
+ 1638, 3089, 5134, 6351, 7360, 8304, 9787, 12377, 13755, 15209,
+ 1264, 2543, 5564, 6686, 7958, 9481, 11021, 12517, 13875, 15147,
+ 1304, 2537, 3713, 4863, 6564, 7910, 9400, 11794, 13268, 14834,
+ 1652, 3245, 4686, 6405, 7931, 9223, 10591, 12020, 13193, 14759,
+ 1302, 2619, 4287, 5884, 7166, 8556, 10512, 12471, 13767, 15075,
+ 2034, 3467, 5577, 6530, 7674, 8783, 10920, 12798, 13727, 15002,
+ 2621, 3956, 5275, 6542, 7509, 8517, 9456, 10781, 12456, 14099,
+ 1496, 2653, 4147, 5637, 7370, 9233, 11817, 12986, 13968, 15046,
+ 2224, 3324, 4700, 5868, 7211, 8638, 11369, 12695, 13600, 14559,
+ 1267, 3050, 4707, 6321, 8663, 10140, 11174, 12453, 13425, 14844,
+ 1662, 2980, 4155, 5414, 6639, 7797, 9253, 11360, 12838, 14440,
+ 1521, 2856, 4944, 6367, 7506, 8857, 10971, 12183, 13275, 15006,
+ 1454, 2859, 4563, 5971, 7186, 8569, 10151, 11770, 13396, 14984,
+ 1143, 2942, 5267, 6840, 8377, 9457, 10589, 11615, 13892, 15271,
+ 1674, 3053, 4605, 5768, 7104, 8452, 10094, 11782, 12793, 13758,
+ 1702, 3261, 4723, 6245, 7899, 9494, 11010, 12387, 13680, 15066,
+ 1365, 2796, 5406, 6505, 7488, 8679, 10447, 12000, 13637, 15046,
+ 2090, 3931, 5788, 7157, 8254, 9717, 11007, 12081, 13238, 14880,
+ 1952, 3157, 4132, 5164, 6334, 7389, 9004, 11798, 14096, 15505,
+ 1641, 3212, 4919, 6364, 7863, 9311, 10766, 12234, 13694, 15054,
+ 1653, 3008, 4213, 5354, 6980, 8821, 11185, 12685, 13903, 15251,
+ 1856, 3444, 5146, 6579, 7801, 9250, 11062, 12947, 14145, 15291,
+ 1365, 3567, 5552, 6474, 7332, 8254, 9952, 11364, 13505, 14951,
+ 1488, 2896, 4521, 6279, 7880, 9446, 11418, 12921, 14431, 15465,
+ 1516, 3174, 5364, 6410, 7295, 8285, 10799, 12594, 14172, 15424,
+ 1738, 3416, 5237, 6878, 8440, 10539, 12105, 13063, 13924, 15150,
+ 1431, 2659, 3909, 5328, 6641, 7950, 9347, 11037, 13510, 14992,
+ 1400, 2646, 4233, 6366, 7749, 9220, 10560, 11594, 13046, 14992,
+ 1115, 2198, 3607, 5279, 8055, 9774, 11024, 12426, 13972, 15232,
+ 1360, 3418, 5724, 6973, 7912, 9078, 10810, 12437, 13630, 14826,
+ 1422, 3051, 5132, 6141, 7206, 8275, 9355, 10859, 13814, 15202,
+ 1080, 2227, 4117, 6404, 8080, 9318, 10934, 12404, 13688, 14827,
+ 1611, 3423, 4928, 6214, 7426, 8723, 10502, 11915, 13438, 15105,
+ 1947, 3524, 5198, 7008, 8358, 10006, 11397, 12444, 13583, 15135,
+ 1394, 2672, 4004, 5681, 6953, 8301, 9815, 12000, 13709, 15079,
+ 1788, 3193, 4579, 6221, 7874, 9170, 11186, 12647, 13521, 14538,
+ 1548, 2811, 4058, 5331, 6528, 7769, 10982, 12743, 13822, 15131,
+ 1751, 4007, 5154, 6463, 7935, 9470, 11103, 12406, 13337, 14520,
+ 2004, 3172, 5079, 6116, 7109, 8155, 10351, 12192, 13413, 14773,
+ 1644, 3185, 4750, 6290, 7816, 9271, 11041, 12831, 14139, 15341,
+ 2311, 3779, 5116, 6100, 7321, 9139, 10353, 12134, 13834, 15172,
+ 1723, 3339, 5049, 6754, 8353, 10290, 12048, 13157, 14206, 15460,
+ 2218, 3501, 4639, 5764, 6789, 7834, 9804, 11907, 13182, 14689,
+ 1640, 3173, 4679, 6202, 7660, 9120, 10773, 12395, 13894, 15200,
+ 1591, 3070, 4537, 6005, 7341, 8802, 10480, 12240, 13768, 15130,
+ 1169, 3611, 5983, 7054, 8601, 10022, 10948, 11927, 12834, 14747,
+ 1708, 3191, 4642, 6156, 7396, 8805, 10028, 11733, 13206, 14857,
+ 1519, 3082, 4752, 6484, 7730, 9328, 10796, 12003, 14524, 15513,
+ 2153, 3558, 5162, 6714, 7762, 8857, 10008, 12012, 13725, 15209,
+ 2680, 4053, 5310, 6996, 8309, 9343, 10361, 12333, 14224, 15498,
+ 2356, 3805, 5032, 5970, 6915, 7880, 8924, 12060, 13838, 15185,
+ 1807, 3439, 4962, 6483, 8013, 9556, 10952, 12327, 13686, 15059,
+ 1571, 2900, 4208, 6449, 7675, 8592, 11138, 12775, 14181, 15422,
+ 2006, 4262, 5508, 6414, 7621, 8725, 10788, 12605, 13609, 14776,
+ 1785, 3741, 5267, 6702, 8097, 9460, 10487, 11481, 12889, 14885,
+ 1647, 3223, 4795, 6391, 8007, 9620, 11575, 12955, 14100, 15381,
+ 1518, 3214, 5233, 6509, 7687, 8803, 11778, 13932, 14760, 15491,
+ 2136, 3647, 5373, 7317, 8671, 10261, 11786, 12933, 13820, 15186,
+ 1633, 3265, 4672, 5640, 6776, 7783, 8907, 10184, 12066, 14492,
+ 1690, 3028, 4184, 6049, 7489, 8678, 11045, 12244, 13372, 15016,
+ 1649, 3080, 4358, 5795, 7364, 8601, 10257, 12126, 13328, 15113,
+ 1850, 3286, 5392, 6765, 7826, 9185, 10506, 11776, 13248, 15163,
+ 2111, 3522, 4870, 6087, 7162, 8385, 9645, 10861, 12341, 14302,
+ 1529, 2909, 4136, 6783, 8064, 9325, 10942, 12094, 13886, 15169,
+ 1847, 3281, 4752, 6098, 7310, 8744, 10129, 12278, 13554, 14930,
+ 1149, 2767, 5869, 7479, 8514, 9723, 11235, 12300, 13871, 15068,
+ 1689, 3066, 4325, 5613, 6772, 7936, 9051, 12135, 13730, 15025,
+ 2127, 3394, 5263, 6880, 7874, 9155, 10305, 12136, 13494, 14437,
+ 1682, 3054, 4412, 6053, 7380, 8465, 9817, 12460, 14155, 15285,
+ 1799, 3430, 5123, 6594, 7934, 9609, 11472, 12791, 13686, 14849,
+ 1899, 3656, 5369, 6355, 7516, 8800, 9888, 11646, 13024, 13965,
+ 1410, 3252, 5101, 6050, 7480, 9912, 11739, 12806, 14085, 15186,
+ 1487, 3934, 5351, 6390, 7519, 8890, 11488, 12818, 13787, 14941,
+ 1562, 3156, 5075, 7044, 8872, 10271, 11479, 12632, 13907, 14993,
+ 1548, 2926, 4338, 5796, 7011, 8143, 9336, 11323, 13461, 14904,
+ 1421, 2907, 4736, 6272, 7730, 8977, 10453, 12374, 13840, 15234,
+ 1495, 2996, 4496, 6036, 7545, 9034, 10534, 12014, 13486, 14958,
+ 1388, 3203, 5691, 7076, 8578, 9661, 10874, 12326, 14433, 15423,
+ 1248, 2983, 5304, 6423, 7544, 8611, 10290, 11682, 12904, 14549,
+ 1496, 2988, 4632, 6342, 7852, 9329, 11175, 12546, 13758, 15182,
+ 1373, 3379, 5067, 6179, 7379, 8775, 10005, 11464, 14147, 15386,
+ 2537, 3849, 5533, 7263, 8318, 9657, 11346, 12355, 13955, 15314,
+ 2113, 3405, 4419, 5268, 6436, 8005, 10292, 12442, 13655, 15176,
+ 1620, 3681, 5454, 6406, 7459, 9354, 10872, 12035, 14163, 15279,
+ 1903, 3232, 4517, 5758, 7156, 8851, 10670, 12413, 14518, 15565,
+ 1714, 3779, 5166, 6557, 8107, 9168, 10560, 12854, 14208, 15329,
+ 1926, 3645, 5521, 7072, 7999, 8974, 9806, 11088, 13527, 15298,
+ 1820, 2840, 4726, 7091, 8261, 9758, 11218, 12148, 14064, 15262,
+ 2072, 3303, 5391, 6710, 7504, 8497, 10457, 12394, 14480, 15541,
+ 1627, 3294, 5209, 7432, 8846, 10147, 11517, 12890, 14488, 15411,
+ 2172, 3405, 4580, 5623, 6732, 7648, 8485, 9913, 13396, 15213,
+ 1581, 3058, 4633, 6225, 7724, 9238, 10779, 12240, 13650, 15094,
+ 1675, 2927, 4090, 5753, 7461, 8922, 10277, 11670, 13987, 15336,
+ 1868, 3611, 5256, 6927, 8093, 9434, 10998, 12144, 13380, 15165,
+ 1498, 3635, 5273, 6823, 7825, 8916, 9811, 10903, 12514, 14884,
+ 1448, 2626, 3930, 6895, 8348, 9746, 11404, 12565, 14288, 15325,
+ 1945, 3408, 4987, 6340, 7627, 8954, 10251, 12381, 13481, 14983,
+ 1956, 3759, 5388, 6894, 8466, 9962, 11460, 12759, 14145, 15321,
+ 1670, 3271, 4588, 5970, 7185, 8366, 9640, 12011, 13488, 14833,
+ 1964, 3444, 4826, 6213, 7936, 9097, 10785, 12617, 13612, 15229,
+ 1646, 3390, 4669, 6049, 7001, 7940, 10461, 12478, 14675, 15704,
+ 2202, 3782, 5107, 6754, 8280, 9628, 11687, 13028, 13871, 15207,
+ 2354, 3830, 5174, 6360, 7555, 8997, 10681, 11977, 13066, 14781,
+ 2351, 3525, 4892, 6386, 7616, 9133, 11859, 13061, 13946, 15004,
+ 2252, 3772, 5155, 6485, 7799, 9145, 10769, 12561, 13763, 15241,
+ 1714, 3107, 4725, 6097, 9158, 10459, 11619, 12699, 14346, 15256,
+ 1830, 3506, 4969, 5973, 6900, 7836, 8994, 11088, 13366, 14860,
+ 1856, 3406, 4898, 6367, 7810, 9186, 10422, 12172, 13969, 15331,
+ 2006, 3382, 4743, 6100, 7430, 8753, 10805, 12234, 13673, 15195,
+ 1491, 3607, 5343, 7464, 9179, 10087, 11024, 12099, 13199, 14956,
+ 1749, 3371, 5121, 6500, 7646, 8770, 9968, 11673, 13339, 14931,
+ 1857, 3506, 5083, 6595, 8200, 9739, 11138, 12528, 13884, 15137,
+ 1780, 3860, 5581, 6692, 7837, 8989, 10304, 12318, 13611, 15109,
+ 2164, 4463, 5655, 7632, 9047, 9922, 10784, 12950, 14723, 15589,
+ 2305, 3300, 4366, 5608, 6857, 7795, 10006, 11950, 14376, 15700,
+ 1628, 3408, 5074, 6761, 8312, 9687, 11104, 12332, 13619, 15076,
+ 1842, 3314, 4771, 6460, 7463, 8661, 11191, 12739, 14592, 15633,
+ 1808, 4360, 5904, 6869, 8134, 9174, 10780, 12589, 13995, 15150,
+ 2966, 4354, 5686, 6983, 7938, 9092, 10062, 11747, 13307, 14611,
+ 1932, 3293, 4910, 6818, 7690, 9074, 11715, 13019, 14429, 15478,
+ 1978, 3772, 5429, 6580, 7448, 8496, 11755, 13132, 14549, 15560,
+ 1881, 3635, 5627, 7292, 8573, 10911, 12325, 13200, 14068, 15243,
+ 1436, 2716, 4002, 5347, 6553, 7646, 8955, 10690, 12967, 14784,
+ 1426, 2825, 4206, 5726, 8100, 9391, 10712, 12262, 13506, 14954,
+ 1448, 2767, 4089, 5265, 7185, 8684, 10378, 12257, 13431, 14803,
+ 1669, 3312, 4990, 6887, 8050, 9595, 10943, 12015, 13145, 14920,
+ 1534, 2814, 4191, 5933, 7393, 8687, 9865, 11185, 12958, 14743,
+ 1397, 2706, 4322, 6052, 7618, 9168, 10995, 12433, 13931, 15267,
+ 1717, 3164, 4630, 6329, 7519, 8846, 10088, 12116, 14012, 15197,
+ 1606, 3316, 5165, 6942, 8278, 9625, 11461, 12806, 14095, 15299,
+ 2014, 3357, 4281, 5076, 6191, 7372, 9501, 12414, 13419, 14901,
+ 1322, 3655, 5269, 6494, 7613, 9253, 10752, 11974, 13302, 14833,
+ 1687, 3291, 4718, 5817, 7001, 8136, 10741, 12692, 13884, 15224,
+ 2255, 3723, 5555, 7021, 8101, 9345, 10765, 12705, 13693, 15223,
+ 2376, 3715, 5249, 6505, 7410, 8345, 10176, 11618, 12708, 14488,
+ 1842, 3232, 4371, 5954, 7832, 9126, 11296, 12743, 13862, 15331,
+ 2046, 3597, 5325, 6453, 7353, 8588, 10588, 12082, 13664, 15152,
+ 1970, 3564, 4925, 6547, 8672, 9980, 11383, 12786, 13969, 15234,
+ 1497, 2938, 4909, 6099, 7102, 8072, 9514, 11294, 12761, 14578,
+ 1666, 3164, 5098, 6255, 7350, 8902, 10694, 12503, 13808, 14980,
+ 1467, 2774, 4556, 6308, 7435, 8644, 10040, 12356, 13597, 14776,
+ 1915, 3618, 5160, 6707, 8479, 9521, 10481, 11536, 14163, 15479,
+ 1857, 3466, 4760, 6205, 7312, 8801, 10376, 11978, 13161, 14235,
+ 1615, 3107, 4710, 6452, 8069, 9877, 11348, 12575, 13751, 15049,
+ 1563, 3092, 4977, 6851, 8056, 9025, 10327, 12181, 14039, 15192,
+ 2294, 3843, 5781, 7222, 8505, 9851, 11210, 12802, 13676, 15158,
+ 1931, 3436, 4681, 5837, 6908, 7825, 9440, 12600, 14162, 15305,
+ 1572, 3189, 4879, 6680, 7970, 9293, 10974, 12193, 13506, 15218,
+ 1759, 3172, 4687, 5950, 7484, 8874, 10563, 12821, 14112, 15299,
+ 1461, 4009, 5495, 6608, 7867, 9497, 11307, 12520, 14357, 15467,
+ 1922, 4314, 5736, 6599, 7481, 8598, 9852, 11345, 14012, 15280,
+ 1249, 2609, 4690, 7006, 8061, 9011, 11477, 13214, 14382, 15337,
+ 2251, 3776, 5514, 6458, 7300, 8078, 10961, 12696, 14279, 15567,
+ 1697, 3374, 5134, 6984, 8675, 10700, 12194, 13233, 14184, 15464,
+ 1985, 3326, 4440, 5685, 6870, 8207, 9545, 11223, 13672, 15143,
+ 1453, 2824, 4722, 6476, 7730, 8963, 10217, 11743, 13545, 15152,
+ 1217, 2442, 3821, 5409, 7315, 8949, 10797, 12564, 14281, 15410,
+ 1546, 3204, 5604, 6730, 8040, 9677, 11029, 12107, 13803, 15267,
+ 2042, 3424, 4830, 6328, 7473, 8525, 9386, 10755, 13398, 14998,
+ 1106, 2508, 4816, 7337, 8399, 9630, 11278, 12453, 14067, 15024,
+ 1764, 3305, 4955, 6537, 7767, 9117, 10404, 11961, 13576, 15021,
+ 1604, 3797, 5700, 7128, 8515, 9896, 11389, 12534, 13696, 15136,
+ 1623, 3004, 4355, 6217, 7351, 8437, 9819, 11537, 13974, 15340,
+ 2457, 3890, 4962, 5848, 7311, 9718, 11213, 12292, 13705, 15111,
+ 1601, 3330, 4648, 6043, 7138, 8179, 11247, 13078, 14768, 15641,
+ 2457, 3677, 5174, 6432, 7982, 10024, 11164, 12170, 13704, 15112,
+ 1552, 3777, 5267, 6325, 7532, 8642, 9894, 12404, 13569, 14620,
+ 1961, 3463, 4720, 6498, 8059, 9304, 11486, 12824, 14102, 15458,
+ 2443, 3699, 5252, 6348, 7638, 8733, 10224, 12666, 13768, 15009,
+ 2204, 3657, 5086, 6792, 8300, 10152, 12313, 13306, 14079, 15287,
+ 2360, 3731, 5002, 6094, 6952, 8009, 9152, 11586, 13038, 14158,
+ 1888, 3469, 4880, 6183, 7603, 9244, 10801, 12319, 13657, 15002,
+ 1670, 3283, 4591, 6080, 7801, 8951, 10534, 12572, 13620, 14969,
+ 1304, 4140, 5864, 7008, 8377, 9651, 10825, 11805, 13637, 15300,
+ 2077, 3547, 4890, 6216, 7303, 8608, 9810, 11796, 13525, 14984,
+ 1658, 3252, 4916, 6498, 8069, 9529, 11029, 12538, 13903, 15184,
+ 2206, 3648, 4949, 6636, 7875, 8833, 9853, 12624, 14448, 15475,
+ 3039, 4664, 5792, 7321, 8798, 9724, 10485, 12329, 14465, 15650,
+ 1885, 3201, 5227, 6590, 7343, 8049, 9372, 12313, 14594, 15645,
+ 1826, 3446, 5138, 6665, 8008, 9352, 10668, 12583, 13810, 15065,
+ 1455, 3065, 5233, 6306, 7404, 8776, 11422, 12775, 14032, 15239,
+ 2395, 4674, 5883, 6877, 7900, 9322, 10931, 12537, 13765, 14888,
+ 1840, 4359, 5629, 6875, 7968, 9185, 10266, 11861, 13202, 14464,
+ 1662, 3278, 4865, 6555, 8122, 10011, 11874, 13087, 14128, 15418,
+ 1643, 3366, 5837, 7033, 7854, 8928, 11487, 12972, 14409, 15467,
+ 1878, 3685, 5789, 7325, 8714, 10906, 12273, 13110, 13834, 14837,
+ 2259, 3652, 4995, 6055, 7005, 7900, 8843, 10024, 12609, 14736,
+ 1568, 2949, 4504, 6035, 7428, 9194, 10893, 12444, 13595, 14939,
+ 1678, 3143, 4416, 5872, 7501, 8768, 10418, 12127, 13144, 14622,
+ 1878, 3549, 5481, 7178, 8322, 9347, 10532, 12117, 13554, 15167,
+ 2055, 3346, 4814, 6193, 7418, 8757, 10144, 11365, 12698, 14779,
+ 1486, 2779, 3954, 6134, 8290, 9646, 10767, 12112, 14441, 15428,
+ 1787, 3511, 4962, 6055, 7295, 8858, 10179, 12437, 13813, 15217,
+ 1374, 3184, 5771, 7998, 9354, 10209, 11249, 12469, 14015, 15248,
+ 1627, 2947, 4046, 5182, 6798, 8225, 9770, 12661, 14250, 15408,
+ 2117, 3704, 5007, 6630, 8002, 9222, 10550, 12108, 13472, 15034,
+ 1365, 2885, 4896, 6144, 7426, 9137, 10283, 12727, 14709, 15505,
+ 2073, 3691, 5305, 6800, 8134, 9508, 11139, 12857, 13896, 15239,
+ 1564, 4084, 5497, 6495, 7391, 8539, 10468, 11705, 12804, 14704,
+ 1844, 3180, 4380, 5754, 8181, 9923, 11738, 12995, 14138, 15232,
+ 2157, 3736, 5059, 5932, 7192, 8916, 11216, 12783, 13945, 15189,
+ 1782, 2860, 4362, 7179, 9083, 10438, 11580, 12929, 14789, 15500,
+ 1651, 3273, 4587, 5886, 7069, 8346, 9787, 11277, 13152, 14811,
+ 1549, 3138, 5049, 6704, 7803, 9102, 10748, 12577, 13813, 15215,
+ 1674, 3187, 4709, 6204, 7622, 9024, 10541, 12135, 13576, 15063,
+ 1888, 3562, 5468, 7111, 8694, 9948, 11111, 12286, 14070, 15300,
+ 1905, 3158, 5368, 6372, 7554, 8719, 10568, 12430, 13449, 14427,
+ 1953, 3411, 4718, 6545, 8090, 9298, 11232, 12723, 13668, 15077,
+ 1459, 3444, 5688, 6814, 7843, 8977, 10119, 12107, 14316, 15368,
+ 2450, 4363, 5827, 7349, 8683, 10032, 11143, 12131, 13519, 15058,
+ 2482, 3664, 4763, 5944, 7191, 8390, 10105, 12234, 13702, 15188,
+ 1838, 3465, 5255, 6751, 8016, 9254, 10946, 12321, 13790, 15337,
+ 2497, 3548, 4702, 5987, 7645, 8883, 10740, 12247, 14393, 15540,
+ 1717, 3679, 5335, 6587, 8564, 9808, 10735, 12675, 14672, 15558,
+ 2454, 3997, 5364, 6810, 8026, 8913, 9715, 11315, 14258, 15605,
+ 1906, 3443, 4901, 6363, 8186, 9716, 11074, 13186, 14701, 15474,
+ 1992, 3246, 5488, 6514, 7455, 8324, 10807, 13238, 14763, 15579,
+ 1721, 3438, 5244, 7173, 9106, 10873, 12178, 13181, 14060, 15415,
+ 2191, 3555, 4802, 6108, 7015, 7850, 8947, 11115, 14483, 15593,
+ 1925, 3232, 4601, 6574, 7791, 8989, 11038, 12282, 13630, 15136,
+ 1816, 3167, 4292, 5730, 7588, 9096, 10743, 12341, 13760, 15252,
+ 2069, 3850, 5424, 6815, 8274, 9569, 10910, 12283, 13835, 15185,
+ 2419, 3773, 5288, 6591, 7672, 8909, 9832, 10975, 13163, 14998,
+ 1215, 2710, 4939, 6437, 8745, 9918, 11200, 12553, 14234, 15384,
+ 1867, 3527, 5134, 6496, 7656, 8923, 10602, 12568, 13896, 15276,
+ 2259, 4214, 5751, 7270, 8590, 10120, 11611, 12822, 14130, 15258,
+ 1911, 3261, 4446, 5685, 6897, 8494, 10128, 11970, 13707, 15106,
+ 1762, 3549, 4874, 6153, 8146, 9634, 10690, 11886, 13713, 15057,
+ 2371, 3716, 4778, 6111, 7097, 8063, 10544, 12615, 14716, 15724,
+ 2254, 3759, 5627, 6870, 7896, 9379, 11627, 12889, 13795, 15272,
+ 2516, 4000, 5378, 6444, 7496, 8634, 9767, 12110, 13503, 14640,
+ 2385, 3201, 4283, 6677, 8216, 9689, 11654, 12319, 14142, 15367,
+ 2775, 4055, 5455, 6553, 7821, 8901, 10890, 12775, 13696, 14884,
+ 1568, 3940, 5341, 6824, 9355, 10305, 11405, 12879, 14291, 15334,
+ 2436, 3807, 5183, 6189, 7099, 8116, 9655, 11275, 13641, 15137,
+ 1755, 3340, 4871, 6382, 7790, 9316, 10921, 12432, 13903, 15217,
+ 1932, 3246, 4603, 6454, 7590, 8678, 10609, 12641, 13938, 15245,
+ 1417, 4366, 6289, 7362, 8846, 10151, 11160, 12134, 13593, 15216,
+ 1820, 3378, 4782, 6421, 7788, 9056, 10070, 11271, 13614, 15297,
+ 1855, 3399, 4933, 6526, 8097, 9655, 11043, 12475, 14301, 15370,
+ 1901, 3653, 6053, 7290, 8154, 8986, 10262, 12993, 14405, 15387,
+ 1958, 4295, 5824, 8196, 9580, 10318, 11267, 12551, 13716, 15374,
+ 2082, 4060, 5500, 6423, 7298, 8128, 9713, 12497, 14442, 15562,
+ 1878, 3425, 4781, 7062, 8455, 9625, 10810, 12311, 13948, 15201,
+ 2035, 3727, 4804, 6256, 7248, 9235, 11563, 13120, 14882, 15662,
+ 2143, 3982, 6527, 7709, 8742, 9804, 11240, 12658, 14397, 15409,
+ 2593, 4431, 5861, 7222, 8381, 9351, 10400, 11837, 13286, 15326,
+ 1840, 3798, 5465, 6800, 7919, 9752, 12004, 13265, 14424, 15420,
+ 2157, 4145, 5394, 6454, 7240, 8776, 11093, 12831, 14856, 15708,
+ 1467, 3782, 5811, 8123, 9314, 10456, 11641, 13211, 14562, 15331,
+};
+
+
+const Word16 wac_swb_h[LPC_SHB_ORDER] =
+{
+ 32758,
+ 32731,
+ 32686,
+ 32622,
+ 32541,
+ 32442,
+ 32325,
+ 32191,
+ 32039,
+ 31870
+};
+
+const Word16 wac_swb_l[LPC_SHB_ORDER] =
+{
+ 29673,
+ 20874,
+ 7850,
+ 25873,
+ 12831,
+ 5927,
+ 10541,
+ 239,
+ 15037,
+ 30328
+};
+
+
+
+
+const Word16 lsf_q_diff_cb_8b_rf[256*16] = /* Q6 */
+{
+ -3145, 863, -1389, 4087, 1110, 3193, 290, -3160, 824, 212, -2936, -5827, -10181, -15650, -13373, -3849,
+ -4602, -3228, -8398, -1649, -5788, -8971, -2025, -2971, -1476, -2748, -2458, 966, -4, -1802, -1360, 654,
+ -8629, -7702, 6280, 3296, -1205, 365, -5964, 3125, 2443, 1442, 1149, -3835, -9867, -4238, -1977, -1955,
+ -2629, -759, -2056, -2297, -1839, 1678, -2412, -7539, -13208, -9624, -1688, -2171, 943, -454, 536, 2644,
+ -2840, -1391, -10500, 2516, 907, 146, -2762, -6750, 2949, -2282, -4614, -5663, -7773, -5510, -5947, -3727,
+ -4006, -939, -2500, -771, -3414, -4521, -6417, -4064, 3698, 3969, 4300, 4177, -3195, -10419, -13072, -6695,
+ -4284, -1172, -4415, -1601, -6029, 66, -4338, -2300, -3402, -5614, -7181, -7288, 7154, 6538, 64, -3263,
+ -6470, -4503, -9698, -5885, 235, 5049, 2698, -3656, -3600, -6261, -4270, 766, 1037, -1511, -1274, 1800,
+ 669, 2937, -3464, -1034, -4098, -11296, -382, -4610, -9613, -2081, 3947, 2832, 2962, -332, -9039, -10702,
+ -11109, -5950, -7200, -6525, -4260, -5060, -8936, -91, -672, 4557, 3192, -147, -2247, 1566, -734, -3007,
+ -2411, 1587, -2575, 2172, -3270, 10648, 7093, 1517, 1512, -392, 49, -9117, -16895, -908, -8443, -9923,
+ -1934, -603, -6588, 5335, -1565, -11521, 5944, -5092, -615, -2221, -7703, -1903, -5195, 2323, 3958, 3050,
+ -7094, 5361, -7885, -3299, -3282, -3125, -1888, -406, 1522, -23, -1506, -6075, -8517, -7605, -3450, -3362,
+ -3573, -2421, 1385, -181, -11027, 4778, -4014, -4956, 7316, 3138, 2351, 3406, -1998, -968, -2375, -3262,
+ -141, 6652, 11944, -4131, -2073, -2592, -1562, 1521, -1804, -2585, -2685, -5798, -10850, -11629, -4300, -4287,
+ -1569, 2229, 2330, 3147, -1026, -7010, 265, -1320, -3648, 1942, -5375, 73, 10348, 3913, -5535, -5938,
+ -5642, -3433, -8423, 1178, -540, -4790, -1976, 4686, 1701, -1323, -2009, -5997, -5693, -3852, -7604, -5361,
+ -1784, -325, -8561, -17592, 1663, 1377, 2347, -245, -2426, 141, -137, 985, -4926, -7898, -3559, 895,
+ -2548, -1563, -5007, 7311, 4409, 3177, 3920, 1546, -725, -5252, -9754, -9267, -5701, -6900, -961, 1772,
+ -1676, 889, -4798, 8060, 3460, -1911, 415, -4044, -6146, -12074, -10588, 13056, 2765, 1396, -4737, -4905,
+ 943, 3342, -8515, 4676, -774, -3963, -5503, -1625, 3909, -3614, 12347, 2835, -9710, 5877, 297, -918,
+ -5317, -2799, -3708, -4084, -8175, -6155, 1752, 6801, 7493, 6271, 4083, 3132, -809, -4200, -5389, -5982,
+ -5060, -5285, -1533, -2751, 2259, -3893, -3473, -108, -4711, -2627, -2069, -2320, -172, 1547, 770, 309,
+ -4485, -2618, -7238, 1767, -2965, 6693, 5256, 18, -1789, -5076, 7167, 3204, -1242, 1628, 4519, 1796,
+ -114, 1225, -3083, 321, -4002, 4834, -3014, -741, -4189, -5946, 6871, -2068, -13016, -9772, -3235, 2044,
+ 559, 10477, -9704, -7733, -8989, -10787, -10342, -8585, -2844, 1474, 5638, 9798, 10986, 9105, 4619, 2186,
+ 1576, 9039, 4354, 2073, 1861, -1492, -715, 1840, -6736, -10798, 994, -2921, -6369, 779, 2668, -443,
+ -2067, -1020, 1, 14571, 2253, -2163, 5255, 973, -1722, 4173, 102, -3633, -1430, -1720, 1243, 1749,
+ -6589, -1601, -9469, -5581, 3018, 1186, -11, 1252, 5708, 3338, 187, -3950, -6035, -3294, -106, -1130,
+ -2490, 445, -2543, -3283, -3432, -6963, 9950, 4072, 2294, 4517, 2736, 8173, 4270, -8347, -9374, 4776,
+ -66, 3476, 537, 2659, -677, 1552, 1974, -1703, -2139, -634, -1988, 694, 1921, -12938, -16525, 5848,
+ -9849, 7389, 4653, -1158, 1340, -2250, -2460, -2201, -3122, -90, 3974, 5105, 9127, 8701, 6184, 3770,
+ -5086, -3159, -3197, -9944, -7474, 961, 1158, -3536, 1050, 5572, -1480, -11120, -9276, -1841, -2086, -24,
+ -1019, -346, -6765, -8343, -6302, -3019, -5606, 2728, -3994, -6909, 10146, 6321, -230, -393, -846, -1536,
+ -1598, 3610, 3330, -233, -1215, -1953, -1330, 19, -4839, -10681, -11699, -1104, 1146, -6143, -6849, 422,
+ 892, 7937, -5005, -5547, 1756, -4020, -3420, -6811, -6304, -7812, -6019, 5109, 5503, 5568, 4600, 6472,
+ -3296, -2230, -6010, 3497, 5502, -2291, -2342, -6544, -12576, 2192, -1004, -5205, -500, -6764, -6200, 1816,
+ 5114, 4922, 6498, 6613, 4909, 2318, -5626, -11915, 3072, 11570, 1766, 4361, 552, -8139, -14006, -17228,
+ -3321, -1514, -473, 3295, -1028, -4536, -12374, 12452, 7396, -2269, -5052, 554, 1053, -4370, -5859, 97,
+ -2532, 2546, -4920, -13800, 8116, 2425, 1695, -2088, -5105, -346, -2869, -2457, 9336, 13166, 6150, 5166,
+ -2329, 72, 11513, -3075, -7745, -5492, -8015, -5108, -16, 3261, 876, -357, -3241, -2956, -4265, -2320,
+ -7869, -6495, -16668, -1339, -3678, 975, -2740, -2776, 3755, 141, -190, 1026, 5972, 3232, -924, -3212,
+ -1077, 568, -5606, 1478, -243, 2479, 10198, 3667, 682, -2873, -9164, -9042, 2186, 4347, -750, 5303,
+ 556, 5098, -6825, -2564, -3946, -5752, 1977, -6171, -5627, 4580, -835, -6362, 10132, 9511, 6475, 2861,
+ 3320, 11074, -483, 2698, -20, -4084, -4213, -3931, -231, -17, -1826, -2737, -5920, -1539, -1897, -3347,
+ -1346, 2075, -1230, -5248, 10906, 9461, 5046, 3485, -267, -948, 4273, 1889, 81, -488, -4763, -5532,
+ -1237, 6446, 3974, 5166, -723, -10033, 8338, 4102, 683, 1474, 624, -5287, -8628, -7519, -6290, 1767,
+ 207, 2676, 870, 13754, 7087, 2357, -922, -1734, -4651, 352, 14028, 10050, 8916, 2725, -5722, -9415,
+ 364, 3660, -813, 4370, -2151, -2115, 5570, -2545, -8167, -1978, -8301, -10715, 959, -5127, -11250, -7721,
+ -1668, -1437, -5508, -11155, -15130, 6829, 6070, -1555, -3048, -314, -528, 1714, 1474, -42, -541, 3361,
+ -15356, -12047, -4659, -1598, 4105, 3069, 2375, 3647, 1217, 140, -2518, -4195, -3080, 2155, 66, -570,
+ 84, 1523, -742, 13326, 5544, -2653, -5484, -3816, -9239, -10794, 6967, 2095, -4231, -2102, 4368, 8737,
+ 2959, 3968, -2430, 4601, 317, 5804, -3547, -11099, 5849, 273, -5513, 767, -9421, -11095, 3029, 8472,
+ -518, 2355, 2733, 53, -1439, -2709, -394, 5355, -2408, -3122, 8729, 5660, 7771, 4999, -7588, -15134,
+ -2240, 2281, 6677, -5155, 5663, 266, -4355, -7052, -3825, -2235, -2745, -3212, -2018, 1828, 1971, 2086,
+ -1241, 699, -2126, 3835, 1147, 4456, -3810, -23, 1284, -4878, 3807, 14029, 2820, -6773, 9556, 6600,
+ -1716, 315, -3259, -3282, -2859, -2219, 3508, -3452, -7850, 623, -5558, -2168, 1842, -8228, -885, 15388,
+ -8177, -7705, -14377, -6808, -7099, -7676, -4141, -5548, 3677, 5846, 6160, 10031, 11318, 8141, 3326, 904,
+ -3072, 1139, 1875, 4811, 3767, 7294, 4507, 1476, -1622, -6385, 384, 3318, -3867, -10447, -6387, -4252,
+ -19, 1102, -6317, 3433, -1856, -5732, 7225, -2107, -6977, 9620, 7964, 3013, 7152, 4986, -2184, 2136,
+ -524, 1479, -923, 3729, -259, 227, 6477, 2660, 4208, 1017, -423, -6090, -13677, 5309, 702, 2721,
+ -822, 2175, 1717, 3580, 1133, 3835, 980, 13265, 6367, 2741, 7462, 6211, -2347, -7635, 4781, 4132,
+ -8168, 13481, 5777, -963, 643, -2853, -2086, -1593, -2092, 2348, 3867, 413, 461, 1644, -259, -1656,
+ -846, 1615, -2805, 935, 3206, 1907, 7862, 3901, -975, 4507, 3151, 1433, 15449, 4412, -1221, 1001,
+ -3952, 1411, -2148, -1025, -2553, -4164, -4725, -3465, -2654, -3828, -6151, -7679, -5881, -2007, -581, -2499,
+ -1744, 4546, -8725, -6274, -1364, -1087, -2198, -4504, -3542, -1966, -516, -802, 448, -162, -1277, -2081,
+ -12133, -10923, 10206, 4436, 611, -2300, -4926, -4708, -5138, -3373, 2358, 295, -370, 4406, 2947, 351,
+ 1477, 3584, 3776, 4714, -1508, 2029, 426, -5245, -2805, -5852, -8752, 199, -3945, 10358, 10127, 4852,
+ -1894, 528, -776, 2698, -1298, -7579, -12457, -12545, 2483, 2421, -140, 723, -395, -292, -4196, -1766,
+ -3071, 1449, -3716, 3712, -3017, 543, -391, -1984, 3301, 375, 1107, -2635, 4730, 870, -19666, -12653,
+ -2823, 3165, 5399, -10321, -6087, -2824, -329, -1699, -268, -1995, -2254, 2744, 319, 51, 2834, 452,
+ -2837, -240, -1298, 2244, 1977, 3061, 3676, -1207, -3774, -2607, -3405, 9701, 12102, -3052, -10263, 1164,
+ -1548, -515, -3862, 1117, 3329, 4105, -804, -4141, -9321, -3136, 1792, 3484, 2025, -6747, -11991, -10905,
+ -3361, -2922, -3472, 1165, -3055, -1620, -4751, -8940, -477, 1932, 1054, 4687, 5735, 5566, 2447, -778,
+ 1791, 3768, 602, -2421, -6876, 9505, 7350, 2428, -3175, -6252, -707, -3720, -7723, -42, 4292, -1141,
+ -2469, 269, -1028, 1057, -890, 383, -128, 821, -2854, -5548, -2437, -3349, 3935, 1474, 14267, 13393,
+ -3416, 14072, 1196, -3166, -4252, -711, 521, 2462, 5346, 1483, -4287, -7676, -5805, -321, 867, 475,
+ -1674, 1391, 539, -471, -5201, -25, 6911, -2142, 10454, 10963, 1353, -2831, -3219, -131, -3005, -4468,
+ 3476, 4986, 6318, -2959, -9204, -87, 3906, -833, -247, 5687, 451, 716, -2970, -5788, -6743, -9436,
+ 4831, 6767, 3852, 2164, -1362, -1404, -3260, -4807, 2809, -2699, -4693, 21984, 10803, 4063, 2353, 6177,
+ -2813, -890, -5363, -165, -5755, -20361, 3639, 4639, -2073, 1798, -1097, -6169, 30, -1827, -4590, -2586,
+ -5855, -6418, -10115, -6038, 2674, 3620, 1206, 1379, -520, 5333, 5334, 3618, 439, -1048, 439, 777,
+ -7871, 2657, -3649, 7671, 10875, 5285, 423, 1869, -2283, -6081, -2750, -3935, -1815, 2851, 754, -2545,
+ -2253, -245, 87, 3432, 4323, 803, -3981, -8416, -12174, 6263, 9281, 7472, 2558, 327, -3198, -1436,
+ -1398, -211, -6595, 4670, 63, 2041, -4372, 967, 2444, -9123, -11355, 1727, -4221, -3144, 6411, 4338,
+ -4409, -3256, -6504, 6064, 4055, -2268, 5638, 5466, 82, -516, 6974, 5206, 1235, -364, -4919, -6016,
+ 2, 7, -5, 5, 1, 2, -8, 4, 4, 2, 4, 5, 0, -1, -3, 1,
+ -1139, 1101, -1501, -3122, 2059, 9130, 5593, -2976, -5845, -8198, 10800, 771, -4815, 20594, 5385, 9434,
+ -497, 877, -5365, -1190, -2940, -6216, 4700, 872, -2276, 9901, 5530, 417, -4381, -9743, -1935, -1025,
+ -3555, -643, -5254, -6674, -6586, -4879, -3791, -2733, 1046, 2275, 3157, 3643, 8384, 10607, 11929, 9237,
+ 1573, 3323, 130, 12128, 9521, 6522, 4035, -1444, -7190, 565, 2160, -2808, -3716, -9398, -1115, 4631,
+ -1938, -2034, -5142, 6407, 5972, 302, -3078, -7362, -12229, 6591, 5640, 1240, 2727, 3243, 9738, 7334,
+ -8793, 935, -4176, 103, 2398, 1724, 1579, 7649, 5685, 2791, 1754, -453, -5030, -4870, -3871, -3139,
+ -243, 3111, -2068, 3022, -4587, -11340, 14571, 7771, 3558, 5750, 1203, 4665, -1981, -109, 4442, 1369,
+ -2041, 3713, 1013, 1345, 4716, 129, 3062, 1444, -3639, -6184, 7457, 7819, 958, -8391, -8799, 9312,
+ 235, 3895, 12172, 2716, -1347, -1094, -4869, -880, 7519, 9011, 9914, 5683, 5909, 7805, 4428, 2129,
+ -1538, -36, -678, 1486, -649, 1517, -5121, 8530, 5048, -1844, -4781, -9145, -11353, -8076, -4133, -307,
+ -2707, 80, -5905, -4315, -4389, -6758, -6105, -9003, -10744, -1701, 3765, 6091, 10523, 7504, 4350, 4312,
+ 786, 3663, 9280, 6578, 391, 1514, -7019, 5089, 3483, -6871, -8172, -180, -7469, 1419, -121, 838,
+ 2692, 6995, 1431, -1074, 1394, -268, -1170, -3367, -7586, -5698, 7587, 7378, 5733, 8353, 10152, 10834,
+ -8158, -6271, -9914, 9985, 5364, -2601, -1959, -6260, -4097, 3235, 2097, -196, 2968, 3371, 2095, -1207,
+ -2269, 648, -1910, 7766, 5356, 3667, 981, 2825, 4288, 6668, 696, -661, 4042, -5356, -12858, -3646,
+ -4703, -3239, 10100, -2312, -256, -2120, -2612, 4835, -1675, 1068, 5746, -140, -869, 3620, 3505, 1703,
+ -3250, -2423, -1423, -674, -4843, 10905, 4109, 635, -1606, -6241, -2449, 3295, 6275, 14389, 8002, 4352,
+ -842, 3170, 1430, 1513, -4583, -12820, 1470, -4220, -8952, 6987, 4718, 532, -2136, -3700, -1727, 4512,
+ -3663, -2257, -8998, 5471, 843, -2858, -4142, 5134, 7250, 525, 3002, 118, 423, 6929, 5389, -1003,
+ -3457, -2564, 4399, 5758, -1462, 9992, 2582, 885, 6350, -670, -4446, -5882, -1814, -1178, -3073, 1157,
+ 2529, 7505, 5440, 202, -5746, -976, 8235, 1049, -181, -142, -6919, -6675, 18283, 16554, 8385, 3001,
+ 2266, 12753, -3253, -3832, -7200, -5627, -4778, -925, 239, 539, 2225, 324, 3182, 1914, -309, -507,
+ 5074, 4381, 9167, 1915, -3908, 1754, -5997, 2537, 17796, 13293, 7314, 12286, 1815, -4329, -8064, -20774,
+ -2484, 4942, 14515, 5406, -2595, -1380, 8417, 5956, 1651, 1559, -1389, 24, -6421, -4047, 2557, -1331,
+ -3164, 848, 15096, 9663, 6043, 3180, 595, 2733, 830, 1861, 9051, 8435, 8904, 6571, 2208, -762,
+ -135, 870, -2484, -3227, -9497, -586, 14177, 5880, -3708, 505, -1483, -415, 2507, -1973, -13853, -8468,
+ -3854, -2420, -9258, -4766, -3435, -2360, 10467, 7572, 598, -4099, 3457, 402, -195, 4193, 2023, 1851,
+ -4359, -3760, -1315, -585, 11411, 2958, 5446, 1608, 228, 4691, 1446, -1971, -3898, -3822, -1651, -1697,
+ 5112, 1738, -12375, 11069, 8416, -139, -721, 740, -8678, -7527, 10378, 4791, 5388, 2724, 4652, 1931,
+ -1419, 520, -6325, 10393, 8379, 2544, -2104, -11110, 7461, 2884, -1766, 548, -217, -2709, -1287, -2598,
+ 1996, 4969, 3862, 5813, -629, -7138, 7107, 9009, 5157, 1564, 5244, 1326, 78, 263, -4389, -5858,
+ -5423, -34, 1648, 2316, -3981, -5525, -1762, -996, 2075, 878, 718, 1458, 613, 3914, 3912, 2074,
+ -1176, 643, -3222, -444, 779, 9634, 14238, 11755, 3727, 1970, -1421, 3653, 1795, -2315, 10947, 8623,
+ 19, 6095, 3277, 2648, 2148, 509, 3577, 978, 1862, 5842, 1302, -3853, -10993, -12406, 858, 7763,
+ -4944, -1993, -5563, 833, -1365, -2240, -25, 2546, 10150, 10369, 10670, 10551, 9322, 5582, 881, -1029,
+ -763, 4474, 9314, 8818, 2703, 4844, 7776, 1684, 1, -3980, -9739, 5565, 2667, 1185, 2203, 1611,
+ -635, 724, -4112, 8414, 3049, 1437, 2314, -2611, -5835, 5541, -3027, 1017, 14246, 10165, 9910, 14393,
+ 2201, 3204, -295, 2519, -855, 5303, -2184, -12725, 10839, 1337, 154, -5290, -7908, 9490, 4292, 5533,
+ 544, 3574, 602, -783, -3121, 21721, 8166, -1137, 4729, -2399, 2504, 3721, -2704, -10309, 4957, 8028,
+ 2782, 11109, 5440, 2691, -3942, 3286, 2848, -532, -186, -2661, 7318, 6015, -1200, 2174, 5498, -379,
+ 4440, 6050, 3576, -819, -3697, 13144, 9664, -2178, 2966, 3302, -623, 10572, 15713, 9000, 2137, -5160,
+ -1593, 613, 3985, -7128, -5989, 2429, 721, -5488, -11848, 981, -3054, -4499, -4102, -7743, -7416, -340,
+ -2759, -2449, -4426, -6796, -13804, -7472, -1409, -1103, 181, 3071, 434, -741, 1045, 1976, 1407, 1365,
+ -2578, -1275, 5323, 9313, 4798, -1130, -6220, -2101, -3402, -868, -1959, -4365, -4536, -1626, -3701, -5011,
+ -3479, -3407, -9706, 4812, -812, -4014, 2558, -5416, -10543, -5186, -3840, 1189, 3804, 5839, 4744, 1003,
+ -3585, -2339, -4745, 3869, -2763, 1306, -6059, -8604, -1377, -5116, -730, -1693, -3321, 888, -685, 876,
+ -3492, 910, -7012, -2555, -5147, -1372, -1910, -8518, 2661, 7652, 6967, 7296, 4514, -4741, -9827, 873,
+ -1258, 4649, 3654, 653, -5264, -5509, -4222, 1703, 3992, -5102, -4342, -6447, 6603, 2642, -923, 6242,
+ -992, 647, 1228, -3124, -3463, 15067, 838, -6186, -3433, 872, 97, 2876, 3686, -2643, -6780, 356,
+ -1727, 2555, 2552, -1938, -8798, -773, -757, -3588, -7005, -6121, 4601, 235, -4446, 2984, 1353, -776,
+ -15055, -12154, -6273, 84, 390, -3286, -4758, -3713, -2185, -1512, 1403, 3479, 7578, 6327, 5045, 3075,
+ 2469, 8960, 6679, 3813, 1059, 9183, 2971, 4300, -1040, -927, -2376, -6240, -5131, -6030, -7385, -7560,
+ 933, 4512, -899, -1226, -7230, -10649, 11249, 4655, -7924, -5423, -5107, 993, 588, 2896, 4305, 1369,
+ -1938, 11282, -2696, -7285, 1163, -6289, -344, -2329, 3632, 2191, -1017, -1404, -2305, -6223, -2822, -1369,
+ -3688, -918, -3118, 256, -5446, 8638, 6195, 2855, 7432, 6937, 8638, 4020, -3296, -4260, 21, -3914,
+ 3006, 5845, 16377, 17059, 3579, 103, 204, -563, 1735, 6204, -405, -2618, -7929, -14028, -9415, -5277,
+ 303, 934, -305, 3211, -2970, 2963, 10231, 2833, 1656, 1162, -4439, 6346, 9314, 7062, -5015, -15980,
+ -320, 499, -14803, 4610, 2112, -4049, 7242, -245, -3115, 1323, -1276, -4286, -1951, 100, -1389, -1612,
+ -4391, -2691, -5202, -11000, 373, -2423, 4221, 4146, 1045, 503, -4063, -2244, 2311, 1646, -1779, -3188,
+ -3374, 346, -3243, -3662, 5971, 5519, 3022, 516, -4538, -6550, -5227, -6165, -4919, -1105, 30, 721,
+ 2935, 3922, -1041, 4217, 2528, 1985, 661, -824, -10133, -13715, 8714, 2218, 3769, 3384, 1193, -6246,
+ -5357, -2959, -8106, 5394, 1542, -4964, -7749, -4183, 877, 1146, 8307, 2891, -4905, -5775, 1888, 1442,
+ -2472, -850, 1278, 1397, -4545, -3625, -11722, 9811, 7790, 7832, 12234, 6079, -2436, -890, -1820, -234,
+ -3905, -1081, -7818, 2577, -299, 5742, 4982, -1421, 3506, -604, -4944, 2130, 544, 1545, -2399, -3202,
+ -895, -203, 783, -203, -2734, 10200, 7718, 3943, -6098, 9859, 9374, 6777, 2263, -2089, 866, 3381,
+ -3828, 1991, -2866, -1612, 747, -3896, 6041, 2875, -5838, -6829, -2319, -1146, -8845, -10612, 3630, 2942,
+ -509, 5457, 1119, -3222, -3623, -6421, -9746, -8661, 5658, 8283, 8062, 6310, 1787, 454, 1766, 2750,
+ -1632, 7787, 5349, 243, -1526, 3143, 5218, 10290, 1446, -6324, -3035, -1055, 2974, -7871, 39, 3664,
+ -769, -9, -8896, 9699, 4546, -1295, 6107, -4534, 3367, 1450, -3607, 8816, 3219, -5601, 1298, 12366,
+ -7130, -4420, -6848, 3453, 3599, 4371, 609, -6059, 8057, 9067, 2408, -3523, -6908, -6822, -6636, -2017,
+ -477, 5145, -1462, -475, -2003, -3769, 7781, 4563, 4437, 2134, -2726, 15777, 2839, -1929, 2913, 2174,
+ 841, 2396, 754, 14163, 4130, -1807, -177, -3884, -6782, 9287, 1864, -599, 5913, -2587, -10749, 5856,
+ 1304, 7980, -2237, -2092, -4384, -828, 552, -6108, 2193, 10107, 6057, 9885, 13003, 8977, 4006, -926,
+ -1523, 1282, -1805, -2709, -6024, -7618, -10251, 832, -689, -1488, 1528, -1635, -4512, -3974, 3366, 5884,
+ -2891, -646, -4227, -16787, 4586, 2689, -48, 1956, -5398, -5693, 4030, 1138, 2292, 2634, 6453, 3271,
+ -3526, 9059, 2896, 8101, 3313, -270, -1336, -3002, 826, -1572, -3793, -2235, -1597, 272, 910, -778,
+ -1195, 3634, 1576, 2036, -3675, -10512, -6414, -3268, -9714, -6636, 3287, -947, 6643, 7755, 4317, 2928,
+ -592, -46, -6118, -3775, 11750, 5301, -2878, -7240, -4674, 1543, -626, -1300, -608, -1661, -4053, -3154,
+ -2514, -545, 771, 7292, 3641, 749, -1664, -1652, 2686, 8715, 10176, 4547, -6065, -7417, -6454, -4928,
+ -576, 940, 681, 2977, -2947, -1968, -6468, 10093, 7720, -2235, -3869, -8057, -4152, 7399, 8617, 5658,
+ -1043, 1637, -3699, -5968, 13092, 1526, 1185, -3128, -2234, 3343, 5773, 9935, 7870, 6240, 3284, 3932,
+ 377, 5872, 3528, 3824, -852, -1575, -3799, -8401, -5628, -3612, -2451, 1396, 1471, -1669, -579, -384,
+ -6978, -4522, -6731, -1881, 1485, -73, -38, -3990, 11379, 4104, 1154, 5492, 3709, -645, -641, -750,
+ -97, 2556, 1619, 3351, 1996, 10845, 8411, 2751, 3099, -165, -6582, -11822, 8128, 7722, 4495, 3322,
+ 950, 2744, -2039, -3959, -6098, -2113, 4512, -1699, -758, 3243, -4760, 7788, 11837, 5336, 7626, 5509,
+ -4876, 13906, -3059, 1351, 4037, 2283, 614, -5014, 2149, 613, 744, -4239, -5981, -4296, -1799, -3121,
+ -2111, 3530, -1221, 1654, 9442, 10361, 6422, 7826, 7510, 7790, 3836, -323, -761, 1652, 330, -386,
+ -3239, 3070, 7009, -1209, 6710, 213, 5225, 3105, 1173, 842, -1774, -5027, -3901, -1359, -2786, -3513,
+ 1481, 1904, 7402, 23443, 5946, -3615, -1528, -4317, -2629, 11277, 7171, 5620, 7938, 4715, 3575, -3794,
+ 2315, 5200, 63, 4010, -400, -2074, 6624, -516, -731, -2133, -10088, 6969, -3380, -7450, -7347, -6915,
+ -3407, -3447, -1422, -4020, -11809, 3562, 3865, 570, 7656, 6367, 5964, 802, -2306, 5862, 7700, 6476,
+ -17049, -2577, 3748, -1004, 990, 2569, 4487, 2137, -3540, -3508, 608, -2102, 90, 4634, 3115, 1273,
+ -1960, -1414, 1516, 9460, 6833, 2088, -3598, -3590, -2554, -1783, 2680, 2127, 939, 8562, 4170, 1914,
+ 3335, 6241, -2988, 1816, 3233, -951, 587, -5590, -3415, -926, -7987, 8897, 3700, -12712, 5722, 4683,
+ -756, 1823, 2804, 3392, -2019, 801, -2923, 43, 5720, 2302, 3604, 14791, 4960, -425, -7298, -6606,
+ 205, 5909, 8599, 4641, -4600, -1580, -4536, -5178, 2346, 6910, 3641, -2630, -6079, 351, 5478, 5524,
+ 151, 1252, -2569, 6834, 5377, 4284, 450, -1607, 7257, 4429, -2568, 9851, 9183, 2197, 20053, 9155,
+ -1462, 924, -3196, -3257, -8953, 6147, 6251, -3186, 3285, 3198, 2326, 1225, -8446, -11295, 5393, 10785,
+ -2381, -2014, -9329, 4719, -880, -2308, -4714, 4429, 3675, -1874, 3253, 9686, 12557, 9338, 4719, 3836,
+ -3103, 7031, 11258, 6883, 11690, 8131, 3644, -307, -2590, -274, 1004, -1314, -166, 3063, 695, -1815,
+ -2455, 811, -1161, 2731, 5931, 2352, 3361, -363, -7371, 2805, 4053, 3586, 7364, 242, -1692, 17531,
+ -4497, -535, 286, 214, 3804, 11412, 4562, -1157, 550, 4841, 1657, -4984, -6307, 1482, 5745, 3540,
+ -2763, -1313, -1385, 3735, -2423, 5601, 14635, 10815, 9726, 6141, 4010, 3556, -104, -3353, -7143, 7077,
+ -245, 8209, 15457, 5234, 1860, -2195, -4620, -4895, -4263, -759, 2016, 2664, 3153, 2966, 1601, 30,
+ -4764, -1351, 3227, 2660, 1556, 198, 5379, 11277, 8580, 6978, 2506, 3310, 13165, 9623, 7120, 1665,
+ -59, 558, 3194, 1299, -2918, -2455, 3754, -3394, -3634, -2782, -7987, -7903, -7058, -2214, -1060, 2183,
+ -1954, -186, -11418, -2859, -1110, -2027, -932, -2040, 1282, 174, -161, -2628, -3341, 2675, 4169, 2475,
+ -5934, -5196, 10580, 9382, 1417, -1362, -2572, -4391, 7418, 4314, 148, 31, -82, 461, -2595, -570,
+ -3639, -2081, -1014, 4355, 5943, 6217, 2491, -4106, -6520, -4050, -5030, -2053, 6821, 6135, 2456, 1015,
+ -3447, -1303, -5380, -6759, -3272, -129, -4989, -11231, 5106, 1264, -3433, -3327, -3139, -1282, 1031, 1558,
+ 4180, 1592, -3435, 2252, -4803, -6443, 8937, 1696, -5599, 9240, 5481, -328, 3197, -4392, -12452, -16482,
+ -4613, 5693, 11596, -9035, 1399, 1388, 5182, 4750, 958, 310, -866, 829, 5122, 1203, -115, -759,
+ -3551, -1843, -3272, -1753, -195, 17324, 8182, -502, -2987, -146, -2640, 6865, 6979, -3675, -6047, 12865,
+ 3739, 8307, 5634, -2783, 96, 1167, -274, -636, -5808, -8880, 835, 6363, 5092, -700, -8229, -7634,
+ -6799, -5871, 4391, 1265, -1493, 440, -7322, 2387, 1763, -1406, 4030, 8075, 8810, 5655, 1375, 2309,
+ 3191, 6527, 2671, -128, -5345, 14221, 13006, 1792, -548, -2974, -7549, -3471, 1835, -1490, -3556, -4240,
+ -3368, -1748, -3945, 8349, 2444, -5349, 5825, 4222, -1891, -3570, -10832, 8764, 2791, 5495, 9332, 5366,
+ 1020, 5766, -8313, 522, -568, -20, -2169, 3981, 6641, 4235, 1781, -4362, -7143, -3864, -2205, -3217,
+ -3300, -1346, -1200, 5950, -1315, -285, 2642, -180, 12986, 11560, 5996, 6755, -2578, -1417, 1848, 5560,
+ 10662, 13080, 11225, 419, -4335, -128, 6716, 1638, -4903, 154, -2404, -4228, 5262, -364, -5170, -12310,
+ 360, 1588, 2173, 8939, 4304, 7241, 367, -2361, 6569, 837, -4801, 8650, 7208, 5996, 3566, 1112,
+ -5017, 4300, 2649, 3064, -6110, -14292, 2204, 13008, 5245, 1594, -6536, -11045, 5146, -211, -4067, -11435,
+ -530, 1840, 187, -12175, 1984, -1576, 3659, 4293, -1971, 8025, 8287, 4420, 3935, 358, -1691, -2707,
+ -3429, 252, 1235, 3895, 13024, 5900, 317, 1720, 3724, 1510, -3576, -6091, -8218, -3620, -844, -406,
+ 2105, 7096, 3064, 3952, 2071, -2774, 8459, 1501, -10913, 1387, -405, 12863, 2328, 4475, 3498, -1584,
+ -3085, -920, -7032, 8494, 2146, 1346, 1867, -404, 1886, -1042, -378, -2121, -10433, -7336, 15525, 9808,
+ -15685, -7623, 1925, 2963, 4001, -105, 3843, 5498, 4039, 6151, 6044, 3867, 1730, 2971, 1484, -319,
+ 3080, 9412, -1223, -3973, 4734, 2248, 3127, 1119, -1738, -1669, -1477, -1472, 1412, 1213, 773, 1674,
+ -730, 2282, 495, 1849, 753, 4313, 2052, 11060, 2638, -4153, 12967, 4232, 1600, 8305, 6247, 4101,
+ 1078, -516, -6160, -2738, -3949, 549, 2665, 313, -11805, 5780, 13753, 4964, -3343, -3825, 7392, 657,
+ -3356, -672, 2091, 1930, -1942, -6931, -7983, -7306, 1452, 3417, 9758, 12537, 14305, 11570, 5653, 1593,
+ 2820, 8229, 5573, 6212, 5169, 4568, 4877, 1219, -5520, -3569, -4997, 3799, -1152, -6233, 13054, 8210,
+ -1905, -1112, -1728, 19102, 8663, -331, 3226, 1066, -1807, 8189, 5678, 1987, 4661, 3278, 7947, 11458,
+ -4574, -517, -5124, 4711, -740, 416, 4847, 4427, 11056, 3251, -1915, -3528, -2529, -2213, 1857, 1203,
+ 316, 3731, 4619, -1294, -3138, -336, 8691, 7311, 3124, 9892, 5880, 614, 1873, 1916, 3856, 3588,
+ 1323, 8284, 7332, 4197, 626, 4877, 9117, 4163, 1998, 4387, 5489, 4184, 2124, -5170, -10914, 3921,
+ -1504, 12727, 938, 3478, 1876, -1017, 389, 3233, 8278, 8027, 8392, 12663, 13264, 9858, 5767, 4287,
+ -4008, 49, -1854, -5454, -9369, 5309, -1597, 6002, 6031, -2543, -4793, -2340, -2559, 229, -983, -2068,
+ -3514, 815, -7510, -3824, -931, -1573, -1337, -1189, -2019, 245, 4084, 4416, 6165, 7239, 3899, 2461,
+ -4781, -2173, 17577, 2751, -894, 2264, 1789, -623, 992, -322, -3113, -1854, -1553, 2213, 731, 850,
+ 2054, 3456, 3747, 3842, 980, -940, -5065, -5905, 423, -2009, 74, 3933, 13511, 12742, 8908, 5783,
+ 894, 6872, -2742, 7127, 5497, -660, -2361, -3114, -5552, -884, -1825, -8536, 4278, 4047, 3263, 2117,
+ 46, 3829, 3392, 7000, 5004, 11640, 7090, 2661, 2072, 3834, 6408, 9453, 4328, -5807, -11811, -6081,
+ 1119, 3292, 8329, 5549, -1361, -4414, -15806, 7144, 6824, -4515, -1143, 4774, 1451, 5261, 4830, 5562,
+ -1393, 5662, 4446, 1807, 8826, 6248, 6415, 4547, -1665, 1181, 6405, 5864, 8293, 10387, 7545, 4688,
+ 1312, 7883, 6317, -3965, -8535, -2725, 1117, -5447, -7012, 3655, 3196, 4576, 6822, -341, -646, 6098,
+ -6332, -4527, -5839, 4942, 2805, 6652, 925, -1187, 3859, 4466, 5194, 4814, 7489, 8532, 2922, 2874,
+ -1137, 1068, 2253, 3741, -2505, 9887, 10247, 3472, 9158, 1176, -2976, 1937, -2064, 7351, 6057, 2696,
+ 532, 4702, 4601, 502, -1350, -5364, 9112, 2103, -4340, 18, -1329, -2532, 2939, 15707, 4071, -2154,
+ -628, 13794, -2239, -2982, -3391, -2332, -1483, 5699, 7418, 5487, 5469, 3426, 2471, 2248, -610, -2978,
+ 4520, 7035, 8360, 8190, 4367, 11231, 9045, 6518, 5468, 6414, -626, -2179, -2327, -6601, -11740, -18010,
+ 872, 6597, 9823, 6115, 5121, 3028, -3065, 9266, 9664, 2144, 2461, -758, -3373, -348, -421, -2786,
+ -2998, -2310, 5826, 14327, 10399, 10344, 5906, 4646, 4013, 7488, 6656, 3601, 212, 2499, 812, -4251,
+ -3455, -259, -2801, -3743, -3930, 4402, 11531, 8368, 3812, 2663, -1885, -3062, -3413, -12432, -6348, -1832,
+ -2574, 1227, -6578, -7396, -131, 1139, 3464, 2303, 6848, 4302, 422, 1994, 4840, 6023, 4369, 1222,
+ -5186, -3043, -5221, 9413, 9009, 6329, 6302, 7712, 4428, -1745, -1711, 1216, 1855, 1215, 1003, 58,
+ 3844, 4380, -2452, 17587, 5229, 106, 3809, 5238, 2909, -6280, 6367, 4649, 3777, 2815, 4377, 9833,
+ -3469, 6722, -2982, 1867, 2944, 3428, -115, -6063, 4740, 2369, 3681, 2580, 319, 76, 4169, 1079,
+ 5357, 7937, 8749, 6732, 3237, 475, 10599, 7708, 2300, 9384, 6872, 6516, 11437, 2109, -2788, -10922,
+ -2925, 1420, 3109, 500, 6953, 1289, -522, 1064, 2885, 6445, 3595, 2000, 2669, 2797, 2174, 873,
+ 1980, 6159, 1331, 1321, -1922, 6722, 11666, 3321, -1515, 1233, -1664, 9262, 9668, 2502, 13862, 9666,
+ 3582, 10575, 2715, -603, 596, -1567, 4182, 49, 2208, 1795, 10525, 9472, -2866, -8439, 7591, 11197,
+ -2356, 153, -10244, -4768, -2178, -2408, 1367, 708, 4615, 9681, 13007, 14875, 15382, 12708, 8355, 5074,
+ -358, 1803, 1987, 7888, 9168, 16089, 2288, -2716, -1669, 1078, 1165, 5324, 4412, -4354, 298, 6519,
+ 4826, 9355, 6507, 12087, 4177, -6, 2865, -2898, -5149, 6100, -1829, 80, 12459, 4967, 591, 7846,
+ -3452, 13887, -142, 4052, 5842, 3702, 4535, 2718, 4976, 3690, 1377, -72, -1938, -836, 961, -1944,
+ 4315, 5391, 6496, 1795, -2279, 20485, 16142, 9768, 8889, 6390, 1789, 3149, 4186, 487, -922, -2249,
+ -1225, 14246, 10277, 980, 2427, 180, 5713, 4730, -901, 590, 3351, 1871, 4389, 4760, 8650, 3433,
+ 1760, 3580, 5798, 6813, 4246, 17695, 7227, 4364, 2222, 13912, 11731, 10965, 14919, 7273, -6023, 6474,
+};
+
+
+const Word16 win_lpc_shb_fx[(L_LOOK_12k8 + L_SUBFR + L_FRAME) * 5/8] =
+{
+ /*Q15 */
+ 1, 4, 10, 18, 28, 40, 54, 71, 89, 110, 134, 159, 186, 216, 248,
+ 282, 318, 357, 397, 440, 485, 532, 581, 632, 686, 741, 799, 859, 921,
+ 984, 1050, 1119, 1189, 1261, 1335, 1411, 1490, 1570, 1652, 1736, 1823,
+ 1911, 2001, 2093, 2187, 2283, 2381, 2481, 2582, 2686, 2791, 2898, 3007,
+ 3118, 3230, 3345, 3461, 3579, 3698, 3819, 3942, 4067, 4193, 4321, 4451,
+ 4582, 4715, 4849, 4985, 5123, 5261, 5402, 5544, 5687, 5832, 5978, 6126,
+ 6275, 6426, 6577, 6730, 6885, 7041, 7197, 7356, 7515, 7676, 7837, 8000,
+ 8164, 8329, 8496, 8663, 8831, 9001, 9171, 9342, 9515, 9688, 9862, 10037,
+ 10213, 10390, 10567, 10745, 10924, 11104, 11285, 11466, 11648, 11830, 12013,
+ 12197, 12381, 12566, 12751, 12937, 13123, 13310, 13497, 13684, 13872, 14060,
+ 14249, 14438, 14627, 14816, 15006, 15195, 15385, 15575, 15765, 15955, 16146,
+ 16336, 16526, 16716, 16907, 17097, 17287, 17477, 17667, 17856, 18046, 18235,
+ 18424, 18612, 18801, 18989, 19176, 19364, 19551, 19737, 19923, 20109, 20294,
+ 20478, 20662, 20846, 21028, 21210, 21392, 21573, 21753, 21932, 22111, 22289,
+ 22466, 22642, 22818, 22992, 23166, 23339, 23510, 23681, 23851, 24020, 24188,
+ 24355, 24520, 24685, 24848, 25011, 25172, 25332, 25491, 25648, 25804, 25960,
+ 26113, 26266, 26417, 26567, 26715, 26862, 27007, 27152, 27294, 27435, 27575,
+ 27713, 27850, 27985, 28119, 28251, 28381, 28510, 28637, 28762, 28886, 29008,
+ 29129, 29248, 29364, 29480, 29593, 29705, 29815, 29923, 30029, 30133, 30236,
+ 30337, 30435, 30532, 30627, 30720, 30811, 30901, 30988, 31073, 31156, 31238,
+ 31317, 31394, 31469, 31543, 31614, 31683, 31750, 31815, 31878, 31938, 31997,
+ 32054, 32108, 32161, 32211, 32259, 32305, 32349, 32390, 32430, 32467, 32502,
+ 32535, 32566, 32595, 32621, 32645, 32667, 32687, 32705, 32720, 32734, 32745,
+ 32753, 32760, 32765, 32767
+};
+
+#define SHC(x) ((Word16)x)
+
+const Word16 cos_coef_new[4]= { SHC(0x02BA), SHC(0xE60A), SHC(0xEEEF), SHC(0xAAAB)};
+
+/*Sachin: New table. cos_diff_table[i] = sub(cos_table[i+1],cos_table[i]) */
+const Word16 cos_diff_table[512] =
+{
+ SHC(0xFFFF), SHC(0xFFF8), SHC(0xFFF4), SHC(0xFFEF), SHC(0xFFE9), SHC(0xFFE5), SHC(0xFFE0), SHC(0xFFDB),
+ SHC(0xFFD6), SHC(0xFFD2), SHC(0xFFCC), SHC(0xFFC7), SHC(0xFFC3), SHC(0xFFBE), SHC(0xFFB8), SHC(0xFFB4),
+ SHC(0xFFB0), SHC(0xFFAA), SHC(0xFFA5), SHC(0xFFA1), SHC(0xFF9C), SHC(0xFF97), SHC(0xFF92), SHC(0xFF8E),
+ SHC(0xFF89), SHC(0xFF84), SHC(0xFF80), SHC(0xFF7B), SHC(0xFF76), SHC(0xFF71), SHC(0xFF6D), SHC(0xFF69),
+ SHC(0xFF64), SHC(0xFF5F), SHC(0xFF5B), SHC(0xFF56), SHC(0xFF52), SHC(0xFF4D), SHC(0xFF49), SHC(0xFF45),
+ SHC(0xFF40), SHC(0xFF3C), SHC(0xFF38), SHC(0xFF33), SHC(0xFF2F), SHC(0xFF2B), SHC(0xFF27), SHC(0xFF23),
+ SHC(0xFF1E), SHC(0xFF1B), SHC(0xFF16), SHC(0xFF13), SHC(0xFF0E), SHC(0xFF0B), SHC(0xFF06), SHC(0xFF03),
+ SHC(0xFEFF), SHC(0xFEFB), SHC(0xFEF8), SHC(0xFEF3), SHC(0xFEF1), SHC(0xFEEC), SHC(0xFEE9), SHC(0xFEE5),
+ SHC(0xFEE2), SHC(0xFEDF), SHC(0xFEDB), SHC(0xFED8), SHC(0xFED4), SHC(0xFED1), SHC(0xFECE), SHC(0xFECB),
+ SHC(0xFEC7), SHC(0xFEC5), SHC(0xFEC1), SHC(0xFEBF), SHC(0xFEBB), SHC(0xFEB9), SHC(0xFEB6), SHC(0xFEB3),
+ SHC(0xFEB0), SHC(0xFEAE), SHC(0xFEAB), SHC(0xFEA8), SHC(0xFEA6), SHC(0xFEA3), SHC(0xFEA1), SHC(0xFE9F),
+ SHC(0xFE9C), SHC(0xFE9A), SHC(0xFE98), SHC(0xFE95), SHC(0xFE94), SHC(0xFE91), SHC(0xFE8F), SHC(0xFE8E),
+ SHC(0xFE8B), SHC(0xFE8A), SHC(0xFE88), SHC(0xFE86), SHC(0xFE85), SHC(0xFE83), SHC(0xFE81), SHC(0xFE80),
+ SHC(0xFE7F), SHC(0xFE7D), SHC(0xFE7B), SHC(0xFE7B), SHC(0xFE79), SHC(0xFE79), SHC(0xFE77), SHC(0xFE76),
+ SHC(0xFE75), SHC(0xFE74), SHC(0xFE73), SHC(0xFE73), SHC(0xFE72), SHC(0xFE71), SHC(0xFE71), SHC(0xFE70),
+ SHC(0xFE6F), SHC(0xFE70), SHC(0xFE6E), SHC(0xFE6F), SHC(0xFE6E), SHC(0xFE6E), SHC(0xFE6E), SHC(0xFE6E),
+ SHC(0xFE6E), SHC(0xFE6E), SHC(0xFE6E), SHC(0xFE6E), SHC(0xFE6F), SHC(0xFE6E), SHC(0xFE70), SHC(0xFE6F),
+ SHC(0xFE70), SHC(0xFE71), SHC(0xFE71), SHC(0xFE72), SHC(0xFE73), SHC(0xFE73), SHC(0xFE74), SHC(0xFE75),
+ SHC(0xFE76), SHC(0xFE77), SHC(0xFE79), SHC(0xFE79), SHC(0xFE7B), SHC(0xFE7B), SHC(0xFE7D), SHC(0xFE7F),
+ SHC(0xFE80), SHC(0xFE81), SHC(0xFE83), SHC(0xFE85), SHC(0xFE86), SHC(0xFE88), SHC(0xFE8A), SHC(0xFE8B),
+ SHC(0xFE8E), SHC(0xFE8F), SHC(0xFE91), SHC(0xFE94), SHC(0xFE95), SHC(0xFE98), SHC(0xFE9A), SHC(0xFE9C),
+ SHC(0xFE9F), SHC(0xFEA1), SHC(0xFEA3), SHC(0xFEA6), SHC(0xFEA8), SHC(0xFEAB), SHC(0xFEAE), SHC(0xFEB0),
+ SHC(0xFEB3), SHC(0xFEB6), SHC(0xFEB9), SHC(0xFEBB), SHC(0xFEBF), SHC(0xFEC1), SHC(0xFEC5), SHC(0xFEC7),
+ SHC(0xFECB), SHC(0xFECE), SHC(0xFED1), SHC(0xFED4), SHC(0xFED8), SHC(0xFEDB), SHC(0xFEDF), SHC(0xFEE2),
+ SHC(0xFEE5), SHC(0xFEE9), SHC(0xFEEC), SHC(0xFEF1), SHC(0xFEF3), SHC(0xFEF8), SHC(0xFEFB), SHC(0xFEFF),
+ SHC(0xFF03), SHC(0xFF06), SHC(0xFF0B), SHC(0xFF0E), SHC(0xFF13), SHC(0xFF16), SHC(0xFF1B), SHC(0xFF1E),
+ SHC(0xFF23), SHC(0xFF27), SHC(0xFF2B), SHC(0xFF2F), SHC(0xFF33), SHC(0xFF38), SHC(0xFF3C), SHC(0xFF40),
+ SHC(0xFF45), SHC(0xFF49), SHC(0xFF4D), SHC(0xFF52), SHC(0xFF56), SHC(0xFF5B), SHC(0xFF5F), SHC(0xFF64),
+ SHC(0xFF69), SHC(0xFF6D), SHC(0xFF71), SHC(0xFF76), SHC(0xFF7B), SHC(0xFF80), SHC(0xFF84), SHC(0xFF89),
+ SHC(0xFF8E), SHC(0xFF92), SHC(0xFF97), SHC(0xFF9C), SHC(0xFFA1), SHC(0xFFA5), SHC(0xFFAA), SHC(0xFFB0),
+ SHC(0xFFB4), SHC(0xFFB8), SHC(0xFFBE), SHC(0xFFC3), SHC(0xFFC7), SHC(0xFFCC), SHC(0xFFD2), SHC(0xFFD6),
+ SHC(0xFFDB), SHC(0xFFE0), SHC(0xFFE5), SHC(0xFFE9), SHC(0xFFEF), SHC(0xFFF4), SHC(0xFFF8), SHC(0xFFFF),
+ SHC(0x0001), SHC(0x0008), SHC(0x000C), SHC(0x0011), SHC(0x0017), SHC(0x001B), SHC(0x0020), SHC(0x0025),
+ SHC(0x002A), SHC(0x002E), SHC(0x0034), SHC(0x0039), SHC(0x003D), SHC(0x0042), SHC(0x0048), SHC(0x004C),
+ SHC(0x0050), SHC(0x0056), SHC(0x005B), SHC(0x005F), SHC(0x0064), SHC(0x0069), SHC(0x006E), SHC(0x0072),
+ SHC(0x0077), SHC(0x007C), SHC(0x0080), SHC(0x0085), SHC(0x008A), SHC(0x008F), SHC(0x0093), SHC(0x0097),
+ SHC(0x009C), SHC(0x00A1), SHC(0x00A5), SHC(0x00AA), SHC(0x00AE), SHC(0x00B3), SHC(0x00B7), SHC(0x00BB),
+ SHC(0x00C0), SHC(0x00C4), SHC(0x00C8), SHC(0x00CD), SHC(0x00D1), SHC(0x00D5), SHC(0x00D9), SHC(0x00DD),
+ SHC(0x00E2), SHC(0x00E5), SHC(0x00EA), SHC(0x00ED), SHC(0x00F2), SHC(0x00F5), SHC(0x00FA), SHC(0x00FD),
+ SHC(0x0101), SHC(0x0105), SHC(0x0108), SHC(0x010D), SHC(0x010F), SHC(0x0114), SHC(0x0117), SHC(0x011B),
+ SHC(0x011E), SHC(0x0121), SHC(0x0125), SHC(0x0128), SHC(0x012C), SHC(0x012F), SHC(0x0132), SHC(0x0135),
+ SHC(0x0139), SHC(0x013B), SHC(0x013F), SHC(0x0141), SHC(0x0145), SHC(0x0147), SHC(0x014A), SHC(0x014D),
+ SHC(0x0150), SHC(0x0152), SHC(0x0155), SHC(0x0158), SHC(0x015A), SHC(0x015D), SHC(0x015F), SHC(0x0161),
+ SHC(0x0164), SHC(0x0166), SHC(0x0168), SHC(0x016B), SHC(0x016C), SHC(0x016F), SHC(0x0171), SHC(0x0172),
+ SHC(0x0175), SHC(0x0176), SHC(0x0178), SHC(0x017A), SHC(0x017B), SHC(0x017D), SHC(0x017F), SHC(0x0180),
+ SHC(0x0181), SHC(0x0183), SHC(0x0185), SHC(0x0185), SHC(0x0187), SHC(0x0187), SHC(0x0189), SHC(0x018A),
+ SHC(0x018B), SHC(0x018C), SHC(0x018D), SHC(0x018D), SHC(0x018E), SHC(0x018F), SHC(0x018F), SHC(0x0190),
+ SHC(0x0191), SHC(0x0190), SHC(0x0192), SHC(0x0191), SHC(0x0192), SHC(0x0192), SHC(0x0192), SHC(0x0192),
+ SHC(0x0192), SHC(0x0192), SHC(0x0192), SHC(0x0192), SHC(0x0191), SHC(0x0192), SHC(0x0190), SHC(0x0191),
+ SHC(0x0190), SHC(0x018F), SHC(0x018F), SHC(0x018E), SHC(0x018D), SHC(0x018D), SHC(0x018C), SHC(0x018B),
+ SHC(0x018A), SHC(0x0189), SHC(0x0187), SHC(0x0187), SHC(0x0185), SHC(0x0185), SHC(0x0183), SHC(0x0181),
+ SHC(0x0180), SHC(0x017F), SHC(0x017D), SHC(0x017B), SHC(0x017A), SHC(0x0178), SHC(0x0176), SHC(0x0175),
+ SHC(0x0172), SHC(0x0171), SHC(0x016F), SHC(0x016C), SHC(0x016B), SHC(0x0168), SHC(0x0166), SHC(0x0164),
+ SHC(0x0161), SHC(0x015F), SHC(0x015D), SHC(0x015A), SHC(0x0158), SHC(0x0155), SHC(0x0152), SHC(0x0150),
+ SHC(0x014D), SHC(0x014A), SHC(0x0147), SHC(0x0145), SHC(0x0141), SHC(0x013F), SHC(0x013B), SHC(0x0139),
+ SHC(0x0135), SHC(0x0132), SHC(0x012F), SHC(0x012C), SHC(0x0128), SHC(0x0125), SHC(0x0121), SHC(0x011E),
+ SHC(0x011B), SHC(0x0117), SHC(0x0114), SHC(0x010F), SHC(0x010D), SHC(0x0108), SHC(0x0105), SHC(0x0101),
+ SHC(0x00FD), SHC(0x00FA), SHC(0x00F5), SHC(0x00F2), SHC(0x00ED), SHC(0x00EA), SHC(0x00E5), SHC(0x00E2),
+ SHC(0x00DD), SHC(0x00D9), SHC(0x00D5), SHC(0x00D1), SHC(0x00CD), SHC(0x00C8), SHC(0x00C4), SHC(0x00C0),
+ SHC(0x00BB), SHC(0x00B7), SHC(0x00B3), SHC(0x00AE), SHC(0x00AA), SHC(0x00A5), SHC(0x00A1), SHC(0x009C),
+ SHC(0x0097), SHC(0x0093), SHC(0x008F), SHC(0x008A), SHC(0x0085), SHC(0x0080), SHC(0x007C), SHC(0x0077),
+ SHC(0x0072), SHC(0x006E), SHC(0x0069), SHC(0x0064), SHC(0x005F), SHC(0x005B), SHC(0x0056), SHC(0x0050),
+ SHC(0x004C), SHC(0x0048), SHC(0x0042), SHC(0x003D), SHC(0x0039), SHC(0x0034), SHC(0x002E), SHC(0x002A),
+ SHC(0x0025), SHC(0x0020), SHC(0x001B), SHC(0x0017), SHC(0x0011), SHC(0x000C), SHC(0x0008), SHC(0x0001)
+};
+
+const Word16 cos_table[512]=
+{
+ SHC(0x7fff),
+ SHC(0x7ffe),
+ SHC(0x7ff6),
+ SHC(0x7fea),
+ SHC(0x7fd9),
+ SHC(0x7fc2),
+ SHC(0x7fa7),
+ SHC(0x7f87),
+ SHC(0x7f62),
+ SHC(0x7f38),
+ SHC(0x7f0a),
+ SHC(0x7ed6),
+ SHC(0x7e9d),
+ SHC(0x7e60),
+ SHC(0x7e1e),
+ SHC(0x7dd6),
+ SHC(0x7d8a),
+ SHC(0x7d3a),
+ SHC(0x7ce4),
+ SHC(0x7c89),
+ SHC(0x7c2a),
+ SHC(0x7bc6),
+ SHC(0x7b5d),
+ SHC(0x7aef),
+ SHC(0x7a7d),
+ SHC(0x7a06),
+ SHC(0x798a),
+ SHC(0x790a),
+ SHC(0x7885),
+ SHC(0x77fb),
+ SHC(0x776c),
+ SHC(0x76d9),
+ SHC(0x7642),
+ SHC(0x75a6),
+ SHC(0x7505),
+ SHC(0x7460),
+ SHC(0x73b6),
+ SHC(0x7308),
+ SHC(0x7255),
+ SHC(0x719e),
+ SHC(0x70e3),
+ SHC(0x7023),
+ SHC(0x6f5f),
+ SHC(0x6e97),
+ SHC(0x6dca),
+ SHC(0x6cf9),
+ SHC(0x6c24),
+ SHC(0x6b4b),
+ SHC(0x6a6e),
+ SHC(0x698c),
+ SHC(0x68a7),
+ SHC(0x67bd),
+ SHC(0x66d0),
+ SHC(0x65de),
+ SHC(0x64e9),
+ SHC(0x63ef),
+ SHC(0x62f2),
+ SHC(0x61f1),
+ SHC(0x60ec),
+ SHC(0x5fe4),
+ SHC(0x5ed7),
+ SHC(0x5dc8),
+ SHC(0x5cb4),
+ SHC(0x5b9d),
+ SHC(0x5a82),
+ SHC(0x5964),
+ SHC(0x5843),
+ SHC(0x571e),
+ SHC(0x55f6),
+ SHC(0x54ca),
+ SHC(0x539b),
+ SHC(0x5269),
+ SHC(0x5134),
+ SHC(0x4ffb),
+ SHC(0x4ec0),
+ SHC(0x4d81),
+ SHC(0x4c40),
+ SHC(0x4afb),
+ SHC(0x49b4),
+ SHC(0x486a),
+ SHC(0x471d),
+ SHC(0x45cd),
+ SHC(0x447b),
+ SHC(0x4326),
+ SHC(0x41ce),
+ SHC(0x4074),
+ SHC(0x3f17),
+ SHC(0x3db8),
+ SHC(0x3c57),
+ SHC(0x3af3),
+ SHC(0x398d),
+ SHC(0x3825),
+ SHC(0x36ba),
+ SHC(0x354e),
+ SHC(0x33df),
+ SHC(0x326e),
+ SHC(0x30fc),
+ SHC(0x2f87),
+ SHC(0x2e11),
+ SHC(0x2c99),
+ SHC(0x2b1f),
+ SHC(0x29a4),
+ SHC(0x2827),
+ SHC(0x26a8),
+ SHC(0x2528),
+ SHC(0x23a7),
+ SHC(0x2224),
+ SHC(0x209f),
+ SHC(0x1f1a),
+ SHC(0x1d93),
+ SHC(0x1c0c),
+ SHC(0x1a83),
+ SHC(0x18f9),
+ SHC(0x176e),
+ SHC(0x15e2),
+ SHC(0x1455),
+ SHC(0x12c8),
+ SHC(0x113a),
+ SHC(0xfab),
+ SHC(0xe1c),
+ SHC(0xc8c),
+ SHC(0xafb),
+ SHC(0x96b),
+ SHC(0x7d9),
+ SHC(0x648),
+ SHC(0x4b6),
+ SHC(0x324),
+ SHC(0x192),
+ SHC(0x0),
+ SHC(0xfe6e),
+ SHC(0xfcdc),
+ SHC(0xfb4a),
+ SHC(0xf9b8),
+ SHC(0xf827),
+ SHC(0xf695),
+ SHC(0xf505),
+ SHC(0xf374),
+ SHC(0xf1e4),
+ SHC(0xf055),
+ SHC(0xeec6),
+ SHC(0xed38),
+ SHC(0xebab),
+ SHC(0xea1e),
+ SHC(0xe892),
+ SHC(0xe707),
+ SHC(0xe57d),
+ SHC(0xe3f4),
+ SHC(0xe26d),
+ SHC(0xe0e6),
+ SHC(0xdf61),
+ SHC(0xdddc),
+ SHC(0xdc59),
+ SHC(0xdad8),
+ SHC(0xd958),
+ SHC(0xd7d9),
+ SHC(0xd65c),
+ SHC(0xd4e1),
+ SHC(0xd367),
+ SHC(0xd1ef),
+ SHC(0xd079),
+ SHC(0xcf04),
+ SHC(0xcd92),
+ SHC(0xcc21),
+ SHC(0xcab2),
+ SHC(0xc946),
+ SHC(0xc7db),
+ SHC(0xc673),
+ SHC(0xc50d),
+ SHC(0xc3a9),
+ SHC(0xc248),
+ SHC(0xc0e9),
+ SHC(0xbf8c),
+ SHC(0xbe32),
+ SHC(0xbcda),
+ SHC(0xbb85),
+ SHC(0xba33),
+ SHC(0xb8e3),
+ SHC(0xb796),
+ SHC(0xb64c),
+ SHC(0xb505),
+ SHC(0xb3c0),
+ SHC(0xb27f),
+ SHC(0xb140),
+ SHC(0xb005),
+ SHC(0xaecc),
+ SHC(0xad97),
+ SHC(0xac65),
+ SHC(0xab36),
+ SHC(0xaa0a),
+ SHC(0xa8e2),
+ SHC(0xa7bd),
+ SHC(0xa69c),
+ SHC(0xa57e),
+ SHC(0xa463),
+ SHC(0xa34c),
+ SHC(0xa238),
+ SHC(0xa129),
+ SHC(0xa01c),
+ SHC(0x9f14),
+ SHC(0x9e0f),
+ SHC(0x9d0e),
+ SHC(0x9c11),
+ SHC(0x9b17),
+ SHC(0x9a22),
+ SHC(0x9930),
+ SHC(0x9843),
+ SHC(0x9759),
+ SHC(0x9674),
+ SHC(0x9592),
+ SHC(0x94b5),
+ SHC(0x93dc),
+ SHC(0x9307),
+ SHC(0x9236),
+ SHC(0x9169),
+ SHC(0x90a1),
+ SHC(0x8fdd),
+ SHC(0x8f1d),
+ SHC(0x8e62),
+ SHC(0x8dab),
+ SHC(0x8cf8),
+ SHC(0x8c4a),
+ SHC(0x8ba0),
+ SHC(0x8afb),
+ SHC(0x8a5a),
+ SHC(0x89be),
+ SHC(0x8927),
+ SHC(0x8894),
+ SHC(0x8805),
+ SHC(0x877b),
+ SHC(0x86f6),
+ SHC(0x8676),
+ SHC(0x85fa),
+ SHC(0x8583),
+ SHC(0x8511),
+ SHC(0x84a3),
+ SHC(0x843a),
+ SHC(0x83d6),
+ SHC(0x8377),
+ SHC(0x831c),
+ SHC(0x82c6),
+ SHC(0x8276),
+ SHC(0x822a),
+ SHC(0x81e2),
+ SHC(0x81a0),
+ SHC(0x8163),
+ SHC(0x812a),
+ SHC(0x80f6),
+ SHC(0x80c8),
+ SHC(0x809e),
+ SHC(0x8079),
+ SHC(0x8059),
+ SHC(0x803e),
+ SHC(0x8027),
+ SHC(0x8016),
+ SHC(0x800a),
+ SHC(0x8002),
+ SHC(0x8001),
+ SHC(0x8002),
+ SHC(0x800a),
+ SHC(0x8016),
+ SHC(0x8027),
+ SHC(0x803e),
+ SHC(0x8059),
+ SHC(0x8079),
+ SHC(0x809e),
+ SHC(0x80c8),
+ SHC(0x80f6),
+ SHC(0x812a),
+ SHC(0x8163),
+ SHC(0x81a0),
+ SHC(0x81e2),
+ SHC(0x822a),
+ SHC(0x8276),
+ SHC(0x82c6),
+ SHC(0x831c),
+ SHC(0x8377),
+ SHC(0x83d6),
+ SHC(0x843a),
+ SHC(0x84a3),
+ SHC(0x8511),
+ SHC(0x8583),
+ SHC(0x85fa),
+ SHC(0x8676),
+ SHC(0x86f6),
+ SHC(0x877b),
+ SHC(0x8805),
+ SHC(0x8894),
+ SHC(0x8927),
+ SHC(0x89be),
+ SHC(0x8a5a),
+ SHC(0x8afb),
+ SHC(0x8ba0),
+ SHC(0x8c4a),
+ SHC(0x8cf8),
+ SHC(0x8dab),
+ SHC(0x8e62),
+ SHC(0x8f1d),
+ SHC(0x8fdd),
+ SHC(0x90a1),
+ SHC(0x9169),
+ SHC(0x9236),
+ SHC(0x9307),
+ SHC(0x93dc),
+ SHC(0x94b5),
+ SHC(0x9592),
+ SHC(0x9674),
+ SHC(0x9759),
+ SHC(0x9843),
+ SHC(0x9930),
+ SHC(0x9a22),
+ SHC(0x9b17),
+ SHC(0x9c11),
+ SHC(0x9d0e),
+ SHC(0x9e0f),
+ SHC(0x9f14),
+ SHC(0xa01c),
+ SHC(0xa129),
+ SHC(0xa238),
+ SHC(0xa34c),
+ SHC(0xa463),
+ SHC(0xa57e),
+ SHC(0xa69c),
+ SHC(0xa7bd),
+ SHC(0xa8e2),
+ SHC(0xaa0a),
+ SHC(0xab36),
+ SHC(0xac65),
+ SHC(0xad97),
+ SHC(0xaecc),
+ SHC(0xb005),
+ SHC(0xb140),
+ SHC(0xb27f),
+ SHC(0xb3c0),
+ SHC(0xb505),
+ SHC(0xb64c),
+ SHC(0xb796),
+ SHC(0xb8e3),
+ SHC(0xba33),
+ SHC(0xbb85),
+ SHC(0xbcda),
+ SHC(0xbe32),
+ SHC(0xbf8c),
+ SHC(0xc0e9),
+ SHC(0xc248),
+ SHC(0xc3a9),
+ SHC(0xc50d),
+ SHC(0xc673),
+ SHC(0xc7db),
+ SHC(0xc946),
+ SHC(0xcab2),
+ SHC(0xcc21),
+ SHC(0xcd92),
+ SHC(0xcf04),
+ SHC(0xd079),
+ SHC(0xd1ef),
+ SHC(0xd367),
+ SHC(0xd4e1),
+ SHC(0xd65c),
+ SHC(0xd7d9),
+ SHC(0xd958),
+ SHC(0xdad8),
+ SHC(0xdc59),
+ SHC(0xdddc),
+ SHC(0xdf61),
+ SHC(0xe0e6),
+ SHC(0xe26d),
+ SHC(0xe3f4),
+ SHC(0xe57d),
+ SHC(0xe707),
+ SHC(0xe892),
+ SHC(0xea1e),
+ SHC(0xebab),
+ SHC(0xed38),
+ SHC(0xeec6),
+ SHC(0xf055),
+ SHC(0xf1e4),
+ SHC(0xf374),
+ SHC(0xf505),
+ SHC(0xf695),
+ SHC(0xf827),
+ SHC(0xf9b8),
+ SHC(0xfb4a),
+ SHC(0xfcdc),
+ SHC(0xfe6e),
+ SHC(0x0),
+ SHC(0x192),
+ SHC(0x324),
+ SHC(0x4b6),
+ SHC(0x648),
+ SHC(0x7d9),
+ SHC(0x96b),
+ SHC(0xafb),
+ SHC(0xc8c),
+ SHC(0xe1c),
+ SHC(0xfab),
+ SHC(0x113a),
+ SHC(0x12c8),
+ SHC(0x1455),
+ SHC(0x15e2),
+ SHC(0x176e),
+ SHC(0x18f9),
+ SHC(0x1a83),
+ SHC(0x1c0c),
+ SHC(0x1d93),
+ SHC(0x1f1a),
+ SHC(0x209f),
+ SHC(0x2224),
+ SHC(0x23a7),
+ SHC(0x2528),
+ SHC(0x26a8),
+ SHC(0x2827),
+ SHC(0x29a4),
+ SHC(0x2b1f),
+ SHC(0x2c99),
+ SHC(0x2e11),
+ SHC(0x2f87),
+ SHC(0x30fc),
+ SHC(0x326e),
+ SHC(0x33df),
+ SHC(0x354e),
+ SHC(0x36ba),
+ SHC(0x3825),
+ SHC(0x398d),
+ SHC(0x3af3),
+ SHC(0x3c57),
+ SHC(0x3db8),
+ SHC(0x3f17),
+ SHC(0x4074),
+ SHC(0x41ce),
+ SHC(0x4326),
+ SHC(0x447b),
+ SHC(0x45cd),
+ SHC(0x471d),
+ SHC(0x486a),
+ SHC(0x49b4),
+ SHC(0x4afb),
+ SHC(0x4c40),
+ SHC(0x4d81),
+ SHC(0x4ec0),
+ SHC(0x4ffb),
+ SHC(0x5134),
+ SHC(0x5269),
+ SHC(0x539b),
+ SHC(0x54ca),
+ SHC(0x55f6),
+ SHC(0x571e),
+ SHC(0x5843),
+ SHC(0x5964),
+ SHC(0x5a82),
+ SHC(0x5b9d),
+ SHC(0x5cb4),
+ SHC(0x5dc8),
+ SHC(0x5ed7),
+ SHC(0x5fe4),
+ SHC(0x60ec),
+ SHC(0x61f1),
+ SHC(0x62f2),
+ SHC(0x63ef),
+ SHC(0x64e9),
+ SHC(0x65de),
+ SHC(0x66d0),
+ SHC(0x67bd),
+ SHC(0x68a7),
+ SHC(0x698c),
+ SHC(0x6a6e),
+ SHC(0x6b4b),
+ SHC(0x6c24),
+ SHC(0x6cf9),
+ SHC(0x6dca),
+ SHC(0x6e97),
+ SHC(0x6f5f),
+ SHC(0x7023),
+ SHC(0x70e3),
+ SHC(0x719e),
+ SHC(0x7255),
+ SHC(0x7308),
+ SHC(0x73b6),
+ SHC(0x7460),
+ SHC(0x7505),
+ SHC(0x75a6),
+ SHC(0x7642),
+ SHC(0x76d9),
+ SHC(0x776c),
+ SHC(0x77fb),
+ SHC(0x7885),
+ SHC(0x790a),
+ SHC(0x798a),
+ SHC(0x7a06),
+ SHC(0x7a7d),
+ SHC(0x7aef),
+ SHC(0x7b5d),
+ SHC(0x7bc6),
+ SHC(0x7c2a),
+ SHC(0x7c89),
+ SHC(0x7ce4),
+ SHC(0x7d3a),
+ SHC(0x7d8a),
+ SHC(0x7dd6),
+ SHC(0x7e1e),
+ SHC(0x7e60),
+ SHC(0x7e9d),
+ SHC(0x7ed6),
+ SHC(0x7f0a),
+ SHC(0x7f38),
+ SHC(0x7f62),
+ SHC(0x7f87),
+ SHC(0x7fa7),
+ SHC(0x7fc2),
+ SHC(0x7fd9),
+ SHC(0x7fea),
+ SHC(0x7ff6),
+ SHC(0x7ffe)
+};
+
+
+
+const Word16 window_8_16_32kHz_fx[370] =
+{
+ 3, 9, 19, 33, 49, 69, 93, 119,
+ 149, 182, 219, 258, 301, 347, 396, 448,
+ 503, 561, 623, 687, 755, 825, 898, 974,
+ 1054, 1136, 1221, 1309, 1399, 1493, 1589, 1688,
+ 1790, 1895, 2002, 2112, 2225, 2340, 2458, 2579,
+ 2702, 2827, 2955, 3086, 3219, 3355, 3493, 3633,
+ 3775, 3920, 4068, 4217, 4369, 4523, 4679, 4837,
+ 4998, 5160, 5325, 5491, 5660, 5830, 6003, 6177,
+ 6353, 6531, 6711, 6892, 7076, 7260, 7447, 7635,
+ 7825, 8016, 8209, 8403, 8599, 8796, 8995, 9195,
+ 9396, 9598, 9802, 10007, 10212, 10419, 10628, 10837,
+ 11047, 11248, 11437, 11623, 11809, 11997, 12185, 12374,
+ 12564, 12754, 12944, 13135, 13326, 13517, 13709, 13901,
+ 14093, 14286, 14478, 14671, 14864, 15057, 15250, 15443,
+ 15636, 15829, 16023, 16216, 16409, 16602, 16794, 16987,
+ 17179, 17372, 17564, 17755, 17947, 18138, 18329, 18519,
+ 18710, 18899, 19089, 19278, 19466, 19654, 19841, 20028,
+ 20214, 20400, 20585, 20770, 20954, 21137, 21319, 21501,
+ 21682, 21862, 22042, 22220, 22398, 22575, 22751, 22926,
+ 23101, 23274, 23446, 23618, 23788, 23958, 24126, 24266,
+ 24321, 24460, 24625, 24789, 24953, 25114, 25275, 25435,
+ 25593, 25751, 25907, 26061, 26215, 26367, 26518, 26668,
+ 26817, 26964, 27110, 27254, 27398, 27540, 27680, 27819,
+ 27957, 28093, 28228, 28362, 28494, 28625, 28754, 28882,
+ 29008, 29133, 29256, 29378, 29499, 29618, 29736, 29852,
+ 29966, 30079, 30191, 30301, 30410, 30517, 30623, 30727,
+ 30830, 30931, 31031, 31129, 31226, 31322, 31416, 31508,
+ 31599, 31689, 31777, 31864, 31950, 32035, 32118, 32200,
+ 32280, 32360, 32439, 32517, 32595, 32673, 32673, 32593,
+ 32513, 32432, 32349, 32265, 32178, 32090, 31999, 31907,
+ 31812, 31715, 31615, 31514, 31410, 31304, 31196, 31085,
+ 30972, 30857, 30739, 30619, 30497, 30372, 30245, 30116,
+ 29984, 29850, 29714, 29575, 29434, 29290, 29144, 28996,
+ 28845, 28692, 28537, 28379, 28219, 28057, 27892, 27725,
+ 27555, 27383, 27209, 27033, 26854, 26672, 26489, 26303,
+ 26115, 25924, 25731, 25536, 25338, 25138, 24936, 24731,
+ 24525, 24316, 24104, 23890, 23674, 23456, 23236, 23013,
+ 22788, 22561, 22331, 22138, 22060, 21865, 21629, 21390,
+ 21150, 20907, 20662, 20414, 20165, 19913, 19659, 19403,
+ 19145, 18885, 18622, 18357, 18090, 17821, 17550, 17277,
+ 17001, 16723, 16443, 16161, 15877, 15591, 15303, 15012,
+ 14719, 14425, 14127, 13828, 13527, 13223, 12918, 12610,
+ 12300, 11988, 11673, 11356, 11038, 10716, 10393, 10067,
+ 9739, 9408, 9076, 8740, 8403, 8062, 7720, 7374,
+ 7026, 6675, 6322, 5965, 5606, 5243, 4878, 4508,
+ 4136, 3759, 3378, 2993, 2603, 2208, 1807, 1397,
+ 978, 545
+};
+
+
+
+
+const Word16 window_48kHz_fx[1110] =
+{
+ 0, 1, 2, 3, 5, 8, 10, 13,
+ 17, 21, 25, 30, 35, 40, 46, 52,
+ 58, 65, 72, 80, 88, 96, 105, 114,
+ 124, 133, 144, 154, 165, 176, 188, 200,
+ 212, 225, 238, 251, 265, 279, 293, 308,
+ 323, 339, 354, 371, 387, 404, 421, 439,
+ 457, 475, 493, 512, 532, 551, 571, 591,
+ 612, 633, 654, 676, 698, 720, 743, 766,
+ 789, 813, 837, 861, 885, 910, 936, 961,
+ 987, 1013, 1040, 1067, 1094, 1122, 1149, 1178,
+ 1206, 1235, 1264, 1293, 1323, 1353, 1384, 1414,
+ 1445, 1477, 1508, 1540, 1573, 1605, 1638, 1671,
+ 1705, 1739, 1773, 1807, 1842, 1877, 1912, 1948,
+ 1984, 2020, 2057, 2093, 2130, 2168, 2206, 2244,
+ 2282, 2320, 2359, 2399, 2438, 2478, 2518, 2558,
+ 2599, 2640, 2681, 2722, 2764, 2806, 2848, 2891,
+ 2934, 2977, 3020, 3064, 3108, 3152, 3196, 3241,
+ 3286, 3332, 3377, 3423, 3469, 3515, 3562, 3609,
+ 3656, 3704, 3751, 3799, 3847, 3896, 3945, 3994,
+ 4043, 4092, 4142, 4192, 4242, 4293, 4343, 4394,
+ 4445, 4497, 4549, 4600, 4653, 4705, 4758, 4811,
+ 4864, 4917, 4971, 5024, 5078, 5133, 5187, 5242,
+ 5297, 5352, 5407, 5463, 5519, 5575, 5631, 5688,
+ 5744, 5801, 5859, 5916, 5974, 6031, 6089, 6147,
+ 6206, 6265, 6323, 6382, 6442, 6501, 6561, 6620,
+ 6680, 6741, 6801, 6862, 6922, 6983, 7045, 7106,
+ 7168, 7229, 7291, 7353, 7416, 7478, 7541, 7604,
+ 7667, 7730, 7793, 7857, 7920, 7984, 8048, 8112,
+ 8177, 8241, 8306, 8371, 8436, 8501, 8566, 8632,
+ 8697, 8763, 8829, 8895, 8961, 9028, 9094, 9161,
+ 9228, 9295, 9362, 9429, 9497, 9564, 9632, 9700,
+ 9768, 9836, 9904, 9972, 10041, 10109, 10178, 10247,
+ 10316, 10385, 10454, 10523, 10593, 10662, 10732, 10802,
+ 10871, 10941, 11012, 11082, 11152, 11222, 11283, 11344,
+ 11406, 11467, 11529, 11591, 11653, 11716, 11778, 11840,
+ 11903, 11966, 12028, 12091, 12154, 12217, 12280, 12343,
+ 12406, 12469, 12532, 12595, 12658, 12722, 12785, 12849,
+ 12912, 12976, 13039, 13103, 13166, 13230, 13294, 13358,
+ 13421, 13485, 13549, 13613, 13677, 13741, 13805, 13869,
+ 13933, 13997, 14061, 14125, 14189, 14253, 14318, 14382,
+ 14446, 14510, 14574, 14639, 14703, 14767, 14832, 14896,
+ 14960, 15025, 15089, 15153, 15218, 15282, 15346, 15411,
+ 15475, 15540, 15604, 15668, 15733, 15797, 15862, 15926,
+ 15990, 16055, 16119, 16183, 16248, 16312, 16376, 16441,
+ 16505, 16569, 16634, 16698, 16762, 16826, 16891, 16955,
+ 17019, 17083, 17147, 17211, 17275, 17339, 17404, 17468,
+ 17532, 17596, 17659, 17723, 17787, 17851, 17915, 17979,
+ 18042, 18106, 18170, 18233, 18297, 18361, 18424, 18488,
+ 18551, 18614, 18678, 18741, 18804, 18868, 18931, 18994,
+ 19057, 19120, 19183, 19246, 19309, 19372, 19434, 19497,
+ 19560, 19622, 19685, 19748, 19810, 19872, 19935, 19997,
+ 20059, 20121, 20183, 20245, 20307, 20369, 20431, 20493,
+ 20554, 20616, 20677, 20739, 20800, 20862, 20923, 20984,
+ 21045, 21106, 21167, 21228, 21289, 21349, 21410, 21471,
+ 21531, 21591, 21652, 21712, 21772, 21832, 21892, 21952,
+ 22012, 22071, 22131, 22190, 22250, 22309, 22368, 22427,
+ 22486, 22545, 22604, 22663, 22722, 22780, 22839, 22897,
+ 22955, 23013, 23071, 23129, 23187, 23245, 23303, 23360,
+ 23418, 23475, 23532, 23589, 23646, 23703, 23760, 23817,
+ 23873, 23930, 23986, 24042, 24098, 24154, 24210, 24266,
+ 24321, 24377, 24432, 24488, 24543, 24598, 24653, 24707,
+ 24762, 24817, 24871, 24925, 24979, 25034, 25087, 25141,
+ 25195, 25248, 25302, 25355, 25408, 25461, 25514, 25567,
+ 25620, 25672, 25724, 25777, 25829, 25881, 25932, 25984,
+ 26036, 26087, 26138, 26189, 26240, 26291, 26342, 26393,
+ 26443, 26493, 26543, 26593, 26643, 26693, 26743, 26792,
+ 26841, 26890, 26939, 26988, 27037, 27086, 27134, 27182,
+ 27230, 27278, 27326, 27374, 27421, 27469, 27516, 27563,
+ 27610, 27657, 27703, 27750, 27796, 27842, 27888, 27934,
+ 27980, 28025, 28071, 28116, 28161, 28206, 28250, 28295,
+ 28340, 28384, 28428, 28472, 28516, 28559, 28603, 28646,
+ 28689, 28732, 28775, 28818, 28860, 28903, 28945, 28987,
+ 29029, 29071, 29112, 29154, 29195, 29236, 29277, 29318,
+ 29358, 29399, 29439, 29479, 29519, 29559, 29598, 29638,
+ 29677, 29716, 29755, 29794, 29832, 29871, 29909, 29947,
+ 29985, 30023, 30061, 30098, 30135, 30172, 30209, 30246,
+ 30283, 30319, 30356, 30392, 30428, 30464, 30499, 30535,
+ 30570, 30605, 30640, 30675, 30710, 30744, 30779, 30813,
+ 30847, 30881, 30914, 30948, 30981, 31014, 31047, 31080,
+ 31113, 31145, 31178, 31210, 31242, 31274, 31306, 31337,
+ 31369, 31400, 31431, 31462, 31493, 31523, 31554, 31584,
+ 31614, 31644, 31674, 31704, 31733, 31763, 31792, 31821,
+ 31850, 31879, 31907, 31936, 31964, 31992, 32020, 32048,
+ 32076, 32104, 32131, 32159, 32186, 32213, 32240, 32267,
+ 32294, 32320, 32347, 32373, 32399, 32426, 32452, 32478,
+ 32504, 32530, 32556, 32582, 32607, 32633, 32659, 32685,
+ 32712, 32739, 32739, 32712, 32685, 32659, 32633, 32606,
+ 32580, 32553, 32527, 32500, 32473, 32446, 32418, 32391,
+ 32363, 32335, 32307, 32279, 32251, 32222, 32193, 32164,
+ 32134, 32105, 32075, 32045, 32015, 31984, 31953, 31922,
+ 31891, 31859, 31828, 31796, 31764, 31731, 31698, 31665,
+ 31632, 31599, 31565, 31531, 31497, 31462, 31428, 31393,
+ 31357, 31322, 31286, 31250, 31214, 31177, 31141, 31104,
+ 31066, 31029, 30991, 30953, 30915, 30876, 30837, 30798,
+ 30759, 30719, 30679, 30639, 30599, 30558, 30517, 30476,
+ 30435, 30393, 30351, 30309, 30266, 30224, 30181, 30138,
+ 30094, 30050, 30006, 29962, 29917, 29873, 29827, 29782,
+ 29737, 29691, 29645, 29598, 29551, 29505, 29457, 29410,
+ 29362, 29314, 29266, 29218, 29169, 29120, 29070, 29021,
+ 28971, 28921, 28871, 28820, 28769, 28718, 28667, 28615,
+ 28563, 28511, 28459, 28406, 28353, 28300, 28246, 28192,
+ 28138, 28084, 28030, 27975, 27920, 27864, 27809, 27753,
+ 27697, 27640, 27584, 27527, 27470, 27412, 27355, 27297,
+ 27238, 27180, 27121, 27062, 27003, 26944, 26884, 26824,
+ 26763, 26703, 26642, 26581, 26520, 26458, 26396, 26334,
+ 26272, 26209, 26146, 26083, 26020, 25956, 25892, 25828,
+ 25763, 25699, 25634, 25568, 25503, 25437, 25371, 25305,
+ 25239, 25172, 25105, 25037, 24970, 24902, 24834, 24766,
+ 24697, 24628, 24559, 24490, 24420, 24351, 24281, 24210,
+ 24140, 24069, 23998, 23926, 23855, 23783, 23711, 23638,
+ 23566, 23493, 23420, 23346, 23273, 23199, 23125, 23050,
+ 22976, 22901, 22826, 22750, 22675, 22599, 22523, 22446,
+ 22370, 22293, 22215, 22138, 22060, 21983, 21904, 21826,
+ 21747, 21669, 21589, 21510, 21430, 21351, 21271, 21190,
+ 21110, 21029, 20948, 20866, 20785, 20703, 20621, 20538,
+ 20456, 20373, 20290, 20207, 20123, 20039, 19955, 19871,
+ 19787, 19702, 19617, 19532, 19446, 19360, 19274, 19188,
+ 19102, 19015, 18928, 18841, 18754, 18666, 18578, 18490,
+ 18402, 18313, 18224, 18135, 18046, 17956, 17866, 17776,
+ 17686, 17595, 17505, 17414, 17322, 17231, 17139, 17047,
+ 16955, 16863, 16770, 16677, 16584, 16490, 16397, 16303,
+ 16209, 16114, 16020, 15925, 15830, 15735, 15639, 15543,
+ 15447, 15351, 15254, 15158, 15061, 14964, 14866, 14768,
+ 14671, 14572, 14474, 14375, 14276, 14177, 14078, 13978,
+ 13878, 13778, 13678, 13578, 13477, 13376, 13274, 13173,
+ 13071, 12969, 12867, 12764, 12662, 12559, 12455, 12352,
+ 12248, 12144, 12040, 11936, 11831, 11726, 11621, 11515,
+ 11410, 11304, 11197, 11091, 10984, 10877, 10770, 10663,
+ 10555, 10447, 10339, 10230, 10122, 10013, 9904, 9794,
+ 9684, 9574, 9464, 9353, 9243, 9131, 9020, 8908,
+ 8797, 8684, 8572, 8459, 8346, 8233, 8119, 8006,
+ 7892, 7777, 7662, 7547, 7432, 7317, 7201, 7085,
+ 6968, 6851, 6734, 6617, 6499, 6381, 6263, 6144,
+ 6025, 5906, 5786, 5666, 5546, 5425, 5304, 5183,
+ 5061, 4939, 4817, 4694, 4570, 4447, 4323, 4198,
+ 4074, 3948, 3823, 3696, 3570, 3443, 3315, 3187,
+ 3058, 2929, 2800, 2669, 2539, 2407, 2275, 2142,
+ 2009, 1875, 1740, 1604, 1467, 1330, 1191, 1051,
+ 909, 766, 621, 474, 324, 169
+};
+
+
+const Word16 window_256kHz[592] = /*ALDO at 25.6 maybe not needed ?*/
+{
+ 1, 3, 7, 12, 19, 27, 36, 47,
+ 58, 72, 86, 102, 119, 138, 157, 178,
+ 201, 224, 249, 275, 302, 331, 361, 391,
+ 424, 457, 492, 527, 564, 603, 642, 683,
+ 724, 767, 811, 857, 903, 951, 999, 1049,
+ 1100, 1152, 1205, 1260, 1315, 1372, 1430, 1488,
+ 1548, 1609, 1671, 1735, 1799, 1864, 1931, 1998,
+ 2066, 2136, 2207, 2278, 2351, 2424, 2499, 2575,
+ 2651, 2729, 2808, 2887, 2968, 3049, 3132, 3215,
+ 3300, 3385, 3472, 3559, 3647, 3736, 3826, 3917,
+ 4009, 4101, 4195, 4289, 4385, 4481, 4578, 4676,
+ 4774, 4874, 4974, 5075, 5177, 5280, 5384, 5488,
+ 5593, 5699, 5806, 5913, 6021, 6130, 6240, 6350,
+ 6461, 6573, 6685, 6798, 6912, 7026, 7141, 7257,
+ 7373, 7491, 7608, 7726, 7845, 7965, 8085, 8206,
+ 8327, 8449, 8571, 8694, 8817, 8941, 9066, 9191,
+ 9316, 9442, 9569, 9696, 9823, 9951, 10079, 10208,
+ 10337, 10467, 10597, 10727, 10858, 10990, 11121, 11253,
+ 11367, 11482, 11598, 11714, 11831, 11948, 12065, 12182,
+ 12300, 12418, 12536, 12654, 12772, 12891, 13010, 13129,
+ 13248, 13367, 13486, 13605, 13725, 13844, 13964, 14084,
+ 14203, 14323, 14443, 14563, 14683, 14804, 14924, 15044,
+ 15164, 15284, 15405, 15525, 15645, 15765, 15885, 16006,
+ 16126, 16246, 16366, 16486, 16606, 16726, 16846, 16966,
+ 17086, 17206, 17325, 17445, 17564, 17684, 17803, 17922,
+ 18041, 18160, 18279, 18397, 18516, 18634, 18753, 18871,
+ 18988, 19106, 19224, 19341, 19458, 19575, 19692, 19809,
+ 19925, 20041, 20157, 20273, 20388, 20503, 20618, 20733,
+ 20848, 20962, 21076, 21190, 21303, 21416, 21529, 21642,
+ 21754, 21866, 21978, 22089, 22200, 22311, 22421, 22531,
+ 22641, 22751, 22860, 22968, 23077, 23185, 23293, 23400,
+ 23507, 23613, 23719, 23825, 23931, 24036, 24140, 24244,
+ 24348, 24452, 24555, 24657, 24759, 24861, 24962, 25063,
+ 25163, 25263, 25363, 25462, 25561, 25659, 25756, 25854,
+ 25950, 26047, 26142, 26238, 26333, 26427, 26521, 26614,
+ 26707, 26799, 26891, 26982, 27073, 27164, 27253, 27343,
+ 27432, 27520, 27608, 27695, 27781, 27868, 27953, 28038,
+ 28123, 28207, 28290, 28373, 28456, 28537, 28619, 28699,
+ 28780, 28859, 28938, 29017, 29095, 29172, 29249, 29325,
+ 29401, 29476, 29550, 29624, 29698, 29771, 29843, 29915,
+ 29986, 30056, 30126, 30196, 30264, 30333, 30400, 30467,
+ 30534, 30600, 30665, 30730, 30794, 30858, 30921, 30984,
+ 31046, 31107, 31168, 31228, 31288, 31347, 31406, 31464,
+ 31522, 31579, 31635, 31691, 31746, 31801, 31856, 31909,
+ 31963, 32016, 32068, 32120, 32171, 32222, 32273, 32323,
+ 32372, 32422, 32471, 32520, 32568, 32617, 32666, 32715,
+ 32715, 32666, 32616, 32567, 32517, 32466, 32415, 32364,
+ 32311, 32258, 32204, 32150, 32094, 32038, 31981, 31923,
+ 31864, 31805, 31744, 31683, 31621, 31557, 31494, 31429,
+ 31363, 31296, 31229, 31161, 31091, 31021, 30950, 30878,
+ 30805, 30731, 30657, 30581, 30505, 30427, 30349, 30270,
+ 30189, 30108, 30026, 29943, 29860, 29775, 29689, 29603,
+ 29515, 29427, 29337, 29247, 29156, 29064, 28971, 28877,
+ 28782, 28687, 28590, 28492, 28394, 28294, 28194, 28093,
+ 27991, 27888, 27784, 27679, 27573, 27466, 27358, 27250,
+ 27140, 27030, 26919, 26806, 26693, 26579, 26464, 26349,
+ 26232, 26114, 25996, 25876, 25756, 25635, 25512, 25389,
+ 25265, 25140, 25015, 24888, 24761, 24632, 24503, 24373,
+ 24242, 24110, 23977, 23843, 23708, 23573, 23436, 23299,
+ 23161, 23022, 22882, 22741, 22599, 22457, 22313, 22169,
+ 22024, 21878, 21731, 21583, 21435, 21285, 21135, 20984,
+ 20832, 20679, 20525, 20370, 20215, 20059, 19901, 19743,
+ 19584, 19425, 19264, 19103, 18940, 18777, 18613, 18448,
+ 18283, 18116, 17949, 17781, 17612, 17442, 17271, 17100,
+ 16927, 16754, 16580, 16405, 16230, 16053, 15876, 15698,
+ 15518, 15339, 15158, 14976, 14794, 14611, 14427, 14242,
+ 14056, 13869, 13682, 13494, 13305, 13115, 12924, 12732,
+ 12540, 12346, 12152, 11957, 11761, 11564, 11366, 11168,
+ 10968, 10768, 10566, 10364, 10161, 9957, 9752, 9547,
+ 9340, 9132, 8924, 8714, 8503, 8292, 8079, 7866,
+ 7651, 7436, 7219, 7002, 6783, 6563, 6343, 6121,
+ 5897, 5673, 5448, 5221, 4993, 4764, 4533, 4301,
+ 4067, 3832, 3596, 3358, 3118, 2876, 2632, 2387,
+ 2139, 1888, 1635, 1379, 1119, 854, 583, 304
+};
+
+const Word16 small_overlap_48[R2_48/7]=
+{
+ 429, 1286, 2143, 2998, 3851, 4702, 5549, 6393,
+ 7232, 8066, 8895, 9717, 10533, 11342, 12142, 12935,
+ 13719, 14493, 15257, 16011, 16754, 17485, 18205, 18912,
+ 19606, 20286, 20953, 21605, 22243, 22865, 23472, 24062,
+ 24636, 25193, 25733, 26255, 26760, 27246, 27713, 28161,
+ 28590, 28999, 29389, 29758, 30107, 30435, 30743, 31029,
+ 31294, 31538, 31760, 31960, 32138, 32295, 32429, 32541,
+ 32631, 32698, 32743, 32765
+};
+
+const Word16 small_overlap_25[R2_25/7]=
+{
+ 804, 2411, 4011, 5602, 7180, 8740, 10279, 11793,
+ 13279, 14733, 16151, 17531, 18868, 20160, 21403, 22595,
+ 23732, 24812, 25833, 26791, 27684, 28511, 29269, 29957,
+ 30572, 31114, 31581, 31972, 32286, 32522, 32679, 32758
+};
+
+const Word16 small_overlap_int[R2_16/7]=
+{
+ 2571, 5126,
+ 7650, 10126, 12540, 14876, 17121, 19261, 21281, 22865,
+ 23472, 24917, 26510, 27939, 29197, 30274, 31164, 31863,
+ 32365, 32667
+};
+
+
+const Word16 half_overlap_48[3*R2_48/7]=
+{
+ 143, 429,
+ 715, 1001, 1286, 1572, 1858, 2143, 2428, 2713,
+ 2998, 3283, 3567, 3851, 4135, 4419, 4702, 4985,
+ 5267, 5549, 5831, 6112, 6393, 6673, 6953, 7232,
+ 7510, 7788, 8066, 8343, 8619, 8895, 9169, 9444,
+ 9717, 9990, 10262, 10533, 10803, 11073, 11342, 11609,
+ 11876, 12142, 12408, 12672, 12935, 13197, 13458, 13719,
+ 13978, 14236, 14493, 14749, 15004, 15257, 15510, 15761,
+ 16011, 16260, 16508, 16754, 16999, 17243, 17485, 17727,
+ 17966, 18205, 18442, 18678, 18912, 19145, 19376, 19606,
+ 19834, 20061, 20286, 20510, 20732, 20953, 21172, 21390,
+ 21605, 21820, 22032, 22243, 22452, 22659, 22865, 23069,
+ 23271, 23472, 23670, 23867, 24062, 24255, 24447, 24636,
+ 24824, 25010, 25193, 25375, 25555, 25733, 25909, 26083,
+ 26255, 26426, 26594, 26760, 26924, 27086, 27246, 27403,
+ 27559, 27713, 27864, 28014, 28161, 28306, 28449, 28590,
+ 28729, 28865, 28999, 29131, 29261, 29389, 29514, 29637,
+ 29758, 29877, 29993, 30107, 30219, 30328, 30435, 30540,
+ 30643, 30743, 30840, 30936, 31029, 31120, 31208, 31294,
+ 31378, 31459, 31538, 31614, 31688, 31760, 31829, 31896,
+ 31960, 32022, 32081, 32138, 32193, 32245, 32295, 32342,
+ 32387, 32429, 32469, 32506, 32541, 32573, 32603, 32631,
+ 32655, 32678, 32698, 32715, 32730, 32743, 32753, 32760,
+ 32765, 32767
+};
+
+const Word16 half_overlap_25[3*R2_25/7]=
+{
+ 268, 804, 1340, 1876, 2411, 2945, 3479, 4011,
+ 4543, 5073, 5602, 6130, 6655, 7180, 7702, 8222,
+ 8740, 9255, 9768, 10279, 10786, 11291, 11793, 12292,
+ 12787, 13279, 13767, 14252, 14733, 15210, 15683, 16151,
+ 16616, 17075, 17531, 17981, 18427, 18868, 19304, 19735,
+ 20160, 20580, 20994, 21403, 21806, 22204, 22595, 22980,
+ 23359, 23732, 24099, 24459, 24812, 25159, 25499, 25833,
+ 26159, 26478, 26791, 27096, 27394, 27684, 27967, 28243,
+ 28511, 28771, 29024, 29269, 29506, 29736, 29957, 30170,
+ 30375, 30572, 30761, 30942, 31114, 31278, 31434, 31581,
+ 31720, 31850, 31972, 32085, 32190, 32286, 32373, 32452,
+ 32522, 32583, 32635, 32679, 32714, 32741, 32758, 32767
+};
+
+const Word16 half_overlap_int[3*R2_16/7]=
+{
+ 858, 1715, 2571, 3425, 4277, 5126,
+ 5971, 6813, 7650, 8481, 9307, 10126, 10938, 11743,
+ 12540, 13328, 14107, 14876, 15636, 16384, 17121, 17847,
+ 18560, 19261, 19948, 20622, 21281, 21926, 22556, 23069,
+ 23271, 23769, 24351, 24917, 25466, 25997, 26510, 27005,
+ 27482, 27939, 28378, 28797, 29197, 29576, 29935, 30274,
+ 30592, 30888, 31164, 31419, 31651, 31863, 32052, 32219,
+ 32365, 32488, 32588, 32667, 32723, 32757
+};
+
+
+/*----------------------------------------------------------------------------------*
+ * SC-VBR
+ *----------------------------------------------------------------------------------*/
+
+const Word16 bp1_num_coef_wb_fx[5]= { 15286, 0, -30572, 0, 15286, }; /* Q14 */
+
+const Word16 bp1_den_coef_wb_fx[5]= { 16384, 0, -30498, 0, 14262, }; /* Q14 */
+
+
+
+const Word16 shape1_num_coef_fx[11]= /* Q15 */
+{
+ 31437, -2443, -13636, 4316,
+ -10188, 48, 2639, -3575,
+ -776, 1046, 399
+};
+
+
+const Word16 shape1_den_coef_fx[11]= { 32767, /* Q15 */
+ 2940, -12237, 4032, -9609,
+ -1998, 2335, -3900, -1595,
+ 857, 253
+ };
+
+const Word16 shape2_num_coef_fx[11]= /* Q15 */
+{
+ 30760, 31, -9699, 9516,
+ -5878, -7249, -10468, 442,
+ 3278, -63, 1115
+};
+
+
+const Word16 shape2_den_coef_fx[11]= { 32767, /* Q15 */
+ 16019, -890, 12799, 2346,
+ -6985, -13192, -5795, -949,
+ -1492, -304
+ };
+
+
+const Word16 shape3_num_coef_fx[11]= /* Q15 */
+{
+ 30685, -383, -9937, -9605,
+ -5997, 7611, -10393, -355,
+ 3239, 12, 1196
+};
+
+
+const Word16 shape3_den_coef_fx[11]= { 32767, /* Q15 */
+ -16498, -911, -12947, 2286,
+ 7430, -13385, 6066, -1182,
+ 1580, -273
+ };
+
+
+
+const Word16 txlpf1_num_coef_fx[11] = /* Q13 */
+{
+ 138, 198, 514, 681, 921,
+ 964, 921, 681, 514, 198,
+ 138,
+};
+
+
+
+const Word16 txlpf1_den_coef_fx[11] = /* Q13 */
+{
+ 8192,-18945, 31613,-31149, 24494,
+ -12753, 5528, -1436, 347, -25,
+ 4,
+};
+
+
+
+const Word16 txhpf1_num_coef_fx[11] = /* Q13 */
+{
+ 138, -198, 514, -681, 921,
+ -964, 921, -681, 514, -198,
+ 138,
+};
+
+
+const Word16 txhpf1_den_coef_fx[11] = /* Q13 */
+{
+ 8192, 18945, 31613, 31149, 24494,
+ 12753, 5528, 1436, 347, 25,
+ 4,
+};
+
+/* NELP filter coefficients */
+
+/*BP1_ORDER = 7; */
+const Word16 bp1_num_coef_nb_fx_order7[8] =
+{
+ /* Q = BP1_COEF_NB_QF_ORDER7 = 13 */
+ 1481, 6730, 15579, 22923, 22923, 15579, 6730, 1481,
+
+};
+const Word16 bp1_den_coef_nb_fx_order7[8] =
+{
+ /* Q = BP1_COEF_NB_QF_ORDER7 = 13 */
+ 8192, 16156, 23814, 21855, 14620, 6614, 1907, 268,
+};
+
+
+/* NELP gain tables */
+
+const Word16 UVG1CB_WB_FX[UVG1_CBSIZE][2] = /* Q13 */
+{
+ { -2224, -2114, },
+ { 12666, 12314, },
+ { 3723, 9690, },
+ { 17880, 17978, },
+ { 4136, 3946, },
+ { 11605, 21280, },
+ { 9777, 9340, },
+ { 21701, 21627, },
+ { 1088, 1679, },
+ { 13993, 13697, },
+ { 10443, 5214, },
+ { 19702, 19692, },
+ { 5458, 5317, },
+ { 17051, 16918, },
+ { 14206, 8503, },
+ { 24330, 24271, },
+ { -118, -279, },
+ { 11615, 14863, },
+ { 6898, 6544, },
+ { 18913, 18637, },
+ { 1142, 6811, },
+ { 15995, 16070, },
+ { 6921, 13182, },
+ { 22857, 22741, },
+ { 3017, 2260, },
+ { 14952, 14992, },
+ { 8176, 8093, },
+ { 20721, 20549, },
+ { 7441, 2370, },
+ { 17897, 13988, },
+ { 10986, 10966, },
+ { 26098, 25992, },
+};
+
+const Word16 UVG1CB_NB_FX[UVG1_CBSIZE][2] = /* Q13 */
+{
+ { -4791, -5157, },
+ { 4824, 4937, },
+ { -3443, 3610, },
+ { 5539, 15293, },
+ { -469, -3986, },
+ { 7977, 8157, },
+ { 2748, 2492, },
+ { 14070, 14014, },
+ { -2486, -2863, },
+ { 6033, 5892, },
+ { 2678, -441, },
+ { 11741, 11804, },
+ { -256, -847, },
+ { 9153, 8922, },
+ { -106, 5979, },
+ { 16876, 16741, },
+ { -3584, -3873, },
+ { 3511, 9538, },
+ { 401, 416, },
+ { 11082, 10550, },
+ { -1418, -1725, },
+ { 8988, 5255, },
+ { 6275, 1137, },
+ { 15372, 15247, },
+ { -3899, 301, },
+ { 6976, 7095, },
+ { 1581, 1453, },
+ { 12988, 12824, },
+ { 2692, -3093, },
+ { 9778, 10153, },
+ { 3938, 3628, },
+ { 18823, 18695, },
+};
+
+const Word16 UVG2CB1_WB_FX[UVG2_CBSIZE][5] = /* Q12 */
+{
+ { 914, 990, 1490, 5954, 2618, },
+ { 5599, 4621, 4078, 3493, 3057, },
+ { 4930, 4031, 2999, 2150, 1706, },
+ { 7722, 3021, 1804, 1478, 1452, },
+ { 1171, 1390, 6895, 2592, 1486, },
+ { 4155, 4287, 4409, 4515, 4577, },
+ { 3633, 3661, 3694, 3711, 3736, },
+ { 13212, 5009, 2611, 2175, 2048, },
+ { 3716, 2887, 2253, 1965, 1723, },
+ { 7141, 4567, 3434, 2970, 2396, },
+ { 2856, 3038, 3259, 3481, 3709, },
+ { 5929, 5459, 4923, 4448, 4084, },
+ { 980, 1024, 1550, 5686, 8038, },
+ { 3516, 7354, 10392, 3619, 2856, },
+ { 2598, 3093, 3582, 4780, 5965, },
+ { 1962, 10993, 5020, 2861, 2587, },
+ { 796, 916, 1010, 1175, 7720, },
+ { 4445, 4406, 4344, 4249, 4175, },
+ { 1454, 6493, 2611, 1758, 1765, },
+ { 6296, 7686, 4763, 2945, 2203, },
+ { 1502, 1573, 1895, 2981, 5464, },
+ { 4750, 4829, 4909, 4929, 4895, },
+ { 3644, 3774, 3922, 4037, 4116, },
+ { 9051, 7403, 6003, 4746, 4081, },
+ { 1558, 1869, 2331, 3000, 3595, },
+ { 4671, 4646, 4614, 4553, 4482, },
+ { 2262, 2608, 3158, 3890, 4468, },
+ { 5556, 5441, 6824, 7146, 5724, },
+ { 1470, 1550, 2016, 11169, 3828, },
+ { 5488, 6270, 6771, 8202, 9281, },
+ { 3477, 3693, 4113, 4460, 4705, },
+ { 10877, 17984, 10194, 7291, 2824, },
+ { 1327, 1498, 1476, 1667, 2138, },
+ { 4463, 4299, 4094, 3880, 3731, },
+ { 3188, 3164, 3156, 3104, 3140, },
+ { 9757, 5690, 3366, 2296, 1792, },
+ { 1731, 1753, 12406, 4082, 2247, },
+ { 3866, 4060, 5007, 5274, 5225, },
+ { 3998, 3957, 3900, 3839, 3789, },
+ { 18040, 9417, 5567, 3465, 2504, },
+ { 2160, 2532, 2895, 2577, 2321, },
+ { 5052, 4789, 4490, 4203, 3953, },
+ { 3381, 3415, 3458, 3496, 3536, },
+ { 6166, 5811, 5440, 5035, 4650, },
+ { 2839, 3389, 5057, 7558, 10414, },
+ { 3875, 4431, 5183, 6310, 7166, },
+ { 4311, 4130, 3571, 3070, 8555, },
+ { 8791, 8260, 7299, 6243, 5421, },
+ { 1191, 1237, 1368, 1814, 11819, },
+ { 2486, 5729, 6150, 4222, 3667, },
+ { 4018, 3825, 3600, 3388, 3256, },
+ { 7504, 5817, 4989, 4065, 3322, },
+ { 1430, 1962, 5546, 4096, 4681, },
+ { 5393, 5378, 5324, 5230, 5052, },
+ { 4041, 4090, 4132, 4159, 4181, },
+ { 12469, 9221, 5735, 3617, 2501, },
+ { 2482, 2565, 2768, 3088, 3461, },
+ { 5209, 5080, 4905, 4706, 4522, },
+ { 3139, 3362, 3647, 3910, 4156, },
+ { 7139, 6588, 5941, 5251, 4674, },
+ { 1719, 1866, 7993, 7634, 3987, },
+ { 3587, 5289, 7882, 13519, 16095, },
+ { 2409, 2515, 2749, 7316, 4636, },
+ { 30391, 18493, 13798, 4799, 2283, },
+};
+
+const Word16 UVG2CB2_WB_FX[UVG2_CBSIZE][5] = /* Q12 */
+{
+ { 1565, 1391, 1635, 5228, 2681, },
+ { 2156, 2558, 6205, 5561, 3944, },
+ { 2039, 2406, 3094, 3409, 3968, },
+ { 5090, 5065, 4989, 4858, 4764, },
+ { 1436, 1736, 2816, 2362, 2400, },
+ { 4375, 4425, 4465, 4478, 4493, },
+ { 4648, 4081, 3550, 2981, 2667, },
+ { 1705, 1950, 3679, 7828, 9895, },
+ { 2839, 1826, 1443, 1210, 1245, },
+ { 1387, 1410, 1768, 8873, 4383, },
+ { 4022, 3784, 3565, 3316, 3096, },
+ { 9983, 7147, 5225, 3742, 3027, },
+ { 6769, 2357, 1531, 1448, 1556, },
+ { 4591, 4671, 4735, 4765, 4789, },
+ { 4308, 4198, 4052, 3896, 3769, },
+ { 2288, 2550, 4922, 8294, 14878, },
+ { 1361, 1480, 1511, 1991, 10450, },
+ { 2933, 3131, 3694, 4687, 5201, },
+ { 3984, 3048, 2479, 2644, 5514, },
+ { 5353, 5480, 5488, 5434, 5437, },
+ { 3319, 2881, 2528, 2152, 1927, },
+ { 4873, 4748, 4578, 4407, 4257, },
+ { 6185, 4396, 3751, 3400, 2899, },
+ { 2159, 8067, 7534, 5121, 3640, },
+ { 2265, 10177, 3803, 2588, 2441, },
+ { 2188, 2206, 4293, 12691, 5893, },
+ { 3587, 3651, 3760, 3864, 3960, },
+ { 13158, 9752, 7171, 5431, 5364, },
+ { 5710, 4173, 2928, 2090, 1774, },
+ { 3531, 3831, 4641, 5787, 6622, },
+ { 4395, 4356, 4281, 4194, 4111, },
+ { 2243, 2476, 5814, 3965, 27176, },
+ { 1575, 1667, 7544, 3005, 1984, },
+ { 2583, 2511, 11684, 5765, 4807, },
+ { 3632, 3458, 3277, 3114, 2971, },
+ { 8569, 6778, 5866, 5515, 5141, },
+ { 3267, 3035, 2940, 2782, 2691, },
+ { 3929, 4249, 4577, 4877, 5162, },
+ { 4443, 4173, 3864, 3590, 3337, },
+ { 3998, 4725, 5728, 6873, 7885, },
+ { 4369, 2824, 2237, 1648, 1404, },
+ { 1000, 1022, 1477, 2682, 15276, },
+ { 3916, 3851, 3766, 3664, 3591, },
+ { 13206, 4485, 3230, 3897, 3648, },
+ { 10002, 3515, 2393, 2233, 2211, },
+ { 4603, 4836, 5071, 5259, 5411, },
+ { 3919, 4035, 4177, 4304, 4419, },
+ { 3046, 8332, 16475, 11172, 10858, },
+ { 1027, 1007, 1196, 1578, 5937, },
+ { 1892, 2422, 3227, 3920, 7400, },
+ { 3584, 3532, 3508, 3470, 3437, },
+ { 5363, 6155, 6805, 6854, 6811, },
+ { 4038, 3512, 3030, 2636, 2332, },
+ { 6760, 6124, 5235, 4299, 3687, },
+ { 4125, 6528, 4068, 3238, 3483, },
+ { 5020, 5905, 7082, 8554, 9623, },
+ { 1399, 5868, 3069, 1726, 1655, },
+ { 4691, 4234, 3974, 3757, 9616, },
+ { 3978, 4003, 4003, 3983, 3960, },
+ { 2103, 16858, 9252, 4860, 4727, },
+ { 8043, 5294, 3970, 3098, 2583, },
+ { 4680, 5109, 5576, 5965, 6275, },
+ { 4867, 4584, 4276, 3958, 3682, },
+ { 1213, 3115, 6552, 22778, 20977, },
+};
+
+
+const Word16 UVG2CB1_NB_FX[UVG2_CBSIZE][5] = /* Q12 */
+{
+ { 773, 785, 785, 785, 860, },
+ { 3560, 3521, 3410, 3265, 3167, },
+ { 1766, 2982, 10273, 3790, 2248, },
+ { 4986, 4753, 4496, 4172, 3922, },
+ { 2036, 2030, 2009, 1973, 1897, },
+ { 3291, 3554, 3868, 4126, 4345, },
+ { 3207, 3122, 3026, 2913, 2797, },
+ { 13220, 6844, 3967, 2746, 2466, },
+ { 1553, 1627, 1392, 1766, 3679, },
+ { 5379, 4640, 3844, 3254, 2635, },
+ { 1600, 1622, 2430, 9446, 4214, },
+ { 5115, 5200, 5311, 5365, 5343, },
+ { 6229, 3008, 1989, 1622, 1597, },
+ { 1726, 2114, 7046, 6162, 4301, },
+ { 1004, 1056, 1841, 6006, 7101, },
+ { 6388, 9659, 4510, 2774, 2113, },
+ { 1060, 1153, 1400, 1733, 2121, },
+ { 3448, 3523, 3612, 3683, 3770, },
+ { 1496, 2045, 2910, 3563, 4058, },
+ { 4419, 4592, 4795, 4921, 4978, },
+ { 1407, 5314, 2788, 1675, 1350, },
+ { 4210, 4225, 4227, 4186, 4169, },
+ { 2247, 8245, 4392, 2522, 1709, },
+ { 7211, 6741, 6110, 5397, 4680, },
+ { 3602, 2286, 1577, 1229, 1148, },
+ { 6674, 5227, 3576, 2448, 1901, },
+ { 954, 1035, 1079, 1683, 9558, },
+ { 4011, 5853, 8979, 7138, 4484, },
+ { 2784, 2702, 2637, 2546, 2471, },
+ { 4414, 4065, 4627, 4208, 9275, },
+ { 2771, 3012, 3357, 3735, 4066, },
+ { 19742, 8603, 3943, 2546, 2085, },
+ { 1132, 1123, 1107, 1093, 1114, },
+ { 3913, 3838, 3733, 3630, 3548, },
+ { 948, 1565, 6063, 2654, 1667, },
+ { 6159, 5567, 4884, 4241, 3770, },
+ { 925, 1164, 1585, 6062, 3090, },
+ { 3818, 4037, 4322, 4536, 4726, },
+ { 4291, 3894, 3441, 3006, 2733, },
+ { 8544, 6487, 4962, 3812, 2970, },
+ { 1744, 1758, 1704, 1633, 1576, },
+ { 4416, 4259, 4044, 3810, 3628, },
+ { 1919, 2159, 3323, 13977, 7898, },
+ { 5952, 5731, 5419, 5061, 4732, },
+ { 2775, 2812, 2507, 2540, 6585, },
+ { 3436, 3960, 4661, 5975, 6274, },
+ { 3082, 3150, 3246, 3337, 3404, },
+ { 4089, 16018, 8285, 4116, 2704, },
+ { 1419, 1425, 1400, 1371, 1363, },
+ { 3825, 3890, 3953, 3993, 4015, },
+ { 2498, 2689, 2846, 3011, 3213, },
+ { 5122, 5024, 4881, 4691, 4524, },
+ { 2285, 2325, 2317, 2313, 2271, },
+ { 4493, 4529, 4517, 4478, 4443, },
+ { 9138, 3969, 2522, 2222, 2415, },
+ { 10009, 8719, 7292, 5837, 4532, },
+ { 831, 908, 1039, 1656, 6813, },
+ { 2070, 5478, 5174, 3911, 3694, },
+ { 1577, 1565, 1635, 2583, 13154, },
+ { 5590, 5788, 5922, 6752, 7063, },
+ { 4061, 3497, 2710, 2099, 1716, },
+ { 2750, 3118, 16574, 7891, 3651, },
+ { 2598, 3072, 3809, 4906, 5172, },
+ { 15348, 10948, 7740, 4979, 3446, },
+};
+
+const Word16 UVG2CB2_NB_FX[UVG2_CBSIZE][5]= /* Q12 */
+{
+ { 961, 867, 812, 771, 775, },
+ { 2544, 2686, 3010, 3605, 5048, },
+ { 1524, 1818, 2889, 3029, 3046, },
+ { 4195, 4301, 4421, 4497, 4580, },
+ { 2026, 1990, 1965, 1943, 1939, },
+ { 4338, 4156, 3963, 3750, 3590, },
+ { 7732, 2904, 1804, 1407, 1513, },
+ { 1613, 2353, 11315, 5764, 4291, },
+ { 1519, 1462, 1434, 1341, 1294, },
+ { 1627, 1710, 2163, 9654, 5615, },
+ { 2322, 7293, 3251, 2020, 2066, },
+ { 4967, 5112, 5174, 5203, 5230, },
+ { 1590, 1449, 1943, 5947, 3563, },
+ { 7747, 5170, 3268, 2392, 2082, },
+ { 3970, 3559, 3164, 2774, 2493, },
+ { 1993, 2210, 3204, 3717, 23534, },
+ { 1185, 1236, 1423, 2115, 4772, },
+ { 3935, 3840, 3714, 3583, 3477, },
+ { 1640, 1550, 1800, 2609, 10880, },
+ { 4067, 4437, 4811, 5108, 5536, },
+ { 1472, 1367, 1533, 2132, 7352, },
+ { 4310, 4284, 4216, 4117, 4057, },
+ { 10817, 4587, 2611, 2066, 2037, },
+ { 2089, 2427, 4698, 14635, 7517, },
+ { 2529, 1561, 1209, 976, 945, },
+ { 2908, 3070, 4055, 5862, 6448, },
+ { 2676, 2861, 3115, 3295, 3408, },
+ { 2932, 14330, 6533, 3739, 3462, },
+ { 3681, 3079, 2559, 2151, 1903, },
+ { 5636, 5316, 4978, 4690, 4425, },
+ { 2298, 7228, 6976, 4251, 3347, },
+ { 2504, 3421, 6784, 8483, 15064, },
+ { 1253, 1180, 1136, 1094, 1076, },
+ { 3451, 3524, 3600, 3646, 3707, },
+ { 1701, 2030, 6574, 4746, 4451, },
+ { 4688, 4751, 4762, 4727, 4722, },
+ { 2977, 2363, 1883, 1563, 1399, },
+ { 5080, 4685, 4275, 3835, 3513, },
+ { 5445, 3828, 2851, 2242, 1948, },
+ { 1929, 5037, 17760, 8346, 6300, },
+ { 1839, 1782, 1680, 1586, 1534, },
+ { 3086, 3472, 4031, 4950, 9695, },
+ { 3199, 3052, 2896, 2751, 2622, },
+ { 5822, 5782, 5727, 5566, 5478, },
+ { 1548, 2234, 6748, 2562, 1722, },
+ { 6699, 5216, 4475, 3531, 3028, },
+ { 3773, 3628, 3460, 3279, 3155, },
+ { 1581, 1672, 2929, 20221, 16432, },
+ { 1210, 1215, 1389, 1678, 2177, },
+ { 3863, 3886, 3937, 3961, 3989, },
+ { 1541, 1745, 1829, 3479, 15563, },
+ { 4444, 4952, 5573, 6056, 6545, },
+ { 2460, 2397, 2284, 2133, 2041, },
+ { 4808, 4676, 4493, 4322, 4213, },
+ { 15031, 6644, 3315, 2900, 2885, },
+ { 4003, 4760, 6946, 8274, 8401, },
+ { 5001, 2495, 1594, 1337, 1365, },
+ { 3428, 3706, 4073, 4457, 4670, },
+ { 3326, 3277, 3222, 3142, 3088, },
+ { 6162, 6317, 6494, 6459, 6530, },
+ { 2659, 2599, 2537, 2482, 2546, },
+ { 8554, 6902, 5233, 4116, 3650, },
+ { 4643, 4099, 3616, 3201, 2895, },
+ { 9589, 26630, 15412, 12532, 8715, },
+};
+
+
+const Word16 frac_4sf_fx[NB_SUBFR+2]= {4,8,12,16,16,16}; /* Q4 */
+
+/* ERB table for PPP-ampl-quant */
+
+/* ERB table for PPP-ampl-quant */
+const Word16 erb_WB_fx[NUM_ERB_WB+1]= {0, 238, 475, 713, 950, 1188, 1426, 1663, 1911, 2185, 2490, 2826, 3205, 3624, 4094, 4620, 5210, 5875, 6626, 7478, 8448, 9558, 11264, 13568, 16387};
+
+
+/* ERB table for PPP-ampl-quant */
+const Word16 erb_NB_fx[NUM_ERB_NB+1]= {0, 238, 475, 713, 950, 1188, 1426, 1663, 1911, 2185, 2490, 2826, 3205, 3624, 4094, 4620, 5210, 5875, 6626, 7478, 8448, 9558, 10243};
+
+
+const Word16 AmpCB1_WB_fx[640] =
+{
+ 5655, 1589, -653, 3568, -3173, -1852, -3204, -4623, -2100, -5103,
+ -923, -67, -7152, -4958, -2019, -1810, -8532, -648, 6581, 8043,
+ 160, 778, -1535, 863, 5482, 1674, -3576, 123, -3163, -3595,
+ -852, -53, -1080, -2683, -3199, -950, -1353, 6258, -1431, 1249,
+ 2059, 677, 146, 1011, 956, -2022, -25, 300, 421, -5859,
+ 1027, -452, -7343, -1052, 3818, 1099, -1005, 659, -511, -658,
+ 2091, 720, -600, 145, -1504, -1716, -442, -2172, -1505, 2702,
+ 731, 1473, -213, -4120, -2976, 688, 3205, 1213, 679, 232,
+ 3672, 4770, -1198, -298, -1714, -3669, -2833, -664, -1859, -2380,
+ -1169, -1593, -453, 295, -1225, -3110, -1776, 2112, 2710, 3333,
+ 1022, 1248, 1091, 1164, 1200, 1782, -809, -2306, -3124, -2194,
+ -1567, 465, 2223, -1301, -463, -2157, 729, 2279, -1938, 610,
+ 437, -803, -1025, 775, -171, -637, 163, 2251, 316, -1663,
+ -4123, -20, -2827, -1529, -1436, 3447, 79, -274, 1650, 4097,
+ 2369, 927, 448, -449, 293, -239, -1028, -4805, 1354, 431,
+ -2219, -490, -3849, 1639, -2925, 817, 1485, 2527, 5444, -1994,
+ 1476, 506, -1643, 2003, -1676, -788, -1681, -2011, 1389, 452,
+ 593, 3, -1200, -3987, -1634, -4310, -686, 882, 6235, 2420,
+ -196, -1257, -2038, -498, 1394, 671, -2302, -809, -446, 3644,
+ -1643, -2304, -828, 105, -323, -3906, -960, 7324, 3095, -786,
+ 95, 633, 1266, 750, 1509, -2033, -3134, 432, 1028, -1825,
+ 1258, 256, -3249, -6868, -523, -325, -1779, 4313, 2524, 3433,
+ -600, -410, -88, 410, -1182, -1140, -1448, -1344, -5074, 6054,
+ 2194, 1505, -681, -2408, 1376, 1389, 1209, 1048, -4199, -2939,
+ 1855, 1744, -1344, -1431, -1955, -1805, -4992, 512, 624, 2749,
+ -3446, -1215, -3764, -2169, -3601, -1321, 67, 4326, 6624, 5816,
+ -334, -1746, -441, -754, 1853, 3889, -595, -493, 441, -811,
+ -48, -764, -1473, -683, 603, -1754, 780, 698, 1084, 1713,
+ 560, -808, -754, -2890, -1205, -318, -1021, 3195, 5693, -4603,
+ 1343, -1061, -2441, -1784, 721, 267, 227, -622, 3013, -768,
+ -472, 90, 13, 290, 1055, 948, 1617, -2368, -1087, 1103,
+ -4784, -3872, 5125, -2518, -215, 6962, 1095, -1521, 2091, -2962,
+ 2285, 1117, 1174, 2635, -1907, -1012, 814, -417, -2162, -2805,
+ -1188, -707, -808, -1757, 260, -1093, -3957, -3266, 4132, 5980,
+ 177, -1478, 960, 2029, 3989, 597, -3062, -3940, -1688, 236,
+ -1559, 150, 2432, 348, -242, -2014, -1027, 6298, -2957, -3960,
+ 1090, 1014, -1261, -744, -954, -938, -3713, -3272, 5356, -2356,
+ -1439, 3808, -2330, -4437, 5177, -3606, -1382, 1824, 407, 325,
+ 649, 330, 85, 206, -415, 183, -646, 602, -2656, 808,
+ 1039, 29, -3202, -6168, -3640, 3736, 4183, 3959, 330, 339,
+ 2701, 343, 1501, 1879, -3194, -4648, -1630, 1656, -1578, -84,
+ -3065, -4126, 24, -260, 263, -1705, -1289, 2432, 1229, 7481,
+ 2586, 1696, 646, -1773, -792, 1932, -1908, -1897, -1129, 112,
+ -5667, -1592, 2253, -980, 1581, 211, 5277, 4846, -288, -159,
+ 956, 1196, 771, -973, -1785, -516, -1015, 847, 614, -791,
+ -442, -1594, -4632, -4392, -416, 1398, 2570, 752, 264, 6570,
+ 1655, 546, 1238, -1362, -1330, -2005, 3590, -2155, -184, -1224,
+ -1452, -1533, -534, 1010, -1707, 801, 3628, -289, 2414, 132,
+ 2643, -2813, -4524, 5092, -7362, 740, 428, -510, 81, -1209,
+ 616, 1454, 1861, -3958, -4084, 189, -1219, -875, 3764, 2086,
+ -1554, -2071, 1515, 3392, 12, -686, -2414, -1382, 176, 1685,
+ 2055, -5698, 1582, 4117, -4846, -2922, 610, 2082, 4682, -2487,
+ 348, 2258, -338, -1379, 1472, 618, -202, -1122, -76, -2468,
+ -1216, -986, -327, -1441, 102, 403, -2105, 2411, 1510, 1288,
+ -715, -577, 1074, 2533, -3521, -3449, 2140, -751, -307, 3805,
+ 158, -1385, -404, -1378, -1948, 3785, 4216, 2667, -1894, -1559,
+ 1037, 1371, 989, -205, -333, -4784, -3429, -1283, 3299, 859,
+ -4922, -5481, -1196, -1748, -720, 516, 113, 4590, 7071, 4345,
+ -5729, -3862, 3590, 1463, 7094, 4991, 854, -66, -1630, -686,
+ -923, -3266, -1988, 2345, 785, -1420, 3004, 2934, -1245, -65,
+ -2696, -3088, -1438, 614, 1584, -239, -1552, 580, 6285, -1673,
+ -1598, -4018, -1909, 747, 3191, 366, 1467, -1933, 2759, 2804,
+ 518, 193, -1149, -3108, 441, 1458, 2791, -4131, 2694, 3372,
+ -5023, -6491, 1794, 2739, 1463, 5843, 2869, 1993, -1409, 4832
+};
+
+const Word16 pwf78_fx[17]= { 25559, 19936, 15550, 12129, 9460, 7379, 5755, 4489,
+ 3501, 2731, 2130, 1661, 1296, 1011, 788, 615,
+ 479
+ }; /* 0.78^i (i=1,...,17), Q15 */
+
+
+
+
+const Word16 AmpCB2_WB_fx[64*(NUM_ERB_WB-13)]=
+{
+ -5276, -7711, -3518, -2416, -382, 319, -1900, -900, 1725, 884,
+ 4071, -4052, -2430, -336, 2136, 3006, 591, -3893, -2731, 2625,
+ 2390, -1047, -883, -3368, -4235, -3726, 189, -1803, 784, 2336,
+ 206, -2140, 3001, -730, -2279, 85, -3395, 4367, 2214, -254,
+ -3114, -2348, 2763, 686, -7495, -6618, 3164, -3957, -2681, -2049,
+ 1659, 3634, 2962, 1574, 379, -2478, 2861, 616, 1124, 205,
+ -3075, -348, -2006, -90, 761, 1157, -114, -9460, -2786, -3254,
+ -1120, -1500, -446, 2835, -314, 3205, 2115, -837, -261, 36,
+ 80, -485, 1133, 2124, -1031, -401, -3166, 1145, -1616, -3425,
+ -3071, -6891, -4198, 2292, 5160, -46, 1430, 280, 1378, 1700,
+ -1673, -1126, 5270, 5096, -975, -1070, 1314, -2389, -2982, 20,
+ -3218, -892, -636, -876, -302, -2923, -3240, 4121, 1625, -557,
+ 994, 544, 2657, 7133, -273, -3530, -1419, 1431, -936, -2622,
+ 303, 75, -5444, -5549, 4183, 1248, 3474, -789, 2375, -1778,
+ 1660, 1520, -1433, -4047, 531, 7001, 695, 1889, 4261, -2791,
+ -1557, -2980, -316, 415, 1134, 1501, -6923, 521, -3134, -1812,
+ 1848, 676, -1733, 734, 2207, 2029, -476, -1976, -161, 29,
+ 7147, -1774, 720, -1070, -372, -1626, -6473, -2448, -5235, -2651,
+ -1800, -1477, -767, 1335, 471, 4857, 888, 593, -370, 196,
+ 907, 174, 557, -720, -1339, 1590, 37, -1247, -1307, 276,
+ -1739, -6032, -3088, -2499, -497, -393, -569, 3003, 2694, 3751,
+ 4652, -258, -1305, 175, 189, -344, -2381, -1992, 463, 529,
+ -6375, 3966, -3558, -3001, -640, 3117, 1120, 966, 1316, -561,
+ 27, 2794, 2831, 3512, 3453, -418, -2319, -6741, -3443, 80,
+ 1281, 1691, 1500, -591, -739, 2385, -4676, -5822, -1437, 730,
+ 3593, -437, 1090, 3497, -1932, 2854, 4858, 2654, 947, 1879,
+ -4115, 2700, -3092, -1524, 225, -8272, -6736, -1277, 2991, 2983,
+ 1129, -1661, 2817, 468, 491, -744, 390, 677, 8129, -3130,
+ -687, -433, 1488, -3763, -177, -581, -764, 39, 1537, -2203,
+ -1678, 263, -1214, 2175, -1857, 3097, -894, 4207, -1943, -834,
+ 1513, -4123, 3981, 6041, 653, -757, -313, -3024, -4614, -3139,
+ -2966, 178, 4956, -427, -41, 2376, 1008, -1351, -92, 978,
+ 1998, 5146, 2069, 117, -1754, -2756, 4425, 168, -1807, -1761,
+ -1215, 178, -1562, -3369, -919, -2576, 3614, 4968, -30, -396,
+ -1151, -1146, 868, 1073, -359, 2732, 546, 4431, -321, -1081,
+ 1410, -3214, -2316, -4889, -2460, -3844, -7323, -1438, -1488, 1849,
+ 4037, 2421, 2697, -2372, -1877, 670, 3674, -907, 888, -3703,
+ 375, -1278, -1477, 2501, -936, -1682, -1353, -335, -4440, 383,
+ -2730, -2130, -1105, 1588, 3340, 4816, -4023, 502, -4146, 236,
+ 4481, 589, -3696, 826, -97, 222, -8037, -2244, 142, 810,
+ -2195, 1315, 656, 1901, -485, 317, 1512, 1465, -2026, 1853,
+ 929, 1670, -2736, -463, -836, -4946, -134, 2769, 2972, -5148,
+ -3147, 913, -1483, 267, -1560, 3903, 1507, 1105, -1496, 210,
+ -1196, 3764, 601, 1630, 3842, 6374, -1293, -4555, -3087, 199,
+ -1917, -3331, -2317, -1774, 479, 3712, 2729, 1309, -3047, -514,
+ 861, -213, 1317, -2035, 4369, 5228, 942, -3052, -2316, -3377,
+ 1123, -65, 2507, 2711, -2096, -2164, -2634, -5215, -3919, 1551,
+ -47, 1990, 2370, 2025, -2401, 4833, -3879, -162, -3081, 501,
+ -510, 2744, -907, 253, -1746, -2520, 3418, -1461, 2140, 2507,
+ 135, 1457, 3195, -1277, -2558, -66, 10850, -1633, -1051, -3436,
+ -1617, 1438, -1231, -1744, 696, -348, 3434, 2121, -1629, -2460,
+ -4065, 1159, -1288, 2843, 697, -862, 4, 966, -444, -1860,
+ 1450, 6426, 5544, 1456, -2826, -1303, -2778, -1278, -6656, -3241,
+ -7083, 2234, 204, 1753, 803, 499, 1641, 87, 1471, -1325,
+ 398, 2983, 4340, -1382, 735, -600, -4671, -254, 2327, -1008,
+ -144, -1453, -1806, -1669, 395, -3285, -1803, -2119, 1232, 2914,
+ 1480, 8610, 1788, 2644, 1359, 3783, -110, -1339, -1337, -3427,
+ -630, -1189, -2560, 976, 483, -2744, -3653, -1289, 2910, -2437,
+ 3171, 1479, 157, 823, 4631, -1910, 3736, -424, -155, -5470,
+ -741, 3829, -2794, -55, -1447, -3469, -1947, 2914, -61, -3430,
+ 3544, -1867, 2986, 1009, -1051, 725, 2933, 2926, 5849, 257,
+ -2666, 6286, -2282, -2998, -2576, -975, -3655, -1867, -5040, -1440,
+ 3542, -603, 4806, -2808, -1633, 1388, 1149, -1616, -1851, 2122,
+ 4477, 2485, 1376, 721, 2174, -3072, 1378, -2574, -37, 1322,
+ -1646, -3612, 4443, 1612, -3403, 711, 132, 119, -227, 5059,
+ 2892, 840, 5462, -3471, -1340, 2097, 143, 1750, -3052, -1932,
+ -6352, -4166, -645, 4317, 633, 3681, 2811, 2346, 2374, -2999,
+ -1265, -210, 5115, 4652, 1305, 3704, -1456, -307, -457, -1455,
+ -3580, 674, 2215, 2458, -3021, -66, 2535, -652, 1226, 685,
+ 875, -1753, -1164, -609, 3444, 563, 3826, 1607, 3798, 1385,
+ 3902, -1990, -4078, -2509
+};
+
+
+const Word16 AmpCB1_NB_fx[640] =
+{
+ -1355, 185, -222, -221, 1976, 3119, 540, 1333, -3646, -2511,
+ -979, 1664, 2087, 951, 787, -1687, -855, 1594, 1264, -4990,
+ -1957, -215, -850, 1369, -113, 2541, -2904, 743, 634, -657,
+ -3438, -2047, 706, 85, -596, -50, 212, 944, 118, 1380,
+ -1203, -78, -213, -1811, -781, -1970, 6607, -2971, 147, -1483,
+ 38, 5607, 5222, -4567, -4040, -2259, -3110, -2120, 932, -236,
+ -1052, 1039, -872, 334, -919, 2761, 3320, -5828, 53, 1063,
+ -1064, -75, -1015, -2137, -722, 565, 629, 1961, -454, 866,
+ -888, 2652, 1996, -2170, -885, 3325, -645, -1898, -984, -643,
+ -1008, 2472, 2400, -3708, -2408, -1051, 2029, 1357, -636, -470,
+ -1307, 655, 663, 29, 892, -95, -91, -2966, -1610, 2657,
+ -2175, -3170, -3799, -3065, 1130, 1351, 3814, 2791, 1478, 1520,
+ -1326, -520, -692, 899, 1979, -397, -407, 450, -569, -611,
+ -1228, 864, 2549, 3067, -2511, -4737, -2701, -304, 680, 1426,
+ -1070, -19, -1582, -2813, -1832, 3010, 250, -613, 3390, -171,
+ -1450, -417, -773, -651, -405, -2304, -780, 6656, -3270, -1322,
+ 70, 5105, 3202, -83, -925, -458, 1203, -1582, -4158, -3630,
+ -1702, -849, -55, -986, -1963, -1140, -1942, 3347, 3526, -435,
+ -1429, -2089, -1620, -1271, 2851, 2184, -2472, 3216, 2885, -2922,
+ -1217, 86, -186, -279, -746, 1288, 3016, -651, -2719, 317,
+ -1307, -127, -1110, 1389, 212, 1783, 2619, -1718, 1795, -4086,
+ -1295, 743, 301, -1823, -223, -651, -1774, -405, 1687, 2031,
+ -865, 1059, -391, 505, -2739, -2773, 16, -2960, 3071, 3325,
+ -791, 2301, 435, 107, -4039, 801, -1224, 1854, -1039, 507,
+ -518, 997, 837, 3311, 506, 1026, -232, -1920, -3904, 406,
+ -1857, -529, -776, -700, -663, -1520, 1699, 814, 2084, -477,
+ -1341, -1123, -2564, -2784, 2457, 3223, -959, 385, -1864, 3754,
+ -1351, -1347, -2229, -2882, -1061, -1499, -3028, 3302, 2250, 5539,
+ -957, -340, 27, 1508, 167, -3513, 1689, 2577, -1810, -516,
+ -1061, 2171, 1774, 2031, 923, -1933, -1640, -2881, 859, -834,
+ 408, 2462, 2073, 2107, -2671, 1140, -3497, -2497, 2984, -2707,
+ -1762, -2524, -2196, 279, -2580, 477, 2306, 4645, 693, -909,
+ -1089, 1952, 3034, -1790, 786, -1149, -3117, 3605, -1933, -1886,
+ -959, 934, 246, -2177, -2440, 1356, 871, 3472, 2558, -4512,
+ -782, 1262, 893, 1979, 2386, -1809, -4357, -392, -1928, 1576,
+ -1751, -327, -1018, -617, -2370, -2910, 4230, -90, -1361, 3596,
+ -1069, -315, -162, -339, -313, 33, 4684, 2811, -2717, -3684,
+ 695, 4567, -745, -2311, -776, -2600, -827, -1040, -997, 2480,
+ -1549, -748, -622, -260, 1460, 1116, -302, -2529, 2156, -42,
+ -1318, -568, -266, -446, -2212, 2690, -4669, 5325, -2022, 1358,
+ -1312, 2293, 1528, 706, 970, -291, 383, -683, -1532, -1843,
+ -1379, 845, 1218, 395, -1884, 14, 676, -1711, 795, 290,
+ -742, 386, -435, 411, 1311, 549, -4181, -4922, 1497, 4465,
+ -1722, -699, -1958, -4126, -3727, -655, 1553, 1793, 4933, 3055,
+ -1260, -618, 535, -2008, 3802, -3784, 2527, -833, 193, -1062,
+ -866, 823, 1562, 147, -623, -1808, -1099, 694, -577, 745,
+ -2282, -4139, -3171, 76, 25, -1077, 477, 545, 6081, 3244,
+ -1332, -785, 98, -1681, -3603, -3937, 524, 4648, 1114, 2547,
+ -1145, 407, 2030, 3120, -1739, -513, -518, 1325, -1700, -2860,
+ -1427, 520, -1040, -792, -366, -2174, -522, -240, 5660, -3163,
+ -1449, -1653, -1507, 581, 1338, -2627, -1863, 1831, 1301, 2106,
+ -1252, 974, 199, 68, -69, -869, 864, 2373, -5818, 2873,
+ 26, 972, 359, -561, -390, 376, 225, 517, 649, -1767,
+ -653, 2167, 882, -698, 214, -4084, -4134, 2092, 2798, -523,
+ -1002, 486, 648, -1082, 404, -1490, 1560, -4984, 5614, -1441,
+ -1024, -311, 427, 356, -2342, 215, -2312, 445, -2378, 5111,
+ -568, 85, 1328, 1847, 3506, 1183, -2521, -2070, -794, -1881,
+ -485, 1121, 1242, 1301, -4365, -2222, 2602, -387, 1498, -1344,
+ -1272, -1365, -2207, -213, -1877, 2858, 849, -915, 333, 2488,
+ -2019, -2048, -1461, -1930, -1409, -400, 490, -2222, 1276, 7305,
+ -1530, -1741, -2663, 3159, 1162, -1490, 1516, -1498, 1222, 838,
+ 1325, 5387, 3888, 1944, -1706, -2890, -1905, -3901, -3207, 206,
+ -1411, -959, -292, -396, -1547, -84, -4405, -1073, 5532, 1796,
+ 3160, 48, -2339, -5884, -184, -52, 129, 5398, 378, -321
+};
+
+const Word16 AmpCB2_NB_fx[64*(NUM_ERB_NB-13)]=
+{
+ -2681, -4389, -4270, -4727, -239, 1938, 1748, 2311, 4300, -3957,
+ -1299, 3487, 1595, -377, 295, -1193, -1588, 2112, -1573, -6362,
+ -504, 1796, -2521, -68, 1322, 1223, 2263, -503, -3906, 3686,
+ -3899, -139, 2086, 48, 349, 547, -6387, 1340, -1467, -1062,
+ -193, 1325, -1190, 2394, 1671, -1982, -2597, -390, -1504, 2271,
+ -379, -2350, 4071, 70, -955, -883, -1770, -1065, -2443, -1779,
+ -1101, -661, 6325, 1871, -2673, 3596, 3773, -681, 3340, -1418,
+ 701, -4253, -3931, -1840, -2388, -2677, -3545, -41, 3675, 3843,
+ 2198, -1713, -324, 599, 1323, 1827, -4909, -1668, 616, 2608,
+ 360, -1769, -5263, -1278, 3490, 1935, 1355, -1298, 952, 1801,
+ 449, 251, -1021, -3666, 479, 3497, 1542, -2234, -3414, -4483,
+ -5785, 1406, 1207, 2984, 1767, 3262, -799, -3124, 5237, 460,
+ 2007, -1525, -2106, -770, 546, 137, 401, -1308, 969, 204,
+ -1626, -589, -4257, 1744, 2836, 2383, 2740, -423, 3166, 1920,
+ -690, -3000, -4489, 2523, -6693, -5135, -739, -1919, 1228, 2354,
+ 3340, 1902, 1069, -3185, -2614, 2764, -212, -2061, -1377, 698,
+ 3694, -125, -954, -4132, -404, 4297, 1294, 1765, 2446, -2287,
+ -1387, -14, 508, 1149, 9, -437, 519, -420, 450, -751,
+ -1632, -1391, -2208, -1955, -1170, 4818, 1112, 1086, -782, 1337,
+ 846, -3434, 569, 1721, -776, -2723, 1207, 982, -1432, -887,
+ 315, -3031, 3452, 765, -1263, -2146, 2959, -2619, 1507, 1312,
+ 4087, 3125, 1637, -1402, -45, -3193, 1397, -2611, -3641, -2478,
+ -1706, 588, 199, 3721, 1217, -1249, -1196, 7228, 996, 879,
+ -1339, 11, -971, -1680, 716, -39, 233, 1945, 1548, -1476,
+ 550, -2277, 307, 7413, 2094, -1631, -569, -1351, -198, -483,
+ -515, -1347, -212, -2649, -519, 195, 2944, -795, 1470, 654,
+ -1448, 3156, 1369, 3966, 3382, -2782, -4255, -1157, -212, 392,
+ 861, 5064, 4740, -2513, -3413, -552, -2298, -575, 1130, 1178,
+ 1568, 4591, 1238, 367, 1626, 600, -5889, 163, -3742, -3650,
+ -3911, 716, 919, -1501, 55, 1807, 3801, -5571, -4635, 1225,
+ 3211, 3804, 1491, -906, 100, 404, -1742, -1878, -2140, 1651,
+ 1640, 3976, -3432, -1149, 1365, 2042, 392, 768, -1534, 1096,
+ 3811, -211, -2067, -1315, -4167, 1145, -2747, -149, 5296, -735,
+ 438, 56, -404, -159, -2164, -959, 3492, -690, -688, -1081,
+ 2762, -1191, 654, 2051, -2144, -3210, -1823, 743, 686, -751,
+ 2483, 160, 1279, 3246, 1874, 2488, 1192, -5977, -478, 120,
+ -349, -65, -2350, -222, -1678, -3584, 1114, 3269, 1462, -1114,
+ -138, 2360, -2762, 720, -3822, 2523, 216, 1170, 4398, -4229,
+ -1850, 1272, 383, 1736, -383, -1295, 85, -132, 1133, 1505,
+ 1467, -2389, -2175, 4028, -2752, 241, -4353, -2103, -562, 817,
+ 3959, 5471, 1941, -1598, -2349, 201, 1412, -796, 2791, -4226,
+ 3227, -1992, -159, -159, 4085, -1549, 1020, -2179, -776, -2088,
+ -147, -42, 1880, -1029, 4982, -2056, 111, 1420, 2141, 302,
+ -2574, -986, -477, -3697, -2349, -2064, -335, -220, 5857, 57,
+ -7, -5407, -546, -353, 2866, 137, -136, 3508, 992, -2059,
+ -2034, -1127, -189, -300, -2153, 3606, 2523, -3727, 1526, -3797,
+ 2134, 4352, -920, -459, 2722, 1784, -71, -3030, -877, 1967,
+ -1645, -4432, 512, 39, 1757, 2875, -947, 1842, 1365, 1500,
+ 851, 594, -2892, -404, 3327, -3078, -1575, -1258, -973, -191,
+ -390, 45, 627, -227, 1624, -143, 215, 2157, 4846, 5335,
+ 3397, -199, -4443, -3091, -283, -216, 1237, -1478, -5639, -775,
+ 525, 2107, 2469, 2934, -255, 2438, 824, 5973, -1820, -1330,
+ -1202, -2433, 900, 650, -5654, 2891, -1539, -453, 1662, 231,
+ -145, 1661, 741, -332, 1221, 1809, 943, 4831, -1588, -4619,
+ 65, -790, -985, -893, 3374, 3148, 289, 2947, -4980, -661,
+ -427, 1441, 7696, 158, -1914, -2069, -1717, -418, 2657, 4219,
+ 1505, -1096, 601, -1466, -1754, -479, -159, 3378, 5252, 5060,
+ 4001, 1301, 420, -1268, -2813, -4196
+};
+
+const Word16 PowerCB_WB_fx[128] =
+{
+ -3371, -1712,
+ -170, 350,
+ -638, -939,
+ 56, 1074,
+ -1559, -626,
+ 200, 344,
+ -397, 238,
+ 284, 1415,
+ -1323, -1880,
+ -544, 1170,
+ -619, -255,
+ 587, 974,
+ -1262, -98,
+ 327, 151,
+ 41, -302,
+ 941, 1876,
+ -2257, -1233,
+ 28, 202,
+ -520, -561,
+ 338, 1048,
+ -1080, -495,
+ 190, 582,
+ -284, -24,
+ 578, 1585,
+ -1324, -1089,
+ -71, 568,
+ -471, -26,
+ 1140, 909,
+ -856, -128,
+ 425, 740,
+ 140, 12,
+ 1595, 1891,
+ -2176, -2310,
+ -308, 541,
+ -315, -859,
+ -80, 1314,
+ -1782, 510,
+ 403, 450,
+ -607, 582,
+ 145, 1837,
+ -920, -1386,
+ -225, 872,
+ -395, -258,
+ 829, 981,
+ -945, 345,
+ 643, 241,
+ -56, -23,
+ 1211, 1482,
+ -1793, -1459,
+ 40, 400,
+ -239, -471,
+ 532, 1238,
+ -774, -516,
+ 244, 831,
+ -157, 152,
+ 576, 2287,
+ -928, -844,
+ 41, 759,
+ -161, -198,
+ 873, 1353,
+ -640, 105,
+ 695, 623,
+ 364, -184,
+ 1238, 2446
+};
+
+
+
+const Word16 PowerCB_NB_fx[128] =
+{
+ -3349, -2784,
+ -784, 385,
+ -891, -562,
+ 126, 915,
+ -1518, -1438,
+ 304, 53,
+ -314, -447,
+ 687, 1219,
+ -2585, -1807,
+ -65, 153,
+ -1219, -337,
+ 497, 700,
+ -894, -1051,
+ 161, 451,
+ -46, -516,
+ 987, 1519,
+ -2277, -2303,
+ -354, 445,
+ -532, -540,
+ 5, 1271,
+ -1047, -1433,
+ 672, -225,
+ -335, -75,
+ 1007, 1056,
+ -1362, -1879,
+ -93, 367,
+ -468, -259,
+ 1800, -290,
+ -1118, -793,
+ 412, 472,
+ -9, -197,
+ 1471, 1634,
+ -2627, -2847,
+ -269, 164,
+ -689, -373,
+ 432, 940,
+ -1601, -839,
+ 311, 271,
+ -212, -251,
+ 543, 1714,
+ -2014, -1336,
+ 109, 241,
+ -789, -110,
+ 729, 888,
+ -418, -1277,
+ 256, 674,
+ 218, -217,
+ 1027, 2065,
+ -1769, -2293,
+ -276, 853,
+ -360, -764,
+ 376, 1247,
+ -1274, -1122,
+ 602, 272,
+ -133, -32,
+ 1374, 1118,
+ -1860, -1795,
+ -23, 620,
+ -525, 60,
+ 1070, 548,
+ -691, -799,
+ 701, 572,
+ 81, 18,
+ 1949, 2120
+};
+
+
+const Word16 sinc_fx[8][12]= /* sinc for warp/extrapolate, in Q14 */
+{
+ {0,0,0,0,0,16384,0,0,0,0,0,0,},
+ {-388,484,-638,939,-1773,15966,2281,-1063,694,-514,409,-339,},
+ {-701,868,-1134,1639,-2949,14751,4917,-2106,1341,-982,776,-640,},
+ {-895,1101,-1427,2029,-3503,12849,7709,-2964,1835,-1328,1042,-856,},
+ {-947,1159,-1489,2086,-3476,10430,10430,-3476,2086,-1489,1159,-947,},
+ {-856,1042,-1328,1835,-2964,7709,12849,-3503,2029,-1427,1101,-895,},
+ {-640,776,-982,1341,-2106,4917,14751,-2949,1639,-1134,868,-701,},
+ {-339,409,-514,694,-1063,2281,15966,-1773,939,-638,484,-388,},
+};
+
+
+const Word32 inverse_table[]=
+{
+ 0,
+ 134217728, 67108864, 44739242, 33554432, 26843545, 22369621, 19173961, 16777216, 14913080, 13421772, 12201611, 11184810, 10324440, 9586980, 8947848, 8388608, 7895160, 7456540, 7064090, 6710886, 6391320, 6100805, 5835553, 5592405, 5368709, 5162220, 4971026, 4793490, 4628197, 4473924, 4329604, 4194304, 4067203, 3947580, 3834792, 3728270, 3627506, 3532045, 3441480, 3355443, 3273603, 3195660, 3121342, 3050402, 2982616, 2917776, 2855696, 2796202, 2739137, 2684354, 2631720, 2581110, 2532409, 2485513, 2440322, 2396745, 2354696, 2314098, 2274876, 2236962, 2200290, 2164802, 2130440, 2097152, 2064888, 2033601, 2003249, 1973790, 1945184, 1917396, 1890390, 1864135, 1838599, 1813753, 1789569, 1766022, 1743087, 1720740, 1698958, 1677721, 1657008, 1636801, 1617081, 1597830, 1579032, 1560671, 1542732, 1525201, 1508064, 1491308, 1474920, 1458888, 1443201, 1427848, 1412818, 1398101, 1383687, 1369568, 1355734, 1342177, 1328888, 1315860, 1303084, 1290555, 1278264, 1266204, 1254371, 1242756, 1231355, 1220161, 1209168, 1198372, 1187767, 1177348, 1167110, 1157049, 1147160, 1137438, 1127880, 1118481, 1109237, 1100145, 1091201, 1082401, 1073741, 1065220, 1056832, 1048576, 1040447, 1032444, 1024562, 1016800, 1009155, 1001624, 994205, 986895, 979691, 972592, 965595, 958698, 951898, 945195, 938585, 932067, 925639, 919299, 913045, 906876, 900790, 894784, 888859, 883011, 877240, 871543, 865920, 860370, 854889, 849479, 844136, 838860, 833650, 828504, 823421, 818400, 813440, 808540, 803698, 798915, 794187, 789516, 784898, 780335, 775825, 771366, 766958, 762600, 758292, 754032, 749819, 745654, 741534, 737460, 733430, 729444, 725501, 721600, 717741, 713924, 710146, 706409, 702710, 699050, 695428, 691843, 688296, 684784, 681308, 677867, 674460, 671088, 667749, 664444, 661171, 657930, 654720, 651542, 648394, 645277, 642190, 639132, 636102, 633102, 630130, 627185, 624268, 621378, 618514, 615677, 612866, 610080, 607320, 604584, 601873, 599186, 596523, 593883, 591267, 588674, 586103, 583555, 581029, 578524, 576041, 573580, 571139, 568719, 566319, 563940, 561580, 559240, 556920, 554618, 552336, 550072, 547827, 545600, 543391, 541200, 539027, 536870, 534731, 532610, 530504, 528416, 526344,
+};
+
+
+const Word16 W_DTX_HO_FX[HO_HIST_SIZE] = /* Q15 */
+{
+ 6554, 5243, 4194, 3355, 2684, 2147, 1718, 344
+};
+
+const Word16 HO_ATT_FX[5] = /* Q15 */
+{
+ 17597, 20205, 22410, 23198, 23198
+};
+
+/*----------------------------------------------------------------------------------*
+ * SWB HR BWE
+ *----------------------------------------------------------------------------------*/
+
+const Word16 wscw16q15_fx[240] =
+{
+ -32768, -32766, -32764, -32759, -32754, -32747, -32738, -32729, -32717, -32705, -32691,
+ -32675, -32658, -32640, -32621, -32600, -32577, -32553, -32528, -32501, -32473, -32444,
+ -32413, -32381, -32348, -32313, -32276, -32239, -32200, -32159, -32117, -32074, -32029,
+ -31984, -31936, -31887, -31837, -31786, -31733, -31679, -31624, -31567, -31508, -31449,
+ -31388, -31326, -31262, -31197, -31131, -31063, -30994, -30924, -30853, -30780, -30705,
+ -30630, -30553, -30475, -30395, -30315, -30232, -30149, -30064, -29979, -29891, -29803,
+ -29713, -29622, -29530, -29436, -29341, -29245, -29148, -29049, -28949, -28848, -28746,
+ -28642, -28537, -28431, -28324, -28216, -28106, -27995, -27883, -27770, -27655, -27540,
+ -27423, -27305, -27186, -27066, -26944, -26821, -26698, -26573, -26447, -26320, -26191,
+ -26062, -25931, -25800, -25667, -25533, -25398, -25262, -25125, -24986, -24847, -24707,
+ -24565, -24423, -24279, -24135, -23989, -23843, -23695, -23546, -23397, -23246, 23095,
+ 22942, 22788, 22634, 22478, 22322, 22164, 22006, 21846, 21686, 21525, 21363,
+ 21199, 21035, 20871, 20705, 20538, 20371, 20202, 20033, 19863, 19692, 19520,
+ 19347, 19174, 18999, 18824, 18648, 18472, 18294, 18116, 17937, 17757, 17576,
+ 17395, 17213, 17030, 16846, 16662, 16477, 16291, 16105, 15917, 15730, 15541,
+ 15352, 15162, 14972, 14781, 14589, 14397, 14204, 14010, 13816, 13621, 13426,
+ 13230, 13033, 12836, 12639, 12441, 12242, 12043, 11843, 11643, 11442, 11241,
+ 11039, 10837, 10634, 10431, 10228, 10024, 9819, 9615, 9409, 9204, 8998,
+ 8791, 8585, 8377, 8170, 7962, 7754, 7545, 7336, 7127, 6918, 6708,
+ 6498, 6288, 6077, 5866, 5655, 5444, 5232, 5020, 4808, 4596, 4383,
+ 4171, 3958, 3745, 3532, 3319, 3105, 2892, 2678, 2464, 2250, 2036,
+ 1822, 1608, 1394, 1179, 965, 751, 536, 322, 107
+};
+const Word16 wscw16q15_8_fx[40] =
+{
+ -32762, -32711, -32610, -32459, -32258, -32007, -31706, -31357,
+ -30959, -30514, -30022, -29483, -28899, -28270, -27598, -26883,
+ -26127, -25330, -24494, -23621, 22711, 21766, 20788, 19777,
+ 18736, 17666, 16569, 15447, 14300, 13132, 11943, 10736,
+ 9512, 8274, 7022, 5760, 4490, 3212, 1929, 643
+};
+const Word16 wscw16q15_16_fx[80] =
+{
+ -32766, -32754, -32729, -32691, -32640, -32577, -32501, -32413,
+ -32313, -32200, -32074, -31936, -31786, -31624, -31449, -31262,
+ -31063, -30853, -30630, -30395, -30149, -29891, -29622, -29341,
+ -29049, -28746, -28431, -28106, -27770, -27423, -27066, -26698,
+ -26320, -25931, -25533, -25125, -24707, -24279, -23843, -23397,
+ 22942, 22478, 22006, 21525, 21035, 20538, 20033, 19520,
+ 18999, 18472, 17937, 17395, 16846, 16291, 15730, 15162,
+ 14589, 14010, 13426, 12836, 12242, 11643, 11039, 10431,
+ 9819, 9204, 8585, 7962, 7336, 6708, 6077, 5444,
+ 4808, 4171, 3532, 2892, 2250, 1608, 965, 322
+};
+const Word16 wscw16q15_32_fx[160] =
+{
+ -32768, -32764, -32758, -32749, -32736, -32720, -32701, -32679, -32654, -32626, -32594,
+ -32559, -32522, -32481, -32437, -32389, -32339, -32286, -32229, -32169, -32107, -32041,
+ -31972, -31900, -31825, -31747, -31665, -31581, -31494, -31403, -31310, -31214, -31114,
+ -31012, -30906, -30798, -30687, -30572, -30455, -30335, -30212, -30086, -29957, -29825,
+ -29690, -29553, -29412, -29269, -29123, -28974, -28823, -28668, -28511, -28351, -28188,
+ -28023, -27855, -27684, -27511, -27335, -27156, -26975, -26791, -26604, -26415, -26223,
+ -26029, -25833, -25633, -25432, -25228, -25021, -24812, -24601, -24387, -24171, -23953,
+ -23732, -23509, -23284, 23056, 22827, 22595, 22361, 22125, 21886, 21646, 21403,
+ 21159, 20912, 20663, 20413, 20160, 19905, 19649, 19390, 19130, 18868, 18604,
+ 18338, 18071, 17802, 17531, 17258, 16984, 16708, 16430, 16151, 15871, 15588,
+ 15305, 15019, 14733, 14445, 14155, 13865, 13572, 13279, 12984, 12688, 12391,
+ 12093, 11793, 11492, 11191, 10888, 10584, 10279, 9973, 9666, 9358, 9049,
+ 8740, 8429, 8118, 7806, 7493, 7180, 6865, 6550, 6235, 5919, 5602,
+ 5285, 4967, 4649, 4330, 4011, 3692, 3372, 3052, 2731, 2411, 2090,
+ 1768, 1447, 1126, 804, 483, 161
+};
+
+/*------------------------------------------------------------------------------*
+ * HQ MDCT tables
+ *------------------------------------------------------------------------------*/
+const Word16 hvq_class_c_fx[16] = /* Q15 */
+{
+ -7617, -14387, 2136, 6914,
+ 4821, -4428, 14131, -4538,
+ -4538, 14131, -4428, 4821,
+ 6914, 2136, -14387, -7617
+};
+const Word32 dicn_fx[40] = /* Q=14 */
+{
+ 2147483647, 1518500224,
+ 1073741824, 759250112,
+ 536870912, 379625056,
+ 268435456, 189812528,
+ 134217728, 94906264,
+ 67108864, 47453132,
+ 33554432, 23726566,
+ 16777216, 11863283,
+ 8388608, 5931642,
+ 4194304, 2965821,
+ 2097152, 1482910,
+ 1048576, 741455,
+ 524288, 370728,
+ 262144, 185364,
+ 131072, 92682,
+ 65536, 46341,
+ 32768, 23170,
+ 16384, 11585,
+ 8192, 5793,
+ 4096, 2896
+};
+const Word16 sqac_headroom_fx[146] = /* Q0 */
+{
+ 0 /*not used */, 0, 0, 1, 1, 1, 1, 1, 1, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4
+};
+
+const Word16 inv_N_fx[32] = /* Q15 */
+{
+ 0, 1056, 2113, 3170,
+ 4227, 5284, 6341, 7398,
+ 8455, 9512, 10569, 11626,
+ 12683, 13740, 14797, 15854,
+ 16912, 17969, 19026, 20083,
+ 21140, 22197, 23254, 24311,
+ 25368, 26425, 27482, 28539,
+ 29596, 30653, 31710, 32767
+};
+
+const Word16 hvq_bwe_fac_fx[16] = /* Q15 */
+{
+ 16384, 17408, 18432, 19456,
+ 20480, 21504, 22528, 23552,
+ 24576, 25600, 26624, 27648,
+ 28672, 29696, 30720, 31744
+};
+
+const Word16 att_step_fx[4]= /* Q=13 */
+{
+ 32767, 16384, 10923, 8192
+};
+
+const Word16 gain_att_fx[40]= /* Q=15 */
+{
+ 15711, 19367, 21781, 23743, 24899, 25929, 26758, 27514,
+ 28059, 28562, 28994, 29398, 29693, 29970, 30213, 30442,
+ 30619, 30786, 30936, 31077, 31190, 31298, 31395, 31488,
+ 31564, 31637, 31704, 31768, 31822, 31873, 31920, 31966,
+ 32005, 32042, 32077, 32111, 32140, 32168, 32195, 32220
+};
+
+const Word16 stab_trans_fx[10] = /* Q15 */
+{
+ 16384, 11381, 7232, 4292, 2433,
+ 1341, 728, 391, 209, 112
+};
+
+const Word16 env_stab_tp_fx[2][2] = /* Q15 */
+{
+ {32735, 16384},
+ {33, 16384}
+};
+
+
+const Word16 subf_norm_groups_fx[4][11] =
+{
+ {0,1,8,9,16,20,24,28,32,36,40},
+ {2,3,10,11,17,21,25,29,33,37,41},
+ {4,5,12,13,18,22,26,30,34,38,42},
+ {6,7,14,15,19,23,27,31,35,39,43}
+};
+
+const Word32 dicn_pg_fx[45] = /* Q12 */
+{
+ 536870912, 451452834, 379625056, 319225344, 268435456,
+ 225726416, 189812528, 159612672, 134217728, 112863208,
+ 94906264, 67108864, 47453132, 33554432, 23726566,
+ 16777216, 11863283, 8388608, 5931641, 4194304,
+ 2965821, 2097152, 1482910, 1048576, 741455,
+ 524288, 370728, 262144, 185364, 131072,
+ 92682, 65536, 46341, 32768, 23170,
+ 16384, 11585, 8192, 5793, 4096,
+ 2896, 2048, 1448, 1024, 724
+};
+
+const Word16 hvq_peak_cb_fx[1024] = /* Q15 */
+{
+ -22652,-20549,-23019, 13968,-25496,-27493, -6957, 5753,-19678,-20274,
+ -6119, 18297, -5329,-22843,-21254, 13929,-27525,-29034, 563, 7265,
+ -26138,-13138, -9678, 7972, -517,-20830,-10703, 26832,-27818,-21449,
+ 208, 6297,-14803,-28396, -7655, 5118, 15134,-24005,-21776, 25330,
+ -11282,-23669,-20340, -2006,-16212,-24127, 9075, 22581,-20047,-25695,
+ -254, 6509,-17174,-29714, 1589, 7104,-17683, -4117, -4049, 22347,
+ -28338,-13898, 671, 6777,-18368,-17925, -7409, 5169,-22093,-19561,
+ 702, 5969, -6610,-27398, -4875, 8773,-29634, -5552, 272, 6992,
+ -9167,-19887, -9136, 6447,-23125,-25612, 9760, 5749,-10410,-29816,
+ 1606, 7019,-13758,-24849, 2084, 7129,-17795,-16160, 596, 7287,
+ -22276,-11145, 521, 6474,-13471,-20705, -74, 6740, 1891,-16245,
+ -12763, 13602, -1617,-27384, -9648, 2511,-21802,-11734, -4836, -1602,
+ -9670,-27913, 6456, 6338,-23227, -4603, 754, 5830, -7699,-24416,
+ 2204, 6518,-27591, 2763, 1885, 6839,-15248,-10500, 344, 6942,
+ -13247, -9761, -4486, 4294,-12097,-15164, 637, 6142,-25994,-16384,
+ 17277, 6511,-10346,-26179, 923, -2374,-13316,-18125, 6841, 7100,
+ -21083,-24251, 4207, -9464,-22914, -7057, 8647, 8026, 2488,-20731,
+ -799, 13754, -3451,-12872, 2545, 17315, 2576,-19594,-10340, 4361,
+ -7007,-19401, 1937, 6751, 17502,-24923,-16948, 8534, -3436,-29004,
+ 6315, 6467,-16936, -4957, 591, 6604, 1099,-26790, -708, 5543,
+ -5949,-14167, -4750, 4068,-10682,-14990, -7489, -5197, 169, -6472,
+ -5143, 16200,-20331, 1722, 395, 6233,-15661,-22913, 24689, 14221,
+ -3892,-22862, 5154, 6301, -8786,-10120, 216, 6831,-12390,-11062,
+ 4824, 6473, -7705, -4195, -5326, 6572, -560,-20773, -2777, 1822,
+ -6703,-14413, 2409, 6083,-10595,-25038, 14291, 4825, 2064,-25736,
+ 16863, 20463, -2752,-29103, 12609, 7539, -7638,-18024, 1948, 689,
+ -10961, -5839, 683, 6170,-26004, 12209, 10742, 15580, -2105, -8625,
+ -4932, 6977, -9940,-15129, 12160, 9806,-13921, -55, 440, 6315,
+ -305, -6080, 11303, 25730,-12423, -3161, 6875, 9836, -2780,-16434,
+ 4128, 5778, 17790,-10991, -6633, 21111, 12367,-26550,-10581, -2530,
+ -6713,-10210, 4804, 6280, -5932, 2832, 4978, 18330, 2696,-23822,
+ -11870,-13313, 5266,-10870, -7933, 4455, -3155,-10994, 2225, 5803,
+ 820,-11966, -1397, 5344, -5027, -7230, 1236, 5812, -1649,-21007,
+ 8948, 5539,-16246, -801, -533, -3132, -8272, -1302, 367, 5958,
+ -26574, -3470, 7126, -8876, -4819, -5380, -3923, 1466, 1929,-20655,
+ 4419, 3663, 2437,-26758, 10897, 5616, -6601,-10394, 2148, 137,
+ 15007,-22909, -3948, 6197, -9059,-27702, 23041, 4088, 8312, -267,
+ 2973, 25579, -3795, -3612, -489, 5401, 7711,-25887, 3443, 2623,
+ -24306, 3091, 13248, 3273, -3113, -1410, 3541, 12047, 306,-11933,
+ -4493, -1997,-18725, 8257, 7593, 7218,-13588, -8411, 8715, -1137,
+ -12028, 5907, 17904, 21327, -2223,-22989, 9863, -1633, -723, -5944,
+ 714, 5170, 2128,-15199, 2081, 1626, -482, -8521, 8131, 10765,
+ 53,-12020, 5152, 5033, 2361,-13747, 24714, 26357, 1074,-28538,
+ 18087, 4333, 1067,-22148, 14277, 5540, 729,-15049, 7936, 4648,
+ -16646, -6350, 23646, 9628, -91, -8477, 3298, 4297, 3499, -7417,
+ -2214, 2931, -4795, -4424, 6487, 4264, -9333, 3377, 6570, 5734,
+ 1733,-17598, 11163, 4167, -2713,-16183, 14693, 4188,-23780, 9825,
+ 25701, 15331, 586,-19288, 21576, 12040, 11328,-15656, 2944, 7335,
+ 9203,-16906, -5723, -5371, -7906, -4632, 12470, 5724, -123,-16520,
+ 976, -8288, 1262, -3966, -3014, -148, 230, -2169, 505, 3954,
+ -2256,-11474, 9990, 2644, 4841, -8017, -4617, -2959, 24226,-22733,
+ 7475, 17722, 6747, -5782, 4877, 8664, -6893,-24218, 12181,-14683,
+ 2839, -7574, 4815, 2376, 2680, -3986, 1749, 2061, -563, 3232,
+ 3039, 5761, 343, -4150, 6600, 3792, 6356, 7199, 10702, 24266,
+ -25636,-12157, 22874,-14633, 2438, -8680, 8312, 3091, 7135, -3110,
+ 268, 4547, 4272, 4886, 5861, 14177, 11382,-10386, -767, 1448,
+ 1770,-28758, 27658, 4643, -3008,-10314, 18024, 5252, 6999,-17854,
+ 9789, 909, 1556,-21532, 20929, 3182, 26836,-23774, -2868, 3509,
+ -9884,-14471, 24685, 193, -3300, -5891, 5237, -5722, -9043,-14338,
+ 17448, -7167, -683, 26, 4002, -235, 3072,-12689, 13537, 2670,
+ 3577,-10477, 10097, 1435, 17713,-24555, 7486, 1713, 6633, -6645,
+ 1863, -783, 3185, -8349, 3975, -3967, 8090,-23915, 7470, -8732,
+ 2793,-16733, 17412, 1948, -5975,-14195, 1741,-22095, 3376, -782,
+ 18258, 16642, 3845, -3536, 5136, 335, 3267, -719, 10538, 7756,
+ -10993, 5165, 17885, 4767, 4733, -7751, 15643, 8215, 3678, 1686,
+ 3571, 2189,-11186, 1470, 6152,-11489, 4353, -2197, 1357, -3164,
+ 4258, -6029, 8420, -230, 6220, -1478, 2105, -787, -4229, -4632,
+ 15095, -1672, 1986,-16134, 14035, -6088, 7849,-14512, 2875,-10127,
+ 4796,-14269, -8761,-25428, 1192,-24490, 22001, -6216, 258,-10418,
+ 27459, 10524, -754, 7182, 7574, 3444, 5995, 3253, 25190, 25483,
+ 6379, -6363, 409, -8435, -3319, 3253, 12035, 1358, 3184, -6482,
+ 12864, -216, 25363, -7652, -2971, 5718, 4969, -3415, 7040, -2605,
+ 2616,-21129, 28211, 1289, 2553,-15075, 23833, 1871, 14598, -6793,
+ 7189, 4535, 5581, -1997, 4257, -4337, 6027,-10630, 9913, -5633,
+ 3695,-11614, 19091, 585, 4415, -8798, 15569, -1099, -879, 752,
+ 19480, 5412, 5743, 448, 9863, 1342, 20634,-16941, -7404,-16938,
+ -11946, 17852, 19422, 5918, 12538,-20829, 22707, 1113, 4715, -4341,
+ 12573, -3709, 4015, -8219, 3349,-17549, 6395, -1551, 4414, -8302,
+ 24598,-24474, 21909, 9778, 5346, 1386, 6942, -4708, -1507, 2077,
+ 8224,-10420, 6088, -3411, 8824, -6355, 7219, 17353, 22325, 25889,
+ 6666, -1811, 1964,-13461, 8123, -4454, 26614, 11418, 4582, -7133,
+ 18420, -3918, -264, 10545, 24810, 12821, 6936,-22880, 10241,-24118,
+ 3108, -7220, 11991,-12963, 4237,-10392, 23417, -2591, 4624,-14780,
+ 29121, -1235, 7543, -1157, 17358, 1244, 20161, -6319, 2575, -5204,
+ 4384, 5974, 10993, -2909, 1619, -4017, 26017, 722, 4659, 11545,
+ 14463, 4774, -2892, 10593, 15058, -4543, 1972,-15782, 26652,-10199,
+ 6046, -562, 11992, -8022, 6197, -349, 7928,-12070, 21399,-13670,
+ 15116, 99, 5829, -4061, 16713, -7200, -8904, 4170, 24814, -7599,
+ 12177, 6080, 19388, 11094, 4262, 1544, 17090, -4775, -6957, -5908,
+ 19576,-23176, 7126,-23499, 24889,-17683, 5514, -5416, 23284, -5830,
+ 6388, -1788, 14378,-11597, 5099, -8771, 28791, -4573, 6029, -4164,
+ 3217,-26929, 6427, 145, 9306,-17874, 5544, 3835, 25432, -15,
+ 8297,-10673, 21003,-15084, 6019, -7628, 13891,-22535, 27144, 1685,
+ 10077, 4230, 5211, -1543, 22179,-10638, 6385, 5710, 13476,-12976,
+ 5272, 17571, 23747, 5084, -2100, 9127, 13746,-20852,-16310, 15716,
+ 21422,-23074, 6532, -31, 17127,-16620, 5397, -3362, 28477, -9453,
+ 6238, 1258, 13189,-22475, 12895, -4568, 8062,-26648, 2873, 5975,
+ 22151,-15208, 6319, -507, 23117,-17415, 24129,-14207, 12908,-21101,
+ 7262, 8470, 25405, -9450, 5424, -1162, 29494,-16114, 21373, 22875,
+ 24554, 16783, 6684, 2453, 15785,-28885, 6504, 1085, 21619,-24241,
+ 21468, 620, 23222, -7235, 10917, 8863, 18570,-21606, 6710, -2091,
+ 28961,-25837, 6884, 20869, 27603, -8999, 6798, 5617, 28706,-21501,
+ 6066, 4720, 25084,-28951
+};
+
+const Word16 rat_fx[SFM_N_WB] = { 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576, 24576,
+ 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 13107, 13107
+ };
+
+const Word16 fb_inv_bwe_subband_width_fx[DIM_FB] = {819, 819, 409};
+const Word16 fb_smooth_factor_fx[DIM_FB] = {1024, 819, 512};
+
+const Word16 hvq_thr_adj_fx[5] = { 23170, 16384, 8192, 16384, 23170}; /* Q15 */
+
+const Word16 hvq_index_mapping_fx[4] = {0, 1, 3, 4};
+
+const Word16 hq_nominal_scaling_inv[7] = {0, 8192, 11585, 0, 16384, 0, 20066}; /*Q13 */
+const Word16 hq_nominal_scaling[7] = {0, 32767, 23170, 0, 16384, 0, 13377}; /*Q15 */
+
+/* %* lowered Table ROM, call with band_len_idx[sfm_size>>3] */
+/* % sfms =[ 8, 16, 24, 32, 48, 64, 80, 96 ], */
+/* sfm/8= [ 1 2 3 4 6 8 10 12]; */
+/* % idx= 0 1 2 3 4 5 6 7; */
+/* call with band_len_idx[sfm_size>>3] */
+const Word16 band_len_idx[1+(MAX_SFM_LEN_FX/8)] =
+{
+ /*sfm/8*/ /*1*/ /*2 */ /*3 */ /*4 */ /*6 */ /*8 */ /*10*/ /*12*/
+ -1 , 0/*8*/, 1/*16*/,2/*24*/,3/*32*/,-1, 4/*48 */,-1, 5/*64 */,-1, 6/*80*/,-1, 7/*96*/
+};
+const Word16 band_len_ener_shift[8] = {1, 2, 2, 2, 3, 3 , 4/*sfm==80*/, 4 /*sfm==96*/}; /* 96 requires 1 bit more than 48 */
+/*% sfms=[8,16,24,32,48,64,80,96], round(sqrt(sfms)*2^11) */
+const Word16 fine_gain_pred_sqrt_bw[8] = {5793, 8192, 10033, 11585, 14189, 16384, 18318 , 20066 }; /* (Q11) */
+const Word32 SQRT_DIM_fx[1+PVQ_MAX_BAND_SIZE] = /* sqrt(x) for x = 0, 1, ..., 64. in Q15 */
+{
+ 0, 32768, 46341, 56756, 65536, 73271, 80265, 86696,
+ 92682, 98304, 103622, 108679, 113512, 118147, 122607, 126910,
+ 131072, 135106, 139023, 142832, 146543, 150162, 153696, 157150,
+ 160530, 163840, 167085, 170268, 173392, 176461, 179478, 182445,
+ 185364, 188238, 191069, 193858, 196608, 199320, 201996, 204636,
+ 207243, 209818, 212361, 214874, 217358, 219814, 222243, 224646,
+ 227023, 229376, 231705, 234010, 236293, 238555, 240795, 243014,
+ 245213, 247393, 249554, 251696, 253820, 255926, 258015, 260088,
+ 262144
+};
+
+
+
+
+
+
+const Word16 finegain_1_fx[2] = {-12204, 12647}; /* Q14 */
+const Word16 finegain_2_fx[4] = {-17773, -5925, 6010, 18769}; /* Q14 */
+const Word16 finegain_3_fx[8] = {-16384, -11703, -7022, -2341, 2341, 7022, 11703, 16384}; /* Q14 */
+const Word16 finegain_4_fx[16] = /* Q14 */
+{
+ -21683, -18292, -14998, -11876, -8936, -6239, -3702, -1371,
+ 945, 3275, 6088, 9079, 12450, 15999, 19796, 23868
+};
+const Word16 finegain_5_fx[32] = /* Q14 */
+{
+ -21462, -18895, -16284, -14135, -12605, -11307, -10139, -8910,
+ -8028, -6792, -5638, -4812, -3672, -2681, -1725, -479,
+ 449, 1390, 2364, 3433, 4579, 5516, 6769, 7767,
+ 9085, 10152, 11009, 12535, 14765, 17093, 20094, 24716
+};
+const Word16* finegain_fx[5] = { finegain_1_fx, finegain_2_fx, finegain_3_fx, finegain_4_fx, finegain_5_fx };
+const Word16 gain_cb_size[MAX_GAIN_BITS] = {2, 4, 8, 16, 32};
+
+const UWord32 exactdivodd_fx[ODD_DIV_SIZE_FX]=/* exactdivodd[0]=1/1,exactdivodd[1]=1/3 exactdivodd[47]=1/95 */
+{
+ 1U, 2863311531U, 3435973837U, 3067833783U, 954437177U, 3123612579U, 3303820997U, 4008636143U,
+ 4042322161U, 678152731U, 1022611261U, 3921491879U, 3264175145U, 1749801491U, 1332920885U, 3186588639U,
+ 1041204193U, 2331553675U, 2437684141U, 2532929431U, 3247414297U, 799063683U, 2767867813U, 1736263375U,
+ 438261969U, 4210752251U, 2350076445U, 1483715975U, 3089362441U, 2693454067U, 3238827797U, 3204181951U,
+ 3237744577U, 128207979U, 2738819725U, 3811027319U, 3353604601U, 2519714147U, 1059797125U, 1631000239U,
+ 2014922929U, 724452315U, 4244438269U, 1875962727U, 4198451177U, 3539808211U, 1062196213U, 3571604383U
+};
+
+
+const Word32 thren_fx[39] = /* Q8 */
+{
+ 28215802, 19951584, 14107901,
+ 9975792, 7053951, 4987896,
+ 3526975, 2493948, 1763488,
+ 1246974, 881744, 623487,
+ 440872, 311744, 220436,
+ 155872, 110218, 77936,
+ 55109, 38968, 27554,
+ 19484, 13777, 9742,
+ 6889, 4871, 3444,
+ 2435, 1722, 1218,
+ 861, 609, 431,
+ 304, 215, 152,
+ 108, 76, 54
+};
+
+/*------------------------------------------------------------------------------*
+ * LR-MDCT tables
+ *------------------------------------------------------------------------------*/
+/* NB short win: 7200/8000/9600, 13200/16400/24400 */
+static const Word16 band_width_40_4_6_0_0_0[4] = { 6, 8, 11, 15 };
+static const Word16 band_width_40_5_6_0_0_0[5] = { 6, 7, 7, 9, 11 };
+
+/* NB long win: 7200, 8000, 9600, 13200, 16400/24400 */
+static const Word16 band_width_160_13_6_2_0_0[13] = { 6, 6, 6, 6, 7, 8, 9, 10, 13, 15, 19, 24, 31 };
+static const Word16 band_width_160_14_6_3_0_0[14] = { 6, 6, 6, 6, 6, 7, 8, 9, 10, 12, 15, 18, 22, 29 };
+static const Word16 band_width_160_17_6_3_0_0[17] = { 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 13, 15, 17, 19 };
+static const Word16 band_width_160_18_6_4_0_0[18] = { 6, 6, 6, 6, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 12, 14, 15, 17 };
+
+/* WB short win: 13200/16400/24400 */
+static const Word16 band_width_80_7_6_0_0_0[7] = { 6, 7, 8, 10, 12, 16, 21 };
+
+/* WB long win: 12800, 16000, 24000 */
+static const Word16 band_width_320_18_6_3_0_0[18] = { 6, 6, 6, 6, 6, 7, 7, 8, 10, 11, 13, 16, 19, 24, 30, 37, 47, 61 };
+static const Word16 band_width_320_20_6_3_0_0[20] = { 6, 6, 6, 6, 6, 6, 7, 8, 8, 9, 11, 12, 14, 17, 20, 23, 28, 34, 42, 51 };
+
+/* SWB short win: 12800, 16000, 24000 */
+static const Word16 band_width_142_8_8_0_0_0[8] = {7,8,10,11,15,21,29,41 };
+static const Word16 band_width_160_8_8_0_0_0[8] = { 8, 9, 11,13,17,23,32,47 };
+
+/* SWB long win: 12800, 16000, 24000 */
+static const Word16 band_width_568_22_6_2_0_0[22] = { 6, 6, 6, 6, 6, 6, 7, 8, 9, 10, 11, 13, 16, 19, 23, 28, 34, 42, 55, 68, 84, 105};
+static const Word16 band_width_640_24_6_4_0_0[24] = { 6, 6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 13, 15, 18, 21, 26, 32, 39, 48, 59, 74, 92,115 };
+
+/* LR-MDCT: NB configuration tables */
+const Xcore_Config_fx xcore_config_8kHz_007200bps_long_fx = { 13, L_FRAME8k, band_width_160_13_6_2_0_0, 536870912L, 24576, 13107, 2, 2, 0, 0, 13107, 4260, 19661 };
+const Xcore_Config_fx xcore_config_8kHz_008000bps_long_fx = { 14, L_FRAME8k, band_width_160_14_6_3_0_0, 536870912L, 24576, 13107, 2, 2, 0, 0, 13107, 4260, 19661 };
+const Xcore_Config_fx xcore_config_8kHz_013200bps_long_fx = { 17, L_FRAME8k, band_width_160_17_6_3_0_0, 429496730L, 24576, 13107, 2, 4, 2, 24576, 13107, 4260, 19661 };
+const Xcore_Config_fx xcore_config_8kHz_016400bps_long_fx = { 18, L_FRAME8k, band_width_160_18_6_4_0_0, 322122547L, 24576, 13107, 2, 2, 0, 0, 13107, 4260, 19661 };
+
+const Xcore_Config_fx xcore_config_8kHz_007200bps_short_fx = { 4, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_4_6_0_0_0, 966367642L, 24576, 13107, 2, 2, 0, 0, 9830, 2949, 19661 };
+const Xcore_Config_fx xcore_config_8kHz_008000bps_short_fx = { 4, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_4_6_0_0_0, 1181116006L, 24576, 13107, 2, 4, 0, 0, 9830, 2949, 19661 };
+const Xcore_Config_fx xcore_config_8kHz_013200bps_short_fx = { 5, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_5_6_0_0_0, 751619276L, 24576, 11469, 2, 4, 0, 0, 22938, 3604, 19661 };
+const Xcore_Config_fx xcore_config_8kHz_016400bps_short_fx = { 5, L_FRAME8k / NUM_TIME_SWITCHING_BLOCKS, band_width_40_5_6_0_0_0, 536870912L, 24576, 11469, 2, 6, 0, 0, 22491, 3604, 19661 };
+
+/* LR-MDCT: WB configuration tables */
+const Xcore_Config_fx xcore_config_16kHz_013200bps_long_fx = { 18, L_FRAME16k, band_width_320_18_6_3_0_0, 429496730L, 24576, 13106, 2, 6, 3, 24576, 13107, 3932, 18022 };
+const Xcore_Config_fx xcore_config_16kHz_016400bps_long_fx = { 20, L_FRAME16k, band_width_320_20_6_3_0_0, 429496730L, 24576, 13106, 2, 6, 3, 24576, 13107, 3932, 19660 };
+
+const Xcore_Config_fx xcore_config_16kHz_013200bps_short_fx = { 7, L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, band_width_80_7_6_0_0_0, 966367642L, 24576, 9830, 2, 4, 0, 0, 9830, 4258, 18022 };
+const Xcore_Config_fx xcore_config_16kHz_016400bps_short_fx = { 7, L_FRAME16k / NUM_TIME_SWITCHING_BLOCKS, band_width_80_7_6_0_0_0, 966367642L, 24576, 11468, 2, 8, 0, 0, 9830, 4258, 19660 };
+
+/* LR-MDCT: SWB configuration tables */
+const Xcore_Config_fx xcore_config_32kHz_013200bps_long_fx = { 22, 568, band_width_568_22_6_2_0_0, 322122547L, 24576, 6554, 2, 4, 5, 28672, 13107, 4260, 19661 };
+const Xcore_Config_fx xcore_config_32kHz_016400bps_long_fx = { 24, 640, band_width_640_24_6_4_0_0, 322122547L, 24576, 8192, 2, 4, 5, 28672, 13107, 4260, 19661 };
+
+const Xcore_Config_fx xcore_config_32kHz_013200bps_short_fx = { 8, 568 / NUM_TIME_SWITCHING_BLOCKS, band_width_142_8_8_0_0_0, 1610612736L, 24576, 13107, 2, 4, 0, 0, 16384, 3604, 19661 };
+const Xcore_Config_fx xcore_config_32kHz_016400bps_short_fx = { 8, 640 / NUM_TIME_SWITCHING_BLOCKS, band_width_160_8_8_0_0_0, 644245094L, 24576, 8192, 2, 4, 0, 0, 9830, 4260, 19661 };
+
+/*------------------------------------------------------------------------------*
+ * LR MDCT SWB BWE coding tables
+ *------------------------------------------------------------------------------*/
+const Word16 subband_offsets_12KBPS[NB_SWB_SUBBANDS] = {SWB_SB_OFF0_12KBPS, SWB_SB_OFF1_12KBPS, SWB_SB_OFF2_12KBPS, SWB_SB_OFF3_12KBPS};
+const Word16 subband_offsets_16KBPS[NB_SWB_SUBBANDS] = {SWB_SB_OFF0_16KBPS, SWB_SB_OFF1_16KBPS, SWB_SB_OFF2_16KBPS, SWB_SB_OFF3_16KBPS};
+const Word16 gain_table_SWB_BWE_fx[NB_SWB_SUBBANDS] = { -6554/*-0.4f*/, 1638/*0.1f*/, 9830/*0.6f*/, 18022/*1.1f*/ }; /* Q14 */
+
+const Word16 bits_lagIndices_modeNormal_fx[NB_SWB_SUBBANDS] = {2, 2, 1, 1};
+
+/* Search offset for the subbands that use a partial search */
+const Word16 subband_search_offsets_fx[NB_SWB_SUBBANDS] =
+{
+ 0, 0, 64, 64
+};
+/* SPT : shorten subband length table */
+const Word16 bw_SPT_tbl[2][SPT_SHORTEN_SBNUM]=
+{
+ {15, 31, 31, 31}, /* 13.2kbps: original band_width 53, 66, 82, 102 */
+ {15, 15, 31, 31} /* 16.4kbps: original band_width 51 64, 80, 90 */
+};
+
+/* Harmonic Mode */
+const Word16 bits_lagIndices_mode0_Har_fx[NB_SWB_SUBBANDS_HAR_SEARCH_SB] = {1,1};
+
+/* 13.2 kbps */
+const Word16 subband_offsets_sub5_13p2kbps_Har_fx[NB_SWB_SUBBANDS_HAR] =
+{
+ SWB_SB_OFF0_SUB5_12KBPS_HAR, SWB_SB_OFF1_SUB5_12KBPS_HAR, SWB_SB_OFF2_SUB5_12KBPS_HAR, SWB_SB_OFF3_SUB5_12KBPS_HAR
+};
+
+/* Search offset for the subbands that use a partial search */
+const Word16 subband_search_offsets_13p2kbps_Har_fx[NB_SWB_SUBBANDS_HAR_SEARCH_SB] =
+{
+ 120, 210
+};
+
+/* 16.4 kbps */
+const Word16 subband_offsets_sub5_16p4kbps_Har_fx[NB_SWB_SUBBANDS_HAR] =
+{
+ SWB_SB_OFF0_SUB5_16KBPS_HAR, SWB_SB_OFF1_SUB5_16KBPS_HAR, SWB_SB_OFF2_SUB5_16KBPS_HAR, SWB_SB_OFF3_SUB5_16KBPS_HAR
+};
+
+/* Search offset for the subbands that use a partial search */
+const Word16 subband_search_offsets_16p4kbps_Har_fx[NB_SWB_SUBBANDS_HAR_SEARCH_SB] =
+{
+ 120, 210
+};
+
+const Word16 inv_tbl_fx[146] =
+{
+ 0, 32767, 16384, 10923, 8192, 6554, 5462, 4681,
+ 4096, 3641, 3277, 2979, 2731, 2521, 2341, 2185,
+ 2048, 1928, 1820, 1725, 1638, 1560, 1489, 1425,
+ 1365, 1311, 1260, 1214, 1170, 1130, 1092, 1057,
+ 1024, 993, 964, 936, 910, 886, 862, 840,
+ 819, 799, 780, 762, 745, 728, 712, 697,
+ 683, 669, 655, 643, 630, 618, 607, 596,
+ 585, 575, 565, 555, 546, 537, 529, 520,
+ 512, 504, 496, 489, 482, 475, 468, 462,
+ 455, 449, 443, 437, 431, 426, 420, 415,
+ 410, 405, 400, 395, 390, 386, 381, 377,
+ 372, 368, 364, 360, 356, 352, 349, 345,
+ 341, 338, 334, 331, 328, 324, 321, 318,
+ 315, 312, 309, 306, 303, 301, 298, 295,
+ 293, 290, 287, 285, 282, 280, 278, 275,
+ 273, 271, 269, 266, 264, 262, 260, 258,
+ 256, 254, 252, 250, 248, 246, 245, 243,
+ 241, 239, 237, 236, 234, 232, 231, 229,
+ 228, 226
+};
+const Word32 table_logcum_fx[563] =
+{
+ 0, 0, 0, 65536, 169408, 300480, 452650, 622058, 806041,
+ 1002649, 1210393, 1428099, 1654816, 1889761, 2132272, 2381791, 2637833,
+ 2899977, 3167853, 3441134, 3719526, 4002767, 4290623, 4582876, 4879332,
+ 5179812, 5484152, 5792200, 6103816, 6418871, 6737244, 7058822, 7383500,
+ 7711180, 8041769, 8375181, 8711333, 9050150, 9391557, 9735485, 10081869,
+ 10430647, 10781759, 11135150, 11490766, 11848556, 12208469, 12570461, 12934487,
+ 13300503, 13668469, 14038345, 14410092, 14783676, 15159061, 15536214, 15915101,
+ 16295692, 16677956, 17061866, 17447390, 17834504, 18223180, 18613394, 19005122,
+ 19398338, 19793020, 20189146, 20586692, 20985640, 21385968, 21787658, 22190686,
+ 22595040, 23000696, 23407638, 23815850, 24225314, 24636014, 25047934, 25461060,
+ 25875374, 26290862, 26707510, 27125304, 27544232, 27964278, 28385428, 28807674,
+ 29231000, 29655392, 30080844, 30507338, 30934866, 31363416, 31792978, 32223540,
+ 32655092, 33087624, 33521126, 33955588, 34391000, 34827352, 35264636, 35702840,
+ 36141960, 36581988, 37022908, 37464716, 37907404, 38350964, 38795388, 39240668,
+ 39686792, 40133760, 40581560, 41030188, 41479632, 41929888, 42380948, 42832808,
+ 43285456, 43738892, 44193104, 44648088, 45103840, 45560348, 46017612, 46475624,
+ 46934376, 47393864, 47854080, 48315024, 48776684, 49239060, 49702144, 50165928,
+ 50630412, 51095588, 51561452, 52028000, 52495224, 52963124, 53431688, 53900916,
+ 54370808, 54841348, 55312540, 55784380, 56256856, 56729972, 57203720, 57678096,
+ 58153096, 58628716, 59104952, 59581800, 60059256, 60537316, 61015980, 61495236,
+ 61975084, 62455524, 62936548, 63418156, 63900340, 64383100, 64866428, 65350328,
+ 65834792, 66319816, 66805396, 67291536, 67778224, 68265456, 68753240, 69241560,
+ 69730424, 70219816, 70709744, 71200208, 71691192, 72182704, 72674736, 73167280,
+ 73660344, 74153920, 74648008, 75142600, 75637704, 76133296, 76629400, 77125992,
+ 77623080, 78120656, 78618728, 79117280, 79616320, 80115840, 80615832, 81116312,
+ 81617256, 82118680, 82620568, 83122920, 83625744, 84129024, 84632768, 85136968,
+ 85641624, 86146728, 86652288, 87158304, 87664760, 88171664, 88679008, 89186792,
+ 89695016, 90203680, 90712776, 91222304, 91732256, 92242648, 92753464, 93264704,
+ 93776368, 94288448, 94800952, 95313872, 95827208, 96340960, 96855120, 97369696,
+ 97884672, 98400064, 98915856, 99432048, 99948648, 100465640, 100983040, 101500832,
+ 102019016, 102537592, 103056568, 103575928, 104095672, 104615808, 105136328, 105657232,
+ 106178520, 106700184, 107222232, 107744656, 108267456, 108790632, 109314176, 109838096,
+ 110362384, 110887040, 111412064, 111937448, 112463208, 112989320, 113515800, 114042640,
+ 114569832, 115097392, 115625304, 116153568, 116682184, 117211160, 117740480, 118270152,
+ 118800168, 119330536, 119861248, 120392312, 120923712, 121455448, 121987536, 122519960,
+ 123052720, 123585816, 124119248, 124653016, 125187120, 125721552, 126256320, 126791416,
+ 127326840, 127862592, 128398664, 128935072, 129471800, 130008856, 130546224, 131083920,
+ 131621936, 132160272, 132698920, 133237888, 133777176, 134316768, 134856688, 135396912,
+ 135937440, 136478288, 137019440, 137560912, 138102688, 138644768, 139187152, 139729840,
+ 140272832, 140816128, 141359712, 141903616, 142447808, 142992304, 143537104, 144082192,
+ 144627568, 145173248, 145719232, 146265504, 146812064, 147358912, 147906048, 148453488,
+ 149001200, 149549216, 150097504, 150646096, 151194960, 151744112, 152293536, 152843264,
+ 153393264, 153943536, 154494096, 155044944, 155596064, 156147456, 156699120, 157251072,
+ 157803296, 158355792, 158908560, 159461616, 160014928, 160568512, 161122368, 161676496,
+ 162230896, 162785568, 163340496, 163895696, 164451168, 165006896, 165562896, 166119152,
+ 166675664, 167232448, 167789504, 168346816, 168904368, 169462208, 170020288, 170578624,
+ 171137232, 171696080, 172255200, 172814560, 173374192, 173934064, 174494192, 175054576,
+ 175615216, 176176096, 176737232, 177298608, 177860256, 178422128, 178984256, 179546640,
+ 180109264, 180672128, 181235248, 181798608, 182362208, 182926064, 183490144, 184054480,
+ 184619056, 185183872, 185748928, 186314224, 186879760, 187445520, 188011536, 188577776,
+ 189144272, 189710992, 190277936, 190845136, 191412560, 191980208, 192548112, 193116224,
+ 193684592, 194253168, 194821984, 195391040, 195960320, 196529824, 197099568, 197669520,
+ 198239712, 198810144, 199380784, 199951648, 200522752, 201094080, 201665616, 202237392,
+ 202809376, 203381600, 203954032, 204526688, 205099568, 205672672, 206246000, 206819536,
+ 207393296, 207967280, 208541472, 209115888, 209690528, 210265376, 210840432, 211415712,
+ 211991216, 212566912, 213142848, 213718976, 214295328, 214871888, 215448672, 216025664,
+ 216602864, 217180272, 217757888, 218335712, 218913760, 219492000, 220070464, 220649120,
+ 221228000, 221807072, 222386368, 222965856, 223545552, 224125456, 224705568, 225285872,
+ 225866400, 226447120, 227028032, 227609168, 228190496, 228772016, 229353760, 229935680,
+ 230517824, 231100160, 231682688, 232265424, 232848352, 233431472, 234014800, 234598336,
+ 235182048, 235765968, 236350080, 236934400, 237518896, 238103600, 238688496, 239273600,
+ 239858880, 240444352, 241030032, 241615888, 242201952, 242788192, 243374640, 243961264,
+ 244548096, 245135104, 245722304, 246309696, 246897280, 247485056, 248073008, 248661152,
+ 249249488, 249838016, 250426720, 251015616, 251604704, 252193968, 252783424, 253373056,
+ 253962880, 254552896, 255143088, 255733472, 256324032, 256914768, 257505696, 258096800,
+ 258688096, 259279568, 259871216, 260463056, 261055056, 261647264, 262239632, 262832192,
+ 263424928, 264017840, 264610928, 265204192, 265797632, 266391264, 266985072, 267579040,
+ 268173200, 268767520, 269362048, 269956736, 270551584, 271146624, 271741824, 272337216,
+ 272932768, 273528480, 274124384, 274720480, 275316704, 275913120, 276509728, 277106496,
+ 277703424, 278300544, 278897824, 279495264, 280092896, 280690688, 281288640, 281886752,
+ 282485056, 283083520
+};
+const Word32 pow_getbitsfrompulses_fx[16] = /*Q21 */
+{
+ 2097152, 2190001, 2286961, 2388214, 2493948, 2604365, 2719671, 2840081,
+ 2965822, 3097129, 3234251, 3377442, 3526976, 3683128, 3846194, 4016480
+};
+const Word16 DDP_fx[4] = { 3, 0, 1, 2 };
+const Word16 step_tcq_fx[8][STATES] = { {0,4}, {0,4}, {1,5}, {1,5}, {2,6}, {2,6}, {3,7}, {3,7} };
+const Word16 denc_fx[8][STATES] = { {0,2}, {2,0}, {1,3}, {3,1}, {2,0}, {0,2}, {3,1}, {1,3} }; /* enc trellis */
+const Word16 ddec_fx[8][STATES] = { {0,2}, {1,3}, {2,0}, {3,1}, {2,0}, {3,1}, {0,2}, {1,3} }; /* dec trellis */
+
+const Word16 step_LSB_fx[STATES_LSB][2] = { {0,1}, {2,3}, {0,1}, {2,3} };
+const Word16 denc_LSB_fx[STATES_LSB][2] = { {0,3}, {2,1}, {3,0}, {1,2} };
+const Word16 dqnt_LSB_fx[STATES_LSB][4] = { {0,8,1,8}, {0,8,1,8}, {8,0,8,1}, {8,0,8,1} };
+
+const Word16 dstep_LSB_fx[4][2] = { {0,2}, {0,2}, {1,3}, {1,3} };
+const Word16 ddec_LSB_fx[4][2] = { {0,3}, {3,0}, {2,1}, {1,2} };
+
+
+const Word16 SmoothingWin_NB875_fx[70] = /*Q15*/
+{
+ 0, 16, 66, 148, 263, 411, 590, 802, 1045, 1318,
+ 1623, 1956, 2319, 2710, 3129, 3574, 4046, 4542, 5062, 5604,
+ 6169, 6754, 7358, 7981, 8620, 9275, 9945, 10627, 11321, 12025,
+ 12738, 13459, 14185, 14915, 15649, 16384, 17119, 17853, 18583, 19309,
+ 20030, 20743, 21447, 22141, 22823, 23493, 24148, 24787, 25410, 26014,
+ 26599, 27164, 27706, 28226, 28722, 29194, 29639, 30058, 30449, 30812,
+ 31145, 31450, 31723, 31966, 32178, 32357, 32505, 32620, 32702, 32752
+};
+
+const Word16 SmoothingWin_NB2_fx[16] =
+{
+ 0, 315, 1247, 2761, 4799, 7282, 10114, 13188, 16384, 19580, 22654, 25486, 27969, 30007, 31521, 32453
+};
+
+
+const Word16 crit_bands_loc_fx[CRIT_NOIS_BAND] =
+{
+ 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720,
+ 2000, 2320, 2700, 3150, 3700, 4100, 4500, 5000, 5500, 6000, 6375
+};
+
+const unsigned char hBitsMinus1_N01[2] = {1, 7};
+
+const unsigned char hBitsMinus1_N02[65]=
+{
+ 64, 15, 23, 28, 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47,
+ 47, 48, 49, 49, 50, 51, 52, 53, 54, 54, 55, 56, 57, 57, 58, 59,
+ 60, 61, 62, 63, 63, 64, 65, 65, 67, 68, 69, 69, 70, 71, 72, 72,
+ 73, 74, 75, 76, 77, 78, 79, 80, 80, 81, 82, 83, 84, 85, 86, 87,
+ 87
+};
+
+const unsigned char hBitsMinus1_N03[65]=
+{
+ 64, 20, 33, 41, 48, 53, 57, 61, 64, 66, 69, 71, 73, 75, 76, 78,
+ 80, 81, 82, 83, 85, 86, 88, 90, 92, 93, 95, 96, 98, 99, 100, 102,
+ 104, 106, 108, 110, 111, 113, 114, 115, 118, 120, 122, 123, 125, 127, 128, 129,
+ 131, 133, 135, 137, 139, 141, 142, 144, 145, 146, 149, 151, 153, 155, 157, 158,
+ 160
+};
+
+const unsigned char hBitsMinus1_N04[65]=
+{
+ 64, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, 97, 100, 102, 105,
+ 107, 109, 111, 113, 115, 116, 119, 122, 125, 127, 130, 132, 134, 136, 138, 141,
+ 144, 147, 150, 152, 154, 156, 158, 160, 164, 167, 170, 173, 175, 177, 180, 182,
+ 184, 187, 190, 193, 196, 199, 201, 203, 205, 207, 211, 214, 217, 220, 222, 225,
+ 227
+};
+
+const unsigned char hBitsMinus1_N05[54]=
+{
+ 53, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, 128,
+ 131, 134, 136, 139, 141, 144, 148, 152, 155, 158, 161, 164, 167, 170, 172, 176,
+ 181, 184, 188, 191, 194, 197, 200, 202, 207, 211, 215, 219, 222, 225, 228, 231,
+ 233, 238, 242, 246, 250, 253
+};
+
+const unsigned char hBitsMinus1_N06[42]=
+{
+ 41, 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149,
+ 153, 156, 159, 162, 165, 168, 173, 178, 183, 187, 191, 194, 198, 201, 204, 209,
+ 214, 219, 224, 228, 231, 235, 238, 241, 247, 253
+};
+
+const unsigned char hBitsMinus1_N07[34]=
+{
+ 33, 30, 52, 70, 85, 98, 109, 118, 126, 134, 141, 147, 153, 158, 163, 168,
+ 172, 176, 180, 184, 188, 191, 197, 203, 208, 213, 218, 222, 226, 230, 233, 240,
+ 246, 252
+};
+
+const unsigned char hBitsMinus1_N08[29]=
+{
+ 28, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, 185,
+ 190, 195, 200, 204, 208, 212, 219, 226, 232, 238, 243, 248, 253
+};
+
+const unsigned char hBitsMinus1_N09[25]=
+{
+ 24, 33, 58, 79, 97, 112, 125, 137, 148, 157, 166, 174, 182, 189, 195, 201,
+ 207, 212, 217, 222, 227, 231, 240, 247, 254
+};
+
+const unsigned char hBitsMinus1_N10[22]=
+{
+ 21, 34, 61, 83, 101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216,
+ 222, 228, 234, 239, 245, 250
+};
+
+const unsigned char hBitsMinus1_N11[19]=
+{
+ 18, 35, 63, 86, 106, 123, 139, 152, 165, 176, 187, 197, 206, 214, 222, 230,
+ 237, 243, 250
+};
+
+const unsigned char hBitsMinus1_N12[17]=
+{
+ 16, 36, 65, 89, 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242,
+ 250
+};
+
+const unsigned char hBitsMinus1_N13[16]=
+{
+ 15, 37, 67, 92, 113, 133, 150, 165, 180, 193, 205, 216, 227, 237, 246, 254,
+};
+
+const unsigned char hBitsMinus1_N14[14]=
+{
+ 13, 38, 68, 94, 117, 137, 155, 171, 186, 200, 213, 225, 236, 247
+};
+
+const unsigned char hBitsMinus1_N15[13]=
+{
+ 12, 39, 70, 97, 120, 141, 160, 177, 193, 207, 221, 233, 245
+};
+
+const unsigned char hBitsMinus1_N16[13]=
+{
+ 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, 228, 241, 253
+};
+
+const unsigned char hBitsMinus1_N17[12]=
+{
+ 11, 40, 73, 101, 126, 148, 168, 187, 204, 220, 234, 248
+};
+
+const unsigned char hBitsMinus1_N18[12]=
+{
+ 11, 41, 74, 103, 128, 151, 172, 191, 209, 225, 241, 255
+};
+
+const unsigned char hBitsMinus1_N19[11]=
+{
+ 10, 41, 75, 105, 131, 154, 176, 196, 214, 231, 247
+};
+
+const unsigned char hBitsMinus1_N20[11]=
+{
+ 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253
+};
+
+const unsigned char hBitsMinus1_N21[10]=
+{
+ 9, 43, 78, 108, 135, 160, 183, 204, 223, 241
+};
+
+const unsigned char hBitsMinus1_N22[10]=
+{
+ 9, 43, 79, 110, 138, 163, 186, 207, 227, 246
+};
+
+const unsigned char hBitsMinus1_N23[10]=
+{
+ 9, 44, 80, 111, 140, 165, 189, 211, 231, 250
+};
+
+const unsigned char hBitsMinus1_N24[10]=
+{
+ 9, 44, 81, 113, 142, 168, 192, 214, 235, 255
+};
+
+const unsigned char hBitsMinus1_N25[9]=
+{
+ 8, 45, 82, 114, 143, 170, 195, 217, 239
+};
+
+const unsigned char hBitsMinus1_N26[9]=
+{
+ 8, 45, 83, 116, 145, 172, 197, 221, 242
+};
+
+const unsigned char hBitsMinus1_N27[9]=
+{
+ 8, 46, 84, 117, 147, 175, 200, 224, 246
+};
+
+const unsigned char hBitsMinus1_N28[9]=
+{
+ 8, 46, 84, 118, 149, 177, 202, 227, 249
+};
+const unsigned char hBitsMinus1_N29[9]=
+{
+ 8, 46, 85, 119, 150, 179, 205, 229, 252
+};
+const unsigned char hBitsMinus1_N30[8]=
+{
+ 7, 47, 86, 121, 152, 181, 207, 232
+};
+const unsigned char hBitsMinus1_N31[8]=
+{
+ 7, 47, 87, 122, 153, 182, 209, 235
+};
+const unsigned char hBitsMinus1_N32[8]=
+{
+ 7, 47, 87, 123, 155, 184, 212, 237
+};
+const unsigned char hBitsMinus1_N33[8]=
+{
+ 7, 48, 88, 124, 156, 186, 214, 240
+};
+const unsigned char hBitsMinus1_N34[8]=
+{
+ 7, 48, 89, 125, 158, 188, 216, 242
+};
+const unsigned char hBitsMinus1_N35[8]=
+{
+ 7, 49, 90, 126, 159, 189, 218, 245
+};
+const unsigned char hBitsMinus1_N36[8]=
+{
+ 7, 49, 90, 127, 160, 191, 220, 247
+};
+const unsigned char hBitsMinus1_N37[8]=
+{
+ 7, 49, 91, 128, 162, 193, 222, 249
+};
+const unsigned char hBitsMinus1_N38[8]=
+{
+ 7, 49, 91, 129, 163, 194, 224, 251
+};
+const unsigned char hBitsMinus1_N39[8]=
+{
+ 7, 50, 92, 130, 164, 196, 225, 253
+};
+const unsigned char hBitsMinus1_N40[8]=
+{
+ 7, 50, 93, 131, 165, 197, 227, 255
+};
+const unsigned char hBitsMinus1_N41[7]=
+{
+ 6, 50, 93, 131, 166, 199, 229
+};
+const unsigned char hBitsMinus1_N42[7]=
+{
+ 6, 51, 94, 132, 167, 200, 230
+};
+const unsigned char hBitsMinus1_N43[7]=
+{
+ 6, 51, 94, 133, 168, 201, 232
+};
+const unsigned char hBitsMinus1_N44[7]=
+{
+ 6, 51, 95, 134, 170, 203, 234
+};
+const unsigned char hBitsMinus1_N45[7]=
+{
+ 6, 51, 95, 135, 171, 204, 235
+};
+const unsigned char hBitsMinus1_N46[7]=
+{
+ 6, 52, 96, 135, 172, 205, 237
+};
+const unsigned char hBitsMinus1_N47[7]=
+{
+ 6, 52, 96, 136, 173, 206, 238
+};
+const unsigned char hBitsMinus1_N48[7]=
+{
+ 6, 52, 97, 137, 174, 208, 240
+};
+const unsigned char hBitsMinus1_N49[7]=
+{
+ 6, 52, 97, 138, 175, 209, 241
+};
+const unsigned char hBitsMinus1_N50[7]=
+{
+ 6, 53, 98, 138, 175, 210, 243
+};
+const unsigned char hBitsMinus1_N51[7]=
+{
+ 6, 53, 98, 139, 176, 211, 244
+};
+const unsigned char hBitsMinus1_N52[7]=
+{
+ 6, 53, 99, 140, 177, 212, 245
+};
+const unsigned char hBitsMinus1_N53[7]=
+{
+ 6, 53, 99, 140, 178, 213, 247
+};
+const unsigned char hBitsMinus1_N54[7]=
+{
+ 6, 54, 100, 141, 179, 214, 248
+};
+const unsigned char hBitsMinus1_N55[7]=
+{
+ 6, 54, 100, 142, 180, 216, 249
+};
+const unsigned char hBitsMinus1_N56[7]=
+{
+ 6, 54, 100, 142, 181, 217, 250
+};
+const unsigned char hBitsMinus1_N57[7]=
+{
+ 6, 54, 101, 143, 181, 218, 252
+};
+const unsigned char hBitsMinus1_N58[7]=
+{
+ 6, 54, 101, 143, 182, 219, 253
+};
+const unsigned char hBitsMinus1_N59[7]=
+{
+ 6, 55, 102, 144, 183, 220, 254
+};
+const unsigned char hBitsMinus1_N60[7]=
+{
+ 6, 55, 102, 145, 184, 221, 255
+};
+const unsigned char hBitsMinus1_N61[6]=
+{
+ 5, 55, 102, 145, 185, 221
+};
+const unsigned char hBitsMinus1_N62[6]=
+{
+ 5, 55, 103, 146, 185, 222
+};
+const unsigned char hBitsMinus1_N63[6]=
+{
+ 5, 55, 103, 146, 186, 223
+};
+const unsigned char hBitsMinus1_N64[6]=
+{
+ 5, 55, 103, 147, 187, 224
+};
+
+
+
+const Word16 dsDiracsTab[65] =
+{
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 23, 25,
+ 27, 29, 31, 33, 35, 37, 39, 43,
+ 47, 51, 55, 59, 63, 67, 71, 75,
+ 83, 91, 99, 107, 115, 123, 131, 139,
+ 147, 163, 179, 195, 211, 227, 243, 259,
+ 275, 291, 323, 355, 387, 419, 451, 483,
+ 512
+};
+
+const unsigned int intLimCDivInvDQ31[67+1] =
+{
+ 0x00000000, 0x80000000, 0x40000000, 0x2aaaaaab, 0x20000000, 0x1999999a, 0x15555556, 0x12492493,
+ 0x10000000, 0x0e38e38f, 0x0ccccccd, 0x0ba2e8bb, 0x0aaaaaab, 0x09d89d8a, 0x0924924a, 0x08888889,
+ 0x08000000, 0x07878788, 0x071c71c8, 0x06bca1b0, 0x06666667, 0x06186187, 0x05d1745e, 0x0590b217,
+ 0x05555556, 0x051eb852, 0x04ec4ec5, 0x04bda130, 0x04924925, 0x0469ee59, 0x04444445, 0x04210843,
+ 0x04000000, 0x03e0f83f, 0x03c3c3c4, 0x03a83a84, 0x038e38e4, 0x03759f23, 0x035e50d8, 0x03483484,
+ 0x03333334, 0x031f3832, 0x030c30c4, 0x02fa0be9, 0x02e8ba2f, 0x02d82d83, 0x02c8590c, 0x02b93106,
+ 0x02aaaaab, 0x029cbc15, 0x028f5c29, 0x02828283, 0x02762763, 0x026a43a0, 0x025ed098, 0x0253c826,
+ 0x02492493, 0x023ee090, 0x0234f72d, 0x022b63cc, 0x02222223, 0x02192e2a, 0x02108422, 0x02082083,
+ 0x02000000, 0x01f81f82, 0x01f07c20, 0x01e9131b
+};
+
+const unsigned char obtainEnergyQuantizerDensity_f[57] =
+{
+ 1, 1, 1, 1, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 4, 4, 4,
+ 4, 4, 4, 6, 6, 6, 6, 8,
+ 8, 8, 10,10,12,12,14,14,
+ 16,18,20,20,22,24,26,30,
+ 32,34,38,42,46,50,54,58,
+ 64,70,76,82,90,98,108,118, 128
+};
+
+
+/* (char)ceil(log2(hBitsN[N][0])) - 2) */
+unsigned char f_log2_n[ PVQ_MAX_BAND_SIZE + 1] =
+{
+ 0xff, 0xff, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
+ 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01
+};
+
+const unsigned char* const hBitsN[ PVQ_MAX_BAND_SIZE + 1 ]=
+{
+ f_log2_n/*N=0*/, hBitsMinus1_N01, hBitsMinus1_N02, hBitsMinus1_N03, hBitsMinus1_N04,
+ hBitsMinus1_N05, hBitsMinus1_N06, hBitsMinus1_N07, hBitsMinus1_N08, hBitsMinus1_N09,
+ hBitsMinus1_N10, hBitsMinus1_N11, hBitsMinus1_N12, hBitsMinus1_N13, hBitsMinus1_N14,
+ hBitsMinus1_N15, hBitsMinus1_N16, hBitsMinus1_N17, hBitsMinus1_N18, hBitsMinus1_N19,
+ hBitsMinus1_N20, hBitsMinus1_N21, hBitsMinus1_N22, hBitsMinus1_N23, hBitsMinus1_N24,
+ hBitsMinus1_N25, hBitsMinus1_N26, hBitsMinus1_N27, hBitsMinus1_N28, hBitsMinus1_N29,
+ hBitsMinus1_N30, hBitsMinus1_N31, hBitsMinus1_N32, hBitsMinus1_N33, hBitsMinus1_N34,
+ hBitsMinus1_N35, hBitsMinus1_N36, hBitsMinus1_N37, hBitsMinus1_N38, hBitsMinus1_N39,
+ hBitsMinus1_N40, hBitsMinus1_N41, hBitsMinus1_N42, hBitsMinus1_N43, hBitsMinus1_N44,
+ hBitsMinus1_N45, hBitsMinus1_N46, hBitsMinus1_N47, hBitsMinus1_N48, hBitsMinus1_N49,
+ hBitsMinus1_N50, hBitsMinus1_N51, hBitsMinus1_N52, hBitsMinus1_N53, hBitsMinus1_N54,
+ hBitsMinus1_N55, hBitsMinus1_N56, hBitsMinus1_N57, hBitsMinus1_N58, hBitsMinus1_N59,
+ hBitsMinus1_N60, hBitsMinus1_N61, hBitsMinus1_N62, hBitsMinus1_N63, hBitsMinus1_N64,
+};
+
+
+const Word16 lim_neg_inv_tbl_fx[MAX_SPLITS + 1] =
+{
+ 0,
+ -32768, -16384, -10923, -8192, -6554,
+ -5462, -4681, -4096, -3641, -3277
+};
+
+
+
+const Word16 Idx2Freq_Tbl[] = { 6554/*12.8*512*/, 48*512, 13108/*25.6*512*/, 32*512, 16*512, 8*512 }; /* in Q9 */
+
+/*-------------------------------------------------------------------*
+ * inverse (reciprocal) of integer, used in FEC_fx.c, pitch_extr and in pitchDoubling_det
+ * 1/n = One_div[n-1]
+ *-------------------------------------------------------------------*/
+const Word16 One_div_fx[] = /* in Q15 */
+{
+ 32767, /* 1/1 */
+ 16384, /* 1/2 */
+ 10923, /* 1/3 */
+ 8192, /* 1/4 */
+ 6554, /* 1/5 */
+ 5461, /* 1/6 */
+ 4681, /* 1/7 */
+ 4096 /* 1/8 */
+};
+
+/*
+ * 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2)
+ */
+const Word16 E_ROM_inter4_1[UP_SAMP * L_INTERPOL1 + 1] =
+{
+ /* cut-off frequency at 0.9*fs/2 */
+ 14746/*0.900000F Q14*/,
+ 13418/*0.818959F Q14*/, 9910/*0.604850F Q14*/, 5429/*0.331379F Q14*/, 1376/*0.083958F Q14*/,
+ -1242/*-0.075795F Q14*/, -2142/*-0.130717F Q14*/, -1732/*-0.105685F Q14*/, -766/*-0.046774F Q14*/,
+ 73/*0.004467F Q14*/, 455/*0.027789F Q14*/, 420/*0.025642F Q14*/, 206/*0.012571F Q14*/,
+ 32/*0.001927F Q14*/, -26/*-0.001571F Q14*/, -12/*-0.000753F Q14*/, 0/*0.000000f Q14*/
+};
+/*
+ * 1/6 resolution interpolation filter (-3 dB at 0.9*fs/2)
+ */
+const Word16 E_ROM_inter6_1[PIT_UP_SAMP6 * L_INTERPOL1 + 1] =
+{
+ 14759/*0.900848F Q14*/,
+ 14158/*0.864136F Q14*/,
+ 12453/*0.760071F Q14*/,
+ 9919/*0.605408F Q14*/,
+ 6948/*0.424072F Q14*/,
+ 3972/*0.242462F Q14*/,
+ 1377/*0.0840759F Q14*/,
+ -563/*-0.0343933F Q14*/,
+ -1729/*-0.105560F Q14*/,
+ -2152/*-0.131348F Q14*/,
+ -1984/*-0.121124F Q14*/,
+ -1450/*-0.0884705F Q14*/,
+ -780/*-0.0476379F Q14*/,
+ -168/*-0.0102539F Q14*/,
+ 267/*0.0162964F Q14*/,
+ 485/*0.0296021F Q14*/,
+ 512/*0.0312195F Q14*/,
+ 412/*0.0251160F Q14*/,
+ 258/*0.0157471F Q14*/,
+ 110/*0.00671387F Q14*/,
+ 0/*0.000000F Q14*/,
+ -65/*-0.00399780F Q14*/,
+ -97/*-0.00592041F Q14*/,
+ -108/*-0.00656128F Q14*/,
+ 0/*0.000000F Q14*/
+};
+
+
+const Word16 Grid[GRID100_POINTS+1] =
+{
+ 32767, 32751, 32703, 32622, 32509, 32364,
+ 32187, 31978, 31738, 31466, 31164, 30830,
+ 30466, 30072, 29649, 29196, 28714, 28204,
+ 27666, 27101, 26509, 25891, 25248, 24579,
+ 23886, 23170, 22431, 21669, 20887, 20083,
+ 19260, 18418, 17557, 16680, 15786, 14876,
+ 13951, 13013, 12062, 11099, 10125, 9141,
+ 8149, 7148, 6140, 5126, 4106, 3083,
+ 2057, 1029, 0, -1029, -2057, -3083,
+ -4106, -5126, -6140, -7148, -8149, -9141,
+ -10125, -11099, -12062, -13013, -13951, -14876,
+ -15786, -16680, -17557, -18418, -19260, -20083,
+ -20887, -21669, -22431, -23170, -23886, -24579,
+ -25248, -25891, -26509, -27101, -27666, -28204,
+ -28714, -29196, -29649, -30072, -30466, -30830,
+ -31164, -31466, -31738, -31978, -32187, -32364,
+ -32509, -32622, -32703, -32751, -32760
+};
+
+/* 16-byte align end */
+
+/*----------------------------------------------------------------------------------*
+ * impulse response with phase dispersion
+ * Used in lib_dec\enhancer.c
+ *----------------------------------------------------------------------------------*/
+/* 2.0 - 6.4 kHz phase dispersion in frequency domain (output of fft_rel) */
+const Word16 low_H[64] = /* (1Q14) */
+{
+ 16388, 16380, 16386, 16381, 16382, 16382, 16381, 16383, 16385, 10265,
+ 10154, 9894, 14051, 16342, -531, 13216, 16372, 15509, 9406, 15948,
+ 4726, 14593, 10404, 9795, -16337, -1815, -10624, 12646, 14555, -12684,
+ 11388, 8175, 16382, -14198, 11781, 10378, 7515, 10423, -12473, 16284,
+ -1200, -13137, 12658, -7446, 15683, -3764, -13419, -5281, 521, -9686,
+ -16375, -1219, 8435, -13059, -12862, -12775, -1, 2, 0, -3,
+ -1, -1, -2, 1
+};
+
+const Word16 low_H16k[80] = /* (1Q14) */
+{
+ 16388, 16380, 16386, 16381, 16382, 16382, 16381, 16383, 16385, 10265,
+ 10154, 9894, 14051, 16342, -531, 13216, 16372, 15509, 9406, 15948,
+ 4726, 14593, 10404, 9795, -16337, -1815, -10624, 12646, 14555, -12684,
+ 11388, 8175, -4121, -13408, 10605, -12308, 16358, 4699, 7640, -7360,
+ 16382, -14639, -14494, 15695, -907, -10815, -12489, 9416, 15857,
+ -14198, 11781, 10378, 7515, 10423, -12473, 16284, -1200, -13137, 12658,
+ -7446, 15683, -3764, -13419, -5281, 521, -9686, -16375, -1219, 8435,
+ -13059, -12862, -12775, -1, 2, 0, -3, -1, -1, -2, 1
+};
+
+/* 3.2 - 6.4 kHz phase dispersion in frequency domain (output of fft_rel) */
+const Word16 mid_H[64] = /* (1Q14) */
+{
+ 16382, 16381, 16384, 16384, 16385, 16387, 16386, 16382, 16387, 16382,
+ 16385, 16385, 16385, 16384, 16382, 16388, 14847, 9629, 13248, 14486,
+ 10995, 642, 13817, 13779, 6468, 8664, 11634, 9780, -14636, -982,
+ 11746, -722, 16385, -16366, -11423, 16354, 7362, 13147, -11538, -13904,
+ -15052, -8862, 8811, -16371, -12146, 7660, -9638, -13254, -6923, 3,
+ -5, -2, -6, 1, 6, 5, -8, -2, 3, -5,
+ 0, -2, -4, 3
+};
+
+const Word16 mid_H16k[80] = /* (1Q14) */
+{
+ 16382, 16381, 16384, 16384, 16385, 16387, 16386, 16382, 16387, 16382,
+ 16385, 16385, 16385, 16384, 16382, 16388, 14847, 9629, 13248, 14486,
+ 10995, 642, 13817, 13779, 6468, 8664, 11634, 9780, -14636, -982,
+ 11746, -722, 108, -16195, -13199, -13289, 5114, 12941, 7110, 8873,
+ 16385, -13774, -14761, 10047, -15566, -9584, 9707, 2483, 16383,
+ -16366, -11423, 16354, 7362, 13147, -11538, -13904, -15052, -8862,
+ 8811, -16371, -12146, 7660, -9638, -13254, -6923, 3, -5, -2, -6,
+ 1, 6, 5, -8, -2, 3, -5, 0, -2, -4, 3
+};
+
+
+/*----------------------------------------------------------------------------------*
+ * Tables for ISF Quantizers
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * Used in lib_com\disf.c, lib_dec\isf_dec.c and lib_enc\isf_enc.c
+ *----------------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------------*
+ * MA prediction coefficients for gain quantizer
+ * Used in "lib_enc\gain_enc.c" and "lib_dec\gain_dec.c".
+ *----------------------------------------------------------------------------------*/
+
+
+/* Initial LSF/ISF memory */
+const Word16 lsf_init[16] = /*14Q1*1.28*/
+{
+ 960, 1920, 2880, 3840, 4800, 5760, 6720, 7680, 8640, 9600, 10560, 11520, 12480, 13440, 14400, 15360
+};
+
+
+/*----------------------------------------------------------------------------------*
+ * Bitstream packing ordering:
+ * Nb of bits per quantization index for each coding mode for layers R1 - R5
+ * Used in lib_enc\bits_enc.c and lib_dec\bits_dec.c
+ *----------------------------------------------------------------------------------*/
+
+const Word16 gain_corr_fac[3]= {0x4155, 0x40A9, 0x4055}; /* pow(10, 2^(-n-2)/28) (1Q14) */
+const Word16 gain_corr_inv_fac[3]= {0x7D67, 0x7EB2, 0x7F59}; /* pow(10,-2^(-n-2)/28) (0Q15) */
+
+/* interpolation windows: Hann * modified Hamming */
+const Word16 inter4_2tcx2[4][4] =
+{
+ { 7620/*0.2325402f Q15*/, 17528/*0.5349195f Q15*/, 7620/*0.2325402f Q15*/, 0/*0.0000000f Q15*/ },
+ { 4434/*0.1353017f Q15*/, 16694/*0.5094465f Q15*/, 11141/*0.3400065f Q15*/, 500/*0.0152453f Q15*/ },
+ { 1995/*0.0608774f Q15*/, 14389/*0.4391226f Q15*/, 14389/*0.4391226f Q15*/, 1995/*0.0608774f Q15*/ },
+ { 500/*0.0152453f Q15*/, 11141/*0.3400065f Q15*/, 16694/*0.5094465f Q15*/, 4434/*0.1353017f Q15*/ }
+};
+const Word16 inter6_2tcx2[6][4] =
+{
+ { 7345/*0.2241379f Q15*/, 18079/*0.5517241f Q15*/, 7345/*0.2241379f Q15*/, 0/*0.0000000f Q15*/ },
+ { 5119/*0.1562044f Q15*/, 17657/*0.5388595f Q15*/, 9798/*0.2990011f Q15*/, 194/*0.0059349f Q15*/ },
+ { 3249/*0.0991379f Q15*/, 16444/*0.5018346f Q15*/, 12288/*0.3750000f Q15*/, 787/*0.0240275f Q15*/ },
+ { 1800/*0.0549361f Q15*/, 14584/*0.4450639f Q15*/, 14584/*0.4450639f Q15*/, 1800/*0.0549361f Q15*/ },
+ { 787/*0.0240275f Q15*/, 12288/*0.3750000f Q15*/, 16444/*0.5018346f Q15*/, 3249/*0.0991379f Q15*/ },
+ { 194/*0.0059349f Q15*/, 9798/*0.2990011f Q15*/, 17657/*0.5388595f Q15*/, 5119/*0.1562044f Q15*/ }
+};
+
+const Word16 inter_core_12_8kHz_output_8kHz[] =
+{
+ 17528/*0.5349196f Q15*/, 16694/*0.5094466f Q15*/, 14389/*0.4391227f Q15*/, 11141/*0.3400065f Q15*/,
+ 7620/*0.2325402f Q15*/, 4434/*0.1353016f Q15*/, 1995/*0.0608773f Q15*/, 500/*0.0152453f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_12_8kHz_output_16kHz[] =
+{
+ 14023/*0.4279357f Q15*/, 13592/*0.4147958f Q15*/, 12367/*0.3774199f Q15*/, 10533/*0.3214508f Q15*/,
+ 8350/*0.2548195f Q15*/, 6096/*0.1860321f Q15*/, 4017/*0.1225801f Q15*/, 2291/*0.0699165f Q15*/,
+ 1023/*0.0312127f Q15*/, 256/*0.0078047f Q15*/, 0/*0.0000000f Q15*/, 0/*0.0000000f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_12_8kHz_output_32kHz[] =
+{
+ 7011/*0.2139679f Q15*/, 6957/*0.2123089f Q15*/, 6796/*0.2073979f Q15*/, 6535/*0.1994284f Q15*/,
+ 6184/*0.1887100f Q15*/, 5756/*0.1756491f Q15*/, 5267/*0.1607254f Q15*/, 4734/*0.1444646f Q15*/,
+ 4175/*0.1274097f Q15*/, 3608/*0.1100939f Q15*/, 3048/*0.0930161f Q15*/, 2511/*0.0766219f Q15*/,
+ 2008/*0.0612900f Q15*/, 1551/*0.0473253f Q15*/, 1146/*0.0349583f Q15*/, 798/*0.0243509f Q15*/,
+ 511/*0.0156063f Q15*/, 288/*0.0087817f Q15*/, 128/*0.0039024f Q15*/, 32/*0.0009753f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_12_8kHz_output_48kHz[] =
+{
+ 4674/*0.1426452f Q15*/, 4658/*0.1421528f Q15*/, 4610/*0.1406841f Q15*/, 4531/*0.1382653f Q15*/,
+ 4422/*0.1349386f Q15*/, 4285/*0.1307618f Q15*/, 4122/*0.1258066f Q15*/, 3937/*0.1201564f Q15*/,
+ 3732/*0.1139041f Q15*/, 3511/*0.1071503f Q15*/, 3277/*0.1000000f Q15*/, 3033/*0.0925607f Q15*/,
+ 2783/*0.0849398f Q15*/, 2531/*0.0772420f Q15*/, 2280/*0.0695677f Q15*/, 2032/*0.0620107f Q15*/,
+ 1791/*0.0546572f Q15*/, 1559/*0.0475844f Q15*/, 1339/*0.0408600f Q15*/, 1132/*0.0345417f Q15*/,
+ 940/*0.0286774f Q15*/, 764/*0.0233055f Q15*/, 605/*0.0184558f Q15*/, 464/*0.0141503f Q15*/,
+ 341/*0.0104042f Q15*/, 237/*0.0072274f Q15*/, 152/*0.0046257f Q15*/, 85/*0.0026016f Q15*/,
+ 38/*0.0011560f Q15*/, 9/*0.0002890f Q15*/, 0/*0.0000000f Q15*/, 0/*0.0000000f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_16kHz_output_8kHz[] =
+{
+ 18079/*0.5517241f Q15*/, 17657/*0.5388595f Q15*/, 16444/*0.5018346f Q15*/, 14584/*0.4450639f Q15*/, 12288/*0.3750000f Q15*/, 9798/*0.2990011f Q15*/,
+ 7345/*0.2241379f Q15*/, 5119/*0.1562044f Q15*/, 3249/*0.0991379f Q15*/, 1800/*0.0549361f Q15*/, 787/*0.0240275f Q15*/, 194/*0.0059349f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_16kHz_output_16kHz[] =
+{
+ 18079/*0.5517241f Q15*/, 17657/*0.5388595f Q15*/, 16444/*0.5018346f Q15*/, 14584/*0.4450639f Q15*/, 12288/*0.3750000f Q15*/, 9798/*0.2990011f Q15*/,
+ 7345/*0.2241379f Q15*/, 5119/*0.1562044f Q15*/, 3249/*0.0991379f Q15*/, 1800/*0.0549361f Q15*/, 787/*0.0240275f Q15*/, 194/*0.0059349f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_16kHz_output_32kHz[] =
+{
+ 9039/*0.2758621f Q15*/, 8986/*0.2742414f Q15*/, 8829/*0.2694298f Q15*/, 8571/*0.2615753f Q15*/, 8222/*0.2509173f Q15*/, 7791/*0.2377748f Q15*/,
+ 7292/*0.2225320f Q15*/, 6738/*0.2056203f Q15*/, 6144/*0.1875000f Q15*/, 5526/*0.1686403f Q15*/, 4899/*0.1495006f Q15*/, 4277/*0.1305132f Q15*/,
+ 3672/*0.1120690f Q15*/, 3097/*0.0945060f Q15*/, 2559/*0.0781022f Q15*/, 2067/*0.0630725f Q15*/, 1624/*0.0495690f Q15*/, 1235/*0.0376861f Q15*/,
+ 900/*0.0274680f Q15*/, 620/*0.0189188f Q15*/, 394/*0.0120137f Q15*/, 220/*0.0067120f Q15*/, 97/*0.0029675f Q15*/, 24/*0.0007394f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_16kHz_output_48kHz[] =
+{
+ 6026/*0.1839080f Q15*/, 6011/*0.1834272f Q15*/, 5963/*0.1819912f Q15*/, 5886/*0.1796198f Q15*/, 5778/*0.1763457f Q15*/, 5643/*0.1722133f Q15*/,
+ 5481/*0.1672782f Q15*/, 5296/*0.1616061f Q15*/, 5088/*0.1552712f Q15*/, 4861/*0.1483546f Q15*/, 4618/*0.1409433f Q15*/, 4362/*0.1331275f Q15*/,
+ 4096/*0.1250000f Q15*/, 3823/*0.1166535f Q15*/, 3545/*0.1081796f Q15*/, 3266/*0.0996670f Q15*/, 2988/*0.0912002f Q15*/, 2715/*0.0828579f Q15*/,
+ 2448/*0.0747126f Q15*/, 2190/*0.0668293f Q15*/, 1942/*0.0592649f Q15*/, 1706/*0.0520681f Q15*/, 1484/*0.0452794f Q15*/, 1276/*0.0389306f Q15*/,
+ 1083/*0.0330460f Q15*/, 906/*0.0276422f Q15*/, 745/*0.0227295f Q15*/, 600/*0.0183120f Q15*/, 472/*0.0143894f Q15*/, 359/*0.0109575f Q15*/,
+ 262/*0.0080092f Q15*/, 181/*0.0055360f Q15*/, 116/*0.0035286f Q15*/, 65/*0.0019783f Q15*/, 29/*0.0008771f Q15*/, 7/*0.0002189f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_25_6kHz_output_8kHz[] =
+{
+ 17528/*0.5349196f Q15*/, 16694/*0.5094466f Q15*/, 14389/*0.4391227f Q15*/, 11141/*0.3400065f Q15*/,
+ 7620/*0.2325402f Q15*/, 4434/*0.1353016f Q15*/, 1995/*0.0608773f Q15*/, 500/*0.0152453f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_25_6kHz_output_16kHz[] =
+{
+ 17528/*0.5349196f Q15*/, 16694/*0.5094466f Q15*/, 14389/*0.4391227f Q15*/, 11141/*0.3400065f Q15*/,
+ 7620/*0.2325402f Q15*/, 4434/*0.1353016f Q15*/, 1995/*0.0608773f Q15*/, 500/*0.0152453f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_25_6kHz_output_32kHz[] =
+{
+ 14023/*0.4279357f Q15*/, 13592/*0.4147958f Q15*/, 12367/*0.3774199f Q15*/, 10533/*0.3214508f Q15*/,
+ 8350/*0.2548195f Q15*/, 6096/*0.1860321f Q15*/, 4017/*0.1225801f Q15*/, 2291/*0.0699165f Q15*/,
+ 1023/*0.0312127f Q15*/, 256/*0.0078047f Q15*/, 0/*0.0000000f Q15*/, 0/*0.0000000f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+const Word16 inter_core_25_6kHz_output_48kHz[] =
+{
+ 9349/*0.2852965f Q15*/, 9220/*0.2813740f Q15*/, 8843/*0.2698819f Q15*/, 8245/*0.2516166f Q15*/,
+ 7465/*0.2278099f Q15*/, 6554/*0.2000000f Q15*/, 5567/*0.1698781f Q15*/, 4559/*0.1391327f Q15*/,
+ 3582/*0.1093111f Q15*/, 2678/*0.0817166f Q15*/, 1879/*0.0573517f Q15*/, 1209/*0.0369093f Q15*/,
+ 682/*0.0208069f Q15*/, 303/*0.0092505f Q15*/, 76/*0.0023118f Q15*/, 0/*0.0000000f Q15*/,
+ 0/*0.0000000f Q15*/
+};
+
+const TCX_LTP_FILTER tcxLtpFilters[12] =
+{
+ { inter_core_12_8kHz_output_8kHz, 2 },
+ { inter_core_12_8kHz_output_16kHz, 3 },
+ { inter_core_12_8kHz_output_32kHz, 5 },
+ { inter_core_12_8kHz_output_48kHz, 8 },
+ { inter_core_16kHz_output_8kHz, 2 },
+ { inter_core_16kHz_output_16kHz, 2 },
+ { inter_core_16kHz_output_32kHz, 4 },
+ { inter_core_16kHz_output_48kHz, 6 },
+ { inter_core_25_6kHz_output_8kHz, 2 },
+ { inter_core_25_6kHz_output_16kHz, 2 },
+ { inter_core_25_6kHz_output_32kHz, 3 },
+ { inter_core_25_6kHz_output_48kHz, 4 },
+};
+
+const SCALE_TCX_SETUP scaleTcxTable[13] =
+{
+ { 0, 0, 8000, 21955/*0.67f Q15*/ },
+ { 0, 8000, 9600, 22938/*0.70f Q15*/ },
+ { 0, 9600, 13200, 24904/*0.76f Q15*/ },
+ { 0, 13200, 16400, 28180/*0.86f Q15*/ },
+ { 0, 16400, 24400, 29491/*0.90f Q15*/ },
+ { 0, 24400, 64000, 31457/*0.96f Q15*/ },
+ { 1, 0, 8000, 32767/*1.f Q15*/ },
+ { 1, 8000, 9600, 32767/*1.f Q15*/ },
+ { 1, 9600, 13200, 32767/*1.f Q15*/ },
+ { 1, 13200, 16400, 27853/*0.85f Q15*/ },
+ { 1, 16400, 24400, 28836/*0.88f Q15*/ },
+ { 1, 24400, 32000, 29491/*0.90f Q15*/ },
+ { 1, 32000, 32400, 31130/*0.95f Q15*/ },
+};
+
+
+/*----------------------------------------------------------------------------------*
+* Quantization table for pitch and innovation gain (gamma) *
+*----------------------------------------------------------------------------------*/
+const Word16 E_ROM_qua_gain5b_const[NB_QUA_GAIN5B * 2] =
+{
+ 1774,577,
+ 2090,1805,
+ 2103,3371,
+ 3908,1116,
+ 4834,2500,
+ 6030,4763,
+ 6838,1334,
+ 7490,2033,
+ 8585,3036,
+ 9845,1575,
+ 10437,2320,
+ 10649,3739,
+ 11298,945,
+ 12108,1920,
+ 12310,5108,
+ 12391,2758,
+ 12659,1237,
+ 13729,1557,
+ 13798,2201,
+ 13972,3275,
+ 14881,993,
+ 15175,1776,
+ 15409,16190,
+ 15551,2395,
+ 15879,4048,
+ 16341,1335,
+ 16988,2918,
+ 18317,7449,
+ 18368,2026,
+ 19114,1364,
+ 19991,4472,
+ 20644,2790,
+};
+#define QUA_PITCH_E 1
+#define QUA_CODE_E 4
+
+const Word16 E_ROM_qua_gain6b_const[NB_QUA_GAIN6B * 2] =
+{
+ 0,2758,
+ 143,3562,
+ 397,2146,
+ 544,4306,
+ 952,1726,
+ 1236,724,
+ 1779,3158,
+ 1820,5448,
+ 1975,2473,
+ 2121,1343,
+ 3049,3912,
+ 3081,1885,
+ 3289,8261,
+ 3416,2843,
+ 3495,2204,
+ 3831,3386,
+ 4295,4590,
+ 4300,2476,
+ 4345,1545,
+ 4913,1122,
+ 5198,2080,
+ 5200,3079,
+ 5448,3714,
+ 5482,2689,
+ 5546,1817,
+ 5783,17318,
+ 5934,6236,
+ 6156,2320,
+ 6481,4225,
+ 6828,3351,
+ 6832,5045,
+ 6888,2895,
+ 7186,2559,
+ 7214,1663,
+ 7373,2052,
+ 7906,3819,
+ 8192,1372,
+ 8452,3063,
+ 8464,2354,
+ 9021,4468,
+ 9037,2715,
+ 9175,1874,
+ 9219,3463,
+ 9831,2155,
+ 10523,5383,
+ 10557,9061,
+ 10618,3093,
+ 10633,3949,
+ 10890,2465,
+ 11141,1654,
+ 12132,2790,
+ 12180,3477,
+ 12376,2079,
+ 12494,4560,
+ 14430,2468,
+ 14573,3914,
+ 14576,3111,
+ 15043,1827,
+ 15207,1329,
+ 16073,6155,
+ 17519,4719,
+ 18345,2148,
+ 18554,2784,
+ 18576,3563,
+};
+
+const Word16 E_ROM_qua_gain7b_const[NB_QUA_GAIN7B * 2] =
+{
+ 123,2777,
+ 369,2102,
+ 404,4368,
+ 693,3486,
+ 1107,719,
+ 1222,1679,
+ 1657,1293,
+ 1667,5547,
+ 1805,2425,
+ 2369,3075,
+ 2489,12063,
+ 2681,1901,
+ 2693,3984,
+ 3031,7547,
+ 3248,990,
+ 3466,2672,
+ 3674,2165,
+ 3718,1513,
+ 3844,3456,
+ 4120,4656,
+ 4748,2967,
+ 4821,19622,
+ 4855,2400,
+ 4912,1776,
+ 5245,3860,
+ 5312,6282,
+ 5500,1176,
+ 5713,2056,
+ 5872,3287,
+ 5960,2662,
+ 6170,9756,
+ 6364,5021,
+ 6545,1476,
+ 6788,2283,
+ 6796,4163,
+ 7038,2949,
+ 7216,1831,
+ 7274,3516,
+ 7707,2510,
+ 8123,5762,
+ 8361,4485,
+ 8376,2110,
+ 8594,3135,
+ 8611,3755,
+ 8634,1570,
+ 8636,2748,
+ 8683,8222,
+ 9274,335,
+ 9512,2404,
+ 9640,5020,
+ 9690,1893,
+ 9778,3361,
+ 9808,15435,
+ 9936,4029,
+ 10194,2767,
+ 10306,6510,
+ 10325,1252,
+ 10686,2186,
+ 10844,32767,
+ 10913,4453,
+ 10968,3078,
+ 11044,1666,
+ 11076,3609,
+ 11398,2509,
+ 11423,5160,
+ 11848,1994,
+ 11997,2823,
+ 12002,3880,
+ 12084,7573,
+ 12129,3325,
+ 12214,5867,
+ 12331,1496,
+ 12450,4245,
+ 12458,2283,
+ 12768,901,
+ 12896,4741,
+ 12898,1811,
+ 12902,2569,
+ 12983,2959,
+ 13173,3331,
+ 13413,2059,
+ 13416,3734,
+ 13429,10641,
+ 13448,1148,
+ 13615,5340,
+ 13674,1425,
+ 13779,2332,
+ 13847,4264,
+ 13909,2657,
+ 13958,6488,
+ 14047,3085,
+ 14130,1648,
+ 14547,1915,
+ 14554,3684,
+ 14749,2739,
+ 14868,5017,
+ 14875,2216,
+ 14898,3197,
+ 14988,1085,
+ 15026,4246,
+ 15375,7971,
+ 15421,1446,
+ 15548,2462,
+ 15722,5920,
+ 15882,3449,
+ 15960,1782,
+ 15994,2863,
+ 16365,3977,
+ 16419,4754,
+ 16472,2162,
+ 17378,3101,
+ 17410,2550,
+ 17743,1339,
+ 17856,5485,
+ 17979,1982,
+ 17996,3628,
+ 18041,7110,
+ 18242,4381,
+ 18602,22207,
+ 19373,12827,
+ 19533,2777,
+ 19640,1678,
+ 19728,2272,
+ 19795,8861,
+ 20065,3275,
+ 20133,4881,
+ 20198,3947,
+ 20290,6128,
+};
+
+/*----------------------------------------------------------------------------------*
+ * Quantization table for scaled innovation energy prediction, Q8 *
+ * Used in "gain_pre.c" *
+ *----------------------------------------------------------------------------------*/
+const Word16 Es_pred_qua[8] =
+{
+ 1521/* 5.9422f Q8*/,
+ 3909/*15.2711f Q8*/,
+ 5987/*23.3857f Q8*/,
+ 7816/*30.5310f Q8*/,
+ 9477/*37.0190f Q8*/,
+ 11124/*43.4539f Q8*/,
+ 12863/*50.2442f Q8*/,
+ 15031/*58.7164f Q8*/
+};
+
+const Word16 Es_pred_qua_2[16] =
+{
+ -1280/*-5.f Q8*/,
+ 0/* 0.f Q8*/,
+ 1280/* 5.f Q8*/,
+ 2560/*10.f Q8*/,
+ 3840/*15.f Q8*/,
+ 5120/*20.f Q8*/,
+ 6400/*25.f Q8*/,
+ 7680/*30.f Q8*/,
+ 8960/*35.f Q8*/,
+ 10240/*40.f Q8*/,
+ 11520/*45.f Q8*/,
+ 12800/*50.f Q8*/,
+ 14080/*55.f Q8*/,
+ 15360/*60.f Q8*/,
+ 16640/*65.f Q8*/,
+ 17920/*70.f Q8*/
+};
+
+
+const Word16 lag_window_8k[2][16] = /* LAGW_STRONG */
+{
+ /* h */ { 32728, 32619, 32438, 32187, 31867, 31480, 31029, 30517, 29946, 29321, 28645, 27923, 27158, 26356, 25521, 24658 },
+ /* l */ { 11904, 17280, 30720, 25856, 24192, 28992, 24384, 7360, 19456, 14720, 22080, 12928, 31040, 27328, 22080, 5184 }
+};
+const Word16 lag_window_12k8[NUM_LAGW_STRENGTHS][2][16] =
+{
+ /* LAGW_WEAK */
+ {
+ /* h */ { 32763, 32758, 32750, 32739, 32725, 32707, 32687, 32663, 32637, 32607, 32574, 32538, 32498, 32456, 32411, 32362 },
+ /* l */ { 4736, 13312, 16896, 15360, 8896, 30464, 14528, 27008, 2496, 6720, 7296, 4480, 31424, 22976, 12160, 32384 }
+ },
+ /* LAGW_MEDIUM */
+ {
+ /* h */ { 32758, 32739, 32707, 32663, 32607, 32538, 32456, 32362, 32257, 32139, 32009, 31867, 31714, 31549, 31374, 31187 },
+ /* l */ { 13312, 15360, 30464, 27008, 6720, 4480, 22976, 32384, 3520, 5888, 11200, 24192, 17472, 29376, 576, 3136 }
+ },
+ /* LAGW_STRONG */
+ {
+ /* h */ { 32750, 32707, 32637, 32538, 32411, 32257, 32075, 31867, 31633, 31374, 31089, 30780, 30449, 30094, 29718, 29321 },
+ /* l */ { 16896, 30464, 2496, 4480, 12160, 3520, 24256, 24192, 20736, 576, 18240, 31488, 128, 16704, 11520, 14720 }
+ }
+};
+const Word16 lag_window_16k[NUM_LAGW_STRENGTHS][2][16] =
+{
+ /* LAGW_WEAK */
+ {
+ /* h */ { 32763, 32760, 32755, 32748, 32739, 32728, 32715, 32700, 32682, 32663, 32642, 32619, 32594, 32567, 32538, 32507 },
+ /* l */ { 23360, 22272, 20672, 18304, 15360, 11904, 8000, 3648, 31808, 27008, 22080, 17280, 12608, 8256, 4480, 1344 }
+ },
+ /* LAGW_MEDIUM */
+ {
+ /* h */ { 32760, 32748, 32728, 32700, 32663, 32619, 32567, 32507, 32438, 32362, 32279, 32187, 32088, 31981, 31867, 31746 },
+ /* l */ { 22272, 18304, 11904, 3648, 27008, 17280, 8256, 1344, 30720, 32384, 8256, 25856, 21824, 31360, 24192, 3072 }
+ },
+ /* LAGW_STRONG */
+ {
+ /* h */ { 32755, 32728, 32682, 32619, 32538, 32438, 32322, 32187, 32036, 31867, 31682, 31480, 31263, 31029, 30780, 30517 },
+ /* l */ { 20672, 11904, 31808, 17280, 4480, 30720, 2944, 25856, 8320, 24192, 16896, 28992, 5824, 24384, 31488, 7360 }
+ }
+};
+const Word16 lag_window_25k6[NUM_LAGW_STRENGTHS][2][16] =
+{
+ /* LAGW_WEAK */
+ {
+ /* h */ { 32764, 32763, 32761, 32758, 32754, 32750, 32745, 32739, 32732, 32725, 32716, 32707, 32698, 32687, 32676, 32663 },
+ /* l */ { 10752, 4736, 5568, 13312, 28096, 16896, 12672, 15360, 25024, 8896, 32576, 30464, 2624, 14528, 832, 27008 }
+ },
+ /* LAGW_MEDIUM */
+ {
+ /* h */ { 32763, 32758, 32750, 32739, 32725, 32707, 32687, 32663, 32637, 32607, 32574, 32538, 32498, 32456, 32411, 32362 },
+ /* l */ { 4736, 13312, 16896, 15360, 8896, 30464, 14528, 27008, 2496, 6720, 7296, 4480, 31424, 22976, 12160, 32384 }
+ },
+ /* LAGW_STRONG */
+ {
+ /* h */ { 32761, 32750, 32732, 32707, 32676, 32637, 32591, 32538, 32478, 32411, 32337, 32257, 32169, 32075, 31975, 31867 },
+ /* l */ { 5568, 16896, 25024, 30464, 832, 2496, 3328, 4480, 7040, 12160, 21440, 3520, 25728, 24256, 1216, 24192 }
+ }
+};
+const Word16 lag_window_32k[NUM_LAGW_STRENGTHS][2][16] =
+{
+ /* LAGW_WEAK */
+ {
+ /* h */ { 32764, 32763, 32762, 32760, 32758, 32755, 32752, 32748, 32744, 32739, 32734, 32728, 32722, 32715, 32707, 32700 },
+ /* l */ { 15424, 23360, 14720, 22272, 13312, 20672, 11328, 18304, 8704, 15360, 5504, 11904, 1792, 8000, 30464, 3648 }
+ },
+ /* LAGW_MEDIUM */
+ {
+ /* h */ { 32763, 32760, 32755, 32748, 32739, 32728, 32715, 32700, 32682, 32663, 32642, 32619, 32594, 32567, 32538, 32507 },
+ /* l */ { 23360, 22272, 20672, 18304, 15360, 11904, 8000, 3648, 31808, 27008, 22080, 17280, 12608, 8256, 4480, 1344 }
+ },
+ /* LAGW_STRONG */
+ {
+ /* h */ { 32762, 32755, 32744, 32728, 32707, 32682, 32653, 32619, 32581, 32538, 32490, 32438, 32382, 32322, 32257, 32187 },
+ /* l */ { 14720, 20672, 8704, 11904, 30464, 31808, 16384, 17280, 2240, 4480, 24704, 30720, 23168, 2944, 3520, 25856 }
+ }
+};
+const Word16 lag_window_48k[2][16] = /* LAGW_STRONG */
+{
+ /* h */ { 32763, 32760, 32755, 32748, 32739, 32728, 32715, 32700, 32682, 32663, 32642, 32619, 32594, 32567, 32538, 32507 },
+ /* l */ { 23360, 22272, 20672, 18304, 15360, 11904, 8000, 3648, 31808, 27008, 22080, 17280, 12608, 8256, 4480, 1344 }
+};
+
+
+#define W16(x) ((Word16)x)
+
+const Word16 d_array[18] = { 1, 2, 5, 8, 10, 15, 20, 30, 40, 60, 80, 120, 140, 160, 180, 220, 260, 300 };
+const Word16 m_array[18] = { 0/*0.000f Q15*/, 8520/*0.260f Q15*/, 15729/*0.480f Q15*/, 19005/*0.580f Q15*/, 19988/*0.610f Q15*/, 21889/*0.668f Q15*/, 23101/*0.705f Q15*/, 24969/*0.762f Q15*/, 26214/*0.800f Q15*/, 27558/*0.841f Q15*/, 28344/*0.865f Q15*/, 29164/*0.890f Q15*/, 29491/*0.900f Q15*/, 29819/*0.910f Q15*/, 30147/*0.920f Q15*/, 30474/*0.930f Q15*/, 30638/*0.935f Q15*/, 30802/*0.940f Q15*/ };
+const Word16 msQeqInvAv_thresh[3] = { 328/*0.01f Q15*/, 983/*0.03f Q15*/, 1638/*0.05f Q15*/ };
+const Word16 msNoiseSlopeMax[4] = { 32767/*2.f Q14*/, 26214/*1.6f Q14*/, 21299/*1.3f Q14*/, 18022/*1.1f Q14*/ };
+const Word16 preemphCompensation[NB_BANDS] = { 19960/*9.7461f Q11*/, 19493/*9.5182f Q11*/, 18486/*9.0262f Q11*/, 17099/*8.3493f Q11*/, 15516/*7.5764f Q11*/, 13893/*6.7838f Q11*/, 11956/*5.8377f Q11*/, 9933/*4.8502f Q11*/, 8263/*4.0346f Q11*/, 6715/*3.2788f Q11*/, 5383/*2.6283f Q11*/, 4284/*2.0920f Q11*/, 3339/*1.6304f Q11*/, 2632/*1.2850f Q11*/, 2070/*1.0108f Q11*/, 1621/*0.7916f Q11*/, 1284/*0.6268f Q11*/, 1026/*0.5011f Q11*/, 844/*0.4119f Q11*/, 745/*0.3637f Q11*/ };
+
+const SCALE_SETUP scaleTable[20] =
+{
+ { 0, 8000, -704/*-5.5f Q7*/, 0 },
+ { 8000, 9600, -640/*-5.0f Q7*/, 0 },
+ { 9600, 13200, -512/*-4.0f Q7*/, 0 },
+ { 13200, 16400, -384/*-3.0f Q7*/, 0 },
+ { 16400, 24400, -192/*-1.5f Q7*/, 0 },
+ { 24400, 64001, -64/*-0.5f Q7*/, 0 },
+
+ { 0, 8000, -704/*-5.5f Q7*/, 1 },
+ { 8000, 9600, -640/*-5.0f Q7*/, 1 },
+
+ { 9600, 13200, -198/*-1.55f Q7*/, 1 },
+ { 13200, 16400, -384/*-3.0f Q7*/, 1 },
+
+ { 16400, 24400, -77/*-0.6f Q7*/, 1 },
+ { 24400, 32000, -26/*-0.2f Q7*/, 1 },
+ { 32000,128001, 0/* 0.0f Q7*/, 1 },
+
+ { 0, 8000, -115/*-0.9f Q7*/, 2 },
+ { 8000, 9600, -83/*-0.65f Q7*/, 2 },
+ { 9600, 13200, -256/*-2.0f Q7*/, 2 },
+ { 13200, 16400, -384/*-3.0f Q7*/, 2 },
+
+ { 16400, 24400, -102/*-0.8f Q7*/, 2 },
+ { 24400, 32000, -32/*-0.25f Q7*/, 2 },
+ { 32000,128001, 0/* 0.0f Q7*/, 2 },
+};
+
+/*
+ Element scale is precalculated in the following way (fomat: Q2.14):
+ - scaleTable_cn_only[i].scale = pow( 10.f,-scaleTable_cn_only[i].scale/10.f ) - 1.f;
+*/
+const SCALE_SETUP scaleTable_cn_only[18] =
+{
+ { 0, 8000, 20295/*1.2387211385 Q14*/ /*-3.5f*/, 0 },
+ { 8000, 9600, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 0 },
+ { 9600, 13200, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 0 },
+ { 13200, 16400, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 0 },
+ { 16400,128001, 0/*0.0000000000 Q14*/ /* 0.0f*/, 0 },
+
+ { 0, 8000, 16306/*0.9952622652 Q14*/ /*-3.0f*/, 1 },
+ { 8000, 9600, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 1 },
+ { 9600, 13200, 6759/*0.4125375748 Q14*/ /*-1.5f*/, 1 },
+ { 13200, 16400, 12751/*0.7782794237 Q14*/ /*-2.5f*/, 1 },
+ { 16400, 24400, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 1 },
+ { 24400,128001, 0/*0.0000000000 Q14*/ /* 0.0f*/, 1 },
+
+ { 0, 8000, 12751/*0.7782794237 Q14*/ /*-2.0f*/, 2 },
+ { 8000, 9600, 12751/*0.7782794237 Q14*/ /*-2.0f*/, 2 },
+ { 9600, 13200, 9583/*0.5848932266 Q14*/ /*-2.0f*/, 2 },
+ { 13200, 16400, 4242/*0.2589254379 Q14*/ /*-1.0f*/, 2 },
+
+ { 16400, 24400, 1999/*0.1220184565 Q14*/ /*-0.5f*/, 2 },
+ { 24400, 32000, 0/*0.0000000000 Q14*/ /* 0.0f*/, 2 },
+ { 32000,128001, 0/*0.0000000000 Q14*/ /* 0.0f*/, 2 }
+};
+
+const Word16 scaleTable_cn_only_amrwbio[3][2] =
+{
+ { ACELP_6k60, 24771/*1.5118864315 Q14*/ },
+ { ACELP_8k85, 16306/*0.9952622652 Q14*/ },
+ { ACELP_12k65, 9583/*0.5848932266 Q14*/ },
+};
+
+const Word16 sidparts_encoder_noise_est[24] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259, 264, 269, 279 };
+
+const Word16 sidPartitions_nb[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 159 };
+const Word16 sidPartitions_wb1[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255 };
+const Word16 sidPartitions_wb2[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259 };
+const Word16 sidPartitions_wb3[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 319 };
+const Word16 sidPartitions_swb1[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 259, 264, 269, 274 };
+const Word16 sidPartitions_swb2[] = { 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 58, 68, 80, 92, 108, 126, 148, 176, 212, 255, 319, 324, 329, 339 };
+
+const Word16 shapingPartitions_nb[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 159 };
+const Word16 shapingPartitions_wb1[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 };
+const Word16 shapingPartitions_wb2[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 };
+const Word16 shapingPartitions_wb3[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 148, 176, 212, 256, 308, 319 };
+const Word16 shapingPartitions_swb1[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 135, 148, 162, 176, 192, 212, 232, 255 };
+const Word16 shapingPartitions_swb2[] = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 47, 51, 55, 59, 64, 69, 74, 80, 86, 93, 100, 108, 117, 126, 136, 148, 176, 212, 256, 308, 319 };
+
+const FD_CNG_SETUP FdCngSetup_nb = { 512, 160, sizeof(sidPartitions_nb)/sizeof(Word16), sidPartitions_nb, sizeof(shapingPartitions_nb)/sizeof(Word16), shapingPartitions_nb };
+const FD_CNG_SETUP FdCngSetup_wb1 = { 512, 256, sizeof(sidPartitions_wb1)/sizeof(Word16), sidPartitions_wb1, sizeof(shapingPartitions_wb1)/sizeof(Word16), shapingPartitions_wb1 };
+const FD_CNG_SETUP FdCngSetup_wb2 = { 512, 256, sizeof(sidPartitions_wb2)/sizeof(Word16), sidPartitions_wb2, sizeof(shapingPartitions_wb2)/sizeof(Word16), shapingPartitions_wb2 };
+const FD_CNG_SETUP FdCngSetup_wb3 = { 640, 320, sizeof(sidPartitions_wb3)/sizeof(Word16), sidPartitions_wb3, sizeof(shapingPartitions_wb3)/sizeof(Word16), shapingPartitions_wb3 };
+const FD_CNG_SETUP FdCngSetup_swb1 = { 512, 256, sizeof(sidPartitions_swb1)/sizeof(Word16), sidPartitions_swb1, sizeof(shapingPartitions_swb1)/sizeof(Word16), shapingPartitions_swb1 };
+const FD_CNG_SETUP FdCngSetup_swb2 = { 640, 320, sizeof(sidPartitions_swb2)/sizeof(Word16), sidPartitions_swb2, sizeof(shapingPartitions_swb2)/sizeof(Word16), shapingPartitions_swb2 };
+
+const Word16 maxN_37bits = 24;
+const Word16 maxC_37bits = 8;
+const Word16 stages_37bits = 6;
+const Word16 levels_37bits[6] = { 128, 64, 64, 64, 64, 64 };
+const Word16 bits_37bits[6] = { 7, 6, 6, 6, 6, 6 };
+
+const Word16 cdk_37bits_1_fx[3072] =
+{
+ W16(0x017B), W16(0x0548), W16(0x068C), W16(0x058B), W16(0x0572), W16(0x0577), W16(0x04BC), W16(0x03C0),
+ W16(0x0399), W16(0x0237), W16(0x00A1), W16(0xFEB3), W16(0xFCFA), W16(0xFC2F), W16(0xFACB), W16(0xFA70),
+ W16(0xF914), W16(0xF6A8), W16(0xF439), W16(0xF145), W16(0xF02C), W16(0xEFDD), W16(0xEE63), W16(0xED8C),
+ W16(0x089B), W16(0x0B41), W16(0x08E4), W16(0x079C), W16(0x05CF), W16(0x03F9), W16(0x03E0), W16(0x031E),
+ W16(0x02E2), W16(0x0212), W16(0x0015), W16(0xFECD), W16(0xFF39), W16(0xFE3F), W16(0xFBE8), W16(0xFA04),
+ W16(0xF7FF), W16(0xF5BC), W16(0xF361), W16(0xF14A), W16(0xEFCE), W16(0xEDF1), W16(0xEC58), W16(0xEB8A),
+ W16(0x0815), W16(0x0642), W16(0x0569), W16(0x03C1), W16(0x044B), W16(0x04DB), W16(0x0474), W16(0x03DF),
+ W16(0x0432), W16(0x030C), W16(0x0121), W16(0xFF19), W16(0xFD1C), W16(0xFCAE), W16(0xFAF1), W16(0xF9F7),
+ W16(0xF85E), W16(0xF5DD), W16(0xF370), W16(0xF072), W16(0xEF52), W16(0xEF6F), W16(0xEE06), W16(0xED0C),
+ W16(0x10A9), W16(0x0DA2), W16(0x0C21), W16(0x0A1E), W16(0x0854), W16(0x07D7), W16(0x0690), W16(0x0658),
+ W16(0x043C), W16(0x036E), W16(0x00B9), W16(0xFE78), W16(0xFC8A), W16(0xFAEB), W16(0xF926), W16(0xF6C2),
+ W16(0xF4B5), W16(0xF2B1), W16(0xF0CD), W16(0xEED0), W16(0xEDF7), W16(0xEC97), W16(0xEBD3), W16(0xEB6E),
+ W16(0xFA8A), W16(0x0181), W16(0x03DF), W16(0x04A4), W16(0x0331), W16(0x0599), W16(0x04DB), W16(0x03CB),
+ W16(0x0005), W16(0x0161), W16(0xFF3F), W16(0xFEFE), W16(0xFEC7), W16(0xFCED), W16(0xFB97), W16(0xFBA7),
+ W16(0xFBFC), W16(0xFA73), W16(0xF96A), W16(0xF909), W16(0xF92B), W16(0xF7C3), W16(0xF6C5), W16(0xF5F7),
+ W16(0x1095), W16(0x0E41), W16(0x096C), W16(0x0813), W16(0x0652), W16(0x046A), W16(0x0423), W16(0x0350),
+ W16(0x034C), W16(0x023D), W16(0x0074), W16(0xFEC0), W16(0xFF76), W16(0xFE66), W16(0xFB60), W16(0xF90E),
+ W16(0xF6CC), W16(0xF4B3), W16(0xF27A), W16(0xF058), W16(0xEF09), W16(0xED48), W16(0xEBE3), W16(0xEB2E),
+ W16(0x0DA9), W16(0x0772), W16(0x056E), W16(0x041F), W16(0x039A), W16(0x0308), W16(0x02C3), W16(0x0275),
+ W16(0x0221), W16(0x01B5), W16(0x00ED), W16(0x0049), W16(0xFEF4), W16(0xFD31), W16(0xFC0A), W16(0xFBD5),
+ W16(0xFB17), W16(0xF8FF), W16(0xF705), W16(0xF603), W16(0xF494), W16(0xF2D4), W16(0xF031), W16(0xEDB6),
+ W16(0x14D0), W16(0x0F44), W16(0x0DF3), W16(0x0C0E), W16(0x0938), W16(0x07D3), W16(0x06C1), W16(0x0522),
+ W16(0x0475), W16(0x02EA), W16(0x004B), W16(0xFE88), W16(0xFC2B), W16(0xFAAC), W16(0xF8C9), W16(0xF73A),
+ W16(0xF605), W16(0xF554), W16(0xF3ED), W16(0xF31F), W16(0xF305), W16(0xF26A), W16(0xF225), W16(0xF1E6),
+ W16(0xFE9B), W16(0x0403), W16(0x0558), W16(0x0336), W16(0x0433), W16(0x02F7), W16(0x01DD), W16(0x012C),
+ W16(0x016C), W16(0x0124), W16(0x0041), W16(0xFFAF), W16(0xFF0E), W16(0xFE2D), W16(0xFCE7), W16(0xFC8B),
+ W16(0xFCA0), W16(0xFB7D), W16(0xF975), W16(0xF831), W16(0xF73E), W16(0xF582), W16(0xF394), W16(0xF20E),
+ W16(0x079D), W16(0x0AD6), W16(0x0B5A), W16(0x09A9), W16(0x084A), W16(0x0738), W16(0x066E), W16(0x0608),
+ W16(0x047C), W16(0x02E1), W16(0x0059), W16(0xFE81), W16(0xFCD0), W16(0xFABD), W16(0xF93B), W16(0xF769),
+ W16(0xF5A1), W16(0xF44F), W16(0xF26B), W16(0xEFCD), W16(0xEE85), W16(0xECDA), W16(0xEBE5), W16(0xEB83),
+ W16(0x04A1), W16(0x0509), W16(0x0556), W16(0x044A), W16(0x038A), W16(0x030A), W16(0x02B8), W16(0x0255),
+ W16(0x0212), W16(0x01BB), W16(0x0101), W16(0x0035), W16(0xFEEC), W16(0xFD22), W16(0xFC1D), W16(0xFBF2),
+ W16(0xFB3F), W16(0xF91E), W16(0xF70F), W16(0xF5E9), W16(0xF49C), W16(0xF2E0), W16(0xF02D), W16(0xEDA3),
+ W16(0x0D77), W16(0x0DC1), W16(0x0D75), W16(0x0AA8), W16(0x0814), W16(0x065D), W16(0x0456), W16(0x0451),
+ W16(0x0310), W16(0x02B3), W16(0x0134), W16(0xFEFC), W16(0xFD02), W16(0xFB55), W16(0xFA2D), W16(0xF891),
+ W16(0xF7E0), W16(0xF6F0), W16(0xF59C), W16(0xF425), W16(0xF3A2), W16(0xF253), W16(0xF1DF), W16(0xF188),
+ W16(0x0274), W16(0x04F8), W16(0x0575), W16(0x048C), W16(0x044E), W16(0x0467), W16(0x0413), W16(0x040C),
+ W16(0x0213), W16(0x00C8), W16(0x001D), W16(0xFEF2), W16(0xFE21), W16(0xFCF7), W16(0xFC59), W16(0xFB5C),
+ W16(0xFA76), W16(0xF9A5), W16(0xF914), W16(0xF8D4), W16(0xF853), W16(0xF770), W16(0xF5D5), W16(0xF40D),
+ W16(0x1148), W16(0x0E53), W16(0x09F3), W16(0x085C), W16(0x0711), W16(0x04CC), W16(0x0453), W16(0x03F2),
+ W16(0x03BA), W16(0x0278), W16(0x0090), W16(0xFF0A), W16(0xFED1), W16(0xFD92), W16(0xFA84), W16(0xF871),
+ W16(0xF6BA), W16(0xF489), W16(0xF23B), W16(0xEFD0), W16(0xEED3), W16(0xED71), W16(0xEC93), W16(0xEBF6),
+ W16(0x0AED), W16(0x075D), W16(0x05A3), W16(0x0493), W16(0x0446), W16(0x0463), W16(0x0411), W16(0x0422),
+ W16(0x0219), W16(0x00C6), W16(0x001A), W16(0xFF06), W16(0xFE27), W16(0xFCEF), W16(0xFC57), W16(0xFB4F),
+ W16(0xFA6B), W16(0xF9A0), W16(0xF90D), W16(0xF8CA), W16(0xF827), W16(0xF757), W16(0xF5C4), W16(0xF400),
+ W16(0x155D), W16(0x0F9F), W16(0x0C38), W16(0x09DC), W16(0x07A7), W16(0x053D), W16(0x03A9), W16(0x051C),
+ W16(0x04ED), W16(0x02A2), W16(0x00D4), W16(0xFF7C), W16(0xFDB2), W16(0xFBBA), W16(0xF8EA), W16(0xF824),
+ W16(0xF7FD), W16(0xF68C), W16(0xF3DB), W16(0xF2A3), W16(0xF27D), W16(0xF19C), W16(0xF0C9), W16(0xEFDB),
+ W16(0xFFCD), W16(0x038E), W16(0x0463), W16(0x037C), W16(0x0340), W16(0x02A6), W16(0x02AB), W16(0x0290),
+ W16(0x0288), W16(0x01E2), W16(0x00EF), W16(0x002F), W16(0xFEA6), W16(0xFDA9), W16(0xFCAC), W16(0xFBAE),
+ W16(0xFAAF), W16(0xF96E), W16(0xF84B), W16(0xF6F3), W16(0xF4CD), W16(0xF2DA), W16(0xF0F7), W16(0xEEFD),
+ W16(0x0C53), W16(0x0BF8), W16(0x0C2B), W16(0x0A1A), W16(0x077A), W16(0x0556), W16(0x03F4), W16(0x03E3),
+ W16(0x0259), W16(0x01FA), W16(0x0084), W16(0xFE9B), W16(0xFD34), W16(0xFBF2), W16(0xFAFB), W16(0xF9EA),
+ W16(0xF9DD), W16(0xF9E2), W16(0xF898), W16(0xF6CB), W16(0xF505), W16(0xF2D8), W16(0xF195), W16(0xF0B6),
+ W16(0x07BE), W16(0x054B), W16(0x0435), W16(0x030E), W16(0x03A2), W16(0x03DA), W16(0x0342), W16(0x026B),
+ W16(0x01E4), W16(0x0170), W16(0x00CE), W16(0x0009), W16(0xFDFF), W16(0xFE36), W16(0xFCBF), W16(0xFC00),
+ W16(0xF9B8), W16(0xF7AD), W16(0xF51D), W16(0xF180), W16(0xF15B), W16(0xF1C5), W16(0xF045), W16(0xEF23),
+ W16(0x0FD5), W16(0x0D41), W16(0x0B8A), W16(0x09BD), W16(0x0838), W16(0x0754), W16(0x0692), W16(0x0611),
+ W16(0x0487), W16(0x02ED), W16(0x0044), W16(0xFE7B), W16(0xFCBA), W16(0xFAA6), W16(0xF92D), W16(0xF773),
+ W16(0xF59D), W16(0xF47B), W16(0xF29E), W16(0xEFF4), W16(0xEE86), W16(0xECCF), W16(0xEBD8), W16(0xEB78),
+ W16(0xFDB6), W16(0x0365), W16(0x05CE), W16(0x0610), W16(0x0505), W16(0x035E), W16(0x02CE), W16(0x01CF),
+ W16(0x0089), W16(0x00B8), W16(0xFFD1), W16(0xFF08), W16(0xFEAA), W16(0xFE04), W16(0xFDC1), W16(0xFC29),
+ W16(0xFC4E), W16(0xFB7A), W16(0xFAAD), W16(0xF9D2), W16(0xF818), W16(0xF6F3), W16(0xF5A0), W16(0xF46B),
+ W16(0x1008), W16(0x0D2C), W16(0x08D0), W16(0x0746), W16(0x05AB), W16(0x039D), W16(0x035A), W16(0x0295),
+ W16(0x02A9), W16(0x01D8), W16(0x001B), W16(0xFF0D), W16(0xFF48), W16(0xFE4F), W16(0xFBEB), W16(0xFA8C),
+ W16(0xF912), W16(0xF65C), W16(0xF3E1), W16(0xF14F), W16(0xEF83), W16(0xED7D), W16(0xEBAE), W16(0xEACA),
+ W16(0x0DAD), W16(0x08AD), W16(0x075B), W16(0x059B), W16(0x04DC), W16(0x0476), W16(0x03F2), W16(0x025C),
+ W16(0x010B), W16(0x009F), W16(0xFFDA), W16(0xFE63), W16(0xFDF1), W16(0xFDBE), W16(0xFD7D), W16(0xFC45),
+ W16(0xFB08), W16(0xFA08), W16(0xF8CA), W16(0xF795), W16(0xF5B6), W16(0xF412), W16(0xF2D3), W16(0xF1F4),
+ W16(0x15E3), W16(0x0F2D), W16(0x0DD2), W16(0x0BB2), W16(0x0912), W16(0x080C), W16(0x06B1), W16(0x0509),
+ W16(0x03F9), W16(0x0210), W16(0xFF8C), W16(0xFE56), W16(0xFC61), W16(0xFAFD), W16(0xF94E), W16(0xF7D6),
+ W16(0xF6BB), W16(0xF61C), W16(0xF49D), W16(0xF3F1), W16(0xF3E4), W16(0xF35B), W16(0xF31D), W16(0xF2DF),
+ W16(0x02E6), W16(0x0643), W16(0x0700), W16(0x05A9), W16(0x04E3), W16(0x047E), W16(0x03C0), W16(0x0266),
+ W16(0x012B), W16(0x0098), W16(0xFFD2), W16(0xFE89), W16(0xFDF6), W16(0xFD9F), W16(0xFD4A), W16(0xFC4C),
+ W16(0xFB32), W16(0xFA7B), W16(0xF96E), W16(0xF878), W16(0xF743), W16(0xF5CA), W16(0xF486), W16(0xF36B),
+ W16(0x080C), W16(0x0B47), W16(0x0BE1), W16(0x0A0A), W16(0x086F), W16(0x079C), W16(0x06AD), W16(0x063D),
+ W16(0x0465), W16(0x031D), W16(0x0054), W16(0xFE68), W16(0xFCB0), W16(0xFAAD), W16(0xF917), W16(0xF735),
+ W16(0xF525), W16(0xF3D8), W16(0xF29D), W16(0xF191), W16(0xF0EF), W16(0xF025), W16(0xEF93), W16(0xEF3F),
+ W16(0x0839), W16(0x0628), W16(0x04DB), W16(0x039C), W16(0x0365), W16(0x02CB), W16(0x029E), W16(0x02A9),
+ W16(0x02BC), W16(0x01F6), W16(0x0101), W16(0x0026), W16(0xFEB0), W16(0xFDA0), W16(0xFC84), W16(0xFB74),
+ W16(0xFA68), W16(0xF932), W16(0xF804), W16(0xF691), W16(0xF46D), W16(0xF26E), W16(0xF079), W16(0xEE80),
+ W16(0x0AC8), W16(0x0CCE), W16(0x0DA8), W16(0x0C60), W16(0x0994), W16(0x083E), W16(0x06D0), W16(0x0529),
+ W16(0x03EA), W16(0x0249), W16(0xFFB9), W16(0xFE3A), W16(0xFC21), W16(0xFAFA), W16(0xF90B), W16(0xF78E),
+ W16(0xF65C), W16(0xF571), W16(0xF418), W16(0xF331), W16(0xF33A), W16(0xF29F), W16(0xF24C), W16(0xF219),
+ W16(0x05E1), W16(0x05CC), W16(0x05EE), W16(0x060D), W16(0x0517), W16(0x0357), W16(0x02C0), W16(0x01D0),
+ W16(0x0085), W16(0x00B0), W16(0xFFD1), W16(0xFF12), W16(0xFEAD), W16(0xFE06), W16(0xFDBA), W16(0xFC2D),
+ W16(0xFC50), W16(0xFB87), W16(0xFAB7), W16(0xF9DA), W16(0xF80B), W16(0xF6EC), W16(0xF59D), W16(0xF469),
+ W16(0x11D1), W16(0x0F70), W16(0x0A08), W16(0x087F), W16(0x068E), W16(0x04B0), W16(0x0432), W16(0x0375),
+ W16(0x0389), W16(0x023A), W16(0x0028), W16(0xFEB9), W16(0xFF3A), W16(0xFE36), W16(0xFAFC), W16(0xF915),
+ W16(0xF6F6), W16(0xF510), W16(0xF2CC), W16(0xF0F8), W16(0xEFEB), W16(0xEE83), W16(0xED84), W16(0xECD7),
+ W16(0x0B3B), W16(0x096D), W16(0x06CD), W16(0x050E), W16(0x04AD), W16(0x034C), W16(0x0288), W16(0x0224),
+ W16(0x0190), W16(0x0137), W16(0x0015), W16(0xFF8F), W16(0xFE3C), W16(0xFDD9), W16(0xFD04), W16(0xFC60),
+ W16(0xFB77), W16(0xFAAD), W16(0xF9FB), W16(0xF936), W16(0xF7EF), W16(0xF65B), W16(0xF5A2), W16(0xF4D2),
+ W16(0x16C0), W16(0x0F48), W16(0x0C90), W16(0x09AC), W16(0x0757), W16(0x058C), W16(0x03D0), W16(0x03AF),
+ W16(0x0284), W16(0x0249), W16(0x00FA), W16(0xFF36), W16(0xFD66), W16(0xFC00), W16(0xFB05), W16(0xF96E),
+ W16(0xF8C8), W16(0xF7E7), W16(0xF66D), W16(0xF49F), W16(0xF350), W16(0xF21E), W16(0xF1CA), W16(0xF174),
+ W16(0xFFE5), W16(0x03B4), W16(0x04C3), W16(0x0399), W16(0x0448), W16(0x049E), W16(0x0425), W16(0x035F),
+ W16(0x03B2), W16(0x0263), W16(0x00C3), W16(0xFED0), W16(0xFCF3), W16(0xFCDA), W16(0xFBD9), W16(0xFADE),
+ W16(0xF96B), W16(0xF760), W16(0xF516), W16(0xF1F5), W16(0xF126), W16(0xF0FC), W16(0xEFBB), W16(0xEE91),
+ W16(0x0A14), W16(0x0BD9), W16(0x0A05), W16(0x08A9), W16(0x06EE), W16(0x04E1), W16(0x0468), W16(0x03AB),
+ W16(0x0385), W16(0x026A), W16(0x005B), W16(0xFED5), W16(0xFECC), W16(0xFD95), W16(0xFAE2), W16(0xF8D1),
+ W16(0xF6EB), W16(0xF51F), W16(0xF2F7), W16(0xF0C4), W16(0xEFFB), W16(0xEEB0), W16(0xEDCF), W16(0xED30),
+ W16(0x0A84), W16(0x07B7), W16(0x0699), W16(0x0588), W16(0x04F8), W16(0x0512), W16(0x0439), W16(0x0387),
+ W16(0x0354), W16(0x01E7), W16(0x0081), W16(0xFEBF), W16(0xFD3C), W16(0xFC6A), W16(0xFB27), W16(0xFB1A),
+ W16(0xF9D4), W16(0xF7D3), W16(0xF57F), W16(0xF254), W16(0xF0C2), W16(0xF08D), W16(0xEF08), W16(0xEE09),
+ W16(0x10BB), W16(0x0E08), W16(0x0CA3), W16(0x0ABA), W16(0x0932), W16(0x0815), W16(0x0737), W16(0x0671),
+ W16(0x04A3), W16(0x0325), W16(0x0024), W16(0xFE61), W16(0xFC7D), W16(0xFA41), W16(0xF8AF), W16(0xF6FF),
+ W16(0xF459), W16(0xF2FA), W16(0xF103), W16(0xEF58), W16(0xEE8C), W16(0xED3F), W16(0xEC8D), W16(0xEC48),
+ W16(0xFCE7), W16(0x0381), W16(0x0337), W16(0x05B9), W16(0x054D), W16(0x01C2), W16(0x0285), W16(0x05FF),
+ W16(0x013C), W16(0x0143), W16(0x0019), W16(0xFFAB), W16(0xFE36), W16(0xFDDC), W16(0xFC25), W16(0xFB58),
+ W16(0xFA9A), W16(0xF9FC), W16(0xF8BF), W16(0xF861), W16(0xF87B), W16(0xF713), W16(0xF660), W16(0xF5C9),
+ W16(0x112E), W16(0x0E94), W16(0x08F3), W16(0x07FC), W16(0x0620), W16(0x044C), W16(0x0403), W16(0x035F),
+ W16(0x0357), W16(0x0235), W16(0x0029), W16(0xFEA5), W16(0xFF72), W16(0xFE6C), W16(0xFB9C), W16(0xF945),
+ W16(0xF71B), W16(0xF4FC), W16(0xF2BD), W16(0xF0CA), W16(0xEF8E), W16(0xEDBD), W16(0xEC47), W16(0xEB7F),
+ W16(0x0E4C), W16(0x084A), W16(0x05D9), W16(0x0481), W16(0x034C), W16(0x02CB), W16(0x0294), W16(0x0222),
+ W16(0x01EB), W16(0x018D), W16(0x00E0), W16(0x001B), W16(0xFED4), W16(0xFD0C), W16(0xFC56), W16(0xFC9B),
+ W16(0xFBEE), W16(0xF9CE), W16(0xF7CA), W16(0xF718), W16(0xF5C9), W16(0xF440), W16(0xF1F2), W16(0xEFE7),
+ W16(0x1518), W16(0x0FD5), W16(0x0E18), W16(0x0C03), W16(0x08E7), W16(0x072A), W16(0x0631), W16(0x04D7),
+ W16(0x04EC), W16(0x039D), W16(0x00F4), W16(0xFF9B), W16(0xFC59), W16(0xFA81), W16(0xF87B), W16(0xF6DF),
+ W16(0xF59C), W16(0xF4DC), W16(0xF365), W16(0xF2A1), W16(0xF298), W16(0xF1F8), W16(0xF1A0), W16(0xF168),
+ W16(0x0193), W16(0x04EA), W16(0x0536), W16(0x03C4), W16(0x0354), W16(0x02B6), W16(0x022D), W16(0x01B1),
+ W16(0x01AC), W16(0x011E), W16(0x007D), W16(0xFF96), W16(0xFE78), W16(0xFE21), W16(0xFD66), W16(0xFCDE),
+ W16(0xFC5D), W16(0xFB38), W16(0xFA40), W16(0xF988), W16(0xF86B), W16(0xF70D), W16(0xF58F), W16(0xF3DD),
+ W16(0x0872), W16(0x0B35), W16(0x0BE0), W16(0x0A14), W16(0x085B), W16(0x07D8), W16(0x0687), W16(0x064C),
+ W16(0x042E), W16(0x034F), W16(0x00AC), W16(0xFE7B), W16(0xFC91), W16(0xFAF1), W16(0xF933), W16(0xF6D6),
+ W16(0xF4CC), W16(0xF2CC), W16(0xF0E3), W16(0xEED3), W16(0xEE16), W16(0xECB7), W16(0xEBFA), W16(0xEB9C),
+ W16(0x0708), W16(0x0631), W16(0x05B1), W16(0x0338), W16(0x042E), W16(0x02E0), W16(0x01D3), W16(0x0124),
+ W16(0x0171), W16(0x0125), W16(0x003C), W16(0xFFB6), W16(0xFF19), W16(0xFE36), W16(0xFCDF), W16(0xFC93),
+ W16(0xFCB2), W16(0xFB91), W16(0xF970), W16(0xF83C), W16(0xF74E), W16(0xF596), W16(0xF399), W16(0xF20D),
+ W16(0x0E8A), W16(0x0F20), W16(0x0E41), W16(0x0B71), W16(0x087A), W16(0x0680), W16(0x049F), W16(0x0516),
+ W16(0x03B9), W16(0x02FF), W16(0x00FE), W16(0xFF01), W16(0xFCC6), W16(0xFAF5), W16(0xF9B5), W16(0xF808),
+ W16(0xF723), W16(0xF645), W16(0xF4AE), W16(0xF322), W16(0xF373), W16(0xF254), W16(0xF1FF), W16(0xF1A5),
+ W16(0x0539), W16(0x05F3), W16(0x0351), W16(0x05D6), W16(0x057A), W16(0x01D0), W16(0x02A3), W16(0x061D),
+ W16(0x0131), W16(0x0123), W16(0x001A), W16(0xFFA6), W16(0xFE21), W16(0xFDF1), W16(0xFC22), W16(0xFB38),
+ W16(0xFA75), W16(0xF9E5), W16(0xF892), W16(0xF846), W16(0xF85C), W16(0xF702), W16(0xF669), W16(0xF5E2),
+ W16(0x11C4), W16(0x0EE5), W16(0x09CF), W16(0x086F), W16(0x068D), W16(0x04AD), W16(0x043D), W16(0x0386),
+ W16(0x0384), W16(0x027C), W16(0x0077), W16(0xFED8), W16(0xFF16), W16(0xFDD4), W16(0xFB2A), W16(0xF8DE),
+ W16(0xF6C3), W16(0xF499), W16(0xF24C), W16(0xF02F), W16(0xEF1F), W16(0xEDB6), W16(0xECAD), W16(0xEC0A),
+ W16(0x09CA), W16(0x0743), W16(0x0573), W16(0x03BB), W16(0x034A), W16(0x02AD), W16(0x0229), W16(0x01B9),
+ W16(0x018E), W16(0x0112), W16(0x0075), W16(0xFF8F), W16(0xFE7F), W16(0xFE2A), W16(0xFD67), W16(0xFCF4),
+ W16(0xFC7F), W16(0xFB43), W16(0xFA39), W16(0xF989), W16(0xF871), W16(0xF721), W16(0xF598), W16(0xF3DE),
+ W16(0x16BC), W16(0x10D3), W16(0x0D86), W16(0x0A30), W16(0x079A), W16(0x057B), W16(0x0420), W16(0x0535),
+ W16(0x0495), W16(0x0281), W16(0x00C9), W16(0xFF84), W16(0xFD9F), W16(0xFB53), W16(0xF904), W16(0xF835),
+ W16(0xF809), W16(0xF6A4), W16(0xF4AF), W16(0xF3FE), W16(0xF3EE), W16(0xF31F), W16(0xF259), W16(0xF157),
+ W16(0x01AD), W16(0x053B), W16(0x0656), W16(0x0556), W16(0x046F), W16(0x03B5), W16(0x0334), W16(0x02C7),
+ W16(0x0264), W16(0x01B2), W16(0x00D3), W16(0xFF8F), W16(0xFE4B), W16(0xFD3C), W16(0xFC6F), W16(0xFB21),
+ W16(0xFA52), W16(0xF98D), W16(0xF87D), W16(0xF719), W16(0xF592), W16(0xF3B2), W16(0xF1D6), W16(0xF003),
+ W16(0x0C15), W16(0x0D4E), W16(0x0C6F), W16(0x09F0), W16(0x0798), W16(0x057F), W16(0x03B6), W16(0x053F),
+ W16(0x04D0), W16(0x027D), W16(0x00B2), W16(0xFF76), W16(0xFD90), W16(0xFB93), W16(0xF8F0), W16(0xF84F),
+ W16(0xF81D), W16(0xF6AC), W16(0xF3F7), W16(0xF2AC), W16(0xF2B0), W16(0xF1D0), W16(0xF0FF), W16(0xF006),
+ W16(0x085E), W16(0x06B3), W16(0x05AE), W16(0x0410), W16(0x0456), W16(0x04FE), W16(0x0396), W16(0x01B6),
+ W16(0x01EC), W16(0x01B1), W16(0x00D9), W16(0xFEC7), W16(0xFC6D), W16(0xFD63), W16(0xFD25), W16(0xFC60),
+ W16(0xFACF), W16(0xF9CC), W16(0xF78F), W16(0xF3CC), W16(0xF205), W16(0xF190), W16(0xF022), W16(0xEEC5),
+ W16(0x1269), W16(0x0F13), W16(0x0C2F), W16(0x09FB), W16(0x08A4), W16(0x07AC), W16(0x065B), W16(0x05EC),
+ W16(0x045F), W16(0x0299), W16(0x0050), W16(0xFE59), W16(0xFC74), W16(0xFA2F), W16(0xF8C8), W16(0xF7B8),
+ W16(0xF6A4), W16(0xF54D), W16(0xF3CB), W16(0xF224), W16(0xF148), W16(0xF06F), W16(0xEF7F), W16(0xEE7E),
+ W16(0xFFA0), W16(0xFFC1), W16(0xFFFB), W16(0x0001), W16(0xFFFD), W16(0xFFCA), W16(0xFFF1), W16(0x0006),
+ W16(0xFFE3), W16(0xFFCB), W16(0xFFF5), W16(0xFFD8), W16(0xFFD5), W16(0xFFFA), W16(0xFFE9), W16(0xFFCE),
+ W16(0xFFE8), W16(0xFFEE), W16(0xFFF6), W16(0xFFE1), W16(0x0003), W16(0xFF8C), W16(0xFFD1), W16(0xFF89),
+ W16(0x1069), W16(0x0D77), W16(0x08FD), W16(0x07C3), W16(0x061F), W16(0x03F0), W16(0x03F7), W16(0x0359),
+ W16(0x031A), W16(0x0270), W16(0x001B), W16(0xFED7), W16(0xFF68), W16(0xFE31), W16(0xFBAB), W16(0xF969),
+ W16(0xF779), W16(0xF559), W16(0xF2FD), W16(0xF114), W16(0xEF9C), W16(0xEDC8), W16(0xEC2D), W16(0xEB5B),
+ W16(0x0BD5), W16(0x0963), W16(0x07B7), W16(0x059A), W16(0x0436), W16(0x030F), W16(0x02AB), W16(0x029A),
+ W16(0x0257), W16(0x01D3), W16(0x00C4), W16(0xFF32), W16(0xFE18), W16(0xFDB7), W16(0xFCD5), W16(0xFBB2),
+ W16(0xFB00), W16(0xFA03), W16(0xF8EB), W16(0xF7B3), W16(0xF66E), W16(0xF4C1), W16(0xF341), W16(0xF1C3),
+ W16(0x186B), W16(0x111B), W16(0x0E20), W16(0x0BE5), W16(0x0994), W16(0x082F), W16(0x06C3), W16(0x0601),
+ W16(0x03CB), W16(0x0249), W16(0xFFC8), W16(0xFD34), W16(0xFB66), W16(0xFA33), W16(0xF94F), W16(0xF816),
+ W16(0xF76C), W16(0xF6E3), W16(0xF580), W16(0xF44A), W16(0xF3F4), W16(0xF2F1), W16(0xF2CF), W16(0xF28D),
+ W16(0x02D3), W16(0x06E5), W16(0x0678), W16(0x050E), W16(0x04A0), W16(0x035A), W16(0x027D), W16(0x0212),
+ W16(0x019A), W16(0x0120), W16(0x0016), W16(0xFF9E), W16(0xFE40), W16(0xFDCC), W16(0xFD09), W16(0xFC6A),
+ W16(0xFB8A), W16(0xFAC7), W16(0xFA21), W16(0xF976), W16(0xF835), W16(0xF696), W16(0xF5F2), W16(0xF50D),
+ W16(0x0A01), W16(0x0C87), W16(0x0BD7), W16(0x09CF), W16(0x086E), W16(0x076D), W16(0x062A), W16(0x05DD),
+ W16(0x0447), W16(0x0273), W16(0x0050), W16(0xFE70), W16(0xFC86), W16(0xFA57), W16(0xF910), W16(0xF7E5),
+ W16(0xF6D3), W16(0xF563), W16(0xF3DE), W16(0xF23B), W16(0xF17A), W16(0xF0BD), W16(0xEFBF), W16(0xEE9E),
+ W16(0x0A10), W16(0x079A), W16(0x06A0), W16(0x0554), W16(0x0475), W16(0x03BB), W16(0x0339), W16(0x02DB),
+ W16(0x0266), W16(0x01BF), W16(0x00E0), W16(0xFFA1), W16(0xFE4A), W16(0xFD45), W16(0xFC62), W16(0xFAF5),
+ W16(0xFA2F), W16(0xF979), W16(0xF869), W16(0xF6ED), W16(0xF555), W16(0xF37E), W16(0xF18A), W16(0xEFB7),
+ W16(0x0D46), W16(0x0D11), W16(0x0DEA), W16(0x0C1D), W16(0x0970), W16(0x084C), W16(0x06D2), W16(0x04E1),
+ W16(0x03A5), W16(0x020C), W16(0xFFA4), W16(0xFE5E), W16(0xFC58), W16(0xFB02), W16(0xF934), W16(0xF7BF),
+ W16(0xF692), W16(0xF5F1), W16(0xF48F), W16(0xF3D2), W16(0xF402), W16(0xF368), W16(0xF32B), W16(0xF2F2),
+ W16(0x0876), W16(0x07D2), W16(0x0757), W16(0x0496), W16(0x05DC), W16(0x045E), W16(0x02DF), W16(0x01A8),
+ W16(0x01EA), W16(0x0169), W16(0x0001), W16(0xFF2F), W16(0xFE65), W16(0xFD1C), W16(0xFBA4), W16(0xFB98),
+ W16(0xFBFE), W16(0xFB3B), W16(0xF953), W16(0xF821), W16(0xF7CD), W16(0xF644), W16(0xF4DD), W16(0xF399),
+ W16(0x10A3), W16(0x0E7E), W16(0x0943), W16(0x081D), W16(0x05EA), W16(0x0408), W16(0x037A), W16(0x031F),
+ W16(0x02C7), W16(0x01C3), W16(0x0046), W16(0xFEAD), W16(0xFFE1), W16(0xFEC1), W16(0xFBF2), W16(0xF9BF),
+ W16(0xF7A7), W16(0xF5C0), W16(0xF418), W16(0xF2DA), W16(0xF21C), W16(0xF133), W16(0xF05E), W16(0xEFBD),
+ W16(0x0DD5), W16(0x0AB1), W16(0x07A5), W16(0x05A6), W16(0x039F), W16(0x0209), W16(0x011E), W16(0x0100),
+ W16(0x010F), W16(0x012F), W16(0x008E), W16(0xFFF7), W16(0xFF30), W16(0xFE68), W16(0xFDC0), W16(0xFD5D),
+ W16(0xFCC0), W16(0xFB85), W16(0xFA5F), W16(0xF96C), W16(0xF839), W16(0xF71D), W16(0xF53F), W16(0xF428),
+ W16(0x1716), W16(0x11B9), W16(0x0DD2), W16(0x0A4B), W16(0x078C), W16(0x05AC), W16(0x042E), W16(0x0529),
+ W16(0x04B4), W16(0x0269), W16(0x00B9), W16(0xFF59), W16(0xFD99), W16(0xFB32), W16(0xF900), W16(0xF87D),
+ W16(0xF7F9), W16(0xF6CC), W16(0xF57A), W16(0xF51D), W16(0xF511), W16(0xF454), W16(0xF397), W16(0xF29F),
+ W16(0x02C7), W16(0x058B), W16(0x0656), W16(0x05B0), W16(0x052D), W16(0x04E3), W16(0x03C6), W16(0x02CC),
+ W16(0x02A2), W16(0x01CE), W16(0x00A6), W16(0xFF3B), W16(0xFD87), W16(0xFCC8), W16(0xFB6D), W16(0xFB5E),
+ W16(0xF9F2), W16(0xF7BA), W16(0xF574), W16(0xF25D), W16(0xF166), W16(0xF16B), W16(0xEFD8), W16(0xEF18),
+ W16(0x0910), W16(0x0C5A), W16(0x0967), W16(0x0839), W16(0x065E), W16(0x045E), W16(0x0412), W16(0x036E),
+ W16(0x0345), W16(0x0235), W16(0x006F), W16(0xFEB8), W16(0xFF3E), W16(0xFE47), W16(0xFB6E), W16(0xF930),
+ W16(0xF700), W16(0xF4E2), W16(0xF2AA), W16(0xF095), W16(0xEF83), W16(0xEDD9), W16(0xEC8E), W16(0xEBD7),
+ W16(0x09A7), W16(0x07C5), W16(0x06F4), W16(0x05C1), W16(0x05B1), W16(0x059E), W16(0x04D3), W16(0x03A8),
+ W16(0x037B), W16(0x022E), W16(0x00A4), W16(0xFEBE), W16(0xFCF4), W16(0xFC2C), W16(0xFAC8), W16(0xFA59),
+ W16(0xF8EB), W16(0xF684), W16(0xF414), W16(0xF147), W16(0xF047), W16(0xEFF3), W16(0xEE8A), W16(0xEDC3),
+ W16(0x106C), W16(0x0D7F), W16(0x0BFD), W16(0x0A0C), W16(0x0897), W16(0x079B), W16(0x06B6), W16(0x0638),
+ W16(0x0494), W16(0x0315), W16(0x005C), W16(0xFE8A), W16(0xFCCC), W16(0xFA95), W16(0xF905), W16(0xF730),
+ W16(0xF4BB), W16(0xF34B), W16(0xF14A), W16(0xEF4B), W16(0xEE4B), W16(0xECE3), W16(0xEC19), W16(0xEBD6),
+ W16(0xFB0B), W16(0x0267), W16(0x048B), W16(0x0582), W16(0x03A0), W16(0x0601), W16(0x0513), W16(0x03E6),
+ W16(0x0004), W16(0x019D), W16(0xFF41), W16(0xFF1D), W16(0xFD75), W16(0xFCF1), W16(0xFBE7), W16(0xFBD7),
+ W16(0xFB42), W16(0xFA9B), W16(0xF9D3), W16(0xF97A), W16(0xF991), W16(0xF7F4), W16(0xF72B), W16(0xF5EF),
+ W16(0x10F7), W16(0x0EDE), W16(0x099F), W16(0x089E), W16(0x0663), W16(0x046B), W16(0x041E), W16(0x038F),
+ W16(0x035D), W16(0x0207), W16(0x0097), W16(0xFEB0), W16(0xFF14), W16(0xFE44), W16(0xFB5A), W16(0xF923),
+ W16(0xF705), W16(0xF4FB), W16(0xF2DA), W16(0xF0DF), W16(0xEFC8), W16(0xEDFA), W16(0xEC6A), W16(0xEBA3),
+ W16(0x0F44), W16(0x09B4), W16(0x0661), W16(0x04A1), W16(0x035A), W16(0x02DD), W16(0x0284), W16(0x0201),
+ W16(0x01CE), W16(0x01CB), W16(0x012A), W16(0x0044), W16(0xFEED), W16(0xFD34), W16(0xFC6E), W16(0xFC2C),
+ W16(0xFB81), W16(0xF985), W16(0xF769), W16(0xF645), W16(0xF538), W16(0xF3BD), W16(0xF0F6), W16(0xEE24),
+ W16(0x159C), W16(0x0F76), W16(0x0E25), W16(0x0C81), W16(0x098C), W16(0x083A), W16(0x06FD), W16(0x0592),
+ W16(0x0447), W16(0x027F), W16(0xFF9F), W16(0xFDDE), W16(0xFBC9), W16(0xFB42), W16(0xF8E5), W16(0xF761),
+ W16(0xF618), W16(0xF553), W16(0xF419), W16(0xF34C), W16(0xF35C), W16(0xF2E3), W16(0xF2AB), W16(0xF27E),
+ W16(0xFFEE), W16(0x05AA), W16(0x071D), W16(0x048C), W16(0x05D5), W16(0x0462), W16(0x02D5), W16(0x0197),
+ W16(0x01EF), W16(0x0172), W16(0x000F), W16(0xFF30), W16(0xFE66), W16(0xFD1C), W16(0xFBA3), W16(0xFB95),
+ W16(0xFC03), W16(0xFB3B), W16(0xF952), W16(0xF821), W16(0xF7E2), W16(0xF650), W16(0xF4EB), W16(0xF3A7),
+ W16(0x077D), W16(0x0A1F), W16(0x0ADC), W16(0x0956), W16(0x080F), W16(0x06D7), W16(0x0609), W16(0x0562),
+ W16(0x03B9), W16(0x0259), W16(0x0029), W16(0xFE97), W16(0xFCE1), W16(0xFB12), W16(0xF9D3), W16(0xF82B),
+ W16(0xF6EC), W16(0xF63E), W16(0xF528), W16(0xF2AC), W16(0xF084), W16(0xEE88), W16(0xED6A), W16(0xECA7),
+ W16(0x05E5), W16(0x05FC), W16(0x05B6), W16(0x0489), W16(0x0361), W16(0x02CE), W16(0x0299), W16(0x0210),
+ W16(0x01D8), W16(0x018E), W16(0x00E1), W16(0x0010), W16(0xFEC5), W16(0xFD05), W16(0xFC5B), W16(0xFCA7),
+ W16(0xFC05), W16(0xF9DD), W16(0xF7C1), W16(0xF717), W16(0xF5EC), W16(0xF446), W16(0xF1F0), W16(0xEFE7),
+ W16(0x0FC3), W16(0x0E43), W16(0x0D5A), W16(0x0A7E), W16(0x07E0), W16(0x05F8), W16(0x0422), W16(0x03E4),
+ W16(0x02BD), W16(0x026A), W16(0x00D4), W16(0xFEEF), W16(0xFD6B), W16(0xFBF5), W16(0xFAA4), W16(0xF8FD),
+ W16(0xF838), W16(0xF782), W16(0xF601), W16(0xF4A9), W16(0xF44B), W16(0xF307), W16(0xF2BC), W16(0xF270),
+ W16(0x0367), W16(0x05CB), W16(0x063A), W16(0x0526), W16(0x0498), W16(0x043E), W16(0x03A2), W16(0x02F4),
+ W16(0x0231), W16(0x0138), W16(0x0059), W16(0xFF18), W16(0xFE05), W16(0xFD20), W16(0xFC74), W16(0xFB8F),
+ W16(0xFA94), W16(0xF9C9), W16(0xF96E), W16(0xF949), W16(0xF8F1), W16(0xF80E), W16(0xF680), W16(0xF4B2),
+ W16(0x1231), W16(0x0E64), W16(0x0A87), W16(0x08C5), W16(0x06FC), W16(0x05D6), W16(0x0537), W16(0x04D6),
+ W16(0x03A3), W16(0x02C8), W16(0x002D), W16(0xFE7A), W16(0xFE22), W16(0xFCCD), W16(0xFA62), W16(0xF84A),
+ W16(0xF673), W16(0xF4BD), W16(0xF2A2), W16(0xF06F), W16(0xEFA0), W16(0xEE75), W16(0xEDAD), W16(0xED15),
+ W16(0x0BB9), W16(0x082C), W16(0x065F), W16(0x0530), W16(0x04A2), W16(0x0450), W16(0x03A7), W16(0x02F5),
+ W16(0x022F), W16(0x0136), W16(0x005D), W16(0xFF10), W16(0xFE02), W16(0xFD19), W16(0xFC6E), W16(0xFB88),
+ W16(0xFA8F), W16(0xF9C3), W16(0xF971), W16(0xF949), W16(0xF8E5), W16(0xF80B), W16(0xF680), W16(0xF4B1),
+ W16(0x1535), W16(0x1077), W16(0x0D5E), W16(0x0A03), W16(0x07A1), W16(0x05C2), W16(0x03E0), W16(0x053D),
+ W16(0x04B8), W16(0x025C), W16(0x009E), W16(0xFF61), W16(0xFD71), W16(0xFB83), W16(0xF8EF), W16(0xF856),
+ W16(0xF834), W16(0xF6D9), W16(0xF455), W16(0xF335), W16(0xF312), W16(0xF22D), W16(0xF15B), W16(0xF05C),
+ W16(0x00C3), W16(0x0490), W16(0x052A), W16(0x0455), W16(0x038A), W16(0x02EC), W16(0x02DF), W16(0x0265),
+ W16(0x021F), W16(0x0177), W16(0x00B8), W16(0xFFBB), W16(0xFE77), W16(0xFD94), W16(0xFCE7), W16(0xFC16),
+ W16(0xFB34), W16(0xFA39), W16(0xF949), W16(0xF82F), W16(0xF630), W16(0xF481), W16(0xF32D), W16(0xF19B),
+ W16(0x0CC9), W16(0x0C4E), W16(0x0C59), W16(0x09DA), W16(0x0795), W16(0x05C3), W16(0x03E9), W16(0x03D1),
+ W16(0x02C0), W16(0x026A), W16(0x00FD), W16(0xFF2B), W16(0xFD60), W16(0xFBC8), W16(0xFABF), W16(0xF92B),
+ W16(0xF88B), W16(0xF7D4), W16(0xF646), W16(0xF445), W16(0xF330), W16(0xF216), W16(0xF1D4), W16(0xF19B),
+ W16(0x0877), W16(0x069D), W16(0x0590), W16(0x0438), W16(0x04B3), W16(0x0508), W16(0x044D), W16(0x0304),
+ W16(0x0374), W16(0x0231), W16(0x00AB), W16(0xFE4C), W16(0xFC8B), W16(0xFC90), W16(0xFC1E), W16(0xFB28),
+ W16(0xF9F8), W16(0xF821), W16(0xF5B6), W16(0xF287), W16(0xF18B), W16(0xF10C), W16(0xEFD5), W16(0xEE9B),
+ W16(0x0FEF), W16(0x0C87), W16(0x0AF8), W16(0x094C), W16(0x0813), W16(0x06D4), W16(0x061E), W16(0x0572),
+ W16(0x03C3), W16(0x0254), W16(0x001C), W16(0xFE86), W16(0xFCDC), W16(0xFB0D), W16(0xF9D8), W16(0xF82F),
+ W16(0xF6E0), W16(0xF631), W16(0xF519), W16(0xF2AD), W16(0xF077), W16(0xEE89), W16(0xED6C), W16(0xECA4),
+ W16(0xFF6F), W16(0x0439), W16(0x05C2), W16(0x0700), W16(0x069C), W16(0x036E), W16(0x02AC), W16(0x011B),
+ W16(0x0056), W16(0x0068), W16(0x0017), W16(0xFF54), W16(0xFE8E), W16(0xFDF1), W16(0xFD91), W16(0xFC01),
+ W16(0xFBF7), W16(0xFA9F), W16(0xF9FE), W16(0xF95F), W16(0xF7F6), W16(0xF6F8), W16(0xF62B), W16(0xF5CD),
+ W16(0x113D), W16(0x0EA0), W16(0x0982), W16(0x0790), W16(0x0603), W16(0x03FC), W16(0x03BB), W16(0x02F3),
+ W16(0x02B1), W16(0x0200), W16(0x0053), W16(0xFEA6), W16(0xFF21), W16(0xFE15), W16(0xFBCF), W16(0xFA70),
+ W16(0xF836), W16(0xF5C7), W16(0xF364), W16(0xF0FE), W16(0xEFB5), W16(0xEE15), W16(0xECF4), W16(0xEC36),
+ W16(0x0D80), W16(0x08AB), W16(0x06F6), W16(0x0577), W16(0x04C6), W16(0x03FE), W16(0x036A), W16(0x0269),
+ W16(0x011F), W16(0x007F), W16(0xFF7D), W16(0xFEDB), W16(0xFE1D), W16(0xFD6A), W16(0xFCEB), W16(0xFCE8),
+ W16(0xFC19), W16(0xFAD7), W16(0xF9CA), W16(0xF8EF), W16(0xF7A0), W16(0xF637), W16(0xF4E5), W16(0xF3C8),
+ W16(0x154E), W16(0x0F85), W16(0x0E6E), W16(0x0C99), W16(0x09C2), W16(0x089D), W16(0x06F1), W16(0x04BB),
+ W16(0x030D), W16(0x01D2), W16(0xFF8A), W16(0xFE83), W16(0xFC74), W16(0xFB0D), W16(0xF947), W16(0xF7B0),
+ W16(0xF692), W16(0xF5F4), W16(0xF492), W16(0xF3EA), W16(0xF3DB), W16(0xF344), W16(0xF300), W16(0xF2C7),
+ W16(0x059C), W16(0x0678), W16(0x0739), W16(0x059B), W16(0x04D3), W16(0x0434), W16(0x03C7), W16(0x029A),
+ W16(0x0135), W16(0x00BA), W16(0xFFCA), W16(0xFE7B), W16(0xFDE8), W16(0xFDB0), W16(0xFD54), W16(0xFC50),
+ W16(0xFB26), W16(0xFA10), W16(0xF8CA), W16(0xF79D), W16(0xF5E8), W16(0xF43C), W16(0xF2F5), W16(0xF200),
+ W16(0x0A2C), W16(0x0BF7), W16(0x0BB0), W16(0x09DA), W16(0x087D), W16(0x079C), W16(0x0640), W16(0x05D4),
+ W16(0x0434), W16(0x0286), W16(0x0059), W16(0xFE6B), W16(0xFC7B), W16(0xFA60), W16(0xF901), W16(0xF7CA),
+ W16(0xF6AE), W16(0xF583), W16(0xF462), W16(0xF368), W16(0xF2E5), W16(0xF24B), W16(0xF1B0), W16(0xF143),
+ W16(0x080E), W16(0x063B), W16(0x04D7), W16(0x03B5), W16(0x032F), W16(0x0286), W16(0x0297), W16(0x0258),
+ W16(0x01F5), W16(0x0194), W16(0x00B5), W16(0xFFEE), W16(0xFEAA), W16(0xFDBF), W16(0xFD14), W16(0xFC38),
+ W16(0xFB7B), W16(0xFA4B), W16(0xF95B), W16(0xF827), W16(0xF5DF), W16(0xF427), W16(0xF2A4), W16(0xF0D8),
+ W16(0x0BF7), W16(0x0DAE), W16(0x0E6C), W16(0x0CA8), W16(0x0988), W16(0x07CC), W16(0x06AC), W16(0x053F),
+ W16(0x0504), W16(0x0391), W16(0x00A8), W16(0xFEE6), W16(0xFBE1), W16(0xFA1C), W16(0xF842), W16(0xF6C8),
+ W16(0xF599), W16(0xF4E4), W16(0xF393), W16(0xF2CE), W16(0xF319), W16(0xF280), W16(0xF238), W16(0xF1FF),
+ W16(0x071A), W16(0x069C), W16(0x0603), W16(0x070B), W16(0x06A3), W16(0x0371), W16(0x02AE), W16(0x0120),
+ W16(0x0054), W16(0x0072), W16(0x0020), W16(0xFF5E), W16(0xFE81), W16(0xFDEB), W16(0xFD8C), W16(0xFBF4),
+ W16(0xFBEF), W16(0xFA96), W16(0xF9F7), W16(0xF954), W16(0xF7CB), W16(0xF6D2), W16(0xF602), W16(0xF59F),
+ W16(0x11C4), W16(0x0EBE), W16(0x09D4), W16(0x083C), W16(0x0610), W16(0x046E), W16(0x0439), W16(0x0387),
+ W16(0x035C), W16(0x0209), W16(0x00B5), W16(0xFE91), W16(0xFF44), W16(0xFE67), W16(0xFB2E), W16(0xF948),
+ W16(0xF6F6), W16(0xF530), W16(0xF34C), W16(0xF1B8), W16(0xF0E9), W16(0xEFBC), W16(0xEEDB), W16(0xEE5B),
+ W16(0x0C81), W16(0x0AAB), W16(0x082C), W16(0x06AA), W16(0x05BA), W16(0x048D), W16(0x02A0), W16(0x01BC),
+ W16(0x0207), W16(0x00EF), W16(0xFF91), W16(0xFE7F), W16(0xFE1E), W16(0xFD9A), W16(0xFCFD), W16(0xFC21),
+ W16(0xFB7F), W16(0xFB22), W16(0xFA12), W16(0xF8D4), W16(0xF79C), W16(0xF67E), W16(0xF578), W16(0xF49A),
+ W16(0x15E4), W16(0x0FAA), W16(0x0D3B), W16(0x0AAE), W16(0x0793), W16(0x055C), W16(0x042F), W16(0x0411),
+ W16(0x024D), W16(0x0223), W16(0x003E), W16(0xFE80), W16(0xFD25), W16(0xFBCD), W16(0xFAB4), W16(0xF9F2),
+ W16(0xFA0B), W16(0xFA0B), W16(0xF8CB), W16(0xF71B), W16(0xF541), W16(0xF318), W16(0xF1D1), W16(0xF0E5),
+ W16(0x00C1), W16(0x04F8), W16(0x05DF), W16(0x04A6), W16(0x04E6), W16(0x051A), W16(0x03EE), W16(0x0222),
+ W16(0x027D), W16(0x01C6), W16(0x00A1), W16(0xFE74), W16(0xFC93), W16(0xFD00), W16(0xFCA2), W16(0xFBD6),
+ W16(0xFA8F), W16(0xF921), W16(0xF6B4), W16(0xF360), W16(0xF234), W16(0xF1CC), W16(0xF098), W16(0xEF7C),
+ W16(0x09A6), W16(0x0B5C), W16(0x08FD), W16(0x0823), W16(0x0635), W16(0x046C), W16(0x0414), W16(0x0355),
+ W16(0x032D), W16(0x020B), W16(0x005C), W16(0xFE99), W16(0xFF5B), W16(0xFE74), W16(0xFB94), W16(0xF948),
+ W16(0xF71E), W16(0xF579), W16(0xF3B1), W16(0xF238), W16(0xF1A5), W16(0xF0B2), W16(0xEFF3), W16(0xEF8A),
+ W16(0x0B75), W16(0x0825), W16(0x06AA), W16(0x05E4), W16(0x058D), W16(0x04CD), W16(0x0380), W16(0x0277),
+ W16(0x0230), W16(0x01A7), W16(0x00CD), W16(0xFF92), W16(0xFDBE), W16(0xFCF0), W16(0xFB7E), W16(0xFB60),
+ W16(0xF9ED), W16(0xF79E), W16(0xF567), W16(0xF25B), W16(0xF175), W16(0xF1B3), W16(0xF00F), W16(0xEF68),
+ W16(0x10BA), W16(0x0DA4), W16(0x0C13), W16(0x0A09), W16(0x0881), W16(0x07B1), W16(0x0695), W16(0x0646),
+ W16(0x0441), W16(0x0314), W16(0x0082), W16(0xFE65), W16(0xFC91), W16(0xFAB2), W16(0xF912), W16(0xF718),
+ W16(0xF54B), W16(0xF40C), W16(0xF2E2), W16(0xF1EA), W16(0xF11C), W16(0xF056), W16(0xEFC2), W16(0xEF69),
+ W16(0xFF55), W16(0x0390), W16(0x0492), W16(0x0613), W16(0x050A), W16(0x0220), W16(0x02D3), W16(0x04A9),
+ W16(0x0184), W16(0x00B1), W16(0xFFC3), W16(0xFF2D), W16(0xFE4D), W16(0xFDF9), W16(0xFCC9), W16(0xFC03),
+ W16(0xFB22), W16(0xFAC1), W16(0xFA3B), W16(0xFA38), W16(0xFA06), W16(0xF8D8), W16(0xF7EA), W16(0xF728),
+ W16(0x11B5), W16(0x0EF5), W16(0x09CB), W16(0x0809), W16(0x064A), W16(0x042E), W16(0x040C), W16(0x0357),
+ W16(0x02F1), W16(0x024E), W16(0x0056), W16(0xFEAF), W16(0xFF65), W16(0xFE60), W16(0xFB98), W16(0xF94B),
+ W16(0xF73A), W16(0xF534), W16(0xF2EF), W16(0xF0CD), W16(0xEF97), W16(0xEE13), W16(0xECFC), W16(0xEC4C),
+ W16(0x0E1A), W16(0x07FF), W16(0x0574), W16(0x0424), W16(0x0308), W16(0x0288), W16(0x025B), W16(0x01DC),
+ W16(0x01A6), W16(0x0194), W16(0x00BD), W16(0xFFF1), W16(0xFED2), W16(0xFD0A), W16(0xFC7C), W16(0xFD39),
+ W16(0xFCBF), W16(0xFAB3), W16(0xF883), W16(0xF858), W16(0xF754), W16(0xF580), W16(0xF326), W16(0xF164),
+ W16(0x1578), W16(0x1060), W16(0x0F1C), W16(0x0D00), W16(0x09C6), W16(0x0813), W16(0x06DB), W16(0x056D),
+ W16(0x051A), W16(0x03B2), W16(0x0098), W16(0xFEA8), W16(0xFBA2), W16(0xF9EC), W16(0xF816), W16(0xF6B4),
+ W16(0xF57B), W16(0xF4BD), W16(0xF36B), W16(0xF2CB), W16(0xF2DA), W16(0xF255), W16(0xF211), W16(0xF1D9),
+ W16(0x037E), W16(0x060E), W16(0x0676), W16(0x0551), W16(0x04A6), W16(0x03E7), W16(0x0350), W16(0x0258),
+ W16(0x0116), W16(0x0082), W16(0xFF71), W16(0xFEE3), W16(0xFE38), W16(0xFD84), W16(0xFCFA), W16(0xFCF9),
+ W16(0xFC31), W16(0xFB55), W16(0xFA9A), W16(0xF9FC), W16(0xF8C4), W16(0xF77C), W16(0xF655), W16(0xF56C),
+ W16(0x084B), W16(0x0BA1), W16(0x0C77), W16(0x0AAE), W16(0x0923), W16(0x080C), W16(0x071E), W16(0x0665),
+ W16(0x04A1), W16(0x0315), W16(0x0026), W16(0xFE65), W16(0xFC85), W16(0xFA45), W16(0xF8C1), W16(0xF712),
+ W16(0xF46E), W16(0xF315), W16(0xF120), W16(0xEF4A), W16(0xEE87), W16(0xED2A), W16(0xEC77), W16(0xEC38),
+ W16(0x0999), W16(0x071B), W16(0x0556), W16(0x042B), W16(0x036A), W16(0x030C), W16(0x02F3), W16(0x0244),
+ W16(0x023C), W16(0x017E), W16(0x00BA), W16(0xFFC4), W16(0xFE76), W16(0xFD99), W16(0xFCD2), W16(0xFC0E),
+ W16(0xFB2C), W16(0xFA4D), W16(0xF98D), W16(0xF8D6), W16(0xF71A), W16(0xF57C), W16(0xF44B), W16(0xF2E6),
+ W16(0x0EC4), W16(0x0F57), W16(0x0DAE), W16(0x0A4B), W16(0x0792), W16(0x05B9), W16(0x042F), W16(0x052A),
+ W16(0x04B9), W16(0x0265), W16(0x00B7), W16(0xFF57), W16(0xFD8E), W16(0xFB34), W16(0xF8FA), W16(0xF87C),
+ W16(0xF7F8), W16(0xF6CD), W16(0xF574), W16(0xF502), W16(0xF522), W16(0xF458), W16(0xF39D), W16(0xF2A2),
+ W16(0x041B), W16(0x055C), W16(0x037A), W16(0x0524), W16(0x046C), W16(0x018B), W16(0x023A), W16(0x0577),
+ W16(0x011B), W16(0x014E), W16(0x000F), W16(0xFF9F), W16(0xFE98), W16(0xFE17), W16(0xFC95), W16(0xFBDD),
+ W16(0xFB20), W16(0xFA7B), W16(0xF99C), W16(0xF917), W16(0xF8F0), W16(0xF7A1), W16(0xF6A6), W16(0xF5EF),
+ W16(0x124C), W16(0x0F7E), W16(0x0A28), W16(0x07F6), W16(0x0685), W16(0x046A), W16(0x0448), W16(0x03B7),
+ W16(0x0369), W16(0x0234), W16(0x0091), W16(0xFE7E), W16(0xFF1D), W16(0xFE27), W16(0xFB41), W16(0xF906),
+ W16(0xF6DA), W16(0xF4B7), W16(0xF2AD), W16(0xF08B), W16(0xEF6C), W16(0xEDE1), W16(0xECAB), W16(0xEBFF),
+ W16(0x0AC7), W16(0x090A), W16(0x066E), W16(0x050B), W16(0x0486), W16(0x0345), W16(0x025D), W16(0x01DD),
+ W16(0x016D), W16(0x00DB), W16(0xFFF7), W16(0xFF86), W16(0xFE3F), W16(0xFDC9), W16(0xFD3F), W16(0xFCD6),
+ W16(0xFC18), W16(0xFB8D), W16(0xFB22), W16(0xFAA9), W16(0xF935), W16(0xF7A8), W16(0xF71D), W16(0xF5F9),
+ W16(0x1773), W16(0x11C9), W16(0x0E4C), W16(0x0B28), W16(0x0863), W16(0x06A2), W16(0x04C0), W16(0x04F4),
+ W16(0x03AC), W16(0x02F9), W16(0x00FF), W16(0xFF05), W16(0xFCDD), W16(0xFAF6), W16(0xF9B8), W16(0xF7F2),
+ W16(0xF720), W16(0xF63F), W16(0xF4B7), W16(0xF379), W16(0xF34D), W16(0xF22F), W16(0xF1E0), W16(0xF189),
+ W16(0x0386), W16(0x0768), W16(0x07CF), W16(0x05BE), W16(0x0445), W16(0x031D), W16(0x02BA), W16(0x02A4),
+ W16(0x0253), W16(0x01D0), W16(0x00B7), W16(0xFF23), W16(0xFE0F), W16(0xFDB2), W16(0xFCC0), W16(0xFBB3),
+ W16(0xFB0F), W16(0xFA0E), W16(0xF8FB), W16(0xF7BA), W16(0xF676), W16(0xF4C6), W16(0xF335), W16(0xF1B7),
+ W16(0x0D50), W16(0x0E22), W16(0x0D40), W16(0x0A33), W16(0x078C), W16(0x058E), W16(0x040F), W16(0x053B),
+ W16(0x04AC), W16(0x0277), W16(0x00BB), W16(0xFF75), W16(0xFD8E), W16(0xFB57), W16(0xF907), W16(0xF847),
+ W16(0xF816), W16(0xF6AD), W16(0xF47E), W16(0xF38D), W16(0xF3A2), W16(0xF2BA), W16(0xF1E9), W16(0xF0F0),
+ W16(0x0956), W16(0x078B), W16(0x0679), W16(0x050A), W16(0x0501), W16(0x04D6), W16(0x03A7), W16(0x0243),
+ W16(0x0288), W16(0x01A6), W16(0x008F), W16(0xFE95), W16(0xFD0F), W16(0xFCDF), W16(0xFC73), W16(0xFBE7),
+ W16(0xFAA5), W16(0xF93B), W16(0xF6D9), W16(0xF3BD), W16(0xF254), W16(0xF203), W16(0xF0F4), W16(0xEFE0),
+ W16(0x1206), W16(0x0EA1), W16(0x0BE4), W16(0x09D1), W16(0x0868), W16(0x0769), W16(0x0635), W16(0x05ED),
+ W16(0x044B), W16(0x029D), W16(0x003D), W16(0xFE68), W16(0xFC72), W16(0xFA57), W16(0xF901), W16(0xF7E0),
+ W16(0xF6D5), W16(0xF5A0), W16(0xF464), W16(0xF31B), W16(0xF272), W16(0xF1E0), W16(0xF13B), W16(0xF0C5),
+ W16(0x0030), W16(0x0026), W16(0xFFFE), W16(0x000F), W16(0x000E), W16(0x002B), W16(0x001B), W16(0xFFFA),
+ W16(0xFFFD), W16(0x0031), W16(0x000C), W16(0xFFF6), W16(0x0000), W16(0x0025), W16(0x000E), W16(0x0019),
+ W16(0x002D), W16(0x000F), W16(0xFFFA), W16(0x0019), W16(0x0004), W16(0x0009), W16(0xFFE3), W16(0x001A),
+ W16(0x1088), W16(0x0E1C), W16(0x0925), W16(0x0774), W16(0x05E9), W16(0x0444), W16(0x03AF), W16(0x031D),
+ W16(0x02ED), W16(0x01D6), W16(0x001A), W16(0xFEAB), W16(0xFF43), W16(0xFE92), W16(0xFC13), W16(0xF9E1),
+ W16(0xF7B9), W16(0xF5B2), W16(0xF370), W16(0xF175), W16(0xF007), W16(0xEE39), W16(0xEC85), W16(0xEBB2),
+ W16(0x0C41), W16(0x0B9B), W16(0x08F6), W16(0x060A), W16(0x047E), W16(0x0367), W16(0x02EB), W16(0x02B5),
+ W16(0x0229), W16(0x01CD), W16(0x00D1), W16(0xFF51), W16(0xFE2E), W16(0xFD6C), W16(0xFC3C), W16(0xFB9B),
+ W16(0xFAF3), W16(0xF9FB), W16(0xF904), W16(0xF794), W16(0xF5EB), W16(0xF448), W16(0xF297), W16(0xF112),
+ W16(0x1841), W16(0x1114), W16(0x0E1F), W16(0x0BC4), W16(0x0928), W16(0x07F2), W16(0x0645), W16(0x0597),
+ W16(0x0320), W16(0x020F), W16(0xFFBD), W16(0xFD59), W16(0xFB76), W16(0xFA6A), W16(0xF9D9), W16(0xF8B4),
+ W16(0xF85A), W16(0xF7E9), W16(0xF6BF), W16(0xF59E), W16(0xF4BC), W16(0xF374), W16(0xF2FA), W16(0xF28E),
+ W16(0x040C), W16(0x085D), W16(0x07F5), W16(0x06B2), W16(0x05B3), W16(0x0489), W16(0x02A3), W16(0x01C6),
+ W16(0x0210), W16(0x00FA), W16(0xFF92), W16(0xFE81), W16(0xFE16), W16(0xFD92), W16(0xFCF3), W16(0xFC22),
+ W16(0xFB81), W16(0xFB21), W16(0xFA10), W16(0xF8D1), W16(0xF7AE), W16(0xF682), W16(0xF57B), W16(0xF499),
+ W16(0x0A70), W16(0x0CC9), W16(0x0C30), W16(0x0A4C), W16(0x08C0), W16(0x07E8), W16(0x068B), W16(0x0608),
+ W16(0x047C), W16(0x02D7), W16(0x0045), W16(0xFE38), W16(0xFC5A), W16(0xFA03), W16(0xF87A), W16(0xF794),
+ W16(0xF68A), W16(0xF541), W16(0xF3C7), W16(0xF219), W16(0xF161), W16(0xF04C), W16(0xEF66), W16(0xEE85),
+ W16(0x09B5), W16(0x0777), W16(0x062C), W16(0x0522), W16(0x041F), W16(0x0379), W16(0x030C), W16(0x028F),
+ W16(0x022B), W16(0x0180), W16(0x00C3), W16(0xFF88), W16(0xFE4D), W16(0xFD43), W16(0xFCCD), W16(0xFBBF),
+ W16(0xFABA), W16(0xF9D8), W16(0xF8C3), W16(0xF794), W16(0xF5E1), W16(0xF440), W16(0xF2BA), W16(0xF0EB),
+ W16(0x0E79), W16(0x0E14), W16(0x0DAD), W16(0x0BF1), W16(0x0986), W16(0x0850), W16(0x069D), W16(0x05E7),
+ W16(0x0365), W16(0x01E7), W16(0xFF95), W16(0xFD26), W16(0xFB64), W16(0xFA4C), W16(0xF992), W16(0xF86A),
+ W16(0xF7F2), W16(0xF753), W16(0xF60A), W16(0xF4B6), W16(0xF478), W16(0xF34C), W16(0xF309), W16(0xF2C1),
+ W16(0x0629), W16(0x085C), W16(0x07B5), W16(0x05D5), W16(0x03A3), W16(0x0232), W16(0x01A6), W16(0x01AA),
+ W16(0x019D), W16(0x0164), W16(0x00B9), W16(0xFF98), W16(0xFE70), W16(0xFE08), W16(0xFDAD), W16(0xFCF3),
+ W16(0xFC70), W16(0xFB8D), W16(0xFA6A), W16(0xF94F), W16(0xF7E8), W16(0xF675), W16(0xF524), W16(0xF3D5),
+ W16(0x11B2), W16(0x0E4F), W16(0x08FA), W16(0x0833), W16(0x0622), W16(0x0493), W16(0x0451), W16(0x02EE),
+ W16(0x02A4), W16(0x0151), W16(0xFFDB), W16(0xFE6E), W16(0xFEA3), W16(0xFE6B), W16(0xFBEF), W16(0xFA4A),
+ W16(0xF887), W16(0xF696), W16(0xF461), W16(0xF27D), W16(0xF1CA), W16(0xF0EB), W16(0xF04C), W16(0xF014),
+ W16(0x0E96), W16(0x0B2E), W16(0x0818), W16(0x05E8), W16(0x03AA), W16(0x0250), W16(0x01F1), W16(0x01F9),
+ W16(0x01D1), W16(0x016C), W16(0x00CA), W16(0xFF64), W16(0xFE0D), W16(0xFDE3), W16(0xFDAE), W16(0xFCC4),
+ W16(0xFC4E), W16(0xFB93), W16(0xFA73), W16(0xF957), W16(0xF7B4), W16(0xF62B), W16(0xF527), W16(0xF3B7),
+ W16(0x17EA), W16(0x10B1), W16(0x0D83), W16(0x0A75), W16(0x07F4), W16(0x0606), W16(0x042B), W16(0x03F9),
+ W16(0x02B8), W16(0x027D), W16(0x00F7), W16(0xFEED), W16(0xFD61), W16(0xFBC5), W16(0xFA88), W16(0xF8F0),
+ W16(0xF82A), W16(0xF775), W16(0xF601), W16(0xF4EB), W16(0xF453), W16(0xF321), W16(0xF2CA), W16(0xF274)
+};
+
+const Word16 cdk_37bits_2_fx[1536] =
+{
+ W16(0xFFB3), W16(0xFFD1), W16(0xFFDB), W16(0xFFB1), W16(0xFFE5), W16(0x0002), W16(0xFFE4), W16(0xFFED),
+ W16(0x0018), W16(0x0058), W16(0x005D), W16(0x006D), W16(0x0055), W16(0x0018), W16(0xFFB1), W16(0xFF83),
+ W16(0xFF6E), W16(0xFF10), W16(0xFEBF), W16(0xFE86), W16(0xFE7C), W16(0xFE80), W16(0xFE8F), W16(0xFEB7),
+ W16(0xFD2D), W16(0xFEBB), W16(0x0033), W16(0x017C), W16(0xFFED), W16(0xFF59), W16(0x0125), W16(0x0143),
+ W16(0xFFA1), W16(0xFFB6), W16(0xFFCD), W16(0xFFD2), W16(0xFF67), W16(0x0008), W16(0x0053), W16(0xFFDB),
+ W16(0xFFC0), W16(0x0014), W16(0xFFC0), W16(0xFF6B), W16(0xFF62), W16(0xFF1F), W16(0xFF27), W16(0xFE5D),
+ W16(0xFE2D), W16(0xFF2A), W16(0xFF78), W16(0xFF50), W16(0xFF70), W16(0xFFA8), W16(0xFF9A), W16(0xFFDD),
+ W16(0xFFED), W16(0xFFEE), W16(0x0005), W16(0x0058), W16(0x0061), W16(0x0046), W16(0x0033), W16(0x0038),
+ W16(0x0028), W16(0x003C), W16(0x0034), W16(0x002D), W16(0xFFCC), W16(0xFFBE), W16(0xFF8D), W16(0xFF79),
+ W16(0xFEF1), W16(0xFF29), W16(0xFF4E), W16(0xFF83), W16(0xFFA8), W16(0xFFE0), W16(0x0016), W16(0x0049),
+ W16(0x0085), W16(0x0044), W16(0x0040), W16(0x002F), W16(0x0001), W16(0xFFF3), W16(0xFFAF), W16(0xFFB5),
+ W16(0xFF89), W16(0xFF71), W16(0xFF59), W16(0xFF44), W16(0xFF48), W16(0xFF52), W16(0xFF54), W16(0xFF57),
+ W16(0x0021), W16(0xFF57), W16(0xFFC3), W16(0xFFEF), W16(0x006E), W16(0x007D), W16(0x0042), W16(0x0015),
+ W16(0x0004), W16(0x0006), W16(0x0015), W16(0x000B), W16(0xFFFA), W16(0xFFB0), W16(0xFFA3), W16(0xFFB1),
+ W16(0xFF96), W16(0xFF7B), W16(0xFF7E), W16(0xFF93), W16(0xFF83), W16(0xFF84), W16(0xFF8F), W16(0xFFA2),
+ W16(0xFFDE), W16(0xFF98), W16(0xFFB5), W16(0xFF7D), W16(0xFFC8), W16(0x004A), W16(0x0095), W16(0x0118),
+ W16(0x0018), W16(0xFFB7), W16(0xFF95), W16(0xFF9B), W16(0xFF9D), W16(0xFF73), W16(0xFFC4), W16(0x0033),
+ W16(0x003B), W16(0xFFAF), W16(0xFFA1), W16(0xFF9B), W16(0x0013), W16(0x0077), W16(0x0058), W16(0x0073),
+ W16(0xFF2B), W16(0xFFBF), W16(0xFFFD), W16(0x003C), W16(0x0040), W16(0x0096), W16(0x0067), W16(0x0095),
+ W16(0x0069), W16(0x003F), W16(0x000F), W16(0xFFE4), W16(0xFFAA), W16(0xFF59), W16(0xFF7C), W16(0xFF83),
+ W16(0xFF92), W16(0xFF82), W16(0xFFA1), W16(0xFFCC), W16(0xFFF5), W16(0x006F), W16(0x00B8), W16(0x00D2),
+ W16(0x0123), W16(0xFFB5), W16(0xFFA8), W16(0xFFC4), W16(0xFFB1), W16(0xFFBE), W16(0xFFDA), W16(0x000D),
+ W16(0x002E), W16(0x0047), W16(0x004A), W16(0x003D), W16(0x0038), W16(0x0008), W16(0xFFE0), W16(0xFFC3),
+ W16(0xFFCA), W16(0xFFA9), W16(0xFFB6), W16(0xFFA2), W16(0xFF8F), W16(0xFF6E), W16(0xFF69), W16(0xFF76),
+ W16(0xFFDE), W16(0xFF74), W16(0xFF2C), W16(0xFEEE), W16(0xFEF8), W16(0xFF28), W16(0xFF7F), W16(0xFFD0),
+ W16(0xFFF8), W16(0x002D), W16(0x007E), W16(0x0075), W16(0x006F), W16(0x006B), W16(0x0068), W16(0x0031),
+ W16(0x0006), W16(0xFFB4), W16(0xFF96), W16(0xFF61), W16(0xFF3E), W16(0xFF33), W16(0xFF24), W16(0xFF32),
+ W16(0xFF74), W16(0x0009), W16(0x000A), W16(0xFF60), W16(0x000F), W16(0x0039), W16(0x002C), W16(0x0019),
+ W16(0xFFED), W16(0xFFF5), W16(0xFFF6), W16(0xFFE6), W16(0x0009), W16(0xFFF4), W16(0xFFFD), W16(0xFFDF),
+ W16(0xFFDC), W16(0xFFAD), W16(0xFFA0), W16(0xFF7E), W16(0xFF5A), W16(0xFF45), W16(0xFF42), W16(0xFF54),
+ W16(0xFFAD), W16(0xFF8E), W16(0xFF94), W16(0xFFD4), W16(0x002A), W16(0xFFDA), W16(0xFF38), W16(0xFF1F),
+ W16(0xFF4F), W16(0xFFCA), W16(0x000A), W16(0x008E), W16(0x00B2), W16(0x0058), W16(0x002B), W16(0x0062),
+ W16(0x005D), W16(0x000C), W16(0xFFDF), W16(0x001B), W16(0x005D), W16(0x0085), W16(0x0044), W16(0x006D),
+ W16(0xFFAB), W16(0xFFA3), W16(0xFF6B), W16(0xFFB2), W16(0xFFEE), W16(0xFFD1), W16(0xFFE9), W16(0xFFFE),
+ W16(0x000A), W16(0xFFF3), W16(0x000A), W16(0x0022), W16(0x002D), W16(0x000B), W16(0x000D), W16(0xFFFC),
+ W16(0xFFEF), W16(0xFFE3), W16(0xFFD6), W16(0xFFDF), W16(0xFFDE), W16(0xFFE5), W16(0xFFF3), W16(0x0003),
+ W16(0x0058), W16(0xFF6D), W16(0xFEDB), W16(0x0148), W16(0x002F), W16(0xFEF8), W16(0x0025), W16(0x00F8),
+ W16(0x007F), W16(0x001A), W16(0xFFFD), W16(0x0016), W16(0x000A), W16(0x0003), W16(0xFF8F), W16(0xFFB0),
+ W16(0xFFC4), W16(0xFFEC), W16(0xFFB3), W16(0xFFB1), W16(0xFF88), W16(0xFF36), W16(0xFECB), W16(0xFE30),
+ W16(0x000E), W16(0x0038), W16(0x00C8), W16(0x0124), W16(0x013B), W16(0x00A4), W16(0x0050), W16(0x0061),
+ W16(0x0053), W16(0x0022), W16(0xFFC3), W16(0xFFC8), W16(0xFFB0), W16(0xFF77), W16(0xFF89), W16(0xFF67),
+ W16(0xFF57), W16(0xFF51), W16(0xFF46), W16(0xFF20), W16(0xFF1B), W16(0xFF2D), W16(0xFF2F), W16(0xFF42),
+ W16(0xFF7C), W16(0xFF55), W16(0xFF89), W16(0xFFC7), W16(0x0030), W16(0x0076), W16(0x003C), W16(0xFFC6),
+ W16(0xFFAA), W16(0xFF6A), W16(0xFF99), W16(0xFFC6), W16(0x002C), W16(0x0079), W16(0x0055), W16(0x0003),
+ W16(0xFFE7), W16(0x0025), W16(0x0019), W16(0xFFE8), W16(0xFFE1), W16(0xFFDC), W16(0xFFEB), W16(0xFFF7),
+ W16(0x0065), W16(0x0005), W16(0xFFC6), W16(0x0050), W16(0x0034), W16(0x003B), W16(0x0021), W16(0xFFFF),
+ W16(0x0016), W16(0x0004), W16(0xFFF6), W16(0x0022), W16(0xFFE4), W16(0xFF9E), W16(0xFFC9), W16(0xFFEF),
+ W16(0x0003), W16(0x001B), W16(0x003A), W16(0x0053), W16(0x0047), W16(0x0049), W16(0x0050), W16(0x005C),
+ W16(0x001D), W16(0xFFFA), W16(0x0042), W16(0x0045), W16(0x0074), W16(0xFFC3), W16(0xFFB3), W16(0xFFCF),
+ W16(0x005C), W16(0x0038), W16(0x003E), W16(0x0038), W16(0x0018), W16(0x0004), W16(0xFFCD), W16(0xFFB4),
+ W16(0xFFA0), W16(0xFFA0), W16(0xFF9C), W16(0xFF96), W16(0xFFA3), W16(0xFF9F), W16(0xFFB6), W16(0xFFD0),
+ W16(0xFED6), W16(0xFFA8), W16(0xFFDC), W16(0xFFD1), W16(0xFFDB), W16(0xFFFF), W16(0x0015), W16(0x0024),
+ W16(0x001F), W16(0x0002), W16(0xFFD6), W16(0xFFDB), W16(0xFFE0), W16(0xFFDC), W16(0x0009), W16(0x0022),
+ W16(0x0036), W16(0x0040), W16(0x0047), W16(0x0068), W16(0x0035), W16(0x001B), W16(0x000A), W16(0x000E),
+ W16(0xFFDD), W16(0xFF6B), W16(0xFF4C), W16(0xFF80), W16(0xFF71), W16(0xFF90), W16(0xFFAF), W16(0xFFCD),
+ W16(0xFFCC), W16(0xFFF8), W16(0x0011), W16(0x0039), W16(0x003A), W16(0x0018), W16(0x0047), W16(0x0064),
+ W16(0x0079), W16(0x0081), W16(0x00DA), W16(0x0122), W16(0x013D), W16(0x014D), W16(0x0166), W16(0x0164),
+ W16(0xFFD7), W16(0xFF25), W16(0xFEAE), W16(0xFEAA), W16(0xFF89), W16(0x0022), W16(0xFFDF), W16(0x0003),
+ W16(0x002B), W16(0x0009), W16(0x0003), W16(0x0020), W16(0x0032), W16(0xFFFE), W16(0xFFE6), W16(0x0001),
+ W16(0x0004), W16(0x000C), W16(0x001D), W16(0x002B), W16(0x0001), W16(0x0016), W16(0x0071), W16(0x0073),
+ W16(0x0078), W16(0x0042), W16(0x0005), W16(0xFFA0), W16(0x003D), W16(0x0046), W16(0x0018), W16(0xFFCE),
+ W16(0xFFF6), W16(0xFFEF), W16(0x0010), W16(0xFFE3), W16(0x0004), W16(0x0003), W16(0xFFF9), W16(0xFFE9),
+ W16(0xFFD6), W16(0xFFC6), W16(0xFFCD), W16(0xFFC6), W16(0xFFB9), W16(0xFFC7), W16(0xFFCB), W16(0xFFDD),
+ W16(0x00A0), W16(0xFFEB), W16(0xFFE2), W16(0xFF8B), W16(0x000C), W16(0x0079), W16(0x007F), W16(0x00BD),
+ W16(0x0098), W16(0x002C), W16(0x000B), W16(0xFFD9), W16(0xFFD6), W16(0xFFB0), W16(0xFF62), W16(0xFF53),
+ W16(0xFF5C), W16(0xFF4D), W16(0xFF42), W16(0xFF63), W16(0xFFAE), W16(0xFFD8), W16(0x0007), W16(0x004E),
+ W16(0xFF5C), W16(0x0027), W16(0x0008), W16(0x001B), W16(0x0020), W16(0x002A), W16(0x0043), W16(0xFFE7),
+ W16(0x0049), W16(0x0023), W16(0x0019), W16(0xFFDB), W16(0xFFFC), W16(0xFFF1), W16(0xFFC8), W16(0xFFB7),
+ W16(0xFFC1), W16(0xFFEF), W16(0x0057), W16(0x00C2), W16(0x00F7), W16(0x0133), W16(0x0193), W16(0x0204),
+ W16(0x00E7), W16(0xFFB8), W16(0xFF59), W16(0xFF4C), W16(0xFFA9), W16(0xFF9E), W16(0xFFB3), W16(0xFFBF),
+ W16(0xFFA9), W16(0xFFC1), W16(0xFFEF), W16(0x001A), W16(0x0053), W16(0x0056), W16(0x0051), W16(0x0071),
+ W16(0x006A), W16(0x0042), W16(0x003B), W16(0x003E), W16(0x0035), W16(0x003A), W16(0x0045), W16(0x0055),
+ W16(0xFF39), W16(0xFFE6), W16(0xFFED), W16(0xFF80), W16(0xFF51), W16(0xFF63), W16(0xFF81), W16(0xFFC1),
+ W16(0x0085), W16(0x00B5), W16(0x0078), W16(0x001F), W16(0xFFFA), W16(0xFFC4), W16(0xFFF2), W16(0x0030),
+ W16(0x005A), W16(0x0026), W16(0x0010), W16(0x0001), W16(0xFFD9), W16(0xFFB9), W16(0xFF83), W16(0xFF55),
+ W16(0xFF8A), W16(0x0105), W16(0x010B), W16(0xFFD4), W16(0xFFBC), W16(0xFF9B), W16(0xFFD3), W16(0xFFFA),
+ W16(0xFFF9), W16(0x0026), W16(0x001B), W16(0x001B), W16(0x0020), W16(0x000A), W16(0x0021), W16(0x002E),
+ W16(0x000E), W16(0x0001), W16(0x0005), W16(0xFFEE), W16(0xFFEA), W16(0x0024), W16(0x0020), W16(0x0022),
+ W16(0xFFB2), W16(0xFFF7), W16(0xFFB1), W16(0xFF56), W16(0xFF75), W16(0xFFB1), W16(0xFFCD), W16(0xFFBF),
+ W16(0xFFD3), W16(0xFFD5), W16(0xFFEF), W16(0xFFF9), W16(0x0003), W16(0x0031), W16(0x0039), W16(0x008B),
+ W16(0x00C8), W16(0x0076), W16(0x0055), W16(0x0034), W16(0x000F), W16(0x0003), W16(0xFFEF), W16(0xFFD6),
+ W16(0x0028), W16(0xFFFC), W16(0xFFFA), W16(0xFFD1), W16(0xFF1C), W16(0x002B), W16(0x001E), W16(0x000D),
+ W16(0x0027), W16(0x0018), W16(0x001B), W16(0xFFF3), W16(0x0029), W16(0x0024), W16(0x000A), W16(0xFFFE),
+ W16(0xFFEB), W16(0xFFED), W16(0xFFFB), W16(0x0002), W16(0xFFFF), W16(0x0004), W16(0x0010), W16(0x001F),
+ W16(0x008D), W16(0x000D), W16(0xFFDE), W16(0xFFE5), W16(0x0016), W16(0xFFFB), W16(0xFFCA), W16(0xFFDE),
+ W16(0xFFBB), W16(0xFFA1), W16(0xFFCE), W16(0xFFD8), W16(0x0006), W16(0x0005), W16(0x000E), W16(0x0080),
+ W16(0x00AB), W16(0x0041), W16(0xFFDE), W16(0xFFA4), W16(0xFF6E), W16(0xFF47), W16(0xFF30), W16(0xFF31),
+ W16(0xFF69), W16(0xFFAC), W16(0xFF93), W16(0xFF7F), W16(0x0021), W16(0x003F), W16(0xFFD0), W16(0xFF89),
+ W16(0xFF75), W16(0xFF81), W16(0xFF9C), W16(0xFF4B), W16(0xFF1F), W16(0x0011), W16(0x015C), W16(0x018B),
+ W16(0x0053), W16(0x001B), W16(0xFF65), W16(0xFED5), W16(0x0002), W16(0x0108), W16(0x0023), W16(0x0033),
+ W16(0xFFC2), W16(0x0007), W16(0x0014), W16(0x008D), W16(0x0088), W16(0x0096), W16(0x00C7), W16(0x0039),
+ W16(0xFFCB), W16(0xFF6F), W16(0xFF89), W16(0xFF74), W16(0xFF8B), W16(0xFFC2), W16(0x000E), W16(0x0031),
+ W16(0x001F), W16(0x0022), W16(0x0056), W16(0x0053), W16(0x0001), W16(0xFF91), W16(0xFF5F), W16(0xFF4A),
+ W16(0x00C6), W16(0x00D2), W16(0x00BF), W16(0x003B), W16(0x0078), W16(0x008A), W16(0x0068), W16(0x0017),
+ W16(0x003D), W16(0x0026), W16(0xFFF2), W16(0xFFC0), W16(0xFFA7), W16(0xFFAB), W16(0xFF98), W16(0xFFC2),
+ W16(0xFFC0), W16(0xFFD2), W16(0xFFCB), W16(0xFFE4), W16(0x0019), W16(0x0033), W16(0x0060), W16(0x0080),
+ W16(0x000D), W16(0xFFE0), W16(0x005B), W16(0xFFFC), W16(0x0006), W16(0xFFEA), W16(0x001F), W16(0x00A3),
+ W16(0x00C5), W16(0x00A1), W16(0x00B4), W16(0x006A), W16(0xFFFF), W16(0xFFB6), W16(0xFF4C), W16(0xFEFA),
+ W16(0xFECE), W16(0xFEDC), W16(0xFF33), W16(0xFF14), W16(0xFF40), W16(0xFF57), W16(0xFF4B), W16(0xFF76),
+ W16(0xFE80), W16(0xFFD5), W16(0x0044), W16(0x0041), W16(0x0053), W16(0x001C), W16(0x0021), W16(0xFFF9),
+ W16(0x000C), W16(0xFFEE), W16(0xFFEB), W16(0x001A), W16(0x0020), W16(0xFFEE), W16(0xFFE3), W16(0xFFD5),
+ W16(0xFFB2), W16(0xFFB4), W16(0xFFAD), W16(0xFFB6), W16(0xFF93), W16(0xFF95), W16(0xFFA8), W16(0xFFB7),
+ W16(0xFF19), W16(0xFEF4), W16(0xFEC3), W16(0xFEBE), W16(0xFF0D), W16(0xFF3D), W16(0xFF49), W16(0xFF58),
+ W16(0xFF69), W16(0xFFA0), W16(0x0011), W16(0x0086), W16(0x0065), W16(0x00AB), W16(0x00BE), W16(0x00F6),
+ W16(0x00B1), W16(0x00C3), W16(0x00C5), W16(0x0089), W16(0x0043), W16(0x0072), W16(0x0060), W16(0x003E),
+ W16(0xFF96), W16(0xFF5F), W16(0xFFE1), W16(0xFF92), W16(0xFF57), W16(0xFF7E), W16(0xFFDA), W16(0x0008),
+ W16(0x00B5), W16(0x0092), W16(0x008C), W16(0x0054), W16(0x0055), W16(0x001D), W16(0xFFC1), W16(0xFF8C),
+ W16(0xFF63), W16(0xFF6F), W16(0xFFAD), W16(0xFFD6), W16(0xFFEE), W16(0x002A), W16(0x0067), W16(0x009F),
+ W16(0x0004), W16(0xFFCC), W16(0x0081), W16(0x0020), W16(0x001C), W16(0x005E), W16(0x000E), W16(0x0018),
+ W16(0xFFEF), W16(0xFFF6), W16(0xFFF2), W16(0xFFEB), W16(0x000F), W16(0xFFEB), W16(0xFFDE), W16(0xFFE6),
+ W16(0xFFE0), W16(0xFFE4), W16(0xFFE4), W16(0xFFD6), W16(0xFFD6), W16(0xFFD9), W16(0xFFED), W16(0x0007),
+ W16(0xFFC3), W16(0xFFB7), W16(0xFF6C), W16(0xFFF4), W16(0x0172), W16(0xFFED), W16(0xFF8F), W16(0x021C),
+ W16(0x00B3), W16(0xFF40), W16(0xFFC8), W16(0xFF96), W16(0xFFD8), W16(0xFF89), W16(0xFF9E), W16(0xFF4E),
+ W16(0xFF5A), W16(0xFFEC), W16(0x0022), W16(0x0023), W16(0x000D), W16(0x0023), W16(0x000D), W16(0xFFF1),
+ W16(0xFF96), W16(0x00A1), W16(0x012A), W16(0x0086), W16(0x005C), W16(0x004A), W16(0x0082), W16(0x0000),
+ W16(0x0052), W16(0x0017), W16(0xFFDD), W16(0xFFD8), W16(0xFFD2), W16(0xFFB4), W16(0xFFA4), W16(0xFFD0),
+ W16(0xFFC1), W16(0xFFE3), W16(0x001D), W16(0x004F), W16(0x0093), W16(0x00BA), W16(0x00DE), W16(0x00E2),
+ W16(0x01E5), W16(0x005B), W16(0x0048), W16(0x004D), W16(0x0075), W16(0x0093), W16(0x0050), W16(0x0020),
+ W16(0x0007), W16(0xFFEE), W16(0xFFE9), W16(0xFFED), W16(0xFFEA), W16(0xFFE8), W16(0xFFC2), W16(0xFF9C),
+ W16(0xFF8E), W16(0xFF89), W16(0xFF8A), W16(0xFF8B), W16(0xFFA4), W16(0xFFBB), W16(0xFFD3), W16(0xFFF3),
+ W16(0x00F1), W16(0x009F), W16(0xFF81), W16(0xFFA5), W16(0xFF99), W16(0xFF36), W16(0xFF3B), W16(0xFFA2),
+ W16(0xFFF9), W16(0x0065), W16(0x005E), W16(0x004D), W16(0x0073), W16(0x0023), W16(0x0047), W16(0x0036),
+ W16(0x0038), W16(0x0018), W16(0xFFD0), W16(0xFFD4), W16(0xFFC4), W16(0xFFBA), W16(0xFFC4), W16(0xFFBE),
+ W16(0xFFC3), W16(0x0081), W16(0x005E), W16(0x0044), W16(0xFFFE), W16(0x0004), W16(0x0034), W16(0x0057),
+ W16(0x005A), W16(0x004B), W16(0x001C), W16(0x0002), W16(0xFFE5), W16(0xFFBE), W16(0xFFA9), W16(0xFFBC),
+ W16(0xFFAA), W16(0xFFA6), W16(0xFFAD), W16(0xFFA9), W16(0xFFA6), W16(0xFF9A), W16(0xFFAE), W16(0xFFC2),
+ W16(0x00A3), W16(0x007B), W16(0x0032), W16(0x005C), W16(0x0084), W16(0x001C), W16(0xFFAC), W16(0xFF34),
+ W16(0xFF86), W16(0xFFC6), W16(0x0020), W16(0x0074), W16(0x0079), W16(0x000F), W16(0xFFEC), W16(0x0014),
+ W16(0x001A), W16(0x0009), W16(0x0015), W16(0x0077), W16(0x00C2), W16(0x0100), W16(0x011E), W16(0x016A),
+ W16(0xFFBA), W16(0x0029), W16(0x0017), W16(0xFFE0), W16(0x0015), W16(0x001F), W16(0xFFF4), W16(0xFFB0),
+ W16(0xFFD2), W16(0xFFBB), W16(0xFFEA), W16(0x0007), W16(0x002A), W16(0x0026), W16(0x0033), W16(0x001C),
+ W16(0x000B), W16(0x0018), W16(0x0029), W16(0x0034), W16(0x004C), W16(0x0079), W16(0x0090), W16(0x00AC),
+ W16(0xFFF1), W16(0xFFCA), W16(0x0002), W16(0x0052), W16(0xFFBE), W16(0xFF5B), W16(0xFFDD), W16(0xFFEC),
+ W16(0xFFDD), W16(0xFFF5), W16(0x003C), W16(0x0050), W16(0x003D), W16(0x0016), W16(0x0027), W16(0x002C),
+ W16(0x0019), W16(0x0017), W16(0x001F), W16(0x0030), W16(0x0021), W16(0x002C), W16(0x0020), W16(0x002B),
+ W16(0x000E), W16(0x0099), W16(0x0075), W16(0x0097), W16(0x009F), W16(0x007B), W16(0x003E), W16(0xFFF5),
+ W16(0xFF9F), W16(0xFFB1), W16(0xFFF0), W16(0xFFF9), W16(0x000F), W16(0x000A), W16(0xFFF9), W16(0xFFC0),
+ W16(0xFFA6), W16(0xFF93), W16(0xFF97), W16(0xFF93), W16(0xFF9E), W16(0xFFAC), W16(0xFFC2), W16(0xFFEC),
+ W16(0x002D), W16(0xFF24), W16(0xFEC4), W16(0x0070), W16(0xFF17), W16(0x0191), W16(0x00DD), W16(0xFFF4),
+ W16(0xFDFE), W16(0x00C4), W16(0xFF19), W16(0x0031), W16(0xFFB2), W16(0xFFED), W16(0xFF78), W16(0x0076),
+ W16(0x00EC), W16(0x00E1), W16(0x007F), W16(0x005A), W16(0x00C6), W16(0x0028), W16(0x00F2), W16(0x01B2),
+ W16(0x0127), W16(0x0076), W16(0x007F), W16(0x007A), W16(0x0041), W16(0x0078), W16(0x003E), W16(0xFFF5),
+ W16(0xFFB0), W16(0xFF89), W16(0xFFA4), W16(0xFFBC), W16(0xFFF0), W16(0x000C), W16(0x003C), W16(0x001E),
+ W16(0x0024), W16(0x003B), W16(0x004F), W16(0x007B), W16(0x0090), W16(0x00AB), W16(0x00B5), W16(0x00C7),
+ W16(0x00B0), W16(0x007D), W16(0x0076), W16(0x0068), W16(0x0056), W16(0x0050), W16(0xFFE6), W16(0x0004),
+ W16(0x0038), W16(0x0040), W16(0x001E), W16(0x002C), W16(0x0022), W16(0xFFC9), W16(0xFFAA), W16(0xFF9B),
+ W16(0xFF7D), W16(0xFF7A), W16(0xFF95), W16(0xFFCF), W16(0x0002), W16(0x0046), W16(0x00A9), W16(0x00F5),
+ W16(0xFF44), W16(0xFFB4), W16(0xFFDB), W16(0xFFD9), W16(0xFF9D), W16(0xFF8B), W16(0xFF71), W16(0xFF5E),
+ W16(0xFF8E), W16(0xFF94), W16(0xFFA9), W16(0xFFF0), W16(0x006F), W16(0x007A), W16(0x00AA), W16(0x00C5),
+ W16(0x00F6), W16(0x0145), W16(0x015F), W16(0x013D), W16(0x0111), W16(0x00FF), W16(0x00DC), W16(0x00C7),
+ W16(0xFEE8), W16(0xFEFE), W16(0xFEDE), W16(0xFF0B), W16(0xFE87), W16(0xFED9), W16(0xFEB8), W16(0xFEF7),
+ W16(0x0069), W16(0x0072), W16(0x00AE), W16(0x009A), W16(0x00B6), W16(0x004F), W16(0xFF68), W16(0x0035),
+ W16(0x022C), W16(0x0238), W16(0x020A), W16(0x0284), W16(0x01BA), W16(0xFFD5), W16(0x003F), W16(0xFF8E),
+ W16(0x00D0), W16(0x000F), W16(0xFFCE), W16(0xFF88), W16(0x0015), W16(0xFFFE), W16(0x003F), W16(0x001A),
+ W16(0x0023), W16(0x0019), W16(0x0029), W16(0xFFF1), W16(0xFFE7), W16(0xFFDC), W16(0xFFBF), W16(0xFFE4),
+ W16(0xFFD7), W16(0xFFDF), W16(0x000D), W16(0x0051), W16(0x0090), W16(0x00C6), W16(0x010D), W16(0x0138),
+ W16(0x00E7), W16(0x00AC), W16(0x0057), W16(0x0021), W16(0x0008), W16(0xFFE6), W16(0xFFE0), W16(0x0021),
+ W16(0x002C), W16(0xFFE0), W16(0xFFFC), W16(0x0001), W16(0x000F), W16(0xFFE8), W16(0xFFFD), W16(0x0006),
+ W16(0x000E), W16(0x000F), W16(0x0021), W16(0x001A), W16(0x0013), W16(0x0006), W16(0x0021), W16(0x0044),
+ W16(0x013C), W16(0x0128), W16(0x00CA), W16(0xFFFD), W16(0xFFC0), W16(0xFFA0), W16(0x0013), W16(0x0077),
+ W16(0x00E3), W16(0x00B9), W16(0x0066), W16(0xFFF7), W16(0xFFD2), W16(0xFFE0), W16(0xFF99), W16(0xFF5A),
+ W16(0xFF78), W16(0xFF7A), W16(0xFF80), W16(0xFF73), W16(0xFF90), W16(0xFF88), W16(0xFF86), W16(0xFF8B),
+ W16(0x0038), W16(0x006D), W16(0x004E), W16(0x0015), W16(0xFFF6), W16(0xFFF0), W16(0x0004), W16(0x000A),
+ W16(0x000E), W16(0xFFEE), W16(0xFFE1), W16(0xFFF1), W16(0xFFE5), W16(0xFFEE), W16(0xFFFA), W16(0x001B),
+ W16(0x0056), W16(0x00A5), W16(0x00D9), W16(0x0103), W16(0x0104), W16(0x0118), W16(0x012A), W16(0x0111),
+ W16(0x0299), W16(0x000F), W16(0xFFE1), W16(0xFFCC), W16(0xFFC8), W16(0xFFC3), W16(0xFFF5), W16(0xFFDB),
+ W16(0x0000), W16(0x0006), W16(0x0029), W16(0x001B), W16(0x001F), W16(0xFFF5), W16(0x0011), W16(0x0011),
+ W16(0x0023), W16(0x002A), W16(0x003B), W16(0x0046), W16(0x004F), W16(0x0049), W16(0x0058), W16(0x0053),
+ W16(0x004B), W16(0x0043), W16(0x0088), W16(0x00CD), W16(0x0037), W16(0xFE8A), W16(0xFEB7), W16(0xFF69),
+ W16(0x0019), W16(0x0084), W16(0x0058), W16(0xFFF1), W16(0xFF76), W16(0x00C5), W16(0x016A), W16(0x0028),
+ W16(0x006B), W16(0x004E), W16(0x001C), W16(0xFFD0), W16(0x0032), W16(0xFFB9), W16(0xFF95), W16(0xFFC6),
+ W16(0xFF8D), W16(0x005A), W16(0x00CB), W16(0x0100), W16(0x0056), W16(0xFFD6), W16(0x001A), W16(0xFFC6),
+ W16(0xFFBE), W16(0xFFE8), W16(0xFFEF), W16(0x0009), W16(0xFFF5), W16(0xFFDD), W16(0xFFF6), W16(0x003D),
+ W16(0x0053), W16(0x00B0), W16(0x00D2), W16(0x0092), W16(0x0050), W16(0x0023), W16(0x0014), W16(0xFFFB),
+ W16(0x0119), W16(0x0057), W16(0x0013), W16(0x0009), W16(0xFFF2), W16(0xFFBD), W16(0xFF9C), W16(0xFF9F),
+ W16(0xFFB8), W16(0xFFB1), W16(0xFFE9), W16(0xFFDE), W16(0xFFFC), W16(0x0036), W16(0x007D), W16(0x0096),
+ W16(0x00A1), W16(0x00CB), W16(0x00FC), W16(0x011C), W16(0x00A5), W16(0x003F), W16(0x0010), W16(0xFFE0),
+ W16(0x007C), W16(0x00BA), W16(0x0029), W16(0xFF86), W16(0xFF34), W16(0xFFD2), W16(0xFFB7), W16(0xFFE5),
+ W16(0x0033), W16(0x0041), W16(0x0035), W16(0xFFFB), W16(0x0037), W16(0x0040), W16(0x000B), W16(0x000C),
+ W16(0x0029), W16(0x0038), W16(0x006F), W16(0x00B3), W16(0x00C6), W16(0x00C4), W16(0x00BB), W16(0x009C),
+ W16(0x00E5), W16(0x00CF), W16(0x0125), W16(0x00BA), W16(0xFFFD), W16(0x0010), W16(0x0007), W16(0xFFA1),
+ W16(0xFFFB), W16(0xFFFE), W16(0x0005), W16(0x000E), W16(0x0004), W16(0xFFDE), W16(0x0026), W16(0x0020),
+ W16(0x0017), W16(0xFFE3), W16(0xFFA9), W16(0xFF84), W16(0xFF5A), W16(0xFF1B), W16(0xFEAE), W16(0xFE61),
+ W16(0xFD6E), W16(0x012D), W16(0x014A), W16(0x01A9), W16(0x02D2), W16(0x02CA), W16(0x01CC), W16(0xFF5B),
+ W16(0xFF28), W16(0xFEF0), W16(0xFE82), W16(0xFDF4), W16(0xFDFF), W16(0xFFE2), W16(0x00A4), W16(0x0063),
+ W16(0xFFC7), W16(0xFF44), W16(0xFEE8), W16(0xFEBA), W16(0xFE4F), W16(0xFF09), W16(0xFE6C), W16(0xFDBE),
+ W16(0xFFD3), W16(0x0007), W16(0x00A0), W16(0x0043), W16(0x0035), W16(0x0060), W16(0x007A), W16(0x0039),
+ W16(0xFFD4), W16(0xFFEE), W16(0xFFB3), W16(0xFFAD), W16(0xFFE3), W16(0x008D), W16(0x0055), W16(0xFF7B),
+ W16(0xFF56), W16(0x0096), W16(0x011B), W16(0x00F3), W16(0x009A), W16(0x006B), W16(0xFFBC), W16(0xFEEB),
+ W16(0x0298), W16(0x01D9), W16(0x0134), W16(0x0082), W16(0x0005), W16(0x002A), W16(0xFFE3), W16(0xFFB3),
+ W16(0xFFCA), W16(0xFFF4), W16(0x0019), W16(0x0036), W16(0x0023), W16(0x0010), W16(0x0011), W16(0xFFF2),
+ W16(0xFFF7), W16(0xFFF5), W16(0xFFFF), W16(0x0001), W16(0x0022), W16(0x003E), W16(0x0047), W16(0x0037)
+};
+
+const Word16 cdk_37bits_3_fx[1536] =
+{
+ W16(0xFFCD), W16(0xFFFB), W16(0xFFC7), W16(0x0024), W16(0x0000), W16(0xFFAB), W16(0x014C), W16(0xFF9A),
+ W16(0xFFF0), W16(0xFFF1), W16(0x0002), W16(0x0015), W16(0xFFF3), W16(0xFFDC), W16(0xFFD2), W16(0x000F),
+ W16(0xFFC6), W16(0xFFF3), W16(0xFFF1), W16(0x0032), W16(0x006F), W16(0x0054), W16(0x008F), W16(0x009B),
+ W16(0x001C), W16(0x0006), W16(0xFFFE), W16(0xFFF3), W16(0xFFDF), W16(0xFF49), W16(0xFFB0), W16(0xFFC8),
+ W16(0xFFFB), W16(0xFFC2), W16(0xFFE5), W16(0xFFBF), W16(0xFFFC), W16(0x00B0), W16(0x0129), W16(0x0079),
+ W16(0xFFB2), W16(0xFF40), W16(0xFF97), W16(0xFF9B), W16(0xFFCB), W16(0xFFB6), W16(0xFFB4), W16(0xFFBD),
+ W16(0xFEFA), W16(0xFFA2), W16(0xFF63), W16(0xFFB2), W16(0xFFAB), W16(0xFFAF), W16(0x000F), W16(0x0024),
+ W16(0x0003), W16(0xFFD1), W16(0xFFF4), W16(0xFFB4), W16(0xFFFC), W16(0x001D), W16(0x0041), W16(0x0066),
+ W16(0x0039), W16(0xFFE5), W16(0xFFE3), W16(0x000D), W16(0x003B), W16(0x0076), W16(0x0069), W16(0x0044),
+ W16(0xFF95), W16(0xFF75), W16(0xFF97), W16(0xFFE8), W16(0x0022), W16(0xFFBB), W16(0x0009), W16(0x0049),
+ W16(0x0046), W16(0x0004), W16(0xFFFA), W16(0x0010), W16(0x001C), W16(0xFFDB), W16(0xFFE9), W16(0xFFCA),
+ W16(0xFFD3), W16(0xFFAE), W16(0xFFAC), W16(0xFFA9), W16(0xFF8C), W16(0xFF7B), W16(0xFF71), W16(0xFF78),
+ W16(0x002E), W16(0xFF90), W16(0xFF94), W16(0xFFA4), W16(0xFFAF), W16(0xFFEF), W16(0x0000), W16(0x0076),
+ W16(0x001E), W16(0x0031), W16(0x0044), W16(0x0081), W16(0xFFFE), W16(0xFFA3), W16(0xFF90), W16(0xFFB4),
+ W16(0xFFF2), W16(0x0053), W16(0x011E), W16(0x0107), W16(0xFF79), W16(0xFFBB), W16(0xFF82), W16(0xFED6),
+ W16(0xFFD0), W16(0x004A), W16(0x002F), W16(0xFF34), W16(0xFF4E), W16(0x0016), W16(0x0007), W16(0x0047),
+ W16(0x004D), W16(0x0025), W16(0x000F), W16(0x0018), W16(0xFFF9), W16(0xFFF9), W16(0xFFDC), W16(0xFFE9),
+ W16(0xFFFF), W16(0xFFCE), W16(0xFFB7), W16(0xFFB8), W16(0xFFB0), W16(0xFFB4), W16(0xFFB1), W16(0xFF9A),
+ W16(0x006B), W16(0xFFDD), W16(0x0002), W16(0xFFE4), W16(0xFFE1), W16(0xFFE2), W16(0xFFD5), W16(0xFFC3),
+ W16(0xFFEC), W16(0xFFE6), W16(0x000D), W16(0xFFD7), W16(0xFF99), W16(0xFFBD), W16(0x0001), W16(0x00C4),
+ W16(0x00D3), W16(0xFF57), W16(0xFF8A), W16(0xFF78), W16(0xFFF6), W16(0xFFEA), W16(0xFFDC), W16(0xFFDC),
+ W16(0xFFD2), W16(0x001D), W16(0x0017), W16(0x0004), W16(0xFFF0), W16(0x0014), W16(0xFFF6), W16(0xFF21),
+ W16(0x0020), W16(0x0041), W16(0x0030), W16(0x000C), W16(0xFFCA), W16(0xFFFF), W16(0x0037), W16(0x003D),
+ W16(0x000A), W16(0xFFEA), W16(0xFFE0), W16(0xFFCC), W16(0xFFD4), W16(0xFFC0), W16(0xFFD0), W16(0xFFCD),
+ W16(0xFF6A), W16(0xFFEF), W16(0xFFFF), W16(0x002C), W16(0xFFC8), W16(0x0077), W16(0x0059), W16(0x000B),
+ W16(0xFFF5), W16(0xFFFA), W16(0xFFF6), W16(0xFFF1), W16(0xFFDD), W16(0xFFCF), W16(0xFFEA), W16(0xFFF1),
+ W16(0x0000), W16(0xFFF9), W16(0xFFE4), W16(0xFFB7), W16(0xFF96), W16(0xFF61), W16(0xFF43), W16(0xFF3C),
+ W16(0xFFE4), W16(0xFFE7), W16(0xFFA0), W16(0xFFA4), W16(0x003D), W16(0x00B1), W16(0x0085), W16(0xFFFC),
+ W16(0xFF91), W16(0xFFCD), W16(0x0002), W16(0x0011), W16(0xFFF4), W16(0x002A), W16(0xFFE1), W16(0xFF92),
+ W16(0xFF8F), W16(0xFF82), W16(0xFF9A), W16(0xFFB1), W16(0xFFBE), W16(0xFFEA), W16(0x0011), W16(0x002A),
+ W16(0xFFAC), W16(0xFFD1), W16(0xFFC2), W16(0xFF84), W16(0xFFCF), W16(0xFFFD), W16(0xFFB5), W16(0xFFA4),
+ W16(0xFFE6), W16(0xFFD3), W16(0x001E), W16(0x0061), W16(0x0062), W16(0xFFFA), W16(0x0023), W16(0x0016),
+ W16(0x000D), W16(0x000E), W16(0x000E), W16(0x0003), W16(0x0009), W16(0x0015), W16(0x000A), W16(0x0002),
+ W16(0xFFB7), W16(0xFFD9), W16(0xFFE4), W16(0xFFBB), W16(0x00F9), W16(0xFFCC), W16(0xFFC6), W16(0xFFA8),
+ W16(0x0026), W16(0x0005), W16(0x0014), W16(0x0039), W16(0x0040), W16(0xFFE4), W16(0xFF68), W16(0xFF9A),
+ W16(0x002F), W16(0x0058), W16(0xFFB2), W16(0x001C), W16(0xFFCC), W16(0xFF92), W16(0xFF7D), W16(0xFF60),
+ W16(0xFFB4), W16(0xFFA5), W16(0xFFEC), W16(0xFFF2), W16(0xFFDD), W16(0xFFF6), W16(0x0033), W16(0x00A0),
+ W16(0x0097), W16(0x0028), W16(0xFFB8), W16(0xFF58), W16(0xFFA8), W16(0x0024), W16(0xFFE4), W16(0xFFE0),
+ W16(0xFFFB), W16(0xFFEB), W16(0xFFE2), W16(0xFFD9), W16(0xFFFC), W16(0xFFF7), W16(0x000F), W16(0x0004),
+ W16(0x0053), W16(0x0020), W16(0x004C), W16(0xFFFC), W16(0x003C), W16(0x0052), W16(0x0027), W16(0x000E),
+ W16(0x0050), W16(0x0024), W16(0x001C), W16(0xFFE9), W16(0xFFDE), W16(0xFFDB), W16(0xFFBA), W16(0xFFB3),
+ W16(0xFF9E), W16(0xFFAD), W16(0xFFA2), W16(0xFFA3), W16(0xFFB2), W16(0xFFAA), W16(0xFFB4), W16(0xFFBC),
+ W16(0xFFF7), W16(0xFFF0), W16(0xFFE4), W16(0x000B), W16(0xFFDE), W16(0xFFE3), W16(0x0024), W16(0xFFB4),
+ W16(0x0062), W16(0x0045), W16(0xFFCB), W16(0xFFB0), W16(0x00DD), W16(0x006B), W16(0xFF74), W16(0xFF89),
+ W16(0x0001), W16(0xFFBB), W16(0xFFCD), W16(0xFF9D), W16(0xFF92), W16(0xFF76), W16(0xFF9F), W16(0xFFCF),
+ W16(0xFF91), W16(0xFF37), W16(0xFFB4), W16(0x00BC), W16(0x004A), W16(0xFFB2), W16(0x001B), W16(0xFF97),
+ W16(0xFF7D), W16(0x0039), W16(0x003C), W16(0xFFE1), W16(0x0007), W16(0xFFEF), W16(0x0045), W16(0x0031),
+ W16(0x0014), W16(0x0069), W16(0x005C), W16(0xFFF5), W16(0xFFE8), W16(0xFFD8), W16(0xFFA5), W16(0xFFCB),
+ W16(0x0024), W16(0x000A), W16(0xFEB4), W16(0x0002), W16(0x0003), W16(0xFFCA), W16(0x002D), W16(0xFFE3),
+ W16(0xFFF5), W16(0xFFE2), W16(0xFFFE), W16(0x000E), W16(0x0008), W16(0x000F), W16(0x0019), W16(0x0032),
+ W16(0xFFDD), W16(0xFFFB), W16(0xFFCE), W16(0xFFBA), W16(0xFFC9), W16(0xFFDE), W16(0x000E), W16(0x003D),
+ W16(0xFFC6), W16(0xFFDD), W16(0xFFA6), W16(0xFFB3), W16(0x0105), W16(0xFFDA), W16(0xFFD0), W16(0xFFCD),
+ W16(0x0000), W16(0xFFB9), W16(0x0018), W16(0xFF8C), W16(0xFFF1), W16(0xFFD9), W16(0x0030), W16(0x002F),
+ W16(0xFFFF), W16(0xFFF1), W16(0xFFF6), W16(0x0000), W16(0xFFFC), W16(0x0017), W16(0x003C), W16(0x004E),
+ W16(0xFED7), W16(0x0028), W16(0x0038), W16(0x0015), W16(0x0006), W16(0xFFF7), W16(0xFFF2), W16(0xFFEC),
+ W16(0xFFD4), W16(0xFFCF), W16(0xFFE3), W16(0x0024), W16(0x0022), W16(0x000D), W16(0x0027), W16(0x0014),
+ W16(0x0010), W16(0x0015), W16(0x0028), W16(0x001C), W16(0x0007), W16(0xFFD2), W16(0xFFBD), W16(0xFF93),
+ W16(0x0068), W16(0xFF90), W16(0x002E), W16(0x007D), W16(0x001B), W16(0x004E), W16(0x000D), W16(0x006E),
+ W16(0x0039), W16(0xFFF7), W16(0xFF97), W16(0x0018), W16(0xFFF1), W16(0xFFC5), W16(0xFF94), W16(0xFFDB),
+ W16(0x0018), W16(0x0003), W16(0x001A), W16(0xFFE9), W16(0xFFBC), W16(0xFF9E), W16(0xFF96), W16(0xFF88),
+ W16(0xFFB0), W16(0xFF7C), W16(0xFF95), W16(0x002C), W16(0xFF96), W16(0xFFB9), W16(0x005F), W16(0x0042),
+ W16(0xFFEA), W16(0xFFBE), W16(0xFFDC), W16(0x0030), W16(0x00AB), W16(0x006D), W16(0xFFC0), W16(0xFFA5),
+ W16(0xFFE0), W16(0x0098), W16(0x007B), W16(0x0017), W16(0x0040), W16(0x0079), W16(0x005B), W16(0x002E),
+ W16(0x0021), W16(0x001A), W16(0x0055), W16(0xFFCE), W16(0xFF7A), W16(0x0058), W16(0x001F), W16(0xFFC7),
+ W16(0xFFCA), W16(0x002E), W16(0x001E), W16(0x0020), W16(0x0004), W16(0x0014), W16(0x000C), W16(0xFFF8),
+ W16(0xFFF7), W16(0xFFE0), W16(0xFFCF), W16(0xFFEF), W16(0x00B1), W16(0x00C8), W16(0xFF9A), W16(0xFF27),
+ W16(0x000D), W16(0x0039), W16(0x0036), W16(0x0009), W16(0xFFC7), W16(0xFFBB), W16(0xFFE9), W16(0x0019),
+ W16(0x0004), W16(0x000D), W16(0x0007), W16(0xFFF6), W16(0xFFF1), W16(0x0018), W16(0x0013), W16(0x003A),
+ W16(0x0017), W16(0xFFAF), W16(0xFF5F), W16(0xFF23), W16(0xFF3C), W16(0xFF6D), W16(0xFFB3), W16(0x0035),
+ W16(0xFFAC), W16(0x0041), W16(0xFFE3), W16(0x0054), W16(0xFFCB), W16(0x003E), W16(0xFFFE), W16(0x000E),
+ W16(0x003A), W16(0x003C), W16(0x0018), W16(0xFFDF), W16(0xFFFB), W16(0x0012), W16(0xFFE9), W16(0xFFC7),
+ W16(0xFFC1), W16(0xFFE2), W16(0xFFFF), W16(0x0009), W16(0x001F), W16(0x0018), W16(0x0015), W16(0x0009),
+ W16(0xFFEA), W16(0xFFBD), W16(0xFFEC), W16(0xFFD1), W16(0xFFF5), W16(0x0036), W16(0x005A), W16(0x002D),
+ W16(0xFFD8), W16(0xFF85), W16(0xFF4D), W16(0xFFA3), W16(0xFFE4), W16(0x0015), W16(0x0097), W16(0x0050),
+ W16(0x0021), W16(0xFFDA), W16(0xFFB6), W16(0x003A), W16(0xFFF8), W16(0xFFD2), W16(0xFFD6), W16(0xFFD8),
+ W16(0x0084), W16(0xFF0B), W16(0xFFEF), W16(0xFFD7), W16(0xFFCF), W16(0x0001), W16(0xFFE0), W16(0xFFFE),
+ W16(0x001C), W16(0x0020), W16(0x0018), W16(0x0005), W16(0xFFF3), W16(0x0009), W16(0xFFFF), W16(0x0007),
+ W16(0xFFF8), W16(0xFFF2), W16(0xFFF3), W16(0x0001), W16(0x0008), W16(0x000A), W16(0x0014), W16(0x000E),
+ W16(0xFFD6), W16(0xFFB8), W16(0xFFC6), W16(0xFFF9), W16(0x0008), W16(0xFFFD), W16(0xFFE6), W16(0x0048),
+ W16(0xFF6D), W16(0x005B), W16(0x0013), W16(0x002F), W16(0xFFD8), W16(0x0003), W16(0x0002), W16(0xFFF8),
+ W16(0xFFEE), W16(0x0008), W16(0xFFFB), W16(0xFFF6), W16(0xFFFC), W16(0xFFFF), W16(0x0002), W16(0x0002),
+ W16(0x0059), W16(0x006C), W16(0xFFE7), W16(0x004C), W16(0x0074), W16(0x0086), W16(0x0037), W16(0xFFA6),
+ W16(0xFFD0), W16(0xFFD6), W16(0xFFC0), W16(0xFFCD), W16(0xFFC3), W16(0xFFD8), W16(0xFFFE), W16(0x0026),
+ W16(0x0037), W16(0x0027), W16(0x0003), W16(0xFFE9), W16(0xFFC5), W16(0xFFB8), W16(0xFFCD), W16(0xFFCF),
+ W16(0x0005), W16(0x0037), W16(0x001E), W16(0xFFFC), W16(0x0022), W16(0x0034), W16(0xFF0F), W16(0x002B),
+ W16(0x0037), W16(0x002D), W16(0x0013), W16(0x0021), W16(0x000C), W16(0x0003), W16(0x000D), W16(0xFFEE),
+ W16(0xFFCF), W16(0xFFE6), W16(0xFFF6), W16(0xFFEC), W16(0xFFDB), W16(0xFFDB), W16(0xFFDC), W16(0xFFCF),
+ W16(0xFF53), W16(0x0078), W16(0x00C4), W16(0xFFC3), W16(0x0051), W16(0x0005), W16(0x0002), W16(0x0022),
+ W16(0x001C), W16(0x0028), W16(0xFFF9), W16(0xFFE4), W16(0xFFF7), W16(0xFFE5), W16(0xFFC9), W16(0xFFE1),
+ W16(0xFFDF), W16(0xFFE1), W16(0xFFE8), W16(0x0007), W16(0x003C), W16(0x005F), W16(0x0083), W16(0x0089),
+ W16(0x00EB), W16(0x0009), W16(0xFFB7), W16(0xFF7B), W16(0xFFD0), W16(0x0024), W16(0xFFC8), W16(0xFFBD),
+ W16(0xFFDF), W16(0xFFE4), W16(0xFFF5), W16(0x002E), W16(0x0023), W16(0x001D), W16(0x002C), W16(0x001B),
+ W16(0x001A), W16(0xFFF8), W16(0xFFEA), W16(0xFFD5), W16(0xFFE9), W16(0xFFD1), W16(0xFFC9), W16(0xFFC1),
+ W16(0xFFE3), W16(0xFFB1), W16(0x0009), W16(0x0096), W16(0x0111), W16(0x00E2), W16(0xFFEA), W16(0xFFBB),
+ W16(0x000E), W16(0xFFF0), W16(0xFFBC), W16(0xFFF9), W16(0xFFC7), W16(0xFF9E), W16(0xFFA3), W16(0xFFBD),
+ W16(0xFFEE), W16(0x001E), W16(0x0002), W16(0x0020), W16(0x0032), W16(0x0051), W16(0x0052), W16(0x0062),
+ W16(0x0032), W16(0x0041), W16(0xFFE4), W16(0xFF9B), W16(0x001C), W16(0xFF48), W16(0x0000), W16(0x002F),
+ W16(0x0015), W16(0x0014), W16(0x003D), W16(0x0026), W16(0xFFF1), W16(0x0015), W16(0xFFF1), W16(0xFFF9),
+ W16(0xFFF0), W16(0xFFF4), W16(0xFFED), W16(0xFFFA), W16(0x000D), W16(0x001C), W16(0x002B), W16(0x0023),
+ W16(0xFFEB), W16(0xFFCF), W16(0x0049), W16(0x0037), W16(0x0039), W16(0xFFBA), W16(0xFFF9), W16(0xFFFD),
+ W16(0x0045), W16(0x0021), W16(0xFF72), W16(0x0033), W16(0x0010), W16(0x0017), W16(0xFFF6), W16(0x0002),
+ W16(0xFFEC), W16(0xFFDB), W16(0xFFD4), W16(0xFFC8), W16(0xFFE3), W16(0xFFF4), W16(0x0015), W16(0x0019),
+ W16(0xFFAC), W16(0xFFB9), W16(0x000E), W16(0xFFA3), W16(0xFF88), W16(0xFFB0), W16(0xFFF1), W16(0xFFEA),
+ W16(0xFFED), W16(0xFFD8), W16(0x0009), W16(0x0004), W16(0xFFEF), W16(0x002C), W16(0x0051), W16(0x004E),
+ W16(0x0062), W16(0x0074), W16(0x0075), W16(0x0055), W16(0x0027), W16(0x000F), W16(0xFFF2), W16(0xFFDA),
+ W16(0xFF96), W16(0xFFB4), W16(0x0033), W16(0x001C), W16(0xFF5C), W16(0xFFC5), W16(0xFFC8), W16(0xFFD7),
+ W16(0x000D), W16(0x0059), W16(0x0077), W16(0x006A), W16(0x002C), W16(0x002D), W16(0x0003), W16(0xFFD2),
+ W16(0xFFCD), W16(0xFFD8), W16(0xFFD0), W16(0xFFED), W16(0xFFEA), W16(0xFFE8), W16(0xFFF9), W16(0xFFF6),
+ W16(0x0052), W16(0xFFD4), W16(0xFF5B), W16(0xFF8B), W16(0xFFA9), W16(0x003F), W16(0x007C), W16(0x0028),
+ W16(0x001B), W16(0x0010), W16(0xFFD1), W16(0xFFCD), W16(0x0004), W16(0xFFCA), W16(0xFFEE), W16(0xFFE7),
+ W16(0x0008), W16(0x0047), W16(0x0086), W16(0x0087), W16(0x0064), W16(0x0024), W16(0x000C), W16(0xFFD7),
+ W16(0x00A6), W16(0x008E), W16(0x0077), W16(0xFFD8), W16(0xFF6A), W16(0x003A), W16(0x003B), W16(0x0017),
+ W16(0x0028), W16(0x0010), W16(0xFFFA), W16(0xFFDE), W16(0xFFFC), W16(0xFFEC), W16(0xFFE0), W16(0x000B),
+ W16(0x0026), W16(0x003C), W16(0x003F), W16(0x003E), W16(0x0049), W16(0x006F), W16(0x0080), W16(0x0080),
+ W16(0xFFB8), W16(0xFFC2), W16(0xFFBE), W16(0x0017), W16(0xFFF9), W16(0xFFF0), W16(0xFFE0), W16(0xFFE4),
+ W16(0x0027), W16(0x0000), W16(0xFFE9), W16(0x00A2), W16(0x002E), W16(0xFF66), W16(0xFF4F), W16(0x0042),
+ W16(0x007C), W16(0xFFE4), W16(0xFFF6), W16(0x000A), W16(0x0039), W16(0x0054), W16(0x0054), W16(0x0033),
+ W16(0xFFD9), W16(0x0003), W16(0x0012), W16(0x0010), W16(0x000B), W16(0x0000), W16(0xFF97), W16(0xFF97),
+ W16(0xFFC8), W16(0x00AF), W16(0x0215), W16(0xFF25), W16(0xFFD7), W16(0xFFF1), W16(0xFF98), W16(0xFFC3),
+ W16(0xFFF2), W16(0x0005), W16(0xFFDA), W16(0x0052), W16(0x0069), W16(0x0051), W16(0x008A), W16(0x00CA),
+ W16(0xFFAB), W16(0xFF9D), W16(0x00C3), W16(0x006D), W16(0x002D), W16(0x006D), W16(0x0064), W16(0x0037),
+ W16(0xFFBA), W16(0xFFA4), W16(0xFFB3), W16(0xFFF0), W16(0xFFFE), W16(0x0045), W16(0x0029), W16(0xFFD6),
+ W16(0xFF87), W16(0xFFCD), W16(0xFFFF), W16(0xFFCF), W16(0xFFFF), W16(0xFFE4), W16(0x0003), W16(0x0021),
+ W16(0x0066), W16(0xFF93), W16(0xFFAD), W16(0xFFFA), W16(0xFFC8), W16(0xFFA4), W16(0xFFD9), W16(0x0072),
+ W16(0x0007), W16(0x000D), W16(0x0011), W16(0x004A), W16(0x002A), W16(0x002B), W16(0x0002), W16(0xFFDF),
+ W16(0xFFA4), W16(0xFF6C), W16(0xFF66), W16(0xFF97), W16(0x0035), W16(0x0084), W16(0x00B6), W16(0x00EA),
+ W16(0x0017), W16(0xFFDC), W16(0x005C), W16(0x004A), W16(0xFFF1), W16(0x0038), W16(0xFFE1), W16(0xFF9F),
+ W16(0xFF3F), W16(0xFF63), W16(0xFFDE), W16(0x0092), W16(0x0082), W16(0x0053), W16(0x0033), W16(0x003F),
+ W16(0xFFFF), W16(0xFFEB), W16(0xFFD3), W16(0xFFC8), W16(0xFFC0), W16(0xFFD9), W16(0xFFBD), W16(0xFFA6),
+ W16(0xFFFE), W16(0x0006), W16(0x0045), W16(0xFF02), W16(0x0036), W16(0x008E), W16(0x000B), W16(0xFFE4),
+ W16(0x001C), W16(0xFFEF), W16(0xFFCF), W16(0xFFD5), W16(0xFFD3), W16(0xFFFA), W16(0xFFE6), W16(0xFFF1),
+ W16(0xFFFB), W16(0x001D), W16(0x0019), W16(0x001A), W16(0x002E), W16(0x0022), W16(0x0011), W16(0x0005),
+ W16(0x00D4), W16(0x0039), W16(0x0060), W16(0x0018), W16(0xFFC9), W16(0xFFB3), W16(0xFFDF), W16(0x0057),
+ W16(0x00B5), W16(0x007C), W16(0x001F), W16(0xFF64), W16(0xFF9B), W16(0xFFF1), W16(0x0011), W16(0xFFD2),
+ W16(0x002A), W16(0x0029), W16(0x001F), W16(0x0000), W16(0x002A), W16(0x0017), W16(0x0019), W16(0xFFEF),
+ W16(0x0082), W16(0x0064), W16(0x0002), W16(0x0057), W16(0x0006), W16(0x002D), W16(0x005F), W16(0x006D),
+ W16(0xFFF1), W16(0x0035), W16(0x0017), W16(0x001B), W16(0xFFB5), W16(0xFF99), W16(0xFFBE), W16(0xFFD3),
+ W16(0xFFCA), W16(0xFFD1), W16(0xFFDB), W16(0xFFE2), W16(0xFFF8), W16(0xFFF8), W16(0x000B), W16(0x0000),
+ W16(0x005A), W16(0x0064), W16(0x0024), W16(0x0001), W16(0xFFCF), W16(0xFFA4), W16(0xFF80), W16(0xFFA0),
+ W16(0xFFE3), W16(0xFFEF), W16(0xFFC4), W16(0x0006), W16(0x0022), W16(0x0093), W16(0x004D), W16(0x006A),
+ W16(0x0065), W16(0x0030), W16(0x001C), W16(0x001A), W16(0x0029), W16(0x004A), W16(0x0064), W16(0x0061),
+ W16(0xFFD8), W16(0xFF96), W16(0x000D), W16(0x008E), W16(0xFFDB), W16(0xFFB8), W16(0xFF8A), W16(0x0013),
+ W16(0x004D), W16(0x0032), W16(0x002E), W16(0xFFBB), W16(0xFFD1), W16(0xFFF1), W16(0x0062), W16(0x001F),
+ W16(0x0025), W16(0x003D), W16(0x0036), W16(0x0033), W16(0x0091), W16(0x008C), W16(0x0064), W16(0x0041),
+ W16(0x0053), W16(0x0030), W16(0xFF71), W16(0x005F), W16(0x0086), W16(0xFFCC), W16(0xFF97), W16(0xFFE9),
+ W16(0xFFF9), W16(0xFFAC), W16(0xFFD8), W16(0x0017), W16(0xFFF9), W16(0x001C), W16(0x000B), W16(0x001F),
+ W16(0x005A), W16(0x0052), W16(0x0036), W16(0xFFF3), W16(0xFFE2), W16(0xFFCE), W16(0xFFC4), W16(0xFFBA),
+ W16(0x0019), W16(0x0030), W16(0x0044), W16(0xFFD3), W16(0x000C), W16(0xFFF5), W16(0x0011), W16(0x0030),
+ W16(0x0029), W16(0xFF5C), W16(0x002B), W16(0x0012), W16(0x0008), W16(0x0004), W16(0x001F), W16(0xFFFA),
+ W16(0xFFD8), W16(0xFFE9), W16(0xFFE1), W16(0xFFE0), W16(0xFFF7), W16(0xFFF2), W16(0xFFF2), W16(0xFFDC),
+ W16(0xFFA8), W16(0x00AA), W16(0xFFE6), W16(0x0022), W16(0x000F), W16(0xFFE9), W16(0x0015), W16(0x0043),
+ W16(0x004C), W16(0xFFE2), W16(0xFFCE), W16(0xFFF5), W16(0xFFEB), W16(0xFFAC), W16(0xFFCE), W16(0x0016),
+ W16(0x0044), W16(0x005C), W16(0x003F), W16(0x0020), W16(0x0008), W16(0xFFF9), W16(0xFFF1), W16(0xFFE4),
+ W16(0x0033), W16(0x0005), W16(0x0088), W16(0x0023), W16(0x004C), W16(0xFFBB), W16(0x0015), W16(0x0011),
+ W16(0x0024), W16(0x002F), W16(0x0019), W16(0x0004), W16(0xFFC8), W16(0xFFB5), W16(0xFFDC), W16(0x0006),
+ W16(0x0004), W16(0x0011), W16(0x000E), W16(0x0003), W16(0xFFE2), W16(0xFFB2), W16(0xFF99), W16(0xFF7B),
+ W16(0xFFEE), W16(0xFFF8), W16(0x0017), W16(0x002B), W16(0xFF2C), W16(0xFFA2), W16(0x0086), W16(0x00F1),
+ W16(0xFFD0), W16(0xFFDD), W16(0xFFD5), W16(0x0032), W16(0x002C), W16(0xFFD5), W16(0xFFFD), W16(0x002B),
+ W16(0xFFDD), W16(0xFFE7), W16(0xFFF7), W16(0x003C), W16(0x0011), W16(0x002D), W16(0x004D), W16(0x001F),
+ W16(0xFFCE), W16(0x001A), W16(0x0052), W16(0xFF95), W16(0xFFFC), W16(0xFFEC), W16(0x0007), W16(0x0013),
+ W16(0x0013), W16(0x000F), W16(0xFFD7), W16(0x0057), W16(0x0028), W16(0x0019), W16(0xFFCD), W16(0xFFD3),
+ W16(0xFFCC), W16(0xFFF5), W16(0x006F), W16(0x011E), W16(0x00C4), W16(0x0064), W16(0xFFE2), W16(0xFFA3),
+ W16(0x0053), W16(0xFFE8), W16(0xFFC4), W16(0x0022), W16(0xFF9D), W16(0x0004), W16(0xFFD3), W16(0x001C),
+ W16(0x0017), W16(0xFFF0), W16(0xFFF1), W16(0x0012), W16(0x0007), W16(0x001D), W16(0x0010), W16(0x0015),
+ W16(0x001B), W16(0x000B), W16(0xFFE1), W16(0xFFDA), W16(0xFFA6), W16(0xFF79), W16(0x0002), W16(0x020E),
+ W16(0x003B), W16(0x0003), W16(0xFFFB), W16(0xFFEC), W16(0xFFCA), W16(0xFFD2), W16(0xFFC8), W16(0xFFAB),
+ W16(0xFFE1), W16(0x0013), W16(0x0005), W16(0x0020), W16(0x0048), W16(0x005D), W16(0x00E1), W16(0xFFA6),
+ W16(0xFFAC), W16(0x0073), W16(0x008A), W16(0x005B), W16(0xFFDC), W16(0xFFD2), W16(0xFFEF), W16(0x001A),
+ W16(0x0035), W16(0x0050), W16(0x000C), W16(0x0047), W16(0x0049), W16(0x0038), W16(0x002E), W16(0x0074),
+ W16(0xFFE5), W16(0xFF9E), W16(0xFF99), W16(0xFFB6), W16(0xFFF1), W16(0x0004), W16(0x0028), W16(0x0004),
+ W16(0xFFEA), W16(0x0000), W16(0x0000), W16(0x001A), W16(0x0061), W16(0x0079), W16(0x008A), W16(0x00A0),
+ W16(0x00D0), W16(0xFFF3), W16(0x0055), W16(0x004B), W16(0x005A), W16(0x0016), W16(0xFFE5), W16(0xFFCC),
+ W16(0xFFC2), W16(0x0004), W16(0x0017), W16(0x0014), W16(0x0007), W16(0x0000), W16(0xFFFB), W16(0xFFF3),
+ W16(0xFFF9), W16(0xFFFD), W16(0xFFFD), W16(0x0015), W16(0x003F), W16(0x0045), W16(0x0053), W16(0x004B),
+ W16(0xFFE7), W16(0x005D), W16(0x0018), W16(0xFFE0), W16(0xFFF7), W16(0x0059), W16(0x003D), W16(0xFFEA),
+ W16(0xFEFA), W16(0xFFDF), W16(0xFFDD), W16(0x0009), W16(0x001F), W16(0x0016), W16(0x0034), W16(0x002E),
+ W16(0x0033), W16(0x003F), W16(0x004D), W16(0x002D), W16(0x0016), W16(0x0020), W16(0x0023), W16(0x0014),
+ W16(0xFFC7), W16(0xFFDE), W16(0x0056), W16(0xFFE8), W16(0x003A), W16(0x008F), W16(0xFFEB), W16(0xFFB7),
+ W16(0x0011), W16(0x0001), W16(0xFFD2), W16(0xFF83), W16(0xFF90), W16(0xFFEE), W16(0x0037), W16(0x0020),
+ W16(0x0059), W16(0x00BE), W16(0x00A3), W16(0x000F), W16(0xFF91), W16(0xFFB4), W16(0xFF97), W16(0xFF67),
+ W16(0xFFDF), W16(0x0046), W16(0xFF9A), W16(0xFFB2), W16(0xFFF0), W16(0x000E), W16(0xFF8F), W16(0xFFC7),
+ W16(0x0017), W16(0x005B), W16(0x0054), W16(0xFFFB), W16(0xFFC4), W16(0xFFD7), W16(0xFFE8), W16(0x0022),
+ W16(0x0043), W16(0x004C), W16(0x0066), W16(0x0074), W16(0x0092), W16(0x00B9), W16(0x00D5), W16(0x00BB),
+ W16(0x0071), W16(0x0148), W16(0x00DB), W16(0x00D4), W16(0x005C), W16(0x0031), W16(0x0012), W16(0x0025),
+ W16(0xFFE7), W16(0xFFEB), W16(0xFFD8), W16(0xFFC1), W16(0xFFE8), W16(0xFFED), W16(0xFFFA), W16(0x0001),
+ W16(0xFFFF), W16(0xFFF0), W16(0xFFE3), W16(0xFFE7), W16(0x0004), W16(0xFFFF), W16(0xFFF0), W16(0xFFF3),
+ W16(0x0055), W16(0x0136), W16(0xFFF5), W16(0xFFA3), W16(0xFFE5), W16(0xFFDC), W16(0xFFC6), W16(0xFFDD),
+ W16(0xFFDF), W16(0x0000), W16(0x0023), W16(0x0040), W16(0x0045), W16(0x0003), W16(0x0007), W16(0x000B),
+ W16(0x0002), W16(0x0004), W16(0xFFE8), W16(0xFFDF), W16(0xFFAD), W16(0xFFAA), W16(0xFF6E), W16(0xFF35),
+ W16(0x0017), W16(0x000B), W16(0x002B), W16(0x00DC), W16(0x00B1), W16(0xFFE2), W16(0xFFC0), W16(0x0001),
+ W16(0x0024), W16(0x0023), W16(0x0029), W16(0x006A), W16(0xFFED), W16(0xFFDF), W16(0xFFCA), W16(0xFF98),
+ W16(0xFFA4), W16(0xFFEA), W16(0x001A), W16(0x002C), W16(0x0003), W16(0x002A), W16(0x005F), W16(0x0077)
+};
+
+const Word16 cdk_37bits_4_fx[1536] =
+{
+ W16(0xFFF5), W16(0xFFA9), W16(0x000E), W16(0xFFC8), W16(0xFFCB), W16(0xFFB9), W16(0xFFD4), W16(0xFFCC),
+ W16(0xFFCB), W16(0xFFC8), W16(0xFFD3), W16(0x001A), W16(0x0049), W16(0x003A), W16(0x001F), W16(0x0044),
+ W16(0x0077), W16(0x004D), W16(0xFFEC), W16(0xFF84), W16(0xFFBC), W16(0xFFED), W16(0xFFE0), W16(0xFFE5),
+ W16(0x0033), W16(0xFFF7), W16(0xFFF9), W16(0x005E), W16(0x00B6), W16(0x003A), W16(0xFFEA), W16(0xFFA0),
+ W16(0xFFAB), W16(0xFFB9), W16(0xFFD3), W16(0xFFFB), W16(0xFFF2), W16(0xFFFA), W16(0x0010), W16(0x0029),
+ W16(0x002E), W16(0xFFD6), W16(0xFFCA), W16(0xFFBE), W16(0xFFC9), W16(0xFFCA), W16(0xFFD8), W16(0xFFD2),
+ W16(0xFF2B), W16(0x0024), W16(0xFFAF), W16(0x0020), W16(0x0068), W16(0x0038), W16(0x0015), W16(0x001B),
+ W16(0x0006), W16(0x0005), W16(0xFFF4), W16(0xFFCC), W16(0xFFD1), W16(0xFFF3), W16(0xFFDF), W16(0xFFBF),
+ W16(0x0003), W16(0xFFE3), W16(0x0001), W16(0x0018), W16(0x0021), W16(0x0010), W16(0xFFF4), W16(0xFFD9),
+ W16(0xFF6C), W16(0xFFD8), W16(0x0011), W16(0xFFB4), W16(0xFFD1), W16(0xFFBD), W16(0x0002), W16(0xFFDA),
+ W16(0x003A), W16(0x0033), W16(0x0038), W16(0x001D), W16(0x0030), W16(0x002A), W16(0xFFD3), W16(0xFFC7),
+ W16(0xFFDF), W16(0xFFC0), W16(0xFFDE), W16(0xFFD8), W16(0xFFB9), W16(0xFFCC), W16(0xFFDE), W16(0xFFFF),
+ W16(0xFFFA), W16(0xFFCE), W16(0xFFB7), W16(0xFFD7), W16(0x0031), W16(0x0017), W16(0xFFB0), W16(0x0018),
+ W16(0x003E), W16(0x002E), W16(0xFFE7), W16(0x0096), W16(0xFFCB), W16(0xFFC8), W16(0xFFDB), W16(0xFFB8),
+ W16(0xFFE0), W16(0xFFF6), W16(0xFFE9), W16(0xFFA6), W16(0xFFBD), W16(0xFFC1), W16(0xFFCC), W16(0xFFE0),
+ W16(0xFFF0), W16(0xFFDA), W16(0xFFD5), W16(0x000E), W16(0xFF85), W16(0x0112), W16(0xFFBB), W16(0xFFDF),
+ W16(0xFFF1), W16(0xFFF0), W16(0xFFED), W16(0xFFFB), W16(0xFFF6), W16(0x0009), W16(0x0010), W16(0xFFF1),
+ W16(0x0005), W16(0xFFE2), W16(0xFFDF), W16(0x0003), W16(0xFFBA), W16(0x0003), W16(0xFFFC), W16(0xFFD8),
+ W16(0xFFBE), W16(0x0070), W16(0xFF97), W16(0xFFC2), W16(0xFFE8), W16(0xFFF4), W16(0x001A), W16(0xFFE6),
+ W16(0xFFCD), W16(0xFFDA), W16(0xFFB6), W16(0x0020), W16(0x0020), W16(0x0035), W16(0xFFEC), W16(0x0029),
+ W16(0x003B), W16(0x0012), W16(0x0026), W16(0x002E), W16(0xFFF9), W16(0xFFE0), W16(0xFFD2), W16(0xFFBC),
+ W16(0x0042), W16(0xFF99), W16(0xFF90), W16(0x0013), W16(0x0007), W16(0xFFBE), W16(0x0007), W16(0x0016),
+ W16(0x0019), W16(0xFFC5), W16(0xFFF7), W16(0x001A), W16(0xFFC3), W16(0x002E), W16(0x002C), W16(0x0037),
+ W16(0xFFDC), W16(0xFFE5), W16(0x0001), W16(0x002A), W16(0x0022), W16(0x0042), W16(0x0043), W16(0x003B),
+ W16(0x002A), W16(0xFF9D), W16(0xFFD0), W16(0xFFFA), W16(0xFFC4), W16(0x000A), W16(0x0005), W16(0xFFD4),
+ W16(0x0036), W16(0x0036), W16(0xFFFB), W16(0xFFFC), W16(0xFFEE), W16(0xFFC3), W16(0xFF9A), W16(0x004E),
+ W16(0x005D), W16(0xFFF4), W16(0xFFEB), W16(0x0015), W16(0xFFF1), W16(0xFFD1), W16(0xFF99), W16(0xFF78),
+ W16(0x004F), W16(0xFFBD), W16(0xFFA8), W16(0x0053), W16(0x0038), W16(0xFFE5), W16(0xFFD2), W16(0x0026),
+ W16(0xFFE1), W16(0x0003), W16(0xFFD5), W16(0xFFAB), W16(0x0039), W16(0x0045), W16(0x0028), W16(0xFFF6),
+ W16(0xFFEB), W16(0xFFD6), W16(0xFFD5), W16(0xFFB9), W16(0xFFDA), W16(0xFFEE), W16(0x0000), W16(0x000E),
+ W16(0xFF7C), W16(0xFF75), W16(0xFFFF), W16(0xFFED), W16(0xFFFF), W16(0x002D), W16(0x001E), W16(0xFFB1),
+ W16(0x000A), W16(0x0015), W16(0xFFF0), W16(0xFFF8), W16(0xFFE5), W16(0x0015), W16(0x000E), W16(0x0012),
+ W16(0xFFE4), W16(0x0003), W16(0x000B), W16(0x000D), W16(0x0024), W16(0x003A), W16(0x0039), W16(0x0033),
+ W16(0xFFBA), W16(0xFFFD), W16(0xFFD0), W16(0xFFC4), W16(0xFFAE), W16(0x0020), W16(0x0024), W16(0x0050),
+ W16(0xFFFE), W16(0xFFF7), W16(0xFFE7), W16(0x000C), W16(0x0040), W16(0x001F), W16(0x001E), W16(0xFFD4),
+ W16(0xFF86), W16(0xFF87), W16(0xFF8B), W16(0xFFD1), W16(0x0024), W16(0x0036), W16(0xFFF4), W16(0xFFD6),
+ W16(0xFFFE), W16(0x001D), W16(0x0010), W16(0xFFDC), W16(0xFFD0), W16(0xFFF2), W16(0xFFE6), W16(0x0003),
+ W16(0xFFD5), W16(0xFFED), W16(0x006C), W16(0xFF8D), W16(0x000A), W16(0x0022), W16(0x0023), W16(0x001A),
+ W16(0x0030), W16(0xFFCA), W16(0xFFD4), W16(0xFFF2), W16(0x0004), W16(0xFFE5), W16(0xFFAB), W16(0xFF9B),
+ W16(0x0058), W16(0xFFD4), W16(0xFFA9), W16(0xFFAF), W16(0xFFDB), W16(0xFFF2), W16(0x003C), W16(0x008E),
+ W16(0x0007), W16(0xFFEE), W16(0xFFCE), W16(0xFFE0), W16(0xFFF7), W16(0xFFC4), W16(0xFFF3), W16(0xFFF7),
+ W16(0x0021), W16(0x0016), W16(0x0017), W16(0x000E), W16(0xFFF1), W16(0xFFF4), W16(0x0004), W16(0x0009),
+ W16(0xFFDA), W16(0xFFC0), W16(0x0048), W16(0x008F), W16(0x0007), W16(0xFF9C), W16(0xFFE3), W16(0xFFEF),
+ W16(0x0036), W16(0x0023), W16(0xFFF7), W16(0x000E), W16(0xFFEF), W16(0xFFF5), W16(0x0022), W16(0x0004),
+ W16(0x0022), W16(0xFFE7), W16(0xFFC5), W16(0xFFDC), W16(0xFFCE), W16(0xFFD7), W16(0xFFAE), W16(0xFF8F),
+ W16(0xFF94), W16(0x0053), W16(0xFFE9), W16(0xFFFD), W16(0x0002), W16(0x000E), W16(0xFFCA), W16(0xFFB0),
+ W16(0xFF9E), W16(0x0024), W16(0x0040), W16(0x0048), W16(0x0032), W16(0xFFBC), W16(0xFFFE), W16(0x0025),
+ W16(0x001A), W16(0xFFC6), W16(0xFFD6), W16(0xFFE9), W16(0xFFFB), W16(0x0012), W16(0x000C), W16(0x0005),
+ W16(0xFFB4), W16(0xFF9D), W16(0x001F), W16(0xFF74), W16(0xFFE3), W16(0xFFF2), W16(0xFFD9), W16(0x005A),
+ W16(0x0009), W16(0xFFDD), W16(0xFFEB), W16(0x0033), W16(0x0013), W16(0x0003), W16(0xFFD9), W16(0x0000),
+ W16(0x0004), W16(0x0000), W16(0x0008), W16(0x0045), W16(0x0022), W16(0x0038), W16(0x004F), W16(0x0036),
+ W16(0xFFC8), W16(0xFFE4), W16(0xFFD6), W16(0x0076), W16(0x0020), W16(0xFFEE), W16(0x004C), W16(0xFFFA),
+ W16(0xFFB2), W16(0x0008), W16(0x002E), W16(0x001B), W16(0x0002), W16(0xFFEC), W16(0xFFDD), W16(0xFFEF),
+ W16(0xFFEE), W16(0xFFD1), W16(0xFFC8), W16(0xFFC8), W16(0xFFBB), W16(0xFFE7), W16(0x0008), W16(0x0018),
+ W16(0xFFF5), W16(0xFFBA), W16(0x000D), W16(0x001B), W16(0x0045), W16(0x0013), W16(0x0001), W16(0x0010),
+ W16(0x000D), W16(0xFFF9), W16(0x0043), W16(0x000D), W16(0xFFCD), W16(0xFFF2), W16(0x007E), W16(0xFFAA),
+ W16(0xFF59), W16(0x00A5), W16(0x0018), W16(0xFFEA), W16(0xFFAE), W16(0xFFCB), W16(0xFFD4), W16(0x0013),
+ W16(0xFFEA), W16(0xFFA6), W16(0xFFB1), W16(0xFFA5), W16(0x0036), W16(0xFFB5), W16(0xFFB5), W16(0xFFD0),
+ W16(0xFFD2), W16(0x002D), W16(0x002C), W16(0x0013), W16(0xFFF5), W16(0x0013), W16(0x001C), W16(0x001F),
+ W16(0x000F), W16(0x001F), W16(0x001A), W16(0x002E), W16(0x001C), W16(0xFFF4), W16(0xFFBE), W16(0xFF9E),
+ W16(0x000C), W16(0x0037), W16(0xFFDB), W16(0x001C), W16(0x003D), W16(0xFF98), W16(0xFF81), W16(0x0097),
+ W16(0x005A), W16(0x0001), W16(0xFFDE), W16(0xFFCB), W16(0x0024), W16(0xFFFD), W16(0xFFED), W16(0x0011),
+ W16(0xFFF0), W16(0xFFD4), W16(0xFFCA), W16(0xFFD8), W16(0xFFD8), W16(0xFFE1), W16(0xFFE2), W16(0xFFD1),
+ W16(0xFFF7), W16(0xFFD4), W16(0xFFF8), W16(0xFFAD), W16(0x002B), W16(0x002B), W16(0xFFC9), W16(0xFFED),
+ W16(0xFFED), W16(0x0006), W16(0xFFEE), W16(0xFFCF), W16(0xFF8C), W16(0x0007), W16(0x0022), W16(0x0011),
+ W16(0x007F), W16(0x005A), W16(0x001C), W16(0xFFBB), W16(0xFF8E), W16(0xFFF7), W16(0x00B9), W16(0x00C3),
+ W16(0xFFDB), W16(0xFFCB), W16(0x0004), W16(0x0024), W16(0x0025), W16(0x0016), W16(0x0019), W16(0xFFEF),
+ W16(0xFFD2), W16(0xFFCA), W16(0xFFAD), W16(0xFFE6), W16(0xFFCB), W16(0x0005), W16(0x0060), W16(0x0032),
+ W16(0x002D), W16(0xFFE8), W16(0xFFC9), W16(0xFFF6), W16(0x0177), W16(0xFF8E), W16(0xFF7B), W16(0xFFCF),
+ W16(0xFFC6), W16(0x000A), W16(0xFFD3), W16(0xFFDB), W16(0xFFF4), W16(0xFFF3), W16(0x0034), W16(0xFFE2),
+ W16(0x0035), W16(0xFF72), W16(0x0019), W16(0xFFDE), W16(0x0013), W16(0x000A), W16(0x0003), W16(0x0017),
+ W16(0x002F), W16(0x0006), W16(0x0012), W16(0xFFFB), W16(0xFFF5), W16(0x000D), W16(0x0004), W16(0xFFF9),
+ W16(0x0026), W16(0x0005), W16(0xFFF2), W16(0xFF8B), W16(0xFFEE), W16(0x0010), W16(0xFFEB), W16(0xFFBC),
+ W16(0x002C), W16(0x0043), W16(0xFFA2), W16(0x0014), W16(0x002C), W16(0xFFF6), W16(0x0007), W16(0x0000),
+ W16(0x000F), W16(0xFFF8), W16(0xFFE7), W16(0xFFDB), W16(0xFFC9), W16(0xFFE2), W16(0xFFFB), W16(0x000B),
+ W16(0x001F), W16(0xFFF4), W16(0xFFFD), W16(0xFFDB), W16(0x0008), W16(0x0052), W16(0xFFBB), W16(0xFFC6),
+ W16(0x004A), W16(0xFFFB), W16(0x0049), W16(0xFFE0), W16(0x0059), W16(0xFFEA), W16(0xFFD3), W16(0xFFD0),
+ W16(0xFFD0), W16(0xFFD9), W16(0xFFEB), W16(0xFFD8), W16(0xFFF0), W16(0x0026), W16(0x0084), W16(0x00A7),
+ W16(0xFFE8), W16(0xFFCB), W16(0x001B), W16(0x0039), W16(0x0009), W16(0x0000), W16(0x0030), W16(0x0048),
+ W16(0x0046), W16(0x0061), W16(0x000B), W16(0xFFE0), W16(0xFFEB), W16(0xFFC4), W16(0xFFB2), W16(0xFFB2),
+ W16(0xFFDC), W16(0xFFEC), W16(0x0009), W16(0x0006), W16(0xFFFC), W16(0x0001), W16(0xFFFB), W16(0xFFF4),
+ W16(0x004E), W16(0x004A), W16(0x003E), W16(0xFFE0), W16(0xFFCC), W16(0x0035), W16(0x0024), W16(0x0024),
+ W16(0x0017), W16(0xFFB7), W16(0xFFED), W16(0x0048), W16(0xFFF9), W16(0x000B), W16(0xFFCF), W16(0xFFF1),
+ W16(0xFFF1), W16(0xFFD0), W16(0xFFBC), W16(0xFFAA), W16(0xFF97), W16(0xFFA4), W16(0xFFA7), W16(0xFFAD),
+ W16(0x001D), W16(0xFFD1), W16(0x0036), W16(0xFFD3), W16(0x0015), W16(0x0016), W16(0x0065), W16(0x000F),
+ W16(0x0006), W16(0xFFED), W16(0xFFD0), W16(0xFFB1), W16(0xFFDE), W16(0x0022), W16(0x001A), W16(0x0012),
+ W16(0xFFC0), W16(0xFFBB), W16(0xFFBD), W16(0xFFBB), W16(0xFFD0), W16(0xFFE3), W16(0xFFE2), W16(0xFFE5),
+ W16(0x001C), W16(0x003A), W16(0x0004), W16(0xFFCD), W16(0x003C), W16(0x004D), W16(0xFFD8), W16(0x0004),
+ W16(0x0040), W16(0xFFDC), W16(0xFFA3), W16(0xFFB7), W16(0x002F), W16(0x0017), W16(0xFFDC), W16(0xFFFA),
+ W16(0x0009), W16(0x0033), W16(0x001C), W16(0x0008), W16(0x0004), W16(0xFFE6), W16(0xFFB8), W16(0xFFA5),
+ W16(0xFFF0), W16(0xFFD4), W16(0x0042), W16(0xFFD4), W16(0xFFE8), W16(0x003F), W16(0x0064), W16(0xFFEB),
+ W16(0xFFA8), W16(0xFFE1), W16(0x0017), W16(0x000C), W16(0x0020), W16(0xFFB8), W16(0xFFD5), W16(0x000C),
+ W16(0x0025), W16(0x0051), W16(0x0016), W16(0xFFF3), W16(0xFFCF), W16(0xFFB7), W16(0xFFA6), W16(0xFF84),
+ W16(0xFFE6), W16(0xFFC8), W16(0x0024), W16(0xFFE1), W16(0x0044), W16(0xFF29), W16(0x0015), W16(0x0029),
+ W16(0x0004), W16(0x0023), W16(0xFFD5), W16(0xFFEA), W16(0x001B), W16(0x002B), W16(0xFFFB), W16(0x0011),
+ W16(0x001C), W16(0x0015), W16(0x0017), W16(0x000B), W16(0xFFF6), W16(0x0009), W16(0x0005), W16(0x0007),
+ W16(0x0060), W16(0xFFE5), W16(0x005F), W16(0xFFCF), W16(0xFFAF), W16(0xFFB2), W16(0xFFD3), W16(0x0002),
+ W16(0xFFFA), W16(0xFFD1), W16(0x001D), W16(0x001D), W16(0x0019), W16(0x0037), W16(0x002A), W16(0x0025),
+ W16(0x0027), W16(0x0029), W16(0x003C), W16(0x0049), W16(0x0035), W16(0x0027), W16(0xFFF9), W16(0xFFD0),
+ W16(0x0067), W16(0xFFDD), W16(0x000F), W16(0x0043), W16(0x0027), W16(0x002A), W16(0x0051), W16(0xFF79),
+ W16(0xFFDC), W16(0x002B), W16(0x0012), W16(0x0010), W16(0x001B), W16(0xFFFE), W16(0x0000), W16(0xFFCE),
+ W16(0xFFD6), W16(0x0002), W16(0x0028), W16(0x0030), W16(0xFFE4), W16(0xFFD8), W16(0xFFCD), W16(0xFFC8),
+ W16(0x003F), W16(0x0064), W16(0x000C), W16(0x0049), W16(0x0034), W16(0x0062), W16(0x006F), W16(0x004F),
+ W16(0x0004), W16(0xFFB8), W16(0x0006), W16(0xFFDD), W16(0xFFB8), W16(0xFFD3), W16(0xFFE4), W16(0xFFB6),
+ W16(0xFFE8), W16(0xFFFE), W16(0x0018), W16(0x004A), W16(0x0022), W16(0xFFFA), W16(0xFFF9), W16(0xFFFC),
+ W16(0xFFD7), W16(0x0066), W16(0xFFFD), W16(0x0013), W16(0x0023), W16(0xFFE5), W16(0xFFB5), W16(0xFFE5),
+ W16(0xFFFA), W16(0x000D), W16(0x0043), W16(0x0011), W16(0x003E), W16(0x0083), W16(0xFFF8), W16(0xFFC5),
+ W16(0xFF84), W16(0x000E), W16(0x0013), W16(0xFFBB), W16(0xFFA7), W16(0xFFB8), W16(0xFFDB), W16(0xFFDA),
+ W16(0xFFFD), W16(0x001C), W16(0xFFE9), W16(0x0005), W16(0x006D), W16(0xFFD2), W16(0x000C), W16(0x0002),
+ W16(0x003A), W16(0x002A), W16(0x0012), W16(0x0000), W16(0xFF71), W16(0xFFCA), W16(0xFFE6), W16(0x0009),
+ W16(0x0012), W16(0xFFEF), W16(0xFFFB), W16(0xFFF5), W16(0x000E), W16(0x001C), W16(0x0029), W16(0x0028),
+ W16(0x0036), W16(0x002B), W16(0xFFE3), W16(0x004D), W16(0xFF48), W16(0x0019), W16(0x0032), W16(0x0003),
+ W16(0x0066), W16(0x0003), W16(0xFFE0), W16(0xFFFC), W16(0x0004), W16(0xFFFA), W16(0x001A), W16(0x000B),
+ W16(0x0001), W16(0xFFFE), W16(0xFFFC), W16(0xFFE3), W16(0xFFE8), W16(0x0004), W16(0x0024), W16(0x0032),
+ W16(0x0021), W16(0x002B), W16(0xFF99), W16(0x000C), W16(0x0008), W16(0x004D), W16(0xFFD5), W16(0xFFC1),
+ W16(0xFFDE), W16(0xFFD3), W16(0x0001), W16(0xFFE1), W16(0xFFD3), W16(0x0018), W16(0x0044), W16(0x0024),
+ W16(0x0030), W16(0x0004), W16(0x000F), W16(0x0017), W16(0x002D), W16(0x0042), W16(0x004A), W16(0x0048),
+ W16(0xFFDF), W16(0x000D), W16(0x000A), W16(0xFFF4), W16(0xFFF0), W16(0xFFCC), W16(0xFFE2), W16(0xFFF4),
+ W16(0xFFF3), W16(0x0009), W16(0x0024), W16(0x0054), W16(0x0004), W16(0xFFEB), W16(0x0019), W16(0x0092),
+ W16(0xFF5F), W16(0xFFFD), W16(0x0022), W16(0x001E), W16(0xFFD5), W16(0xFF9D), W16(0xFFB6), W16(0x002E),
+ W16(0xFFC7), W16(0xFFCB), W16(0xFF9E), W16(0x0036), W16(0xFF8C), W16(0xFFCD), W16(0xFFDC), W16(0xFFF8),
+ W16(0x0010), W16(0x001B), W16(0x0019), W16(0x0004), W16(0x0035), W16(0x0018), W16(0xFFFD), W16(0x0010),
+ W16(0x0032), W16(0x004E), W16(0x0035), W16(0x0037), W16(0x000A), W16(0xFFF5), W16(0xFFE6), W16(0xFFE5),
+ W16(0x002D), W16(0xFFFA), W16(0xFFF7), W16(0xFFF0), W16(0xFFC6), W16(0xFFCA), W16(0xFFEA), W16(0x001E),
+ W16(0x0041), W16(0x002C), W16(0xFFF9), W16(0xFFEF), W16(0xFFBD), W16(0x00C2), W16(0x0012), W16(0xFF8E),
+ W16(0xFFF4), W16(0xFFF1), W16(0x004F), W16(0x0026), W16(0xFFF2), W16(0xFFD6), W16(0xFFAE), W16(0xFFA5),
+ W16(0xFFBD), W16(0xFFEB), W16(0x0056), W16(0xFFA9), W16(0xFF78), W16(0x0020), W16(0x005D), W16(0xFFE9),
+ W16(0xFFFA), W16(0x0054), W16(0x0026), W16(0xFFFB), W16(0xFFAC), W16(0xFFE8), W16(0xFFF6), W16(0xFFEC),
+ W16(0x003E), W16(0x0025), W16(0x0045), W16(0x0027), W16(0x0046), W16(0x0031), W16(0x001D), W16(0xFFF3),
+ W16(0xFFDD), W16(0x0016), W16(0xFFE8), W16(0x003B), W16(0x0004), W16(0x0053), W16(0x0024), W16(0xFFFA),
+ W16(0xFFDA), W16(0x0014), W16(0xFF6A), W16(0x0062), W16(0x0006), W16(0xFFE2), W16(0x0003), W16(0xFFF4),
+ W16(0xFFF2), W16(0xFFF7), W16(0xFFFC), W16(0x0012), W16(0x0019), W16(0x0019), W16(0x000D), W16(0x000E),
+ W16(0x0049), W16(0xFFF4), W16(0x0028), W16(0x000C), W16(0xFFC1), W16(0xFFDF), W16(0x0025), W16(0x003D),
+ W16(0xFF8A), W16(0x0048), W16(0x001A), W16(0xFFD5), W16(0x003B), W16(0x0055), W16(0x000C), W16(0xFFB4),
+ W16(0xFFEF), W16(0xFFFF), W16(0x0007), W16(0x0026), W16(0x001D), W16(0x0025), W16(0x0029), W16(0x0030),
+ W16(0x0059), W16(0x0057), W16(0xFFF3), W16(0xFFE7), W16(0xFFE6), W16(0xFF6D), W16(0x0080), W16(0xFFD4),
+ W16(0x002A), W16(0x0027), W16(0xFFE6), W16(0xFF9C), W16(0xFFC5), W16(0x0009), W16(0x0023), W16(0x004C),
+ W16(0x0048), W16(0x004F), W16(0xFFFB), W16(0xFFF3), W16(0x0016), W16(0x0001), W16(0xFFED), W16(0xFFEC),
+ W16(0xFF76), W16(0x0021), W16(0x009C), W16(0x0018), W16(0xFFD7), W16(0x002C), W16(0xFFD7), W16(0xFFF4),
+ W16(0x0025), W16(0xFFD1), W16(0xFFC9), W16(0xFFFB), W16(0xFFF5), W16(0x0005), W16(0x001D), W16(0x0035),
+ W16(0x002A), W16(0xFFEB), W16(0xFFE6), W16(0xFFD3), W16(0xFFDF), W16(0xFFFB), W16(0xFFFB), W16(0xFFEE),
+ W16(0x000B), W16(0x0024), W16(0x000C), W16(0x0024), W16(0xFFDB), W16(0xFFEC), W16(0xFFF5), W16(0x0009),
+ W16(0xFFFE), W16(0x0015), W16(0x0034), W16(0x0058), W16(0xFFF7), W16(0xFF52), W16(0x0058), W16(0x0023),
+ W16(0xFFD8), W16(0xFFD4), W16(0xFFE6), W16(0xFFFB), W16(0x0000), W16(0x0029), W16(0x003E), W16(0x0041),
+ W16(0xFFF2), W16(0xFFBA), W16(0xFFF7), W16(0x000A), W16(0x002A), W16(0x004C), W16(0xFFC4), W16(0x0042),
+ W16(0xFFAC), W16(0xFF6C), W16(0x003B), W16(0x0025), W16(0x0005), W16(0xFFE3), W16(0x000B), W16(0x000F),
+ W16(0x000C), W16(0x0028), W16(0x0021), W16(0x0015), W16(0xFFFF), W16(0xFFFE), W16(0x0006), W16(0x000B),
+ W16(0x0005), W16(0x006C), W16(0x0018), W16(0x0068), W16(0x0027), W16(0xFFA0), W16(0x0025), W16(0x0003),
+ W16(0xFFE8), W16(0xFFD7), W16(0xFFE4), W16(0x0026), W16(0x000D), W16(0xFFFF), W16(0x001D), W16(0x001F),
+ W16(0x0000), W16(0xFFEC), W16(0xFFF5), W16(0x0017), W16(0x0023), W16(0x003C), W16(0x0041), W16(0x0032),
+ W16(0xFFB5), W16(0x0068), W16(0xFFE8), W16(0x0006), W16(0xFFB3), W16(0x0002), W16(0xFFF4), W16(0x005C),
+ W16(0xFFE6), W16(0x0011), W16(0xFFE6), W16(0xFFCA), W16(0xFFA2), W16(0x0023), W16(0x004C), W16(0x0038),
+ W16(0x000B), W16(0x0011), W16(0x0015), W16(0xFFEA), W16(0xFFEC), W16(0xFFFB), W16(0x000A), W16(0x0003),
+ W16(0xFFFF), W16(0x0040), W16(0xFF79), W16(0xFFC5), W16(0x002C), W16(0xFFCB), W16(0x0007), W16(0xFFF1),
+ W16(0x0030), W16(0x003E), W16(0x001F), W16(0xFFE1), W16(0x0020), W16(0x0013), W16(0xFFCE), W16(0xFFD6),
+ W16(0xFFCC), W16(0xFFFF), W16(0x0027), W16(0x004B), W16(0x004B), W16(0x0045), W16(0x0038), W16(0x0036),
+ W16(0x0008), W16(0xFFF8), W16(0x0026), W16(0xFFFE), W16(0x000F), W16(0xFFD1), W16(0xFFE3), W16(0x0039),
+ W16(0xFFF3), W16(0xFFCB), W16(0xFFDE), W16(0x000E), W16(0x0102), W16(0xFFC2), W16(0xFF93), W16(0xFFF9),
+ W16(0x000C), W16(0xFFD7), W16(0xFFF4), W16(0x000F), W16(0xFFFD), W16(0x0022), W16(0x0020), W16(0x0027),
+ W16(0x002B), W16(0x0034), W16(0x0006), W16(0x0022), W16(0x0018), W16(0x0022), W16(0xFFE0), W16(0xFFFC),
+ W16(0x0037), W16(0x001E), W16(0x003F), W16(0xFFCC), W16(0xFFE7), W16(0xFFC3), W16(0xFFA8), W16(0xFFE4),
+ W16(0x0054), W16(0x006D), W16(0x0025), W16(0xFF9E), W16(0xFFBD), W16(0xFFCB), W16(0xFFE6), W16(0x001A),
+ W16(0xFFD6), W16(0x0080), W16(0x0074), W16(0xFFA3), W16(0x0034), W16(0xFFFA), W16(0x0010), W16(0xFFBF),
+ W16(0xFFC1), W16(0x0009), W16(0x0006), W16(0xFFE6), W16(0x0000), W16(0x0035), W16(0x003F), W16(0xFFF7),
+ W16(0xFFE3), W16(0xFFCF), W16(0x0000), W16(0x0019), W16(0x003B), W16(0x0043), W16(0x003F), W16(0x0047),
+ W16(0x0028), W16(0xFFCD), W16(0x000C), W16(0x0026), W16(0x0052), W16(0xFFF9), W16(0x003A), W16(0xFF99),
+ W16(0x0071), W16(0xFFAD), W16(0xFFFB), W16(0x001F), W16(0x000C), W16(0xFFF0), W16(0xFFDB), W16(0xFFFF),
+ W16(0xFFD5), W16(0x0023), W16(0x0022), W16(0x0032), W16(0x0048), W16(0x0025), W16(0xFFFE), W16(0xFFDB),
+ W16(0x009C), W16(0x0007), W16(0x0022), W16(0x0002), W16(0xFFB7), W16(0xFFAE), W16(0x0011), W16(0xFFE0),
+ W16(0x0000), W16(0x003B), W16(0x0027), W16(0x004D), W16(0x003A), W16(0xFFE2), W16(0xFFF6), W16(0x0006),
+ W16(0xFFE3), W16(0xFFCE), W16(0xFFCD), W16(0xFFD5), W16(0xFFFC), W16(0x0000), W16(0xFFF5), W16(0xFFF5),
+ W16(0x0040), W16(0xFFDE), W16(0x0050), W16(0x0018), W16(0xFFFB), W16(0x0041), W16(0xFF88), W16(0x000F),
+ W16(0xFFD7), W16(0x006B), W16(0x0038), W16(0xFFFC), W16(0xFFD8), W16(0xFFE9), W16(0xFFEC), W16(0x0007),
+ W16(0x0002), W16(0x000E), W16(0x0007), W16(0x0035), W16(0x002B), W16(0x0028), W16(0x0018), W16(0xFFFF),
+ W16(0xFFD6), W16(0x00B3), W16(0x0087), W16(0x001B), W16(0xFFBD), W16(0x001E), W16(0x0073), W16(0x0071),
+ W16(0x004B), W16(0x0052), W16(0x004D), W16(0xFFCE), W16(0xFFC2), W16(0xFFC6), W16(0xFFCB), W16(0xFF92),
+ W16(0xFFA3), W16(0xFF9F), W16(0xFFBA), W16(0x0011), W16(0xFFCF), W16(0xFFD7), W16(0x0018), W16(0x0072),
+ W16(0x0075), W16(0x0016), W16(0xFFD3), W16(0xFFA9), W16(0x0048), W16(0x001E), W16(0x0019), W16(0x000F),
+ W16(0xFF97), W16(0xFFF0), W16(0x0025), W16(0x003D), W16(0x0003), W16(0xFFE5), W16(0xFFE9), W16(0xFFEB),
+ W16(0xFFCD), W16(0xFFEA), W16(0xFFF0), W16(0x000E), W16(0x0018), W16(0x002A), W16(0x0030), W16(0x003C),
+ W16(0x0041), W16(0xFF90), W16(0x0039), W16(0x0015), W16(0x0006), W16(0x0039), W16(0x004B), W16(0x001E),
+ W16(0xFFFA), W16(0xFFC3), W16(0x0001), W16(0xFFBD), W16(0xFFF5), W16(0xFFC3), W16(0x0001), W16(0xFFFD),
+ W16(0x0026), W16(0xFFF4), W16(0x0006), W16(0x0069), W16(0x0083), W16(0x0080), W16(0x0077), W16(0x006E),
+ W16(0x00B3), W16(0x003E), W16(0x0007), W16(0x0037), W16(0x0025), W16(0xFFFD), W16(0xFFA5), W16(0xFFF6),
+ W16(0x0000), W16(0xFFF8), W16(0xFFED), W16(0x0003), W16(0x001A), W16(0xFFF7), W16(0x001B), W16(0x0030),
+ W16(0x0001), W16(0x002D), W16(0x0032), W16(0x0016), W16(0x000B), W16(0x0020), W16(0x0017), W16(0x0004),
+ W16(0xFFED), W16(0x004D), W16(0x0067), W16(0x0053), W16(0xFFD0), W16(0x0003), W16(0xFFC8), W16(0xFFC3),
+ W16(0xFFF4), W16(0x0001), W16(0x0032), W16(0x005D), W16(0xFFDF), W16(0x0027), W16(0xFFF2), W16(0xFFFB),
+ W16(0x002B), W16(0x0048), W16(0x002F), W16(0x0019), W16(0x001B), W16(0x0027), W16(0x001B), W16(0xFFFF),
+ W16(0xFFB9), W16(0xFFFC), W16(0x0003), W16(0x0054), W16(0x006D), W16(0x0003), W16(0xFFCF), W16(0x000B),
+ W16(0xFFD1), W16(0x000B), W16(0xFFD6), W16(0xFFDC), W16(0x000B), W16(0x0013), W16(0xFFCB), W16(0x0015),
+ W16(0x0029), W16(0x0046), W16(0x0084), W16(0x0071), W16(0x004F), W16(0x0045), W16(0x0040), W16(0x0038)
+};
+
+const Word16 cdk_37bits_5_fx[1536] =
+{
+ W16(0xFFF5), W16(0x0024), W16(0xFFA1), W16(0xFFDD), W16(0x0022), W16(0x004B), W16(0x003F), W16(0x0001),
+ W16(0x0040), W16(0xFFF4), W16(0xFFEE), W16(0xFFE4), W16(0xFFA4), W16(0xFFD7), W16(0xFFEA), W16(0xFFFD),
+ W16(0xFFEB), W16(0xFFDF), W16(0xFFDA), W16(0xFFFA), W16(0xFFFC), W16(0xFFF7), W16(0xFFFA), W16(0x0003),
+ W16(0x0015), W16(0xFFF0), W16(0xFFF2), W16(0xFFC0), W16(0x002F), W16(0x0002), W16(0xFFCA), W16(0xFFCD),
+ W16(0xFFF3), W16(0xFFFE), W16(0xFFCF), W16(0xFFF4), W16(0x0017), W16(0x0047), W16(0xFFDD), W16(0xFFFD),
+ W16(0x004D), W16(0xFF98), W16(0xFFBF), W16(0x0005), W16(0x0041), W16(0x0029), W16(0xFFF9), W16(0x0001),
+ W16(0xFFA6), W16(0xFFB8), W16(0xFFE4), W16(0x0009), W16(0xFFE0), W16(0x0031), W16(0x0005), W16(0xFFFD),
+ W16(0xFFAC), W16(0xFFF1), W16(0x000B), W16(0xFFFB), W16(0xFFDB), W16(0x000F), W16(0x0062), W16(0x0000),
+ W16(0xFFFE), W16(0x0018), W16(0x0000), W16(0xFFDB), W16(0xFFE6), W16(0xFFD1), W16(0xFFCF), W16(0xFFE5),
+ W16(0xFFE6), W16(0x0002), W16(0xFFAF), W16(0x003F), W16(0xFFF2), W16(0xFFD9), W16(0x0036), W16(0xFFF1),
+ W16(0x0048), W16(0xFFE7), W16(0xFFD8), W16(0x0002), W16(0x003D), W16(0x0002), W16(0x0005), W16(0x0006),
+ W16(0xFFBD), W16(0xFFCF), W16(0xFFCB), W16(0x0003), W16(0xFFFB), W16(0xFFF2), W16(0xFFD9), W16(0xFFDF),
+ W16(0xFFF8), W16(0xFFBF), W16(0x0001), W16(0xFFBB), W16(0xFFEA), W16(0xFFE6), W16(0xFFC8), W16(0x0028),
+ W16(0x0014), W16(0x0041), W16(0x0014), W16(0x0018), W16(0x0006), W16(0x0007), W16(0x0003), W16(0xFFF2),
+ W16(0xFFBF), W16(0xFFB0), W16(0xFFDA), W16(0xFFCC), W16(0xFFD4), W16(0xFFE4), W16(0xFFCD), W16(0xFFBE),
+ W16(0xFFA2), W16(0xFFA8), W16(0xFFF8), W16(0x0055), W16(0x002D), W16(0xFFEA), W16(0xFFE6), W16(0x0000),
+ W16(0x0005), W16(0xFFEF), W16(0x002D), W16(0x002F), W16(0x003D), W16(0xFFE0), W16(0xFFCF), W16(0xFFE2),
+ W16(0xFFE5), W16(0xFFEB), W16(0xFFEE), W16(0x0018), W16(0x000B), W16(0x0001), W16(0xFFF6), W16(0x0015),
+ W16(0x001F), W16(0xFFBA), W16(0xFFEA), W16(0x0002), W16(0xFFDC), W16(0xFFFB), W16(0xFFF0), W16(0xFFE6),
+ W16(0x005A), W16(0x0013), W16(0xFFF6), W16(0xFFCA), W16(0xFFF9), W16(0xFFB6), W16(0x0060), W16(0x0006),
+ W16(0x0012), W16(0x0046), W16(0x001D), W16(0x000C), W16(0x0022), W16(0x0022), W16(0x001B), W16(0x0012),
+ W16(0xFFB2), W16(0x0021), W16(0x000B), W16(0xFFDB), W16(0xFFE3), W16(0x0023), W16(0xFFCE), W16(0xFF8C),
+ W16(0x0058), W16(0xFFF7), W16(0x0026), W16(0xFFFD), W16(0x0016), W16(0x000D), W16(0x0008), W16(0xFFF0),
+ W16(0x0015), W16(0x001E), W16(0xFFF6), W16(0xFFF0), W16(0xFFD7), W16(0xFFD2), W16(0xFFD7), W16(0xFFEA),
+ W16(0xFFD8), W16(0x0006), W16(0xFF77), W16(0x0047), W16(0x0021), W16(0xFFEA), W16(0xFFC7), W16(0x0036),
+ W16(0xFFE1), W16(0x0032), W16(0xFFDD), W16(0xFFF5), W16(0xFFEA), W16(0xFFAD), W16(0x0028), W16(0x0034),
+ W16(0x001F), W16(0xFFEB), W16(0x0002), W16(0xFFD9), W16(0xFFEC), W16(0xFFE9), W16(0xFFEA), W16(0xFFE7),
+ W16(0x0021), W16(0xFFFC), W16(0xFFCD), W16(0xFFD7), W16(0x000D), W16(0xFFE4), W16(0x0025), W16(0xFFEC),
+ W16(0xFFF0), W16(0xFFF2), W16(0x002B), W16(0xFFE5), W16(0x0040), W16(0xFFB0), W16(0x001C), W16(0xFFE5),
+ W16(0x001C), W16(0xFFF5), W16(0xFFBD), W16(0xFFD3), W16(0xFFB4), W16(0xFFC8), W16(0xFFDC), W16(0x0000),
+ W16(0x0029), W16(0xFFFC), W16(0xFFE5), W16(0xFFE3), W16(0xFFAB), W16(0xFFDA), W16(0x0017), W16(0xFFD4),
+ W16(0xFFE6), W16(0xFFFF), W16(0x0032), W16(0xFFF7), W16(0xFFE3), W16(0x002C), W16(0x0042), W16(0x004A),
+ W16(0xFFE6), W16(0xFFEE), W16(0xFFE5), W16(0x0008), W16(0xFFDC), W16(0xFFEC), W16(0xFFF6), W16(0x000B),
+ W16(0xFFB6), W16(0x002A), W16(0x0031), W16(0x0011), W16(0x004F), W16(0xFFCA), W16(0xFFEA), W16(0x002A),
+ W16(0xFFF7), W16(0xFFEF), W16(0x000D), W16(0xFFBB), W16(0x0023), W16(0xFFCC), W16(0x0048), W16(0xFFF2),
+ W16(0xFFFD), W16(0xFFFD), W16(0xFFFC), W16(0x0001), W16(0x002D), W16(0x0004), W16(0xFFD0), W16(0xFFA2),
+ W16(0xFFD7), W16(0xFFE2), W16(0x0041), W16(0x000A), W16(0xFFE5), W16(0xFFEB), W16(0x002B), W16(0x001F),
+ W16(0x0043), W16(0xFFBE), W16(0x0044), W16(0xFFCF), W16(0xFFD9), W16(0x001C), W16(0x001E), W16(0xFFDE),
+ W16(0xFFE0), W16(0xFFD3), W16(0xFFD0), W16(0xFFE6), W16(0xFFF0), W16(0xFFF7), W16(0xFFED), W16(0x0002),
+ W16(0xFFD7), W16(0xFFF8), W16(0xFFEB), W16(0x0002), W16(0x0046), W16(0xFFEE), W16(0xFFF7), W16(0xFFD8),
+ W16(0x001B), W16(0xFFB8), W16(0xFFBA), W16(0xFFCE), W16(0x000B), W16(0x0042), W16(0x000C), W16(0x003A),
+ W16(0x000F), W16(0xFFFB), W16(0xFFF2), W16(0xFFE0), W16(0xFFBC), W16(0xFFBE), W16(0xFFF1), W16(0x0023),
+ W16(0xFFE4), W16(0xFFE6), W16(0xFFEA), W16(0xFFA8), W16(0xFFC1), W16(0x0016), W16(0x0054), W16(0x0016),
+ W16(0x001B), W16(0xFFFD), W16(0xFFE2), W16(0xFFD0), W16(0x0008), W16(0x002A), W16(0xFFE8), W16(0xFFC0),
+ W16(0x0019), W16(0xFFFE), W16(0x0021), W16(0x0013), W16(0x000B), W16(0xFFF8), W16(0xFFFE), W16(0x000C),
+ W16(0xFFA9), W16(0x0036), W16(0x0016), W16(0xFFE9), W16(0xFFAB), W16(0x000E), W16(0x0042), W16(0x0006),
+ W16(0xFFD0), W16(0x0009), W16(0xFFE3), W16(0xFFE0), W16(0x0025), W16(0x0015), W16(0x0011), W16(0x0027),
+ W16(0xFFF2), W16(0xFFD4), W16(0xFFB1), W16(0xFFC6), W16(0x001F), W16(0x0038), W16(0x002B), W16(0x0029),
+ W16(0xFFF0), W16(0x0025), W16(0xFFED), W16(0xFF89), W16(0x0014), W16(0x0034), W16(0xFFE5), W16(0xFFF0),
+ W16(0xFFE6), W16(0x000B), W16(0x0066), W16(0x0016), W16(0xFFF3), W16(0xFFCC), W16(0xFFD6), W16(0xFFEA),
+ W16(0xFFF8), W16(0x0007), W16(0x0015), W16(0x0013), W16(0x000A), W16(0x0020), W16(0x001A), W16(0x000E),
+ W16(0xFFD8), W16(0x000C), W16(0xFFF2), W16(0x0001), W16(0xFFD0), W16(0x0006), W16(0x0018), W16(0x0010),
+ W16(0xFFED), W16(0x0000), W16(0x001A), W16(0xFFFE), W16(0xFFFD), W16(0x003E), W16(0xFF67), W16(0x004E),
+ W16(0x000B), W16(0x0015), W16(0xFFEC), W16(0xFFE8), W16(0xFFDE), W16(0xFFF3), W16(0xFFFB), W16(0x0033),
+ W16(0xFFC6), W16(0xFFF1), W16(0xFFDC), W16(0xFFCA), W16(0x0016), W16(0xFFE7), W16(0x0029), W16(0xFFF6),
+ W16(0xFFF9), W16(0xFFE2), W16(0xFFCD), W16(0x002A), W16(0xFFE5), W16(0xFFC4), W16(0x0006), W16(0x0027),
+ W16(0x003B), W16(0x0035), W16(0x001C), W16(0x001C), W16(0x0015), W16(0x0025), W16(0x001F), W16(0x0031),
+ W16(0x0020), W16(0xFFFB), W16(0x0023), W16(0x0015), W16(0xFFF8), W16(0xFFFD), W16(0xFFEE), W16(0x003F),
+ W16(0x0055), W16(0x0006), W16(0x001B), W16(0xFFF7), W16(0xFFFB), W16(0xFFED), W16(0xFFE4), W16(0xFFEB),
+ W16(0xFFBA), W16(0x0029), W16(0x005B), W16(0x0063), W16(0xFFA2), W16(0xFFA6), W16(0xFF9D), W16(0xFFBD),
+ W16(0xFFCC), W16(0xFFB9), W16(0x0034), W16(0x0011), W16(0x000E), W16(0xFFFD), W16(0x0048), W16(0xFFE9),
+ W16(0xFFD8), W16(0x0071), W16(0xFFAB), W16(0x0013), W16(0xFFEC), W16(0xFFD2), W16(0xFFD3), W16(0xFFF8),
+ W16(0x0034), W16(0xFFFE), W16(0xFFD9), W16(0xFFCC), W16(0xFFE6), W16(0xFFF1), W16(0xFFF1), W16(0x0004),
+ W16(0xFFFD), W16(0x0000), W16(0xFFCA), W16(0xFF9C), W16(0xFFE5), W16(0xFFFD), W16(0xFFF9), W16(0x0025),
+ W16(0x0023), W16(0xFFBA), W16(0xFFDC), W16(0x003F), W16(0x0039), W16(0xFFE2), W16(0x0027), W16(0xFFEA),
+ W16(0xFFDC), W16(0x0035), W16(0x0008), W16(0xFFF6), W16(0x0012), W16(0xFFE2), W16(0xFFAD), W16(0xFF94),
+ W16(0x002B), W16(0xFFE5), W16(0x0015), W16(0x001B), W16(0xFF94), W16(0xFFE8), W16(0xFFCE), W16(0x0023),
+ W16(0x002A), W16(0xFFF6), W16(0x0023), W16(0xFFD7), W16(0x0025), W16(0x0004), W16(0xFFE2), W16(0x0020),
+ W16(0x004F), W16(0x0026), W16(0xFFC5), W16(0xFFCE), W16(0xFFF7), W16(0x0012), W16(0x0018), W16(0x0019),
+ W16(0xFFFE), W16(0xFFCA), W16(0xFFFC), W16(0x0002), W16(0x0006), W16(0x002A), W16(0xFF55), W16(0x0006),
+ W16(0xFFEE), W16(0x0017), W16(0xFFE3), W16(0x0005), W16(0x0036), W16(0x003E), W16(0x000C), W16(0x000A),
+ W16(0xFFFD), W16(0x0017), W16(0x0022), W16(0x0013), W16(0xFFFF), W16(0xFFF6), W16(0xFFFE), W16(0x001A),
+ W16(0x0009), W16(0xFFEB), W16(0xFFE5), W16(0x0000), W16(0x0032), W16(0x0058), W16(0x0009), W16(0x0039),
+ W16(0xFFD0), W16(0xFFF7), W16(0xFFD8), W16(0xFFF0), W16(0x0014), W16(0xFFDC), W16(0xFFE1), W16(0x0009),
+ W16(0xFFCB), W16(0xFFD9), W16(0x0002), W16(0x000C), W16(0xFFF9), W16(0x000F), W16(0x003F), W16(0x0062),
+ W16(0x0013), W16(0x002F), W16(0x0028), W16(0xFFE9), W16(0x0030), W16(0x000D), W16(0xFFA7), W16(0x0000),
+ W16(0x000A), W16(0xFFED), W16(0xFFEB), W16(0x003F), W16(0xFFEE), W16(0xFFEB), W16(0x0014), W16(0x0029),
+ W16(0xFFE5), W16(0xFFF0), W16(0xFFB0), W16(0xFFCB), W16(0xFFD5), W16(0x0014), W16(0x0034), W16(0x003B),
+ W16(0xFFE9), W16(0x0059), W16(0xFFBC), W16(0xFFCD), W16(0x000C), W16(0xFFE6), W16(0x001F), W16(0x0013),
+ W16(0xFFE5), W16(0x0030), W16(0xFFFD), W16(0x0025), W16(0xFFD9), W16(0x0011), W16(0x002C), W16(0xFFAC),
+ W16(0xFFE2), W16(0x0014), W16(0xFFF0), W16(0xFFDA), W16(0xFFED), W16(0xFFFE), W16(0xFFFC), W16(0x0006),
+ W16(0xFFDE), W16(0xFFF0), W16(0xFFFB), W16(0x0001), W16(0x001D), W16(0xFFB6), W16(0xFFEF), W16(0x00CD),
+ W16(0xFF91), W16(0xFFD0), W16(0xFFCD), W16(0x0017), W16(0x0006), W16(0x0026), W16(0x0011), W16(0xFFF3),
+ W16(0xFFFD), W16(0x0005), W16(0xFFD7), W16(0xFFF7), W16(0xFFE7), W16(0xFFC3), W16(0xFFDB), W16(0xFFD3),
+ W16(0x0003), W16(0xFFE7), W16(0xFFD9), W16(0x0010), W16(0x0049), W16(0xFFF3), W16(0xFFFD), W16(0xFFB1),
+ W16(0x000B), W16(0x005E), W16(0x0030), W16(0xFF9D), W16(0xFFE3), W16(0x000F), W16(0xFFFB), W16(0xFFF3),
+ W16(0x0001), W16(0xFFFC), W16(0xFFF4), W16(0xFFEC), W16(0xFFEE), W16(0xFFF5), W16(0xFFEB), W16(0xFFFE),
+ W16(0x0049), W16(0x001E), W16(0x0011), W16(0xFFDF), W16(0xFFD5), W16(0x002C), W16(0xFFFD), W16(0xFFF8),
+ W16(0x0007), W16(0xFFBC), W16(0xFFD4), W16(0x0013), W16(0x0045), W16(0xFFDE), W16(0xFFFE), W16(0x0049),
+ W16(0xFFF6), W16(0xFFDC), W16(0xFFE6), W16(0x0000), W16(0xFFFA), W16(0xFFEF), W16(0xFFE3), W16(0xFFF1),
+ W16(0xFFE0), W16(0x000A), W16(0x0019), W16(0x0006), W16(0xFFF3), W16(0xFFFA), W16(0x000B), W16(0x002D),
+ W16(0x000E), W16(0x002A), W16(0x0015), W16(0xFFFC), W16(0xFFE9), W16(0xFFC0), W16(0x0034), W16(0xFFDF),
+ W16(0xFFD7), W16(0xFFF3), W16(0x0017), W16(0x000F), W16(0xFFAC), W16(0xFFEF), W16(0x0101), W16(0xFF60),
+ W16(0xFFE0), W16(0xFFBD), W16(0x0040), W16(0xFFEB), W16(0xFFFF), W16(0xFFE2), W16(0xFFD5), W16(0xFFE1),
+ W16(0xFFFA), W16(0xFFF7), W16(0xFFF4), W16(0x0003), W16(0xFFFE), W16(0xFFCA), W16(0x0004), W16(0x0097),
+ W16(0x001E), W16(0xFF9B), W16(0xFFE6), W16(0x0093), W16(0x0033), W16(0x006E), W16(0xFFFB), W16(0xFFBF),
+ W16(0x0036), W16(0xFFFE), W16(0x002B), W16(0x0004), W16(0x001A), W16(0x005D), W16(0x0027), W16(0xFFF2),
+ W16(0x0013), W16(0x0013), W16(0x000F), W16(0x0000), W16(0xFFD8), W16(0xFFB8), W16(0xFFD8), W16(0x0002),
+ W16(0xFFD2), W16(0x0004), W16(0xFFF1), W16(0xFFD9), W16(0x002C), W16(0x006B), W16(0x0016), W16(0xFF7E),
+ W16(0xFFFE), W16(0xFFFE), W16(0xFFEB), W16(0x000B), W16(0x000F), W16(0x006C), W16(0x000A), W16(0xFF8A),
+ W16(0xFFBB), W16(0xFFF3), W16(0xFFE8), W16(0xFFDF), W16(0x0055), W16(0x0037), W16(0xFFE0), W16(0xFFE8),
+ W16(0x0028), W16(0x000A), W16(0x0005), W16(0xFFDF), W16(0x001B), W16(0x0016), W16(0x0015), W16(0x001D),
+ W16(0xFFFC), W16(0xFFBA), W16(0x0016), W16(0xFFE0), W16(0x001E), W16(0xFFD4), W16(0xFFF6), W16(0xFFE0),
+ W16(0xFFA2), W16(0xFFF7), W16(0x0018), W16(0x0012), W16(0x0056), W16(0x0032), W16(0x001A), W16(0xFFEB),
+ W16(0xFFE7), W16(0x0021), W16(0xFFFE), W16(0x001F), W16(0x000E), W16(0x0016), W16(0x0007), W16(0x0011),
+ W16(0x0008), W16(0xFFF2), W16(0xFFC4), W16(0x0039), W16(0x0003), W16(0xFFFB), W16(0x0008), W16(0xFF8E),
+ W16(0x0027), W16(0xFFEA), W16(0x0021), W16(0x0041), W16(0xFFF2), W16(0xFFE4), W16(0x0018), W16(0x0005),
+ W16(0x0006), W16(0x000E), W16(0xFFEB), W16(0xFFDA), W16(0x0009), W16(0x0019), W16(0x002C), W16(0x004F),
+ W16(0x0077), W16(0xFFEC), W16(0xFFE6), W16(0xFFF4), W16(0xFFF6), W16(0x000D), W16(0x001C), W16(0xFFE2),
+ W16(0x0030), W16(0x0035), W16(0x0004), W16(0xFFF5), W16(0x001F), W16(0x003C), W16(0xFFD0), W16(0xFFC4),
+ W16(0xFFB1), W16(0x0000), W16(0xFFF9), W16(0xFFF5), W16(0xFFEB), W16(0xFFF8), W16(0xFFF8), W16(0xFFFB),
+ W16(0x0023), W16(0xFF64), W16(0x002A), W16(0x0001), W16(0x0004), W16(0x0030), W16(0x0004), W16(0xFFD9),
+ W16(0x001B), W16(0xFFDF), W16(0xFFF9), W16(0x0022), W16(0x0011), W16(0xFFE4), W16(0xFFE1), W16(0xFFE2),
+ W16(0x0023), W16(0x0014), W16(0x0025), W16(0xFFF3), W16(0xFFEA), W16(0xFFEB), W16(0xFFED), W16(0xFFF5),
+ W16(0x004C), W16(0xFFDE), W16(0xFFE9), W16(0x0024), W16(0x0073), W16(0xFFEB), W16(0xFFCA), W16(0x0018),
+ W16(0x0024), W16(0xFFE8), W16(0x0022), W16(0xFFD7), W16(0xFFD6), W16(0xFFFE), W16(0xFFE4), W16(0xFFFB),
+ W16(0x0009), W16(0xFFDF), W16(0x000D), W16(0x0008), W16(0x0012), W16(0x000C), W16(0x0012), W16(0x0019),
+ W16(0xFFC4), W16(0x005D), W16(0x001A), W16(0x004E), W16(0x0030), W16(0x0028), W16(0xFFFA), W16(0xFFE7),
+ W16(0xFFD3), W16(0xFFE7), W16(0x001A), W16(0x000C), W16(0xFFCB), W16(0xFFD8), W16(0x0013), W16(0x0011),
+ W16(0x001F), W16(0x003A), W16(0x0019), W16(0x0006), W16(0xFFF2), W16(0xFFFE), W16(0x000C), W16(0x0019),
+ W16(0xFFFF), W16(0x0027), W16(0xFF96), W16(0x0023), W16(0xFFFA), W16(0x002D), W16(0xFFC5), W16(0x0037),
+ W16(0x000B), W16(0xFFD5), W16(0x0027), W16(0xFFF7), W16(0x0007), W16(0x001C), W16(0xFFF4), W16(0xFFDB),
+ W16(0xFFEE), W16(0x0015), W16(0xFFF9), W16(0xFFF6), W16(0xFFE9), W16(0xFFE9), W16(0xFFFF), W16(0x0027),
+ W16(0x004C), W16(0x0038), W16(0xFFBB), W16(0xFFF4), W16(0x000E), W16(0xFFA5), W16(0xFFD7), W16(0xFFF3),
+ W16(0xFFE5), W16(0xFFFA), W16(0x0015), W16(0x0046), W16(0x0023), W16(0xFFFA), W16(0xFFED), W16(0x0010),
+ W16(0x0030), W16(0x0025), W16(0x003E), W16(0x0006), W16(0xFFD6), W16(0xFFDE), W16(0xFFEE), W16(0x0006),
+ W16(0x0002), W16(0x001D), W16(0xFFC3), W16(0x000D), W16(0xFFFD), W16(0x0008), W16(0x0053), W16(0xFFD9),
+ W16(0xFFA1), W16(0xFF9C), W16(0x004A), W16(0x0032), W16(0xFFB5), W16(0x0050), W16(0xFFF1), W16(0x000E),
+ W16(0x0013), W16(0xFFD6), W16(0xFFFA), W16(0xFFF4), W16(0xFFFE), W16(0xFFE9), W16(0xFFCD), W16(0xFFC4),
+ W16(0x002E), W16(0x001B), W16(0x0026), W16(0xFFC8), W16(0x001D), W16(0xFFA0), W16(0x0026), W16(0x0031),
+ W16(0x005B), W16(0x0017), W16(0xFFD8), W16(0x0004), W16(0x0003), W16(0xFFD6), W16(0xFFF9), W16(0xFFD2),
+ W16(0xFFFA), W16(0xFFEF), W16(0xFFF5), W16(0xFFF7), W16(0xFFEF), W16(0x000F), W16(0x0036), W16(0x004E),
+ W16(0xFFCD), W16(0x0006), W16(0x001E), W16(0x0007), W16(0x0024), W16(0x0000), W16(0x0012), W16(0x000B),
+ W16(0x0031), W16(0xFFFA), W16(0x0004), W16(0x004F), W16(0xFFB3), W16(0x0017), W16(0xFFCE), W16(0xFFDA),
+ W16(0xFFD0), W16(0xFFE6), W16(0xFFE6), W16(0x0039), W16(0x0044), W16(0x003F), W16(0x0024), W16(0x0014),
+ W16(0xFFF4), W16(0xFFE0), W16(0x0002), W16(0x0020), W16(0xFFD5), W16(0xFFE0), W16(0xFFF9), W16(0x0018),
+ W16(0x004A), W16(0x0032), W16(0xFF9D), W16(0x0010), W16(0xFFBA), W16(0x0019), W16(0x000B), W16(0x001F),
+ W16(0x0013), W16(0xFFFE), W16(0x0016), W16(0xFFFA), W16(0xFFF2), W16(0xFFED), W16(0xFFEA), W16(0xFFFD),
+ W16(0x0005), W16(0xFFE1), W16(0x0003), W16(0x0041), W16(0x000E), W16(0xFFF3), W16(0x0050), W16(0x002C),
+ W16(0xFFDC), W16(0xFFEE), W16(0x0002), W16(0xFF95), W16(0x001E), W16(0x0006), W16(0x0000), W16(0xFFFD),
+ W16(0x0002), W16(0x000F), W16(0x002E), W16(0x0041), W16(0x0008), W16(0xFFF4), W16(0xFFE4), W16(0xFFEF),
+ W16(0xFFC3), W16(0x001F), W16(0x0020), W16(0xFFFD), W16(0xFFEA), W16(0x0021), W16(0xFFEA), W16(0xFFEF),
+ W16(0xFFF4), W16(0x004B), W16(0x000F), W16(0xFFA9), W16(0x0058), W16(0xFFC5), W16(0xFFD5), W16(0x004C),
+ W16(0xFFE4), W16(0x003A), W16(0x0016), W16(0x000C), W16(0xFFED), W16(0x001D), W16(0x001E), W16(0x0017),
+ W16(0x0015), W16(0x007A), W16(0x001F), W16(0xFFDC), W16(0xFFEB), W16(0x0025), W16(0x0000), W16(0x000D),
+ W16(0x0031), W16(0x0001), W16(0xFFF5), W16(0xFFC2), W16(0xFFDF), W16(0xFFF7), W16(0xFFF7), W16(0x0004),
+ W16(0x002B), W16(0x0029), W16(0x0028), W16(0x0025), W16(0x001B), W16(0x0010), W16(0x000C), W16(0x0011),
+ W16(0xFFEE), W16(0x0062), W16(0x003D), W16(0x0058), W16(0x0031), W16(0xFFF5), W16(0x000E), W16(0x000D),
+ W16(0x000D), W16(0x0005), W16(0xFFEC), W16(0xFFF2), W16(0x0020), W16(0x001D), W16(0xFFB1), W16(0xFFEC),
+ W16(0xFFF4), W16(0xFFEB), W16(0xFFE7), W16(0xFFD8), W16(0xFFF3), W16(0xFFF0), W16(0xFFE2), W16(0xFFDC),
+ W16(0x0019), W16(0xFFBF), W16(0xFFF8), W16(0x0010), W16(0xFFF3), W16(0xFFE0), W16(0x0028), W16(0x0034),
+ W16(0xFFE6), W16(0x0016), W16(0x004D), W16(0x0000), W16(0xFFC6), W16(0xFFD8), W16(0xFFC6), W16(0x002E),
+ W16(0xFFF6), W16(0x0068), W16(0x002D), W16(0xFFE4), W16(0x0009), W16(0x002E), W16(0x0045), W16(0x0059),
+ W16(0x0013), W16(0x0009), W16(0x0031), W16(0x0012), W16(0x0041), W16(0x0003), W16(0x0009), W16(0xFFF9),
+ W16(0x0001), W16(0x0005), W16(0x0010), W16(0x0006), W16(0xFFFA), W16(0x0021), W16(0x001A), W16(0xFFE0),
+ W16(0xFF87), W16(0xFFC2), W16(0x00FF), W16(0xFFF1), W16(0x000C), W16(0x0020), W16(0xFFF1), W16(0x0033),
+ W16(0x002E), W16(0x0007), W16(0x0048), W16(0xFFA8), W16(0xFFFF), W16(0x003C), W16(0xFFE9), W16(0xFFCA),
+ W16(0xFFE5), W16(0x0023), W16(0xFFE6), W16(0x0048), W16(0xFFA2), W16(0x002F), W16(0x0011), W16(0xFFF0),
+ W16(0x0009), W16(0x0016), W16(0x002B), W16(0x002A), W16(0xFFCE), W16(0xFFDF), W16(0xFFC7), W16(0xFFC7),
+ W16(0xFFE0), W16(0x003A), W16(0x0040), W16(0x0013), W16(0xFF97), W16(0x000B), W16(0x0020), W16(0x001A),
+ W16(0xFFF6), W16(0xFFD8), W16(0x000C), W16(0x0064), W16(0x0024), W16(0xFFF9), W16(0xFFE1), W16(0xFFE1),
+ W16(0x0008), W16(0xFFFF), W16(0x0013), W16(0x001C), W16(0x0000), W16(0xFFEA), W16(0xFFEE), W16(0x0007),
+ W16(0x0042), W16(0xFFE7), W16(0xFFCB), W16(0x0004), W16(0xFFAD), W16(0x0010), W16(0x0001), W16(0x0019),
+ W16(0xFFD0), W16(0x0052), W16(0x000E), W16(0x000C), W16(0xFFF6), W16(0x0011), W16(0xFFE9), W16(0xFFE9),
+ W16(0x0013), W16(0xFFE4), W16(0x0014), W16(0x003B), W16(0x0033), W16(0x0034), W16(0x0030), W16(0x0030),
+ W16(0xFFD0), W16(0x002C), W16(0x0005), W16(0xFFF2), W16(0xFFF0), W16(0xFF90), W16(0xFFB8), W16(0xFFF6),
+ W16(0x0013), W16(0x001A), W16(0x0026), W16(0xFFFC), W16(0x000E), W16(0x0037), W16(0x0021), W16(0x000E),
+ W16(0x000E), W16(0x0010), W16(0x0029), W16(0x0020), W16(0x0025), W16(0x0026), W16(0x0033), W16(0x0038),
+ W16(0x0016), W16(0x000D), W16(0xFFD6), W16(0x002B), W16(0x000D), W16(0x0029), W16(0xFFF8), W16(0x000C),
+ W16(0x0027), W16(0x0008), W16(0xFFB4), W16(0x0012), W16(0x0016), W16(0xFFCF), W16(0xFFEF), W16(0xFFD4),
+ W16(0x0029), W16(0x0026), W16(0xFFF5), W16(0x00A4), W16(0x009C), W16(0xFE71), W16(0x003B), W16(0xFF88),
+ W16(0x0016), W16(0x000A), W16(0x0021), W16(0x0085), W16(0xFFE0), W16(0x0022), W16(0xFFB1), W16(0x000D),
+ W16(0xFFE9), W16(0x0000), W16(0x0017), W16(0x001A), W16(0x000A), W16(0x000F), W16(0x001A), W16(0xFFF8),
+ W16(0xFFFA), W16(0xFFCA), W16(0xFFCB), W16(0x0000), W16(0xFFE7), W16(0xFFDF), W16(0xFFD0), W16(0xFFE5),
+ W16(0x0052), W16(0x0028), W16(0xFFCD), W16(0xFFE0), W16(0x000D), W16(0xFFD1), W16(0x0016), W16(0x001F),
+ W16(0xFFE1), W16(0xFFDC), W16(0xFFF4), W16(0xFFD9), W16(0xFFE3), W16(0x0048), W16(0x001D), W16(0x0004),
+ W16(0x0017), W16(0x0009), W16(0xFFAA), W16(0xFFAD), W16(0x0093), W16(0x005D), W16(0x0023), W16(0x008B),
+ W16(0x0035), W16(0x001A), W16(0x008C), W16(0xFFD3), W16(0x001B), W16(0xFFF8), W16(0x000A), W16(0x001D),
+ W16(0xFFA4), W16(0xFFFC), W16(0x0037), W16(0xFFFA), W16(0xFFE3), W16(0xFFDA), W16(0x0008), W16(0x0011),
+ W16(0x0020), W16(0xFFEE), W16(0xFFF0), W16(0xFFD9), W16(0xFFEE), W16(0xFFF2), W16(0xFFE8), W16(0x0010),
+ W16(0x0043), W16(0x0017), W16(0x0077), W16(0x0038), W16(0xFFF2), W16(0xFFF0), W16(0xFFEC), W16(0xFFC5),
+ W16(0x0026), W16(0x0007), W16(0x0022), W16(0xFFEB), W16(0xFFFA), W16(0x0012), W16(0x000F), W16(0x0016),
+ W16(0x0002), W16(0xFFE9), W16(0xFFF4), W16(0x0015), W16(0x0008), W16(0x001D), W16(0x003B), W16(0x0044),
+ W16(0x0025), W16(0xFFEB), W16(0x0026), W16(0x002A), W16(0xFFDB), W16(0x0000), W16(0x0047), W16(0x0005),
+ W16(0x000E), W16(0xFFBA), W16(0xFF9B), W16(0x000E), W16(0x0007), W16(0x0052), W16(0x003F), W16(0x0004),
+ W16(0xFFCE), W16(0x0041), W16(0x002C), W16(0xFFF5), W16(0xFFDC), W16(0x000E), W16(0x0023), W16(0x002A),
+ W16(0xFFE0), W16(0xFFFA), W16(0x0013), W16(0x000F), W16(0x0001), W16(0xFFF3), W16(0x0019), W16(0x0003),
+ W16(0xFFDD), W16(0x0010), W16(0x0004), W16(0x0017), W16(0xFFBA), W16(0x002B), W16(0xFFF7), W16(0xFF9E),
+ W16(0x006E), W16(0xFFF2), W16(0x0013), W16(0xFFAC), W16(0x0037), W16(0x012C), W16(0xFFBB), W16(0xFFB8),
+ W16(0x002C), W16(0x001F), W16(0x0017), W16(0xFFFE), W16(0xFFCE), W16(0xFFF3), W16(0x001E), W16(0xFFC7),
+ W16(0xFFE3), W16(0x0038), W16(0xFFD2), W16(0x0010), W16(0x0025), W16(0xFFD2), W16(0x0035), W16(0x0012),
+ W16(0x001F), W16(0x0028), W16(0x0033), W16(0x003A), W16(0x0021), W16(0xFFE2), W16(0xFFB8), W16(0xFFAF)
+};
+
+const Word16 cdk_37bits_6_fx[1536] =
+{
+ W16(0x0003), W16(0xFFDA), W16(0x0007), W16(0x0012), W16(0x0022), W16(0xFFFC), W16(0x001A), W16(0x0047),
+ W16(0x001D), W16(0x0029), W16(0x0015), W16(0xFFF4), W16(0xFFE2), W16(0xFFC7), W16(0xFFD7), W16(0xFFDC),
+ W16(0xFFD6), W16(0xFFE8), W16(0xFFE9), W16(0xFFC5), W16(0xFFFA), W16(0x0002), W16(0x0019), W16(0x0032),
+ W16(0xFF9B), W16(0xFFEF), W16(0xFFDC), W16(0xFFDE), W16(0xFFF3), W16(0x0024), W16(0xFFE6), W16(0xFFCA),
+ W16(0xFFD9), W16(0x000B), W16(0x0009), W16(0x002B), W16(0xFFFB), W16(0x000A), W16(0xFFE1), W16(0xFFF7),
+ W16(0x0045), W16(0xFFE3), W16(0x0009), W16(0xFFF9), W16(0xFFD4), W16(0xFFDE), W16(0x001C), W16(0x0027),
+ W16(0xFFCC), W16(0xFFBD), W16(0xFFF8), W16(0xFFB6), W16(0x0017), W16(0x0015), W16(0x002B), W16(0xFFDC),
+ W16(0x0026), W16(0x001E), W16(0xFFCC), W16(0xFFF1), W16(0xFFD5), W16(0xFFF5), W16(0x0009), W16(0x000F),
+ W16(0xFFEA), W16(0xFFD5), W16(0xFFFD), W16(0x0018), W16(0xFFFF), W16(0xFFE9), W16(0xFFEA), W16(0x0000),
+ W16(0x000C), W16(0x002C), W16(0xFFCF), W16(0x0042), W16(0x001C), W16(0xFFF8), W16(0x0001), W16(0xFFDF),
+ W16(0xFFEE), W16(0x0014), W16(0x0030), W16(0xFFC4), W16(0x001C), W16(0x0013), W16(0xFFED), W16(0xFFF6),
+ W16(0x0003), W16(0xFFBD), W16(0xFFC7), W16(0xFFF4), W16(0x000A), W16(0xFFF4), W16(0xFFF5), W16(0xFFE4),
+ W16(0xFFF2), W16(0xFFD3), W16(0xFFE6), W16(0xFFEF), W16(0x0003), W16(0xFFE0), W16(0xFFCD), W16(0xFFF2),
+ W16(0x002D), W16(0xFFE1), W16(0x0061), W16(0xFFFF), W16(0xFFD0), W16(0xFFEB), W16(0xFFEA), W16(0x0024),
+ W16(0x0027), W16(0x000A), W16(0xFFE5), W16(0xFFCA), W16(0xFFE6), W16(0xFFEF), W16(0xFFF9), W16(0xFFE6),
+ W16(0xFFE1), W16(0x0000), W16(0xFFEB), W16(0x0011), W16(0xFFFA), W16(0xFFF0), W16(0x0024), W16(0x0018),
+ W16(0x0003), W16(0xFFE4), W16(0xFFF2), W16(0xFFF5), W16(0xFFEF), W16(0xFFE8), W16(0x000D), W16(0x0044),
+ W16(0xFFE4), W16(0xFFF9), W16(0xFFC7), W16(0xFFF8), W16(0xFF82), W16(0x00CE), W16(0xFFCF), W16(0x0030),
+ W16(0x0018), W16(0xFFAE), W16(0x0005), W16(0xFFC6), W16(0xFFBA), W16(0x0005), W16(0x0021), W16(0x000B),
+ W16(0xFFF5), W16(0xFFF4), W16(0x0005), W16(0x002F), W16(0xFFF4), W16(0xFFFB), W16(0xFFFE), W16(0x0004),
+ W16(0x0007), W16(0x0011), W16(0xFFF5), W16(0xFFE5), W16(0x0003), W16(0x001C), W16(0x003F), W16(0x0042),
+ W16(0xFFB1), W16(0xFFD1), W16(0x0012), W16(0xFFFB), W16(0x001F), W16(0xFFE4), W16(0x0016), W16(0xFFFF),
+ W16(0x0001), W16(0xFFFC), W16(0xFFF3), W16(0xFFB8), W16(0x001C), W16(0x0027), W16(0xFFFF), W16(0xFFEF),
+ W16(0x000F), W16(0x001C), W16(0x001B), W16(0xFFDA), W16(0x0008), W16(0x0003), W16(0x0018), W16(0x002B),
+ W16(0x0013), W16(0x0000), W16(0x0005), W16(0xFFF6), W16(0xFFF0), W16(0xFF94), W16(0x003D), W16(0x0003),
+ W16(0x0006), W16(0xFFFE), W16(0xFFFE), W16(0x0023), W16(0x0010), W16(0x000E), W16(0x0022), W16(0xFFDF),
+ W16(0xFFF7), W16(0xFFD6), W16(0xFFF5), W16(0xFFD2), W16(0xFFCA), W16(0xFFBC), W16(0xFFD7), W16(0xFFF2),
+ W16(0xFFD3), W16(0xFFF1), W16(0xFFB4), W16(0xFFEE), W16(0xFFCA), W16(0xFFCD), W16(0x000E), W16(0x0046),
+ W16(0x0001), W16(0xFFEB), W16(0x002D), W16(0x0005), W16(0x0001), W16(0x0011), W16(0xFFFC), W16(0x0007),
+ W16(0xFFE3), W16(0xFFDE), W16(0xFFF4), W16(0x0022), W16(0x0020), W16(0x000C), W16(0xFFF7), W16(0xFFE6),
+ W16(0xFFFA), W16(0xFFD0), W16(0x0004), W16(0x0004), W16(0xFFD6), W16(0x0004), W16(0xFFD3), W16(0x0012),
+ W16(0x001C), W16(0xFFA6), W16(0xFFCE), W16(0x0026), W16(0xFFF3), W16(0x004B), W16(0x002F), W16(0xFFFE),
+ W16(0x0021), W16(0xFFEE), W16(0xFFE8), W16(0x0008), W16(0x000E), W16(0x0002), W16(0x000C), W16(0xFFFC),
+ W16(0xFFDF), W16(0x003D), W16(0x0008), W16(0xFFB1), W16(0x0025), W16(0x0009), W16(0x001D), W16(0x0013),
+ W16(0xFFE9), W16(0xFFC5), W16(0xFFEF), W16(0x0006), W16(0x002C), W16(0x0018), W16(0x0014), W16(0xFFD7),
+ W16(0xFFD0), W16(0xFFDB), W16(0xFFEB), W16(0x0008), W16(0xFFE9), W16(0xFFF1), W16(0x0009), W16(0x0012),
+ W16(0x001A), W16(0xFFF4), W16(0xFFD3), W16(0xFFFB), W16(0xFFDF), W16(0x001B), W16(0x0004), W16(0xFFFD),
+ W16(0x0037), W16(0xFFE2), W16(0xFFF0), W16(0x0014), W16(0xFFF4), W16(0xFFF2), W16(0xFFF5), W16(0x000E),
+ W16(0xFFFF), W16(0xFFC4), W16(0x00C0), W16(0xFFAA), W16(0xFFBD), W16(0x0002), W16(0x001A), W16(0xFFCE),
+ W16(0x000E), W16(0xFFDE), W16(0xFF98), W16(0x0022), W16(0x0022), W16(0xFFFA), W16(0x0034), W16(0xFFF5),
+ W16(0x0013), W16(0xFFDB), W16(0xFFCF), W16(0x0003), W16(0xFFF3), W16(0xFFFB), W16(0x000C), W16(0xFFCE),
+ W16(0x0034), W16(0x0026), W16(0x0009), W16(0xFFF8), W16(0xFFE9), W16(0xFFE6), W16(0xFFF2), W16(0xFFFA),
+ W16(0xFFF6), W16(0x0002), W16(0xFFD7), W16(0x001A), W16(0x0007), W16(0x0004), W16(0xFFDC), W16(0xFFF3),
+ W16(0x0020), W16(0x0017), W16(0xFFD8), W16(0xFFF5), W16(0xFFC0), W16(0x006D), W16(0xFFDC), W16(0x0033),
+ W16(0xFFE6), W16(0xFFE3), W16(0xFFE1), W16(0xFFE2), W16(0x000C), W16(0x0019), W16(0x0026), W16(0x0023),
+ W16(0xFFDD), W16(0x0032), W16(0xFFFB), W16(0x0003), W16(0xFFD2), W16(0xFFDB), W16(0x001C), W16(0xFFF2),
+ W16(0xFFFD), W16(0x003B), W16(0xFFED), W16(0xFFF7), W16(0xFFD6), W16(0xFFB8), W16(0x0027), W16(0x003D),
+ W16(0x0037), W16(0x0003), W16(0xFFC9), W16(0xFFD7), W16(0x0021), W16(0x0011), W16(0x001E), W16(0xFFEA),
+ W16(0xFFEF), W16(0x001D), W16(0x0013), W16(0xFFEC), W16(0x0002), W16(0x0021), W16(0x0023), W16(0x003D),
+ W16(0xFFF4), W16(0xFFF0), W16(0xFFDD), W16(0x0008), W16(0x000F), W16(0xFFBF), W16(0xFFBA), W16(0xFFEF),
+ W16(0x003F), W16(0xFFE5), W16(0xFFF4), W16(0xFFFC), W16(0x000A), W16(0x000B), W16(0xFFFE), W16(0xFFD7),
+ W16(0xFFF7), W16(0x0013), W16(0xFFD5), W16(0xFFEA), W16(0xFFD1), W16(0x0025), W16(0xFFF1), W16(0xFFF8),
+ W16(0x000E), W16(0x004D), W16(0x0028), W16(0x0004), W16(0x001F), W16(0xFFEA), W16(0xFFD0), W16(0xFFCE),
+ W16(0xFFF1), W16(0xFFFF), W16(0xFFE6), W16(0xFFF1), W16(0xFFC9), W16(0xFFC2), W16(0xFFCC), W16(0xFFD9),
+ W16(0xFFFB), W16(0xFFC2), W16(0xFFFE), W16(0xFFE4), W16(0x0022), W16(0x0029), W16(0xFFF8), W16(0x0044),
+ W16(0xFFBD), W16(0xFFEE), W16(0xFFFF), W16(0xFFD1), W16(0xFFFF), W16(0x002C), W16(0xFFF2), W16(0xFFE4),
+ W16(0xFFFC), W16(0x000C), W16(0xFFE9), W16(0x001B), W16(0x0019), W16(0x0011), W16(0xFFF6), W16(0xFFC8),
+ W16(0xFFD8), W16(0x0018), W16(0xFFEE), W16(0xFFD1), W16(0x0042), W16(0xFFDE), W16(0x0031), W16(0xFFC4),
+ W16(0xFFFB), W16(0xFFEC), W16(0x002B), W16(0xFFF6), W16(0x000B), W16(0xFFEE), W16(0xFFCD), W16(0x003C),
+ W16(0xFFE2), W16(0xFFFE), W16(0x0006), W16(0xFFF5), W16(0xFFF9), W16(0xFFE4), W16(0xFFEA), W16(0xFFE3),
+ W16(0xFFD6), W16(0x0017), W16(0xFFFC), W16(0xFFEE), W16(0x0024), W16(0xFFF2), W16(0xFFEB), W16(0x0004),
+ W16(0x000E), W16(0xFFF3), W16(0x0021), W16(0xFFED), W16(0xFFD3), W16(0xFFFE), W16(0x003B), W16(0xFFDD),
+ W16(0x0006), W16(0x008A), W16(0xFF6E), W16(0x002F), W16(0x002E), W16(0x0020), W16(0x000F), W16(0xFFDB),
+ W16(0xFFFF), W16(0x0000), W16(0x0045), W16(0xFFF6), W16(0x0008), W16(0x003C), W16(0xFFE5), W16(0xFFF7),
+ W16(0xFFDD), W16(0xFFFD), W16(0xFFE8), W16(0xFFC4), W16(0xFFEE), W16(0x0000), W16(0x000D), W16(0x0028),
+ W16(0x0036), W16(0x0020), W16(0xFFDB), W16(0xFFB8), W16(0xFFDC), W16(0xFFEA), W16(0xFFF1), W16(0xFFE2),
+ W16(0xFFEE), W16(0x0014), W16(0x002C), W16(0xFFCD), W16(0xFFFB), W16(0x0018), W16(0xFFEE), W16(0x001D),
+ W16(0x0035), W16(0xFFDA), W16(0x0020), W16(0xFFEC), W16(0x0002), W16(0xFFFF), W16(0xFFB9), W16(0x002B),
+ W16(0xFFE1), W16(0xFFB9), W16(0xFFE5), W16(0x0007), W16(0x0001), W16(0x000A), W16(0x0025), W16(0x0027),
+ W16(0x0024), W16(0xFFA1), W16(0x0020), W16(0x001A), W16(0x0020), W16(0xFFFD), W16(0x0001), W16(0xFFDD),
+ W16(0xFFB9), W16(0x0008), W16(0xFFF3), W16(0x003F), W16(0x0004), W16(0x0012), W16(0xFFDE), W16(0x0026),
+ W16(0xFFF9), W16(0xFFEB), W16(0xFFFD), W16(0xFFFD), W16(0xFFF1), W16(0xFFF0), W16(0xFFEF), W16(0xFFCE),
+ W16(0x0002), W16(0xFFF6), W16(0xFFD5), W16(0x002D), W16(0x0014), W16(0x000B), W16(0x0050), W16(0xFFFB),
+ W16(0xFFC8), W16(0xFFF7), W16(0x0000), W16(0xFFF8), W16(0xFFD7), W16(0xFFE9), W16(0x0044), W16(0xFFFF),
+ W16(0xFFDC), W16(0xFFC0), W16(0x0010), W16(0x0016), W16(0xFFF1), W16(0x0003), W16(0x0011), W16(0x001F),
+ W16(0xFFD2), W16(0xFFE4), W16(0xFFDE), W16(0x0028), W16(0xFFE1), W16(0x0048), W16(0x001A), W16(0xFFED),
+ W16(0x0006), W16(0xFFE3), W16(0xFFD1), W16(0x0012), W16(0x002A), W16(0x0001), W16(0xFFF1), W16(0x001A),
+ W16(0xFFCE), W16(0x0007), W16(0xFFDA), W16(0xFFE4), W16(0x0034), W16(0xFFE1), W16(0xFFD0), W16(0xFFD2),
+ W16(0xFFD3), W16(0x0000), W16(0xFFF8), W16(0x0023), W16(0x001A), W16(0xFFD7), W16(0xFFC2), W16(0x0007),
+ W16(0x0027), W16(0x0035), W16(0xFFC3), W16(0x000D), W16(0x001A), W16(0xFFE5), W16(0x0033), W16(0xFFE6),
+ W16(0x0000), W16(0xFFCF), W16(0xFFFA), W16(0x0016), W16(0x000C), W16(0x0009), W16(0x001D), W16(0x0014),
+ W16(0x0014), W16(0x0015), W16(0x000F), W16(0xFFF3), W16(0xFFBB), W16(0x002B), W16(0x002F), W16(0xFFE4),
+ W16(0xFFF4), W16(0xFFEF), W16(0x004E), W16(0xFFCE), W16(0x0009), W16(0x0012), W16(0x0014), W16(0x0008),
+ W16(0xFFD1), W16(0x001C), W16(0x0010), W16(0xFFE0), W16(0xFFEE), W16(0xFFF1), W16(0x000C), W16(0x0004),
+ W16(0xFFA0), W16(0x0005), W16(0x0061), W16(0x000D), W16(0xFFE8), W16(0xFFFF), W16(0xFFF5), W16(0x0002),
+ W16(0xFFF2), W16(0x0003), W16(0x001F), W16(0x0020), W16(0x0006), W16(0x000D), W16(0xFFFF), W16(0xFFF3),
+ W16(0xFFE8), W16(0xFFFA), W16(0x0011), W16(0x000B), W16(0xFFE7), W16(0xFFDD), W16(0xFFDA), W16(0xFFC3),
+ W16(0x0013), W16(0x0022), W16(0xFFDA), W16(0x0002), W16(0xFFF1), W16(0x0049), W16(0xFFC8), W16(0x0025),
+ W16(0xFFBE), W16(0xFFF7), W16(0x001C), W16(0x002B), W16(0xFFC7), W16(0xFFEF), W16(0x0004), W16(0x002C),
+ W16(0xFFF7), W16(0xFFF3), W16(0xFFFB), W16(0x000B), W16(0x000A), W16(0xFFE8), W16(0xFFDF), W16(0xFFD2),
+ W16(0x002E), W16(0xFFEE), W16(0xFFFF), W16(0xFFEE), W16(0x003D), W16(0xFFE4), W16(0xFFE8), W16(0x002D),
+ W16(0x0000), W16(0x0015), W16(0x000C), W16(0xFFD1), W16(0xFFA8), W16(0xFFF7), W16(0x0011), W16(0x0015),
+ W16(0x0011), W16(0xFFF8), W16(0x0003), W16(0x0022), W16(0xFFD0), W16(0xFFC1), W16(0xFFC2), W16(0xFFD9),
+ W16(0x0006), W16(0x0016), W16(0xFFFB), W16(0xFF9E), W16(0xFFBD), W16(0xFFDF), W16(0xFFD1), W16(0x0019),
+ W16(0x000F), W16(0x0021), W16(0xFFE9), W16(0xFFF1), W16(0x0024), W16(0x0010), W16(0x0006), W16(0x0016),
+ W16(0x0021), W16(0x0014), W16(0x0017), W16(0x0016), W16(0x0002), W16(0xFFE5), W16(0xFFE0), W16(0xFFDD),
+ W16(0xFFE0), W16(0x0019), W16(0x0009), W16(0x0038), W16(0x0013), W16(0x0005), W16(0x0009), W16(0x0034),
+ W16(0x0024), W16(0xFFB7), W16(0xFFFD), W16(0x003C), W16(0xFFD1), W16(0xFFED), W16(0xFFFD), W16(0xFFEB),
+ W16(0xFFF1), W16(0x002C), W16(0x0031), W16(0xFFE2), W16(0xFFFD), W16(0xFFDA), W16(0xFFF5), W16(0x0001),
+ W16(0x0002), W16(0xFFE6), W16(0xFFDF), W16(0xFFDB), W16(0x0041), W16(0x000A), W16(0xFFD3), W16(0x0000),
+ W16(0x0021), W16(0x001C), W16(0xFFDC), W16(0x002A), W16(0x0012), W16(0xFFDF), W16(0xFFBD), W16(0x0001),
+ W16(0xFFF0), W16(0x003B), W16(0x0005), W16(0x0009), W16(0x0031), W16(0x0026), W16(0x001A), W16(0x0007),
+ W16(0x003C), W16(0xFFE4), W16(0x003E), W16(0xFFF5), W16(0x002C), W16(0xFFFB), W16(0x0024), W16(0xFFD0),
+ W16(0x001F), W16(0xFFD1), W16(0x0005), W16(0x0012), W16(0x0004), W16(0xFFCC), W16(0x001F), W16(0xFFF1),
+ W16(0xFFFE), W16(0xFFF4), W16(0xFFE6), W16(0x0020), W16(0xFFFD), W16(0xFFEA), W16(0xFFD6), W16(0xFFB7),
+ W16(0x0034), W16(0xFFDE), W16(0xFFC8), W16(0xFFBB), W16(0x0018), W16(0xFFFE), W16(0xFFC5), W16(0xFFDE),
+ W16(0x0010), W16(0xFFFB), W16(0x0013), W16(0xFFD3), W16(0x002C), W16(0x000E), W16(0x0032), W16(0x0002),
+ W16(0xFFEA), W16(0xFFDE), W16(0xFFD6), W16(0xFFEF), W16(0x0009), W16(0xFFFB), W16(0x0012), W16(0x001C),
+ W16(0x004A), W16(0xFFD8), W16(0x0012), W16(0x0013), W16(0xFFE1), W16(0xFFF3), W16(0xFFD0), W16(0xFFFB),
+ W16(0xFFEB), W16(0x001A), W16(0x004F), W16(0xFFF6), W16(0xFFE2), W16(0x001D), W16(0x003B), W16(0xFFBB),
+ W16(0x0022), W16(0x0016), W16(0x001D), W16(0xFFF7), W16(0xFFF3), W16(0x0000), W16(0x0007), W16(0x0003),
+ W16(0xFFE8), W16(0xFFFF), W16(0x000B), W16(0x0018), W16(0x0001), W16(0x002D), W16(0xFFE3), W16(0xFFEA),
+ W16(0xFFDD), W16(0x002D), W16(0x0008), W16(0xFFE3), W16(0x0031), W16(0x0029), W16(0x0000), W16(0xFFD6),
+ W16(0xFFDF), W16(0xFFE3), W16(0x0001), W16(0x0091), W16(0xFF6B), W16(0x0028), W16(0x0032), W16(0xFFF0),
+ W16(0x000B), W16(0xFFF6), W16(0x0011), W16(0x000E), W16(0xFFB0), W16(0x003F), W16(0x0007), W16(0x004A),
+ W16(0x0015), W16(0x0025), W16(0xFFCA), W16(0xFFD4), W16(0xFFE5), W16(0xFFF2), W16(0x0026), W16(0xFFFF),
+ W16(0xFFED), W16(0xFFFC), W16(0x0006), W16(0x0009), W16(0x000A), W16(0xFFF4), W16(0xFFFF), W16(0xFFFD),
+ W16(0x004B), W16(0x0013), W16(0xFFF7), W16(0x0009), W16(0x0021), W16(0x0000), W16(0x0015), W16(0x000D),
+ W16(0xFFD2), W16(0x002C), W16(0xFF9E), W16(0xFFED), W16(0x001E), W16(0x000D), W16(0x000D), W16(0xFFFE),
+ W16(0xFFFE), W16(0xFFF0), W16(0xFFF3), W16(0xFFF3), W16(0x0006), W16(0x000C), W16(0x0011), W16(0x0003),
+ W16(0x0026), W16(0x0047), W16(0xFFE0), W16(0xFFF6), W16(0xFFD5), W16(0xFFF6), W16(0xFFF4), W16(0xFFFC),
+ W16(0x0049), W16(0x001B), W16(0xFFDE), W16(0x0053), W16(0xFFE1), W16(0xFFF3), W16(0xFFF3), W16(0x0004),
+ W16(0xFFE5), W16(0xFFE4), W16(0xFFFD), W16(0x0013), W16(0xFFE9), W16(0x0005), W16(0xFFF0), W16(0xFFC2),
+ W16(0xFFFC), W16(0x000D), W16(0x0008), W16(0x0023), W16(0x002A), W16(0xFFCD), W16(0x0034), W16(0x0002),
+ W16(0xFFE5), W16(0x0032), W16(0x0036), W16(0x0011), W16(0x0006), W16(0xFFC8), W16(0xFFEE), W16(0xFFD7),
+ W16(0xFFE2), W16(0x0011), W16(0x001D), W16(0x0043), W16(0x002F), W16(0xFFF3), W16(0xFFE0), W16(0xFFD6),
+ W16(0xFFFC), W16(0x002B), W16(0x0000), W16(0x001E), W16(0x000D), W16(0x002E), W16(0xFFDF), W16(0x0006),
+ W16(0x000B), W16(0xFFE7), W16(0xFFEA), W16(0xFFF8), W16(0x000B), W16(0xFFDC), W16(0x004B), W16(0xFF7E),
+ W16(0x005D), W16(0xFFE1), W16(0xFFDF), W16(0xFFF9), W16(0x002E), W16(0xFFF6), W16(0xFFFE), W16(0x0027),
+ W16(0xFFEB), W16(0x0033), W16(0xFFC8), W16(0x0008), W16(0xFFE0), W16(0xFFEF), W16(0xFFF9), W16(0x0007),
+ W16(0xFFBB), W16(0x000D), W16(0xFFFF), W16(0x000D), W16(0x003E), W16(0x001F), W16(0x0014), W16(0xFFF6),
+ W16(0xFFF6), W16(0x003B), W16(0x001A), W16(0xFFD2), W16(0xFFE7), W16(0x0093), W16(0x0065), W16(0xFF85),
+ W16(0x0028), W16(0xFFCF), W16(0x0031), W16(0x0011), W16(0xFFF6), W16(0xFFE2), W16(0xFFFD), W16(0xFFFA),
+ W16(0x0003), W16(0x002F), W16(0xFFFB), W16(0xFFCB), W16(0x004A), W16(0x0012), W16(0xFFC6), W16(0xFFED),
+ W16(0x0029), W16(0xFFA8), W16(0x002F), W16(0x002C), W16(0x0013), W16(0xFFEF), W16(0xFFFD), W16(0x0004),
+ W16(0x0005), W16(0xFFD9), W16(0xFFD1), W16(0x000C), W16(0x0004), W16(0xFFF4), W16(0x0000), W16(0xFFF0),
+ W16(0x000F), W16(0xFFEB), W16(0x0029), W16(0x0019), W16(0x001D), W16(0x0022), W16(0xFFF5), W16(0xFFEF),
+ W16(0xFFBA), W16(0x0018), W16(0x0044), W16(0x002D), W16(0xFFD1), W16(0xFFA7), W16(0x0019), W16(0x0077),
+ W16(0xFFF4), W16(0x0056), W16(0x0010), W16(0x0017), W16(0x0014), W16(0x0019), W16(0x0015), W16(0xFFBF),
+ W16(0x001D), W16(0xFFFB), W16(0xFFD8), W16(0xFFEC), W16(0xFFEB), W16(0x000C), W16(0x002E), W16(0x0019),
+ W16(0xFFE5), W16(0xFFFB), W16(0x0021), W16(0x003B), W16(0x0022), W16(0xFFEE), W16(0xFFF2), W16(0xFFF2),
+ W16(0xFFFA), W16(0xFFF3), W16(0x000A), W16(0x0006), W16(0xFFF9), W16(0xFFEC), W16(0xFFF5), W16(0x0012),
+ W16(0xFFDD), W16(0xFFFD), W16(0x001F), W16(0x001A), W16(0x0037), W16(0xFF7C), W16(0x0024), W16(0x001C),
+ W16(0x000F), W16(0x0024), W16(0x0021), W16(0xFFD4), W16(0x0009), W16(0xFFF3), W16(0x0007), W16(0x0046),
+ W16(0xFFFF), W16(0x0015), W16(0x0002), W16(0x001C), W16(0xFFCE), W16(0xFFBC), W16(0x0023), W16(0xFFF2),
+ W16(0xFFF1), W16(0xFFD0), W16(0x001E), W16(0x001F), W16(0x0022), W16(0x0007), W16(0xFFDE), W16(0x001E),
+ W16(0x003F), W16(0x0009), W16(0x0020), W16(0x003E), W16(0x002F), W16(0x0028), W16(0x0035), W16(0x002D),
+ W16(0x000E), W16(0x0010), W16(0x002D), W16(0x0004), W16(0xFFDE), W16(0x0002), W16(0x0008), W16(0xFF95),
+ W16(0x000F), W16(0x002D), W16(0xFFF8), W16(0x003A), W16(0x002D), W16(0x0003), W16(0x0005), W16(0xFFEB),
+ W16(0xFFF5), W16(0xFFEF), W16(0xFFE0), W16(0x0003), W16(0x001F), W16(0x001B), W16(0x001C), W16(0x0017),
+ W16(0x0017), W16(0xFFFB), W16(0x0035), W16(0x001A), W16(0x003F), W16(0x0047), W16(0xFFD5), W16(0xFFEC),
+ W16(0x000E), W16(0x0005), W16(0xFFF6), W16(0x000A), W16(0xFFE4), W16(0x0020), W16(0x0004), W16(0xFFC5),
+ W16(0xFFD9), W16(0xFFDB), W16(0xFFFE), W16(0xFFE5), W16(0xFFF9), W16(0xFFF1), W16(0x000F), W16(0x001B),
+ W16(0x0006), W16(0x0052), W16(0x0025), W16(0xFFED), W16(0x001D), W16(0xFFEA), W16(0xFFE0), W16(0x0014),
+ W16(0xFFBF), W16(0x0042), W16(0x0025), W16(0x0004), W16(0xFFE4), W16(0x000B), W16(0xFFDE), W16(0x000B),
+ W16(0x0002), W16(0xFFF1), W16(0xFFEF), W16(0x0006), W16(0x0013), W16(0x0013), W16(0x0032), W16(0x0034),
+ W16(0x0028), W16(0x0016), W16(0x0017), W16(0xFFE7), W16(0x0025), W16(0xFFEF), W16(0x0009), W16(0xFFE8),
+ W16(0xFFEC), W16(0xFFC2), W16(0x002B), W16(0x0013), W16(0x0009), W16(0x004E), W16(0xFFC9), W16(0xFFC9),
+ W16(0x0027), W16(0x0040), W16(0xFFE6), W16(0xFFF6), W16(0x0000), W16(0x0007), W16(0xFFFE), W16(0xFFF3),
+ W16(0x0006), W16(0xFFEE), W16(0xFFF7), W16(0x0038), W16(0xFFFD), W16(0xFFF4), W16(0xFFE9), W16(0x000D),
+ W16(0xFFDE), W16(0xFFFD), W16(0xFFD1), W16(0x0010), W16(0xFFF1), W16(0x0006), W16(0xFFF2), W16(0x0033),
+ W16(0x0043), W16(0x000E), W16(0x0018), W16(0x0026), W16(0xFFF0), W16(0xFFA0), W16(0xFFB0), W16(0x00BF),
+ W16(0xFFF9), W16(0x0002), W16(0xFFFE), W16(0x0033), W16(0x0001), W16(0x0019), W16(0xFFD1), W16(0x000D),
+ W16(0x0016), W16(0xFFB4), W16(0xFFF4), W16(0xFFCA), W16(0x0046), W16(0x0002), W16(0x002A), W16(0x0010),
+ W16(0xFFFE), W16(0x0021), W16(0x0018), W16(0x0017), W16(0xFFF1), W16(0xFFE7), W16(0xFFF1), W16(0xFFF4),
+ W16(0x000D), W16(0xFFE0), W16(0x0019), W16(0x0015), W16(0x0006), W16(0xFFB4), W16(0xFFCB), W16(0x000E),
+ W16(0x0008), W16(0x0017), W16(0xFFF4), W16(0xFFF1), W16(0x0019), W16(0x000E), W16(0x0010), W16(0x0075),
+ W16(0xFFBD), W16(0x001F), W16(0x0012), W16(0xFFE7), W16(0x0025), W16(0x000A), W16(0xFFEC), W16(0xFFD9),
+ W16(0x0002), W16(0xFFF2), W16(0x0032), W16(0x0049), W16(0xFFDA), W16(0x000E), W16(0x0052), W16(0xFFD9),
+ W16(0x000D), W16(0x0006), W16(0x0006), W16(0xFFEF), W16(0xFFC3), W16(0x0020), W16(0xFFF4), W16(0xFFF0),
+ W16(0x001E), W16(0xFFFB), W16(0xFFF3), W16(0x000A), W16(0x000C), W16(0x000E), W16(0x0005), W16(0x000B),
+ W16(0xFFCF), W16(0xFFF1), W16(0xFFE8), W16(0x0019), W16(0xFFF4), W16(0x0043), W16(0xFFEF), W16(0xFFEF),
+ W16(0x003B), W16(0xFFF5), W16(0x0027), W16(0xFFDD), W16(0xFFE9), W16(0xFFD0), W16(0xFFEB), W16(0xFFF9),
+ W16(0x001B), W16(0x0003), W16(0x0033), W16(0x002A), W16(0x0049), W16(0x0024), W16(0x000F), W16(0xFFF8),
+ W16(0x0015), W16(0x0026), W16(0x0010), W16(0x000E), W16(0x0004), W16(0xFFDA), W16(0x0009), W16(0xFFF8),
+ W16(0x004F), W16(0x003C), W16(0xFFD9), W16(0xFFDE), W16(0xFFF3), W16(0x0012), W16(0xFFE9), W16(0xFFDE),
+ W16(0x0013), W16(0x0058), W16(0x0010), W16(0xFFF8), W16(0xFFEC), W16(0xFFEB), W16(0x0008), W16(0x001F),
+ W16(0x005B), W16(0x0043), W16(0xFFFA), W16(0x0028), W16(0xFFEC), W16(0xFFF8), W16(0xFFF9), W16(0x0044),
+ W16(0x0008), W16(0xFFE6), W16(0x000F), W16(0xFFF1), W16(0x0016), W16(0x0005), W16(0xFFF3), W16(0x0001),
+ W16(0xFFE4), W16(0xFFF3), W16(0xFFFC), W16(0xFFF7), W16(0x0015), W16(0xFFFC), W16(0xFFE2), W16(0xFFCD),
+ W16(0x0001), W16(0x0003), W16(0x006E), W16(0xFFEB), W16(0x0011), W16(0xFFC8), W16(0x0023), W16(0x0026),
+ W16(0xFFF9), W16(0x0000), W16(0xFFD4), W16(0x001A), W16(0x0010), W16(0xFFF0), W16(0xFFE0), W16(0x0029),
+ W16(0xFFEC), W16(0x0018), W16(0x0027), W16(0x0010), W16(0x0009), W16(0xFFFB), W16(0x0016), W16(0x0034),
+ W16(0x0041), W16(0x001F), W16(0xFFD6), W16(0xFFBD), W16(0x0011), W16(0x0026), W16(0x003B), W16(0xFFDE),
+ W16(0xFFD0), W16(0xFFEF), W16(0xFFE6), W16(0xFFF1), W16(0x000B), W16(0xFFF0), W16(0xFFE2), W16(0x001D),
+ W16(0x001F), W16(0x0038), W16(0x0028), W16(0x0005), W16(0xFFB6), W16(0xFFD4), W16(0x0013), W16(0x0007),
+ W16(0x0003), W16(0xFFF8), W16(0xFFFF), W16(0xFFDD), W16(0x0002), W16(0x0001), W16(0xFFFD), W16(0xFFD9),
+ W16(0xFFCE), W16(0x0003), W16(0xFFFE), W16(0x0007), W16(0xFFCF), W16(0x001B), W16(0x0049), W16(0x0026),
+ W16(0xFFF8), W16(0x0038), W16(0x0046), W16(0x0009), W16(0x006E), W16(0x0044), W16(0x0011), W16(0xFFFF),
+ W16(0x000F), W16(0x0003), W16(0x002A), W16(0x0001), W16(0xFFE9), W16(0xFFF7), W16(0xFFCF), W16(0x000F),
+ W16(0x0014), W16(0x0003), W16(0x0028), W16(0x0031), W16(0x0008), W16(0xFFF2), W16(0xFFF2), W16(0xFFE6),
+ W16(0x0001), W16(0x000E), W16(0xFFA6), W16(0xFFA6), W16(0x0081), W16(0x007A), W16(0xFFA0), W16(0x0023)
+};
+
+const Word16 * const cdk_37bits[] = { cdk_37bits_1_fx, cdk_37bits_2_fx, cdk_37bits_3_fx, cdk_37bits_4_fx,
+ cdk_37bits_5_fx, cdk_37bits_6_fx
+ };
+
+const Word16 *lsf_means[2] = { means_wb_31bits_ma_lsf, means_nb_31bits_ma_lsf };
+
+
+const lsp_unw_triplet p16_gamma0_92to1[16] = /* Q14 */
+{
+ { 0, 19622, -9695 },
+ { -14938, 29357, -13258 },
+ { -8483, 23708, -13414 },
+ { -7350, 22410, -12305 },
+ { -7397, 21417, -12160 },
+ { -7071, 19878, -11229 },
+ { -7144, 19877, -11326 },
+ { -6423, 17194, -9613 },
+ { -7407, 18024, -9695 },
+ { -6972, 16339, -8191 },
+ { -8220, 17625, -8422 },
+ { -8159, 17459, -8289 },
+ { -8700, 19066, -9508 },
+ { -7986, 17629, -8607 },
+ { -8503, 17203, -8109 },
+ { -7820, 14903, 0 }
+};
+
+const lsp_unw_triplet p16_gamma0_94to1[16] = /* Q14 */
+{
+ { 0, 12931, -6314 },
+ { -9364, 19577, -8870 },
+ { -5512, 16236, -9305 },
+ { -4892, 15366, -8398 },
+ { -4869, 14631, -8275 },
+ { -4631, 13358, -7540 },
+ { -4575, 13271, -7599 },
+ { -4151, 11403, -6385 },
+ { -4859, 11947, -6371 },
+ { -4504, 10805, -5407 },
+ { -5346, 11618, -5515 },
+ { -5418, 11578, -5424 },
+ { -5806, 12711, -6226 },
+ { -5205, 11592, -5606 },
+ { -5745, 11498, -5188 },
+ { -5473, 10245, 0 }
+};
+
+
+/*Frame size config table*/
+const FrameSizeParams FrameSizeConfig[FRAME_SIZE_NB] =
+{
+ /* bits, net bits, trans_bits, trans_mode, band_bits, band_mode_min, band_mode_max, reserved_bits */
+ { FRAME_0, FRAME_0, 0, {0,0}, 0, 0, 0, 0}, /* 0 kbps ZERO_FRAME*/
+ { FRAME_2_4, FRAME_2_4-2, 1, {1,1}, 1, NB, WB, 0}, /* 2.8kbps VBR(SID)*/
+ { FRAME_7_2, FRAME_7_2-1, 0, {0,1}, 1, NB, WB, 0}, /* 7.2kbps VBR/CBR*/
+ { FRAME_8, FRAME_8-1, 0, {0,1}, 1, NB, WB, 0}, /* 8 kbps VBR/CBR*/
+ { FRAME_9_6, FRAME_9_6-2, 0, {0,1}, 2, NB, SWB, 0}, /* 9.6kbps CBR*/
+ { FRAME_13_2, FRAME_13_2-2, 0, {0,1}, 2, NB, SWB, 0}, /* 13.2kbps CBR*/
+ { FRAME_16_4, FRAME_16_4-3, 0, {0,1}, 2, NB, FB, 1}, /* 16.4kbps CBR*/
+ { FRAME_24_4, FRAME_24_4-3, 0, {0,1}, 2, NB, FB, 1}, /* 24.4kbps CBR*/
+ { FRAME_32, FRAME_32-3, 0, {0,1}, 2, WB, FB, 1}, /* 32 kbps CBR*/
+ { FRAME_48, FRAME_48-3, 0, {0,1}, 2, WB, FB, 1}, /* 48 kbps CBR*/
+ { FRAME_64, FRAME_64-3, 0, {0,1}, 2, WB, FB, 1}, /* 64 kbps CBR*/
+ { FRAME_96, FRAME_96-3, 0, {0,1}, 2, WB, FB, 1}, /* 96 kbps CBR*/
+ { FRAME_128, FRAME_128-3, 0, {0,1}, 2, WB, FB, 1} /*128 kbps CBR*/
+};
+
+
+/*===OUTER LOOP 0===*/
+/*./genari 64 -1 ../histo/histo_s17_LC_rate_2*/
+/*limit_tns:-1.00*/
+/*
+Entropy:
+Entropy full mem.: 2.4198 bit (100.00 %)
+Entropy no mem. : 3.2222 bit (133.16 %)
+Entropy clustered : : 2.4227 bit (100.12 %)
+Perf. clustered and mapped : : 2.4321 bit (100.51 %)
+*/
+/*Total states: 398*/
+/*Proba models: 64*/
+/*Tables size: 1535.8 of 32 bits words*/
+/*Perf. clustered and mapped : : 2.4318 bit (100.50 %)*/
+
+Word8 const ari_lookup_s17_LC[4096] =
+{
+ 0x01,0x04,0x29,0x13,0x0A,0x0D,0x05,0x10,
+ 0x10,0x0D,0x00,0x0D,0x2A,0x2A,0x22,0x25,
+ 0x25,0x28,0x2B,0x2E,0x31,0x34,0x34,0x0E,
+ 0x21,0x21,0x21,0x36,0x38,0x38,0x36,0x10,
+ 0x10,0x08,0x09,0x0B,0x0C,0x0E,0x0E,0x21,
+ 0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x10,
+ 0x10,0x1A,0x09,0x1D,0x0C,0x20,0x20,0x21,
+ 0x36,0x36,0x36,0x36,0x36,0x0A,0x36,0x16,
+ 0x1A,0x1A,0x2D,0x0C,0x20,0x20,0x21,0x21,
+ 0x21,0x36,0x38,0x38,0x38,0x38,0x36,0x16,
+ 0x16,0x1A,0x3F,0x1F,0x20,0x21,0x24,0x06,
+ 0x36,0x36,0x36,0x38,0x00,0x0A,0x36,0x22,
+ 0x3E,0x3E,0x3F,0x30,0x20,0x21,0x06,0x06,
+ 0x06,0x38,0x36,0x36,0x36,0x26,0x36,0x1C,
+ 0x1C,0x3E,0x3F,0x02,0x20,0x21,0x06,0x36,
+ 0x36,0x38,0x0A,0x0A,0x0A,0x0A,0x05,0x16,
+ 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
+ 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
+ 0x16,0x3F,0x3F,0x0E,0x35,0x14,0x38,0x38,
+ 0x05,0x05,0x05,0x0D,0x13,0x13,0x1C,0x16,
+ 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
+ 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
+ 0x3F,0x3F,0x3F,0x20,0x35,0x14,0x27,0x38,
+ 0x38,0x0A,0x2A,0x2A,0x2A,0x16,0x05,0x10,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x3F,0x02,0x0E,0x02,0x14,0x13,0x0A,
+ 0x0D,0x0D,0x0D,0x13,0x00,0x00,0x16,0x19,
+ 0x19,0x3F,0x3F,0x02,0x02,0x14,0x38,0x36,
+ 0x0A,0x0A,0x0A,0x0D,0x0D,0x0D,0x1C,0x22,
+ 0x22,0x3F,0x3F,0x02,0x17,0x26,0x26,0x1C,
+ 0x1C,0x10,0x16,0x16,0x16,0x19,0x22,0x25,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x15,0x2C,0x2E,0x2E,0x2E,0x31,
+ 0x31,0x31,0x31,0x31,0x31,0x31,0x34,0x39,
+ 0x39,0x39,0x15,0x2C,0x2E,0x2E,0x0C,0x34,
+ 0x34,0x34,0x36,0x36,0x36,0x36,0x36,0x36,
+ 0x36,0x39,0x15,0x3C,0x2E,0x31,0x34,0x34,
+ 0x31,0x31,0x31,0x1F,0x1E,0x1E,0x1E,0x1E,
+ 0x1E,0x39,0x28,0x2C,0x2E,0x31,0x37,0x34,
+ 0x01,0x01,0x01,0x01,0x01,0x00,0x39,0x39,
+ 0x39,0x39,0x39,0x2C,0x2E,0x31,0x1E,0x34,
+ 0x34,0x35,0x01,0x01,0x01,0x01,0x01,0x01,
+ 0x01,0x39,0x39,0x3C,0x2E,0x03,0x07,0x34,
+ 0x34,0x0F,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x15,0x2B,0x31,0x1E,0x34,
+ 0x34,0x01,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x2C,0x39,0x2F,0x2E,0x2E,
+ 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
+ 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
+ 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
+ 0x2E,0x39,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
+ 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
+ 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
+ 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
+ 0x1E,0x1E,0x1E,0x1E,0x1E,0x0F,0x2E,0x2E,
+ 0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,0x2E,
+ 0x2E,0x2E,0x39,0x15,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
+ 0x19,0x1C,0x16,0x22,0x22,0x25,0x25,0x25,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3E,0x3E,0x2F,0x3D,0x21,0x36,0x38,0x05,
+ 0x0D,0x0D,0x0D,0x10,0x16,0x16,0x16,0x25,
+ 0x2D,0x2D,0x37,0x3D,0x33,0x38,0x05,0x0D,
+ 0x0D,0x10,0x16,0x16,0x16,0x16,0x16,0x25,
+ 0x2F,0x2F,0x30,0x12,0x06,0x05,0x0A,0x0D,
+ 0x0D,0x10,0x16,0x16,0x16,0x22,0x22,0x25,
+ 0x1F,0x1F,0x32,0x3B,0x29,0x0A,0x0A,0x10,
+ 0x16,0x16,0x16,0x16,0x22,0x22,0x22,0x25,
+ 0x02,0x02,0x14,0x29,0x05,0x0D,0x2A,0x10,
+ 0x16,0x16,0x16,0x22,0x22,0x22,0x22,0x25,
+ 0x35,0x35,0x14,0x29,0x0A,0x2A,0x2A,0x10,
+ 0x16,0x16,0x16,0x22,0x22,0x22,0x22,0x25,
+ 0x17,0x17,0x26,0x05,0x0D,0x10,0x10,0x16,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x25,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,
+ 0x26,0x26,0x26,0x1C,0x0D,0x16,0x16,0x16,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x25,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x26,0x1C,0x1C,0x10,0x16,0x16,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x25,0x25,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x1C,0x1C,0x1C,0x16,0x16,0x16,0x22,
+ 0x22,0x22,0x22,0x25,0x25,0x25,0x25,0x00,
+ 0x00,0x26,0x1C,0x1C,0x16,0x16,0x16,0x22,
+ 0x22,0x22,0x22,0x25,0x25,0x25,0x25,0x00,
+ 0x16,0x16,0x16,0x16,0x16,0x22,0x22,0x22,
+ 0x25,0x25,0x25,0x25,0x25,0x25,0x25,0x00,
+ 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
+ 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
+ 0x15,0x15,0x3C,0x1E,0x0F,0x06,0x27,0x2A,
+ 0x2A,0x10,0x16,0x16,0x16,0x16,0x16,0x22,
+ 0x2C,0x2C,0x0B,0x37,0x23,0x27,0x13,0x2A,
+ 0x10,0x10,0x10,0x16,0x16,0x16,0x16,0x22,
+ 0x1B,0x1B,0x1D,0x0F,0x24,0x13,0x13,0x2A,
+ 0x00,0x10,0x16,0x16,0x16,0x16,0x16,0x22,
+ 0x1F,0x1F,0x03,0x24,0x07,0x0A,0x0A,0x10,
+ 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x22,
+ 0x22,0x35,0x06,0x27,0x13,0x2A,0x2A,0x10,
+ 0x16,0x16,0x16,0x16,0x16,0x22,0x22,0x22,
+ 0x22,0x06,0x27,0x27,0x13,0x2A,0x2A,0x10,
+ 0x16,0x16,0x16,0x16,0x16,0x16,0x22,0x22,
+ 0x22,0x05,0x0A,0x2A,0x2A,0x10,0x10,0x16,
+ 0x16,0x16,0x16,0x16,0x16,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
+ 0x22,0x0D,0x2A,0x10,0x10,0x10,0x10,0x16,
+ 0x16,0x16,0x16,0x16,0x16,0x22,0x22,0x25,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x16,0x16,0x16,
+ 0x16,0x16,0x16,0x22,0x22,0x22,0x22,0x25,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
+ 0x10,0x10,0x10,0x10,0x16,0x16,0x16,0x16,
+ 0x16,0x22,0x22,0x22,0x22,0x22,0x22,0x25,
+ 0x0D,0x0D,0x10,0x10,0x10,0x16,0x16,0x16,
+ 0x16,0x22,0x22,0x22,0x22,0x22,0x22,0x25,
+ 0x0D,0x0D,0x0D,0x0D,0x0D,0x10,0x10,0x16,
+ 0x16,0x16,0x16,0x22,0x22,0x22,0x22,0x25,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x3A,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x11,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x18,
+ 0x00,0x11,0x3A,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x11,0x11,0x11,0x18,0x18,0x18,0x18,
+ 0x18,0x25,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x3A,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x18,0x18,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x18,0x18,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x18,0x18,0x18,0x18,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x11,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x11,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x11,0x11,0x11,0x3A,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x18,0x3A,0x3A,0x11,0x11,0x11,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x11,0x11,0x11,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
+ 0x18,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x11,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x2A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x18,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x11,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x11,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,
+ 0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A,0x3A
+
+};
+
+UWord16 const ari_pk_s17_LC_ext[64][18] =
+{
+ {
+ 16384, 16368,16337,16231,16143,16115,16059,15916,15793,15710,15586,15472,15367,15302,15201,15107,15020,
+ 0
+ },
+ {
+ 16384, 8983, 8540, 8498, 8485, 4319, 3666, 3594, 3579, 2285, 1908, 1851, 1835, 1326, 1120, 1085, 1074,
+ 0
+ },
+ {
+ 16384, 12022,10039, 9520, 9346, 7347, 5335, 4648, 4382, 3815, 3083, 2728, 2562, 2363, 2050, 1869, 1777,
+ 0
+ },
+ {
+ 16384, 13429,11201,10562,10371, 8231, 5713, 4770, 4441, 3798, 2844, 2359, 2152, 1947, 1614, 1406, 1304,
+ 0
+ },
+ {
+ 16384, 13229,11403,10769,10529, 8415, 6431, 5645, 5311, 4448, 3547, 3176, 3001, 2617, 2181, 1984, 1886,
+ 0
+ },
+ {
+ 16384, 15168,13754,13120,12826,11553, 9705, 8723, 8227, 7675, 6762, 6180, 5842, 5585, 5141, 4816, 4607,
+ 0
+ },
+ {
+ 16384, 14625,12743,12034,11772,10059, 7706, 6652, 6223, 5594, 4594, 4023, 3742, 3501, 3089, 2818, 2664,
+ 0
+ },
+ {
+ 16384, 15275,13679,12951,12652,11158, 8852, 7652, 7121, 6406, 5242, 4542, 4196, 3894, 3398, 3063, 2864,
+ 0
+ },
+ {
+ 16384, 4860, 3338, 3214, 3193, 1428, 676, 571, 547, 356, 222, 189, 180, 139, 102, 89, 84,
+ 0
+ },
+ {
+ 16384, 8357, 5798, 5475, 5410, 3093, 1523, 1227, 1152, 849, 560, 470, 441, 370, 294, 261, 248,
+ 0
+ },
+ {
+ 16384, 15550,14350,13710,13387,12297,10541, 9493, 8929, 8354, 7371, 6696, 6299, 6008, 5491, 5107, 4856,
+ 0
+ },
+ {
+ 16384, 10346, 7298, 6933, 6865, 4052, 1863, 1471, 1381, 1055, 673, 536, 491, 429, 339, 293, 273,
+ 0
+ },
+ {
+ 16384, 11652, 8699, 8030, 7839, 5667, 3460, 2766, 2532, 2093, 1542, 1301, 1203, 1070, 893, 802, 759,
+ 0
+ },
+ {
+ 16384, 15639,14601,14037,13729,12847,11421,10520, 9978, 9521, 8720, 8136, 7750, 7493, 7033, 6676, 6426,
+ 0
+ },
+ {
+ 16384, 12427, 9590, 8715, 8386, 6641, 4708, 3886, 3515, 3071, 2490, 2198, 2052, 1886, 1670, 1549, 1478,
+ 0
+ },
+ {
+ 16384, 13605,10996,10363,10183, 7802, 5032, 4124, 3840, 3267, 2403, 1976, 1804, 1633, 1345, 1171, 1086,
+ 0
+ },
+ {
+ 16384, 15936,15224,14759,14464,13808,12678,11866,11331,10910,10150, 9549, 9122, 8853, 8352, 7938, 7626,
+ 0
+ },
+ {
+ 16384, 16383,16382,14829,14138,14137,14136,12895,12272,10935, 9788, 9082, 8674, 8073, 7508, 7118, 6867,
+ 0
+ },
+ {
+ 16384, 13888,11474,10840,10662, 8335, 5585, 4695, 4411, 3801, 2917, 2506, 2337, 2150, 1847, 1672, 1581,
+ 0
+ },
+ {
+ 16384, 15463,14162,13504,13196,11977,10063, 8978, 8429, 7811, 6768, 6088, 5705, 5406, 4882, 4504, 4266,
+ 0
+ },
+ {
+ 16384, 13764,11941,11367,11151, 9312, 7171, 6301, 5943, 5335, 4430, 3942, 3708, 3466, 3074, 2819, 2679,
+ 0
+ },
+ {
+ 16384, 5179, 3300, 3206, 3197, 1220, 374, 303, 293, 171, 81, 63, 59, 44, 29, 24, 22,
+ 0
+ },
+ {
+ 16384, 16026,15468,15096,14842,14329,13447,12790,12322,11985,11367,10860,10477,10248, 9811, 9443, 9148,
+ 0
+ },
+ {
+ 16384, 12809,11291,10848,10649, 8976, 7199, 6506, 6196, 5657, 4887, 4451, 4219, 3974, 3590, 3365, 3218,
+ 0
+ },
+ {
+ 16384, 16383,16382,15744,15348,15347,15346,14714,14288,13688,13097,12652,12328,11967,11584,11278,11045,
+ 0
+ },
+ {
+ 16384, 15415,14987,14866,14806,13751,13046,12818,12709,12187,11720,11527,11427,11096,10759,10601,10510,
+ 0
+ },
+ {
+ 16384, 5926, 4280, 4090, 4053, 2138, 1120, 947, 903, 632, 413, 353, 334, 264, 198, 174, 166,
+ 0
+ },
+ {
+ 16384, 9206, 6640, 6345, 6291, 3683, 1772, 1423, 1342, 1024, 652, 515, 467, 406, 314, 267, 245,
+ 0
+ },
+ {
+ 16384, 15086,13966,13505,13271,12238,10875,10157, 9763, 9331, 8629, 8155, 7845, 7608, 7198, 6892, 6670,
+ 0
+ },
+ {
+ 16384, 11427, 8599, 8132, 8027, 5406, 3012, 2429, 2270, 1823, 1244, 1006, 920, 814, 654, 564, 524,
+ 0
+ },
+ {
+ 16384, 11561, 8220, 7814, 7737, 4780, 2215, 1731, 1621, 1279, 830, 657, 599, 532, 424, 366, 339,
+ 0
+ },
+ {
+ 16384, 11649, 9374, 8867, 8724, 6398, 4154, 3470, 3253, 2718, 2010, 1695, 1570, 1412, 1172, 1042, 980,
+ 0
+ },
+ {
+ 16384, 13021,10503, 9726, 9443, 7520, 5271, 4369, 4016, 3495, 2741, 2365, 2181, 1990, 1719, 1561, 1478,
+ 0
+ },
+ {
+ 16384, 13815,11388,10605,10316, 8467, 6133, 5175, 4782, 4255, 3466, 3063, 2864, 2688, 2408, 2229, 2125,
+ 0
+ },
+ {
+ 16384, 16175,15807,15536,15338,15006,14402,13919,13549,13312,12871,12491,12182,12010,11681,11390,11143,
+ 0
+ },
+ {
+ 16384, 14310,12047,11336,11110, 9065, 6381, 5318, 4938, 4279, 3272, 2732, 2499, 2284, 1920, 1693, 1574,
+ 0
+ },
+ {
+ 16384, 14765,12824,12096,11834,10003, 7429, 6282, 5841, 5145, 4022, 3402, 3123, 2868, 2426, 2150, 2003,
+ 0
+ },
+ {
+ 16384, 16295,16127,15943,15802,15650,15360,15059,14816,14668,14401,14162,13954,13839,13634,13443,13275,
+ 0
+ },
+ {
+ 16384, 14182,12821,12340,12120,10698, 9040, 8284, 7908, 7378, 6549, 6053, 5772, 5520, 5080, 4785, 4597,
+ 0
+ },
+ {
+ 16384, 15164,13583,12892,12600,11161, 8997, 7888, 7386, 6744, 5673, 5015, 4673, 4391, 3898, 3555, 3349,
+ 0
+ },
+ {
+ 16384, 3758, 2571, 2481, 2467, 988, 478, 412, 397, 245, 154, 133, 127, 95, 69, 61, 58,
+ 0
+ },
+ {
+ 16384, 14805,13193,12553,12285,10706, 8596, 7623, 7178, 6542, 5563, 4996, 4703, 4426, 3967, 3662, 3482,
+ 0
+ },
+ {
+ 16384, 15787,14870,14320,14005,13147,11705,10747,10171, 9651, 8735, 8068, 7629, 7332, 6785, 6361, 6061,
+ 0
+ },
+ {
+ 16384, 7111, 4622, 4304, 4233, 2346, 1174, 938, 870, 659, 455, 389, 365, 316, 260, 236, 226,
+ 0
+ },
+ {
+ 16384, 7146, 4703, 4532, 4512, 2078, 740, 583, 556, 371, 201, 153, 141, 118, 87, 72, 66,
+ 0
+ },
+ {
+ 16384, 9593, 7184, 6853, 6790, 4144, 2206, 1832, 1745, 1320, 878, 741, 697, 599, 476, 424, 401,
+ 0
+ },
+ {
+ 16384, 9209, 5969, 5479, 5351, 3346, 1763, 1382, 1261, 1017, 733, 622, 578, 520, 446, 410, 392,
+ 0
+ },
+ {
+ 16384, 11324, 8681, 8252, 8159, 5450, 3114, 2606, 2473, 1987, 1412, 1211, 1142, 1017, 847, 765, 730,
+ 0
+ },
+ {
+ 16384, 12663,10073, 9527, 9392, 6827, 4204, 3489, 3286, 2713, 1966, 1666, 1554, 1400, 1172, 1051, 994,
+ 0
+ },
+ {
+ 16384, 10413, 7096, 6340, 6115, 4393, 2704, 2156, 1947, 1634, 1254, 1091, 1010, 925, 805, 742, 707,
+ 0
+ },
+ {
+ 16384, 13337,11073,10477,10306, 8045, 5534, 4705, 4438, 3804, 2942, 2530, 2360, 2164, 1850, 1668, 1574,
+ 0
+ },
+ {
+ 16384, 14323,12104,11391,11156, 9183, 6649, 5649, 5287, 4676, 3778, 3302, 3089, 2886, 2548, 2341, 2223,
+ 0
+ },
+ {
+ 16384, 11646, 8435, 7504, 7150, 5603, 3882, 3170, 2853, 2487, 2029, 1791, 1666, 1549, 1386, 1288, 1231,
+ 0
+ },
+ {
+ 16384, 13147,11339,10752,10524, 8775, 6682, 5776, 5398, 4813, 3908, 3406, 3154, 2933, 2554, 2310, 2176,
+ 0
+ },
+ {
+ 16384, 14551,12495,11707,11356, 9962, 8005, 7006, 6500, 6034, 5298, 4839, 4575, 4381, 4057, 3825, 3673,
+ 0
+ },
+ {
+ 16384, 12395, 9526, 9032, 8925, 6130, 3448, 2813, 2649, 2144, 1489, 1231, 1142, 1020, 836, 738, 694,
+ 0
+ },
+ {
+ 16384, 14921,13187,12475,12164,10758, 8775, 7752, 7257, 6727, 5864, 5306, 5004, 4777, 4393, 4119, 3942,
+ 0
+ },
+ {
+ 16384, 2151, 1301, 1276, 1274, 315, 84, 70, 68, 32, 14, 11, 10, 7, 4, 3, 2,
+ 0
+ },
+ {
+ 16384, 16383,16382,13774,13091,13090,13089,11287,10713, 7917, 6052, 5265, 4947, 4161, 3534, 3199, 3039,
+ 0
+ },
+ {
+ 16384, 14374,12331,11688,11474, 9505, 6993, 5998, 5634, 4991, 4008, 3498, 3265, 3036, 2658, 2417, 2285,
+ 0
+ },
+ {
+ 16384, 8798, 5867, 5626, 5593, 2841, 1038, 807, 765, 538, 302, 234, 215, 182, 139, 119, 111,
+ 0
+ },
+ {
+ 16384, 13325,10612,10015, 9860, 7343, 4583, 3802, 3571, 3023, 2269, 1945, 1817, 1670, 1440, 1309, 1243,
+ 0
+ },
+ {
+ 16384, 7741, 5790, 5571, 5528, 3110, 1698, 1464, 1409, 1034, 704, 613, 585, 487, 381, 342, 327,
+ 0
+ },
+ {
+ 16384, 9664, 7506, 7059, 6917, 4820, 3136, 2640, 2455, 2000, 1504, 1297, 1217, 1073, 896, 815, 777,
+ 0
+ }
+};
+
+
+const Word16 Tab_esc_nb[4] = { 0 << (NBITS_CONTEXT+NBITS_RATEQ),
+ 1 << (NBITS_CONTEXT+NBITS_RATEQ),
+ 2 << (NBITS_CONTEXT+NBITS_RATEQ),
+ 3 << (NBITS_CONTEXT+NBITS_RATEQ)
+ };
+
+const Word16 qGains[2][1 << kTcxHmNumGainBits] =
+{
+ /* GC */ { 1536 /*0.75f Q11*/ },
+ /* VC */ { 1229 /*0.6f Q11*/, 2867 /*1.4f Q11*/, 9216 /*4.5f Q11*/, 20480 /*10.0f Q11*/ }
+};
+
+const Word16 NumRatioBits[2][17] =
+{
+ /* NB */
+ {
+ 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2
+ , 2, 2, 2
+ },
+
+ /* WB */
+ {
+ 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4
+ , 2, 2, 2
+ }
+};
+
+/* 7Q8 */
+const Word16 Ratios_WB_2[32] =
+ /* 2 */ { 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 15360, 16384, 18432 };
+const Word16 Ratios_WB_3[32] =
+ /* 3 */ { 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 11264, 12288, 13824, 15360, 17408, 19968, 20480 };
+const Word16 Ratios_WB_4[32] =
+ /* 4 */ { 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 9728, 10240, 10752, 11264, 12288, 13312, 13824, 17408 };
+const Word16 Ratios_WB_5[32] =
+ /* 5 */ { 256, 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 7680, 8192, 8704, 9216, 10240, 11264, 12288, 13824 };
+const Word16 Ratios_WB_6[32] =
+ /* 6 */ { 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4608, 5120, 5632, 6144, 6656, 7168, 8704, 10240, 10496 };
+const Word16 Ratios_WB_7[32] =
+ /* 7 */ { 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5760, 6144, 6400, 6912, 7168, 7680, 8960 };
+const Word16 Ratios_WB_8[16] =
+ /* 8 */ { 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1792, 2048, 2304, 2560 };
+const Word16 Ratios_WB_9[16] =
+ /* 9 */ { 256, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3840, 4096, 4608, 6912 };
+const Word16 Ratios_WB_10[16] =
+ /* 10 */ { 256, 384, 512, 640, 768, 896, 1024, 1280, 1536, 2048, 2560, 3840, 4608, 5632, 6144, 6656 };
+const Word16 Ratios_WB_11[16] =
+ /* 11 */ { 256, 384, 512, 640, 768, 896, 1024, 1280, 1536, 2048, 2560, 3072, 3328, 3584, 4608, 5376 };
+const Word16 Ratios_WB_12[16] =
+ /* 12 */ { 128, 256, 384, 512, 640, 768, 1024, 1280, 1536, 2048, 2304, 2816, 3072, 3456, 4096, 5120 };
+const Word16 Ratios_WB_13[16] =
+ /* 13 */ { 128, 256, 384, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2560, 2816, 3072, 3584, 5120 };
+const Word16 Ratios_WB_14[16] =
+ /* 14 */ { 128, 256, 384, 512, 640, 768, 1024, 1152, 1536, 1920, 2304, 2560, 3072, 3584, 3840, 4608 };
+const Word16 Ratios_WB_15[16] =
+ /* 15 */ { 128, 256, 320, 384, 448, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 2048, 2304, 3584 };
+const Word16 Ratios_WB_16[4] =
+ /* 16 */ { 128, 256, 512, 1024 };
+const Word16 Ratios_WB_17[4] =
+ /* 17 */ { 256, 384, 512, 1024 };
+const Word16 Ratios_WB_18[4] =
+ /* 18 */ { 256, 512, 768, 1024 };
+
+/******************************************************************************/
+
+/* 7Q8 */
+const Word16 Ratios_NB_2[32] =
+ /* 2 */ { 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400, 6656, 6912, 7168, 7680, 8192, 8704, 9216, 9728, 10240 };
+const Word16 Ratios_NB_3[16] =
+ /* 3 */ { 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 4096, 5120, 6144, 7680 };
+const Word16 Ratios_NB_4[16] =
+ /* 4 */ { 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 6144, 7680 };
+const Word16 Ratios_NB_5[16] =
+ /* 5 */ { 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120, 6144, 7680 };
+const Word16 Ratios_NB_6[16] =
+ /* 6 */ { 512, 640, 768, 896, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120 };
+const Word16 Ratios_NB_7[16] =
+ /* 7 */ { 256, 512, 640, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 3584, 4096, 4608, 5120 };
+const Word16 Ratios_NB_8[16] =
+ /* 8 */ { 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1792, 2048, 2304, 2560, 3072, 4096 };
+const Word16 Ratios_NB_9[8] =
+ /* 9 */ { 256, 512, 768, 1024, 1280, 1536, 2048, 2560 };
+const Word16 Ratios_NB_10[8] =
+ /* 10 */ { 256, 512, 768, 1024, 1280, 1536, 2048, 2560 };
+const Word16 Ratios_NB_11[8] =
+ /* 11 */ { 256, 384, 512, 768, 1024, 1280, 1536, 2048 };
+const Word16 Ratios_NB_12[8] =
+ /* 12 */ { 256, 512, 640, 768, 1024, 1280, 1536, 2048 };
+const Word16 Ratios_NB_13[4] =
+ /* 13 */ { 256, 512, 768, 1024 };
+const Word16 Ratios_NB_14[4] =
+ /* 14 */ { 256, 512, 1024, 1536 };
+const Word16 Ratios_NB_15[4] =
+ /* 15 */ { 256, 512, 768, 1024 };
+const Word16 Ratios_NB_16[4] =
+ /* 16 */ { 256, 384, 512, 1024 };
+const Word16 Ratios_NB_17[4] =
+ /* 17 */ { 256, 384, 512, 768 };
+const Word16 Ratios_NB_18[4] =
+ /* 18 */ { 128, 256, 512, 768 };
+
+/******************************************************************************/
+
+const Word16 *const Ratios[2][17] =
+{
+ /* NB */
+ {
+ Ratios_NB_2,
+ Ratios_NB_3,
+ Ratios_NB_4,
+ Ratios_NB_5,
+ Ratios_NB_6,
+ Ratios_NB_7,
+ Ratios_NB_8,
+ Ratios_NB_9,
+ Ratios_NB_10,
+ Ratios_NB_11,
+ Ratios_NB_12,
+ Ratios_NB_13,
+ Ratios_NB_14,
+ Ratios_NB_15
+ , Ratios_NB_16
+ , Ratios_NB_17
+ , Ratios_NB_18
+ },
+
+ /* WB */
+ {
+ Ratios_WB_2,
+ Ratios_WB_3,
+ Ratios_WB_4,
+ Ratios_WB_5,
+ Ratios_WB_6,
+ Ratios_WB_7,
+ Ratios_WB_8,
+ Ratios_WB_9,
+ Ratios_WB_10,
+ Ratios_WB_11,
+ Ratios_WB_12,
+ Ratios_WB_13,
+ Ratios_WB_14,
+ Ratios_WB_15
+ , Ratios_WB_16
+ , Ratios_WB_17
+ , Ratios_WB_18
+ }
+};
+
+/*tns_tabels.c*/
+
+struct TnsParameters const tnsParametersIGF32kHz_LowBR[1] =
+{
+ { 600, 3, 237/*1.85f Q7*/, 2458/*0.075f Q15*/ }
+};
+
+struct TnsParameters const tnsParameters32kHz[2] =
+{
+ { 4500, 3, 173/*1.35f Q7*/, 983/*0.0300f Q15*/ },
+ { 600, 1, 224/*1.75f Q7*/, 2048/*0.0625f Q15*/ }
+};
+
+struct TnsParameters const tnsParameters32kHz_grouped[2] =
+{
+ { 8400, 3, 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ },
+ { 800, 3, 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ }
+};
+
+
+/* Tuning for Wide Band 16kHz */
+struct TnsParameters const tnsParameters16kHz[1] =
+{
+ { 600, 3, 192/*1.5f Q7*/, 1638/*0.05f Q15*/ }
+};
+
+struct TnsParameters const tnsParameters16kHz_grouped[2] =
+{
+ { 4400, 3, 192/*1.5f Q7*/, 1638/*0.05f Q15*/ },
+ { 800, 3, 192/*1.5f Q7*/, 1638/*0.05f Q15*/ }
+};
+
+struct TnsParameters const tnsParameters48kHz_grouped[2] =
+{
+ { 10400, 3, 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ },
+ { 800, 3, 176/*1.375f Q7*/, 1024/*0.03125f Q15*/ }
+};
+
+const Word16 tnsAcfWindow[TNS_MAX_FILTER_ORDER] =
+{
+ 32696/*0.997803f Q15*/, 32480/*0.991211f Q15*/, 32120/*0.980225f Q15*/, 31616/*0.964844f Q15*/, 30968/*0.945068f Q15*/, 30176/*0.920898f Q15*/, 29240/*0.892334f Q15*/, 28160/*0.859375f Q15*/
+};
+
+/**********************************************************************/
+/* Definition of the mapping between TNS parameters and a bitstream */
+/**********************************************************************/
+
+/* Helper structures for hufmann table coding */
+const Coding codesTnsCoeff0TCX20[] =
+{
+ { -8+INDEX_SHIFT, 609, 11 }, /* 01001100001 */
+ { -7+INDEX_SHIFT, 305, 10 }, /* 0100110001 */
+ { -6+INDEX_SHIFT, 77, 8 }, /* 01001101 */
+ { -5+INDEX_SHIFT, 39, 7 }, /* 0100111 */
+ { -4+INDEX_SHIFT, 8, 5 }, /* 01000 */
+ { -3+INDEX_SHIFT, 21, 5 }, /* 10101 */
+ { -2+INDEX_SHIFT, 11, 4 }, /* 1011 */
+ { -1+INDEX_SHIFT, 3, 3 }, /* 011 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 0, 2 }, /* 00 */
+ { 2+INDEX_SHIFT, 4, 3 }, /* 100 */
+ { 3+INDEX_SHIFT, 5, 4 }, /* 0101 */
+ { 4+INDEX_SHIFT, 20, 5 }, /* 10100 */
+ { 5+INDEX_SHIFT, 18, 6 }, /* 010010 */
+ { 6+INDEX_SHIFT, 153, 9 }, /* 010011001 */
+ { 7+INDEX_SHIFT, 608, 11 } /* 01001100000 */
+};
+
+const Coding codesTnsCoeff0TCX10[] =
+{
+ { -8+INDEX_SHIFT, 441, 9 }, /* 110111001 */
+ { -7+INDEX_SHIFT, 111, 7 }, /* 1101111 */
+ { -6+INDEX_SHIFT, 8, 4 }, /* 1000 */
+ { -5+INDEX_SHIFT, 9, 4 }, /* 1001 */
+ { -4+INDEX_SHIFT, 14, 4 }, /* 1110 */
+ { -3+INDEX_SHIFT, 15, 4 }, /* 1111 */
+ { -2+INDEX_SHIFT, 3, 3 }, /* 011 */
+ { -1+INDEX_SHIFT, 5, 3 }, /* 101 */
+ { 0+INDEX_SHIFT, 0, 2 }, /* 00 */
+ { 1+INDEX_SHIFT, 2, 3 }, /* 010 */
+ { 2+INDEX_SHIFT, 12, 4 }, /* 1100 */
+ { 3+INDEX_SHIFT, 26, 5 }, /* 11010 */
+ { 4+INDEX_SHIFT, 54, 6 }, /* 110110 */
+ { 5+INDEX_SHIFT, 221, 8 }, /* 11011101 */
+ { 6+INDEX_SHIFT, 881, 10 }, /* 1101110001 */
+ { 7+INDEX_SHIFT, 880, 10 } /* 1101110000 */
+};
+
+const Coding codesTnsCoeff1TCX20[] =
+{
+ { -8+INDEX_SHIFT, 30018, 15 }, /* 111010101000010 */
+ { -7+INDEX_SHIFT, 30019, 15 }, /* 111010101000011 */
+ { -6+INDEX_SHIFT, 7505, 13 }, /* 1110101010001 */
+ { -5+INDEX_SHIFT, 3753, 12 }, /* 111010101001 */
+ { -4+INDEX_SHIFT, 939, 10 }, /* 1110101011 */
+ { -3+INDEX_SHIFT, 235, 8 }, /* 11101011 */
+ { -2+INDEX_SHIFT, 28, 5 }, /* 11100 */
+ { -1+INDEX_SHIFT, 6, 3 }, /* 110 */
+ { 0+INDEX_SHIFT, 0, 1 }, /* 0 */
+ { 1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 2+INDEX_SHIFT, 15, 4 }, /* 1111 */
+ { 3+INDEX_SHIFT, 59, 6 }, /* 111011 */
+ { 4+INDEX_SHIFT, 116, 7 }, /* 1110100 */
+ { 5+INDEX_SHIFT, 468, 9 }, /* 111010100 */
+ { 6+INDEX_SHIFT, 1877, 11 }, /* 11101010101 */
+ { 7+INDEX_SHIFT, 15008, 14 } /* 11101010100000 */
+};
+
+const Coding codesTnsCoeff1TCX10[] =
+{
+ { -8+INDEX_SHIFT, 2818, 12 }, /* 101100000010 */
+ { -7+INDEX_SHIFT, 2819, 12 }, /* 101100000011 */
+ { -6+INDEX_SHIFT, 705, 10 }, /* 1011000001 */
+ { -5+INDEX_SHIFT, 353, 9 }, /* 101100001 */
+ { -4+INDEX_SHIFT, 177, 8 }, /* 10110001 */
+ { -3+INDEX_SHIFT, 45, 6 }, /* 101101 */
+ { -2+INDEX_SHIFT, 10, 4 }, /* 1010 */
+ { -1+INDEX_SHIFT, 3, 3 }, /* 011 */
+ { 0+INDEX_SHIFT, 6, 3 }, /* 110 */
+ { 1+INDEX_SHIFT, 0, 2 }, /* 00 */
+ { 2+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 3+INDEX_SHIFT, 4, 3 }, /* 100 */
+ { 4+INDEX_SHIFT, 2, 3 }, /* 010 */
+ { 5+INDEX_SHIFT, 23, 5 }, /* 10111 */
+ { 6+INDEX_SHIFT, 89, 7 }, /* 1011001 */
+ { 7+INDEX_SHIFT, 1408, 11 } /* 10110000000 */
+};
+
+const Coding codesTnsCoeff2TCX20[] =
+{
+ { -8+INDEX_SHIFT, 13312, 14 }, /* 11010000000000 */
+ { -7+INDEX_SHIFT, 13313, 14 }, /* 11010000000001 */
+ { -6+INDEX_SHIFT, 3329, 12 }, /* 110100000001 */
+ { -5+INDEX_SHIFT, 833, 10 }, /* 1101000001 */
+ { -4+INDEX_SHIFT, 209, 8 }, /* 11010001 */
+ { -3+INDEX_SHIFT, 53, 6 }, /* 110101 */
+ { -2+INDEX_SHIFT, 12, 4 }, /* 1100 */
+ { -1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 0+INDEX_SHIFT, 0, 1 }, /* 0 */
+ { 1+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 2+INDEX_SHIFT, 27, 5 }, /* 11011 */
+ { 3+INDEX_SHIFT, 105, 7 }, /* 1101001 */
+ { 4+INDEX_SHIFT, 417, 9 }, /* 110100001 */
+ { 5+INDEX_SHIFT, 1665, 11 }, /* 11010000001 */
+ { 6+INDEX_SHIFT, 13314, 14 }, /* 11010000000010 */
+ { 7+INDEX_SHIFT, 13315, 14 } /* 11010000000011 */
+};
+
+const Coding codesTnsCoeff2TCX10[] =
+{
+ { -8+INDEX_SHIFT, 512, 12 }, /* 001000000000 */
+ { -7+INDEX_SHIFT, 513, 12 }, /* 001000000001 */
+ { -6+INDEX_SHIFT, 65, 9 }, /* 001000001 */
+ { -5+INDEX_SHIFT, 17, 7 }, /* 0010001 */
+ { -4+INDEX_SHIFT, 5, 5 }, /* 00101 */
+ { -3+INDEX_SHIFT, 0, 3 }, /* 000 */
+ { -2+INDEX_SHIFT, 6, 3 }, /* 110 */
+ { -1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 0+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 1+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 2+INDEX_SHIFT, 3, 4 }, /* 0011 */
+ { 3+INDEX_SHIFT, 9, 6 }, /* 001001 */
+ { 4+INDEX_SHIFT, 33, 8 }, /* 00100001 */
+ { 5+INDEX_SHIFT, 129, 10 }, /* 0010000001 */
+ { 6+INDEX_SHIFT, 514, 12 }, /* 001000000010 */
+ { 7+INDEX_SHIFT, 515, 12 } /* 001000000011 */
+};
+
+const Coding codesTnsCoeff3TCX20[] =
+{
+ { -8+INDEX_SHIFT, 13318, 14 }, /* 11010000000110 */
+ { -7+INDEX_SHIFT, 13319, 14 }, /* 11010000000111 */
+ { -6+INDEX_SHIFT, 6656, 13 }, /* 1101000000000 */
+ { -5+INDEX_SHIFT, 1665, 11 }, /* 11010000001 */
+ { -4+INDEX_SHIFT, 417, 9 }, /* 110100001 */
+ { -3+INDEX_SHIFT, 105, 7 }, /* 1101001 */
+ { -2+INDEX_SHIFT, 27, 5 }, /* 11011 */
+ { -1+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 0+INDEX_SHIFT, 0, 1 }, /* 0 */
+ { 1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 2+INDEX_SHIFT, 12, 4 }, /* 1100 */
+ { 3+INDEX_SHIFT, 53, 6 }, /* 110101 */
+ { 4+INDEX_SHIFT, 209, 8 }, /* 11010001 */
+ { 5+INDEX_SHIFT, 833, 10 }, /* 1101000001 */
+ { 6+INDEX_SHIFT, 6657, 13 }, /* 1101000000001 */
+ { 7+INDEX_SHIFT, 6658, 13 } /* 1101000000010 */
+};
+
+const Coding codesTnsCoeff3TCX10[] =
+{
+ { -8+INDEX_SHIFT, 1284, 12 }, /* 010100000100 */
+ { -7+INDEX_SHIFT, 1285, 12 }, /* 010100000101 */
+ { -6+INDEX_SHIFT, 1286, 12 }, /* 010100000110 */
+ { -5+INDEX_SHIFT, 1287, 12 }, /* 010100000111 */
+ { -4+INDEX_SHIFT, 161, 9 }, /* 010100001 */
+ { -3+INDEX_SHIFT, 41, 7 }, /* 0101001 */
+ { -2+INDEX_SHIFT, 11, 5 }, /* 01011 */
+ { -1+INDEX_SHIFT, 0, 2 }, /* 00 */
+ { 0+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 1+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 2+INDEX_SHIFT, 3, 3 }, /* 011 */
+ { 3+INDEX_SHIFT, 4, 4 }, /* 0100 */
+ { 4+INDEX_SHIFT, 21, 6 }, /* 010101 */
+ { 5+INDEX_SHIFT, 81, 8 }, /* 01010001 */
+ { 6+INDEX_SHIFT, 640, 11 }, /* 01010000000 */
+ { 7+INDEX_SHIFT, 641, 11 } /* 01010000001 */
+};
+
+const Coding codesTnsCoeff4TCX20[] =
+{
+ { -8+INDEX_SHIFT, 13318, 14 }, /* 11010000000110 */
+ { -7+INDEX_SHIFT, 13319, 14 }, /* 11010000000111 */
+ { -6+INDEX_SHIFT, 6656, 13 }, /* 1101000000000 */
+ { -5+INDEX_SHIFT, 833, 10 }, /* 1101000001 */
+ { -4+INDEX_SHIFT, 209, 8 }, /* 11010001 */
+ { -3+INDEX_SHIFT, 53, 6 }, /* 110101 */
+ { -2+INDEX_SHIFT, 12, 4 }, /* 1100 */
+ { -1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 0+INDEX_SHIFT, 0, 1 }, /* 0 */
+ { 1+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 2+INDEX_SHIFT, 27, 5 }, /* 11011 */
+ { 3+INDEX_SHIFT, 105, 7 }, /* 1101001 */
+ { 4+INDEX_SHIFT, 417, 9 }, /* 110100001 */
+ { 5+INDEX_SHIFT, 1665, 11 }, /* 11010000001 */
+ { 6+INDEX_SHIFT, 6657, 13 }, /* 1101000000001 */
+ { 7+INDEX_SHIFT, 6658, 13 } /* 1101000000010 */
+};
+
+const Coding codesTnsCoeff4TCX10[] =
+{
+ { -8+INDEX_SHIFT, 20, 12 }, /* 000000010100 */
+ { -7+INDEX_SHIFT, 21, 12 }, /* 000000010101 */
+ { -6+INDEX_SHIFT, 22, 12 }, /* 000000010110 */
+ { -5+INDEX_SHIFT, 3, 9 }, /* 000000011 */
+ { -4+INDEX_SHIFT, 1, 7 }, /* 0000001 */
+ { -3+INDEX_SHIFT, 1, 5 }, /* 00001 */
+ { -2+INDEX_SHIFT, 1, 3 }, /* 001 */
+ { -1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 2+INDEX_SHIFT, 1, 4 }, /* 0001 */
+ { 3+INDEX_SHIFT, 1, 6 }, /* 000001 */
+ { 4+INDEX_SHIFT, 0, 8 }, /* 00000000 */
+ { 5+INDEX_SHIFT, 23, 12 }, /* 000000010111 */
+ { 6+INDEX_SHIFT, 8, 11 }, /* 00000001000 */
+ { 7+INDEX_SHIFT, 9, 11 } /* 00000001001 */
+};
+
+const Coding codesTnsCoeff5[] =
+{
+ { -8+INDEX_SHIFT, 6788, 13 }, /* 1101010000100 */
+ { -7+INDEX_SHIFT, 6789, 13 }, /* 1101010000101 */
+ { -6+INDEX_SHIFT, 6790, 13 }, /* 1101010000110 */
+ { -5+INDEX_SHIFT, 849, 10 }, /* 1101010001 */
+ { -4+INDEX_SHIFT, 213, 8 }, /* 11010101 */
+ { -3+INDEX_SHIFT, 107, 7 }, /* 1101011 */
+ { -2+INDEX_SHIFT, 27, 5 }, /* 11011 */
+ { -1+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 0+INDEX_SHIFT, 0, 1 }, /* 0 */
+ { 1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 2+INDEX_SHIFT, 12, 4 }, /* 1100 */
+ { 3+INDEX_SHIFT, 52, 6 }, /* 110100 */
+ { 4+INDEX_SHIFT, 425, 9 }, /* 110101001 */
+ { 5+INDEX_SHIFT, 6791, 13 }, /* 1101010000111 */
+ { 6+INDEX_SHIFT, 3392, 12 }, /* 110101000000 */
+ { 7+INDEX_SHIFT, 3393, 12 } /* 110101000001 */
+};
+
+const Coding codesTnsCoeff6[] =
+{
+ { -8+INDEX_SHIFT, 4, 12 }, /* 000000000100 */
+ { -7+INDEX_SHIFT, 5, 12 }, /* 000000000101 */
+ { -6+INDEX_SHIFT, 6, 12 }, /* 000000000110 */
+ { -5+INDEX_SHIFT, 1, 9 }, /* 000000001 */
+ { -4+INDEX_SHIFT, 1, 7 }, /* 0000001 */
+ { -3+INDEX_SHIFT, 1, 5 }, /* 00001 */
+ { -2+INDEX_SHIFT, 1, 3 }, /* 001 */
+ { -1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 2+INDEX_SHIFT, 1, 4 }, /* 0001 */
+ { 3+INDEX_SHIFT, 1, 6 }, /* 000001 */
+ { 4+INDEX_SHIFT, 1, 8 }, /* 00000001 */
+ { 5+INDEX_SHIFT, 7, 12 }, /* 000000000111 */
+ { 6+INDEX_SHIFT, 0, 11 }, /* 00000000000 */
+ { 7+INDEX_SHIFT, 1, 11 } /* 00000000001 */
+};
+
+const Coding codesTnsCoeff7[] =
+{
+ { -8+INDEX_SHIFT, 14, 11 }, /* 00000001110 */
+ { -7+INDEX_SHIFT, 15, 11 }, /* 00000001111 */
+ { -6+INDEX_SHIFT, 0, 10 }, /* 0000000000 */
+ { -5+INDEX_SHIFT, 1, 10 }, /* 0000000001 */
+ { -4+INDEX_SHIFT, 1, 7 }, /* 0000001 */
+ { -3+INDEX_SHIFT, 1, 5 }, /* 00001 */
+ { -2+INDEX_SHIFT, 1, 4 }, /* 0001 */
+ { -1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 0+INDEX_SHIFT, 2, 10 }, /* 0000000010 */
+ { 1+INDEX_SHIFT, 1, 1 }, /* 1 */
+ { 2+INDEX_SHIFT, 1, 3 }, /* 001 */
+ { 3+INDEX_SHIFT, 1, 6 }, /* 000001 */
+ { 4+INDEX_SHIFT, 3, 10 }, /* 0000000011 */
+ { 5+INDEX_SHIFT, 4, 10 }, /* 0000000100 */
+ { 6+INDEX_SHIFT, 5, 10 }, /* 0000000101 */
+ { 7+INDEX_SHIFT, 6, 10 } /* 0000000110 */
+};
+
+const Coding codesTnsCoeff456[] =
+{
+ { -8+INDEX_SHIFT, 516, 12 }, /* 001000000100 */
+ { -7+INDEX_SHIFT, 517, 12 }, /* 001000000101 */
+ { -6+INDEX_SHIFT, 518, 12 }, /* 001000000110 */
+ { -5+INDEX_SHIFT, 65, 9 }, /* 001000001 */
+ { -4+INDEX_SHIFT, 17, 7 }, /* 0010001 */
+ { -3+INDEX_SHIFT, 5, 5 }, /* 00101 */
+ { -2+INDEX_SHIFT, 3, 4 }, /* 0011 */
+ { -1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 2+INDEX_SHIFT, 0, 3 }, /* 000 */
+ { 3+INDEX_SHIFT, 9, 6 }, /* 001001 */
+ { 4+INDEX_SHIFT, 33, 8 }, /* 00100001 */
+ { 5+INDEX_SHIFT, 519, 12 }, /* 001000000111 */
+ { 6+INDEX_SHIFT, 256, 11 }, /* 00100000000 */
+ { 7+INDEX_SHIFT, 257, 11 } /* 00100000001 */
+};
+
+const Coding codesTnsCoeff0WBTCX20[] =
+{
+ { -8+INDEX_SHIFT, 225, 10 }, /* 0011100001 */
+ { -7+INDEX_SHIFT, 113, 9 }, /* 001110001 */
+ { -6+INDEX_SHIFT, 29, 7 }, /* 0011101 */
+ { -5+INDEX_SHIFT, 15, 6 }, /* 001111 */
+ { -4+INDEX_SHIFT, 2, 4 }, /* 0010 */
+ { -3+INDEX_SHIFT, 0, 3 }, /* 000 */
+ { -2+INDEX_SHIFT, 13, 4 }, /* 1101 */
+ { -1+INDEX_SHIFT, 2, 3 }, /* 010 */
+ { 0+INDEX_SHIFT, 5, 3 }, /* 101 */
+ { 1+INDEX_SHIFT, 3, 3 }, /* 011 */
+ { 2+INDEX_SHIFT, 4, 3 }, /* 100 */
+ { 3+INDEX_SHIFT, 7, 3 }, /* 111 */
+ { 4+INDEX_SHIFT, 12, 4 }, /* 1100 */
+ { 5+INDEX_SHIFT, 6, 5 }, /* 00110 */
+ { 6+INDEX_SHIFT, 57, 8 }, /* 00111001 */
+ { 7+INDEX_SHIFT, 224, 10 } /* 0011100000 */
+};
+
+const Coding codesTnsCoeff1WBTCX20[] =
+{
+ { -8+INDEX_SHIFT, 512, 12 }, /* 001000000000 */
+ { -7+INDEX_SHIFT, 513, 12 }, /* 001000000001 */
+ { -6+INDEX_SHIFT, 514, 12 }, /* 001000000010 */
+ { -5+INDEX_SHIFT, 65, 9 }, /* 001000001 */
+ { -4+INDEX_SHIFT, 17, 7 }, /* 0010001 */
+ { -3+INDEX_SHIFT, 5, 5 }, /* 00101 */
+ { -2+INDEX_SHIFT, 0, 3 }, /* 000 */
+ { -1+INDEX_SHIFT, 2, 3 }, /* 010 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 2, 2 }, /* 10 */
+ { 2+INDEX_SHIFT, 3, 3 }, /* 011 */
+ { 3+INDEX_SHIFT, 3, 4 }, /* 0011 */
+ { 4+INDEX_SHIFT, 9, 6 }, /* 001001 */
+ { 5+INDEX_SHIFT, 33, 8 }, /* 00100001 */
+ { 6+INDEX_SHIFT, 129, 10 }, /* 0010000001 */
+ { 7+INDEX_SHIFT, 515, 12 } /* 001000000011 */
+};
+
+const Coding codesTnsCoeff2WB[] =
+{
+ { -8+INDEX_SHIFT, 5632, 13 }, /* 1011000000000 */
+ { -7+INDEX_SHIFT, 5633, 13 }, /* 1011000000001 */
+ { -6+INDEX_SHIFT, 1409, 11 }, /* 10110000001 */
+ { -5+INDEX_SHIFT, 353, 9 }, /* 101100001 */
+ { -4+INDEX_SHIFT, 89, 7 }, /* 1011001 */
+ { -3+INDEX_SHIFT, 23, 5 }, /* 10111 */
+ { -2+INDEX_SHIFT, 4, 3 }, /* 100 */
+ { -1+INDEX_SHIFT, 0, 2 }, /* 00 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 2+INDEX_SHIFT, 10, 4 }, /* 1010 */
+ { 3+INDEX_SHIFT, 45, 6 }, /* 101101 */
+ { 4+INDEX_SHIFT, 177, 8 }, /* 10110001 */
+ { 5+INDEX_SHIFT, 705, 10 }, /* 1011000001 */
+ { 6+INDEX_SHIFT, 5634, 13 }, /* 1011000000010 */
+ { 7+INDEX_SHIFT, 5635, 13 } /* 1011000000011 */
+};
+
+const Coding codesTnsCoeff3WB[] =
+{
+ { -8+INDEX_SHIFT, 5638, 13 }, /* 1011000000110 */
+ { -7+INDEX_SHIFT, 5639, 13 }, /* 1011000000111 */
+ { -6+INDEX_SHIFT, 2816, 12 }, /* 101100000000 */
+ { -5+INDEX_SHIFT, 353, 9 }, /* 101100001 */
+ { -4+INDEX_SHIFT, 177, 8 }, /* 10110001 */
+ { -3+INDEX_SHIFT, 45, 6 }, /* 101101 */
+ { -2+INDEX_SHIFT, 10, 4 }, /* 1010 */
+ { -1+INDEX_SHIFT, 0, 2 }, /* 00 */
+ { 0+INDEX_SHIFT, 3, 2 }, /* 11 */
+ { 1+INDEX_SHIFT, 1, 2 }, /* 01 */
+ { 2+INDEX_SHIFT, 4, 3 }, /* 100 */
+ { 3+INDEX_SHIFT, 23, 5 }, /* 10111 */
+ { 4+INDEX_SHIFT, 89, 7 }, /* 1011001 */
+ { 5+INDEX_SHIFT, 705, 10 }, /* 1011000001 */
+ { 6+INDEX_SHIFT, 2817, 12 }, /* 101100000001 */
+ { 7+INDEX_SHIFT, 2818, 12 } /* 101100000010 */
+};
+
+Word16 const nTnsCoeffCodes = sizeof(codesTnsCoeff0TCX20)/sizeof(codesTnsCoeff0TCX20[0]);
+
+const Coding * codesTnsCoeffSWBTCX20[] = { codesTnsCoeff0TCX20, codesTnsCoeff1TCX20, codesTnsCoeff2TCX20, codesTnsCoeff3TCX20, codesTnsCoeff4TCX20, codesTnsCoeff5, codesTnsCoeff6, codesTnsCoeff7 };
+const Coding * codesTnsCoeffSWBTCX10[] = { codesTnsCoeff0TCX10, codesTnsCoeff1TCX10, codesTnsCoeff2TCX10, codesTnsCoeff3TCX10, codesTnsCoeff4TCX10, codesTnsCoeff5, codesTnsCoeff6, codesTnsCoeff7 };
+const Coding * codesTnsCoeffWBTCX20[] = { codesTnsCoeff0WBTCX20, codesTnsCoeff1WBTCX20, codesTnsCoeff2WB, codesTnsCoeff3WB, codesTnsCoeff456, codesTnsCoeff456, codesTnsCoeff456, codesTnsCoeff7 };
+
+Word16 const nTnsCoeffTables = sizeof(codesTnsCoeffSWBTCX20)/sizeof(codesTnsCoeffSWBTCX20[0]);
+
+const Coding codesTnsOrderTCX20[] =
+{
+ { 1, 0, 2 }, /* 00 */
+ { 2, 40, 6 }, /* 101000 */
+ { 3, 41, 6 }, /* 101001 */
+ { 4, 21, 5 }, /* 10101 */
+ { 5, 11, 4 }, /* 1011 */
+ { 6, 4, 3 }, /* 100 */
+ { 7, 1, 2 }, /* 01 */
+ { 8, 3, 2 } /* 11 */
+};
+
+const Coding codesTnsOrderTCX10[] =
+{
+ { 1, 0, 3 }, /* 000 */
+ { 2, 16, 5 }, /* 10000 */
+ { 3, 17, 5 }, /* 10001 */
+ { 4, 9, 4 }, /* 1001 */
+ { 5, 1, 3 }, /* 001 */
+ { 6, 5, 3 }, /* 101 */
+ { 7, 1, 2 }, /* 01 */
+ { 8, 3, 2 } /* 11 */
+};
+
+const Coding codesTnsOrder[] =
+{
+ { 1, 96, 7 }, /* 1100000 */
+ { 2, 97, 7 }, /* 1100001 */
+ { 3, 49, 6 }, /* 110001 */
+ { 4, 25, 5 }, /* 11001 */
+ { 5, 13, 4 }, /* 1101 */
+ { 6, 7, 3 }, /* 111 */
+ { 7, 2, 2 }, /* 10 */
+ { 8, 0, 1 } /* 0 */
+};
+
+Word16 const nTnsOrderCodes = sizeof(codesTnsOrder)/sizeof(codesTnsOrder[0]);
+
+ParamsBitMap const tnsSWBTCX20FilterCoeffBitMap[1] =
+{
+ {
+ 1,
+ {
+ { 0, GetSWBTCX20TnsFilterCoeffBits, TRUE, GetTnsFilterCoeff, SetTnsFilterCoeff, EncodeSWBTCX20TnsFilterCoeff, DecodeSWBTCX20TnsFilterCoeff, NULL } /* TNS filter coefficients */
+ }
+ }
+};
+
+ParamsBitMap const tnsSWBTCX10FilterCoeffBitMap[1] =
+{
+ {
+ 1,
+ {
+ { 0, GetSWBTCX10TnsFilterCoeffBits, TRUE, GetTnsFilterCoeff, SetTnsFilterCoeff, EncodeSWBTCX10TnsFilterCoeff, DecodeSWBTCX10TnsFilterCoeff, NULL } /* TNS filter coefficients */
+ }
+ }
+};
+
+ParamsBitMap tnsSWBTCX20FilterBitMap[1] =
+{
+ {
+ 1,
+ {
+ { 0, GetTnsFilterOrderBitsSWBTCX20, FALSE, GetTnsFilterOrder, SetTnsFilterOrder, EncodeTnsFilterOrderSWBTCX20, DecodeTnsFilterOrderSWBTCX20, tnsSWBTCX20FilterCoeffBitMap } /* TNS filter order */
+ }
+ }
+};
+
+ParamsBitMap tnsSWBTCX10FilterBitMap[1] =
+{
+ {
+ 1,
+ {
+ { 0, GetTnsFilterOrderBitsSWBTCX10, FALSE, GetTnsFilterOrder, SetTnsFilterOrder, EncodeTnsFilterOrderSWBTCX10, DecodeTnsFilterOrderSWBTCX10, tnsSWBTCX10FilterCoeffBitMap } /* TNS filter order */
+ }
+ }
+};
+
+ParamsBitMap const tnsSWBTCX20BitMap[1] =
+{
+ {
+ 1,
+ {
+ { 1, NULL, FALSE, GetNumOfTnsFilters, SetNumOfTnsFilters, NULL, NULL, tnsSWBTCX20FilterBitMap } /* Number of TNS filters */
+ }
+ }
+};
+
+/* For storing/reading bits in SWB/FB mode */
+ParamsBitMap const tnsEnabledSWBTCX20BitMap[1] =
+{
+ {
+ 1,
+ {
+ { 1, NULL, TRUE, GetTnsEnabled, SetTnsEnabled, NULL, NULL, tnsSWBTCX20BitMap } /* TNS Enabled/Disable */
+ }
+ }
+};
+
+ParamsBitMap const tnsSWBTCX10BitMap[1] =
+{
+ {
+ 1,
+ {
+ { 1, NULL, FALSE, GetNumOfTnsFilters, SetNumOfTnsFilters, NULL, NULL, tnsSWBTCX10FilterBitMap } /* Number of TNS filters */
+ }
+ }
+};
+
+/* For storing/reading bits in SWB/FB mode */
+ParamsBitMap const tnsEnabledSWBTCX10BitMap[1] =
+{
+ {
+ 1,
+ {
+ { 1, NULL, TRUE, GetTnsEnabled, SetTnsEnabled, NULL, NULL, tnsSWBTCX10BitMap } /* TNS Enabled/Disable */
+ }
+ }
+};
+
+ParamsBitMap const tnsWBTCX20FilterCoeffBitMap[1] =
+{
+ {
+ 1,
+ {
+ { 0, GetWBTCX20TnsFilterCoeffBits, TRUE, GetTnsFilterCoeff, SetTnsFilterCoeff, EncodeWBTCX20TnsFilterCoeff, DecodeWBTCX20TnsFilterCoeff, NULL } /* TNS filter coefficients */
+ }
+ }
+};
+
+ParamsBitMap const tnsWBTCX20FilterBitMap[1] =
+{
+ {
+ 1,
+ {
+ { 0, GetTnsFilterOrderBits, FALSE, GetTnsFilterOrder, SetTnsFilterOrder, EncodeTnsFilterOrder, DecodeTnsFilterOrder, tnsWBTCX20FilterCoeffBitMap } /* TNS filter order */
+ }
+ }
+};
+
+
+/* For storing/reading bits in WB mode */
+ParamsBitMap const tnsEnabledWBTCX20BitMap[1] =
+{
+ {
+ 1,
+ {
+ { 1, NULL, TRUE, GetTnsEnabledSingleFilter, SetTnsEnabledSingleFilter, NULL, NULL, tnsWBTCX20FilterBitMap } /* TNS Enabled/Disable */
+ }
+ }
+};
+
+
+/**
+ * 4 bit resolution TNS coefficients.
+ */
+const Word16 tnsCoeff4[16]=
+{
+ -32628/*-0.99573418F Q15*/, /* = sin(-8*(PI/2.0)/(8 + 0.5)) */
+ -31517/*-0.96182564F Q15*/, /* = sin(-7*(PI/2.0)/(8 + 0.5)) */
+ -29333/*-0.89516329F Q15*/,
+ -26149/*-0.79801723F Q15*/,
+ -22076/*-0.67369564F Q15*/,
+ -17250/*-0.52643216F Q15*/,
+ -11837/*-0.36124167F Q15*/,
+ -6021/*-0.18374952F Q15*/, /* = sin(-1*(PI/2.0)/(8 + 0.5)) */
+ 0/* 0.00000000F Q15*/, /* = sin(0*(PI/2.0)/(8 + 0.5)) */
+ 6813/* 0.20791169F Q15*/, /* = sin(1*(PI/2.0)/(8 - 0.5)) */
+ 13328/* 0.40673664F Q15*/,
+ 19261/* 0.58778525F Q15*/,
+ 24351/* 0.74314483F Q15*/,
+ 28378/* 0.86602540F Q15*/,
+ 31164/* 0.95105652F Q15*/, /* = sin(6*(PI/2.0)/(8 - 0.5)) */
+ 32588/* 0.99452190F Q15*/ /* = sin(7*(PI/2.0)/(8 - 0.5)) */
+};
+
+/*bits_alloc_tables.c*/
+
+
+/*NRG MODE*/
+/* NRG mode */
+const Word16 ACELP_NRG_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] =
+{
+ {{0,0,1,1,0,0,0,0},{2,2,1,1,0,0,0,0}},
+ {{1,1,1,1,0,0,0,0},{1,1,1,1,1,1,1,0}},
+};
+
+/* NRG bits : (0/2/3 bits) */
+const Word16 ACELP_NRG_BITS[3] =
+{
+ 0,
+ 3,
+ 4
+};
+
+/*LTP MODE*/
+const Word16 ACELP_LTP_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] =
+{
+ {{0,0,1,2,0,0,0,0},{0,0,1,2,0,0,0,0}},
+ {{4,4,3,4,0,0,0,0},{4,4,3,4,8,0,9,0}},
+};
+
+/*LTP BITS*/
+const Word16 ACELP_LTP_BITS_SFR[8+RF_MODE_MAX][5] =
+{
+ {0,0,0,0,0},
+ {8,4,4,4,4},
+ {8,5,8,5,5},
+ {9,6,6,6,6},
+ {9,6,9,6,6},
+ {8,5,5,5,5},
+ {8,5,8,5,5},
+ {8,0,0,0,0},
+ {8,5,5,5,5}, /* All-pred mode in RF, rf_frame_type = 0 */
+ {8,4,4,4,0}, /* Gen-pred mode in RF, rf_frame_type = 2 */
+};
+
+
+/*LTF MODE: 0 no filtering, 1 filtering, 2 adaptive*/
+const Word16 ACELP_LTF_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] =
+{
+ {{1,1,1,0,0,0,0,0},{1,1,1,0,0,0,0,0}},
+ {{0,0,2,0,0,0,0,0},{0,0,2,0,1,1,1,0}},
+};
+
+/*LTF BITS*/
+const Word16 ACELP_LTF_BITS[4] =
+{
+ 0,
+ 0,
+ 4,
+ 0
+};
+
+/*GAINS ELEMENT*/
+/*5 modes: (ACELP: 5b/suframe), (AMRWB: 7b/subframe),(AMRWB: 6b/subframe),(UC: 5b/subframe)*/
+const Word16 ACELP_GAINS_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] =
+{
+ {{6,6,1,1,0,0,0,0},{7,7,1,1,0,0,0,0}},
+ {{2,2,3,3,0,0,0,0},{2,2,3,3,3,2,1,0}},
+};
+
+/*GAINS BITS*/
+const Word16 ACELP_GAINS_BITS[10] =
+{
+ 0, /* skip sub-frame wise gain coding*/
+ 5, /* ACELP 5b */
+ 6, /* ACELP 6b */
+ 7, /* ACELP 7b */
+ 6, /* AMR-WB 6b */
+ 7, /* AMR-WB 7b */
+ 6, /* ACELP_UC 6b */
+ 7, /* GUNVOICED UV 7b (5b ICB/2b Gaussian) */
+ 4, /* GNELP UV 4b */
+ 5 /* GNELP UV 5b */
+};
+
+/*ADAPT BPF*/
+/*BPF MODE: 0 no filtering, 1 filtering, 2 adaptive*/
+const Word16 ACELP_BPF_MODE[RATE_MODE_MAX][BANDWIDTH_MODE_MAX][ACELP_MODE_MAX+RF_MODE_MAX] =
+{
+ {{1,1,1,1,0,0,0,0},{1,1,1,1,0,0,0,0}},
+ {{1,1,2,2,0,0,0,0},{1,1,2,2,1,1,1,1}},
+};
+
+/*BPF BITS*/
+const Word16 ACELP_BPF_BITS[3] = {0, 0, 2};
+
+const Word16 ACELP_CDK_BITS[ACELP_FIXED_CDK_NB] =
+{
+ 7, 10, 12, 15, 17, 20, 24, 26, 28, 30, 32, 34, 36, 40, 43, 46,
+ 47, 49, 50, 53, 55, 56, 58, 59, 61, 62, 65, 68, 70, 73, 75, 78, 80, 83,
+ 85, 87, 89, 92, 94, 96, 98
+};
+
+/* Number of pulses & positions to the number of unique states that can be achieved with those pulses */
+const Word32 pulsestostates[17][9] =
+{
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ { 2, 2, 2, 2, 2, 2, 2, 2, 2},
+ { 4, 8, 12, 16, 20, 24, 28, 32, 36},
+ { 6, 18, 38, 66, 102, 146, 198, 258, 326},
+ { 8, 32, 88, 192, 360, 608, 952, 1408, 1992},
+ { 10, 50, 170, 450, 1002, 1970, 3530, 5890, 9290},
+ { 12, 72, 292, 912, 2364, 5336, 10836, 20256, 35436},
+ { 14, 98, 462, 1666, 4942, 12642, 28814, 59906, 115598},
+ { 16, 128, 688, 2816, 9424, 27008, 68464, 157184, 332688},
+ { 18, 162, 978, 4482, 16722, 53154, 148626, 374274, 864146},
+ { 20, 200, 1340, 6800, 28004, 97880, 299660, 822560, 2060980},
+ { 22, 242, 1782, 9922, 44726, 170610, 568150, 1690370, 4573910},
+ { 24, 288, 2312, 14016, 68664, 284000, 1022760, 3281280, 9545560},
+ { 26, 338, 2938, 19266, 101946, 454610, 1761370, 6065410, 18892250},
+ { 28, 392, 3668, 25872, 147084, 703640, 2919620, 10746400, 35704060},
+ { 30, 450, 4510, 34050, 207006, 1057730, 4680990, 18347010, 64797470},
+ { 32, 512, 5472, 44032, 285088, 1549824, 7288544, 30316544, 113461024},
+};
+
+
+/*vlpc_1st_cod*/
+const Word16 dico_lsf_abs_8b[256*M] = /*14Q1*1.28*/
+{
+ 966, 1761, 2937, 3740, 4574, 5488, 6457, 7398, 8355, 9289, 10254, 11211, 12247, 13202, 14221, 15172,
+ 1540, 2731, 3544, 4232, 5065, 5917, 6846, 7707, 8602, 9538, 10479, 11445, 12439, 13339, 14332, 15243,
+ 1414, 2201, 3469, 4160, 4832, 5563, 6504, 7493, 8507, 9423, 10261, 11087, 12014, 12887, 13935, 15041,
+ 1176, 2031, 3312, 4141, 4915, 5612, 6368, 7097, 7965, 8861, 9900, 10956, 12137, 13161, 14215, 15190,
+ 840, 1102, 1853, 3913, 4514, 5155, 5976, 6577, 7726, 8469, 9195, 9896, 12016, 13534, 14458, 15327,
+ 1165, 1552, 2467, 3520, 3933, 4902, 6085, 6607, 7652, 8343, 8922, 9577, 11002, 13331, 14521, 15310,
+ 1113, 1431, 2280, 3471, 3975, 4853, 5690, 6407, 7275, 8032, 8621, 9884, 12276, 13033, 13880, 15039,
+ 719, 1036, 1867, 2553, 4352, 5021, 5775, 6505, 7179, 7826, 9601, 11113, 12075, 12807, 14022, 15272,
+ 953, 1294, 1952, 2553, 3007, 5085, 6062, 6718, 8178, 8712, 9927, 11330, 12351, 13205, 14164, 15087,
+ 940, 1283, 2111, 2792, 3256, 3911, 6096, 6898, 7589, 9317, 10103, 10891, 11893, 12886, 13757, 15049,
+ 587, 903, 1795, 3140, 4297, 4853, 5479, 6468, 7886, 8442, 9844, 11336, 12043, 12793, 13911, 15151,
+ 861, 1323, 2258, 3258, 3853, 4815, 5824, 6684, 8004, 9358, 10709, 11951, 12810, 13582, 14465, 15216,
+ 758, 1202, 2449, 3134, 3694, 4423, 5673, 6885, 7835, 9014, 10027, 11120, 12196, 13199, 14218, 15199,
+ 1042, 1478, 2150, 3726, 4263, 4954, 6139, 6790, 7965, 8974, 9643, 10764, 12030, 12725, 13557, 14581,
+ 719, 926, 2434, 3748, 4185, 5032, 5661, 6815, 7286, 9180, 10365, 11159, 11991, 12918, 13824, 15248,
+ 715, 1008, 2245, 3846, 4283, 5859, 6516, 7754, 9005, 9791, 10611, 11473, 12342, 13216, 14190, 15177,
+ 972, 1282, 1856, 2557, 3020, 4536, 7105, 8030, 8649, 9405, 10103, 10712, 11575, 12633, 13608, 14745,
+ 813, 1132, 1994, 2990, 3472, 4041, 4711, 7349, 8285, 8967, 9924, 10497, 11905, 13402, 14503, 15358,
+ 897, 1260, 1953, 3238, 3878, 4495, 6373, 7420, 8046, 9326, 10330, 10893, 11883, 13155, 14226, 15156,
+ 772, 1190, 1952, 2591, 4617, 5613, 6788, 7715, 8323, 9061, 10103, 11442, 12520, 13313, 14105, 15130,
+ 648, 914, 1614, 2978, 3913, 5180, 6371, 7029, 7510, 8288, 10181, 11303, 12262, 13298, 14629, 15443,
+ 679, 934, 1510, 2061, 4006, 5506, 6056, 6653, 7326, 8996, 10254, 11800, 12686, 13410, 14130, 15080,
+ 536, 802, 1288, 2431, 4428, 4896, 5421, 6396, 8409, 9756, 10509, 11135, 12212, 13338, 14298, 15284,
+ 774, 1064, 1751, 2361, 3813, 5723, 6272, 7170, 7837, 9027, 9999, 10677, 11383, 12564, 14005, 15142,
+ 678, 938, 1492, 2025, 4146, 5207, 5984, 6738, 7509, 8781, 9766, 10948, 12156, 13220, 14217, 15296,
+ 639, 927, 1490, 2153, 4243, 5592, 6466, 7219, 7989, 9277, 10369, 11353, 12295, 13240, 14272, 15267,
+ 743, 1035, 1700, 2248, 3167, 5728, 6394, 7572, 8421, 9284, 10729, 11762, 12753, 13526, 14380, 15202,
+ 468, 692, 1255, 2740, 4287, 5357, 6462, 7499, 8537, 9503, 10499, 11458, 12457, 13393, 14352, 15260,
+ 734, 989, 1478, 1957, 2947, 5157, 6144, 7370, 8090, 8834, 9907, 11183, 12331, 13280, 14246, 15263,
+ 461, 681, 1659, 3534, 4547, 5654, 6632, 7664, 8623, 9608, 10561, 11542, 12490, 13438, 14368, 15271,
+ 792, 1113, 1855, 2398, 3238, 5817, 6524, 7434, 8483, 9164, 10021, 11002, 12178, 13218, 14316, 15216,
+ 658, 1008, 1970, 3074, 4543, 5908, 7154, 8105, 8980, 9832, 10606, 11401, 12264, 13165, 14158, 15163,
+ 1009, 1541, 2392, 3464, 4644, 5562, 6666, 7588, 8538, 9554, 10547, 11489, 12487, 13412, 14326, 15206,
+ 955, 1704, 3142, 3903, 4985, 6046, 7112, 8024, 8864, 9606, 10417, 11275, 12242, 13171, 14188, 15188,
+ 1152, 2084, 3441, 4308, 5341, 6367, 7465, 8361, 9258, 10034, 10799, 11569, 12435, 13295, 14269, 15192,
+ 1361, 2472, 3734, 4540, 5724, 6786, 7934, 8876, 9753, 10482, 11209, 11930, 12704, 13494, 14411, 15293,
+ 1448, 2793, 3997, 5078, 6382, 7418, 8278, 9062, 9827, 10479, 11193, 11976, 12798, 13632, 14523, 15357,
+ 1488, 2499, 3704, 4557, 5499, 6512, 7628, 8636, 9720, 10662, 11547, 12425, 13250, 13991, 14754, 15490,
+ 1099, 2055, 3146, 3872, 4700, 5675, 6721, 7670, 8652, 9638, 10640, 11603, 12561, 13473, 14404, 15285,
+ 575, 841, 1577, 3091, 3894, 4777, 5587, 6225, 8293, 8937, 9666, 10986, 12135, 13292, 14164, 15178,
+ 799, 1086, 1834, 2360, 3186, 5166, 5756, 7271, 8036, 8703, 9532, 10239, 11731, 13180, 14418, 15362,
+ 956, 1297, 2021, 2413, 4341, 5175, 5948, 6783, 7304, 8114, 9024, 9853, 10910, 12746, 14094, 15167,
+ 1288, 1856, 2407, 3125, 3686, 4421, 5672, 6339, 7288, 8274, 9315, 10205, 11191, 12856, 14483, 15463,
+ 1020, 1359, 2139, 2709, 3398, 4646, 5412, 6441, 7053, 7923, 9213, 10192, 11791, 13084, 14208, 15242,
+ 839, 1165, 2114, 2625, 3382, 3972, 5064, 7268, 7966, 8749, 9833, 12022, 13123, 13848, 14622, 15279,
+ 837, 1104, 1848, 2230, 3860, 4731, 5491, 6377, 6917, 8917, 10029, 10891, 12043, 12753, 13952, 15201,
+ 1136, 1564, 2097, 2558, 3026, 4824, 5743, 6459, 7664, 8183, 9819, 10837, 11538, 12762, 14193, 15309,
+ 1013, 1492, 2105, 2593, 3135, 5090, 6278, 6877, 7559, 8026, 9120, 10257, 11268, 12899, 14253, 15324,
+ 677, 952, 1578, 2156, 3456, 4665, 5545, 6815, 7822, 8967, 10044, 11143, 12218, 13205, 14269, 15290,
+ 560, 833, 1626, 2825, 4189, 5300, 5822, 6280, 7858, 9256, 10189, 11481, 12413, 13040, 14138, 15123,
+ 666, 1181, 2686, 3416, 4169, 5158, 6179, 7282, 8275, 9372, 10419, 11434, 12436, 13400, 14358, 15244,
+ 773, 1040, 1809, 3551, 4049, 5132, 5867, 6525, 7877, 8558, 9275, 10956, 12231, 13016, 14012, 15032,
+ 881, 1209, 1988, 3725, 4126, 5152, 6189, 6712, 8497, 9495, 10097, 11006, 12228, 13271, 14197, 15140,
+ 850, 1109, 2540, 3212, 3836, 4671, 5423, 6258, 6873, 7502, 9107, 10990, 12254, 13154, 14378, 15352,
+ 721, 954, 2751, 3694, 4320, 5071, 5825, 6738, 7291, 7984, 9289, 11579, 12483, 13254, 14338, 15260,
+ 1055, 1371, 1968, 3743, 4580, 4986, 5695, 6267, 7257, 8890, 9548, 10261, 11586, 12347, 13324, 15091,
+ 676, 972, 2112, 2850, 3753, 4728, 5494, 6367, 7285, 8675, 9943, 11368, 12460, 13350, 14172, 15122,
+ 1049, 1494, 2200, 3000, 3527, 5081, 6046, 6884, 8291, 9069, 10097, 11369, 12496, 13375, 14347, 15128,
+ 814, 1123, 2183, 2717, 3304, 3975, 5256, 6076, 7491, 8840, 10493, 11738, 12716, 13494, 14450, 15263,
+ 948, 1271, 2388, 3106, 3719, 4616, 5356, 6675, 7383, 7967, 9440, 11584, 12408, 13133, 13866, 14860,
+ 635, 881, 1924, 3907, 4384, 5217, 5950, 6984, 7695, 8650, 9877, 11108, 12074, 13120, 14245, 15282,
+ 762, 1028, 2283, 3533, 3943, 4563, 5144, 6692, 7423, 8653, 9739, 10969, 12023, 13103, 14147, 15192,
+ 579, 854, 1748, 3347, 3979, 4734, 5418, 7056, 8203, 9063, 10246, 11271, 12279, 13293, 14338, 15258,
+ 503, 768, 1465, 3077, 4620, 5151, 5798, 7143, 8378, 9391, 10401, 11373, 12315, 13200, 14113, 15106,
+ 717, 1002, 1807, 3675, 4066, 5418, 6034, 6837, 8445, 8980, 10353, 11755, 12753, 13520, 14476, 15232,
+ 672, 949, 1676, 3274, 4729, 5344, 6538, 7393, 8330, 9755, 10902, 11594, 12475, 13327, 14247, 15152,
+ 496, 912, 2757, 3804, 4833, 5819, 6853, 7814, 8753, 9709, 10654, 11604, 12540, 13471, 14395, 15300,
+ 775, 1049, 2302, 3012, 3920, 4950, 5709, 7219, 7761, 9746, 10544, 11297, 12044, 12831, 13700, 15084,
+ 1078, 1504, 2140, 3195, 3778, 4555, 5966, 6673, 7747, 8995, 9612, 10447, 11613, 12329, 13101, 14856,
+ 968, 1849, 3399, 4265, 5004, 5732, 6679, 7575, 8554, 9526, 10485, 11412, 12400, 13344, 14309, 15220,
+ 1199, 2464, 3945, 4913, 6009, 6786, 7495, 8106, 8835, 9620, 10520, 11438, 12438, 13342, 14319, 15235,
+ 1081, 2165, 3828, 4637, 5448, 6070, 6800, 7534, 8434, 9349, 10320, 11262, 12293, 13218, 14232, 15192,
+ 1083, 1694, 2537, 3083, 3771, 5128, 6256, 7141, 8587, 9530, 10324, 11062, 11832, 12707, 13900, 15104,
+ 925, 1244, 2121, 3433, 3834, 5306, 6241, 6848, 8344, 9060, 9700, 10464, 11277, 12214, 14081, 15400,
+ 773, 1006, 1754, 4566, 5209, 5778, 6451, 7124, 8069, 8706, 9253, 10001, 10837, 12064, 14326, 15356,
+ 620, 950, 1866, 3048, 4740, 5460, 5977, 6457, 7915, 9271, 9868, 10687, 11496, 12237, 13203, 15016,
+ 1104, 1439, 2275, 2648, 3695, 5401, 5983, 7243, 7860, 8327, 8987, 11178, 12399, 13141, 14208, 14977,
+ 1076, 1712, 2332, 3118, 4625, 5250, 6130, 7069, 7734, 8740, 10166, 11116, 12011, 12960, 13959, 14830,
+ 659, 949, 1548, 2807, 4382, 4952, 5938, 7089, 7729, 8587, 10547, 11148, 11668, 12528, 13953, 15131,
+ 618, 891, 1593, 3197, 3993, 4733, 5928, 6583, 7372, 9278, 10158, 10852, 12066, 13201, 14256, 15298,
+ 1226, 1611, 2351, 3438, 3930, 4616, 6358, 6975, 7675, 9306, 10025, 10545, 11077, 12750, 14164, 15269,
+ 680, 957, 1852, 3036, 3864, 5284, 5883, 6570, 7132, 8763, 9943, 10590, 11425, 12827, 14180, 15184,
+ 567, 890, 1811, 3039, 4034, 4670, 5067, 5886, 7597, 8889, 10127, 10989, 12275, 13126, 14471, 15240,
+ 1017, 1306, 1912, 4065, 5098, 5506, 6244, 6943, 7610, 8963, 10029, 10608, 11375, 12363, 14054, 15433,
+ 718, 949, 1640, 4407, 4989, 5504, 6145, 6846, 8055, 8755, 9764, 11309, 12335, 13157, 13991, 15052,
+ 833, 1104, 2582, 3256, 3910, 5291, 5740, 7382, 8142, 8582, 9618, 11230, 12436, 13284, 14118, 14993,
+ 1157, 1491, 2370, 3490, 3848, 5022, 5800, 6591, 7995, 8564, 9304, 10921, 12495, 13372, 14254, 15054,
+ 1052, 1417, 2072, 2620, 3044, 4572, 5432, 6284, 7546, 8244, 9800, 10798, 12368, 13625, 14662, 15445,
+ 795, 1132, 1902, 2810, 3433, 4747, 5790, 6745, 8443, 9315, 10050, 10836, 11673, 12528, 13832, 15149,
+ 967, 1250, 2420, 3159, 3625, 4266, 4948, 7030, 7674, 8235, 9112, 9840, 11161, 12837, 14235, 15341,
+ 730, 997, 2113, 3171, 3737, 4764, 5577, 6449, 7240, 8394, 9116, 10604, 12009, 13102, 14231, 15244,
+ 1192, 1617, 2341, 3430, 4000, 4721, 5596, 6358, 7429, 8167, 8895, 9916, 10855, 12188, 13896, 15254,
+ 872, 1150, 2032, 3553, 3983, 4963, 5636, 6604, 7462, 8064, 9470, 10203, 11089, 12799, 14118, 15282,
+ 1013, 1444, 1984, 3267, 4408, 4772, 5805, 7143, 7690, 8647, 10029, 10669, 11431, 12636, 13988, 15117,
+ 830, 1134, 1866, 3581, 4056, 4925, 6011, 6558, 8076, 8830, 9656, 10706, 12639, 13726, 14663, 15367,
+ 684, 957, 1801, 3005, 3559, 4879, 5574, 6920, 7739, 8471, 9724, 10719, 12040, 13148, 14262, 15275,
+ 699, 1022, 2042, 3021, 3652, 5369, 6030, 7152, 8031, 8854, 9968, 10869, 11910, 13073, 14255, 15228,
+ 831, 1105, 1945, 3827, 4272, 5403, 6214, 6843, 8117, 8827, 9516, 10328, 11201, 12905, 14507, 15398,
+ 785, 1036, 2037, 4291, 4698, 5531, 6223, 7000, 8372, 9181, 9784, 10501, 11195, 12592, 13855, 15023,
+ 1079, 1556, 2081, 3294, 4678, 5189, 5975, 6991, 7650, 8458, 9624, 10387, 11370, 12518, 13343, 14521,
+ 1085, 1535, 2122, 2772, 3190, 4157, 6280, 7310, 8119, 8898, 9511, 10169, 11313, 12529, 13732, 15153,
+ 1130, 1625, 2359, 3044, 3504, 5151, 6102, 6755, 7616, 8099, 8791, 9828, 10718, 12434, 14231, 15302,
+ 894, 1194, 1854, 2315, 3048, 5073, 5700, 6637, 7336, 8181, 9563, 10924, 12316, 13331, 14349, 15237,
+ 1274, 1843, 2368, 2935, 3396, 4031, 5905, 6950, 7597, 8704, 9554, 10193, 11657, 13031, 13891, 14934,
+ 1208, 1660, 2310, 3189, 3644, 4355, 5442, 6162, 7602, 8433, 9505, 10600, 12310, 13625, 14495, 15234,
+ 884, 1244, 2154, 2652, 3187, 3810, 5991, 6674, 7284, 8251, 9106, 10547, 11947, 13173, 14248, 15300,
+ 851, 1095, 2125, 2913, 3429, 4068, 4931, 6228, 6911, 8477, 9513, 10932, 12187, 13333, 14385, 15286,
+ 637, 976, 2370, 3892, 4718, 6063, 7126, 8378, 9405, 10359, 11188, 12001, 12807, 13610, 14465, 15303,
+ 674, 1156, 3206, 3848, 4574, 5332, 6275, 7180, 7979, 8944, 9945, 11135, 12211, 13166, 14189, 15185,
+ 648, 874, 1620, 4523, 5335, 5818, 6480, 7079, 8024, 8654, 9320, 10068, 11602, 13428, 14329, 15293,
+ 602, 831, 3174, 4258, 4758, 5558, 6154, 6862, 7261, 8173, 9894, 11228, 12406, 13185, 14416, 15390,
+ 728, 1050, 2523, 3324, 4581, 5112, 6274, 7249, 7665, 8228, 9024, 9779, 11962, 13886, 14569, 15310,
+ 625, 1064, 2658, 3373, 4317, 5328, 6341, 7576, 8230, 9137, 10072, 11030, 12105, 13071, 14050, 15127,
+ 860, 1199, 2569, 3264, 3928, 5082, 6012, 7023, 7568, 8726, 9899, 10975, 11665, 12602, 13465, 14849,
+ 994, 1326, 2131, 3392, 3914, 4629, 5507, 6365, 7208, 8086, 9307, 10139, 11960, 13752, 14791, 15505,
+ 1297, 1723, 2304, 2955, 3528, 4575, 5330, 6141, 7321, 7873, 9079, 11066, 12114, 12781, 13485, 14866,
+ 1247, 1673, 2480, 3557, 4100, 4892, 5843, 6678, 7764, 8607, 9292, 10007, 11055, 11895, 12912, 14829,
+ 1108, 1515, 2302, 3815, 4582, 5275, 6233, 7271, 7993, 8890, 9807, 10489, 11145, 11905, 12753, 14036,
+ 969, 1302, 2055, 2425, 3922, 5219, 6014, 6785, 7331, 9195, 10032, 10897, 11788, 12542, 13408, 14826,
+ 1042, 1398, 2217, 2813, 3449, 4242, 5032, 6957, 7766, 8985, 9916, 10576, 11237, 12222, 13952, 15302,
+ 1099, 1456, 2313, 2814, 3532, 5651, 6349, 7119, 8208, 8769, 9427, 10112, 11070, 12005, 12975, 14815,
+ 952, 1343, 2279, 4277, 5014, 5588, 6550, 7259, 8172, 9304, 10112, 10905, 11848, 12798, 13734, 14852,
+ 827, 1155, 2015, 2590, 3389, 5575, 6147, 7237, 8788, 9352, 9943, 10452, 11166, 11866, 13017, 14908,
+ 965, 1342, 1904, 3530, 4756, 5265, 6282, 7430, 8006, 8866, 10189, 10858, 11593, 12497, 13413, 14286,
+ 791, 1033, 1807, 4669, 5445, 6065, 6777, 7311, 8217, 8955, 9594, 10171, 10891, 11711, 13024, 15079,
+ 703, 982, 1468, 2926, 5508, 6551, 7045, 7648, 8280, 9027, 10043, 10724, 11477, 12486, 13816, 15160,
+ 636, 1084, 3228, 4342, 5051, 5884, 6638, 7545, 8362, 9253, 10190, 11160, 12212, 13207, 14220, 15198,
+ 821, 1100, 1682, 3559, 5618, 6419, 6944, 7630, 8233, 9075, 10130, 10822, 11427, 12149, 13027, 14146,
+ 629, 1332, 3013, 3722, 4532, 5532, 6531, 7553, 8517, 9499, 10507, 11474, 12457, 13390, 14358, 15272,
+ 1317, 2450, 3297, 3892, 4613, 5418, 6425, 7337, 8291, 9245, 10282, 11346, 12442, 13393, 14373, 15268,
+ 1375, 2387, 3533, 4376, 5325, 6263, 7320, 8268, 9276, 10272, 11197, 12094, 13000, 13818, 14648, 15432,
+ 1158, 2044, 2814, 3372, 4231, 5273, 6326, 7190, 8055, 8945, 9909, 11036, 12230, 13264, 14271, 15192,
+ 871, 1102, 2233, 4189, 4539, 5309, 5875, 6894, 8135, 8683, 9397, 10814, 12535, 13312, 14286, 15134,
+ 814, 1062, 2256, 4246, 4741, 5468, 6095, 6832, 7800, 8445, 9019, 9623, 10539, 12957, 14398, 15333,
+ 958, 1249, 1879, 3625, 4221, 4743, 5374, 6010, 7564, 8370, 9054, 10537, 11472, 12580, 13996, 15129,
+ 871, 1148, 2666, 3651, 4193, 5040, 5660, 6778, 7459, 8017, 8780, 9530, 10508, 12721, 14270, 15304,
+ 651, 1057, 2426, 3096, 4328, 5224, 6148, 6984, 7722, 9038, 10150, 11248, 12299, 13281, 14301, 15245,
+ 617, 889, 2138, 4101, 4573, 5464, 6134, 7293, 8294, 9277, 10316, 11265, 12281, 13301, 14327, 15273,
+ 792, 1161, 2081, 2883, 3644, 5502, 6438, 7760, 8867, 9704, 10404, 11003, 11913, 13286, 14647, 15445,
+ 1202, 1869, 2491, 2996, 4025, 5336, 6574, 7586, 8415, 9166, 9940, 11099, 12441, 13461, 14408, 15252,
+ 1164, 2036, 2762, 3315, 4510, 5722, 6901, 7925, 8892, 9813, 10715, 11594, 12526, 13416, 14359, 15235,
+ 1442, 2242, 2916, 3528, 4751, 5836, 6787, 7599, 8395, 9235, 10177, 11157, 12208, 13147, 14145, 15115,
+ 1182, 2189, 3501, 4359, 5481, 6402, 7306, 7997, 8719, 9457, 10314, 11195, 12207, 13152, 14186, 15159,
+ 1123, 1928, 3249, 4174, 5190, 6018, 6841, 7570, 8320, 9079, 9969, 10880, 11946, 12957, 14056, 15116,
+ 1391, 2121, 3172, 3766, 4449, 5215, 6232, 7171, 8096, 8981, 9854, 10664, 11746, 12851, 14017, 15116,
+ 1330, 2144, 2998, 3489, 4141, 5059, 6328, 7427, 8552, 9564, 10505, 11379, 12290, 13173, 14193, 15189,
+ 1109, 1492, 2303, 2946, 3382, 4987, 6548, 6997, 8296, 9305, 9871, 10389, 11172, 13047, 14487, 15395,
+ 1088, 1547, 2223, 3092, 3620, 4386, 6452, 7580, 8220, 9176, 10021, 10624, 11535, 12511, 13349, 14330,
+ 888, 1265, 1930, 3715, 4354, 4929, 6671, 7348, 8125, 9622, 10527, 11265, 12457, 13225, 13909, 14800,
+ 815, 1189, 2006, 3817, 4374, 5838, 6485, 7386, 8816, 9395, 10242, 10930, 11702, 12358, 13510, 14977,
+ 990, 1329, 1856, 2513, 2960, 3841, 6200, 7584, 8128, 9084, 9884, 10615, 11927, 13026, 14162, 15236,
+ 809, 1891, 3000, 3978, 4992, 5938, 6931, 7857, 8818, 9757, 10695, 11637, 12557, 13495, 14394, 15295,
+ 554, 1531, 2712, 3754, 4813, 5795, 6805, 7758, 8739, 9677, 10642, 11569, 12527, 13426, 14344, 15173,
+ 961, 1247, 2162, 4030, 4594, 5392, 6191, 6804, 7979, 8852, 9449, 10061, 10905, 11757, 12852, 14951,
+ 1214, 1854, 2494, 3286, 3894, 4471, 5973, 7358, 7967, 8807, 9608, 10178, 10994, 12344, 13316, 14487,
+ 1024, 1446, 2069, 2773, 3329, 5327, 6627, 7318, 8209, 8780, 9592, 11114, 12066, 12765, 13662, 14618,
+ 907, 1229, 2135, 2657, 3456, 4585, 5614, 6412, 7107, 8072, 10517, 11769, 12447, 13038, 14011, 15186,
+ 608, 888, 1729, 3791, 4395, 4825, 5374, 6977, 7738, 8387, 9316, 10715, 12651, 13548, 14546, 15311,
+ 941, 1202, 2101, 3123, 3503, 4159, 4619, 6676, 7402, 8223, 9627, 10280, 11822, 13131, 14470, 15468,
+ 800, 1065, 1726, 2186, 4630, 5715, 6394, 7256, 7782, 8452, 9368, 11407, 12394, 13086, 14086, 15167,
+ 875, 1208, 1941, 2508, 3296, 4447, 5532, 6821, 7582, 8862, 9556, 10519, 11696, 12896, 14109, 15273,
+ 900, 1183, 1959, 2423, 3386, 5868, 6409, 7218, 7883, 8442, 9143, 9913, 11104, 13003, 14241, 15213,
+ 1115, 1573, 2286, 3113, 3574, 4645, 5519, 6311, 8196, 8937, 9864, 11290, 12252, 13043, 13810, 14631,
+ 754, 1068, 2679, 3694, 4190, 5008, 5606, 7347, 8013, 8864, 9972, 10786, 11627, 12824, 14010, 15316,
+ 825, 1144, 1765, 3426, 4206, 4874, 6385, 7180, 7946, 9319, 10153, 10682, 11276, 11957, 13415, 15087,
+ 537, 862, 1866, 3116, 4349, 4842, 5496, 7245, 7958, 8822, 9611, 10099, 11455, 13291, 14370, 15284,
+ 887, 1205, 1698, 3243, 5173, 5813, 6470, 7237, 7881, 8707, 9739, 10497, 11284, 12115, 13185, 14869,
+ 726, 1002, 2984, 3728, 4334, 5142, 5946, 7127, 7676, 8367, 9085, 10668, 11889, 13054, 14011, 15180,
+ 771, 981, 1772, 4221, 4795, 5401, 6003, 6690, 7480, 8115, 8717, 9938, 12232, 13037, 13941, 15157,
+ 1303, 1922, 2468, 3316, 4185, 4656, 5507, 6631, 7341, 8291, 9593, 10378, 11412, 12616, 13556, 14820,
+ 1080, 1403, 2477, 2954, 3741, 4642, 5517, 6582, 7111, 7805, 8786, 9547, 11253, 12874, 14045, 15236,
+ 872, 1141, 2386, 3209, 3896, 5042, 5805, 7002, 7549, 8285, 9036, 9939, 12031, 13030, 13767, 15055,
+ 728, 1046, 2013, 4276, 5230, 5799, 6889, 7772, 8535, 9890, 10949, 11702, 12791, 13661, 14459, 15218,
+ 768, 1578, 3171, 4134, 5114, 6061, 7128, 8112, 9139, 10152, 11101, 12005, 12913, 13736, 14586, 15387,
+ 622, 1221, 3202, 4279, 5529, 6753, 7808, 8631, 9408, 10115, 10830, 11631, 12512, 13365, 14324, 15263,
+ 621, 848, 1626, 4612, 5335, 5797, 6416, 7167, 8286, 8933, 9880, 11327, 12709, 13565, 14439, 15329,
+ 650, 861, 3115, 4397, 4828, 5572, 6159, 7071, 7513, 8108, 8667, 9739, 12413, 13532, 14414, 15581,
+ 756, 1091, 1615, 2958, 4679, 5429, 6304, 7065, 7657, 8329, 10012, 10763, 11425, 12569, 14285, 15324,
+ 765, 1051, 2074, 3446, 3838, 5659, 6318, 7149, 8407, 8942, 9688, 11058, 12443, 13347, 14361, 15231,
+ 1121, 1473, 2217, 2827, 3347, 5017, 5872, 6668, 7595, 8264, 9085, 10487, 12210, 13022, 13866, 14985,
+ 1056, 1457, 2212, 2861, 3453, 5060, 5976, 6759, 7697, 8519, 9461, 10348, 11169, 12000, 13798, 15274,
+ 1042, 1388, 2220, 3677, 4297, 5120, 6037, 6788, 7788, 8549, 9262, 10069, 10878, 11755, 14085, 15413,
+ 961, 1331, 1957, 3111, 3796, 4344, 5010, 5553, 7612, 9441, 10155, 10903, 11982, 12664, 13391, 14959,
+ 1135, 1470, 2082, 3284, 3937, 4423, 5140, 5618, 7055, 8860, 9355, 10318, 11706, 12556, 13826, 15192,
+ 1084, 1383, 2209, 3550, 4038, 4636, 5240, 5911, 8011, 9044, 9570, 10294, 11155, 11865, 13587, 15219,
+ 737, 1028, 1858, 2434, 3038, 3815, 5414, 6560, 7753, 9010, 10088, 11109, 12200, 13241, 14292, 15286,
+ 979, 1377, 2142, 3511, 4042, 4787, 5869, 6505, 7764, 8710, 9567, 10378, 11383, 13445, 14620, 15417,
+ 802, 1063, 1768, 3997, 4648, 5273, 6005, 6694, 7698, 8427, 9191, 10230, 11176, 12425, 13991, 15244,
+ 926, 1148, 2359, 3438, 3811, 4446, 4994, 6492, 7088, 7840, 8921, 9955, 11823, 13037, 14140, 15275,
+ 639, 939, 1753, 3080, 4204, 5022, 5702, 6198, 6811, 8268, 9786, 10836, 12243, 13126, 14260, 15306,
+ 736, 1079, 1802, 3276, 4001, 5415, 6381, 7119, 8492, 9232, 10308, 11105, 12031, 12793, 13904, 15114,
+ 1249, 1897, 2616, 3398, 4149, 4840, 5809, 6616, 7453, 8768, 9869, 10767, 12051, 13177, 14339, 15241,
+ 1026, 1314, 2014, 3249, 3690, 4344, 4892, 5691, 7289, 7970, 9397, 10615, 11663, 13015, 14272, 15328,
+ 970, 1249, 2342, 2895, 3661, 4685, 5348, 6691, 7176, 8850, 10323, 11025, 11936, 12697, 13429, 14816,
+ 872, 1155, 1680, 2334, 2880, 4439, 6448, 7088, 8221, 9517, 10060, 10691, 11577, 12830, 14274, 15377,
+ 874, 1131, 2067, 2714, 3203, 3786, 4480, 6643, 7487, 8708, 9861, 10989, 12079, 13208, 14240, 15290,
+ 804, 1079, 1708, 2236, 2842, 5275, 6096, 7030, 7886, 8704, 9978, 11354, 12923, 13800, 14706, 15380,
+ 646, 907, 1724, 3428, 3981, 5158, 5889, 7244, 8226, 8728, 9227, 10055, 11833, 13065, 14232, 15287,
+ 986, 1315, 1948, 2518, 3010, 5465, 6638, 7224, 8275, 8820, 9602, 10482, 11268, 12169, 14206, 15449,
+ 565, 805, 1593, 3458, 4571, 5319, 6411, 7828, 8796, 9460, 10121, 10926, 11931, 12989, 14085, 15181,
+ 532, 795, 1654, 3253, 3949, 5323, 6246, 7279, 8378, 9364, 10397, 11379, 12395, 13375, 14390, 15290,
+ 835, 1169, 1895, 2461, 3233, 5608, 6358, 7353, 8521, 9756, 10632, 11371, 12291, 12967, 13777, 14575,
+ 528, 840, 1585, 2511, 4342, 5075, 5825, 7183, 8370, 8938, 9529, 10614, 12398, 13483, 14482, 15340,
+ 789, 1044, 2065, 2677, 3589, 5397, 5969, 7559, 8126, 8638, 9332, 10989, 12645, 13441, 14355, 15188,
+ 685, 970, 1644, 2232, 4331, 5344, 6203, 6877, 7736, 9534, 10331, 11186, 11981, 12778, 13629, 14878,
+ 800, 1120, 1829, 2303, 4180, 4963, 5877, 6722, 7425, 8436, 9106, 10138, 12113, 13163, 14087, 15242,
+ 851, 1150, 2243, 3088, 3642, 5370, 6027, 6953, 7919, 8562, 9276, 9957, 10896, 12786, 14320, 15324,
+ 735, 1113, 2000, 3196, 4699, 5471, 6589, 7347, 8003, 8855, 9650, 10594, 12001, 13017, 13918, 15089,
+ 837, 1098, 1699, 2175, 3008, 6101, 6902, 7529, 8229, 8790, 9674, 10585, 11532, 12971, 14334, 15323,
+ 626, 1278, 3315, 4325, 5436, 6586, 7790, 8824, 9821, 10690, 11482, 12268, 13043, 13789, 14591, 15381,
+ 1439, 2612, 3825, 4715, 5881, 7098, 8204, 9129, 10075, 10889, 11673, 12416, 13159, 13897, 14672, 15420,
+ 1489, 2697, 3785, 4568, 5440, 6284, 7191, 8043, 8936, 9852, 10756, 11696, 12662, 13539, 14458, 15314,
+ 663, 932, 1850, 4514, 5042, 5800, 6482, 7381, 8674, 9537, 10447, 11239, 12074, 12975, 13958, 14969,
+ 695, 1028, 1781, 2195, 4548, 5142, 6539, 7282, 7728, 8259, 8915, 9755, 11646, 13482, 14373, 15221,
+ 846, 1138, 1713, 2239, 2823, 5254, 6237, 6940, 7777, 8443, 9981, 10858, 11793, 13022, 14259, 15331,
+ 595, 882, 1481, 3108, 4815, 5391, 5979, 6529, 8058, 8939, 9706, 10649, 11884, 13065, 14350, 15334,
+ 887, 1139, 1829, 2276, 3102, 5552, 6221, 7067, 7712, 8368, 9127, 10682, 12241, 13127, 14112, 15133,
+ 1019, 1418, 2165, 2865, 3353, 4937, 6019, 6784, 7810, 8440, 9197, 10025, 12092, 13614, 14602, 15352,
+ 951, 1206, 2295, 3066, 3586, 4125, 4780, 7215, 7687, 8320, 9079, 10918, 12519, 13503, 14488, 15224,
+ 847, 1149, 2069, 2504, 4231, 5041, 6034, 6862, 7321, 7882, 8765, 10837, 12433, 13022, 13809, 15203,
+ 829, 1111, 2677, 3505, 3999, 5080, 5694, 7033, 7667, 8302, 8963, 10297, 12410, 13340, 14485, 15373,
+ 908, 1284, 2182, 2613, 3944, 5116, 5768, 7284, 7825, 8461, 10123, 11755, 12583, 13368, 14195, 15053,
+ 930, 1215, 2323, 2834, 3500, 4216, 5200, 5956, 6576, 7757, 9998, 10921, 12073, 12844, 14003, 15254,
+ 973, 1343, 2164, 3265, 3733, 4538, 5294, 6469, 7850, 8468, 9747, 10750, 11398, 12428, 13990, 15226,
+ 952, 1239, 1992, 3093, 3498, 4156, 4605, 5695, 7946, 8668, 9684, 11027, 12029, 13102, 14093, 15158,
+ 558, 828, 1638, 2628, 3361, 4827, 6046, 7182, 8226, 9297, 10326, 11331, 12343, 13333, 14312, 15248,
+ 543, 797, 1292, 2197, 4031, 4954, 6096, 7133, 8292, 9244, 10253, 11267, 12293, 13293, 14303, 15272,
+ 562, 818, 1546, 2854, 3792, 5212, 5897, 6697, 8329, 9105, 10103, 11572, 13033, 13866, 14716, 15223,
+ 897, 1320, 1937, 2717, 3205, 4412, 6880, 7773, 8381, 9585, 10492, 11242, 12589, 13425, 14212, 15053,
+ 798, 1174, 2038, 2482, 3869, 4999, 5820, 7157, 7807, 9160, 10013, 11078, 12122, 13113, 14028, 14997,
+ 686, 1000, 2269, 3020, 3755, 5347, 5960, 7664, 8406, 9199, 10485, 11521, 12512, 13361, 14217, 15144,
+ 715, 1058, 1660, 3282, 4591, 4997, 6361, 7315, 7878, 9084, 10356, 11033, 12186, 13333, 14390, 15279,
+ 784, 1087, 1584, 3299, 5404, 6007, 6611, 7254, 7870, 8870, 10201, 10911, 11780, 12799, 14077, 15156,
+ 664, 905, 1952, 4880, 5346, 5934, 6519, 7374, 8530, 9311, 10103, 10819, 11525, 12818, 14071, 15168,
+ 626, 914, 2854, 4227, 4737, 5634, 6361, 7354, 7918, 8636, 9491, 10701, 11785, 13139, 14220, 15292,
+ 1793, 3491, 4468, 5330, 6092, 6716, 7382, 8023, 8852, 9777, 10729, 11640, 12576, 13418, 14323, 15182,
+ 688, 949, 1560, 3990, 5022, 5519, 6194, 6798, 8071, 8773, 9515, 10514, 12712, 13784, 14609, 15400,
+ 783, 1014, 2824, 3542, 4129, 4903, 5606, 6542, 6965, 7778, 10053, 10913, 11995, 12759, 13498, 15320,
+ 753, 1093, 2085, 2706, 4391, 5134, 5930, 6777, 7408, 8184, 9523, 10719, 12392, 13543, 14552, 15277,
+ 920, 1325, 2067, 2928, 3400, 4646, 5913, 6704, 8091, 8819, 9941, 10843, 12080, 13740, 14761, 15449,
+ 618, 961, 2096, 3325, 4242, 5555, 6567, 7721, 8801, 9891, 10891, 11871, 12871, 13717, 14555, 15310,
+ 826, 1165, 2466, 3876, 4364, 5723, 6461, 7667, 8417, 9095, 9913, 10755, 11704, 12971, 14239, 15196,
+ 1056, 1577, 2885, 3726, 4232, 5031, 5736, 6842, 8006, 8903, 10198, 11414, 12536, 13409, 14359, 15205,
+ 876, 1205, 2453, 3059, 3652, 4312, 5617, 6518, 7542, 8743, 9363, 11286, 13049, 13835, 14643, 15303,
+ 763, 990, 2805, 3723, 4228, 4936, 5628, 6613, 7058, 7705, 8476, 10130, 11974, 13113, 14180, 15342,
+ 857, 1152, 1913, 3994, 4629, 5137, 6183, 6861, 7722, 9347, 10177, 10777, 11599, 13112, 14298, 15264,
+ 656, 1269, 3434, 4621, 5637, 6438, 7220, 7942, 8741, 9612, 10517, 11433, 12435, 13354, 14316, 15237,
+ 1359, 2605, 3748, 4758, 6042, 7092, 7952, 8651, 9338, 9974, 10723, 11579, 12528, 13418, 14397, 15297,
+ 1529, 3067, 4410, 5449, 6449, 7233, 7901, 8525, 9237, 10002, 10859, 11784, 12730, 13589, 14467, 15300,
+ 1790, 3311, 4192, 4897, 5538, 6210, 6922, 7697, 8597, 9590, 10560, 11494, 12426, 13283, 14229, 15138,
+ 1252, 2359, 3404, 4211, 5155, 6055, 7030, 7899, 8850, 9793, 10761, 11714, 12674, 13565, 14489, 15352,
+ 590, 998, 2402, 3314, 4528, 5604, 6649, 7644, 8508, 9487, 10408, 11383, 12335, 13276, 14293, 15243,
+ 727, 1025, 1614, 3818, 5876, 6391, 6980, 7606, 8211, 9304, 10696, 11324, 12381, 13241, 13988, 14791,
+ 621, 899, 2068, 4152, 5232, 6483, 7323, 8193, 8960, 9627, 10417, 11291, 12234, 13192, 14216, 15187,
+ 582, 828, 1926, 4025, 4942, 6029, 6957, 7599, 8278, 9093, 10032, 11126, 12233, 13209, 14256, 15311,
+ 788, 1126, 1690, 3183, 3923, 4599, 6240, 6890, 7758, 9022, 9656, 10453, 11779, 12706, 13913, 15214
+};
+
+
+const Word16 lsf_cdk_nb_gc_stg1[] = /* 14Q1*1.28 */
+{
+ -2046, -827, -3490, -8984, -9331, -8562, -2854, 112, 2194, 13294, 11592, 7952,
+ -294, 2271, 1647, -1260, -2029, -3649, -4081, -3432, -3649, 333, 5042, 4720,
+ -1209, 984, -241, -3413, -4476, -4817, -2910, -2016, -2016, 2900, 6868, 5408,
+ -1900, 896, 688, -197, -33, -993, -1470, -1283, -2145, -665, 2161, 4064,
+ -1998, -351, -1985, -4742, -4879, -5329, -3500, -2023, -1264, 8507, 9766, 6640,
+ 245, 3962, 3664, 1935, 1601, 144, -1054, -1236, -2225, -2647, -3746, 1695,
+ -3051, -1382, -1825, 828, 2537, 1872, 957, 689, -592, 1675, 5507, 5216,
+ -2178, -281, 2097, 5417, 4372, 1648, -802, -1304, -2817, -754, 3345, 4224,
+ -3400, -2402, -4098, -3148, -2066, -1985, -558, 466, 705, 11042, 11096, 7424,
+ 776, 4355, 3200, -1139, -2922, -3985, -2990, -2405, -2881, -661, 2897, 4176,
+ -1818, 394, -385, -1504, -1545, -2913, -3062, -2451, -2609, 2093, 6387, 5248,
+ -1081, 2069, 1952, 1345, 1649, 64, -1394, -1526, -2577, -2051, -1025, 2863,
+ 276, 2780, 1567, -3228, -4881, -5970, -4363, -3523, -3089, 3447, 7300, 5456,
+ 1917, 6445, 5552, 2069, 684, -1233, -2371, -2377, -3409, -1635, 1616, 3648,
+ -2734, -1049, -2001, -1927, -1908, -2273, -1294, -652, -944, 4451, 7893, 5888,
+ -1193, 2108, 5153, 7875, 8214, 6145, 2891, 2001, 208, -1312, -2273, 1599,
+ -3697, -3538, -6739, -7238, -4524, -2464, 2424, 4591, 6098, 15691, 13066, 8912,
+ -352, 2108, 847, -247, 1179, -769, -2757, -2873, -3713, 203, 4994, 4688,
+ -1185, 1565, 703, -1788, -2372, -2721, -1951, -1554, -2129, -374, 2529, 4192,
+ -2094, 401, 352, 1118, 2376, 1632, 582, 351, -1009, -1389, -784, 3056,
+ -367, 1637, -145, -5132, -6888, -8178, -5371, -3397, -1776, 9469, 9894, 6752,
+ 953, 5894, 6785, 5196, 4663, 2400, 31, -598, -2065, -2581, -2786, 1743,
+ -2637, -1222, -560, 5363, 6867, 5329, 2192, 1264, -544, -508, 1345, 3664,
+ -1112, 1918, 2976, 3989, 4508, 3104, 1245, 606, -897, -2381, -4258, 1119,
+ -1983, -328, -2930, -6112, -1802, 144, 486, 194, -960, 4066, 7797, 5872,
+ 648, 3526, 3104, 562, -200, -2177, -3380, -3162, -3857, -1516, 2433, 3920,
+ -2908, -722, -417, -181, 290, -352, -352, -175, -1088, 1689, 5603, 5184,
+ -536, 2771, 2064, 10, -643, -1793, -1733, -1523, -2193, -1813, -1585, 2831,
+ 2239, 5541, 4400, -637, -2370, -4802, -5148, -3901, -2912, 7328, 9222, 6320,
+ 8159, 12344, 9921, 5311, 4611, 2480, -1461, -1819, -2032, 5438, 7396, 5968,
+ -3908, -2998, -3105, 1031, 2171, 1952, 2012, 1982, 1280, 8825, 10343, 7056,
+ -80, 5935, 10546, 12414, 12351, 9601, 4823, 3380, 1152, -840, -2161, 1967
+};
+const Word16 lsf_cdk_nb_gc_stg2[] = /* 14Q1*1.28 */
+{
+ -476, -1387, -3185, 464, 1104, 0,
+ -1029, -675, 63, -1664, -1168, 0,
+ -691, -1002, -1697, -1968, -704, 0,
+ -957, -724, -945, 816, 928, 0,
+ -1131, -2087, -1296, 2704, 1376, 0,
+ -1167, -1003, 512, 592, 192, 0,
+ 492, 517, -721, -3600, -1888, 0,
+ 489, -147, -1153, -688, -864, 0,
+ 865, 179, -608, 2000, 1008, 0,
+ -1286, -1953, -1633, -304, -368, 0,
+ 2033, 1593, -369, -576, 272, 0,
+ -718, 685, 751, -192, 192, 0,
+ 1394, 1172, 1520, -480, -576, 0,
+ -1455, -466, 2896, 2176, 896, 0,
+ -1171, 324, 2512, -272, -496, 0,
+ 4950, 5112, 3536, 1040, 80, 0
+};
+const Word16 lsf_cdk_nb_gc_stg3[] = /* 14Q1*1.28 */
+{
+ 1, 6, -801, -3701, -3408, -1712, 2661, 2257, 768,
+ 4, 11, -481, -1886, -2409, -2353, -652, 1216, 256,
+ 14, 6, -1713, -1706, -1012, -817, -1158, -369, -97,
+ 8, 15, 127, -780, -1241, -1617, -2819, -1474, -577,
+ 13, 6, 2320, 103, -1175, -1681, 297, 1536, 384,
+ 4, 14, -529, -319, -161, -129, -2113, -4131, -1281,
+ 0, 5, -2001, -1650, -185, 1040, 2146, 1713, 736,
+ 12, 4, 320, 1615, 1634, 1376, -1700, -4675, -1697,
+ 15, 13, -401, -348, -511, -320, 2570, 2865, 944,
+ 7, 14, 335, -1107, -768, -112, -338, -65, 15,
+ 13, 15, -1025, 563, -38, -865, -1105, 383, 31,
+ 4, 6, 1056, 1034, 443, -289, -2357, -1986, -689,
+ 7, 6, 1008, 1608, 1329, 816, 730, 1312, 432,
+ 4, 12, -1281, 789, 1794, 1328, -517, -561, -113,
+ 12, 4, 704, 1656, 2289, 3153, 5215, 3682, 1680,
+ 11, 15, 2528, 4255, 3539, 2320, -669, -1585, -641
+};
+const Word16 lsf_cdk_nb_vc_stg1[] = /* 14Q1*1.28 */
+{
+ -1950, -1358, -4562, -8912, -8626, -8050, -2211, 1051, 4226, 15749, 13194, 8800,
+ 224, 2532, 175, -5316, -6930, -5601, 381, 515, -416, 3224, 6964, 5584,
+ -2481, -1570, -3746, -3444, -3066, -3665, -2328, -929, -256, 10781, 10903, 7280,
+ -164, 2676, 1952, 1170, 1362, 32, -809, -978, -1793, -2288, -3137, 2287,
+ -1649, -589, -3746, -9056, -6586, -2160, 1693, 1869, 1072, 8982, 10375, 7056,
+ -1442, 731, -465, -352, 881, 0, -1397, -1476, -2273, -792, 2209, 4048,
+ -570, 1125, -577, -4067, -5011, -6130, -4457, -3228, -2464, 7796, 9414, 6432,
+ 314, 2780, 1599, -2442, -4050, -5762, -4680, -3747, -3169, 3706, 7556, 5568,
+ -3306, -3212, -6178, -5257, -2978, -2209, 33, 2038, 3490, 15396, 13130, 8704,
+ -303, 2334, 927, -1025, -1877, -2753, -1964, -1602, -2145, -943, 1457, 3872,
+ -1437, 228, -1633, -3020, -3188, -2833, -1579, -942, -1184, 2482, 6532, 5408,
+ 2622, 6487, 4448, 511, -1383, -2769, -2495, -2230, -2977, -107, 4082, 4480,
+ -1897, -706, -2994, -2432, 566, 704, 220, 99, -608, 3533, 7300, 5744,
+ -2605, -1419, -1376, 1700, 1217, 112, -957, -849, -1633, 1902, 6131, 5296,
+ 2177, 3621, 751, -6700, -10534, -11698, -2205, 713, 3954, 15329, 12986, 8656,
+ 7156, 9030, 4704, 653, -2345, -6178, -4996, -1616, 1762, 14213, 12329, 8272,
+ -997, 238, -2066, -5868, -6868, -7474, -4302, -2171, -623, 12371, 11336, 7600,
+ 2585, 4011, 959, -298, 477, -353, -2457, -2786, -3233, 5865, 8693, 6064,
+ -2145, -680, -1553, -1961, -2011, -3249, -3184, -2317, -1968, 5674, 8613, 6080,
+ 675, 4202, 4128, 2060, 1483, -865, -2647, -2552, -3377, -2094, 64, 3184,
+ -3084, -2915, -5698, -905, 1626, 2176, 1517, 1566, 1024, 9339, 10663, 7232,
+ -741, 1377, 1168, 206, 185, -1601, -3079, -2936, -3553, -265, 4402, 4528,
+ 872, 3048, 799, -4039, -5660, -7890, -7222, -4564, -1792, 10306, 10311, 6992,
+ 2766, 6132, 4848, -1357, -2881, -4914, -4864, -3528, -2608, 9503, 10134, 6832,
+ -1649, -1598, -6691, -10943, -5664, -3632, 2663, 6788, 11044, 19895, 15933, 10416,
+ 530, 3138, 2560, -401, -1453, -3425, -4047, -3463, -3713, 252, 4914, 4672,
+ -879, 1210, 47, -2253, -2732, -3777, -3689, -2947, -2833, 2110, 6499, 5232,
+ 5749, 8736, 6865, 3519, 2447, 383, -1446, -1459, -2385, 970, 4146, 4560,
+ -2556, -1914, -3969, 3390, 7938, 6305, 1777, 560, -928, 1091, 4563, 4928,
+ -1808, -411, 1313, 6469, 6395, 3680, 398, -149, -1713, -1588, 832, 3360,
+ 3630, 5517, 2479, -2938, -6552, -10675, -4951, -545, 1441, 13744, 12041, 8080,
+ 10956, 13776, 9201, 4285, 3873, -801, -5835, -2466, 1233, 13746, 12105, 8192
+};
+const Word16 lsf_cdk_nb_vc_stg2[] = /* 14Q1*1.28 */
+{
+ -377, -729, -1793, 400, 1312, 0,
+ -1197, -1432, -2033, -1936, -1520, 0,
+ -403, -100, 127, -3232, -3456, 0,
+ 555, 364, -865, -592, -1264, 0,
+ -1136, -1968, -2640, 4448, 3824, 0,
+ -1539, 94, 591, 1600, 1376, 0,
+ -1564, -393, 2528, -304, -688, 0,
+ 1075, 823, 1648, -96, -704, 0,
+ -770, -404, 527, -1648, 64, 0,
+ -1320, -1678, -1072, 48, -688, 0,
+ 145, 83, -1089, -3632, -448, 0,
+ 1994, 1756, 159, 1120, 1504, 0,
+ 282, -236, -800, 2080, 624, 0,
+ -1357, -1537, 1008, 2624, 1360, 0,
+ 2002, 2046, 1215, -2336, -1808, 0,
+ 3757, 3480, 2592, 1472, 512, 0
+};
+const Word16 lsf_cdk_nb_vc_stg3[] = /* 14Q1*1.28 */
+{
+ 3, 5, -657, -4633, -3805, -736, 1304, 1024, 368,
+ 6, 12, -305, -1836, -2507, -2625, -1818, -241, -305,
+ 6, 4, -2577, -1854, -1236, -1073, -594, 207, -1,
+ 2, 2, -80, 643, 38, -993, -3719, -1602, -769,
+ 13, 10, -625, -1825, -2422, -2449, 2887, 2625, 784,
+ 6, 0, -336, 315, 466, 560, -2183, -4867, -1345,
+ 10, 7, -2625, 1255, 2305, 1296, 181, 544, 208,
+ 0, 7, 912, 1998, 1662, 623, -416, 256, 32,
+ 10, 6, -1713, -1720, -311, 1408, 2066, 1585, 672,
+ 7, 11, 15, -1217, -99, -33, -851, -33, -81,
+ 12, 0, -1680, 556, -499, -897, 454, 896, 256,
+ 2, 8, 2608, 425, -938, -1937, -1205, 15, -177,
+ 6, 2, 1504, -796, -939, 80, 2179, 1777, 672,
+ 3, 13, 1984, 3517, 3171, 2320, -2605, -5651, -1857,
+ 14, 2, -160, 1660, 2380, 2832, 2924, 2097, 992,
+ 10, 0, 3857, 3623, 2853, 1728, 1554, 1441, 656
+};
+const Word16 lsf_cdk_wb_gc_stg1[] = /* 14Q1*1.28 */
+{
+ -854, -266, -3202, -8408, -10604, -11763, -10826, -9448, -7970, -4784, -3493, -2593,
+ -2727, -1241, -1489, -1469, -1977, -2529, -2344, -2279, -2273, -1750, -1365, -1505,
+ -728, 1001, -113, -1594, -2256, -3553, -4619, -4591, -4497, -3300, -2327, -2129,
+ -590, 1699, 1264, 1187, 300, -865, -1554, -1669, -1649, -1202, -837, -1169,
+ -1612, -578, -2546, -5013, -6155, -6834, -6779, -6002, -5506, -3988, -2968, -2625,
+ -1725, 1072, 1280, 74, 277, 672, 1385, 2172, 2688, 2643, 2065, 848,
+ -86, 3639, 3824, 1931, 2115, 1120, 338, 500, 496, 751, 718, -65,
+ -1024, 1647, 5377, 9202, 8763, 7665, 5376, 4447, 3824, 2803, 2000, 608,
+ -2585, -2600, -6211, -11489, -11790, -10322, -5788, -3684, -2289, -465, -33, -289,
+ -3165, -2478, -3521, -1181, 298, 1632, 2160, 2107, 2272, 2075, 1407, 319,
+ 1275, 3587, 2848, 570, -26, -1489, -4034, -4818, -5202, -3732, -2550, -2049,
+ -2614, -1530, -848, 4992, 6996, 8002, 9185, 9172, 9106, 7739, 5862, 3408,
+ 440, 2263, 751, -3627, -4674, -4978, -4938, -5078, -5554, -5428, -4266, -3361,
+ -2308, -80, 176, 2603, 3871, 3792, 3219, 2667, 2480, 2189, 1405, 95,
+ 2569, 6546, 6257, 3885, 2438, 1504, 1431, 1319, 1392, 1337, 942, -65,
+ -712, 3328, 6290, 10673, 12635, 13827, 14544, 13939, 13619, 10691, 8026, 4768,
+ 842, 2338, 159, -5945, -8498, -9619, -8197, -7076, -6066, -4502, -3722, -3409,
+ -1628, 617, -129, -1907, -2194, -1505, -95, 486, 928, 1268, 1071, 175,
+ 538, 3277, 2111, -1606, -3194, -3553, -2105, -1604, -1393, -974, -740, -1009,
+ -1279, 456, 2593, 6823, 5435, 3536, 1502, 544, -96, -521, -548, -1105,
+ -983, 675, -865, -4388, -5936, -5697, -3245, -2211, -1633, -519, -276, -849,
+ -102, 3506, 2480, 332, -670, -448, 859, 1384, 1776, 1846, 1568, 448,
+ 270, 5022, 5136, 4435, 4546, 4305, 4185, 4385, 4337, 3659, 2785, 1152,
+ 216, 5449, 10098, 11459, 11060, 9922, 8139, 7175, 6289, 4794, 3394, 1600,
+ -3137, -3309, -5826, -6310, -5500, -4385, -2187, -1054, -288, 502, 527, -129,
+ -2997, -2031, -1344, 2452, 2535, 1856, 912, 451, 272, -124, -515, -993,
+ 3808, 7001, 5536, 908, -807, -1665, -2041, -2232, -2449, -2206, -1782, -1905,
+ -1117, 2493, 3616, 4843, 5755, 6273, 6815, 6906, 6769, 5801, 4580, 2528,
+ 2509, 4911, 3439, -2294, -4945, -7203, -9006, -7957, -6818, -4297, -3321, -3009,
+ -1110, 1877, 1776, 2112, 2398, 2704, 3465, 3938, 4257, 4039, 3202, 1568,
+ 7131, 11568, 10626, 7755, 6467, 5073, 4839, 4543, 4128, 3206, 2160, 912,
+ 2457, 10049, 15204, 18687, 18433, 17364, 14947, 13353, 11682, 8277, 6182, 3232
+};
+const Word16 lsf_cdk_wb_gc_stg2[] = /* 14Q1*1.28 */
+{
+ -1224, -2316, -3425, -928, 128, 0,
+ -1874, -2354, -1025, -624, -448, 0,
+ -1026, -888, -481, -2352, -1024, 0,
+ 838, 174, -2306, -4048, -960, 0,
+ -1336, -2679, -1776, 2464, 1200, 0,
+ 497, 2649, 3536, 1344, 320, 0,
+ -1099, 4, 2448, -544, -752, 0,
+ 993, 486, 592, 64, -480, 0,
+ 288, -551, -2385, 1824, 2016, 0,
+ -1090, -815, 128, 1008, 704, 0,
+ 279, -579, -1729, -560, -832, 0,
+ 60, 1211, 543, -288, 272, 0,
+ 480, 1062, 560, 3152, 1680, 0,
+ -1276, -672, 2961, 2704, 1200, 0,
+ 1357, 1787, 767, -3424, -2768, 0,
+ 4229, 3682, 1696, 192, -256, 0
+};
+const Word16 lsf_cdk_wb_gc_stg3[] = /* 14Q1*1.28 */
+{
+ 15, 1, -1665, -4778, -4630, -3105, -554, -304, -112,
+ 13, 10, -753, -1579, -1817, -1953, -2415, -2148, -1697,
+ 8, 15, 1135, -1716, -3415, -5154, -4958, -3443, -1905,
+ 4, 1, -32, 570, 443, -65, -2187, -2759, -2561,
+ 4, 14, 399, -979, -269, 816, 385, -194, -673,
+ 2, 5, -2161, -1600, -401, -97, -412, -433, -321,
+ 0, 15, 2128, 3449, 1993, 175, -2815, -2580, -1729,
+ 3, 2, 400, 714, 1209, 1904, 2711, 2436, 1840,
+ 9, 13, 143, -1925, -2694, -2545, 358, 930, 960,
+ 10, 0, -960, 868, 173, -513, -97, 577, 896,
+ 0, 5, 1824, 11, -1080, -1761, -1565, -1058, -705,
+ 7, 1, -880, 2304, 2790, 2384, 573, -18, -273,
+ 5, 8, 1840, 1467, 978, 768, 598, 351, -17,
+ 6, 7, -1473, -2052, -711, 992, 3166, 2788, 2080,
+ 7, 12, 1856, 3557, 3483, 3184, 2417, 1923, 1408,
+ 3, 13, -1649, 1850, 4068, 5073, 4907, 4086, 2976
+};
+const Word16 lsf_cdk_wb_vc_stg1[] = /* 14Q1*1.28 */
+{
+ -1159, -1161, -5395, -12785, -14024, -12291, -8572, -6523, -4593, -1979, -1169, -897,
+ -1903, -921, -2065, -1931, -2752, -3825, -4238, -4174, -4145, -3108, -2167, -2081,
+ 522, 1696, -513, -6103, -8611, -9571, -9024, -8617, -7826, -5631, -4489, -3761,
+ -1839, -544, -1280, 1080, 564, 752, 844, 1110, 1344, 1185, 1039, 63,
+ -2685, -2538, -5074, -6161, -6745, -6738, -5709, -4457, -3377, -1830, -1188, -1185,
+ -3059, -3565, -6706, -3405, -1183, -272, -112, 33, 160, -5, 13, -721,
+ 4464, 5425, 1535, -8151, -13242, -15171, -5882, -2159, -288, 176, 739, 1440,
+ 1431, 2210, -769, -2539, -889, -721, -4378, -6019, -8099, -8147, -6215, -3873,
+ -1779, -2663, -8548, -12911, -8955, -5265, -1796, -700, 240, 746, 528, -160,
+ -847, 1228, 735, -1117, -1191, -1857, -2236, -2407, -2321, -1779, -1542, -1665,
+ -11, 1561, 591, -2764, -3940, -4994, -5679, -5652, -5586, -4852, -3930, -3297,
+ -783, 2500, 2912, 1480, 864, -64, -492, -833, -769, -353, -452, -1009,
+ -1207, 305, -1169, -3978, -4167, -3249, -1227, -606, -48, 233, -51, -545,
+ -2442, -2531, -3873, 5622, 7990, 7025, 4210, 3337, 2576, 1042, 237, -673,
+ 7644, 9215, 4703, -2206, -6625, -10676, -11281, -8039, -4321, -386, 15, -113,
+ 5397, 7494, 5296, -39, -1846, -2017, -1875, -1846, -1697, -2156, -2072, -1969,
+ -279, 230, -3010, -8280, -10317, -11859, -10729, -9576, -7922, -4867, -3862, -2865,
+ -899, -234, -2897, 3569, 4566, 799, -5740, -7153, -6546, -3276, -2048, -960,
+ 954, 3319, 1295, -3334, -5133, -5137, -2866, -2245, -1793, -1073, -934, -1281,
+ -1098, 1538, 1024, 1919, 2978, 3729, 4709, 5431, 5521, 4962, 3843, 1920,
+ -772, 429, -1810, -5319, -6411, -7074, -6828, -6001, -5266, -3901, -3160, -2833,
+ -140, 1442, -1153, -2496, -631, 1264, 2033, 3167, 3840, 3225, 2577, 1232,
+ 2263, 4102, 1167, -4671, -6812, -9651, -10507, -2400, 272, 1823, 1124, -2641,
+ 3904, 5709, 4800, 1435, -1797, -3682, -7176, -9009, -11812, -10666, -5157, -2353,
+ 122, 738, -2898, -9698, -11180, -8161, -1527, -926, -352, 476, -116, -705,
+ 1615, 3938, 3296, -117, -1405, -2593, -4075, -4383, -4273, -3528, -3017, -2881,
+ 3319, 4999, 2191, -4352, -6684, -7394, -7503, -7494, -6914, -5038, -4138, -3841,
+ 1933, 5658, 4544, 2619, 2149, 1456, 812, 401, 240, 207, 12, -673,
+ 1747, 3791, 1295, -236, -1712, -1232, 632, 903, 1488, 1527, 1184, 368,
+ -1030, 922, 4017, 7665, 6754, 5073, 3236, 1989, 1056, 426, 45, -609,
+ 12487, 14522, 8896, 2687, 1057, -3810, -10425, -9171, -6482, -2948, -2321, -1169,
+ 7344, 9906, 7921, 4454, 3289, 2320, 1483, 513, 192, 491, 493, 79
+};
+const Word16 lsf_cdk_wb_vc_stg2[] = /* 14Q1*1.28 */
+{
+ -182, -1035, -2593, -176, 528, 0,
+ -2110, -2904, -2881, -1696, -864, 0,
+ -160, -876, -1777, -4160, -2112, 0,
+ 1601, 651, -1393, 208, -896, 0,
+ -1109, -1806, -2112, 2592, 1360, 0,
+ -1723, -1575, 1104, 912, 288, 0,
+ -700, 1343, 687, 1408, 144, 0,
+ 863, 454, 864, 464, -160, 0,
+ -1234, -1141, -289, -832, 832, 0,
+ -230, -608, -480, -1520, -2352, 0,
+ 1268, 2126, 1919, -3440, -3072, 0,
+ 1298, 1365, -65, -2832, 672, 0,
+ 1095, 493, -849, 3184, 3056, 0,
+ -469, -479, 1617, 3728, 2112, 0,
+ -675, 1400, 3984, 240, -592, 0,
+ 2580, 2697, 2432, 1920, 1040, 0
+};
+const Word16 lsf_cdk_wb_vc_stg3[] = /* 14Q1*1.28 */
+{
+ 7, 3, -1329, -4391, -3913, -3041, -859, -255, 176,
+ 13, 7, -2257, -960, -1287, -1649, -1313, -770, -433,
+ 3, 13, -33, -1650, -2302, -2721, -4039, -3798, -2609,
+ 10, 4, 0, 1123, 279, -1057, -2271, -1039, 160,
+ 7, 12, 15, -748, 384, 848, -1029, -1992, -2385,
+ 4, 1, -2417, -2753, -316, 912, 1240, 993, 704,
+ 0, 0, 2497, 3043, 1347, -849, -5667, -5913, -4193,
+ 5, 2, 848, 519, 1737, 2560, 1763, 1506, 912,
+ 12, 12, 271, -2734, -3306, -736, 1294, 383, -209,
+ 10, 14, -577, -71, -129, -449, 1561, 2068, 1920,
+ 14, 1, 1408, -1285, -2943, -4177, -1355, 306, 752,
+ 15, 8, -2529, 2194, 2953, 2368, 1761, 1377, 816,
+ 14, 10, 3024, 1322, 224, -304, 514, 511, -81,
+ 1, 12, -849, -709, 112, 2417, 5221, 4664, 3648,
+ 1, 9, 160, 3607, 3314, 2016, -333, -884, -1233,
+ 13, 12, 1888, 3621, 3935, 4000, 3607, 2932, 2128
+};
+
+const Word16 *const lsf_codebook[2][2][TCXLPC_NUMSTAGES] =
+{
+ {
+ { lsf_cdk_wb_gc_stg1, lsf_cdk_wb_gc_stg2, lsf_cdk_wb_gc_stg3 },
+ { lsf_cdk_wb_vc_stg1, lsf_cdk_wb_vc_stg2, lsf_cdk_wb_vc_stg3 }
+ },
+ {
+ { lsf_cdk_nb_gc_stg1, lsf_cdk_nb_gc_stg2, lsf_cdk_nb_gc_stg3 },
+ { lsf_cdk_nb_vc_stg1, lsf_cdk_nb_vc_stg2, lsf_cdk_nb_vc_stg3 }
+ }
+};
+
+const Word16 lsf_numbits[TCXLPC_NUMSTAGES] = { 5, 4, 4 };
+
+const Word16 lsf_dims[TCXLPC_NUMSTAGES] = { 16, 8, 12 };
+const Word16 lsf_offs[TCXLPC_NUMSTAGES] = { 0, 0, 4 };
+
+const Word16 lsf_ind_cdk_nb_gc_stg4[] = /* 14Q1*1.28 */
+{
+ -1360, -704, 0,
+ 80, 256, 0,
+ -896, 1008, 0,
+ 960, 2016, 0
+};
+const Word16 lsf_ind_cdk_nb_vc_stg4[] = /* 14Q1*1.28 */
+{
+ -1360, -944, 0,
+ 624, 1408, 0,
+ -368, 240, 0,
+ 2480, 3216, 0
+};
+const Word16 lsf_ind_cdk_wb_gc_stg4[] = /* 14Q1*1.28 */
+{
+ -1280, -816, 0,
+ 368, 272, 0,
+ -704, 1136, 0,
+ 1296, 2448, 0
+};
+const Word16 lsf_ind_cdk_wb_vc_stg4[] = /* 14Q1*1.28 */
+{
+ -1040, -848, 0,
+ 688, 400, 0,
+ -560, 1520, 0,
+ 2256, 2704, 0
+};
+
+const Word16 *const lsf_ind_codebook[2][2][TCXLPC_IND_NUMSTAGES] =
+{
+ { { lsf_ind_cdk_wb_gc_stg4 }, { lsf_ind_cdk_wb_vc_stg4 } },
+ { { lsf_ind_cdk_nb_gc_stg4 }, { lsf_ind_cdk_nb_vc_stg4 } }
+};
+
+const Word16 lsf_ind_numbits[TCXLPC_IND_NUMSTAGES] = { 2 };
+
+const Word16 lsf_ind_dims[TCXLPC_IND_NUMSTAGES] = { 4 };
+const Word16 lsf_ind_offs[TCXLPC_IND_NUMSTAGES] = { 0 };
+
+const Word16 min_distance_thr[2][2] = /* 14Q1*1.28 */
+{
+ /* GC, VC */
+ /* WB */ { 580, 580 },
+ /* NB */ {1000, 580 }
+};
+
+
+/*14Q1*1.28*/
+const Word16 means_nb_31bits_ma_lsf[16] = {861 /*336.3281f*1.28f Q1*/, 1360 /*531.2500f*1.28f Q1*/, 2270 /*886.7188f*1.28f Q1*/, 3243 /*1266.7969f*1.28f Q1*/, 4171 /*1629.2969f*1.28f Q1*/, 5052 /*1973.4375f*1.28f Q1*/, 6012 /*2348.4375f*1.28f Q1*/, 6776 /*2646.8750f*1.28f Q1*/, 7676 /*2998.4375f*1.28f Q1*/, 8428 /*3292.1875f*1.28f Q1*/, 9194 /*3591.4062f*1.28f Q1*/, 9744 /*3806.2500f*1.28f Q1*/, 10580 /*4132.8125f*1.28f Q1*/, 11911 /*4652.7344f*1.28f Q1*/, 13440 /*5250.0000f*1.28f Q1*/, 15061 /*5883.2031f*1.28f Q1*/};
+const Word16 means_wb_31bits_ma_lsf[16] = {818 /*319.5312f*1.28f Q1*/, 1403 /*548.0469f*1.28f Q1*/, 2392 /*934.3750f*1.28f Q1*/, 3465 /*1353.5156f*1.28f Q1*/, 4429 /*1730.0781f*1.28f Q1*/, 5428 /*2120.3125f*1.28f Q1*/, 6414 /*2505.4688f*1.28f Q1*/, 7323 /*2860.5469f*1.28f Q1*/, 8304 /*3243.7500f*1.28f Q1*/, 9221 /*3601.9531f*1.28f Q1*/, 10162 /*3969.5312f*1.28f Q1*/, 11091 /*4332.4219f*1.28f Q1*/, 12125 /*4736.3281f*1.28f Q1*/, 13153 /*5137.8906f*1.28f Q1*/, 14241 /*5562.8906f*1.28f Q1*/, 15266 /*5963.2812f*1.28f Q1*/};
+
+
+/*!
+ * \brief CLDFB prototype filter
+ *
+ * cldfb bands: 10
+ * delay[ms]: 1.00
+ * abs. max Val: 1.04
+ * scale: 0.50
+ */
+const Word16 CLDFB80_10[] =
+{
+ W16(0x0000), W16(0xfffc), W16(0xffdf), W16(0x0132), W16(0x23b5),
+ W16(0x0000), W16(0xffff), W16(0xfff3), W16(0x018d), W16(0x2a98),
+ W16(0x0000), W16(0x0000), W16(0x0006), W16(0x020d), W16(0x3116),
+ W16(0x0000), W16(0x0000), W16(0x001a), W16(0x02bd), W16(0x36e2),
+ W16(0x0000), W16(0x0000), W16(0x001c), W16(0x039f), W16(0x3bb5),
+ W16(0x0000), W16(0xffff), W16(0x001a), W16(0x04b1), W16(0x3f51),
+ W16(0x0000), W16(0x0000), W16(0x0024), W16(0x05da), W16(0x419a),
+ W16(0x0000), W16(0x0000), W16(0x002e), W16(0x06ee), W16(0x428c),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x07bd), W16(0x4267),
+ W16(0x0000), W16(0xfffc), W16(0x001b), W16(0x0820), W16(0x410b),
+ W16(0x0000), W16(0xfff0), W16(0xffe9), W16(0x0806), W16(0x3d82),
+ W16(0x0000), W16(0xfffe), W16(0xffe6), W16(0x0746), W16(0x37fe),
+ W16(0x0000), W16(0x0000), W16(0x000d), W16(0x05ae), W16(0x31d1),
+ W16(0x0000), W16(0x0000), W16(0x002a), W16(0x032f), W16(0x2b60),
+ W16(0x0000), W16(0xfffd), W16(0x0025), W16(0xffcd), W16(0x24a3),
+ W16(0x0000), W16(0x0003), W16(0x0004), W16(0xfb88), W16(0x1dc0),
+ W16(0x0000), W16(0x0000), W16(0xffca), W16(0xf66f), W16(0x16c9),
+ W16(0x0000), W16(0x0000), W16(0xff95), W16(0xf09a), W16(0x0fe8),
+ W16(0x0000), W16(0xffff), W16(0xff64), W16(0xea2a), W16(0x08e0),
+ W16(0x0000), W16(0x0012), W16(0xff21), W16(0xe34c), W16(0x02aa)
+};
+
+/*!
+ * \brief CLDFB prototype filter
+ *
+ * cldfb bands: 16
+ * delay[ms]: 1.00
+ * abs. max Val: 1.04
+ * scale: 0.50
+ */
+const Word16 CLDFB80_16[] =
+{
+ W16(0x0000), W16(0xfffb), W16(0xffdd), W16(0x0123), W16(0x2266),
+ W16(0x0000), W16(0xfffe), W16(0xffe7), W16(0x0157), W16(0x26c0),
+ W16(0x0000), W16(0xffff), W16(0xfff4), W16(0x0194), W16(0x2b04),
+ W16(0x0000), W16(0xffff), W16(0xfffe), W16(0x01e0), W16(0x2f1f),
+ W16(0x0000), W16(0x0000), W16(0x000c), W16(0x023f), W16(0x32fc),
+ W16(0x0000), W16(0x0000), W16(0x0019), W16(0x02b0), W16(0x368c),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x0336), W16(0x39bc),
+ W16(0x0000), W16(0x0001), W16(0x0013), W16(0x03cf), W16(0x3c7b),
+ W16(0x0000), W16(0x0001), W16(0x001a), W16(0x047b), W16(0x3ebd),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x0532), W16(0x407c),
+ W16(0x0000), W16(0x0000), W16(0x0025), W16(0x05ec), W16(0x41b3),
+ W16(0x0000), W16(0xffff), W16(0x002d), W16(0x069d), W16(0x4262),
+ W16(0x0000), W16(0x0000), W16(0x0031), W16(0x0738), W16(0x429c),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x07b3), W16(0x4271),
+ W16(0x0000), W16(0xffff), W16(0x002a), W16(0x0804), W16(0x41d1),
+ W16(0x0000), W16(0xfff9), W16(0x0015), W16(0x0824), W16(0x40a3),
+ W16(0x0000), W16(0xffec), W16(0xffee), W16(0x0815), W16(0x3e6c),
+ W16(0x0000), W16(0xfff7), W16(0xffe0), W16(0x07ca), W16(0x3b3b),
+ W16(0x0000), W16(0xfffd), W16(0xffe8), W16(0x0734), W16(0x379e),
+ W16(0x0000), W16(0xfffe), W16(0x0000), W16(0x0647), W16(0x33c7),
+ W16(0x0000), W16(0xffff), W16(0x0018), W16(0x04ff), W16(0x2fd6),
+ W16(0x0000), W16(0x0000), W16(0x0029), W16(0x035e), W16(0x2bca),
+ W16(0x0000), W16(0xffff), W16(0x002b), W16(0x0164), W16(0x279c),
+ W16(0x0000), W16(0x0001), W16(0x0022), W16(0xff11), W16(0x235b),
+ W16(0x0000), W16(0xfffc), W16(0x000f), W16(0xfc66), W16(0x1f0d),
+ W16(0x0000), W16(0x0001), W16(0xffec), W16(0xf966), W16(0x1ab4),
+ W16(0x0000), W16(0x0000), W16(0xffc6), W16(0xf617), W16(0x165a),
+ W16(0x0000), W16(0x0001), W16(0xffa5), W16(0xf27f), W16(0x120e),
+ W16(0x0000), W16(0x0001), W16(0xff86), W16(0xeea6), W16(0x0dbd),
+ W16(0x0000), W16(0x0001), W16(0xff67), W16(0xea95), W16(0x0950),
+ W16(0x0000), W16(0x0005), W16(0xff40), W16(0xe657), W16(0x051a),
+ W16(0x0000), W16(0x001b), W16(0xff12), W16(0xe1fc), W16(0x01c8)
+};
+
+/*!
+ * \brief CLDFB prototype filter
+ *
+ * cldfb bands: 20
+ * delay[ms]: 1.00
+ * abs. max Val: 1.04
+ * scale: 0.50
+ */
+const Word16 CLDFB80_20[] =
+{
+ W16(0x0000), W16(0xfffb), W16(0xffdf), W16(0x011e), W16(0x21f7),
+ W16(0x0000), W16(0xfffd), W16(0xffe1), W16(0x0146), W16(0x2573),
+ W16(0x0000), W16(0xffff), W16(0xfff2), W16(0x0173), W16(0x28e6),
+ W16(0x0000), W16(0xffff), W16(0xfff6), W16(0x01a9), W16(0x2c45),
+ W16(0x0000), W16(0xffff), W16(0xffff), W16(0x01e9), W16(0x2f84),
+ W16(0x0000), W16(0x0000), W16(0x000a), W16(0x0235), W16(0x329c),
+ W16(0x0000), W16(0x0000), W16(0x0014), W16(0x028c), W16(0x3583),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x02f1), W16(0x3831),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x0362), W16(0x3a9c),
+ W16(0x0000), W16(0x0001), W16(0x000d), W16(0x03df), W16(0x3cbb),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x0469), W16(0x3e89),
+ W16(0x0000), W16(0x0000), W16(0x001c), W16(0x04fb), W16(0x4004),
+ W16(0x0000), W16(0x0000), W16(0x0020), W16(0x0590), W16(0x4129),
+ W16(0x0000), W16(0x0000), W16(0x0027), W16(0x0622), W16(0x41f5),
+ W16(0x0000), W16(0x0000), W16(0x002e), W16(0x06ad), W16(0x426d),
+ W16(0x0000), W16(0x0000), W16(0x0030), W16(0x072a), W16(0x429b),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x0792), W16(0x4288),
+ W16(0x0000), W16(0x0001), W16(0x002e), W16(0x07e1), W16(0x4232),
+ W16(0x0000), W16(0xfffe), W16(0x0024), W16(0x0813), W16(0x4186),
+ W16(0x0000), W16(0xfff8), W16(0x0011), W16(0x0825), W16(0x407d),
+ W16(0x0000), W16(0xffed), W16(0xfff1), W16(0x0818), W16(0x3eb8),
+ W16(0x0000), W16(0xfff5), W16(0xffe3), W16(0x07e8), W16(0x3c3c),
+ W16(0x0000), W16(0xfffe), W16(0xffe1), W16(0x0789), W16(0x3977),
+ W16(0x0000), W16(0xfffd), W16(0xffee), W16(0x06f6), W16(0x367b),
+ W16(0x0000), W16(0xfffe), W16(0x0002), W16(0x062a), W16(0x3363),
+ W16(0x0000), W16(0xffff), W16(0x0016), W16(0x0524), W16(0x303c),
+ W16(0x0000), W16(0x0000), W16(0x0026), W16(0x03e4), W16(0x2d04),
+ W16(0x0000), W16(0x0000), W16(0x002d), W16(0x026c), W16(0x29b7),
+ W16(0x0000), W16(0xfffe), W16(0x0029), W16(0x00bb), W16(0x2657),
+ W16(0x0000), W16(0x0005), W16(0x0021), W16(0xfed0), W16(0x22ed),
+ W16(0x0000), W16(0xfff8), W16(0x0014), W16(0xfcae), W16(0x1f7c),
+ W16(0x0000), W16(0x0002), W16(0xfff7), W16(0xfa55), W16(0x1c03),
+ W16(0x0000), W16(0x0000), W16(0xffd8), W16(0xf7c8), W16(0x1886),
+ W16(0x0000), W16(0x0001), W16(0xffbc), W16(0xf50a), W16(0x150f),
+ W16(0x0000), W16(0x0001), W16(0xffa2), W16(0xf21f), W16(0x11a0),
+ W16(0x0000), W16(0x0001), W16(0xff89), W16(0xef0b), W16(0x0e2c),
+ W16(0x0000), W16(0x0001), W16(0xff71), W16(0xebd2), W16(0x0aa5),
+ W16(0x0000), W16(0xfffe), W16(0xff55), W16(0xe87a), W16(0x0724),
+ W16(0x0000), W16(0x0006), W16(0xff33), W16(0xe50a), W16(0x03fd),
+ W16(0x0000), W16(0x001e), W16(0xff0d), W16(0xe18b), W16(0x017f)
+};
+
+/*!
+ * \brief CLDFB prototype filter
+ *
+ * cldfb bands: 32
+ * delay[ms]: 1.00
+ * abs. max Val: 1.04
+ * scale: 0.50
+ */
+const Word16 CLDFB80_32[] =
+{
+ W16(0x0000), W16(0xfffb), W16(0xffe2), W16(0x0115), W16(0x214f),
+ W16(0x0000), W16(0xfffc), W16(0xffde), W16(0x012f), W16(0x237e),
+ W16(0x0000), W16(0xfffd), W16(0xffe2), W16(0x0149), W16(0x25ab),
+ W16(0x0000), W16(0xfffe), W16(0xffec), W16(0x0165), W16(0x27d4),
+ W16(0x0000), W16(0xffff), W16(0xfff4), W16(0x0183), W16(0x29f6),
+ W16(0x0000), W16(0xffff), W16(0xfff6), W16(0x01a6), W16(0x2c10),
+ W16(0x0000), W16(0xffff), W16(0xfffb), W16(0x01cc), W16(0x2e1d),
+ W16(0x0000), W16(0xffff), W16(0x0001), W16(0x01f6), W16(0x301c),
+ W16(0x0000), W16(0x0000), W16(0x0009), W16(0x0226), W16(0x320b),
+ W16(0x0000), W16(0x0000), W16(0x000f), W16(0x025a), W16(0x33e7),
+ W16(0x0000), W16(0x0000), W16(0x0015), W16(0x0292), W16(0x35b0),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x02d0), W16(0x3761),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x0313), W16(0x38fa),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x035a), W16(0x3a77),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x03a7), W16(0x3bd7),
+ W16(0x0000), W16(0x0000), W16(0x0004), W16(0x03f7), W16(0x3d18),
+ W16(0x0000), W16(0xffff), W16(0x001b), W16(0x044e), W16(0x3e38),
+ W16(0x0000), W16(0xffff), W16(0x001a), W16(0x04a8), W16(0x3f39),
+ W16(0x0000), W16(0x0000), W16(0x001c), W16(0x0504), W16(0x4018),
+ W16(0x0000), W16(0x0001), W16(0x001f), W16(0x0561), W16(0x40d6),
+ W16(0x0000), W16(0x0000), W16(0x0022), W16(0x05be), W16(0x4172),
+ W16(0x0000), W16(0x0000), W16(0x0027), W16(0x0619), W16(0x41eb),
+ W16(0x0000), W16(0xffff), W16(0x002c), W16(0x0672), W16(0x4242),
+ W16(0x0000), W16(0x0000), W16(0x002e), W16(0x06c6), W16(0x427b),
+ W16(0x0000), W16(0x0000), W16(0x002f), W16(0x0714), W16(0x4297),
+ W16(0x0000), W16(0x0000), W16(0x0031), W16(0x075a), W16(0x429a),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x0798), W16(0x4285),
+ W16(0x0000), W16(0x0001), W16(0x0031), W16(0x07cb), W16(0x4255),
+ W16(0x0000), W16(0xffff), W16(0x002c), W16(0x07f4), W16(0x4206),
+ W16(0x0000), W16(0xfffe), W16(0x0025), W16(0x0811), W16(0x4193),
+ W16(0x0000), W16(0xfffb), W16(0x001a), W16(0x0821), W16(0x40fa),
+ W16(0x0000), W16(0xfff5), W16(0x000b), W16(0x0823), W16(0x404a),
+ W16(0x0000), W16(0xfff0), W16(0xfff6), W16(0x081b), W16(0x3f2f),
+ W16(0x0000), W16(0xffef), W16(0xffe9), W16(0x0809), W16(0x3daa),
+ W16(0x0000), W16(0xfff5), W16(0xffe2), W16(0x07e4), W16(0x3c12),
+ W16(0x0000), W16(0xfffa), W16(0xffe0), W16(0x07ac), W16(0x3a5c),
+ W16(0x0000), W16(0xffff), W16(0xffe4), W16(0x0761), W16(0x388d),
+ W16(0x0000), W16(0xfffd), W16(0xffed), W16(0x0701), W16(0x36ac),
+ W16(0x0000), W16(0xfffe), W16(0xfff9), W16(0x068a), W16(0x34c0),
+ W16(0x0000), W16(0xffff), W16(0x0006), W16(0x05fd), W16(0x32cd),
+ W16(0x0000), W16(0x0000), W16(0x0013), W16(0x0559), W16(0x30d4),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x049f), W16(0x2ed6),
+ W16(0x0000), W16(0x0000), W16(0x0026), W16(0x03cf), W16(0x2cd0),
+ W16(0x0000), W16(0x0000), W16(0x002c), W16(0x02e8), W16(0x2ac1),
+ W16(0x0000), W16(0x0000), W16(0x002c), W16(0x01eb), W16(0x28aa),
+ W16(0x0000), W16(0xfffe), W16(0x0029), W16(0x00d7), W16(0x268d),
+ W16(0x0000), W16(0xfffd), W16(0x0024), W16(0xffae), W16(0x246c),
+ W16(0x0000), W16(0x000a), W16(0x0021), W16(0xfe6e), W16(0x2248),
+ W16(0x0000), W16(0xfff3), W16(0x001a), W16(0xfd19), W16(0x2022),
+ W16(0x0000), W16(0x0003), W16(0x0006), W16(0xfbad), W16(0x1df8),
+ W16(0x0000), W16(0x0002), W16(0xfff5), W16(0xfa2d), W16(0x1bcb),
+ W16(0x0000), W16(0xffff), W16(0xffe2), W16(0xf899), W16(0x199d),
+ W16(0x0000), W16(0x0001), W16(0xffcf), W16(0xf6f2), W16(0x1770),
+ W16(0x0000), W16(0x0001), W16(0xffbd), W16(0xf537), W16(0x1546),
+ W16(0x0000), W16(0x0001), W16(0xffad), W16(0xf36b), W16(0x1320),
+ W16(0x0000), W16(0x0000), W16(0xff9d), W16(0xf18e), W16(0x10fc),
+ W16(0x0000), W16(0x0001), W16(0xff8e), W16(0xefa2), W16(0x0ed3),
+ W16(0x0000), W16(0x0001), W16(0xff7f), W16(0xeda7), W16(0x0ca3),
+ W16(0x0000), W16(0x0001), W16(0xff6f), W16(0xeb9e), W16(0x0a6c),
+ W16(0x0000), W16(0xfffd), W16(0xff5e), W16(0xe989), W16(0x0837),
+ W16(0x0000), W16(0x0003), W16(0xff4b), W16(0xe769), W16(0x0618),
+ W16(0x0000), W16(0x0006), W16(0xff35), W16(0xe542), W16(0x042a),
+ W16(0x0000), W16(0x0013), W16(0xff1e), W16(0xe314), W16(0x0284),
+ W16(0x0000), W16(0x0020), W16(0xff06), W16(0xe0e2), W16(0x010c)
+};
+
+/*!
+ * \brief CLDFB prototype filter
+ *
+ * cldfb bands: 40
+ * delay[ms]: 1.00
+ * abs. max Val: 1.04
+ * scale: 0.50
+ */
+const Word16 CLDFB80_40[] =
+{
+ W16(0x0000), W16(0xfffa), W16(0xffe2), W16(0x0112), W16(0x2117),
+ W16(0x0000), W16(0xfffb), W16(0xffdc), W16(0x0128), W16(0x22d6),
+ W16(0x0000), W16(0xfffc), W16(0xffe0), W16(0x013c), W16(0x2494),
+ W16(0x0000), W16(0xfffe), W16(0xffe5), W16(0x0151), W16(0x2651),
+ W16(0x0000), W16(0xffff), W16(0xffed), W16(0x0167), W16(0x280b),
+ W16(0x0000), W16(0xffff), W16(0xfff4), W16(0x0180), W16(0x29c0),
+ W16(0x0000), W16(0xffff), W16(0xfff4), W16(0x019b), W16(0x2b6f),
+ W16(0x0000), W16(0xffff), W16(0xfff8), W16(0x01b8), W16(0x2d18),
+ W16(0x0000), W16(0xffff), W16(0xfffd), W16(0x01d8), W16(0x2eb8),
+ W16(0x0000), W16(0xffff), W16(0x0002), W16(0x01fb), W16(0x304e),
+ W16(0x0000), W16(0x0000), W16(0x0008), W16(0x0221), W16(0x31da),
+ W16(0x0000), W16(0x0000), W16(0x000d), W16(0x0249), W16(0x335a),
+ W16(0x0000), W16(0x0000), W16(0x0013), W16(0x0275), W16(0x34ce),
+ W16(0x0000), W16(0x0000), W16(0x0017), W16(0x02a4), W16(0x3634),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x02d6), W16(0x378b),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x030c), W16(0x38d3),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x0344), W16(0x3a08),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x0380), W16(0x3b2b),
+ W16(0x0000), W16(0x0000), W16(0x0017), W16(0x03bf), W16(0x3c3b),
+ W16(0x0000), W16(0xffff), W16(0x0002), W16(0x03ff), W16(0x3d36),
+ W16(0x0000), W16(0xffff), W16(0x001a), W16(0x0445), W16(0x3e1d),
+ W16(0x0000), W16(0x0000), W16(0x001a), W16(0x048d), W16(0x3eef),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x04d6), W16(0x3fad),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x0520), W16(0x4055),
+ W16(0x0000), W16(0x0001), W16(0x001f), W16(0x056a), W16(0x40e8),
+ W16(0x0000), W16(0xffff), W16(0x0021), W16(0x05b5), W16(0x4164),
+ W16(0x0000), W16(0x0000), W16(0x0026), W16(0x05fe), W16(0x41ca),
+ W16(0x0000), W16(0x0000), W16(0x0029), W16(0x0646), W16(0x421b),
+ W16(0x0000), W16(0xffff), W16(0x002d), W16(0x068c), W16(0x4256),
+ W16(0x0000), W16(0x0000), W16(0x002e), W16(0x06ce), W16(0x427f),
+ W16(0x0000), W16(0x0000), W16(0x002f), W16(0x070c), W16(0x4295),
+ W16(0x0000), W16(0x0000), W16(0x0031), W16(0x0746), W16(0x429c),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x077a), W16(0x4293),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x07a8), W16(0x427a),
+ W16(0x0000), W16(0x0001), W16(0x0030), W16(0x07d0), W16(0x424f),
+ W16(0x0000), W16(0xffff), W16(0x002d), W16(0x07f0), W16(0x4210),
+ W16(0x0000), W16(0xffff), W16(0x0028), W16(0x080a), W16(0x41ba),
+ W16(0x0000), W16(0xfffd), W16(0x001f), W16(0x081b), W16(0x414b),
+ W16(0x0000), W16(0xfffa), W16(0x0018), W16(0x0824), W16(0x40c6),
+ W16(0x0000), W16(0xfff4), W16(0x0009), W16(0x0822), W16(0x403a),
+ W16(0xffff), W16(0xfff1), W16(0xfff9), W16(0x081c), W16(0x3f57),
+ W16(0x0000), W16(0xffed), W16(0xffec), W16(0x0810), W16(0x3e1f),
+ W16(0x0000), W16(0xfff3), W16(0xffe6), W16(0x07f9), W16(0x3ce2),
+ W16(0x0000), W16(0xfff6), W16(0xffe1), W16(0x07d5), W16(0x3b92),
+ W16(0x0000), W16(0xfffb), W16(0xffe0), W16(0x07a6), W16(0x3a2f),
+ W16(0x0000), W16(0xffff), W16(0xffe3), W16(0x076a), W16(0x38bc),
+ W16(0x0000), W16(0xfffd), W16(0xffea), W16(0x0720), W16(0x373e),
+ W16(0x0000), W16(0xfffd), W16(0xfff3), W16(0x06c8), W16(0x35b7),
+ W16(0x0000), W16(0xfffe), W16(0xfffd), W16(0x0662), W16(0x342a),
+ W16(0x0000), W16(0xffff), W16(0x0008), W16(0x05ee), W16(0x329a),
+ W16(0x0000), W16(0x0000), W16(0x0011), W16(0x056b), W16(0x3107),
+ W16(0x0000), W16(0xffff), W16(0x001a), W16(0x04d9), W16(0x2f70),
+ W16(0x0000), W16(0x0000), W16(0x0022), W16(0x043a), W16(0x2dd4),
+ W16(0x0000), W16(0x0000), W16(0x0028), W16(0x038c), W16(0x2c33),
+ W16(0x0000), W16(0x0000), W16(0x002c), W16(0x02cf), W16(0x2a8c),
+ W16(0x0000), W16(0x0001), W16(0x002d), W16(0x0205), W16(0x28e0),
+ W16(0x0000), W16(0xffff), W16(0x002b), W16(0x012c), W16(0x2730),
+ W16(0x0000), W16(0xfffd), W16(0x0027), W16(0x0045), W16(0x257d),
+ W16(0x0000), W16(0xffff), W16(0x0023), W16(0xff50), W16(0x23c8),
+ W16(0x0000), W16(0x000a), W16(0x0021), W16(0xfe4d), W16(0x2211),
+ W16(0x0000), W16(0xfff3), W16(0x001c), W16(0xfd3c), W16(0x2059),
+ W16(0x0000), W16(0x0000), W16(0x000b), W16(0xfc1c), W16(0x1e9e),
+ W16(0x0000), W16(0x0003), W16(0xfffd), W16(0xfaf0), W16(0x1ce2),
+ W16(0x0000), W16(0x0001), W16(0xffef), W16(0xf9b6), W16(0x1b24),
+ W16(0x0000), W16(0xfffe), W16(0xffe0), W16(0xf870), W16(0x1965),
+ W16(0x0000), W16(0x0001), W16(0xffd1), W16(0xf71d), W16(0x17a7),
+ W16(0x0000), W16(0x0000), W16(0xffc3), W16(0xf5be), W16(0x15ec),
+ W16(0x0000), W16(0x0001), W16(0xffb5), W16(0xf453), W16(0x1433),
+ W16(0x0000), W16(0x0001), W16(0xffa8), W16(0xf2de), W16(0x127c),
+ W16(0x0000), W16(0x0000), W16(0xff9b), W16(0xf15e), W16(0x10c5),
+ W16(0x0000), W16(0x0001), W16(0xff8f), W16(0xefd4), W16(0x0f0b),
+ W16(0x0000), W16(0x0001), W16(0xff83), W16(0xee40), W16(0x0d4c),
+ W16(0x0000), W16(0x0001), W16(0xff77), W16(0xeca4), W16(0x0b88),
+ W16(0x0000), W16(0x0001), W16(0xff6a), W16(0xeaff), W16(0x09c2),
+ W16(0x0000), W16(0xfffd), W16(0xff5d), W16(0xe953), W16(0x0800),
+ W16(0x0000), W16(0x0002), W16(0xff4d), W16(0xe7a0), W16(0x064d),
+ W16(0x0000), W16(0x0006), W16(0xff3c), W16(0xe5e8), W16(0x04b8),
+ W16(0x0000), W16(0x0009), W16(0xff2a), W16(0xe42c), W16(0x034d),
+ W16(0x0000), W16(0x0018), W16(0xff17), W16(0xe26c), W16(0x0212),
+ W16(0x0001), W16(0x0020), W16(0xff03), W16(0xe0aa), W16(0x00e3)
+};
+
+/*!
+ * \brief CLDFB prototype filter
+ *
+ * cldfb bands: 60
+ * delay[ms]: 1.00
+ * abs. max Val: 1.04
+ * scale: 0.50
+ */
+const Word16 CLDFB80_60[] =
+{
+ W16(0x0000), W16(0xfffa), W16(0xffe2), W16(0x010f), W16(0x20cd),
+ W16(0x0000), W16(0xfffb), W16(0xffdf), W16(0x011e), W16(0x21f7),
+ W16(0x0000), W16(0xfffb), W16(0xffdd), W16(0x012b), W16(0x2320),
+ W16(0x0000), W16(0xfffd), W16(0xffe0), W16(0x0138), W16(0x244a),
+ W16(0x0000), W16(0xfffd), W16(0xffe1), W16(0x0146), W16(0x2573),
+ W16(0x0000), W16(0xfffe), W16(0xffe6), W16(0x0155), W16(0x269b),
+ W16(0x0000), W16(0xfffe), W16(0xffec), W16(0x0164), W16(0x27c1),
+ W16(0x0000), W16(0xffff), W16(0xfff2), W16(0x0173), W16(0x28e6),
+ W16(0x0000), W16(0xffff), W16(0xfff4), W16(0x0184), W16(0x2a08),
+ W16(0x0000), W16(0xffff), W16(0xfff4), W16(0x0196), W16(0x2b28),
+ W16(0x0000), W16(0xffff), W16(0xfff6), W16(0x01a9), W16(0x2c45),
+ W16(0x0000), W16(0xffff), W16(0xfff9), W16(0x01bd), W16(0x2d5e),
+ W16(0x0000), W16(0xffff), W16(0xfffc), W16(0x01d2), W16(0x2e73),
+ W16(0x0000), W16(0xffff), W16(0xffff), W16(0x01e9), W16(0x2f84),
+ W16(0x0000), W16(0x0000), W16(0x0003), W16(0x0201), W16(0x3091),
+ W16(0x0000), W16(0x0000), W16(0x0008), W16(0x021a), W16(0x3199),
+ W16(0x0000), W16(0x0000), W16(0x000a), W16(0x0235), W16(0x329c),
+ W16(0x0000), W16(0x0000), W16(0x000e), W16(0x0251), W16(0x3399),
+ W16(0x0000), W16(0x0000), W16(0x0012), W16(0x026e), W16(0x3491),
+ W16(0x0000), W16(0x0000), W16(0x0014), W16(0x028c), W16(0x3583),
+ W16(0x0000), W16(0x0000), W16(0x0018), W16(0x02ac), W16(0x366f),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x02ce), W16(0x3753),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x02f1), W16(0x3831),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x0315), W16(0x3907),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x033b), W16(0x39d6),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x0362), W16(0x3a9c),
+ W16(0x0000), W16(0x0000), W16(0x001d), W16(0x038a), W16(0x3b5a),
+ W16(0x0000), W16(0x0000), W16(0x0019), W16(0x03b4), W16(0x3c0f),
+ W16(0x0000), W16(0x0001), W16(0x000d), W16(0x03df), W16(0x3cbb),
+ W16(0x0000), W16(0xffff), W16(0x0001), W16(0x040a), W16(0x3d5e),
+ W16(0x0000), W16(0xfffe), W16(0x0017), W16(0x0439), W16(0x3df8),
+ W16(0x0000), W16(0x0000), W16(0x001b), W16(0x0469), W16(0x3e89),
+ W16(0x0000), W16(0x0000), W16(0x001a), W16(0x0499), W16(0x3f10),
+ W16(0x0000), W16(0x0000), W16(0x001a), W16(0x04c9), W16(0x3f8f),
+ W16(0x0000), W16(0x0000), W16(0x001c), W16(0x04fb), W16(0x4004),
+ W16(0x0000), W16(0x0000), W16(0x001e), W16(0x052c), W16(0x406f),
+ W16(0x0000), W16(0x0001), W16(0x001f), W16(0x055e), W16(0x40d1),
+ W16(0x0000), W16(0x0000), W16(0x0020), W16(0x0590), W16(0x4129),
+ W16(0x0000), W16(0x0000), W16(0x0022), W16(0x05c1), W16(0x4177),
+ W16(0x0000), W16(0x0000), W16(0x0025), W16(0x05f2), W16(0x41bb),
+ W16(0x0000), W16(0x0000), W16(0x0027), W16(0x0622), W16(0x41f5),
+ W16(0x0000), W16(0xffff), W16(0x002a), W16(0x0652), W16(0x4226),
+ W16(0x0000), W16(0xffff), W16(0x002c), W16(0x0680), W16(0x424e),
+ W16(0x0000), W16(0x0000), W16(0x002e), W16(0x06ad), W16(0x426d),
+ W16(0x0000), W16(0x0000), W16(0x002e), W16(0x06d9), W16(0x4284),
+ W16(0x0000), W16(0x0000), W16(0x002f), W16(0x0702), W16(0x4293),
+ W16(0x0000), W16(0x0000), W16(0x0030), W16(0x072a), W16(0x429b),
+ W16(0x0000), W16(0x0000), W16(0x0031), W16(0x074f), W16(0x429b),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x0772), W16(0x4295),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x0792), W16(0x4288),
+ W16(0x0000), W16(0x0000), W16(0x0032), W16(0x07af), W16(0x4274),
+ W16(0x0000), W16(0x0001), W16(0x0031), W16(0x07ca), W16(0x4257),
+ W16(0x0000), W16(0x0001), W16(0x002e), W16(0x07e1), W16(0x4232),
+ W16(0x0000), W16(0xffff), W16(0x002c), W16(0x07f5), W16(0x4203),
+ W16(0x0000), W16(0xfffe), W16(0x0029), W16(0x0806), W16(0x41ca),
+ W16(0x0000), W16(0xfffe), W16(0x0024), W16(0x0813), W16(0x4186),
+ W16(0x0000), W16(0xfffd), W16(0x001e), W16(0x081d), W16(0x4137),
+ W16(0x0000), W16(0xfffa), W16(0x0019), W16(0x0823), W16(0x40de),
+ W16(0x0000), W16(0xfff8), W16(0x0011), W16(0x0825), W16(0x407d),
+ W16(0xffff), W16(0xfff3), W16(0x0006), W16(0x0821), W16(0x4023),
+ W16(0xffff), W16(0xfff2), W16(0xfffb), W16(0x081d), W16(0x3f8c),
+ W16(0x0000), W16(0xffed), W16(0xfff1), W16(0x0818), W16(0x3eb8),
+ W16(0x0000), W16(0xffee), W16(0xffeb), W16(0x080d), W16(0x3deb),
+ W16(0x0000), W16(0xfff2), W16(0xffe7), W16(0x07fd), W16(0x3d18),
+ W16(0x0000), W16(0xfff5), W16(0xffe3), W16(0x07e8), W16(0x3c3c),
+ W16(0x0000), W16(0xfff7), W16(0xffe0), W16(0x07ce), W16(0x3b58),
+ W16(0x0000), W16(0xfffa), W16(0xffe0), W16(0x07ae), W16(0x3a6b),
+ W16(0x0000), W16(0xfffe), W16(0xffe1), W16(0x0789), W16(0x3977),
+ W16(0x0000), W16(0xffff), W16(0xffe4), W16(0x075e), W16(0x387d),
+ W16(0x0000), W16(0xfffd), W16(0xffe8), W16(0x072d), W16(0x377e),
+ W16(0x0000), W16(0xfffd), W16(0xffee), W16(0x06f6), W16(0x367b),
+ W16(0x0000), W16(0xfffe), W16(0xfff4), W16(0x06b8), W16(0x3575),
+ W16(0x0000), W16(0xfffe), W16(0xfffb), W16(0x0674), W16(0x346d),
+ W16(0x0000), W16(0xfffe), W16(0x0002), W16(0x062a), W16(0x3363),
+ W16(0x0000), W16(0xffff), W16(0x000a), W16(0x05d9), W16(0x3257),
+ W16(0x0000), W16(0x0000), W16(0x0010), W16(0x0582), W16(0x314b),
+ W16(0x0000), W16(0xffff), W16(0x0016), W16(0x0524), W16(0x303c),
+ W16(0x0000), W16(0xffff), W16(0x001b), W16(0x04c0), W16(0x2f2c),
+ W16(0x0000), W16(0x0000), W16(0x0021), W16(0x0455), W16(0x2e19),
+ W16(0x0000), W16(0x0000), W16(0x0026), W16(0x03e4), W16(0x2d04),
+ W16(0x0000), W16(0x0000), W16(0x0029), W16(0x036d), W16(0x2bed),
+ W16(0x0000), W16(0x0000), W16(0x002c), W16(0x02f0), W16(0x2ad3),
+ W16(0x0000), W16(0x0000), W16(0x002d), W16(0x026c), W16(0x29b7),
+ W16(0x0000), W16(0x0000), W16(0x002c), W16(0x01e2), W16(0x2898),
+ W16(0x0000), W16(0xffff), W16(0x002b), W16(0x0151), W16(0x2778),
+ W16(0x0000), W16(0xfffe), W16(0x0029), W16(0x00bb), W16(0x2657),
+ W16(0x0000), W16(0xfffd), W16(0x0026), W16(0x001d), W16(0x2534),
+ W16(0x0000), W16(0xfffe), W16(0x0024), W16(0xff7a), W16(0x2411),
+ W16(0x0000), W16(0x0005), W16(0x0021), W16(0xfed0), W16(0x22ed),
+ W16(0x0000), W16(0x0009), W16(0x0021), W16(0xfe21), W16(0x21c8),
+ W16(0x0000), W16(0xfff5), W16(0x001f), W16(0xfd6b), W16(0x20a2),
+ W16(0x0000), W16(0xfff8), W16(0x0014), W16(0xfcae), W16(0x1f7c),
+ W16(0x0000), W16(0x0001), W16(0x0009), W16(0xfbeb), W16(0x1e54),
+ W16(0x0000), W16(0x0003), W16(0x0000), W16(0xfb23), W16(0x1d2c),
+ W16(0x0000), W16(0x0002), W16(0xfff7), W16(0xfa55), W16(0x1c03),
+ W16(0x0000), W16(0x0001), W16(0xffed), W16(0xf981), W16(0x1ad9),
+ W16(0x0000), W16(0xffff), W16(0xffe3), W16(0xf8a7), W16(0x19b0),
+ W16(0x0000), W16(0x0000), W16(0xffd8), W16(0xf7c8), W16(0x1886),
+ W16(0x0000), W16(0x0001), W16(0xffcf), W16(0xf6e3), W16(0x175d),
+ W16(0x0000), W16(0x0000), W16(0xffc5), W16(0xf5f9), W16(0x1636),
+ W16(0x0000), W16(0x0001), W16(0xffbc), W16(0xf50a), W16(0x150f),
+ W16(0x0000), W16(0x0001), W16(0xffb3), W16(0xf416), W16(0x13e9),
+ W16(0x0000), W16(0x0001), W16(0xffaa), W16(0xf31d), W16(0x12c5),
+ W16(0x0000), W16(0x0001), W16(0xffa2), W16(0xf21f), W16(0x11a0),
+ W16(0x0000), W16(0x0000), W16(0xff99), W16(0xf11d), W16(0x107b),
+ W16(0x0000), W16(0x0000), W16(0xff91), W16(0xf016), W16(0x0f55),
+ W16(0x0000), W16(0x0001), W16(0xff89), W16(0xef0b), W16(0x0e2c),
+ W16(0x0000), W16(0x0001), W16(0xff81), W16(0xedfc), W16(0x0d01),
+ W16(0x0000), W16(0x0001), W16(0xff79), W16(0xece9), W16(0x0bd4),
+ W16(0x0000), W16(0x0001), W16(0xff71), W16(0xebd2), W16(0x0aa5),
+ W16(0x0000), W16(0x0001), W16(0xff68), W16(0xeab8), W16(0x0976),
+ W16(0x0000), W16(0xfffd), W16(0xff5f), W16(0xe99b), W16(0x084a),
+ W16(0x0000), W16(0xfffe), W16(0xff55), W16(0xe87a), W16(0x0724),
+ W16(0x0000), W16(0x0003), W16(0xff4a), W16(0xe757), W16(0x0607),
+ W16(0x0000), W16(0x0006), W16(0xff3f), W16(0xe632), W16(0x04f9),
+ W16(0x0000), W16(0x0006), W16(0xff33), W16(0xe50a), W16(0x03fd),
+ W16(0x0000), W16(0x000c), W16(0xff27), W16(0xe3e1), W16(0x0315),
+ W16(0x0000), W16(0x0016), W16(0xff1a), W16(0xe2b7), W16(0x0244),
+ W16(0x0000), W16(0x001e), W16(0xff0d), W16(0xe18b), W16(0x017f),
+ W16(0x0002), W16(0x0020), W16(0xff00), W16(0xe05e), W16(0x00a9)
+};
+
+
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 10
+ * global gain: 8.00
+ * scale: sqrt(1.0/16.00)
+ */
+const Word16 rRotVectr_10[] =
+{
+ W16(0x5a71), W16(0x54ea), W16(0x4714), W16(0x3249), W16(0x1891)
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 10
+ * global gain: 8.00
+ * scale: sqrt(1.0/16.00)
+ */
+const Word16 iRotVectr_10[] =
+{
+ W16(0xfc72), W16(0xe0ac), W16(0xc7f7), W16(0xb4be), W16(0xa8e3)
+};
+
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 16
+ * global gain: 5.00
+ * scale: sqrt(1.0/8.00)
+ */
+const Word16 rRotVectr_16[] =
+{
+ W16(0x652a), W16(0x62bc), W16(0x5c83), W16(0x52bc), W16(0x45c7),
+ W16(0x3623), W16(0x246b), W16(0x114d)
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 16
+ * global gain: 5.00
+ * scale: sqrt(1.0/8.00)
+ */
+const Word16 iRotVectr_16[] =
+{
+ W16(0xfd84), W16(0xe9d4), W16(0xd6fe), W16(0xc5bb), W16(0xb6b6),
+ W16(0xaa82), W16(0xa196), W16(0x9c4c)
+};
+
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 20
+ * global gain: 4.00
+ * scale: sqrt(1.0/8.00)
+ */
+const Word16 rRotVectr_20[] =
+{
+ W16(0x5a7e), W16(0x591a), W16(0x5584), W16(0x4fd3), W16(0x482a),
+ W16(0x3ebb), W16(0x33c1), W16(0x2780), W16(0x1a46), W16(0x0c67)
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 20
+ * global gain: 4.00
+ * scale: sqrt(1.0/8.00)
+ */
+const Word16 iRotVectr_20[] =
+{
+ W16(0xfe39), W16(0xf017), W16(0xe259), W16(0xd556), W16(0xc95f),
+ W16(0xbec1), W16(0xb5bf), W16(0xae90), W16(0xa963), W16(0xa658)
+};
+
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 32
+ * global gain: 2.50
+ * scale: sqrt(1.0/4.00)
+ */
+const Word16 rRotVectr_32[] =
+{
+ W16(0x652f), W16(0x6494), W16(0x6300), W16(0x6078), W16(0x5d02),
+ W16(0x58a7), W16(0x5371), W16(0x4d6e), W16(0x46ac), W16(0x3f3b),
+ W16(0x372f), W16(0x2e9a), W16(0x2593), W16(0x1c2f), W16(0x1286),
+ W16(0x08af)
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 32
+ * global gain: 2.50
+ * scale: sqrt(1.0/4.00)
+ */
+const Word16 iRotVectr_32[] =
+{
+ W16(0xfec2), W16(0xf4d9), W16(0xeb0b), W16(0xe170), W16(0xd821),
+ W16(0xcf35), W16(0xc6c1), W16(0xbed9), W16(0xb793), W16(0xb0ff),
+ W16(0xab2d), W16(0xa62d), W16(0xa20b), W16(0x9ed0), W16(0x9c84),
+ W16(0x9b2e)
+};
+
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 40
+ * global gain: 2.00
+ * scale: sqrt(1.0/4.00)
+ */
+const Word16 rRotVectr_40[] =
+{
+ W16(0x5a81), W16(0x5a28), W16(0x5941), W16(0x57cc), W16(0x55cd),
+ W16(0x5347), W16(0x503d), W16(0x4cb4), W16(0x48b3), W16(0x443e),
+ W16(0x3f5e), W16(0x3a1a), W16(0x347b), W16(0x2e88), W16(0x284c),
+ W16(0x21d0), W16(0x1b1f), W16(0x1444), W16(0x0d48), W16(0x0637)
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 40
+ * global gain: 2.00
+ * scale: sqrt(1.0/4.00)
+ */
+const Word16 iRotVectr_40[] =
+{
+ W16(0xff1d), W16(0xf803), W16(0xf0f7), W16(0xea02), W16(0xe330),
+ W16(0xdc8b), W16(0xd61f), W16(0xcff4), W16(0xca15), W16(0xc48c),
+ W16(0xbf60), W16(0xba9a), W16(0xb642), W16(0xb25e), W16(0xaef5),
+ W16(0xac0b), W16(0xa9a6), W16(0xa7ca), W16(0xa678), W16(0xa5b4)
+};
+
+/*!
+ * \brief CLDFB rRotVectr
+ *
+ * cldfb bands: 60
+ * global gain: 1.33
+ * scale: sqrt(1.0/2.00)
+ */
+const Word16 rRotVectr_60[] =
+{
+ W16(0x6882), W16(0x6855), W16(0x67de), W16(0x671e), W16(0x6615),
+ W16(0x64c5), W16(0x632f), W16(0x6153), W16(0x5f32), W16(0x5ccf),
+ W16(0x5a2a), W16(0x5747), W16(0x5426), W16(0x50ca), W16(0x4d35),
+ W16(0x496a), W16(0x456c), W16(0x413d), W16(0x3ce0), W16(0x3859),
+ W16(0x33aa), W16(0x2ed6), W16(0x29e2), W16(0x24d0), W16(0x1fa5),
+ W16(0x1a63), W16(0x150f), W16(0x0fac), W16(0x0a3e), W16(0x04c9)
+};
+
+/*!
+ * \brief CLDFB iRotVectr
+ *
+ * cldfb bands: 60
+ * global gain: 1.33
+ * scale: sqrt(1.0/2.00)
+ */
+const Word16 iRotVectr_60[] =
+{
+ W16(0xff51), W16(0xf9d9), W16(0xf465), W16(0xeefa), W16(0xe99a),
+ W16(0xe44a), W16(0xdf0e), W16(0xd9e9), W16(0xd4de), W16(0xcff2),
+ W16(0xcb27), W16(0xc682), W16(0xc204), W16(0xbdb3), W16(0xb990),
+ W16(0xb59e), W16(0xb1e0), W16(0xae5a), W16(0xab0c), W16(0xa7fb),
+ W16(0xa526), W16(0xa292), W16(0xa03f), W16(0x9e30), W16(0x9c65),
+ W16(0x9ae0), W16(0x99a2), W16(0x98ac), W16(0x97fe), W16(0x9799)
+};
+
+const Word16 cldfb_anaScale[] =
+{
+ SCALE_CLDFB_ANA_10, SCALE_CLDFB_ANA_16, SCALE_CLDFB_ANA_20, SCALE_CLDFB_ANA_32, SCALE_CLDFB_ANA_40, SCALE_CLDFB_ANA_60
+};
+const Word16 cldfb_synScale[] =
+{
+ SCALE_CLDFB_SYN_10, SCALE_CLDFB_SYN_16, SCALE_CLDFB_SYN_20, SCALE_CLDFB_SYN_32, SCALE_CLDFB_SYN_40, SCALE_CLDFB_SYN_60
+};
+const Word16 cldfb_synGain[] =
+{
+ 0x6666, /* 10 bands */
+ 0x51EC, /* 16 bands */
+ 0x6666, /* 20 bands */
+ 0x51EC, /* 32 bands */
+ 0x6666, /* 40 bands */
+ 0x4CCD /* 60 bands */
+};
+const Word16 *cldfb_protoFilter_2_5ms[] =
+{
+ CLDFB80_10, CLDFB80_16, CLDFB80_20, CLDFB80_32, CLDFB80_40, CLDFB80_60
+};
+const Word16 cldfb_scale_2_5ms[7] =
+{
+ 22603/*88.293854 Q8*/, /* 10 bands */
+ 22605/*88.299622 Q8*/, /* 16 bands */
+ 22605/*88.300926 Q8*/, /* 20 bands */
+ 22606/*88.303848 Q8*/, /* 32 bands */
+ 22606/*88.304718 Q8*/, /* 40 bands */
+ 22535/*88.028412 Q8*/ /* 60 bands */
+};
+
+
+/**********************************************************************/ /**
+igf settings structure for each bitrate mode
+**************************************************************************/
+const Word16 swb_offset_LB_new[15][IGF_MAX_SFB] =
+{
+ /* 0: for 9600 kbs WB */
+ {
+ 4, 164, 186, 242, 320
+ },
+ /* 1: for 13200 kbs WB RF */
+ {
+ 4, 164, 186, 242, 320
+ },
+ /* 2: for 9600 kbs SWB */
+ {
+ 4, 200, 322, 444, 566
+ },
+ /* 3: for 13200 kbs SWB */
+ {
+ 7, 256, 288, 328, 376, 432, 496, 566
+ },
+ /* 4: for 13200 kbs SWB RF */
+ {
+ 4, 200, 322, 444, 566
+ },
+ /* 5: for 16400 kbs SWB */
+ {
+ 8, 256, 288, 328, 376, 432, 496, 576, 640
+ },
+ /* 6: for 24400 kbs SWB */
+ {
+ 9, 256, 284, 318, 358, 402, 450, 508, 576, 640
+ },
+ /* 7: for 32000 kbs SWB */
+ {
+ 9, 256, 284, 318, 358, 402, 450, 508, 576, 640
+ },
+ /* 8: for 48000 kbs SWB */
+ {
+ 4, 512, 534, 576, 640
+ },
+ /* 9: for 16400 kbs FB */
+ {
+ 10, 256, 288, 328, 376, 432, 496, 576, 640, 720, 800
+ },
+ /* 10: for 24400 kbs FB */
+ {
+ 11, 256, 284, 318, 358, 402, 450, 508, 576, 640, 720, 800
+ },
+ /* 11: for 32000 kbs FB */
+ {
+ 11, 256, 284, 318, 358, 402, 450, 508, 576, 640, 720, 800
+ },
+ /* 12: for 48000 kbs FB */
+ {
+ 5, 512, 584, 656, 728, 800
+ },
+ /* 13: for 96000 kbs FB */
+ {
+ 3, 640, 720, 800 /* old: 640, 760, 880 */
+ },
+ /* 14: for 128000 kbs FB */
+ {
+ 3, 640, 720, 800 /* old: 640, 760, 880 */
+ }
+};
+
+
+
+const Word16 igf_whitening_TH[15][2][IGF_MAX_TILES] =
+{
+ /* 0: for 9600 kbs WB */
+ {
+ /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 1: for 13200 kbs WB RF */
+ {
+ /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 2: for 9600 kbs SWB */
+ {
+ /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 3: for 13200 kbs SWB */
+ {
+ /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 4: for 13200 kbs SWB RF */
+ {
+ /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 5: for 16400 kbs SWB */
+ {
+ /* medium */ { 6799/*0.83f Q13*/, 7291/*0.89f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 10732/*1.31f Q13*/, 9748/*1.19f Q13*/, 9748/*1.19f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 6: for 24400 kbs SWB*/
+ {
+ /* medium */ { 6636/*0.81f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 11059/*1.35f Q13*/, 10076/*1.23f Q13*/, 10076/*1.23f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 7: for 32000 kbs SWB */
+ {
+ /* medium */ { 7455/*0.91f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 10977/*1.34f Q13*/, 11059/*1.35f Q13*/, 11059/*1.35f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 8: for 48000 kbs SWB */
+ {
+ /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 9: for 16400 kbs FB */
+ {
+ /* medium */ { 5161/*0.63f Q13*/, 2212/*0.27f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 12534/*1.53f Q13*/, 10813/*1.32f Q13*/, 5489/*0.67f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 10: for 24400 kbs FB */
+ {
+ /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/},
+ /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/}
+ },
+ /* 11: for 32000 kbs FB */
+ {
+ /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/},
+ /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/}
+ },
+ /* 12: for 48000 kbs FB */
+ {
+ /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 13: for 96000 kbs FB */
+ {
+ /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ },
+ /* 14: for 128000 kbs FB */
+ {
+ /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/},
+ /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}
+ }
+};
+
+
+/* IGF SCF arithmetic coder cumulative frequency tables and offsets */
+const Word16 cf_off_se01_tab[9] =
+{
+ +1, /* 9.6 kbs B*/
+ +1, /* 13.2 kbs WB RF B*/
+ +1, /* 9.6 kbs SWB B*/
+ +1, /* 13.2 kbs A*/
+ +1, /* 13.2 kbs SWB RF B*/
+ +1, /* 16.4 kbs B*/
+ +1, /* 24.4 kbs B*/
+ +1, /* 32.0 kbs A*/
+ -1 /* 48.0 kbs B*/
+};
+
+const Word16 cf_off_se02_tab[9][IGF_CTX_COUNT] =
+{
+ { +1, +2, +2, +2, +3, +3, +4}, /* 9.6 kbs B*/
+ { +1, +2, +2, +2, +3, +3, +4}, /* 13.2 kbs WB RF B*/
+ { +0, +2, +3, +3, +2, +2, +4}, /* 9.6 kbs SWB B*/
+ { +0, +2, +3, +3, +2, +2, +4}, /* 13.2 kbs A*/
+ { +0, +2, +3, +3, +2, +2, +4}, /* 13.2 kbs SWB RF B*/
+ { +0, +2, +3, +3, +2, +2, +4}, /* 16.4 kbs B*/
+ { -1, +2, +2, +2, +2, +3, +5}, /* 24.4 kbs B*/
+ { -1, +2, +2, +2, +2, +3, +5}, /* 32.0 kbs A*/
+ { +3, +2, +3, +2, +3, +3, +6} /* 48.0 kbs B*/
+};
+
+const Word16 cf_off_se10_tab = -7;
+
+const Word16 cf_off_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT] =
+{
+ { -5, +0, +0, +0, +0, +0, +0},
+ { +0, +0, +0, +0, +0, +0, +0},
+ { +0, +0, +0, +0, +0, +0, +0},
+ { +0, +0, +0, +0, +0, +0, +0},
+ { +0, +0, +0, +0, +0, +0, +0},
+ { +0, +0, +0, +0, +0, +0, +1},
+ { +0, +1, +0, +0, +3, +0, +3}
+};
+
+const Word16 cf_se00_tab[IGF_SYMBOLS_IN_TABLE + 1] =
+{
+ 16384, 16356, 16299, 16185, 15904, 15282, 14669, 13598, 11886, 9541, 6613, 3845, 1799, 606, 153, 32, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
+};
+
+const Word16 cf_se01_tab[9][IGF_SYMBOLS_IN_TABLE + 1] =
+{
+ {16384, 16320, 16285, 16237, 16163, 16049, 15864, 15604, 15187, 14557, 13612, 12308, 10590, 8535, 6346, 4396, 2900, 1917, 1289, 870, 593, 408, 279, 181, 122, 78, 52, 0}, /* 9.6 kbs B*/
+ {16384, 16320, 16285, 16237, 16163, 16049, 15864, 15604, 15187, 14557, 13612, 12308, 10590, 8535, 6346, 4396, 2900, 1917, 1289, 870, 593, 408, 279, 181, 122, 78, 52, 0}, /* 13.2 kbs WB RF B*/
+ {16384, 16375, 16362, 16339, 16307, 16258, 16180, 16061, 15845, 15463, 14795, 13680, 11828, 9252, 6358, 3769, 2079, 1186, 687, 415, 242, 150, 100, 67, 44, 30, 19, 0}, /* 9.6 kbs SWB B*/
+ {16384, 16375, 16362, 16339, 16307, 16258, 16180, 16061, 15845, 15463, 14795, 13680, 11828, 9252, 6358, 3769, 2079, 1186, 687, 415, 242, 150, 100, 67, 44, 30, 19, 0}, /* 13.2 kbs A*/
+ {16384, 16375, 16362, 16339, 16307, 16258, 16180, 16061, 15845, 15463, 14795, 13680, 11828, 9252, 6358, 3769, 2079, 1186, 687, 415, 242, 150, 100, 67, 44, 30, 19, 0}, /* 13.2 kbs SWB RF B*/
+ {16384, 16375, 16362, 16339, 16307, 16258, 16180, 16061, 15845, 15463, 14795, 13680, 11828, 9252, 6358, 3769, 2079, 1186, 687, 415, 242, 150, 100, 67, 44, 30, 19, 0}, /* 16.4 kbs B*/
+ {16384, 16369, 16356, 16337, 16311, 16268, 16197, 16073, 15876, 15544, 14977, 13987, 12327, 9908, 7017, 4393, 2545, 1446, 840, 493, 292, 183, 111, 70, 45, 31, 20, 0}, /* 24.4 kbs B*/
+ {16384, 16369, 16356, 16337, 16311, 16268, 16197, 16073, 15876, 15544, 14977, 13987, 12327, 9908, 7017, 4393, 2545, 1446, 840, 493, 292, 183, 111, 70, 45, 31, 20, 0}, /* 32.0 kbs A*/
+ {16384, 16368, 16355, 16334, 16291, 16212, 16071, 15816, 15359, 14523, 13014, 10534, 7345, 4272, 2228, 1149, 626, 357, 215, 139, 93, 67, 53, 43, 36, 28, 22, 0} /* 48.0 kbs B*/
+};
+
+const Word16 cf_se02_tab[4][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] =
+{
+ { /* 9.6 kbs B */
+ { 16384, 16369, 16348, 16316, 16256, 16172, 16017, 15735, 15246, 14363, 13036, 11139, 8916, 6724, 4757, 3282, 2221, 1549, 1105, 771, 548, 364, 238, 151, 89, 50, 30, 0 },
+{ 16384, 16371, 16358, 16339, 16290, 16241, 16153, 16040, 15813, 15397, 14601, 13301, 11360, 8916, 6254, 3911, 2220, 1280, 755, 461, 278, 177, 111, 70, 35, 20, 12, 0 },
+{ 16384, 16375, 16359, 16333, 16286, 16243, 16154, 16024, 15771, 15380, 14712, 13537, 11742, 9425, 6872, 4378, 2327, 1197, 671, 412, 259, 145, 93, 52, 26, 13, 5, 0 },
+{ 16384, 16372, 16358, 16326, 16289, 16241, 16147, 16014, 15765, 15321, 14670, 13546, 11912, 9787, 7323, 4824, 2536, 1330, 731, 438, 258, 148, 86, 37, 22, 11, 2, 0 },
+{ 16384, 16376, 16364, 16344, 16315, 16272, 16219, 16119, 15910, 15620, 15100, 14254, 13063, 11489, 9413, 7100, 4738, 2751, 1584, 973, 597, 349, 201, 96, 47, 22, 9, 0 },
+{ 16384, 16364, 16340, 16312, 16288, 16237, 16166, 16026, 15756, 15390, 14833, 13870, 12627, 10998, 8985, 6893, 4720, 3048, 1860, 1131, 725, 449, 215, 111, 56, 34, 14, 0 },
+{ 16384, 16326, 16297, 16246, 16183, 16064, 15884, 15632, 15240, 14763, 14107, 13230, 12185, 10886, 9390, 7781, 6194, 4696, 3350, 2259, 1506, 975, 604, 356, 201, 106, 48, 0 }
+ },
+
+ { /* 9.6 kbs SWB B*/
+ { 16384, 16359, 16349, 16331, 16300, 16236, 16112, 15894, 15480, 14691, 13257, 10996, 8168, 5357, 3193, 1864, 1098, 676, 426, 265, 173, 117, 81, 59, 45, 35, 26, 0 },
+{ 16384, 16374, 16370, 16367, 16362, 16348, 16325, 16283, 16204, 16058, 15715, 14980, 13521, 11144, 7972, 4702, 2366, 1063, 480, 241, 128, 71, 42, 22, 14, 9, 5, 0 },
+{ 16384, 16380, 16377, 16375, 16372, 16365, 16354, 16334, 16295, 16216, 16056, 15716, 15034, 13690, 11467, 8404, 5150, 2385, 908, 417, 199, 106, 62, 35, 21, 13, 7, 0 },
+{ 16384, 16378, 16376, 16373, 16368, 16360, 16346, 16318, 16267, 16173, 15991, 15644, 14932, 13623, 11575, 8688, 5224, 2309, 891, 393, 202, 103, 57, 34, 20, 11, 8, 0 },
+{ 16384, 16375, 16372, 16365, 16348, 16322, 16279, 16201, 16046, 15728, 15214, 14297, 12811, 10673, 7918, 4530, 2109, 978, 466, 234, 121, 72, 46, 31, 25, 17, 13, 0 },
+{ 16384, 16366, 16357, 16341, 16325, 16289, 16220, 16084, 15768, 15300, 14466, 13206, 11402, 9176, 6633, 4092, 2192, 1171, 592, 315, 179, 111, 74, 46, 31, 26, 18, 0 },
+{ 16384, 16301, 16266, 16211, 16140, 16045, 15889, 15652, 15358, 14883, 14192, 13119, 11753, 10181, 8445, 6708, 5023, 3449, 2226, 1375, 849, 516, 353, 231, 153, 107, 78, 0 }
+ },
+
+{ /* 24.4 kbs B */
+ { 16384, 16351, 16333, 16303, 16254, 16163, 15993, 15681, 15080, 13987, 12109, 9465, 6588, 4160, 2488, 1480, 912, 589, 389, 266, 190, 131, 93, 68, 47, 34, 24, 0 },
+{ 16384, 16379, 16375, 16369, 16360, 16345, 16328, 16286, 16211, 16078, 15810, 15233, 14058, 11933, 8881, 5609, 2940, 1290, 558, 274, 150, 80, 47, 29, 17, 11, 6, 0 },
+{ 16384, 16382, 16380, 16377, 16370, 16358, 16337, 16300, 16224, 16088, 15811, 15233, 14112, 12019, 9061, 5723, 2780, 1121, 480, 239, 123, 69, 41, 22, 13, 8, 5, 0 },
+{ 16384, 16377, 16375, 16369, 16363, 16351, 16325, 16268, 16172, 16009, 15686, 15039, 13830, 11799, 8924, 5422, 2444, 960, 441, 220, 111, 63, 37, 22, 11, 6, 3, 0 },
+{ 16384, 16374, 16369, 16363, 16356, 16335, 16290, 16214, 16068, 15826, 15382, 14550, 13126, 10956, 8000, 4622, 2090, 973, 478, 249, 128, 75, 42, 19, 13, 7, 4, 0 },
+{ 16384, 16375, 16370, 16367, 16362, 16340, 16298, 16232, 16097, 15860, 15440, 14718, 13570, 11874, 9557, 6790, 4053, 2166, 1150, 622, 323, 179, 96, 53, 33, 17, 12, 0 },
+{ 16384, 16335, 16304, 16276, 16228, 16166, 16094, 15983, 15775, 15501, 15040, 14417, 13552, 12326, 10847, 9117, 7308, 5373, 3666, 2297, 1336, 807, 495, 313, 216, 152, 114, 0 }
+},
+
+{ /* 48.0 kbs B */
+ { 16384, 16334, 16310, 16285, 16254, 16204, 16128, 16031, 15903, 15697, 15380, 14820, 13857, 12267, 9878, 7099, 4509, 2576, 1478, 871, 531, 349, 230, 163, 111, 80, 62, 0},
+ { 16384, 16337, 16327, 16307, 16278, 16239, 16178, 16092, 15947, 15719, 15286, 14428, 12833, 10246, 7123, 4088, 1896, 849, 481, 287, 190, 139, 94, 66, 52, 34, 24, 0 },
+ { 16384, 16352, 16341, 16329, 16312, 16295, 16265, 16223, 16151, 16026, 15825, 15437, 14645, 13089, 10612, 7364, 4077, 1783, 779, 444, 281, 192, 138, 93, 65, 43, 30, 0 },
+ { 16384, 16354, 16347, 16337, 16314, 16284, 16233, 16165, 16051, 15847, 15450, 14621, 13069, 10623, 7298, 3789, 1569, 727, 445, 302, 207, 143, 96, 59, 36, 18, 9, 0 },
+ { 16384, 16352, 16342, 16330, 16314, 16295, 16266, 16215, 16127, 15984, 15709, 15190, 14242, 12540, 9979, 6448, 3160, 1392, 752, 481, 344, 251, 169, 115, 73, 28, 8, 0 },
+ { 16384, 16340, 16320, 16302, 16272, 16257, 16220, 16135, 16011, 15784, 15370, 14688, 13423, 11457, 8721, 5529, 2736, 1375, 784, 525, 353, 263, 172, 113, 78, 26, 11, 0 },
+ { 16384, 16238, 16170, 16113, 16077, 16030, 16000, 15948, 15873, 15752, 15535, 15157, 14595, 13788, 12569, 10767, 8611, 6186, 4101, 2459, 1478, 881, 607, 385, 243, 168, 116, 0 }
+}
+};
+
+/* only needed for >= 48 kbs */
+
+const Word16 cf_se10_tab[IGF_SYMBOLS_IN_TABLE + 1] =
+{
+ 16384, 15493, 15154, 14810, 14331, 13701, 13086, 12403, 11585, 10923, 10293, 9631, 8943, 8385, 7760, 7182, 6593, 6009, 5540, 5082, 4571, 4133, 3711, 3299, 2887, 2460, 2043, 0
+};
+
+const Word16 cf_se11_tab[IGF_CTX_COUNT][IGF_CTX_COUNT][IGF_SYMBOLS_IN_TABLE + 1] =
+{
+ {
+ { 16384, 16313, 16312, 16241, 16206, 16099, 15957, 15386, 14601, 12852, 10282, 7534, 4964, 2966, 1824, 896, 504, 255, 113, 112, 41, 40, 39, 38, 37, 36, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16207, 16206, 16205, 16120, 15949, 14663, 12777, 9947, 6860, 3773, 1972, 772, 430, 259, 174, 89, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16115, 15941, 14891, 12965, 11477, 8587, 5347, 3421, 1407, 620, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16254, 16253, 16004, 15005, 13756, 12006, 9256, 5755, 3755, 1755, 756, 132, 131, 130, 129, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 15964, 15550, 14929, 12856, 9954, 6430, 2906, 1456, 1042, 628, 214, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16087, 15503, 14334, 14333, 11994, 10240, 8193, 5268, 2929, 1760, 1176, 299, 298, 297, 296, 295, 294, 293, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 14922, 13467, 10919, 9464, 7280, 6189, 3641, 2914, 2187, 1824, 1823, 1096, 369, 368, 367, 4, 3, 2, 1, 0}
+ },
+ {
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16238, 16237, 15678, 15399, 14840, 13441, 11341, 8681, 6161, 3781, 2522, 702, 283, 144, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 16374, 15693, 14671, 12625, 7507, 4778, 2390, 1368, 1028, 347, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 16374, 15595, 13776, 9877, 6498, 3639, 3120, 1561, 1042, 523, 265, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 15709, 13704, 12702, 11032, 7355, 3010, 1340, 1007, 674, 341, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 16374, 12816, 10683, 7125, 2854, 720, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 12738, 12737, 10920, 9103, 5466, 1828, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 15359, 15358, 14337, 14336, 14335, 14334, 14333, 10240, 7170, 5124, 2054, 1032, 1031, 1030, 1029, 7, 6, 5, 4, 3, 2, 1, 0}
+ },
+ {
+ { 16384, 16383, 16382, 16107, 16106, 16105, 16104, 16103, 15966, 15965, 15690, 15140, 14315, 12939, 10324, 8122, 4956, 2479, 1654, 966, 691, 416, 141, 140, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 15320, 14265, 12945, 10568, 8984, 6343, 4230, 1853, 797, 270, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16112, 16111, 16110, 15037, 14501, 12622, 11012, 7790, 5374, 3226, 1347, 542, 275, 274, 273, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 15597, 14819, 12090, 7021, 4292, 1953, 1175, 787, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 15935, 14165, 12838, 9297, 6641, 3985, 1772, 1331, 890, 449, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 14740, 13923, 9010, 6555, 4100, 2464, 828, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 13104, 13103, 8192, 4920, 1647, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
+ },
+ {
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16077, 16076, 16075, 15926, 15176, 14425, 10819, 7664, 5711, 2856, 1354, 754, 454, 154, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16044, 16043, 14373, 12369, 10030, 7023, 5019, 1677, 676, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16077, 16076, 16075, 15470, 14258, 12743, 11531, 6375, 3040, 3039, 917, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 15309, 13531, 11396, 7480, 3564, 1786, 364, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 15833, 15289, 13652, 10377, 6556, 3827, 3283, 1646, 555, 554, 553, 552, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 14146, 13404, 13403, 13402, 10425, 7448, 3727, 2240, 2239, 752, 751, 750, 749, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 15562, 14745, 13928, 10653, 7378, 5742, 2467, 830, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
+ },
+ {
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 16219, 15590, 14803, 13544, 11339, 9292, 6930, 4568, 2521, 1419, 790, 318, 161, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16014, 15652, 14925, 14198, 12743, 10196, 5464, 3645, 1826, 371, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16050, 15396, 15395, 12447, 10810, 8518, 4915, 2950, 1313, 659, 333, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 14792, 14001, 11096, 8455, 6079, 3174, 2119, 535, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 15796, 15795, 15794, 15793, 11700, 8777, 6439, 4101, 1178, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 15473, 15472, 15471, 14563, 13655, 12746, 10017, 7288, 6379, 6378, 4559, 1830, 1829, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 15723, 15069, 13105, 9174, 7865, 3934, 3280, 1971, 1317, 663, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
+ },
+ {
+ { 16384, 16383, 16382, 16381, 16232, 16231, 16230, 16229, 16228, 16227, 16078, 15628, 15329, 13977, 12325, 10222, 5413, 4212, 1959, 908, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16109, 15842, 15841, 13694, 11815, 10205, 5640, 3493, 2151, 1347, 543, 542, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16168, 14699, 13650, 11761, 9452, 6093, 3784, 1685, 636, 427, 426, 425, 424, 423, 422, 421, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16122, 15611, 14332, 13053, 10238, 7423, 4608, 2561, 2050, 1027, 516, 515, 260, 259, 258, 257, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 16376, 16375, 15207, 13649, 10531, 6632, 3514, 1176, 398, 397, 396, 395, 394, 393, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16379, 16378, 16377, 15749, 15120, 12601, 10082, 8823, 6304, 3785, 3156, 1267, 638, 637, 636, 7, 6, 5, 4, 3, 2, 1, 0},
+ { 16384, 16383, 15729, 15728, 15727, 15726, 15725, 15071, 14417, 12453, 10489, 8525, 5905, 1975, 1321, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}
+ },
+ {
+ { 16384, 16383, 16372, 16340, 16339, 16328, 16285, 16253, 16136, 15923, 15614, 14931, 13833, 12201, 10175, 7615, 5269, 3243, 2123, 1142, 673, 342, 182, 150, 86, 54, 11, 0},
+ { 16384, 16383, 16366, 16349, 16332, 16331, 16314, 16245, 16244, 16141, 15813, 15451, 14105, 12672, 9910, 7113, 4472, 2590, 1071, 484, 294, 156, 53, 36, 19, 18, 1, 0},
+ { 16384, 16383, 16382, 16369, 16355, 16341, 16271, 16117, 15921, 15627, 14772, 13089, 10929, 8334, 5487, 3299, 1644, 999, 424, 228, 88, 46, 18, 17, 16, 15, 14, 0},
+ { 16384, 16367, 16366, 16365, 16364, 16363, 16259, 16173, 15809, 15028, 13951, 12214, 9278, 6203, 3719, 2052, 1079, 402, 194, 125, 56, 22, 21, 20, 3, 2, 1, 0},
+ { 16384, 16383, 16360, 16359, 16358, 16357, 16356, 16333, 16332, 16143, 15954, 15434, 14227, 12262, 9540, 6652, 3882, 1988, 1207, 829, 427, 191, 73, 50, 49, 2, 1, 0},
+ { 16384, 16383, 16382, 16381, 16380, 16296, 16254, 15748, 14862, 13427, 11189, 8487, 5278, 3252, 2028, 1099, 551, 340, 298, 214, 172, 88, 46, 45, 3, 2, 1, 0},
+ { 16384, 16383, 16307, 16269, 16231, 16230, 16077, 15886, 15464, 14620, 13546, 11896, 9671, 7024, 4338, 2382, 1423, 809, 541, 311, 158, 43, 5, 4, 3, 2, 1, 0}
+ }
+};
+
+
+/**********************************************************************/ /**
+igf settings table for each bitrate mode
+**************************************************************************/
+const IGF_MODE igfMode[15] =
+{
+ /* sampleRate, frameLength, bitRate, igfMinFq, transFac, maxHopsize */
+ { 16000, 320, 9600, 774, 20480/*1.25f Q14*/, 4 }, /* 9.6kbs WB 0 */
+ { 16000, 320, 13200, 774, 20480/*1.25f Q14*/, 4 }, /* 13.2kbs WB RF 1 */
+ { 32000, 640, 9600, 800, 20480/*1.25f Q14*/, 2 }, /* 9.6kbs SWB 2 */
+ { 32000, 640, 13200, 800, 20480/*1.25f Q14*/, 4 }, /* 13.2kbs SWB 3 */
+ { 32000, 640, 13200, 800, 20480/*1.25f Q14*/, 2 }, /* 13.2kbs SWB RF 4 */
+ { 32000, 640, 16400, 800, 20480/*1.25f Q14*/, 4 }, /* 16.4kbs SWB 5 */
+ { 32000, 640, 24400, 800, 20480/*1.25f Q14*/, 4 }, /* 24.4kbs SWB 6 */
+ { 32000, 640, 32000, 800, 20480/*1.25f Q14*/, 4 }, /* 32.0kbs SWB 7 */
+ { 32000, 640, 48000, 1600, 20480/*1.25f Q14*/, 4 }, /* 48.0kbs SWB 8 */
+ { 48000, 960, 16400, 800, 20480/*1.25f Q14*/, 4 }, /* 16.4kbs FB 9 */
+ { 48000, 960, 24400, 800, 20480/*1.25f Q14*/, 2 }, /* 24.4kbs FB 10 */
+ { 48000, 960, 32000, 800, 20480/*1.25f Q14*/, 2 }, /* 32.0kbs FB 11 */
+ { 48000, 960, 48000, 1600, 20480/*1.25f Q14*/, 2 }, /* 48.0kbs FB 12 */
+ { 48000, 960, 96000, 1600, 8192/*0.50f Q14*/, 1 }, /* 96.0kbs FB 13 */
+ { 48000, 960, 128000, 1600, 8192/*0.50f Q14*/, 1 } /*128.0kbs FB 14 */
+};
+
+const Word32 bwMode2fs[4] = { 8000, 16000, 32000, 48000 };
+
+const PWord16 w1N8[15] =
+{
+ {{ 32729/*0.998795 Q15*/, -1608/*-0.049068 Q15*/}},
+ {{ 32610/*0.995185 Q15*/, -3212/*-0.098017 Q15*/}},
+ {{ 32413/*0.989177 Q15*/, -4808/*-0.146730 Q15*/}},
+ {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{ 31786/*0.970031 Q15*/, -7962/*-0.242980 Q15*/}},
+ {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}},
+ {{ 30853/*0.941544 Q15*/, -11039/*-0.336890 Q15*/}},
+ {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{ 29622/*0.903989 Q15*/, -14010/*-0.427555 Q15*/}},
+ {{ 28899/*0.881921 Q15*/, -15447/*-0.471397 Q15*/}},
+ {{ 28106/*0.857729 Q15*/, -16846/*-0.514103 Q15*/}},
+ {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{ 26320/*0.803208 Q15*/, -19520/*-0.595699 Q15*/}},
+ {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}},
+ {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}}
+};
+
+const PWord16 w2N8[15] =
+{
+ {{ 32610/*0.995185 Q15*/, -3212/*-0.098017 Q15*/}},
+ {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}},
+ {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{ 28899/*0.881921 Q15*/, -15447/*-0.471397 Q15*/}},
+ {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}},
+ {{ 23170/*0.707107 Q15*/, -23170/*-0.707107 Q15*/}},
+ {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}},
+ {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}},
+ {{ 15447/*0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{ 9512/*0.290285 Q15*/, -31357/*-0.956940 Q15*/}},
+ {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}}
+};
+
+const PWord16 w3N8[15] =
+{
+ {{ 32413/*0.989177 Q15*/, -4808/*-0.146730 Q15*/}},
+ {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}},
+ {{ 29622/*0.903989 Q15*/, -14010/*-0.427555 Q15*/}},
+ {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}},
+ {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}},
+ {{ 16846/*0.514103 Q15*/, -28106/*-0.857729 Q15*/}},
+ {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{ 7962/*0.242980 Q15*/, -31786/*-0.970031 Q15*/}},
+ {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}},
+ {{ -1608/*-0.049068 Q15*/, -32729/*-0.998795 Q15*/}},
+ {{ -6393/*-0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{-11039/*-0.336890 Q15*/, -30853/*-0.941544 Q15*/}},
+ {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{-19520/*-0.595699 Q15*/, -26320/*-0.803208 Q15*/}}
+};
+
+const PWord16 w4N8[15] =
+{
+ {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{ 23170/*0.707107 Q15*/, -23170/*-0.707107 Q15*/}},
+ {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}},
+ {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{ 0/*0.000000 Q15*/, -32768/*-1.000000 Q15*/}},
+ {{ -6393/*-0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{-12540/*-0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{-18205/*-0.555570 Q15*/, -27246/*-0.831470 Q15*/}},
+ {{-23170/*-0.707107 Q15*/, -23170/*-0.707107 Q15*/}},
+ {{-27246/*-0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}}
+};
+
+const PWord16 w5N8[15] =
+{
+ {{ 31786/*0.970031 Q15*/, -7962/*-0.242980 Q15*/}},
+ {{ 28899/*0.881921 Q15*/, -15447/*-0.471397 Q15*/}},
+ {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}},
+ {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}},
+ {{ 11039/*0.336890 Q15*/, -30853/*-0.941544 Q15*/}},
+ {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}},
+ {{ -4808/*-0.146730 Q15*/, -32413/*-0.989177 Q15*/}},
+ {{-12540/*-0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{-19520/*-0.595699 Q15*/, -26320/*-0.803208 Q15*/}},
+ {{-25330/*-0.773010 Q15*/, -20788/*-0.634393 Q15*/}},
+ {{-29622/*-0.903989 Q15*/, -14010/*-0.427555 Q15*/}},
+ {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{-32729/*-0.998795 Q15*/, 1608/*0.049068 Q15*/}},
+ {{-31357/*-0.956940 Q15*/, 9512/*0.290285 Q15*/}},
+ {{-28106/*-0.857729 Q15*/, 16846/*0.514103 Q15*/}}
+};
+
+const PWord16 w6N8[15] =
+{
+ {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}},
+ {{ 27246/*0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}},
+ {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{ 3212/*0.098017 Q15*/, -32610/*-0.995185 Q15*/}},
+ {{ -6393/*-0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{-23170/*-0.707107 Q15*/, -23170/*-0.707107 Q15*/}},
+ {{-28899/*-0.881921 Q15*/, -15447/*-0.471397 Q15*/}},
+ {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{-32610/*-0.995185 Q15*/, 3212/*0.098017 Q15*/}},
+ {{-30274/*-0.923880 Q15*/, 12540/*0.382683 Q15*/}},
+ {{-25330/*-0.773010 Q15*/, 20788/*0.634393 Q15*/}},
+ {{-18205/*-0.555570 Q15*/, 27246/*0.831470 Q15*/}},
+ {{ -9512/*-0.290285 Q15*/, 31357/*0.956940 Q15*/}}
+};
+
+const PWord16 w7N8[15] =
+{
+ {{ 30853/*0.941544 Q15*/, -11039/*-0.336890 Q15*/}},
+ {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}},
+ {{ 16846/*0.514103 Q15*/, -28106/*-0.857729 Q15*/}},
+ {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{ -4808/*-0.146730 Q15*/, -32413/*-0.989177 Q15*/}},
+ {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{-24279/*-0.740951 Q15*/, -22006/*-0.671559 Q15*/}},
+ {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{-32729/*-0.998795 Q15*/, -1608/*-0.049068 Q15*/}},
+ {{-31357/*-0.956940 Q15*/, 9512/*0.290285 Q15*/}},
+ {{-26320/*-0.803208 Q15*/, 19520/*0.595699 Q15*/}},
+ {{-18205/*-0.555570 Q15*/, 27246/*0.831470 Q15*/}},
+ {{ -7962/*-0.242980 Q15*/, 31786/*0.970031 Q15*/}},
+ {{ 3212/*0.098017 Q15*/, 32610/*0.995185 Q15*/}},
+ {{ 14010/*0.427555 Q15*/, 29622/*0.903989 Q15*/}}
+};
+
+const PWord16 *w_a[7] = {w1N8, w2N8, w3N8, w4N8, w5N8, w6N8, w7N8};
+
+const PWord16 w19N[127] =
+{
+ {{ 31881/*0.972940 Q15*/, 7571/*0.231058 Q15*/}},
+ {{ 29269/*0.893224 Q15*/, 14733/*0.449611 Q15*/}},
+ {{ 25073/*0.765167 Q15*/, 21097/*0.643832 Q15*/}},
+ {{ 19520/*0.595699 Q15*/, 26320/*0.803208 Q15*/}},
+ {{ 12910/*0.393992 Q15*/, 30118/*0.919114 Q15*/}},
+ {{ 5602/*0.170962 Q15*/, 32286/*0.985278 Q15*/}},
+ {{ -2009/*-0.061321 Q15*/, 32706/*0.998118 Q15*/}},
+ {{ -9512/*-0.290285 Q15*/, 31357/*0.956940 Q15*/}},
+ {{-16500/*-0.503538 Q15*/, 28311/*0.863973 Q15*/}},
+ {{-22595/*-0.689541 Q15*/, 23732/*0.724247 Q15*/}},
+ {{-27467/*-0.838225 Q15*/, 17869/*0.545325 Q15*/}},
+ {{-30853/*-0.941544 Q15*/, 11039/*0.336890 Q15*/}},
+ {{-32568/*-0.993907 Q15*/, 3612/*0.110222 Q15*/}},
+ {{-32522/*-0.992480 Q15*/, -4011/*-0.122411 Q15*/}},
+ {{-30715/*-0.937339 Q15*/, -11417/*-0.348419 Q15*/}},
+ {{-27246/*-0.831470 Q15*/, -18205/*-0.555570 Q15*/}},
+ {{-22302/*-0.680601 Q15*/, -24008/*-0.732654 Q15*/}},
+ {{-16151/*-0.492898 Q15*/, -28511/*-0.870087 Q15*/}},
+ {{ -9127/*-0.278520 Q15*/, -31471/*-0.960431 Q15*/}},
+ {{ -1608/*-0.049068 Q15*/, -32729/*-0.998795 Q15*/}},
+ {{ 5998/*0.183040 Q15*/, -32214/*-0.983105 Q15*/}},
+ {{ 13279/*0.405241 Q15*/, -29957/*-0.914210 Q15*/}},
+ {{ 19841/*0.605511 Q15*/, -26078/*-0.795837 Q15*/}},
+ {{ 25330/*0.773010 Q15*/, -20788/*-0.634393 Q15*/}},
+ {{ 29448/*0.898674 Q15*/, -14373/*-0.438616 Q15*/}},
+ {{ 31972/*0.975702 Q15*/, -7180/*-0.219101 Q15*/}},
+ {{ 32766/*0.999925 Q15*/, 402/*0.012272 Q15*/}},
+ {{ 31786/*0.970031 Q15*/, 7962/*0.242980 Q15*/}},
+ {{ 29086/*0.887640 Q15*/, 15091/*0.460539 Q15*/}},
+ {{ 24812/*0.757209 Q15*/, 21403/*0.653173 Q15*/}},
+ {{ 19195/*0.585798 Q15*/, 26557/*0.810457 Q15*/}},
+ {{ 12540/*0.382683 Q15*/, 30274/*0.923880 Q15*/}},
+ {{ 5205/*0.158858 Q15*/, 32352/*0.987301 Q15*/}},
+ {{ -2411/*-0.073565 Q15*/, 32679/*0.997290 Q15*/}},
+ {{ -9896/*-0.302006 Q15*/, 31238/*0.953306 Q15*/}},
+ {{-16846/*-0.514103 Q15*/, 28106/*0.857729 Q15*/}},
+ {{-22884/*-0.698376 Q15*/, 23453/*0.715731 Q15*/}},
+ {{-27684/*-0.844854 Q15*/, 17531/*0.534998 Q15*/}},
+ {{-30986/*-0.945607 Q15*/, 10660/*0.325310 Q15*/}},
+ {{-32610/*-0.995185 Q15*/, 3212/*0.098017 Q15*/}},
+ {{-32470/*-0.990903 Q15*/, -4410/*-0.134581 Q15*/}},
+ {{-30572/*-0.932993 Q15*/, -11793/*-0.359895 Q15*/}},
+ {{-27020/*-0.824589 Q15*/, -18538/*-0.565732 Q15*/}},
+ {{-22006/*-0.671559 Q15*/, -24279/*-0.740951 Q15*/}},
+ {{-15800/*-0.482184 Q15*/, -28707/*-0.876070 Q15*/}},
+ {{ -8740/*-0.266713 Q15*/, -31581/*-0.963776 Q15*/}},
+ {{ -1206/*-0.036807 Q15*/, -32746/*-0.999322 Q15*/}},
+ {{ 6393/*0.195090 Q15*/, -32138/*-0.980785 Q15*/}},
+ {{ 13646/*0.416430 Q15*/, -29792/*-0.909168 Q15*/}},
+ {{ 20160/*0.615232 Q15*/, -25833/*-0.788346 Q15*/}},
+ {{ 25583/*0.780737 Q15*/, -20475/*-0.624859 Q15*/}},
+ {{ 29622/*0.903989 Q15*/, -14010/*-0.427555 Q15*/}},
+ {{ 32057/*0.978317 Q15*/, -6787/*-0.207111 Q15*/}},
+ {{ 32758/*0.999699 Q15*/, 804/*0.024541 Q15*/}},
+ {{ 31686/*0.966976 Q15*/, 8351/*0.254866 Q15*/}},
+ {{ 28899/*0.881921 Q15*/, 15447/*0.471397 Q15*/}},
+ {{ 24548/*0.749136 Q15*/, 21706/*0.662416 Q15*/}},
+ {{ 18868/*0.575808 Q15*/, 26791/*0.817585 Q15*/}},
+ {{ 12167/*0.371317 Q15*/, 30425/*0.928506 Q15*/}},
+ {{ 4808/*0.146730 Q15*/, 32413/*0.989177 Q15*/}},
+ {{ -2811/*-0.085797 Q15*/, 32647/*0.996313 Q15*/}},
+ {{-10279/*-0.313682 Q15*/, 31114/*0.949528 Q15*/}},
+ {{-17190/*-0.524590 Q15*/, 27897/*0.851355 Q15*/}},
+ {{-23170/*-0.707107 Q15*/, 23170/*0.707107 Q15*/}},
+ {{-27897/*-0.851355 Q15*/, 17190/*0.524590 Q15*/}},
+ {{-31114/*-0.949528 Q15*/, 10279/*0.313682 Q15*/}},
+ {{-32647/*-0.996313 Q15*/, 2811/*0.085797 Q15*/}},
+ {{-32413/*-0.989177 Q15*/, -4808/*-0.146730 Q15*/}},
+ {{-30425/*-0.928506 Q15*/, -12167/*-0.371317 Q15*/}},
+ {{-26791/*-0.817585 Q15*/, -18868/*-0.575808 Q15*/}},
+ {{-21706/*-0.662416 Q15*/, -24548/*-0.749136 Q15*/}},
+ {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{ -8351/*-0.254866 Q15*/, -31686/*-0.966976 Q15*/}},
+ {{ -804/*-0.024541 Q15*/, -32758/*-0.999699 Q15*/}},
+ {{ 6787/*0.207111 Q15*/, -32057/*-0.978317 Q15*/}},
+ {{ 14010/*0.427555 Q15*/, -29622/*-0.903989 Q15*/}},
+ {{ 20475/*0.624859 Q15*/, -25583/*-0.780737 Q15*/}},
+ {{ 25833/*0.788346 Q15*/, -20160/*-0.615232 Q15*/}},
+ {{ 29792/*0.909168 Q15*/, -13646/*-0.416430 Q15*/}},
+ {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{ 32746/*0.999322 Q15*/, 1206/*0.036807 Q15*/}},
+ {{ 31581/*0.963776 Q15*/, 8740/*0.266713 Q15*/}},
+ {{ 28707/*0.876070 Q15*/, 15800/*0.482184 Q15*/}},
+ {{ 24279/*0.740951 Q15*/, 22006/*0.671559 Q15*/}},
+ {{ 18538/*0.565732 Q15*/, 27020/*0.824589 Q15*/}},
+ {{ 11793/*0.359895 Q15*/, 30572/*0.932993 Q15*/}},
+ {{ 4410/*0.134581 Q15*/, 32470/*0.990903 Q15*/}},
+ {{ -3212/*-0.098017 Q15*/, 32610/*0.995185 Q15*/}},
+ {{-10660/*-0.325310 Q15*/, 30986/*0.945607 Q15*/}},
+ {{-17531/*-0.534998 Q15*/, 27684/*0.844854 Q15*/}},
+ {{-23453/*-0.715731 Q15*/, 22884/*0.698376 Q15*/}},
+ {{-28106/*-0.857729 Q15*/, 16846/*0.514103 Q15*/}},
+ {{-31238/*-0.953306 Q15*/, 9896/*0.302006 Q15*/}},
+ {{-32679/*-0.997290 Q15*/, 2411/*0.073565 Q15*/}},
+ {{-32352/*-0.987301 Q15*/, -5205/*-0.158858 Q15*/}},
+ {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{-26557/*-0.810457 Q15*/, -19195/*-0.585798 Q15*/}},
+ {{-21403/*-0.653173 Q15*/, -24812/*-0.757209 Q15*/}},
+ {{-15091/*-0.460539 Q15*/, -29086/*-0.887640 Q15*/}},
+ {{ -7962/*-0.242980 Q15*/, -31786/*-0.970031 Q15*/}},
+ {{ -402/*-0.012272 Q15*/, -32766/*-0.999925 Q15*/}},
+ {{ 7180/*0.219101 Q15*/, -31972/*-0.975702 Q15*/}},
+ {{ 14373/*0.438616 Q15*/, -29448/*-0.898674 Q15*/}},
+ {{ 20788/*0.634393 Q15*/, -25330/*-0.773010 Q15*/}},
+ {{ 26078/*0.795837 Q15*/, -19841/*-0.605511 Q15*/}},
+ {{ 29957/*0.914210 Q15*/, -13279/*-0.405241 Q15*/}},
+ {{ 32214/*0.983105 Q15*/, -5998/*-0.183040 Q15*/}},
+ {{ 32729/*0.998795 Q15*/, 1608/*0.049068 Q15*/}},
+ {{ 31471/*0.960431 Q15*/, 9127/*0.278520 Q15*/}},
+ {{ 28511/*0.870087 Q15*/, 16151/*0.492898 Q15*/}},
+ {{ 24008/*0.732654 Q15*/, 22302/*0.680601 Q15*/}},
+ {{ 18205/*0.555570 Q15*/, 27246/*0.831470 Q15*/}},
+ {{ 11417/*0.348419 Q15*/, 30715/*0.937339 Q15*/}},
+ {{ 4011/*0.122411 Q15*/, 32522/*0.992480 Q15*/}},
+ {{ -3612/*-0.110222 Q15*/, 32568/*0.993907 Q15*/}},
+ {{-11039/*-0.336890 Q15*/, 30853/*0.941544 Q15*/}},
+ {{-17869/*-0.545325 Q15*/, 27467/*0.838225 Q15*/}},
+ {{-23732/*-0.724247 Q15*/, 22595/*0.689541 Q15*/}},
+ {{-28311/*-0.863973 Q15*/, 16500/*0.503538 Q15*/}},
+ {{-31357/*-0.956940 Q15*/, 9512/*0.290285 Q15*/}},
+ {{-32706/*-0.998118 Q15*/, 2009/*0.061321 Q15*/}},
+ {{-32286/*-0.985278 Q15*/, -5602/*-0.170962 Q15*/}},
+ {{-30118/*-0.919114 Q15*/, -12910/*-0.393992 Q15*/}},
+ {{-26320/*-0.803208 Q15*/, -19520/*-0.595699 Q15*/}},
+ {{-21097/*-0.643832 Q15*/, -25073/*-0.765167 Q15*/}},
+ {{-14733/*-0.449611 Q15*/, -29269/*-0.893224 Q15*/}},
+ {{ -7571/*-0.231058 Q15*/, -31881/*-0.972940 Q15*/}}
+};
+
+const PWord16 w18N[127] =
+{
+ {{ 31972/*0.975702 Q15*/, 7180/*0.219101 Q15*/}},
+ {{ 29622/*0.903989 Q15*/, 14010/*0.427555 Q15*/}},
+ {{ 25833/*0.788346 Q15*/, 20160/*0.615232 Q15*/}},
+ {{ 20788/*0.634393 Q15*/, 25330/*0.773010 Q15*/}},
+ {{ 14733/*0.449611 Q15*/, 29269/*0.893224 Q15*/}},
+ {{ 7962/*0.242980 Q15*/, 31786/*0.970031 Q15*/}},
+ {{ 804/*0.024541 Q15*/, 32758/*0.999699 Q15*/}},
+ {{ -6393/*-0.195090 Q15*/, 32138/*0.980785 Q15*/}},
+ {{-13279/*-0.405241 Q15*/, 29957/*0.914210 Q15*/}},
+ {{-19520/*-0.595699 Q15*/, 26320/*0.803208 Q15*/}},
+ {{-24812/*-0.757209 Q15*/, 21403/*0.653173 Q15*/}},
+ {{-28899/*-0.881921 Q15*/, 15447/*0.471397 Q15*/}},
+ {{-31581/*-0.963776 Q15*/, 8740/*0.266713 Q15*/}},
+ {{-32729/*-0.998795 Q15*/, 1608/*0.049068 Q15*/}},
+ {{-32286/*-0.985278 Q15*/, -5602/*-0.170962 Q15*/}},
+ {{-30274/*-0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{-26791/*-0.817585 Q15*/, -18868/*-0.575808 Q15*/}},
+ {{-22006/*-0.671559 Q15*/, -24279/*-0.740951 Q15*/}},
+ {{-16151/*-0.492898 Q15*/, -28511/*-0.870087 Q15*/}},
+ {{ -9512/*-0.290285 Q15*/, -31357/*-0.956940 Q15*/}},
+ {{ -2411/*-0.073565 Q15*/, -32679/*-0.997290 Q15*/}},
+ {{ 4808/*0.146730 Q15*/, -32413/*-0.989177 Q15*/}},
+ {{ 11793/*0.359895 Q15*/, -30572/*-0.932993 Q15*/}},
+ {{ 18205/*0.555570 Q15*/, -27246/*-0.831470 Q15*/}},
+ {{ 23732/*0.724247 Q15*/, -22595/*-0.689541 Q15*/}},
+ {{ 28106/*0.857729 Q15*/, -16846/*-0.514103 Q15*/}},
+ {{ 31114/*0.949528 Q15*/, -10279/*-0.313682 Q15*/}},
+ {{ 32610/*0.995185 Q15*/, -3212/*-0.098017 Q15*/}},
+ {{ 32522/*0.992480 Q15*/, 4011/*0.122411 Q15*/}},
+ {{ 30853/*0.941544 Q15*/, 11039/*0.336890 Q15*/}},
+ {{ 27684/*0.844854 Q15*/, 17531/*0.534998 Q15*/}},
+ {{ 23170/*0.707107 Q15*/, 23170/*0.707107 Q15*/}},
+ {{ 17531/*0.534998 Q15*/, 27684/*0.844854 Q15*/}},
+ {{ 11039/*0.336890 Q15*/, 30853/*0.941544 Q15*/}},
+ {{ 4011/*0.122411 Q15*/, 32522/*0.992480 Q15*/}},
+ {{ -3212/*-0.098017 Q15*/, 32610/*0.995185 Q15*/}},
+ {{-10279/*-0.313682 Q15*/, 31114/*0.949528 Q15*/}},
+ {{-16846/*-0.514103 Q15*/, 28106/*0.857729 Q15*/}},
+ {{-22595/*-0.689541 Q15*/, 23732/*0.724247 Q15*/}},
+ {{-27246/*-0.831470 Q15*/, 18205/*0.555570 Q15*/}},
+ {{-30572/*-0.932993 Q15*/, 11793/*0.359895 Q15*/}},
+ {{-32413/*-0.989177 Q15*/, 4808/*0.146730 Q15*/}},
+ {{-32679/*-0.997290 Q15*/, -2411/*-0.073565 Q15*/}},
+ {{-31357/*-0.956940 Q15*/, -9512/*-0.290285 Q15*/}},
+ {{-28511/*-0.870087 Q15*/, -16151/*-0.492898 Q15*/}},
+ {{-24279/*-0.740951 Q15*/, -22006/*-0.671559 Q15*/}},
+ {{-18868/*-0.575808 Q15*/, -26791/*-0.817585 Q15*/}},
+ {{-12540/*-0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{ -5602/*-0.170962 Q15*/, -32286/*-0.985278 Q15*/}},
+ {{ 1608/*0.049068 Q15*/, -32729/*-0.998795 Q15*/}},
+ {{ 8740/*0.266713 Q15*/, -31581/*-0.963776 Q15*/}},
+ {{ 15447/*0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{ 21403/*0.653173 Q15*/, -24812/*-0.757209 Q15*/}},
+ {{ 26320/*0.803208 Q15*/, -19520/*-0.595699 Q15*/}},
+ {{ 29957/*0.914210 Q15*/, -13279/*-0.405241 Q15*/}},
+ {{ 32138/*0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{ 32758/*0.999699 Q15*/, 804/*0.024541 Q15*/}},
+ {{ 31786/*0.970031 Q15*/, 7962/*0.242980 Q15*/}},
+ {{ 29269/*0.893224 Q15*/, 14733/*0.449611 Q15*/}},
+ {{ 25330/*0.773010 Q15*/, 20788/*0.634393 Q15*/}},
+ {{ 20160/*0.615232 Q15*/, 25833/*0.788346 Q15*/}},
+ {{ 14010/*0.427555 Q15*/, 29622/*0.903989 Q15*/}},
+ {{ 7180/*0.219101 Q15*/, 31972/*0.975702 Q15*/}},
+ {{ 0/*0.000000 Q15*/, 32767/*1.000000 Q15*/}},
+ {{ -7180/*-0.219101 Q15*/, 31972/*0.975702 Q15*/}},
+ {{-14010/*-0.427555 Q15*/, 29622/*0.903989 Q15*/}},
+ {{-20160/*-0.615232 Q15*/, 25833/*0.788346 Q15*/}},
+ {{-25330/*-0.773010 Q15*/, 20788/*0.634393 Q15*/}},
+ {{-29269/*-0.893224 Q15*/, 14733/*0.449611 Q15*/}},
+ {{-31786/*-0.970031 Q15*/, 7962/*0.242980 Q15*/}},
+ {{-32758/*-0.999699 Q15*/, 804/*0.024541 Q15*/}},
+ {{-32138/*-0.980785 Q15*/, -6393/*-0.195090 Q15*/}},
+ {{-29957/*-0.914210 Q15*/, -13279/*-0.405241 Q15*/}},
+ {{-26320/*-0.803208 Q15*/, -19520/*-0.595699 Q15*/}},
+ {{-21403/*-0.653173 Q15*/, -24812/*-0.757209 Q15*/}},
+ {{-15447/*-0.471397 Q15*/, -28899/*-0.881921 Q15*/}},
+ {{ -8740/*-0.266713 Q15*/, -31581/*-0.963776 Q15*/}},
+ {{ -1608/*-0.049068 Q15*/, -32729/*-0.998795 Q15*/}},
+ {{ 5602/*0.170962 Q15*/, -32286/*-0.985278 Q15*/}},
+ {{ 12540/*0.382683 Q15*/, -30274/*-0.923880 Q15*/}},
+ {{ 18868/*0.575808 Q15*/, -26791/*-0.817585 Q15*/}},
+ {{ 24279/*0.740951 Q15*/, -22006/*-0.671559 Q15*/}},
+ {{ 28511/*0.870087 Q15*/, -16151/*-0.492898 Q15*/}},
+ {{ 31357/*0.956940 Q15*/, -9512/*-0.290285 Q15*/}},
+ {{ 32679/*0.997290 Q15*/, -2411/*-0.073565 Q15*/}},
+ {{ 32413/*0.989177 Q15*/, 4808/*0.146730 Q15*/}},
+ {{ 30572/*0.932993 Q15*/, 11793/*0.359895 Q15*/}},
+ {{ 27246/*0.831470 Q15*/, 18205/*0.555570 Q15*/}},
+ {{ 22595/*0.689541 Q15*/, 23732/*0.724247 Q15*/}},
+ {{ 16846/*0.514103 Q15*/, 28106/*0.857729 Q15*/}},
+ {{ 10279/*0.313682 Q15*/, 31114/*0.949528 Q15*/}},
+ {{ 3212/*0.098017 Q15*/, 32610/*0.995185 Q15*/}},
+ {{ -4011/*-0.122411 Q15*/, 32522/*0.992480 Q15*/}},
+ {{-11039/*-0.336890 Q15*/, 30853/*0.941544 Q15*/}},
+ {{-17531/*-0.534998 Q15*/, 27684/*0.844854 Q15*/}},
+ {{-23170/*-0.707107 Q15*/, 23170/*0.707107 Q15*/}},
+ {{-27684/*-0.844854 Q15*/, 17531/*0.534998 Q15*/}},
+ {{-30853/*-0.941544 Q15*/, 11039/*0.336890 Q15*/}},
+ {{-32522/*-0.992480 Q15*/, 4011/*0.122411 Q15*/}},
+ {{-32610/*-0.995185 Q15*/, -3212/*-0.098017 Q15*/}},
+ {{-31114/*-0.949528 Q15*/, -10279/*-0.313682 Q15*/}},
+ {{-28106/*-0.857729 Q15*/, -16846/*-0.514103 Q15*/}},
+ {{-23732/*-0.724247 Q15*/, -22595/*-0.689541 Q15*/}},
+ {{-18205/*-0.555570 Q15*/, -27246/*-0.831470 Q15*/}},
+ {{-11793/*-0.359895 Q15*/, -30572/*-0.932993 Q15*/}},
+ {{ -4808/*-0.146730 Q15*/, -32413/*-0.989177 Q15*/}},
+ {{ 2411/*0.073565 Q15*/, -32679/*-0.997290 Q15*/}},
+ {{ 9512/*0.290285 Q15*/, -31357/*-0.956940 Q15*/}},
+ {{ 16151/*0.492898 Q15*/, -28511/*-0.870087 Q15*/}},
+ {{ 22006/*0.671559 Q15*/, -24279/*-0.740951 Q15*/}},
+ {{ 26791/*0.817585 Q15*/, -18868/*-0.575808 Q15*/}},
+ {{ 30274/*0.923880 Q15*/, -12540/*-0.382683 Q15*/}},
+ {{ 32286/*0.985278 Q15*/, -5602/*-0.170962 Q15*/}},
+ {{ 32729/*0.998795 Q15*/, 1608/*0.049068 Q15*/}},
+ {{ 31581/*0.963776 Q15*/, 8740/*0.266713 Q15*/}},
+ {{ 28899/*0.881921 Q15*/, 15447/*0.471397 Q15*/}},
+ {{ 24812/*0.757209 Q15*/, 21403/*0.653173 Q15*/}},
+ {{ 19520/*0.595699 Q15*/, 26320/*0.803208 Q15*/}},
+ {{ 13279/*0.405241 Q15*/, 29957/*0.914210 Q15*/}},
+ {{ 6393/*0.195090 Q15*/, 32138/*0.980785 Q15*/}},
+ {{ -804/*-0.024541 Q15*/, 32758/*0.999699 Q15*/}},
+ {{ -7962/*-0.242980 Q15*/, 31786/*0.970031 Q15*/}},
+ {{-14733/*-0.449611 Q15*/, 29269/*0.893224 Q15*/}},
+ {{-20788/*-0.634393 Q15*/, 25330/*0.773010 Q15*/}},
+ {{-25833/*-0.788346 Q15*/, 20160/*0.615232 Q15*/}},
+ {{-29622/*-0.903989 Q15*/, 14010/*0.427555 Q15*/}},
+ {{-31972/*-0.975702 Q15*/, 7180/*0.219101 Q15*/}}
+};
+
+const Word16 kLog2TableFrac_x[256] =
+{
+ 0, 1, 3, 4, 6, 7, 9, 10,
+ 11, 13, 14, 16, 17, 18, 20, 21,
+ 22, 24, 25, 26, 28, 29, 30, 32,
+ 33, 34, 36, 37, 38, 40, 41, 42,
+ 44, 45, 46, 47, 49, 50, 51, 52,
+ 54, 55, 56, 57, 59, 60, 61, 62,
+ 63, 65, 66, 67, 68, 69, 71, 72,
+ 73, 74, 75, 77, 78, 79, 80, 81,
+ 82, 84, 85, 86, 87, 88, 89, 90,
+ 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 102, 103, 104, 105, 106, 107, 108,
+ 109, 110, 111, 112, 113, 114, 116, 117,
+ 118, 119, 120, 121, 122, 123, 124, 125,
+ 126, 127, 128, 129, 130, 131, 132, 133,
+ 134, 135, 136, 137, 138, 139, 140, 141,
+ 142, 143, 144, 145, 146, 147, 148, 149,
+ 150, 151, 152, 153, 154, 155, 155, 156,
+ 157, 158, 159, 160, 161, 162, 163, 164,
+ 165, 166, 167, 168, 169, 169, 170, 171,
+ 172, 173, 174, 175, 176, 177, 178, 178,
+ 179, 180, 181, 182, 183, 184, 185, 185,
+ 186, 187, 188, 189, 190, 191, 192, 192,
+ 193, 194, 195, 196, 197, 198, 198, 199,
+ 200, 201, 202, 203, 203, 204, 205, 206,
+ 207, 208, 208, 209, 210, 211, 212, 212,
+ 213, 214, 215, 216, 216, 217, 218, 219,
+ 220, 220, 221, 222, 223, 224, 224, 225,
+ 226, 227, 228, 228, 229, 230, 231, 231,
+ 232, 233, 234, 234, 235, 236, 237, 238,
+ 238, 239, 240, 241, 241, 242, 243, 244,
+ 244, 245, 246, 247, 247, 248, 249, 249,
+ 250, 251, 252, 252, 253, 254, 255, 255
+};
+
+const Word16 kExp2TableFrac_x[256] = /* Q15 */
+{
+ 32767, 32678, 32590, 32502, 32414, 32326, 32239, 32152,
+ 32065, 31978, 31892, 31805, 31719, 31634, 31548, 31463,
+ 31378, 31293, 31208, 31124, 31040, 30956, 30872, 30789,
+ 30705, 30622, 30540, 30457, 30375, 30293, 30211, 30129,
+ 30047, 29966, 29885, 29804, 29724, 29643, 29563, 29483,
+ 29404, 29324, 29245, 29166, 29087, 29008, 28930, 28852,
+ 28774, 28696, 28618, 28541, 28464, 28387, 28310, 28233,
+ 28157, 28081, 28005, 27929, 27854, 27778, 27703, 27628,
+ 27554, 27479, 27405, 27331, 27257, 27183, 27110, 27036,
+ 26963, 26890, 26818, 26745, 26673, 26601, 26529, 26457,
+ 26385, 26314, 26243, 26172, 26101, 26031, 25960, 25890,
+ 25820, 25750, 25681, 25611, 25542, 25473, 25404, 25335,
+ 25267, 25198, 25130, 25062, 24995, 24927, 24860, 24792,
+ 24725, 24659, 24592, 24525, 24459, 24393, 24327, 24261,
+ 24196, 24130, 24065, 24000, 23935, 23870, 23806, 23741,
+ 23677, 23613, 23549, 23486, 23422, 23359, 23296, 23233,
+ 23170, 23107, 23045, 22982, 22920, 22858, 22796, 22735,
+ 22673, 22612, 22551, 22490, 22429, 22368, 22308, 22248,
+ 22187, 22127, 22068, 22008, 21948, 21889, 21830, 21771,
+ 21712, 21653, 21595, 21536, 21478, 21420, 21362, 21304,
+ 21247, 21189, 21132, 21075, 21018, 20961, 20904, 20848,
+ 20791, 20735, 20679, 20623, 20568, 20512, 20456, 20401,
+ 20346, 20291, 20236, 20181, 20127, 20072, 20018, 19964,
+ 19910, 19856, 19802, 19749, 19696, 19642, 19589, 19536,
+ 19483, 19431, 19378, 19326, 19274, 19221, 19169, 19118,
+ 19066, 19014, 18963, 18912, 18861, 18810, 18759, 18708,
+ 18657, 18607, 18557, 18506, 18456, 18406, 18357, 18307,
+ 18258, 18208, 18159, 18110, 18061, 18012, 17963, 17915,
+ 17866, 17818, 17770, 17722, 17674, 17626, 17578, 17531,
+ 17483, 17436, 17389, 17342, 17295, 17248, 17202, 17155,
+ 17109, 17063, 17016, 16970, 16925, 16879, 16833, 16788,
+ 16742, 16697, 16652, 16607, 16562, 16517, 16472, 16428
+};
+
+const Word16 sqrt_table_pitch_search[256+1] = /* Q11 */
+{
+ 0, 2048, 2896, 3547, 4096, 4579, 5017, 5418,
+ 5793, 6144, 6476, 6792, 7094, 7384, 7663, 7932,
+ 8192, 8444, 8689, 8927, 9159, 9385, 9606, 9822,
+ 10033, 10240, 10443, 10642, 10837, 11029, 11217, 11403,
+ 11585, 11765, 11942, 12116, 12288, 12457, 12625, 12790,
+ 12953, 13114, 13273, 13430, 13585, 13738, 13890, 14040,
+ 14189, 14336, 14482, 14626, 14768, 14910, 15050, 15188,
+ 15326, 15462, 15597, 15731, 15864, 15995, 16126, 16255,
+ 16384, 16512, 16638, 16764, 16888, 17012, 17135, 17257,
+ 17378, 17498, 17618, 17736, 17854, 17971, 18087, 18203,
+ 18318, 18432, 18545, 18658, 18770, 18882, 18992, 19102,
+ 19212, 19321, 19429, 19537, 19644, 19750, 19856, 19961,
+ 20066, 20170, 20274, 20377, 20480, 20582, 20684, 20785,
+ 20886, 20986, 21085, 21185, 21283, 21382, 21480, 21577,
+ 21674, 21771, 21867, 21962, 22058, 22153, 22247, 22341,
+ 22435, 22528, 22621, 22713, 22806, 22897, 22989, 23080,
+ 23170, 23261, 23351, 23440, 23530, 23619, 23707, 23796,
+ 23884, 23971, 24059, 24146, 24232, 24319, 24405, 24491,
+ 24576, 24661, 24746, 24831, 24915, 24999, 25083, 25166,
+ 25249, 25332, 25415, 25497, 25580, 25661, 25743, 25824,
+ 25905, 25986, 26067, 26147, 26227, 26307, 26387, 26466,
+ 26545, 26624, 26703, 26781, 26859, 26937, 27015, 27092,
+ 27170, 27247, 27324, 27400, 27477, 27553, 27629, 27705,
+ 27780, 27856, 27931, 28006, 28081, 28155, 28230, 28304,
+ 28378, 28452, 28525, 28599, 28672, 28745, 28818, 28891,
+ 28963, 29035, 29108, 29180, 29251, 29323, 29394, 29466,
+ 29537, 29608, 29678, 29749, 29819, 29890, 29960, 30030,
+ 30099, 30169, 30238, 30308, 30377, 30446, 30515, 30583,
+ 30652, 30720, 30788, 30856, 30924, 30992, 31059, 31127,
+ 31194, 31261, 31328, 31395, 31462, 31529, 31595, 31661,
+ 31727, 31794, 31859, 31925, 31991, 32056, 32122, 32187,
+ 32252, 32317, 32382, 32446, 32511, 32575, 32640, 32704,
+ 32766
+};
+
+
+/******************** moved over from tables_plus.c ************************/
+
+/* For bass post filter */
+const Word16 filt_lp[1+L_FILT] =
+{
+ 2892/*0.088250f Q15*/, 2831/*0.086410f Q15*/, 2657/*0.081074f Q15*/, 2384/*0.072768f Q15*/,
+ 2041/*0.062294f Q15*/, 1659/*0.050623f Q15*/, 1271/*0.038774f Q15*/, 907/*0.027692f Q15*/,
+ 594/*0.018130f Q15*/, 347/*0.010578f Q15*/, 171/*0.005221f Q15*/, 64/*0.001946f Q15*/,
+ 13/*0.000385f Q15*/
+};
+const Word16 filt_lp_16kHz[1+L_FILT16k] =
+{
+ 2340/*0.071410f Q15*/, 2308/*0.070433f Q15*/, 2214/*0.067568f Q15*/, 2064/*0.062999f Q15*/,
+ 1868/*0.057020f Q15*/, 1639/*0.050005f Q15*/, 1389/*0.042378f Q15*/, 1133/*0.034577f Q15*/,
+ 885/*0.027022f Q15*/, 658/*0.020078f Q15*/, 460/*0.014031f Q15*/, 297/*0.009070f Q15*/,
+ 173/*0.005276f Q15*/, 86/*0.002625f Q15*/, 33/*0.000999f Q15*/, 7/*0.000205f Q15*/
+};
+
+/* 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) */
+const Word16 pitch_inter4_2[PIT_FIR_SIZE2] =
+{
+ /* cut-off frequency at 0.94*fs/2 */
+ 30802/*0.940000f Q15*/,
+ 28062/*0.856390f Q15*/, 20718/*0.632268f Q15*/, 11061/*0.337560f Q15*/, 1936/*0.059072f Q15*/,
+ -4295/*-0.131059f Q15*/, -6534/*-0.199393f Q15*/, -5196/*-0.158569f Q15*/, -1847/*-0.056359f Q15*/,
+ 1560/*0.047606f Q15*/, 3498/*0.106749f Q15*/, 3398/*0.1037059f Q15*/, 1706/*0.052062f Q15*/,
+ -497/*-0.015182f Q15*/, -2087/*-0.063705f Q15*/, -2414/*-0.073660f Q15*/, -1524/*-0.046497f Q15*/,
+ -32/*-0.000983f Q15*/, 1253/*0.038227f Q15*/, 1741/*0.053143f Q15*/, 1313/*0.040059f Q15*/,
+ 305/*0.009308f Q15*/, -710/*-0.021674f Q15*/, -1238/*-0.037767f Q15*/, -1087/*-0.033186f Q15*/,
+ -427/*-0.013028f Q15*/, 351/*0.010702f Q15*/, 849/*0.025901f Q15*/, 862/*0.026318f Q15*/,
+ 453/*0.013821f Q15*/, -119/*-0.003645f Q15*/, -551/*-0.016813f Q15*/, -651/*-0.019855f Q15*/,
+ -418/*-0.012766f Q15*/, -17/*-0.000530f Q15*/, 330/*0.010080f Q15*/, 463/*0.014122f Q15*/,
+ 349/*0.010657f Q15*/, 85/*0.002594f Q15*/, -176/*-0.005363f Q15*/, -306/*-0.009344f Q15*/,
+ -265/*-0.008101f Q15*/, -104/*-0.003182f Q15*/, 76/*0.002330f Q15*/, 185/*0.005635f Q15*/,
+ 182/*0.005562f Q15*/, 93/*0.002844f Q15*/, -21/*-0.000627f Q15*/, -98/*-0.002993f Q15*/,
+ -110/*-0.003362f Q15*/, -67/*-0.002044f Q15*/, -4/*-0.000116f Q15*/, 43/*0.001315f Q15*/,
+ 55/*0.001692f Q15*/, 38/*0.001151f Q15*/, 8/*0.000259f Q15*/, -14/*-0.000417f Q15*/,
+ -20/*-0.000618f Q15*/, -14/*-0.000434f Q15*/, -4/*-0.000133f Q15*/, 2/*0.000063f Q15*/,
+ 3/*0.000098f Q15*/, 2/*0.000048f Q15*/, 0/*0.000007f Q15*/, 0/*0.000000f Q15*/
+};
+/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */
+const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] =
+{
+ 29491/*0.900000F Q15*/,
+ 26836/*0.818959F Q15*/, 19820/* 0.604850F Q15*/, 10859/* 0.331379F Q15*/, 2751/* 0.083958F Q15*/,
+ -2484/*-0.075795F Q15*/, -4283/* -0.130717F Q15*/, -3463/*-0.105685F Q15*/, -1533/*-0.046774F Q15*/,
+ 146/*0.004467F Q15*/, 911/* 0.027789F Q15*/, 840/* 0.025642F Q15*/, 412/* 0.012571F Q15*/,
+ 63/*0.001927F Q15*/, -51/* -0.001571F Q15*/, -25/*-0.000753F Q15*/, 0/* 0.000000f Q15*/
+};
+/* 1/6 resolution interpolation filter (-3 dB at 0.95*fs/2) */
+const Word16 pitch_inter6_2[PIT_FIR_SIZE6_2] =
+{
+ 31129/*0.949986374119862f Q15*/,
+ 29854/*0.911081104469830f Q15*/,
+ 26218/*0.800115099292852f Q15*/,
+ 20753/*0.633320673120883f Q15*/,
+ 14240/*0.434558462154083f Q15*/,
+ 7575/*0.231177017786780f Q15*/,
+ 1618/*0.049378173063717f Q15*/,
+ -2950/*-0.090039611811170f Q15*/,
+ -5727/*-0.174782560924477f Q15*/,
+ -6635/*-0.202477516286360f Q15*/,
+ -5905/*-0.180218293244902f Q15*/,
+ -4012/*-0.122429229978978f Q15*/,
+ -1558/*-0.047552067127379f Q15*/,
+ 843/*0.025733669494145f Q15*/,
+ 2687/*0.081995376731897f Q15*/,
+ 3656/*0.111581381838187f Q15*/,
+ 3663/*0.111781798292302f Q15*/,
+ 2834/*0.086499988914996f Q15*/,
+ 1462/*0.044629684447068f Q15*/,
+ -79/*-0.002416435594242f Q15*/,
+ -1423/*-0.043440027386915f Q15*/,
+ -2289/*-0.069857782812169f Q15*/,
+ -2533/*-0.077293683967992f Q15*/,
+ -2166/*-0.066098268486336f Q15*/,
+ -1336/*-0.040782649068098f Q15*/,
+ -282/*-0.008590773415008f Q15*/,
+ 734/*0.022397654632128f Q15*/,
+ 1480/*0.045171360007974f Q15*/,
+ 1811/*0.055274128677739f Q15*/,
+ 1690/*0.051578034020076f Q15*/,
+ 1187/*0.036232016917169f Q15*/,
+ 454/*0.013869500422767f Q15*/,
+ -317/*-0.009680698856947f Q15*/,
+ -945/*-0.028843394410080f Q15*/,
+ -1296/*-0.039560663181280f Q15*/,
+ -1314/*-0.040095747151623f Q15*/,
+ -1023/*-0.031231107680685f Q15*/,
+ -520/*-0.015866154815425f Q15*/,
+ 60/*0.001841532922707f Q15*/,
+ 575/*0.017553701334759f Q15*/,
+ 910/*0.027778555138199f Q15*/,
+ 1003/*0.030612329573745f Q15*/,
+ 853/*0.026046143652186f Q15*/,
+ 518/*0.015803012695681f Q15*/,
+ 91/*0.002782973481834f Q15*/,
+ -319/*-0.009720124055079f Q15*/,
+ -617/*-0.018826488463900f Q15*/,
+ -744/*-0.022710487805852f Q15*/,
+ -686/*-0.020936374578238f Q15*/,
+ -473/*-0.014436620433404f Q15*/,
+ -169/*-0.005169079181373f Q15*/,
+ 145/*0.004437651243491f Q15*/,
+ 397/*0.012100372954920f Q15*/,
+ 531/*0.016207075406240f Q15*/,
+ 529/*0.016135389123271f Q15*/,
+ 403/*0.012306629559665f Q15*/,
+ 196/*0.005986734945567f Q15*/,
+ -36/*-0.001094950878591f Q15*/,
+ -236/*-0.007200842219958f Q15*/,
+ -360/*-0.010998212848124f Q15*/,
+ -388/*-0.011835179448280f Q15*/,
+ -322/*-0.009826566540474f Q15*/,
+ -188/*-0.005747665080695f Q15*/,
+ -26/*-0.000780600030751f Q15*/,
+ 125/*0.003810613287985f Q15*/,
+ 229/*0.006990479233404f Q15*/,
+ 268/*0.008174249796791f Q15*/,
+ 240/*0.007317375965949f Q15*/,
+ 159/*0.004864690818765f Q15*/,
+ 52/*0.001587005259212f Q15*/,
+ -54/*-0.001642504305841f Q15*/,
+ -133/*-0.004070609517416f Q15*/,
+ -171/*-0.005230670504649f Q15*/,
+ -164/*-0.005019147682711f Q15*/,
+ -120/*-0.003673879223241f Q15*/,
+ -55/*-0.001671460853812f Q15*/,
+ 14/*0.000420750005150f Q15*/,
+ 69/*0.002095384947391f Q15*/,
+ 99/*0.003020513665060f Q15*/,
+ 101/*0.003095468528243f Q15*/,
+ 80/*0.002441025550729f Q15*/,
+ 44/*0.001335514431569f Q15*/,
+ 4/*0.000120805384516f Q15*/,
+ -29/*-0.000893340757369f Q15*/,
+ -49/*-0.001501610712267f Q15*/,
+ -54/*-0.001636887611783f Q15*/,
+ -45/*-0.001362571776250f Q15*/,
+ -27/*-0.000832126175863f Q15*/,
+ -8/*-0.000232033375863f Q15*/,
+ 9/*0.000273627139471f Q15*/,
+ 19/*0.000582092683087f Q15*/,
+ 22/*0.000666445711949f Q15*/,
+ 19/*0.000566088888178f Q15*/,
+ 12/*0.000360374058147f Q15*/,
+ 4/*0.000136306914913f Q15*/,
+ -1/*-0.000038864994777f Q15*/,
+ -4/*-0.000132755824518f Q15*/,
+ -5/*-0.000148377158880f Q15*/,
+ -4/*-0.000112937171810f Q15*/,
+ -2/*-0.000061132514471f Q15*/,
+ -1/*-0.000019974224468f Q15*/,
+ 0/*-0.000000460344975f Q15*/,
+ 0/*0.000001976848453f Q15*/
+};
+
+const Word16 grid50_fx[(GRID50_POINTS-1)/2 - 1] =
+{
+ 32703, 32510, 32188, 31739, 31164, 30467,
+ 29649, 28715, 27667, 26510, 25248, 23887,
+ 22431, 20887, 19261, 17558, 15786, 13952,
+ 12063, 10126, 8149, 6140, 4107, 2058
+};
+
+
+const Word16 grid40_fx[(GRID40_POINTS-1)/2 - 1] =
+{
+ 32667, 32365, 31863, 31164, 30274, 29197,
+ 27939, 26510, 24917, 23170, 21281, 19261,
+ 17121, 14876, 12540, 10126, 7650, 5126,
+ 2571
+};
+
+const Word16 bit_rates_div50[] = /* bit rate values / 50 to Fit in a Word16 */
+{
+ ACELP_7k20/50, ACELP_8k00/50, ACELP_11k60/50, ACELP_12k15/50,
+ ACELP_12k85/50, ACELP_13k20/50, ACELP_14k80/50, ACELP_16k40/50, ACELP_22k60/50,
+ ACELP_24k40/50, ACELP_29k00/50, ACELP_29k20/50, ACELP_30k20/50, ACELP_30k40/50,
+ ACELP_32k /50, ACELP_48k /50, ACELP_64k /50, HQ_96k /50, HQ_128k /50
+};
+
+const Word16 bit_rates_16k_div50[] = /* bit rate values / 50 to Fit in a Word16 */
+{
+ ACELP_8k00 /50, ACELP_14k80/50, ACELP_22k60/50, ACELP_24k40/50, ACELP_29k00/50,
+ ACELP_29k20/50, ACELP_30k20/50, ACELP_30k40/50, ACELP_32k /50, ACELP_48k /50, ACELP_64k /50
+};
+
+const Word16 L_frame_inv[8] = { 0x4000, 0x369D, 0x3333, 0x2D83, 0x2AAB, 0x28F6, 0, 0x2222 };
+
+const Word16 TecLowBandTable[] = {0, 2, 4, 6};
+const Word16 TecSC_Fx[] =
+{
+ 23999/*0.3662f*2.0f Q15*/, 7065/*0.1078f*2.0f Q15*/, 7825/*0.1194f*2.0f Q15*/,
+ 8448/*0.1289f*2.0f Q15*/, 8946/*0.1365f*2.0f Q15*/, 9254/*0.1412f*2.0f Q15*/
+};
+
+const Word16 uniform_model_fx[] = { MAX_AR_FREQ, MAX_AR_FREQ / 2, 0 };
+
+const Word16 RotVector_32[2*20] =
+{
+ /**
+ * \brief Twiddle factors are unscaled
+ */
+ SHC(0x7d8a), SHC(0xe707), SHC(0x7642), SHC(0xcf04), SHC(0x6a6e), SHC(0xb8e3), SHC(0x5a82), SHC(0xa57e),
+ SHC(0x471d), SHC(0x9592), SHC(0x30fc), SHC(0x89be), SHC(0x18f9), SHC(0x8276), SHC(0x7642), SHC(0xcf04),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x30fc), SHC(0x89be), SHC(0xcf04), SHC(0x89be), SHC(0xa57e), SHC(0xa57e),
+ SHC(0x89be), SHC(0xcf04), SHC(0x6a6e), SHC(0xb8e3), SHC(0x30fc), SHC(0x89be), SHC(0xe707), SHC(0x8276),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x8276), SHC(0xe707), SHC(0x89be), SHC(0x30fc), SHC(0xb8e3), SHC(0x6a6e)
+};
+
+/**
+ * \brief Twiddle factors are unscaled
+ */
+const Word16 RotVector_480[2*(480-30)] =
+{
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ff5), SHC(0xfca6),
+ SHC(0x7fd3), SHC(0xf94d), SHC(0x7f9b), SHC(0xf5f5), SHC(0x7f4c), SHC(0xf29f), SHC(0x7ee8), SHC(0xef4b),
+ SHC(0x7e6d), SHC(0xebfa), SHC(0x7ddb), SHC(0xe8ad), SHC(0x7d34), SHC(0xe563), SHC(0x7c77), SHC(0xe21e),
+ SHC(0x7ba3), SHC(0xdedf), SHC(0x7abb), SHC(0xdba5), SHC(0x79bc), SHC(0xd872), SHC(0x78a8), SHC(0xd546),
+ SHC(0x7780), SHC(0xd221), SHC(0x7642), SHC(0xcf04), SHC(0x74ef), SHC(0xcbf0), SHC(0x7388), SHC(0xc8e5),
+ SHC(0x720d), SHC(0xc5e4), SHC(0x707d), SHC(0xc2ec), SHC(0x6eda), SHC(0xc000), SHC(0x6d23), SHC(0xbd1f),
+ SHC(0x6b5a), SHC(0xba49), SHC(0x697d), SHC(0xb780), SHC(0x678e), SHC(0xb4c3), SHC(0x658d), SHC(0xb214),
+ SHC(0x637a), SHC(0xaf72), SHC(0x6155), SHC(0xacdf), SHC(0x5f1f), SHC(0xaa5a), SHC(0x5cd9), SHC(0xa7e4),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fd3), SHC(0xf94d), SHC(0x7f4c), SHC(0xf29f), SHC(0x7e6d), SHC(0xebfa),
+ SHC(0x7d34), SHC(0xe563), SHC(0x7ba3), SHC(0xdedf), SHC(0x79bc), SHC(0xd872), SHC(0x7780), SHC(0xd221),
+ SHC(0x74ef), SHC(0xcbf0), SHC(0x720d), SHC(0xc5e4), SHC(0x6eda), SHC(0xc000), SHC(0x6b5a), SHC(0xba49),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x637a), SHC(0xaf72), SHC(0x5f1f), SHC(0xaa5a), SHC(0x5a82), SHC(0xa57e),
+ SHC(0x55a6), SHC(0xa0e1), SHC(0x508e), SHC(0x9c86), SHC(0x4b3d), SHC(0x9872), SHC(0x45b7), SHC(0x94a6),
+ SHC(0x4000), SHC(0x9126), SHC(0x3a1c), SHC(0x8df3), SHC(0x3410), SHC(0x8b11), SHC(0x2ddf), SHC(0x8880),
+ SHC(0x278e), SHC(0x8644), SHC(0x2121), SHC(0x845d), SHC(0x1a9d), SHC(0x82cc), SHC(0x1406), SHC(0x8193),
+ SHC(0x0d61), SHC(0x80b4), SHC(0x06b3), SHC(0x802d), SHC(0x7fff), SHC(0x0000), SHC(0x7f9b), SHC(0xf5f5),
+ SHC(0x7e6d), SHC(0xebfa), SHC(0x7c77), SHC(0xe21e), SHC(0x79bc), SHC(0xd872), SHC(0x7642), SHC(0xcf04),
+ SHC(0x720d), SHC(0xc5e4), SHC(0x6d23), SHC(0xbd1f), SHC(0x678e), SHC(0xb4c3), SHC(0x6155), SHC(0xacdf),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x5321), SHC(0x9eab), SHC(0x4b3d), SHC(0x9872), SHC(0x42e1), SHC(0x92dd),
+ SHC(0x3a1c), SHC(0x8df3), SHC(0x30fc), SHC(0x89be), SHC(0x278e), SHC(0x8644), SHC(0x1de2), SHC(0x8389),
+ SHC(0x1406), SHC(0x8193), SHC(0x0a0b), SHC(0x8065), SHC(0x0000), SHC(0x8000), SHC(0xf5f5), SHC(0x8065),
+ SHC(0xebfa), SHC(0x8193), SHC(0xe21e), SHC(0x8389), SHC(0xd872), SHC(0x8644), SHC(0xcf04), SHC(0x89be),
+ SHC(0xc5e4), SHC(0x8df3), SHC(0xbd1f), SHC(0x92dd), SHC(0xb4c3), SHC(0x9872), SHC(0xacdf), SHC(0x9eab),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f4c), SHC(0xf29f), SHC(0x7d34), SHC(0xe563), SHC(0x79bc), SHC(0xd872),
+ SHC(0x74ef), SHC(0xcbf0), SHC(0x6eda), SHC(0xc000), SHC(0x678e), SHC(0xb4c3), SHC(0x5f1f), SHC(0xaa5a),
+ SHC(0x55a6), SHC(0xa0e1), SHC(0x4b3d), SHC(0x9872), SHC(0x4000), SHC(0x9126), SHC(0x3410), SHC(0x8b11),
+ SHC(0x278e), SHC(0x8644), SHC(0x1a9d), SHC(0x82cc), SHC(0x0d61), SHC(0x80b4), SHC(0x0000), SHC(0x8000),
+ SHC(0xf29f), SHC(0x80b4), SHC(0xe563), SHC(0x82cc), SHC(0xd872), SHC(0x8644), SHC(0xcbf0), SHC(0x8b11),
+ SHC(0xc000), SHC(0x9126), SHC(0xb4c3), SHC(0x9872), SHC(0xaa5a), SHC(0xa0e1), SHC(0xa0e1), SHC(0xaa5a),
+ SHC(0x9872), SHC(0xb4c3), SHC(0x9126), SHC(0xc000), SHC(0x8b11), SHC(0xcbf0), SHC(0x8644), SHC(0xd872),
+ SHC(0x82cc), SHC(0xe563), SHC(0x80b4), SHC(0xf29f), SHC(0x7fff), SHC(0x0000), SHC(0x7ee8), SHC(0xef4b),
+ SHC(0x7ba3), SHC(0xdedf), SHC(0x7642), SHC(0xcf04), SHC(0x6eda), SHC(0xc000), SHC(0x658d), SHC(0xb214),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x4dec), SHC(0x9a73), SHC(0x4000), SHC(0x9126), SHC(0x30fc), SHC(0x89be),
+ SHC(0x2121), SHC(0x845d), SHC(0x10b5), SHC(0x8118), SHC(0x0000), SHC(0x8000), SHC(0xef4b), SHC(0x8118),
+ SHC(0xdedf), SHC(0x845d), SHC(0xcf04), SHC(0x89be), SHC(0xc000), SHC(0x9126), SHC(0xb214), SHC(0x9a73),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x9a73), SHC(0xb214), SHC(0x9126), SHC(0xc000), SHC(0x89be), SHC(0xcf04),
+ SHC(0x845d), SHC(0xdedf), SHC(0x8118), SHC(0xef4b), SHC(0x8000), SHC(0x0000), SHC(0x8118), SHC(0x10b5),
+ SHC(0x845d), SHC(0x2121), SHC(0x89be), SHC(0x30fc), SHC(0x9126), SHC(0x4000), SHC(0x9a73), SHC(0x4dec),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e6d), SHC(0xebfa), SHC(0x79bc), SHC(0xd872), SHC(0x720d), SHC(0xc5e4),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x5a82), SHC(0xa57e), SHC(0x4b3d), SHC(0x9872), SHC(0x3a1c), SHC(0x8df3),
+ SHC(0x278e), SHC(0x8644), SHC(0x1406), SHC(0x8193), SHC(0x0000), SHC(0x8000), SHC(0xebfa), SHC(0x8193),
+ SHC(0xd872), SHC(0x8644), SHC(0xc5e4), SHC(0x8df3), SHC(0xb4c3), SHC(0x9872), SHC(0xa57e), SHC(0xa57e),
+ SHC(0x9872), SHC(0xb4c3), SHC(0x8df3), SHC(0xc5e4), SHC(0x8644), SHC(0xd872), SHC(0x8193), SHC(0xebfa),
+ SHC(0x8000), SHC(0x0000), SHC(0x8193), SHC(0x1406), SHC(0x8644), SHC(0x278e), SHC(0x8df3), SHC(0x3a1c),
+ SHC(0x9872), SHC(0x4b3d), SHC(0xa57e), SHC(0x5a82), SHC(0xb4c3), SHC(0x678e), SHC(0xc5e4), SHC(0x720d),
+ SHC(0xd872), SHC(0x79bc), SHC(0xebfa), SHC(0x7e6d), SHC(0x7fff), SHC(0x0000), SHC(0x7ddb), SHC(0xe8ad),
+ SHC(0x7780), SHC(0xd221), SHC(0x6d23), SHC(0xbd1f), SHC(0x5f1f), SHC(0xaa5a), SHC(0x4dec), SHC(0x9a73),
+ SHC(0x3a1c), SHC(0x8df3), SHC(0x245b), SHC(0x8545), SHC(0x0d61), SHC(0x80b4), SHC(0xf5f5), SHC(0x8065),
+ SHC(0xdedf), SHC(0x845d), SHC(0xc8e5), SHC(0x8c78), SHC(0xb4c3), SHC(0x9872), SHC(0xa327), SHC(0xa7e4),
+ SHC(0x94a6), SHC(0xba49), SHC(0x89be), SHC(0xcf04), SHC(0x82cc), SHC(0xe563), SHC(0x800b), SHC(0xfca6),
+ SHC(0x8193), SHC(0x1406), SHC(0x8758), SHC(0x2aba), SHC(0x9126), SHC(0x4000), SHC(0x9eab), SHC(0x5321),
+ SHC(0xaf72), SHC(0x637a), SHC(0xc2ec), SHC(0x707d), SHC(0xd872), SHC(0x79bc), SHC(0xef4b), SHC(0x7ee8),
+ SHC(0x06b3), SHC(0x7fd3), SHC(0x1de2), SHC(0x7c77), SHC(0x3410), SHC(0x74ef), SHC(0x4880), SHC(0x697d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ffd), SHC(0xfe53), SHC(0x7ff5), SHC(0xfca6), SHC(0x7fe7), SHC(0xfafa),
+ SHC(0x7fd3), SHC(0xf94d), SHC(0x7fba), SHC(0xf7a1), SHC(0x7f9b), SHC(0xf5f5), SHC(0x7f77), SHC(0xf44a),
+ SHC(0x7f4c), SHC(0xf29f), SHC(0x7f1d), SHC(0xf0f5), SHC(0x7ee8), SHC(0xef4b), SHC(0x7ead), SHC(0xeda2),
+ SHC(0x7e6d), SHC(0xebfa), SHC(0x7e27), SHC(0xea53), SHC(0x7ddb), SHC(0xe8ad), SHC(0x7d8a), SHC(0xe707),
+ SHC(0x7d34), SHC(0xe563), SHC(0x7cd8), SHC(0xe3c0), SHC(0x7c77), SHC(0xe21e), SHC(0x7c10), SHC(0xe07e),
+ SHC(0x7ba3), SHC(0xdedf), SHC(0x7b32), SHC(0xdd41), SHC(0x7abb), SHC(0xdba5), SHC(0x7a3e), SHC(0xda0b),
+ SHC(0x79bc), SHC(0xd872), SHC(0x7935), SHC(0xd6db), SHC(0x78a8), SHC(0xd546), SHC(0x7817), SHC(0xd3b2),
+ SHC(0x7780), SHC(0xd221), SHC(0x76e3), SHC(0xd092), SHC(0x7fff), SHC(0x0000), SHC(0x7fe7), SHC(0xfafa),
+ SHC(0x7f9b), SHC(0xf5f5), SHC(0x7f1d), SHC(0xf0f5), SHC(0x7e6d), SHC(0xebfa), SHC(0x7d8a), SHC(0xe707),
+ SHC(0x7c77), SHC(0xe21e), SHC(0x7b32), SHC(0xdd41), SHC(0x79bc), SHC(0xd872), SHC(0x7817), SHC(0xd3b2),
+ SHC(0x7642), SHC(0xcf04), SHC(0x743e), SHC(0xca69), SHC(0x720d), SHC(0xc5e4), SHC(0x6fae), SHC(0xc175),
+ SHC(0x6d23), SHC(0xbd1f), SHC(0x6a6e), SHC(0xb8e3), SHC(0x678e), SHC(0xb4c3), SHC(0x6485), SHC(0xb0c2),
+ SHC(0x6155), SHC(0xacdf), SHC(0x5dfe), SHC(0xa91d), SHC(0x5a82), SHC(0xa57e), SHC(0x56e3), SHC(0xa202),
+ SHC(0x5321), SHC(0x9eab), SHC(0x4f3e), SHC(0x9b7b), SHC(0x4b3d), SHC(0x9872), SHC(0x471d), SHC(0x9592),
+ SHC(0x42e1), SHC(0x92dd), SHC(0x3e8b), SHC(0x9052), SHC(0x3a1c), SHC(0x8df3), SHC(0x3597), SHC(0x8bc2),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fba), SHC(0xf7a1), SHC(0x7ee8), SHC(0xef4b), SHC(0x7d8a), SHC(0xe707),
+ SHC(0x7ba3), SHC(0xdedf), SHC(0x7935), SHC(0xd6db), SHC(0x7642), SHC(0xcf04), SHC(0x72cd), SHC(0xc763),
+ SHC(0x6eda), SHC(0xc000), SHC(0x6a6e), SHC(0xb8e3), SHC(0x658d), SHC(0xb214), SHC(0x603c), SHC(0xab9b),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x5465), SHC(0x9fc4), SHC(0x4dec), SHC(0x9a73), SHC(0x471d), SHC(0x9592),
+ SHC(0x4000), SHC(0x9126), SHC(0x389d), SHC(0x8d33), SHC(0x30fc), SHC(0x89be), SHC(0x2925), SHC(0x86cb),
+ SHC(0x2121), SHC(0x845d), SHC(0x18f9), SHC(0x8276), SHC(0x10b5), SHC(0x8118), SHC(0x085f), SHC(0x8046),
+ SHC(0x0000), SHC(0x8000), SHC(0xf7a1), SHC(0x8046), SHC(0xef4b), SHC(0x8118), SHC(0xe707), SHC(0x8276),
+ SHC(0xdedf), SHC(0x845d), SHC(0xd6db), SHC(0x86cb), SHC(0x7fff), SHC(0x0000), SHC(0x7f77), SHC(0xf44a),
+ SHC(0x7ddb), SHC(0xe8ad), SHC(0x7b32), SHC(0xdd41), SHC(0x7780), SHC(0xd221), SHC(0x72cd), SHC(0xc763),
+ SHC(0x6d23), SHC(0xbd1f), SHC(0x668f), SHC(0xb36a), SHC(0x5f1f), SHC(0xaa5a), SHC(0x56e3), SHC(0xa202),
+ SHC(0x4dec), SHC(0x9a73), SHC(0x444d), SHC(0x93bf), SHC(0x3a1c), SHC(0x8df3), SHC(0x2f6e), SHC(0x891d),
+ SHC(0x245b), SHC(0x8545), SHC(0x18f9), SHC(0x8276), SHC(0x0d61), SHC(0x80b4), SHC(0x01ad), SHC(0x8003),
+ SHC(0xf5f5), SHC(0x8065), SHC(0xea53), SHC(0x81d9), SHC(0xdedf), SHC(0x845d), SHC(0xd3b2), SHC(0x87e9),
+ SHC(0xc8e5), SHC(0x8c78), SHC(0xbe8e), SHC(0x91ff), SHC(0xb4c3), SHC(0x9872), SHC(0xab9b), SHC(0x9fc4),
+ SHC(0xa327), SHC(0xa7e4), SHC(0x9b7b), SHC(0xb0c2), SHC(0x94a6), SHC(0xba49), SHC(0x8eb9), SHC(0xc467),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f1d), SHC(0xf0f5), SHC(0x7c77), SHC(0xe21e), SHC(0x7817), SHC(0xd3b2),
+ SHC(0x720d), SHC(0xc5e4), SHC(0x6a6e), SHC(0xb8e3), SHC(0x6155), SHC(0xacdf), SHC(0x56e3), SHC(0xa202),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x3e8b), SHC(0x9052), SHC(0x30fc), SHC(0x89be), SHC(0x22bf), SHC(0x84ce),
+ SHC(0x1406), SHC(0x8193), SHC(0x0506), SHC(0x8019), SHC(0xf5f5), SHC(0x8065), SHC(0xe707), SHC(0x8276),
+ SHC(0xd872), SHC(0x8644), SHC(0xca69), SHC(0x8bc2), SHC(0xbd1f), SHC(0x92dd), SHC(0xb0c2), SHC(0x9b7b),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x9b7b), SHC(0xb0c2), SHC(0x92dd), SHC(0xbd1f), SHC(0x8bc2), SHC(0xca69),
+ SHC(0x8644), SHC(0xd872), SHC(0x8276), SHC(0xe707), SHC(0x8065), SHC(0xf5f5), SHC(0x8019), SHC(0x0506),
+ SHC(0x8193), SHC(0x1406), SHC(0x84ce), SHC(0x22bf), SHC(0x7fff), SHC(0x0000), SHC(0x7ead), SHC(0xeda2),
+ SHC(0x7abb), SHC(0xdba5), SHC(0x743e), SHC(0xca69), SHC(0x6b5a), SHC(0xba49), SHC(0x603c), SHC(0xab9b),
+ SHC(0x5321), SHC(0x9eab), SHC(0x444d), SHC(0x93bf), SHC(0x3410), SHC(0x8b11), SHC(0x22bf), SHC(0x84ce),
+ SHC(0x10b5), SHC(0x8118), SHC(0xfe53), SHC(0x8003), SHC(0xebfa), SHC(0x8193), SHC(0xda0b), SHC(0x85c2),
+ SHC(0xc8e5), SHC(0x8c78), SHC(0xb8e3), SHC(0x9592), SHC(0xaa5a), SHC(0xa0e1), SHC(0x9d97), SHC(0xae27),
+ SHC(0x92dd), SHC(0xbd1f), SHC(0x8a65), SHC(0xcd79), SHC(0x845d), SHC(0xdedf), SHC(0x80e3), SHC(0xf0f5),
+ SHC(0x800b), SHC(0x035a), SHC(0x81d9), SHC(0x15ad), SHC(0x8644), SHC(0x278e), SHC(0x8d33), SHC(0x389d),
+ SHC(0x9683), SHC(0x4880), SHC(0xa202), SHC(0x56e3), SHC(0xaf72), SHC(0x637a), SHC(0xbe8e), SHC(0x6e01),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e27), SHC(0xea53), SHC(0x78a8), SHC(0xd546), SHC(0x6fae), SHC(0xc175),
+ SHC(0x637a), SHC(0xaf72), SHC(0x5465), SHC(0x9fc4), SHC(0x42e1), SHC(0x92dd), SHC(0x2f6e), SHC(0x891d),
+ SHC(0x1a9d), SHC(0x82cc), SHC(0x0506), SHC(0x8019), SHC(0xef4b), SHC(0x8118), SHC(0xda0b), SHC(0x85c2),
+ SHC(0xc5e4), SHC(0x8df3), SHC(0xb36a), SHC(0x9971), SHC(0xa327), SHC(0xa7e4), SHC(0x9592), SHC(0xb8e3),
+ SHC(0x8b11), SHC(0xcbf0), SHC(0x83f0), SHC(0xe07e), SHC(0x8065), SHC(0xf5f5), SHC(0x8089), SHC(0x0bb6),
+ SHC(0x845d), SHC(0x2121), SHC(0x8bc2), SHC(0x3597), SHC(0x9683), SHC(0x4880), SHC(0xa450), SHC(0x5951),
+ SHC(0xb4c3), SHC(0x678e), SHC(0xc763), SHC(0x72cd), SHC(0xdba5), SHC(0x7abb), SHC(0xf0f5), SHC(0x7f1d),
+ SHC(0x06b3), SHC(0x7fd3), SHC(0x1c40), SHC(0x7cd8), SHC(0x7fff), SHC(0x0000), SHC(0x7d8a), SHC(0xe707),
+ SHC(0x7642), SHC(0xcf04), SHC(0x6a6e), SHC(0xb8e3), SHC(0x5a82), SHC(0xa57e), SHC(0x471d), SHC(0x9592),
+ SHC(0x30fc), SHC(0x89be), SHC(0x18f9), SHC(0x8276), SHC(0x0000), SHC(0x8000), SHC(0xe707), SHC(0x8276),
+ SHC(0xcf04), SHC(0x89be), SHC(0xb8e3), SHC(0x9592), SHC(0xa57e), SHC(0xa57e), SHC(0x9592), SHC(0xb8e3),
+ SHC(0x89be), SHC(0xcf04), SHC(0x8276), SHC(0xe707), SHC(0x8000), SHC(0x0000), SHC(0x8276), SHC(0x18f9),
+ SHC(0x89be), SHC(0x30fc), SHC(0x9592), SHC(0x471d), SHC(0xa57e), SHC(0x5a82), SHC(0xb8e3), SHC(0x6a6e),
+ SHC(0xcf04), SHC(0x7642), SHC(0xe707), SHC(0x7d8a), SHC(0x0000), SHC(0x7fff), SHC(0x18f9), SHC(0x7d8a),
+ SHC(0x30fc), SHC(0x7642), SHC(0x471d), SHC(0x6a6e), SHC(0x5a82), SHC(0x5a82), SHC(0x6a6e), SHC(0x471d)
+};
+
+const Word16 RotVector_600[2*(600-30)] =
+{
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ff9), SHC(0xfd52),
+ SHC(0x7fe3), SHC(0xfaa4), SHC(0x7fbf), SHC(0xf7f6), SHC(0x7f8d), SHC(0xf54a), SHC(0x7f4c), SHC(0xf29f),
+ SHC(0x7efe), SHC(0xeff5), SHC(0x7ea0), SHC(0xed4d), SHC(0x7e35), SHC(0xeaa7), SHC(0x7dbc), SHC(0xe804),
+ SHC(0x7d34), SHC(0xe563), SHC(0x7c9e), SHC(0xe2c5), SHC(0x7bfb), SHC(0xe02b), SHC(0x7b49), SHC(0xdd94),
+ SHC(0x7a89), SHC(0xdb01), SHC(0x79bc), SHC(0xd872), SHC(0x78e1), SHC(0xd5e8), SHC(0x77f9), SHC(0xd362),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x7600), SHC(0xce66), SHC(0x74ef), SHC(0xcbf0), SHC(0x73d1), SHC(0xc980),
+ SHC(0x72a7), SHC(0xc716), SHC(0x716f), SHC(0xc4b3), SHC(0x702b), SHC(0xc256), SHC(0x6eda), SHC(0xc000),
+ SHC(0x6d7d), SHC(0xbdb1), SHC(0x6c13), SHC(0xbb6a), SHC(0x6a9d), SHC(0xb92a), SHC(0x691b), SHC(0xb6f3),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fe3), SHC(0xfaa4), SHC(0x7f8d), SHC(0xf54a), SHC(0x7efe), SHC(0xeff5),
+ SHC(0x7e35), SHC(0xeaa7), SHC(0x7d34), SHC(0xe563), SHC(0x7bfb), SHC(0xe02b), SHC(0x7a89), SHC(0xdb01),
+ SHC(0x78e1), SHC(0xd5e8), SHC(0x7703), SHC(0xd0e1), SHC(0x74ef), SHC(0xcbf0), SHC(0x72a7), SHC(0xc716),
+ SHC(0x702b), SHC(0xc256), SHC(0x6d7d), SHC(0xbdb1), SHC(0x6a9d), SHC(0xb92a), SHC(0x678e), SHC(0xb4c3),
+ SHC(0x6450), SHC(0xb07e), SHC(0x60e5), SHC(0xac5d), SHC(0x5d4f), SHC(0xa861), SHC(0x598f), SHC(0xa48c),
+ SHC(0x55a6), SHC(0xa0e1), SHC(0x5197), SHC(0x9d60), SHC(0x4d64), SHC(0x9a0b), SHC(0x490d), SHC(0x96e5),
+ SHC(0x4496), SHC(0x93ed), SHC(0x4000), SHC(0x9126), SHC(0x3b4d), SHC(0x8e91), SHC(0x3680), SHC(0x8c2f),
+ SHC(0x319a), SHC(0x8a00), SHC(0x2c9e), SHC(0x8807), SHC(0x7fff), SHC(0x0000), SHC(0x7fbf), SHC(0xf7f6),
+ SHC(0x7efe), SHC(0xeff5), SHC(0x7dbc), SHC(0xe804), SHC(0x7bfb), SHC(0xe02b), SHC(0x79bc), SHC(0xd872),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x73d1), SHC(0xc980), SHC(0x702b), SHC(0xc256), SHC(0x6c13), SHC(0xbb6a),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x62a0), SHC(0xae69), SHC(0x5d4f), SHC(0xa861), SHC(0x579f), SHC(0xa2b1),
+ SHC(0x5197), SHC(0x9d60), SHC(0x4b3d), SHC(0x9872), SHC(0x4496), SHC(0x93ed), SHC(0x3daa), SHC(0x8fd5),
+ SHC(0x3680), SHC(0x8c2f), SHC(0x2f1f), SHC(0x88fd), SHC(0x278e), SHC(0x8644), SHC(0x1fd5), SHC(0x8405),
+ SHC(0x17fc), SHC(0x8244), SHC(0x100b), SHC(0x8102), SHC(0x080a), SHC(0x8041), SHC(0x0000), SHC(0x8000),
+ SHC(0xf7f6), SHC(0x8041), SHC(0xeff5), SHC(0x8102), SHC(0xe804), SHC(0x8244), SHC(0xe02b), SHC(0x8405),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f8d), SHC(0xf54a), SHC(0x7e35), SHC(0xeaa7), SHC(0x7bfb), SHC(0xe02b),
+ SHC(0x78e1), SHC(0xd5e8), SHC(0x74ef), SHC(0xcbf0), SHC(0x702b), SHC(0xc256), SHC(0x6a9d), SHC(0xb92a),
+ SHC(0x6450), SHC(0xb07e), SHC(0x5d4f), SHC(0xa861), SHC(0x55a6), SHC(0xa0e1), SHC(0x4d64), SHC(0x9a0b),
+ SHC(0x4496), SHC(0x93ed), SHC(0x3b4d), SHC(0x8e91), SHC(0x319a), SHC(0x8a00), SHC(0x278e), SHC(0x8644),
+ SHC(0x1d3b), SHC(0x8362), SHC(0x12b3), SHC(0x8160), SHC(0x080a), SHC(0x8041), SHC(0xfd52), SHC(0x8007),
+ SHC(0xf29f), SHC(0x80b4), SHC(0xe804), SHC(0x8244), SHC(0xdd94), SHC(0x84b7), SHC(0xd362), SHC(0x8807),
+ SHC(0xc980), SHC(0x8c2f), SHC(0xc000), SHC(0x9126), SHC(0xb6f3), SHC(0x96e5), SHC(0xae69), SHC(0x9d60),
+ SHC(0xa671), SHC(0xa48c), SHC(0x9f1b), SHC(0xac5d), SHC(0x7fff), SHC(0x0000), SHC(0x7f4c), SHC(0xf29f),
+ SHC(0x7d34), SHC(0xe563), SHC(0x79bc), SHC(0xd872), SHC(0x74ef), SHC(0xcbf0), SHC(0x6eda), SHC(0xc000),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x5f1f), SHC(0xaa5a), SHC(0x55a6), SHC(0xa0e1), SHC(0x4b3d), SHC(0x9872),
+ SHC(0x4000), SHC(0x9126), SHC(0x3410), SHC(0x8b11), SHC(0x278e), SHC(0x8644), SHC(0x1a9d), SHC(0x82cc),
+ SHC(0x0d61), SHC(0x80b4), SHC(0x0000), SHC(0x8000), SHC(0xf29f), SHC(0x80b4), SHC(0xe563), SHC(0x82cc),
+ SHC(0xd872), SHC(0x8644), SHC(0xcbf0), SHC(0x8b11), SHC(0xc000), SHC(0x9126), SHC(0xb4c3), SHC(0x9872),
+ SHC(0xaa5a), SHC(0xa0e1), SHC(0xa0e1), SHC(0xaa5a), SHC(0x9872), SHC(0xb4c3), SHC(0x9126), SHC(0xc000),
+ SHC(0x8b11), SHC(0xcbf0), SHC(0x8644), SHC(0xd872), SHC(0x82cc), SHC(0xe563), SHC(0x80b4), SHC(0xf29f),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7efe), SHC(0xeff5), SHC(0x7bfb), SHC(0xe02b), SHC(0x7703), SHC(0xd0e1),
+ SHC(0x702b), SHC(0xc256), SHC(0x678e), SHC(0xb4c3), SHC(0x5d4f), SHC(0xa861), SHC(0x5197), SHC(0x9d60),
+ SHC(0x4496), SHC(0x93ed), SHC(0x3680), SHC(0x8c2f), SHC(0x278e), SHC(0x8644), SHC(0x17fc), SHC(0x8244),
+ SHC(0x080a), SHC(0x8041), SHC(0xf7f6), SHC(0x8041), SHC(0xe804), SHC(0x8244), SHC(0xd872), SHC(0x8644),
+ SHC(0xc980), SHC(0x8c2f), SHC(0xbb6a), SHC(0x93ed), SHC(0xae69), SHC(0x9d60), SHC(0xa2b1), SHC(0xa861),
+ SHC(0x9872), SHC(0xb4c3), SHC(0x8fd5), SHC(0xc256), SHC(0x88fd), SHC(0xd0e1), SHC(0x8405), SHC(0xe02b),
+ SHC(0x8102), SHC(0xeff5), SHC(0x8000), SHC(0x0000), SHC(0x8102), SHC(0x100b), SHC(0x8405), SHC(0x1fd5),
+ SHC(0x88fd), SHC(0x2f1f), SHC(0x8fd5), SHC(0x3daa), SHC(0x7fff), SHC(0x0000), SHC(0x7ea0), SHC(0xed4d),
+ SHC(0x7a89), SHC(0xdb01), SHC(0x73d1), SHC(0xc980), SHC(0x6a9d), SHC(0xb92a), SHC(0x5f1f), SHC(0xaa5a),
+ SHC(0x5197), SHC(0x9d60), SHC(0x424f), SHC(0x9283), SHC(0x319a), SHC(0x8a00), SHC(0x1fd5), SHC(0x8405),
+ SHC(0x0d61), SHC(0x80b4), SHC(0xfaa4), SHC(0x801d), SHC(0xe804), SHC(0x8244), SHC(0xd5e8), SHC(0x871f),
+ SHC(0xc4b3), SHC(0x8e91), SHC(0xb4c3), SHC(0x9872), SHC(0xa671), SHC(0xa48c), SHC(0x9a0b), SHC(0xb29c),
+ SHC(0x8fd5), SHC(0xc256), SHC(0x8807), SHC(0xd362), SHC(0x82cc), SHC(0xe563), SHC(0x8041), SHC(0xf7f6),
+ SHC(0x8073), SHC(0x0ab6), SHC(0x8362), SHC(0x1d3b), SHC(0x88fd), SHC(0x2f1f), SHC(0x9126), SHC(0x4000),
+ SHC(0x9bb0), SHC(0x4f82), SHC(0xa861), SHC(0x5d4f), SHC(0xb6f3), SHC(0x691b), SHC(0xc716), SHC(0x72a7),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e35), SHC(0xeaa7), SHC(0x78e1), SHC(0xd5e8), SHC(0x702b), SHC(0xc256),
+ SHC(0x6450), SHC(0xb07e), SHC(0x55a6), SHC(0xa0e1), SHC(0x4496), SHC(0x93ed), SHC(0x319a), SHC(0x8a00),
+ SHC(0x1d3b), SHC(0x8362), SHC(0x080a), SHC(0x8041), SHC(0xf29f), SHC(0x80b4), SHC(0xdd94), SHC(0x84b7),
+ SHC(0xc980), SHC(0x8c2f), SHC(0xb6f3), SHC(0x96e5), SHC(0xa671), SHC(0xa48c), SHC(0x9872), SHC(0xb4c3),
+ SHC(0x8d59), SHC(0xc716), SHC(0x8577), SHC(0xdb01), SHC(0x8102), SHC(0xeff5), SHC(0x801d), SHC(0x055c),
+ SHC(0x82cc), SHC(0x1a9d), SHC(0x88fd), SHC(0x2f1f), SHC(0x9283), SHC(0x424f), SHC(0x9f1b), SHC(0x53a3),
+ SHC(0xae69), SHC(0x62a0), SHC(0xc000), SHC(0x6eda), SHC(0xd362), SHC(0x77f9), SHC(0xe804), SHC(0x7dbc),
+ SHC(0xfd52), SHC(0x7ff9), SHC(0x12b3), SHC(0x7ea0), SHC(0x7fff), SHC(0x0000), SHC(0x7dbc), SHC(0xe804),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x6c13), SHC(0xbb6a), SHC(0x5d4f), SHC(0xa861), SHC(0x4b3d), SHC(0x9872),
+ SHC(0x3680), SHC(0x8c2f), SHC(0x1fd5), SHC(0x8405), SHC(0x080a), SHC(0x8041), SHC(0xeff5), SHC(0x8102),
+ SHC(0xd872), SHC(0x8644), SHC(0xc256), SHC(0x8fd5), SHC(0xae69), SHC(0x9d60), SHC(0x9d60), SHC(0xae69),
+ SHC(0x8fd5), SHC(0xc256), SHC(0x8644), SHC(0xd872), SHC(0x8102), SHC(0xeff5), SHC(0x8041), SHC(0x080a),
+ SHC(0x8405), SHC(0x1fd5), SHC(0x8c2f), SHC(0x3680), SHC(0x9872), SHC(0x4b3d), SHC(0xa861), SHC(0x5d4f),
+ SHC(0xbb6a), SHC(0x6c13), SHC(0xd0e1), SHC(0x7703), SHC(0xe804), SHC(0x7dbc), SHC(0x0000), SHC(0x7fff),
+ SHC(0x17fc), SHC(0x7dbc), SHC(0x2f1f), SHC(0x7703), SHC(0x4496), SHC(0x6c13), SHC(0x579f), SHC(0x5d4f),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ffe), SHC(0xfea9), SHC(0x7ff9), SHC(0xfd52), SHC(0x7ff0), SHC(0xfbfb),
+ SHC(0x7fe3), SHC(0xfaa4), SHC(0x7fd3), SHC(0xf94d), SHC(0x7fbf), SHC(0xf7f6), SHC(0x7fa8), SHC(0xf6a0),
+ SHC(0x7f8d), SHC(0xf54a), SHC(0x7f6f), SHC(0xf3f4), SHC(0x7f4c), SHC(0xf29f), SHC(0x7f27), SHC(0xf14a),
+ SHC(0x7efe), SHC(0xeff5), SHC(0x7ed1), SHC(0xeea1), SHC(0x7ea0), SHC(0xed4d), SHC(0x7e6d), SHC(0xebfa),
+ SHC(0x7e35), SHC(0xeaa7), SHC(0x7dfa), SHC(0xe955), SHC(0x7dbc), SHC(0xe804), SHC(0x7d7a), SHC(0xe6b3),
+ SHC(0x7d34), SHC(0xe563), SHC(0x7ceb), SHC(0xe414), SHC(0x7c9e), SHC(0xe2c5), SHC(0x7c4e), SHC(0xe178),
+ SHC(0x7bfb), SHC(0xe02b), SHC(0x7ba3), SHC(0xdedf), SHC(0x7b49), SHC(0xdd94), SHC(0x7aeb), SHC(0xdc4a),
+ SHC(0x7a89), SHC(0xdb01), SHC(0x7a25), SHC(0xd9b9), SHC(0x7fff), SHC(0x0000), SHC(0x7ff0), SHC(0xfbfb),
+ SHC(0x7fbf), SHC(0xf7f6), SHC(0x7f6f), SHC(0xf3f4), SHC(0x7efe), SHC(0xeff5), SHC(0x7e6d), SHC(0xebfa),
+ SHC(0x7dbc), SHC(0xe804), SHC(0x7ceb), SHC(0xe414), SHC(0x7bfb), SHC(0xe02b), SHC(0x7aeb), SHC(0xdc4a),
+ SHC(0x79bc), SHC(0xd872), SHC(0x786f), SHC(0xd4a4), SHC(0x7703), SHC(0xd0e1), SHC(0x7579), SHC(0xcd2a),
+ SHC(0x73d1), SHC(0xc980), SHC(0x720d), SHC(0xc5e4), SHC(0x702b), SHC(0xc256), SHC(0x6e2d), SHC(0xbed8),
+ SHC(0x6c13), SHC(0xbb6a), SHC(0x69de), SHC(0xb80e), SHC(0x678e), SHC(0xb4c3), SHC(0x6524), SHC(0xb18c),
+ SHC(0x62a0), SHC(0xae69), SHC(0x6004), SHC(0xab5a), SHC(0x5d4f), SHC(0xa861), SHC(0x5a82), SHC(0xa57e),
+ SHC(0x579f), SHC(0xa2b1), SHC(0x54a6), SHC(0x9ffc), SHC(0x5197), SHC(0x9d60), SHC(0x4e74), SHC(0x9adc),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fd3), SHC(0xf94d), SHC(0x7f4c), SHC(0xf29f), SHC(0x7e6d), SHC(0xebfa),
+ SHC(0x7d34), SHC(0xe563), SHC(0x7ba3), SHC(0xdedf), SHC(0x79bc), SHC(0xd872), SHC(0x7780), SHC(0xd221),
+ SHC(0x74ef), SHC(0xcbf0), SHC(0x720d), SHC(0xc5e4), SHC(0x6eda), SHC(0xc000), SHC(0x6b5a), SHC(0xba49),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x637a), SHC(0xaf72), SHC(0x5f1f), SHC(0xaa5a), SHC(0x5a82), SHC(0xa57e),
+ SHC(0x55a6), SHC(0xa0e1), SHC(0x508e), SHC(0x9c86), SHC(0x4b3d), SHC(0x9872), SHC(0x45b7), SHC(0x94a6),
+ SHC(0x4000), SHC(0x9126), SHC(0x3a1c), SHC(0x8df3), SHC(0x3410), SHC(0x8b11), SHC(0x2ddf), SHC(0x8880),
+ SHC(0x278e), SHC(0x8644), SHC(0x2121), SHC(0x845d), SHC(0x1a9d), SHC(0x82cc), SHC(0x1406), SHC(0x8193),
+ SHC(0x0d61), SHC(0x80b4), SHC(0x06b3), SHC(0x802d), SHC(0x7fff), SHC(0x0000), SHC(0x7fa8), SHC(0xf6a0),
+ SHC(0x7ea0), SHC(0xed4d), SHC(0x7ceb), SHC(0xe414), SHC(0x7a89), SHC(0xdb01), SHC(0x7780), SHC(0xd221),
+ SHC(0x73d1), SHC(0xc980), SHC(0x6f84), SHC(0xc12a), SHC(0x6a9d), SHC(0xb92a), SHC(0x6524), SHC(0xb18c),
+ SHC(0x5f1f), SHC(0xaa5a), SHC(0x5898), SHC(0xa39d), SHC(0x5197), SHC(0x9d60), SHC(0x4a26), SHC(0x97aa),
+ SHC(0x424f), SHC(0x9283), SHC(0x3a1c), SHC(0x8df3), SHC(0x319a), SHC(0x8a00), SHC(0x28d4), SHC(0x86b0),
+ SHC(0x1fd5), SHC(0x8405), SHC(0x16ab), SHC(0x8206), SHC(0x0d61), SHC(0x80b4), SHC(0x0405), SHC(0x8010),
+ SHC(0xfaa4), SHC(0x801d), SHC(0xf14a), SHC(0x80d9), SHC(0xe804), SHC(0x8244), SHC(0xdedf), SHC(0x845d),
+ SHC(0xd5e8), SHC(0x871f), SHC(0xcd2a), SHC(0x8a87), SHC(0xc4b3), SHC(0x8e91), SHC(0xbc8d), SHC(0x9337),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f6f), SHC(0xf3f4), SHC(0x7dbc), SHC(0xe804), SHC(0x7aeb), SHC(0xdc4a),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x720d), SHC(0xc5e4), SHC(0x6c13), SHC(0xbb6a), SHC(0x6524), SHC(0xb18c),
+ SHC(0x5d4f), SHC(0xa861), SHC(0x54a6), SHC(0x9ffc), SHC(0x4b3d), SHC(0x9872), SHC(0x4128), SHC(0x91d3),
+ SHC(0x3680), SHC(0x8c2f), SHC(0x2b5c), SHC(0x8791), SHC(0x1fd5), SHC(0x8405), SHC(0x1406), SHC(0x8193),
+ SHC(0x080a), SHC(0x8041), SHC(0xfbfb), SHC(0x8010), SHC(0xeff5), SHC(0x8102), SHC(0xe414), SHC(0x8315),
+ SHC(0xd872), SHC(0x8644), SHC(0xcd2a), SHC(0x8a87), SHC(0xc256), SHC(0x8fd5), SHC(0xb80e), SHC(0x9622),
+ SHC(0xae69), SHC(0x9d60), SHC(0xa57e), SHC(0xa57e), SHC(0x9d60), SHC(0xae69), SHC(0x9622), SHC(0xb80e),
+ SHC(0x8fd5), SHC(0xc256), SHC(0x8a87), SHC(0xcd2a), SHC(0x7fff), SHC(0x0000), SHC(0x7f27), SHC(0xf14a),
+ SHC(0x7c9e), SHC(0xe2c5), SHC(0x786f), SHC(0xd4a4), SHC(0x72a7), SHC(0xc716), SHC(0x6b5a), SHC(0xba49),
+ SHC(0x62a0), SHC(0xae69), SHC(0x5898), SHC(0xa39d), SHC(0x4d64), SHC(0x9a0b), SHC(0x4128), SHC(0x91d3),
+ SHC(0x3410), SHC(0x8b11), SHC(0x2647), SHC(0x85db), SHC(0x17fc), SHC(0x8244), SHC(0x0960), SHC(0x8058),
+ SHC(0xfaa4), SHC(0x801d), SHC(0xebfa), SHC(0x8193), SHC(0xdd94), SHC(0x84b7), SHC(0xcfa3), SHC(0x897d),
+ SHC(0xc256), SHC(0x8fd5), SHC(0xb5da), SHC(0x97aa), SHC(0xaa5a), SHC(0xa0e1), SHC(0x9ffc), SHC(0xab5a),
+ SHC(0x96e5), SHC(0xb6f3), SHC(0x8f31), SHC(0xc383), SHC(0x88fd), SHC(0xd0e1), SHC(0x845d), SHC(0xdedf),
+ SHC(0x8160), SHC(0xed4d), SHC(0x8010), SHC(0xfbfb), SHC(0x8073), SHC(0x0ab6), SHC(0x8286), SHC(0x194d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ed1), SHC(0xeea1), SHC(0x7b49), SHC(0xdd94), SHC(0x7579), SHC(0xcd2a),
+ SHC(0x6d7d), SHC(0xbdb1), SHC(0x637a), SHC(0xaf72), SHC(0x579f), SHC(0xa2b1), SHC(0x4a26), SHC(0x97aa),
+ SHC(0x3b4d), SHC(0x8e91), SHC(0x2b5c), SHC(0x8791), SHC(0x1a9d), SHC(0x82cc), SHC(0x0960), SHC(0x8058),
+ SHC(0xf7f6), SHC(0x8041), SHC(0xe6b3), SHC(0x8286), SHC(0xd5e8), SHC(0x871f), SHC(0xc5e4), SHC(0x8df3),
+ SHC(0xb6f3), SHC(0x96e5), SHC(0xa95c), SHC(0xa1c8), SHC(0x9d60), SHC(0xae69), SHC(0x9337), SHC(0xbc8d),
+ SHC(0x8b11), SHC(0xcbf0), SHC(0x8515), SHC(0xdc4a), SHC(0x8160), SHC(0xed4d), SHC(0x8002), SHC(0xfea9),
+ SHC(0x8102), SHC(0x100b), SHC(0x845d), SHC(0x2121), SHC(0x8a00), SHC(0x319a), SHC(0x91d3), SHC(0x4128),
+ SHC(0x9bb0), SHC(0x4f82), SHC(0xa768), SHC(0x5c63), SHC(0x7fff), SHC(0x0000), SHC(0x7e6d), SHC(0xebfa),
+ SHC(0x79bc), SHC(0xd872), SHC(0x720d), SHC(0xc5e4), SHC(0x678e), SHC(0xb4c3), SHC(0x5a82), SHC(0xa57e),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x3a1c), SHC(0x8df3), SHC(0x278e), SHC(0x8644), SHC(0x1406), SHC(0x8193),
+ SHC(0x0000), SHC(0x8000), SHC(0xebfa), SHC(0x8193), SHC(0xd872), SHC(0x8644), SHC(0xc5e4), SHC(0x8df3),
+ SHC(0xb4c3), SHC(0x9872), SHC(0xa57e), SHC(0xa57e), SHC(0x9872), SHC(0xb4c3), SHC(0x8df3), SHC(0xc5e4),
+ SHC(0x8644), SHC(0xd872), SHC(0x8193), SHC(0xebfa), SHC(0x8000), SHC(0x0000), SHC(0x8193), SHC(0x1406),
+ SHC(0x8644), SHC(0x278e), SHC(0x8df3), SHC(0x3a1c), SHC(0x9872), SHC(0x4b3d), SHC(0xa57e), SHC(0x5a82),
+ SHC(0xb4c3), SHC(0x678e), SHC(0xc5e4), SHC(0x720d), SHC(0xd872), SHC(0x79bc), SHC(0xebfa), SHC(0x7e6d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7dfa), SHC(0xe955), SHC(0x77f9), SHC(0xd362), SHC(0x6e2d), SHC(0xbed8),
+ SHC(0x60e5), SHC(0xac5d), SHC(0x508e), SHC(0x9c86), SHC(0x3daa), SHC(0x8fd5), SHC(0x28d4), SHC(0x86b0),
+ SHC(0x12b3), SHC(0x8160), SHC(0xfbfb), SHC(0x8010), SHC(0xe563), SHC(0x82cc), SHC(0xcfa3), SHC(0x897d),
+ SHC(0xbb6a), SHC(0x93ed), SHC(0xa95c), SHC(0xa1c8), SHC(0x9a0b), SHC(0xb29c), SHC(0x8df3), SHC(0xc5e4),
+ SHC(0x8577), SHC(0xdb01), SHC(0x80d9), SHC(0xf14a), SHC(0x8041), SHC(0x080a), SHC(0x83b2), SHC(0x1e88),
+ SHC(0x8b11), SHC(0x3410), SHC(0x9622), SHC(0x47f2), SHC(0xa48c), SHC(0x598f), SHC(0xb5da), SHC(0x6856),
+ SHC(0xc980), SHC(0x73d1), SHC(0xdedf), SHC(0x7ba3), SHC(0xf54a), SHC(0x7f8d), SHC(0x0c0c), SHC(0x7f6f),
+ SHC(0x226c), SHC(0x7b49), SHC(0x37b6), SHC(0x733e), SHC(0x7fff), SHC(0x0000), SHC(0x7d7a), SHC(0xe6b3),
+ SHC(0x7600), SHC(0xce66), SHC(0x69de), SHC(0xb80e), SHC(0x598f), SHC(0xa48c), SHC(0x45b7), SHC(0x94a6),
+ SHC(0x2f1f), SHC(0x88fd), SHC(0x16ab), SHC(0x8206), SHC(0xfd52), SHC(0x8007), SHC(0xe414), SHC(0x8315),
+ SHC(0xcbf0), SHC(0x8b11), SHC(0xb5da), SHC(0x97aa), SHC(0xa2b1), SHC(0xa861), SHC(0x9337), SHC(0xbc8d),
+ SHC(0x8807), SHC(0xd362), SHC(0x8193), SHC(0xebfa), SHC(0x801d), SHC(0x055c), SHC(0x83b2), SHC(0x1e88),
+ SHC(0x8c2f), SHC(0x3680), SHC(0x993d), SHC(0x4c51), SHC(0xaa5a), SHC(0x5f1f), SHC(0xbed8), SHC(0x6e2d),
+ SHC(0xd5e8), SHC(0x78e1), SHC(0xeea1), SHC(0x7ed1), SHC(0x080a), SHC(0x7fbf), SHC(0x2121), SHC(0x7ba3),
+ SHC(0x38ea), SHC(0x72a7), SHC(0x4e74), SHC(0x6524), SHC(0x60e5), SHC(0x53a3), SHC(0x6f84), SHC(0x3ed6)
+};
+
+
+
+/**
+ * \brief Twiddle factors are unscaled
+ */
+const Word16 RotVector_256[2*(256-32)] =
+{
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ff6), SHC(0xfcdc), SHC(0x7fd9), SHC(0xf9b8), SHC(0x7fa7), SHC(0xf695),
+ SHC(0x7f62), SHC(0xf374), SHC(0x7f0a), SHC(0xf055), SHC(0x7e9d), SHC(0xed38), SHC(0x7e1e), SHC(0xea1e),
+ SHC(0x7d8a), SHC(0xe707), SHC(0x7ce4), SHC(0xe3f4), SHC(0x7c2a), SHC(0xe0e6), SHC(0x7b5d), SHC(0xdddc),
+ SHC(0x7a7d), SHC(0xdad8), SHC(0x798a), SHC(0xd7d9), SHC(0x7885), SHC(0xd4e1), SHC(0x776c), SHC(0xd1ef),
+ SHC(0x7642), SHC(0xcf04), SHC(0x7505), SHC(0xcc21), SHC(0x73b6), SHC(0xc946), SHC(0x7255), SHC(0xc673),
+ SHC(0x70e3), SHC(0xc3a9), SHC(0x6f5f), SHC(0xc0e9), SHC(0x6dca), SHC(0xbe32), SHC(0x6c24), SHC(0xbb85),
+ SHC(0x6a6e), SHC(0xb8e3), SHC(0x68a7), SHC(0xb64c), SHC(0x66d0), SHC(0xb3c0), SHC(0x64e9), SHC(0xb140),
+ SHC(0x62f2), SHC(0xaecc), SHC(0x60ec), SHC(0xac65), SHC(0x5ed7), SHC(0xaa0a), SHC(0x5cb4), SHC(0xa7bd),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fd9), SHC(0xf9b8), SHC(0x7f62), SHC(0xf374), SHC(0x7e9d), SHC(0xed38),
+ SHC(0x7d8a), SHC(0xe707), SHC(0x7c2a), SHC(0xe0e6), SHC(0x7a7d), SHC(0xdad8), SHC(0x7885), SHC(0xd4e1),
+ SHC(0x7642), SHC(0xcf04), SHC(0x73b6), SHC(0xc946), SHC(0x70e3), SHC(0xc3a9), SHC(0x6dca), SHC(0xbe32),
+ SHC(0x6a6e), SHC(0xb8e3), SHC(0x66d0), SHC(0xb3c0), SHC(0x62f2), SHC(0xaecc), SHC(0x5ed7), SHC(0xaa0a),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x55f6), SHC(0xa129), SHC(0x5134), SHC(0x9d0e), SHC(0x4c40), SHC(0x9930),
+ SHC(0x471d), SHC(0x9592), SHC(0x41ce), SHC(0x9236), SHC(0x3c57), SHC(0x8f1d), SHC(0x36ba), SHC(0x8c4a),
+ SHC(0x30fc), SHC(0x89be), SHC(0x2b1f), SHC(0x877b), SHC(0x2528), SHC(0x8583), SHC(0x1f1a), SHC(0x83d6),
+ SHC(0x18f9), SHC(0x8276), SHC(0x12c8), SHC(0x8163), SHC(0x0c8c), SHC(0x809e), SHC(0x0648), SHC(0x8027),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fa7), SHC(0xf695), SHC(0x7e9d), SHC(0xed38), SHC(0x7ce4), SHC(0xe3f4),
+ SHC(0x7a7d), SHC(0xdad8), SHC(0x776c), SHC(0xd1ef), SHC(0x73b6), SHC(0xc946), SHC(0x6f5f), SHC(0xc0e9),
+ SHC(0x6a6e), SHC(0xb8e3), SHC(0x64e9), SHC(0xb140), SHC(0x5ed7), SHC(0xaa0a), SHC(0x5843), SHC(0xa34c),
+ SHC(0x5134), SHC(0x9d0e), SHC(0x49b4), SHC(0x9759), SHC(0x41ce), SHC(0x9236), SHC(0x398d), SHC(0x8dab),
+ SHC(0x30fc), SHC(0x89be), SHC(0x2827), SHC(0x8676), SHC(0x1f1a), SHC(0x83d6), SHC(0x15e2), SHC(0x81e2),
+ SHC(0x0c8c), SHC(0x809e), SHC(0x0324), SHC(0x800a), SHC(0xf9b8), SHC(0x8027), SHC(0xf055), SHC(0x80f6),
+ SHC(0xe707), SHC(0x8276), SHC(0xdddc), SHC(0x84a3), SHC(0xd4e1), SHC(0x877b), SHC(0xcc21), SHC(0x8afb),
+ SHC(0xc3a9), SHC(0x8f1d), SHC(0xbb85), SHC(0x93dc), SHC(0xb3c0), SHC(0x9930), SHC(0xac65), SHC(0x9f14),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f62), SHC(0xf374), SHC(0x7d8a), SHC(0xe707), SHC(0x7a7d), SHC(0xdad8),
+ SHC(0x7642), SHC(0xcf04), SHC(0x70e3), SHC(0xc3a9), SHC(0x6a6e), SHC(0xb8e3), SHC(0x62f2), SHC(0xaecc),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x5134), SHC(0x9d0e), SHC(0x471d), SHC(0x9592), SHC(0x3c57), SHC(0x8f1d),
+ SHC(0x30fc), SHC(0x89be), SHC(0x2528), SHC(0x8583), SHC(0x18f9), SHC(0x8276), SHC(0x0c8c), SHC(0x809e),
+ SHC(0x0000), SHC(0x8000), SHC(0xf374), SHC(0x809e), SHC(0xe707), SHC(0x8276), SHC(0xdad8), SHC(0x8583),
+ SHC(0xcf04), SHC(0x89be), SHC(0xc3a9), SHC(0x8f1d), SHC(0xb8e3), SHC(0x9592), SHC(0xaecc), SHC(0x9d0e),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x9d0e), SHC(0xaecc), SHC(0x9592), SHC(0xb8e3), SHC(0x8f1d), SHC(0xc3a9),
+ SHC(0x89be), SHC(0xcf04), SHC(0x8583), SHC(0xdad8), SHC(0x8276), SHC(0xe707), SHC(0x809e), SHC(0xf374),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f0a), SHC(0xf055), SHC(0x7c2a), SHC(0xe0e6), SHC(0x776c), SHC(0xd1ef),
+ SHC(0x70e3), SHC(0xc3a9), SHC(0x68a7), SHC(0xb64c), SHC(0x5ed7), SHC(0xaa0a), SHC(0x539b), SHC(0x9f14),
+ SHC(0x471d), SHC(0x9592), SHC(0x398d), SHC(0x8dab), SHC(0x2b1f), SHC(0x877b), SHC(0x1c0c), SHC(0x831c),
+ SHC(0x0c8c), SHC(0x809e), SHC(0xfcdc), SHC(0x800a), SHC(0xed38), SHC(0x8163), SHC(0xdddc), SHC(0x84a3),
+ SHC(0xcf04), SHC(0x89be), SHC(0xc0e9), SHC(0x90a1), SHC(0xb3c0), SHC(0x9930), SHC(0xa7bd), SHC(0xa34c),
+ SHC(0x9d0e), SHC(0xaecc), SHC(0x93dc), SHC(0xbb85), SHC(0x8c4a), SHC(0xc946), SHC(0x8676), SHC(0xd7d9),
+ SHC(0x8276), SHC(0xe707), SHC(0x8059), SHC(0xf695), SHC(0x8027), SHC(0x0648), SHC(0x81e2), SHC(0x15e2),
+ SHC(0x8583), SHC(0x2528), SHC(0x8afb), SHC(0x33df), SHC(0x9236), SHC(0x41ce), SHC(0x9b17), SHC(0x4ec0),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e9d), SHC(0xed38), SHC(0x7a7d), SHC(0xdad8), SHC(0x73b6), SHC(0xc946),
+ SHC(0x6a6e), SHC(0xb8e3), SHC(0x5ed7), SHC(0xaa0a), SHC(0x5134), SHC(0x9d0e), SHC(0x41ce), SHC(0x9236),
+ SHC(0x30fc), SHC(0x89be), SHC(0x1f1a), SHC(0x83d6), SHC(0x0c8c), SHC(0x809e), SHC(0xf9b8), SHC(0x8027),
+ SHC(0xe707), SHC(0x8276), SHC(0xd4e1), SHC(0x877b), SHC(0xc3a9), SHC(0x8f1d), SHC(0xb3c0), SHC(0x9930),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x9930), SHC(0xb3c0), SHC(0x8f1d), SHC(0xc3a9), SHC(0x877b), SHC(0xd4e1),
+ SHC(0x8276), SHC(0xe707), SHC(0x8027), SHC(0xf9b8), SHC(0x809e), SHC(0x0c8c), SHC(0x83d6), SHC(0x1f1a),
+ SHC(0x89be), SHC(0x30fc), SHC(0x9236), SHC(0x41ce), SHC(0x9d0e), SHC(0x5134), SHC(0xaa0a), SHC(0x5ed7),
+ SHC(0xb8e3), SHC(0x6a6e), SHC(0xc946), SHC(0x73b6), SHC(0xdad8), SHC(0x7a7d), SHC(0xed38), SHC(0x7e9d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e1e), SHC(0xea1e), SHC(0x7885), SHC(0xd4e1), SHC(0x6f5f), SHC(0xc0e9),
+ SHC(0x62f2), SHC(0xaecc), SHC(0x539b), SHC(0x9f14), SHC(0x41ce), SHC(0x9236), SHC(0x2e11), SHC(0x8894),
+ SHC(0x18f9), SHC(0x8276), SHC(0x0324), SHC(0x800a), SHC(0xed38), SHC(0x8163), SHC(0xd7d9), SHC(0x8676),
+ SHC(0xc3a9), SHC(0x8f1d), SHC(0xb140), SHC(0x9b17), SHC(0xa129), SHC(0xaa0a), SHC(0x93dc), SHC(0xbb85),
+ SHC(0x89be), SHC(0xcf04), SHC(0x831c), SHC(0xe3f4), SHC(0x8027), SHC(0xf9b8), SHC(0x80f6), SHC(0x0fab),
+ SHC(0x8583), SHC(0x2528), SHC(0x8dab), SHC(0x398d), SHC(0x9930), SHC(0x4c40), SHC(0xa7bd), SHC(0x5cb4),
+ SHC(0xb8e3), SHC(0x6a6e), SHC(0xcc21), SHC(0x7505), SHC(0xe0e6), SHC(0x7c2a), SHC(0xf695), SHC(0x7fa7),
+ SHC(0x0c8c), SHC(0x7f62), SHC(0x2224), SHC(0x7b5d), SHC(0x36ba), SHC(0x73b6), SHC(0x49b4), SHC(0x68a7)
+};
+
+/**
+ * \brief Twiddle factors are unscaled
+ */
+const Word16 RotVector_320[2*(320-20)] =
+{
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fe7), SHC(0xfafa), SHC(0x7f9b), SHC(0xf5f5), SHC(0x7f1d), SHC(0xf0f5),
+ SHC(0x7e6d), SHC(0xebfa), SHC(0x7d8a), SHC(0xe707), SHC(0x7c77), SHC(0xe21e), SHC(0x7b32), SHC(0xdd41),
+ SHC(0x79bc), SHC(0xd872), SHC(0x7817), SHC(0xd3b2), SHC(0x7642), SHC(0xcf04), SHC(0x743e), SHC(0xca69),
+ SHC(0x720d), SHC(0xc5e4), SHC(0x6fae), SHC(0xc175), SHC(0x6d23), SHC(0xbd1f), SHC(0x6a6e), SHC(0xb8e3),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x6485), SHC(0xb0c2), SHC(0x6155), SHC(0xacdf), SHC(0x5dfe), SHC(0xa91d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f9b), SHC(0xf5f5), SHC(0x7e6d), SHC(0xebfa), SHC(0x7c77), SHC(0xe21e),
+ SHC(0x79bc), SHC(0xd872), SHC(0x7642), SHC(0xcf04), SHC(0x720d), SHC(0xc5e4), SHC(0x6d23), SHC(0xbd1f),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x6155), SHC(0xacdf), SHC(0x5a82), SHC(0xa57e), SHC(0x5321), SHC(0x9eab),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x42e1), SHC(0x92dd), SHC(0x3a1c), SHC(0x8df3), SHC(0x30fc), SHC(0x89be),
+ SHC(0x278e), SHC(0x8644), SHC(0x1de2), SHC(0x8389), SHC(0x1406), SHC(0x8193), SHC(0x0a0b), SHC(0x8065),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f1d), SHC(0xf0f5), SHC(0x7c77), SHC(0xe21e), SHC(0x7817), SHC(0xd3b2),
+ SHC(0x720d), SHC(0xc5e4), SHC(0x6a6e), SHC(0xb8e3), SHC(0x6155), SHC(0xacdf), SHC(0x56e3), SHC(0xa202),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x3e8b), SHC(0x9052), SHC(0x30fc), SHC(0x89be), SHC(0x22bf), SHC(0x84ce),
+ SHC(0x1406), SHC(0x8193), SHC(0x0506), SHC(0x8019), SHC(0xf5f5), SHC(0x8065), SHC(0xe707), SHC(0x8276),
+ SHC(0xd872), SHC(0x8644), SHC(0xca69), SHC(0x8bc2), SHC(0xbd1f), SHC(0x92dd), SHC(0xb0c2), SHC(0x9b7b),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e6d), SHC(0xebfa), SHC(0x79bc), SHC(0xd872), SHC(0x720d), SHC(0xc5e4),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x5a82), SHC(0xa57e), SHC(0x4b3d), SHC(0x9872), SHC(0x3a1c), SHC(0x8df3),
+ SHC(0x278e), SHC(0x8644), SHC(0x1406), SHC(0x8193), SHC(0x0000), SHC(0x8000), SHC(0xebfa), SHC(0x8193),
+ SHC(0xd872), SHC(0x8644), SHC(0xc5e4), SHC(0x8df3), SHC(0xb4c3), SHC(0x9872), SHC(0xa57e), SHC(0xa57e),
+ SHC(0x9872), SHC(0xb4c3), SHC(0x8df3), SHC(0xc5e4), SHC(0x8644), SHC(0xd872), SHC(0x8193), SHC(0xebfa),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7d8a), SHC(0xe707), SHC(0x7642), SHC(0xcf04), SHC(0x6a6e), SHC(0xb8e3),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x471d), SHC(0x9592), SHC(0x30fc), SHC(0x89be), SHC(0x18f9), SHC(0x8276),
+ SHC(0x0000), SHC(0x8000), SHC(0xe707), SHC(0x8276), SHC(0xcf04), SHC(0x89be), SHC(0xb8e3), SHC(0x9592),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x9592), SHC(0xb8e3), SHC(0x89be), SHC(0xcf04), SHC(0x8276), SHC(0xe707),
+ SHC(0x8000), SHC(0x0000), SHC(0x8276), SHC(0x18f9), SHC(0x89be), SHC(0x30fc), SHC(0x9592), SHC(0x471d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7c77), SHC(0xe21e), SHC(0x720d), SHC(0xc5e4), SHC(0x6155), SHC(0xacdf),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x30fc), SHC(0x89be), SHC(0x1406), SHC(0x8193), SHC(0xf5f5), SHC(0x8065),
+ SHC(0xd872), SHC(0x8644), SHC(0xbd1f), SHC(0x92dd), SHC(0xa57e), SHC(0xa57e), SHC(0x92dd), SHC(0xbd1f),
+ SHC(0x8644), SHC(0xd872), SHC(0x8065), SHC(0xf5f5), SHC(0x8193), SHC(0x1406), SHC(0x89be), SHC(0x30fc),
+ SHC(0x9872), SHC(0x4b3d), SHC(0xacdf), SHC(0x6155), SHC(0xc5e4), SHC(0x720d), SHC(0xe21e), SHC(0x7c77),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7b32), SHC(0xdd41), SHC(0x6d23), SHC(0xbd1f), SHC(0x56e3), SHC(0xa202),
+ SHC(0x3a1c), SHC(0x8df3), SHC(0x18f9), SHC(0x8276), SHC(0xf5f5), SHC(0x8065), SHC(0xd3b2), SHC(0x87e9),
+ SHC(0xb4c3), SHC(0x9872), SHC(0x9b7b), SHC(0xb0c2), SHC(0x89be), SHC(0xcf04), SHC(0x80e3), SHC(0xf0f5),
+ SHC(0x8193), SHC(0x1406), SHC(0x8bc2), SHC(0x3597), SHC(0x9eab), SHC(0x5321), SHC(0xb8e3), SHC(0x6a6e),
+ SHC(0xd872), SHC(0x79bc), SHC(0xfafa), SHC(0x7fe7), SHC(0x1de2), SHC(0x7c77), SHC(0x3e8b), SHC(0x6fae),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ffa), SHC(0xfd7d), SHC(0x7fe7), SHC(0xfafa), SHC(0x7fc7), SHC(0xf877),
+ SHC(0x7f9b), SHC(0xf5f5), SHC(0x7f62), SHC(0xf374), SHC(0x7f1d), SHC(0xf0f5), SHC(0x7ecb), SHC(0xee76),
+ SHC(0x7e6d), SHC(0xebfa), SHC(0x7e02), SHC(0xe980), SHC(0x7d8a), SHC(0xe707), SHC(0x7d07), SHC(0xe492),
+ SHC(0x7c77), SHC(0xe21e), SHC(0x7bda), SHC(0xdfae), SHC(0x7b32), SHC(0xdd41), SHC(0x7a7d), SHC(0xdad8),
+ SHC(0x79bc), SHC(0xd872), SHC(0x78ef), SHC(0xd610), SHC(0x7817), SHC(0xd3b2), SHC(0x7732), SHC(0xd159),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fc7), SHC(0xf877), SHC(0x7f1d), SHC(0xf0f5), SHC(0x7e02), SHC(0xe980),
+ SHC(0x7c77), SHC(0xe21e), SHC(0x7a7d), SHC(0xdad8), SHC(0x7817), SHC(0xd3b2), SHC(0x7546), SHC(0xccb4),
+ SHC(0x720d), SHC(0xc5e4), SHC(0x6e6e), SHC(0xbf47), SHC(0x6a6e), SHC(0xb8e3), SHC(0x660f), SHC(0xb2bf),
+ SHC(0x6155), SHC(0xacdf), SHC(0x5c45), SHC(0xa749), SHC(0x56e3), SHC(0xa202), SHC(0x5134), SHC(0x9d0e),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x4502), SHC(0x9432), SHC(0x3e8b), SHC(0x9052), SHC(0x37dc), SHC(0x8cd5),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f62), SHC(0xf374), SHC(0x7d8a), SHC(0xe707), SHC(0x7a7d), SHC(0xdad8),
+ SHC(0x7642), SHC(0xcf04), SHC(0x70e3), SHC(0xc3a9), SHC(0x6a6e), SHC(0xb8e3), SHC(0x62f2), SHC(0xaecc),
+ SHC(0x5a82), SHC(0xa57e), SHC(0x5134), SHC(0x9d0e), SHC(0x471d), SHC(0x9592), SHC(0x3c57), SHC(0x8f1d),
+ SHC(0x30fc), SHC(0x89be), SHC(0x2528), SHC(0x8583), SHC(0x18f9), SHC(0x8276), SHC(0x0c8c), SHC(0x809e),
+ SHC(0x0000), SHC(0x8000), SHC(0xf374), SHC(0x809e), SHC(0xe707), SHC(0x8276), SHC(0xdad8), SHC(0x8583),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ecb), SHC(0xee76), SHC(0x7b32), SHC(0xdd41), SHC(0x7546), SHC(0xccb4),
+ SHC(0x6d23), SHC(0xbd1f), SHC(0x62f2), SHC(0xaecc), SHC(0x56e3), SHC(0xa202), SHC(0x4930), SHC(0x96fd),
+ SHC(0x3a1c), SHC(0x8df3), SHC(0x29f0), SHC(0x8711), SHC(0x18f9), SHC(0x8276), SHC(0x0789), SHC(0x8039),
+ SHC(0xf5f5), SHC(0x8065), SHC(0xe492), SHC(0x82f9), SHC(0xd3b2), SHC(0x87e9), SHC(0xc3a9), SHC(0x8f1d),
+ SHC(0xb4c3), SHC(0x9872), SHC(0xa749), SHC(0xa3bb), SHC(0x9b7b), SHC(0xb0c2), SHC(0x9192), SHC(0xbf47),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e02), SHC(0xe980), SHC(0x7817), SHC(0xd3b2), SHC(0x6e6e), SHC(0xbf47),
+ SHC(0x6155), SHC(0xacdf), SHC(0x5134), SHC(0x9d0e), SHC(0x3e8b), SHC(0x9052), SHC(0x29f0), SHC(0x8711),
+ SHC(0x1406), SHC(0x8193), SHC(0xfd7d), SHC(0x8006), SHC(0xe707), SHC(0x8276), SHC(0xd159), SHC(0x88ce),
+ SHC(0xbd1f), SHC(0x92dd), SHC(0xaafa), SHC(0xa052), SHC(0x9b7b), SHC(0xb0c2), SHC(0x8f1d), SHC(0xc3a9),
+ SHC(0x8644), SHC(0xd872), SHC(0x8135), SHC(0xee76), SHC(0x8019), SHC(0x0506), SHC(0x82f9), SHC(0x1b6e),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7d07), SHC(0xe492), SHC(0x743e), SHC(0xca69), SHC(0x660f), SHC(0xb2bf),
+ SHC(0x5321), SHC(0x9eab), SHC(0x3c57), SHC(0x8f1d), SHC(0x22bf), SHC(0x84ce), SHC(0x0789), SHC(0x8039),
+ SHC(0xebfa), SHC(0x8193), SHC(0xd159), SHC(0x88ce), SHC(0xb8e3), SHC(0x9592), SHC(0xa3bb), SHC(0xa749),
+ SHC(0x92dd), SHC(0xbd1f), SHC(0x8711), SHC(0xd610), SHC(0x80e3), SHC(0xf0f5), SHC(0x809e), SHC(0x0c8c),
+ SHC(0x8644), SHC(0x278e), SHC(0x9192), SHC(0x40b9), SHC(0xa202), SHC(0x56e3), SHC(0xb6d0), SHC(0x6903),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7bda), SHC(0xdfae), SHC(0x6fae), SHC(0xc175), SHC(0x5c45), SHC(0xa749),
+ SHC(0x42e1), SHC(0x92dd), SHC(0x2528), SHC(0x8583), SHC(0x0506), SHC(0x8019), SHC(0xe492), SHC(0x82f9),
+ SHC(0xc5e4), SHC(0x8df3), SHC(0xaafa), SHC(0xa052), SHC(0x9592), SHC(0xb8e3), SHC(0x8711), SHC(0xd610),
+ SHC(0x8065), SHC(0xf5f5), SHC(0x81fe), SHC(0x1680), SHC(0x8bc2), SHC(0x3597), SHC(0x9d0e), SHC(0x5134),
+ SHC(0xb4c3), SHC(0x678e), SHC(0xd159), SHC(0x7732), SHC(0xf0f5), SHC(0x7f1d), SHC(0x118a), SHC(0x7ecb),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7a7d), SHC(0xdad8), SHC(0x6a6e), SHC(0xb8e3), SHC(0x5134), SHC(0x9d0e),
+ SHC(0x30fc), SHC(0x89be), SHC(0x0c8c), SHC(0x809e), SHC(0xe707), SHC(0x8276), SHC(0xc3a9), SHC(0x8f1d),
+ SHC(0xa57e), SHC(0xa57e), SHC(0x8f1d), SHC(0xc3a9), SHC(0x8276), SHC(0xe707), SHC(0x809e), SHC(0x0c8c),
+ SHC(0x89be), SHC(0x30fc), SHC(0x9d0e), SHC(0x5134), SHC(0xb8e3), SHC(0x6a6e), SHC(0xdad8), SHC(0x7a7d),
+ SHC(0x0000), SHC(0x7fff), SHC(0x2528), SHC(0x7a7d), SHC(0x471d), SHC(0x6a6e), SHC(0x62f2), SHC(0x5134)
+};
+
+
+/**
+ * \brief Twiddle factors are unscaled
+ * Rotation factor table, real and imaginary part interleaved, for dim1=20,dim2=20
+ */
+
+const Word16 RotVector_400[2*(400-20)] =
+{
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ff0), SHC(0xfbfb), SHC(0x7fbf), SHC(0xf7f6), SHC(0x7f6f), SHC(0xf3f4),
+ SHC(0x7efe), SHC(0xeff5), SHC(0x7e6d), SHC(0xebfa), SHC(0x7dbc), SHC(0xe804), SHC(0x7ceb), SHC(0xe414),
+ SHC(0x7bfb), SHC(0xe02b), SHC(0x7aeb), SHC(0xdc4a), SHC(0x79bc), SHC(0xd872), SHC(0x786f), SHC(0xd4a4),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x7579), SHC(0xcd2a), SHC(0x73d1), SHC(0xc980), SHC(0x720d), SHC(0xc5e4),
+ SHC(0x702b), SHC(0xc256), SHC(0x6e2d), SHC(0xbed8), SHC(0x6c13), SHC(0xbb6a), SHC(0x69de), SHC(0xb80e),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fbf), SHC(0xf7f6), SHC(0x7efe), SHC(0xeff5), SHC(0x7dbc), SHC(0xe804),
+ SHC(0x7bfb), SHC(0xe02b), SHC(0x79bc), SHC(0xd872), SHC(0x7703), SHC(0xd0e1), SHC(0x73d1), SHC(0xc980),
+ SHC(0x702b), SHC(0xc256), SHC(0x6c13), SHC(0xbb6a), SHC(0x678e), SHC(0xb4c3), SHC(0x62a0), SHC(0xae69),
+ SHC(0x5d4f), SHC(0xa861), SHC(0x579f), SHC(0xa2b1), SHC(0x5197), SHC(0x9d60), SHC(0x4b3d), SHC(0x9872),
+ SHC(0x4496), SHC(0x93ed), SHC(0x3daa), SHC(0x8fd5), SHC(0x3680), SHC(0x8c2f), SHC(0x2f1f), SHC(0x88fd),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f6f), SHC(0xf3f4), SHC(0x7dbc), SHC(0xe804), SHC(0x7aeb), SHC(0xdc4a),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x720d), SHC(0xc5e4), SHC(0x6c13), SHC(0xbb6a), SHC(0x6524), SHC(0xb18c),
+ SHC(0x5d4f), SHC(0xa861), SHC(0x54a6), SHC(0x9ffc), SHC(0x4b3d), SHC(0x9872), SHC(0x4128), SHC(0x91d3),
+ SHC(0x3680), SHC(0x8c2f), SHC(0x2b5c), SHC(0x8791), SHC(0x1fd5), SHC(0x8405), SHC(0x1406), SHC(0x8193),
+ SHC(0x080a), SHC(0x8041), SHC(0xfbfb), SHC(0x8010), SHC(0xeff5), SHC(0x8102), SHC(0xe414), SHC(0x8315),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7efe), SHC(0xeff5), SHC(0x7bfb), SHC(0xe02b), SHC(0x7703), SHC(0xd0e1),
+ SHC(0x702b), SHC(0xc256), SHC(0x678e), SHC(0xb4c3), SHC(0x5d4f), SHC(0xa861), SHC(0x5197), SHC(0x9d60),
+ SHC(0x4496), SHC(0x93ed), SHC(0x3680), SHC(0x8c2f), SHC(0x278e), SHC(0x8644), SHC(0x17fc), SHC(0x8244),
+ SHC(0x080a), SHC(0x8041), SHC(0xf7f6), SHC(0x8041), SHC(0xe804), SHC(0x8244), SHC(0xd872), SHC(0x8644),
+ SHC(0xc980), SHC(0x8c2f), SHC(0xbb6a), SHC(0x93ed), SHC(0xae69), SHC(0x9d60), SHC(0xa2b1), SHC(0xa861),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e6d), SHC(0xebfa), SHC(0x79bc), SHC(0xd872), SHC(0x720d), SHC(0xc5e4),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x5a82), SHC(0xa57e), SHC(0x4b3d), SHC(0x9872), SHC(0x3a1c), SHC(0x8df3),
+ SHC(0x278e), SHC(0x8644), SHC(0x1406), SHC(0x8193), SHC(0x0000), SHC(0x8000), SHC(0xebfa), SHC(0x8193),
+ SHC(0xd872), SHC(0x8644), SHC(0xc5e4), SHC(0x8df3), SHC(0xb4c3), SHC(0x9872), SHC(0xa57e), SHC(0xa57e),
+ SHC(0x9872), SHC(0xb4c3), SHC(0x8df3), SHC(0xc5e4), SHC(0x8644), SHC(0xd872), SHC(0x8193), SHC(0xebfa),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7dbc), SHC(0xe804), SHC(0x7703), SHC(0xd0e1), SHC(0x6c13), SHC(0xbb6a),
+ SHC(0x5d4f), SHC(0xa861), SHC(0x4b3d), SHC(0x9872), SHC(0x3680), SHC(0x8c2f), SHC(0x1fd5), SHC(0x8405),
+ SHC(0x080a), SHC(0x8041), SHC(0xeff5), SHC(0x8102), SHC(0xd872), SHC(0x8644), SHC(0xc256), SHC(0x8fd5),
+ SHC(0xae69), SHC(0x9d60), SHC(0x9d60), SHC(0xae69), SHC(0x8fd5), SHC(0xc256), SHC(0x8644), SHC(0xd872),
+ SHC(0x8102), SHC(0xeff5), SHC(0x8041), SHC(0x080a), SHC(0x8405), SHC(0x1fd5), SHC(0x8c2f), SHC(0x3680),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ceb), SHC(0xe414), SHC(0x73d1), SHC(0xc980), SHC(0x6524), SHC(0xb18c),
+ SHC(0x5197), SHC(0x9d60), SHC(0x3a1c), SHC(0x8df3), SHC(0x1fd5), SHC(0x8405), SHC(0x0405), SHC(0x8010),
+ SHC(0xe804), SHC(0x8244), SHC(0xcd2a), SHC(0x8a87), SHC(0xb4c3), SHC(0x9872), SHC(0x9ffc), SHC(0xab5a),
+ SHC(0x8fd5), SHC(0xc256), SHC(0x8515), SHC(0xdc4a), SHC(0x8041), SHC(0xf7f6), SHC(0x8193), SHC(0x1406),
+ SHC(0x88fd), SHC(0x2f1f), SHC(0x9622), SHC(0x47f2), SHC(0xa861), SHC(0x5d4f), SHC(0xbed8), SHC(0x6e2d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7bfb), SHC(0xe02b), SHC(0x702b), SHC(0xc256), SHC(0x5d4f), SHC(0xa861),
+ SHC(0x4496), SHC(0x93ed), SHC(0x278e), SHC(0x8644), SHC(0x080a), SHC(0x8041), SHC(0xe804), SHC(0x8244),
+ SHC(0xc980), SHC(0x8c2f), SHC(0xae69), SHC(0x9d60), SHC(0x9872), SHC(0xb4c3), SHC(0x88fd), SHC(0xd0e1),
+ SHC(0x8102), SHC(0xeff5), SHC(0x8102), SHC(0x100b), SHC(0x88fd), SHC(0x2f1f), SHC(0x9872), SHC(0x4b3d),
+ SHC(0xae69), SHC(0x62a0), SHC(0xc980), SHC(0x73d1), SHC(0xe804), SHC(0x7dbc), SHC(0x080a), SHC(0x7fbf),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7aeb), SHC(0xdc4a), SHC(0x6c13), SHC(0xbb6a), SHC(0x54a6), SHC(0x9ffc),
+ SHC(0x3680), SHC(0x8c2f), SHC(0x1406), SHC(0x8193), SHC(0xeff5), SHC(0x8102), SHC(0xcd2a), SHC(0x8a87),
+ SHC(0xae69), SHC(0x9d60), SHC(0x9622), SHC(0xb80e), SHC(0x8644), SHC(0xd872), SHC(0x8010), SHC(0xfbfb),
+ SHC(0x8405), SHC(0x1fd5), SHC(0x91d3), SHC(0x4128), SHC(0xa861), SHC(0x5d4f), SHC(0xc5e4), SHC(0x720d),
+ SHC(0xe804), SHC(0x7dbc), SHC(0x0c0c), SHC(0x7f6f), SHC(0x2f1f), SHC(0x7703), SHC(0x4e74), SHC(0x6524),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7ffc), SHC(0xfdfd), SHC(0x7ff0), SHC(0xfbfb), SHC(0x7fdc), SHC(0xf9f8),
+ SHC(0x7fbf), SHC(0xf7f6), SHC(0x7f9b), SHC(0xf5f5), SHC(0x7f6f), SHC(0xf3f4), SHC(0x7f3a), SHC(0xf1f4),
+ SHC(0x7efe), SHC(0xeff5), SHC(0x7eb9), SHC(0xedf7), SHC(0x7e6d), SHC(0xebfa), SHC(0x7e18), SHC(0xe9fe),
+ SHC(0x7dbc), SHC(0xe804), SHC(0x7d57), SHC(0xe60b), SHC(0x7ceb), SHC(0xe414), SHC(0x7c77), SHC(0xe21e),
+ SHC(0x7bfb), SHC(0xe02b), SHC(0x7b77), SHC(0xde39), SHC(0x7aeb), SHC(0xdc4a), SHC(0x7a57), SHC(0xda5d),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7fdc), SHC(0xf9f8), SHC(0x7f6f), SHC(0xf3f4), SHC(0x7eb9), SHC(0xedf7),
+ SHC(0x7dbc), SHC(0xe804), SHC(0x7c77), SHC(0xe21e), SHC(0x7aeb), SHC(0xdc4a), SHC(0x7919), SHC(0xd68a),
+ SHC(0x7703), SHC(0xd0e1), SHC(0x74a9), SHC(0xcb53), SHC(0x720d), SHC(0xc5e4), SHC(0x6f2f), SHC(0xc095),
+ SHC(0x6c13), SHC(0xbb6a), SHC(0x68b9), SHC(0xb666), SHC(0x6524), SHC(0xb18c), SHC(0x6155), SHC(0xacdf),
+ SHC(0x5d4f), SHC(0xa861), SHC(0x5914), SHC(0xa414), SHC(0x54a6), SHC(0x9ffc), SHC(0x5008), SHC(0x9c1b),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f9b), SHC(0xf5f5), SHC(0x7e6d), SHC(0xebfa), SHC(0x7c77), SHC(0xe21e),
+ SHC(0x79bc), SHC(0xd872), SHC(0x7642), SHC(0xcf04), SHC(0x720d), SHC(0xc5e4), SHC(0x6d23), SHC(0xbd1f),
+ SHC(0x678e), SHC(0xb4c3), SHC(0x6155), SHC(0xacdf), SHC(0x5a82), SHC(0xa57e), SHC(0x5321), SHC(0x9eab),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x42e1), SHC(0x92dd), SHC(0x3a1c), SHC(0x8df3), SHC(0x30fc), SHC(0x89be),
+ SHC(0x278e), SHC(0x8644), SHC(0x1de2), SHC(0x8389), SHC(0x1406), SHC(0x8193), SHC(0x0a0b), SHC(0x8065),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7f3a), SHC(0xf1f4), SHC(0x7ceb), SHC(0xe414), SHC(0x7919), SHC(0xd68a),
+ SHC(0x73d1), SHC(0xc980), SHC(0x6d23), SHC(0xbd1f), SHC(0x6524), SHC(0xb18c), SHC(0x5bec), SHC(0xa6ec),
+ SHC(0x5197), SHC(0x9d60), SHC(0x4646), SHC(0x9504), SHC(0x3a1c), SHC(0x8df3), SHC(0x2d3f), SHC(0x8843),
+ SHC(0x1fd5), SHC(0x8405), SHC(0x1209), SHC(0x8147), SHC(0x0405), SHC(0x8010), SHC(0xf5f5), SHC(0x8065),
+ SHC(0xe804), SHC(0x8244), SHC(0xda5d), SHC(0x85a9), SHC(0xcd2a), SHC(0x8a87), SHC(0xc095), SHC(0x90d1),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7eb9), SHC(0xedf7), SHC(0x7aeb), SHC(0xdc4a), SHC(0x74a9), SHC(0xcb53),
+ SHC(0x6c13), SHC(0xbb6a), SHC(0x6155), SHC(0xacdf), SHC(0x54a6), SHC(0x9ffc), SHC(0x4646), SHC(0x9504),
+ SHC(0x3680), SHC(0x8c2f), SHC(0x25a3), SHC(0x85a9), SHC(0x1406), SHC(0x8193), SHC(0x0203), SHC(0x8004),
+ SHC(0xeff5), SHC(0x8102), SHC(0xde39), SHC(0x8489), SHC(0xcd2a), SHC(0x8a87), SHC(0xbd1f), SHC(0x92dd),
+ SHC(0xae69), SHC(0x9d60), SHC(0xa154), SHC(0xa9db), SHC(0x9622), SHC(0xb80e), SHC(0x8d0d), SHC(0xc7b0),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7e18), SHC(0xe9fe), SHC(0x786f), SHC(0xd4a4), SHC(0x6f2f), SHC(0xc095),
+ SHC(0x62a0), SHC(0xae69), SHC(0x5321), SHC(0x9eab), SHC(0x4128), SHC(0x91d3), SHC(0x2d3f), SHC(0x8843),
+ SHC(0x17fc), SHC(0x8244), SHC(0x0203), SHC(0x8004), SHC(0xebfa), SHC(0x8193), SHC(0xd68a), SHC(0x86e7),
+ SHC(0xc256), SHC(0x8fd5), SHC(0xaff8), SHC(0x9c1b), SHC(0x9ffc), SHC(0xab5a), SHC(0x92dd), SHC(0xbd1f),
+ SHC(0x88fd), SHC(0xd0e1), SHC(0x82a9), SHC(0xe60b), SHC(0x8010), SHC(0xfbfb), SHC(0x8147), SHC(0x1209),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7d57), SHC(0xe60b), SHC(0x7579), SHC(0xcd2a), SHC(0x68b9), SHC(0xb666),
+ SHC(0x579f), SHC(0xa2b1), SHC(0x42e1), SHC(0x92dd), SHC(0x2b5c), SHC(0x8791), SHC(0x1209), SHC(0x8147),
+ SHC(0xf7f6), SHC(0x8041), SHC(0xde39), SHC(0x8489), SHC(0xc5e4), SHC(0x8df3), SHC(0xaff8), SHC(0x9c1b),
+ SHC(0x9d60), SHC(0xae69), SHC(0x8ee1), SHC(0xc41b), SHC(0x8515), SHC(0xdc4a), SHC(0x8065), SHC(0xf5f5),
+ SHC(0x8102), SHC(0x100b), SHC(0x86e7), SHC(0x2976), SHC(0x91d3), SHC(0x4128), SHC(0xa154), SHC(0x5625),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7c77), SHC(0xe21e), SHC(0x720d), SHC(0xc5e4), SHC(0x6155), SHC(0xacdf),
+ SHC(0x4b3d), SHC(0x9872), SHC(0x30fc), SHC(0x89be), SHC(0x1406), SHC(0x8193), SHC(0xf5f5), SHC(0x8065),
+ SHC(0xd872), SHC(0x8644), SHC(0xbd1f), SHC(0x92dd), SHC(0xa57e), SHC(0xa57e), SHC(0x92dd), SHC(0xbd1f),
+ SHC(0x8644), SHC(0xd872), SHC(0x8065), SHC(0xf5f5), SHC(0x8193), SHC(0x1406), SHC(0x89be), SHC(0x30fc),
+ SHC(0x9872), SHC(0x4b3d), SHC(0xacdf), SHC(0x6155), SHC(0xc5e4), SHC(0x720d), SHC(0xe21e), SHC(0x7c77),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7b77), SHC(0xde39), SHC(0x6e2d), SHC(0xbed8), SHC(0x5914), SHC(0xa414),
+ SHC(0x3daa), SHC(0x8fd5), SHC(0x1de2), SHC(0x8389), SHC(0xfbfb), SHC(0x8010), SHC(0xda5d), SHC(0x85a9),
+ SHC(0xbb6a), SHC(0x93ed), SHC(0xa154), SHC(0xa9db), SHC(0x8df3), SHC(0xc5e4), SHC(0x82a9), SHC(0xe60b),
+ SHC(0x8041), SHC(0x080a), SHC(0x86e7), SHC(0x2976), SHC(0x9622), SHC(0x47f2), SHC(0xacdf), SHC(0x6155),
+ SHC(0xc980), SHC(0x73d1), SHC(0xe9fe), SHC(0x7e18), SHC(0x0c0c), SHC(0x7f6f), SHC(0x2d3f), SHC(0x77bd),
+ SHC(0x7fff), SHC(0x0000), SHC(0x7a57), SHC(0xda5d), SHC(0x69de), SHC(0xb80e), SHC(0x5008), SHC(0x9c1b),
+ SHC(0x2f1f), SHC(0x88fd), SHC(0x0a0b), SHC(0x8065), SHC(0xe414), SHC(0x8315), SHC(0xc095), SHC(0x90d1),
+ SHC(0xa2b1), SHC(0xa861), SHC(0x8d0d), SHC(0xc7b0), SHC(0x8193), SHC(0xebfa), SHC(0x8147), SHC(0x1209),
+ SHC(0x8c2f), SHC(0x3680), SHC(0xa154), SHC(0x5625), SHC(0xbed8), SHC(0x6e2d), SHC(0xe21e), SHC(0x7c77),
+ SHC(0x080a), SHC(0x7fbf), SHC(0x2d3f), SHC(0x77bd), SHC(0x4e74), SHC(0x6524), SHC(0x68b9), SHC(0x499a)
+};
+
+/* These words are subtracted from high/low/value with a shift left by 1. */
+/* The value 0x0CCC should never be referenced, low is less/equal high */
+/* The value 0x0BBB should never be referenced, loop must break instead. */
+/* Refer to this table with indices: tab_ari_qnew[msb_high][msb_low] */
+const
+Word16 tab_ari_qnew[4][4] = { { 0x0000, 0x0CCC, 0x0CCC, 0x0CCC },
+ { 0x0000, 0x0000, 0x0CCC, 0x0CCC },
+ { 0x0BBB, 0x2000, 0x4000, 0x0CCC },
+ { 0x0BBB, 0x0BBB, 0x4000, 0x4000 }
+};
+
+/* order 8 LPF for nelp frames when non-native sampling freq inputs used with -max_band NB */
+/* used to suppress frequencies above 4kHz present at the output of filters in pre_proc() */
+
+const Word16 num_nelp_lp_fx[NELP_LP_ORDER+1] = /*Q13*/
+{
+ 727,
+ 3506,
+ 8988,
+ 15029,
+ 17732,
+ 15022,
+ 8979,
+ 3501,
+ 726
+};
+
+const Word16 den_nelp_lp_fx[NELP_LP_ORDER+1] =
+{
+ 8192,
+ 8819,
+ 21618,
+ 12167,
+ 15902,
+ 3553,
+ 3998,
+ -120,
+ 353
+};
+
+/* ACELP pulse coding */
+const Word16 hi_to_low_tmpl[10] = { 0, 0, 0, 3, 9, 5, 3, 1, 8, 8};
+const Word16 low_len[10] = { 0, 0, 8, 5, 7, 11, 13, 15, 16, 16};
+const Word32 low_mask[10] = { 0, 0, 255, 31,127, 2047, 8191, 32767, 65535, 65535};
+const Word16 indx_fact[10] = { 0, 0, 2, 172, 345, 140, 190, 223, 463, 1732};
+const Word16 index_len[3] = {0, 5, 9};
+const UWord32 index_mask_ACELP[3] = {0, 31, 511};
+
+/* HQ pre-echo reduction */
+const Word16 inv_jp2[64] =
+{
+ 16384, 10923, 8192, 6554, 5461, 4681, 4096, 3641, 3277, 2979, 2731, 2521, 2341, 2185, 2048, 1928,
+ 1820, 1725, 1638, 1560, 1489, 1425, 1365, 1311, 1260, 1214, 1170, 1130, 1092, 1057, 1024, 993,
+ 964, 936, 910, 886, 862, 840, 819, 799, 780, 762, 745, 728, 712, 697, 683, 669,
+ 655, 643, 630, 618, 607, 596, 585, 575, 565, 555, 546, 537, 529, 520, 512, 504
+};
+
diff --git a/lib_com/rom_com_fx.h b/lib_com/rom_com_fx.h
new file mode 100644
index 0000000000000000000000000000000000000000..530d2dff74b3e0d299231b4694b0f27e08a18318
--- /dev/null
+++ b/lib_com/rom_com_fx.h
@@ -0,0 +1,1240 @@
+/*====================================================================================
+ EVS Codec 3GPP TS26.452 Aug 12, 2021. Version 16.3.0
+ ====================================================================================*/
+
+#ifndef ROM_COM_FX_H
+#define ROM_COM_FX_H
+
+#include